summaryrefslogtreecommitdiffstats
path: root/install/ui/src/freeipa/util.js
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-07-03 10:31:54 +0200
committerPetr Viktorin <pviktori@redhat.com>2014-07-07 15:30:41 +0200
commitd0c12fb0c0a892f61a5a6127069737fdab2c107d (patch)
tree1af99d8e072080cba8229235f6536ddf2325b7a6 /install/ui/src/freeipa/util.js
parentafe067b1ab9b224080ca05b906e9dfd50c40c59b (diff)
downloadfreeipa-d0c12fb0c0a892f61a5a6127069737fdab2c107d.tar.gz
freeipa-d0c12fb0c0a892f61a5a6127069737fdab2c107d.tar.xz
freeipa-d0c12fb0c0a892f61a5a6127069737fdab2c107d.zip
webui: display messages contained in API responses
API responses can contain warnings in "messages" array. This patch also adds support for displaying multiple notifications at the same time in order to show the message and a status of finished operation. Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'install/ui/src/freeipa/util.js')
-rw-r--r--install/ui/src/freeipa/util.js36
1 files changed, 35 insertions, 1 deletions
diff --git a/install/ui/src/freeipa/util.js b/install/ui/src/freeipa/util.js
index 4b05b18a8..a33ebee0b 100644
--- a/install/ui/src/freeipa/util.js
+++ b/install/ui/src/freeipa/util.js
@@ -220,6 +220,27 @@ define([
}, 0);
}
+ function beautify_message(message) {
+ var els = [];
+ var lines = message.split(/\n/g);
+ var line_span;
+ for (var i=0,l=lines.length; i<l; i++) {
+ if (lines[i].charAt(0) == '\t') {
+ line_span = $('<p />', {
+ 'class': 'error-message-hinted',
+ text: lines[i].substr(1)
+ });
+ els.push(line_span);
+ } else {
+ line_span = $('<p />', {
+ text: lines[i]
+ });
+ els.push(line_span);
+ }
+ }
+ return els;
+ }
+
/**
* Module with utility functions
* @class
@@ -328,7 +349,20 @@ define([
* @param {Object} event Event object
* @param {Number} [delay=0]
*/
- emit_delayed: emit_delayed
+ emit_delayed: emit_delayed,
+
+ /**
+ * Beautify message
+ *
+ * Converts text value into array of HTML <p> elements. One additional
+ * paragraph for each line break.
+ *
+ * Multi-lined text may contain TAB character as first char of the line
+ * to hint at marking the whole line differently.
+ * @param {string} text
+ * @return {Array} array of jQuery elements
+ */
+ beautify_message: beautify_message
};
return util;