From: Marcin Haba Date: Sun, 28 Jul 2019 17:48:05 +0000 (+0200) Subject: baculum: Implement graphical status client X-Git-Tag: Release-9.6.0~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61a63c4492bb493427d6f26b00d6491ec0be9535;p=thirdparty%2Fbacula.git baculum: Implement graphical status client --- diff --git a/gui/baculum/protected/Web/JavaScript/misc.js b/gui/baculum/protected/Web/JavaScript/misc.js index 1aed579482..833a85591b 100644 --- a/gui/baculum/protected/Web/JavaScript/misc.js +++ b/gui/baculum/protected/Web/JavaScript/misc.js @@ -792,11 +792,7 @@ var W3SideBar = { } }; -W3Tabs = { - css: { - tab_btn: 'tab_btn', - tab_item: 'tab_item' - }, +W3TabsCommon = { open: function(btn_id, item_id) { var tab_items = document.getElementsByClassName(this.css.tab_item); for (var i = 0; i < tab_items.length; i++) { @@ -808,12 +804,35 @@ W3Tabs = { } var tab_btns = document.getElementsByClassName(this.css.tab_btn); for (var i = 0; i < tab_btns.length; i++) { - tab_btns[i].className = 'w3-bar-item w3-button ' + this.css.tab_btn; - if (tab_btns[i].id === btn_id) { - tab_btns[i].className += ' w3-gray'; + if (tab_btns[i].id === btn_id && !tab_btns[i].classList.contains(this.css.tab_item_hover)) { + tab_btns[i].classList.add(this.css.tab_item_hover); + } else if (tab_btns[i].classList.contains(this.css.tab_item_hover)) { + tab_btns[i].classList.remove(this.css.tab_item_hover); } } } +}; + +W3Tabs = { + css: { + tab_btn: 'tab_btn', + tab_item: 'tab_item', + tab_item_hover: 'w3-grey' + }, + open: function(btn_id, item_id) { + W3TabsCommon.open.call(this, btn_id, item_id); + } +}; + +W3SubTabs = { + css: { + tab_btn: 'subtab_btn', + tab_item: 'subtab_item', + tab_item_hover: 'w3-border-red' + }, + open: function(btn_id, item_id) { + W3TabsCommon.open.call(this, btn_id, item_id); + } } function get_url_param (name) { diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index b1878a3061..7173c91755 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 0a85e88947..9349787355 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -2224,3 +2224,69 @@ msgstr "Go to job with jobid %jobid" msgid "Go to job %job" msgstr "Go to job %job" + +msgid "Graphical status" +msgstr "Graphical status" + +msgid "Text status" +msgstr "Text status" + +msgid "Uname:" +msgstr "Uname:" + +msgid "Started time:" +msgstr "Started time:" + +msgid "Plugins:" +msgstr "Plugins:" + +msgid "Bandwidth limit:" +msgstr "Bandwidth limit:" + +msgid "No limit" +msgstr "No limit" + +msgid "Debug:" +msgstr "Debug:" + +msgid "No debug" +msgstr "No debug" + +msgid "Job bytes:" +msgstr "Job bytes:" + +msgid "Job files:" +msgstr "Job files:" + +msgid "Average speed:" +msgstr "Average speed:" + +msgid "Processing file:" +msgstr "Processing file:" + +msgid "Read bytes:" +msgstr "Read bytes:" + +msgid "Examined files:" +msgstr "Examined files:" + +msgid "Running jobs" +msgstr "Running jobs" + +msgid "Job errors:" +msgstr "Job errors:" + +msgid "Type:" +msgstr "Type:" + +msgid "Refresh interval (sec.):" +msgstr "Refresh interval (sec.):" + +msgid "To disable refreshing please type 0." +msgstr "To disable refreshing please type 0." + +msgid "No jobs running" +msgstr "No jobs running" + +msgid "Graphical client status is supported for Bacula clients version 9.0 and greater." +msgstr "Graphical client status is supported for Bacula clients version 9.0 and greater." diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index ee5c26e500..55728b5164 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 0bf2f2120f..7296bb8ea3 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -2310,3 +2310,69 @@ msgstr "Go to job with jobid %jobid" msgid "Go to job %job" msgstr "Go to job %job" + +msgid "Graphical status" +msgstr "Graphical status" + +msgid "Text status" +msgstr "Text status" + +msgid "Uname:" +msgstr "Uname:" + +msgid "Started time:" +msgstr "Started time:" + +msgid "Plugins:" +msgstr "Plugins:" + +msgid "Bandwidth limit:" +msgstr "Bandwidth limit:" + +msgid "No limit" +msgstr "No limit" + +msgid "Debug:" +msgstr "Debug:" + +msgid "No debug" +msgstr "No debug" + +msgid "Job bytes:" +msgstr "Job bytes:" + +msgid "Job files:" +msgstr "Job files:" + +msgid "Average speed:" +msgstr "Average speed:" + +msgid "Processing file:" +msgstr "Processing file:" + +msgid "Read bytes:" +msgstr "Read bytes:" + +msgid "Examined files:" +msgstr "Examined files:" + +msgid "Running jobs" +msgstr "Running jobs" + +msgid "Job errors:" +msgstr "Job errors:" + +msgid "Type:" +msgstr "Type:" + +msgid "Refresh interval (sec.):" +msgstr "Refresh interval (sec.):" + +msgid "To disable refreshing please type 0." +msgstr "To disable refreshing please type 0." + +msgid "No jobs running" +msgstr "No jobs running" + +msgid "Graphical client status is supported for Bacula clients version 9.0 and greater." +msgstr "Graphical client status is supported for Bacula clients version 9.0 and greater." diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index 8c3c23b8a2..31e122c609 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 338a5d9306..693bd1ceaa 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -2231,3 +2231,69 @@ msgstr "Przejdź do zadania z jobid %jobid" msgid "Go to job %job" msgstr "Przejdź do zadania %job" + +msgid "Graphical status" +msgstr "Status graficzny" + +msgid "Text status" +msgstr "Status tekstowy" + +msgid "Uname:" +msgstr "Uname:" + +msgid "Started time:" +msgstr "Czas uruchomienia:" + +msgid "Plugins:" +msgstr "Wtyczki:" + +msgid "Bandwidth limit:" +msgstr "Limit transferu:" + +msgid "No limit" +msgstr "Bez limitu" + +msgid "Debug:" +msgstr "Debug:" + +msgid "No debug" +msgstr "Bez debugu" + +msgid "Job bytes:" +msgstr "Ilość bajtów zadania:" + +msgid "Job files:" +msgstr "Ilość plików zadania:" + +msgid "Average speed:" +msgstr "Średnia prędkość:" + +msgid "Processing file:" +msgstr "Przetwarzany plik:" + +msgid "Read bytes:" +msgstr "Przeczytanych bajtów:" + +msgid "Examined files:" +msgstr "Przeczytanych plików:" + +msgid "Running jobs" +msgstr "Uruchomione zadania" + +msgid "Job errors:" +msgstr "Błędy zadania:" + +msgid "Type:" +msgstr "Typ:" + +msgid "Refresh interval (sec.):" +msgstr "Interwał odświeżania (sek.):" + +msgid "To disable refreshing please type 0." +msgstr "Aby wyłączyć odświeżanie proszę wypisać 0." + +msgid "No jobs running" +msgstr "Nie ma uruchomionych zadań" + +msgid "Graphical client status is supported for Bacula clients version 9.0 and greater." +msgstr "Graficzny status klienta jest wspierany dla klientów Bacula w wersji 9.0 i większych." diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index d9b0e1719d..42de8261d5 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 fb06dc2f2e..6800b72660 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -2239,3 +2239,69 @@ msgstr "Go to job with jobid %jobid" msgid "Go to job %job" msgstr "Go to job %job" + +msgid "Graphical status" +msgstr "Graphical status" + +msgid "Text status" +msgstr "Text status" + +msgid "Uname:" +msgstr "Uname:" + +msgid "Started time:" +msgstr "Started time:" + +msgid "Plugins:" +msgstr "Plugins:" + +msgid "Bandwidth limit:" +msgstr "Bandwidth limit:" + +msgid "No limit" +msgstr "No limit" + +msgid "Debug:" +msgstr "Debug:" + +msgid "No debug" +msgstr "No debug" + +msgid "Job bytes:" +msgstr "Job bytes:" + +msgid "Job files:" +msgstr "Job files:" + +msgid "Average speed:" +msgstr "Average speed:" + +msgid "Processing file:" +msgstr "Processing file:" + +msgid "Read bytes:" +msgstr "Read bytes:" + +msgid "Examined files:" +msgstr "Examined files:" + +msgid "Running jobs" +msgstr "Running jobs" + +msgid "Job errors:" +msgstr "Job errors:" + +msgid "Type:" +msgstr "Type:" + +msgid "Refresh interval (sec.):" +msgstr "Refresh interval (sec.):" + +msgid "To disable refreshing please type 0." +msgstr "To disable refreshing please type 0." + +msgid "No jobs running" +msgstr "No jobs running" + +msgid "Graphical client status is supported for Bacula clients version 9.0 and greater." +msgstr "Graphical client status is supported for Bacula clients version 9.0 and greater." diff --git a/gui/baculum/protected/Web/Pages/ClientView.page b/gui/baculum/protected/Web/Pages/ClientView.page index 9b981a22b7..24c31e77bd 100644 --- a/gui/baculum/protected/Web/Pages/ClientView.page +++ b/gui/baculum/protected/Web/Pages/ClientView.page @@ -24,15 +24,389 @@ OnClick="status" CssClass="w3-button w3-green w3-margin-bottom" CausesValidation="false" - ClientSide.OnLoading="$('#status_storage_loading').show();" - ClientSide.OnSuccess="$('#status_storage_loading').hide();" + ClientSide.OnLoading="$('#status_client_loading').show();" + ClientSide.OnSuccess="$('#status_client_loading').hide();$('#show_client_container').hide();$('#status_client_container').show();oGraphicalClientStatus.set_refresh_timeout(document.getElementById('status_client_refresh_interval').value);" > <%=Prado::localize('Status client')%>   - -
-
-
+ +
+
+
+
+
+
diff --git a/gui/baculum/protected/Web/Pages/ClientView.php b/gui/baculum/protected/Web/Pages/ClientView.php index f90e7355ee..665fbbd099 100644 --- a/gui/baculum/protected/Web/Pages/ClientView.php +++ b/gui/baculum/protected/Web/Pages/ClientView.php @@ -55,7 +55,7 @@ class ClientView extends BaculumWebPage { true ); if ($clientshow->error === 0) { - $this->ClientLog->Text = implode(PHP_EOL, $clientshow->output); + $this->ShowLog->Text = implode(PHP_EOL, $clientshow->output); } $client = $this->getModule('api')->get( array('clients', $clientid) @@ -109,10 +109,54 @@ class ClientView extends BaculumWebPage { } public function status($sender, $param) { - $status = $this->getModule('api')->get( + $raw_status = $this->getModule('api')->get( array('clients', $this->getClientId(), 'status') )->output; - $this->ClientLog->Text = implode(PHP_EOL, $status); + $this->ClientLog->Text = implode(PHP_EOL, $raw_status); + + $query_str = '?name=' . rawurlencode($this->getClientName()) . '&type=header'; + $graph_status = $this->getModule('api')->get( + array('status', 'client', $query_str), + ); + $client_status = array( + 'header' => array(), + 'running' => array(), + 'version' => $this->getClientVersion($raw_status) + ); + if ($graph_status->error === 0) { + $client_status['header'] = $graph_status->output; + } + + $query_str = '?name=' . rawurlencode($this->getClientName()) . '&type=running'; + $graph_status = $this->getModule('api')->get( + array('status', 'client', $query_str), + ); + if ($graph_status->error === 0) { + $client_status['running'] = $graph_status->output; + } + + $query_str = '?output=json'; + $show = $this->getModule('api')->get( + array('clients', $this->getClientId(), 'show', $query_str), + ); + if ($show->error === 0) { + $client_status['show'] = $show->output; + } + + $this->getCallbackClient()->callClientFunction('init_graphical_client_status', array($client_status)); + } + + private function getClientVersion($output) { + $version = array('major' => 0, 'minor' => 0, 'release' => 0); + for ($i = 0; $i < count($output); $i++) { + if (preg_match('/^[\w\d\s:.\-]+Version:\s+(?P\d+)\.(?P\d+)\.(?P\d+)\s+\(/', $output[$i], $match) === 1) { + $version['major'] = intval($match['major']); + $version['minor'] = intval($match['minor']); + $version['release'] = intval($match['release']); + break; + } + } + return $version; } } ?> diff --git a/gui/baculum/themes/Baculum-v2/css/baculum.css b/gui/baculum/themes/Baculum-v2/css/baculum.css index 4b0207cc99..414f1e7c49 100644 --- a/gui/baculum/themes/Baculum-v2/css/baculum.css +++ b/gui/baculum/themes/Baculum-v2/css/baculum.css @@ -227,3 +227,15 @@ ul.new_element_menu li { ul.new_element_menu li a { text-decoration: none; } + +table.status_table tr { + height: 40px; +} + +table.status_table td:nth-of-type(1) { + width: 35%; +} + +table.status_table td, table.status_table td svg { + vertical-align: middle; +}