From c4a69191a31e0364d615e8cb8b1f7645784f0377 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 22 Feb 2016 11:14:41 +0100 Subject: [PATCH 1/2] JS: implement Icinga.Utils.padString() refs #10625 --- public/js/icinga/utils.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index dea9c37ed..8c69485e1 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -386,6 +386,24 @@ }[c]; } ); + }, + + /** + * Pad a string with another one + * + * @param {String} str the string to pad + * @param {String} padding the string to use for padding + * @param {Number} minLength the minimum length of the result + * + * @returns {String} the padded string + */ + padString: function(str, padding, minLength) { + str = String(str); + padding = String(padding); + while (str.length < minLength) { + str = padding + str; + } + return str; } }; From a2a96be8c950ab5df0f943ccfd492cdb45bd4309 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 22 Feb 2016 11:24:19 +0100 Subject: [PATCH 2/2] Display ISO date and time when a connection was lost refs #10625 --- public/js/icinga/loader.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 8a6bf7ffe..323ca3069 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -681,11 +681,17 @@ req.addToHistory = false; } else { if (this.failureNotice === null) { + var now = new Date(); + var padString = this.icinga.utils.padString; this.failureNotice = this.createNotice( 'error', - 'The connection to the Icinga web server was lost at ' + - this.icinga.utils.timeShort() + - '.', + 'The connection to the Icinga web server was lost at ' + + now.getFullYear() + + '-' + padString(now.getMonth() + 1, 0, 2) + + '-' + padString(now.getDate(), 0, 2) + + ' ' + padString(now.getHours(), 0, 2) + + ':' + padString(now.getMinutes(), 0, 2) + + '.', true );