From: Marcin Haba Date: Sat, 10 Jul 2021 09:06:00 +0000 (+0200) Subject: baculum: Add jump to previous/next error navigation in messages window X-Git-Tag: Release-11.3.2~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8be427f2a6368e424057c394b9876d02cf32dff;p=thirdparty%2Fbacula.git baculum: Add jump to previous/next error navigation in messages window --- diff --git a/gui/baculum/protected/Web/JavaScript/misc.js b/gui/baculum/protected/Web/JavaScript/misc.js index 49f505936..bb2156b08 100644 --- a/gui/baculum/protected/Web/JavaScript/misc.js +++ b/gui/baculum/protected/Web/JavaScript/misc.js @@ -952,8 +952,16 @@ var MsgEnvelope = { envelope: 'msg_envelope', modal: 'msg_envelope_modal', container: 'msg_envelope_container', - content: 'msg_envelope_content' + content: 'msg_envelope_content', + nav: 'msg_envelope_nav', + nav_down: 'msg_envelope_nav_down', + nav_up: 'msg_envelope_nav_up', + line_indicator: 'msg_envelope_line_indicator' }, + css: { + wrong: 'span[rel="wrong"]' + }, + warn_err_idx: -1, issue_regex: { // @TODO: add more regexes warning: [ /Cannot find any appendable volumes/i, @@ -971,12 +979,69 @@ var MsgEnvelope = { this.set_actions(); }, set_events: function() { + var container = document.getElementById(this.ids.container); + var cont = $(container); document.getElementById(this.ids.envelope).addEventListener('click', function(e) { this.open(); - var container = document.getElementById(this.ids.container); // set scroll to the bottom container.scrollTop = container.scrollHeight; }.bind(this)); + + var content = document.getElementById(this.ids.content); + document.getElementById(this.ids.nav_up).addEventListener('click', function(e) { + var warn_err = content.querySelectorAll(this.css.wrong); + var next; + if (this.warn_err_idx < 0) { + if (warn_err.length > 0) { + this.warn_err_idx = warn_err.length - 1; + next = $(warn_err[this.warn_err_idx]); + } + } else if ((warn_err.length - 1) >= this.warn_err_idx) { + next = $(warn_err[this.warn_err_idx]).prevUntil(warn_err[this.warn_err_idx], this.css.wrong).first(); + } else { + this.warn_err_idx = warn_err.length - 1; + next = $(warn_err[this.warn_err_idx]); + } + if (next && next.length == 1) { + this.warn_err_idx = $(warn_err).index(next); + var pos = next.offset().top - cont.offset().top + cont.scrollTop(); + cont.animate({ + scrollTop: pos - 40 + }); + $('#' + this.ids.line_indicator).css({ + top: pos + 'px', + left: '1px', + display: 'block' + }); + } + }.bind(this)); + document.getElementById(this.ids.nav_down).addEventListener('click', function(e) { + if (this.warn_err_idx > -1) { + var warn_err = content.querySelectorAll(this.css.wrong); + var prev; + if ((warn_err.length - 1) < this.warn_err_idx) { + this.warn_err_idx = war_err.length - 1; + } + var prev; + if (this.warn_err_idx == 0 && warn_err.length == 1) { + prev = $(warn_err[this.warn_err_idx]); + } else { + prev = $(warn_err[this.warn_err_idx]).nextUntil(warn_err[this.warn_err_idx], this.css.wrong).first(); + } + if (prev.length == 1) { + this.warn_err_idx = $(warn_err).index(prev); + var pos = prev.offset().top - cont.offset().top + cont.scrollTop(); + cont.animate({ + scrollTop: pos - 40 + }); + $('#' + this.ids.line_indicator).css({ + top: pos + 'px', + left: '1px', + display: 'block' + }); + } + } + }.bind(this)); }, set_actions: function() { var monitor_func = function() { @@ -996,10 +1061,37 @@ var MsgEnvelope = { if (is_bottom) { container.scrollTop = container.scrollHeight; } + + // set jump to menu + var content = document.getElementById(this.ids.content); + var warn_err = content.querySelectorAll(this.css.wrong); + var nav = document.getElementById(this.ids.nav); + nav.style.display = (warn_err.length == 0) ? 'none' : 'block'; + + // hide line indicator if needed + var indicator = document.getElementById(this.ids.line_indicator); + if (warn_err.length == 0) { + indicator.style.display = 'none'; + } else if (this.warn_err_idx > -1 && (warn_err.length -1) >= this.warn_err_idx) { + var cont = $(container); + var pos = $(warn_err[this.warn_err_idx]).offset().top - cont.offset().top + cont.scrollTop(); + $('#' + this.ids.line_indicator).css({ + top: pos + 'px', + left: '1px', + display: 'block' + }); + } }.bind(this); MonitorCallsInterval.push(monitor_func); }, open: function() { + // reset indicator index + this.warn_err_idx = -1; + + // hide indicator + var indicator = document.getElementById(this.ids.line_indicator); + indicator.style.display = 'none'; + document.getElementById(this.ids.modal).style.display = 'block'; }, close: function() { @@ -1035,6 +1127,17 @@ var MsgEnvelope = { envelope.classList.replace('w3-orange', 'w3-green'); } envelope.querySelector('I').classList.remove('blink'); + + // reset indicator index + this.warn_err_idx = -1; + + // hide navigation + var nav = document.getElementById(this.ids.nav); + nav.style.display = 'none'; + + // hide indicator + var indicator = document.getElementById(this.ids.line_indicator); + indicator.style.display = 'none'; }, find_issues: function(logs) { var error = warning = false; @@ -1043,14 +1146,14 @@ var MsgEnvelope = { for (var i = 0; i < logs_len; i++) { for (var j = 0; j < this.issue_regex.warning.length; j++) { if (this.issue_regex.warning[j].test(logs[i])) { - logs[i] = '' + logs[i] + ''; + logs[i] = '' + logs[i] + ''; warning = true; continue OUTER; } } for (var j = 0; j < this.issue_regex.error.length; j++) { if (this.issue_regex.error[j].test(logs[i])) { - logs[i] = '' + logs[i] + ''; + logs[i] = '' + logs[i] + ''; error = true; continue OUTER; } diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index 5e57a3c5f..a131ef6c1 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index 6b43ae349..52e4d16c4 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -3451,3 +3451,12 @@ msgstr "filtered from _MAX_ total entries" msgid "No data available in table" msgstr "No data available in table" + +msgid "Jump to:" +msgstr "Jump to:" + +msgid "Previous error/warning" +msgstr "Previous error/warning" + +msgid "Next error/warning" +msgstr "Next error/warning" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 126c05a7d..e18c9ba4d 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index f47531b4f..a7b487939 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -3537,3 +3537,12 @@ msgstr "filtered from _MAX_ total entries" msgid "No data available in table" msgstr "No data available in table" + +msgid "Jump to:" +msgstr "Jump to:" + +msgid "Previous error/warning" +msgstr "Previous error/warning" + +msgid "Next error/warning" +msgstr "Next error/warning" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index 7f7233582..903e7182f 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index b55509c7f..08a88c153 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -3461,3 +3461,12 @@ msgstr "odfiltrowane z _MAX_ wszystkich wierszy" msgid "No data available in table" msgstr "Brak dostępnych danych w tabeli" + +msgid "Jump to:" +msgstr "Idź do:" + +msgid "Previous error/warning" +msgstr "Poprzedni błąd/ostrzeżenie" + +msgid "Next error/warning" +msgstr "Następny błąd/ostrzeżenie" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 450fb6a30..3703a8f84 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index 41b15da43..c7107610b 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -3461,3 +3461,12 @@ msgstr "filtered from _MAX_ total entries" msgid "No data available in table" msgstr "No data available in table" + +msgid "Jump to:" +msgstr "Jump to:" + +msgid "Previous error/warning" +msgstr "Previous error/warning" + +msgid "Next error/warning" +msgstr "Next error/warning" diff --git a/gui/baculum/protected/Web/Lang/ru/messages.mo b/gui/baculum/protected/Web/Lang/ru/messages.mo index 4e995a5ac..dfba24487 100644 Binary files a/gui/baculum/protected/Web/Lang/ru/messages.mo and b/gui/baculum/protected/Web/Lang/ru/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ru/messages.po b/gui/baculum/protected/Web/Lang/ru/messages.po index 2dff3a23f..d45b6f5b5 100644 --- a/gui/baculum/protected/Web/Lang/ru/messages.po +++ b/gui/baculum/protected/Web/Lang/ru/messages.po @@ -3460,3 +3460,12 @@ msgstr "filtered from _MAX_ total entries" msgid "No data available in table" msgstr "No data available in table" + +msgid "Jump to:" +msgstr "Jump to:" + +msgid "Previous error/warning" +msgstr "Previous error/warning" + +msgid "Next error/warning" +msgstr "Next error/warning" diff --git a/gui/baculum/protected/Web/Portlets/MsgEnvelope.tpl b/gui/baculum/protected/Web/Portlets/MsgEnvelope.tpl index 22b62106e..afd7638db 100644 --- a/gui/baculum/protected/Web/Portlets/MsgEnvelope.tpl +++ b/gui/baculum/protected/Web/Portlets/MsgEnvelope.tpl @@ -5,8 +5,14 @@

<%[ Messages ]%>

-
+

+				
+			
+
+ <%[ Jump to: ]%>   +   +