From d0c12fb0c0a892f61a5a6127069737fdab2c107d Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Thu, 3 Jul 2014 10:31:54 +0200 Subject: 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 --- install/ui/src/freeipa/util.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'install/ui/src/freeipa/util.js') 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', { + 'class': 'error-message-hinted', + text: lines[i].substr(1) + }); + els.push(line_span); + } else { + line_span = $('

', { + 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

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; -- cgit