]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add jump to previous/next error navigation in messages window
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 10 Jul 2021 09:06:00 +0000 (11:06 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:25 +0000 (09:03 +0100)
12 files changed:
gui/baculum/protected/Web/JavaScript/misc.js
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Lang/ru/messages.mo
gui/baculum/protected/Web/Lang/ru/messages.po
gui/baculum/protected/Web/Portlets/MsgEnvelope.tpl

index 49f505936e750681b4ce1c8bdf76b79d8faa9930..bb2156b088fe753ea863003c4a4cab77117974b8 100644 (file)
@@ -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] = '<span class="w3-orange">' + logs[i] + '</span>';
+                                       logs[i] = '<span class="w3-orange" rel="wrong">' + logs[i] + '</span>';
                                        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] = '<span class="w3-red">' + logs[i] + '</span>';
+                                       logs[i] = '<span class="w3-red" rel="wrong">' + logs[i] + '</span>';
                                        error = true;
                                        continue OUTER;
                                }
index 5e57a3c5f16e1f9ab7eb59cce764e0ecd7398b4d..a131ef6c1ac6ccfe53af5621e5ac2b0f01a260d8 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index 6b43ae34931b32b747645426bc9168f0694c5c52..52e4d16c4f32c46812a800234a97c47c702c1d14 100644 (file)
@@ -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"
index 126c05a7d22dedd8b0a247698d42150c0e6e6181..e18c9ba4de41de002a0a051cf2575b48ee9f8c79 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index f47531b4f79ae9f000eecc99e989469b8709ec18..a7b487939ddda297beea414f6eda465a4c9153f6 100644 (file)
@@ -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"
index 7f72335829068cc0bf1dbd53b2c1e7e78cd65035..903e7182f31b6493935a24abdfd4c92668447baa 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index b55509c7f19eb94612398e76c41a1c905199e5d0..08a88c153530d5216633d67bc42e67ec933a4a68 100644 (file)
@@ -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"
index 450fb6a30181f9ef596a72b4a1998e862203a0d7..3703a8f8484f38182a7aa3304b65dc860688cef3 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index 41b15da43926f21d784a012f4f9c80a63dade04c..c7107610b37786314aa3adc8717a5593140f3658 100644 (file)
@@ -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"
index 4e995a5ac4081defe06186e320e95d02017961ac..dfba2448724312c6bb9ddba349a4e937de97aaba 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ru/messages.mo and b/gui/baculum/protected/Web/Lang/ru/messages.mo differ
index 2dff3a23f4f5de9748a52974abb9298e2b3767f0..d45b6f5b516f035bea168ddf61690d800ff7b080 100644 (file)
@@ -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"
index 22b62106eace854bed7b2f7fba2a61c77446111b..afd7638dbb0f52d94955939651565ab505c53366 100644 (file)
@@ -5,8 +5,14 @@
                        <h2><%[ Messages ]%></h2>
                </header>
                <div class="w3-container w3-margin-left w3-margin-right">
-                       <div id="msg_envelope_container" class="w3-code" style="font-size: 12px; min-height: 50px; max-height: 610px; overflow-y: scroll; overflow-x: auto;">
+                       <div id="msg_envelope_container" class="w3-code" style="font-size: 12px; min-height: 50px; max-height: 610px; overflow-y: scroll; overflow-x: auto; position: relative;">
                                <pre id="msg_envelope_content"></pre>
+                               <div id="msg_envelope_line_indicator" style="position: absolute; display: none;"><i class="fas fa-arrow-right w3-text-red"></i></div>
+                       </div>
+                       <div id="msg_envelope_nav">
+                               <span><%[ Jump to: ]%></span> &nbsp;
+                               <i id="msg_envelope_nav_down" class="fas fa-angle-down w3-large" style="cursor: pointer; user-select: none;" title="<%[ Previous error/warning ]%>"></i> &nbsp;
+                               <i id="msg_envelope_nav_up" class="fas fa-angle-up w3-large" style="cursor: pointer; user-select: none;" title="<%[ Next error/warning ]%>"></i>
                        </div>
                </div>
                <footer class="w3-container w3-center">