</div>
</com:TForm>
<div id="small" class="w3-hide-large"></div>
- <div id="error_message_box" class="w3-modal" style="display: none">
- <div class="w3-modal-content w3-card-4 w3-animate-zoom" style="width:600px">
- <header class="w3-container w3-red">
- <span onclick="document.getElementById('error_message_box').style.display='none'" class="w3-button w3-display-topright">×</span>
- <h2><%[ Error ]%></h2>
- </header>
- <div class="w3-panel w3-padding">
- <p><strong><%[ Error code: ]%></strong> <span id="error_message_error_code"></span></p>
- <p><strong><%[ Message: ]%></strong> <span id="error_message_error_msg"></span></p>
- </div>
- <footer class="w3-container w3-center">
- <button type="button" class="w3-button w3-section w3-red" onclick="document.getElementById('error_message_box').style.display='none'"><i class="fa fa-check"></i> <%[ OK ]%></button>
- </footer>
- </div>
- </div>
-<script type="text/javascript">
+<com:Application.Web.Portlets.ErrorMessageBox />
+<com:Application.Web.Portlets.ResourceMonitor />
+<com:Application.Web.Portlets.MsgEnvelope Visible="<%=$this->User->isInRole(WebUserRoles::ADMIN)%>" />
+<script>
var is_small = $('#small').is(':visible');
-
-var oMonitor;
-var default_refresh_interval = 60000;
-var default_fast_refresh_interval = 10000;
-var timeout_handler;
-var last_callback_time = 0;
-var callback_time_offset = 0;
-var oData;
-var MonitorCalls = [];
-var MonitorCallsInterval = [];
$(function() {
if (is_small) {
W3SideBar.close();
}
- oMonitor = function() {
- return $.ajax('<%=$this->Service->constructUrl("Monitor")%>', {
- dataType: 'json',
- type: 'post',
- data: {
- 'params': (typeof(MonitorParams) == 'object' ? MonitorParams : []),
- 'use_limit' : <%=$this->Service->getRequestedPagePath() == "Dashboard" ? '0' : '1'%>,
- },
- beforeSend: function() {
- last_callback_time = new Date().getTime();
- },
- success: function(response) {
- if (timeout_handler) {
- clearTimeout(timeout_handler);
- }
- if (response && response.hasOwnProperty('error') && response.error.error !== 0) {
- show_error(response.error.output, response.error.error);
- }
-
- oData = response;
- if ('<%=get_class($this->Service->getRequestedPage())%>' == 'Dashboard') {
- Statistics.grab_statistics(oData, JobStatus.get_states());
- Dashboard.set_text({
- js_sum_title: '<%[ Job status summary ]%>'
- });
- Dashboard.update_all(Statistics);
- }
-
- if (oData.running_jobs.length > 0) {
- refreshInterval = callback_time_offset + default_fast_refresh_interval;
- } else {
- refreshInterval = default_refresh_interval;
- }
- if (typeof(job_callback_func) == 'function') {
- job_callback_func();
- }
- document.getElementById('running_jobs').textContent = oData.running_jobs.length;
- timeout_handler = setTimeout("oMonitor()", refreshInterval);
-
- var calls_len = MonitorCalls.length;
- for (var i = 0; i < calls_len; i++) {
- MonitorCalls[i]();
- }
- var calls_interval_len = MonitorCallsInterval.length;
- for (var i = 0; i < calls_interval_len; i++) {
- MonitorCallsInterval[i]();
- }
- if (calls_len > 0) {
- Formatters.set_formatters();
- }
- MonitorCalls = [];
- }
- });
- };
- oMonitor();
});
-function show_error(output, error) {
- var err_box = document.getElementById('error_message_box');
- var err_code = document.getElementById('error_message_error_code');
- var err_msg = document.getElementById('error_message_error_msg');
- err_code.textContent = error;
- err_msg.innerHTML = output;
- err_box.style.display = 'block';
-}
- </script>
- <com:Application.Web.Portlets.MsgEnvelope Visible="<%=$this->User->isInRole(WebUserRoles::ADMIN)%>" />
+</script>
</body>
</html>
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2021 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('Application.Web.Portlets.Portlets');
+
+/**
+ * Error message box - displays global errors and problems.
+ *
+ * @author Marcin Haba <marcin.haba@bacula.pl>
+ * @category Control
+ * @package Baculum Web
+ */
+class ErrorMessageBox extends Portlets {
+}
--- /dev/null
+<div id="error_message_box" class="w3-modal" style="display: none">
+ <div class="w3-modal-content w3-card-4 w3-animate-zoom" style="width:600px">
+ <header class="w3-container w3-red">
+ <span onclick="document.getElementById('error_message_box').style.display='none'" class="w3-button w3-display-topright">×</span>
+ <h2><%[ Error ]%></h2>
+ </header>
+ <div class="w3-panel w3-padding">
+ <p><strong><%[ Error code: ]%></strong> <span id="error_message_error_code"></span></p>
+ <p><strong><%[ Message: ]%></strong> <span id="error_message_error_msg"></span></p>
+ </div>
+ <footer class="w3-container w3-center">
+ <button type="button" class="w3-button w3-section w3-red" onclick="document.getElementById('error_message_box').style.display='none'"><i class="fa fa-check"></i> <%[ OK ]%></button>
+ </footer>
+ </div>
+</div>
+<script>
+function show_error(output, error) {
+ var err_box = document.getElementById('error_message_box');
+ var err_code = document.getElementById('error_message_error_code');
+ var err_msg = document.getElementById('error_message_error_msg');
+ err_code.textContent = error;
+ err_msg.innerHTML = output;
+ err_box.style.display = 'block';
+}
+</script>
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2021 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('Application.Web.Portlets.Portlets');
+
+/**
+ * Resource monitor.
+ *
+ * @author Marcin Haba <marcin.haba@bacula.pl>
+ * @category Control
+ * @package Baculum Web
+ */
+class ResourceMonitor extends Portlets {
+}
--- /dev/null
+<script>
+var oMonitor;
+var default_refresh_interval = 60000;
+var default_fast_refresh_interval = 10000;
+var timeout_handler;
+var last_callback_time = 0;
+var callback_time_offset = 0;
+var oData;
+var MonitorCalls = [];
+var MonitorCallsInterval = [];
+$(function() {
+ oMonitor = function() {
+ return $.ajax('<%=$this->Service->constructUrl("Monitor")%>', {
+ dataType: 'json',
+ type: 'post',
+ data: {
+ 'params': (typeof(MonitorParams) == 'object' ? MonitorParams : []),
+ 'use_limit' : <%=$this->Service->getRequestedPagePath() == "Dashboard" ? '0' : '1'%>,
+ },
+ beforeSend: function() {
+ last_callback_time = new Date().getTime();
+ },
+ success: function(response) {
+ if (timeout_handler) {
+ clearTimeout(timeout_handler);
+ }
+ if (response && response.hasOwnProperty('error') && response.error.error !== 0) {
+ show_error(response.error.output, response.error.error);
+ }
+
+ oData = response;
+ if ('<%=get_class($this->Service->getRequestedPage())%>' == 'Dashboard') {
+ Statistics.grab_statistics(oData, JobStatus.get_states());
+ Dashboard.set_text({
+ js_sum_title: '<%[ Job status summary ]%>'
+ });
+ Dashboard.update_all(Statistics);
+ }
+
+ if (oData.running_jobs.length > 0) {
+ refreshInterval = callback_time_offset + default_fast_refresh_interval;
+ } else {
+ refreshInterval = default_refresh_interval;
+ }
+ if (typeof(job_callback_func) == 'function') {
+ job_callback_func();
+ }
+ document.getElementById('running_jobs').textContent = oData.running_jobs.length;
+ timeout_handler = setTimeout("oMonitor()", refreshInterval);
+
+ var calls_len = MonitorCalls.length;
+ for (var i = 0; i < calls_len; i++) {
+ MonitorCalls[i]();
+ }
+ var calls_interval_len = MonitorCallsInterval.length;
+ for (var i = 0; i < calls_interval_len; i++) {
+ MonitorCallsInterval[i]();
+ }
+ if (calls_len > 0) {
+ Formatters.set_formatters();
+ }
+ MonitorCalls = [];
+ }
+ });
+ };
+ oMonitor();
+});
+</script>