}.bind(this)
});
},
+
+ isWindowOpen: function() {
+ return !(this.window.style.display === 'none');
+ },
resetSize : function() {
if(this.isConfigurationOpen()) {
msgid "Verify option:"
msgstr "Verify option:"
+
+msgid "Running jobs:"
+msgstr "Running jobs:"
+
+msgid "Finished jobs:"
+msgstr "Finished jobs:"
+
msgid "Verify option:"
msgstr "Opcja weryfikacji:"
+msgid "Running jobs:"
+msgstr "Uruchomione zadania:"
+
+msgid "Finished jobs:"
+msgstr "Zakończone zadania:"
+
<com:TActiveLinkButton ID="Workspace" Text="<%[ Workspace ]%>" Attributes.onclick="PanelWindow.show('container');" />
<com:TActiveLinkButton ID="Graphs" Text="<%[ Graphs ]%>" Attributes.onclick="PanelWindow.show('graphs');" />
</div>
+ <com:Application.Portlets.TrayBar ID="TrayBar" />
</div>
<div id="container">
<div id="menu-left">
</div>
<div id="bottom"></div>
<script type="text/javascript">
+ var oMonitor;
document.observe("dom:loaded", function() {
<%=(!is_null($this->openWindow) ?
'$("' . $this->openWindow . '").click(); window.history.pushState("", "", "/");'
--- /dev/null
+<?php
+/**
+ * Bacula® - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2015 Marcin Haba
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The main 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.
+ *
+ * Bacula® is a registered trademark of Kern Sibbald.
+ */
+
+class Monitor extends BaculumPage {
+ public function onInit($param) {
+ parent::onInit($param);
+ $_SESSION['monitor_data'] = array('jobs' => array(), 'running_jobs' => array(), 'terminated_jobs' => array());
+ $_SESSION['monitor_data']['jobs'] = $this->Application->getModule('api')->get(array('jobs'))->output;
+
+ $runningJobStates = $this->Application->getModule('misc')->getRunningJobStates();
+
+ for ($i = 0; $i < count($_SESSION['monitor_data']['jobs']); $i++) {
+ if (in_array($_SESSION['monitor_data']['jobs'][$i]->jobstatus, $runningJobStates)) {
+ $_SESSION['monitor_data']['running_jobs'][] = $_SESSION['monitor_data']['jobs'][$i];
+ } else {
+ $_SESSION['monitor_data']['terminated_jobs'][] = $_SESSION['monitor_data']['jobs'][$i];
+ }
+ }
+ echo json_encode($_SESSION['monitor_data']);
+ exit();
+ }
+}
+
+?>
<configuration>
<authorization>
<allow pages="BaculumError,Requirements" users="*" />
- <allow pages="Home,RestoreWizard,API.*" roles="admin,user" />
+ <allow pages="Home,RestoreWizard,API.*,Monitor" roles="admin,user" />
<allow pages="ConfigurationWizard" roles="admin" />
<deny users="*" />
</authorization>
* Bacula® is a registered trademark of Kern Sibbald.
*/
+Prado::using('System.Web.UI.ActiveControls.TActiveHiddenField');
Prado::using('System.Web.UI.ActiveControls.TActivePanel');
Prado::using('Application.Portlets.Portlets');
$this->Priority->Text = ($jobdata->priorjobid == 0) ? self::DEFAULT_JOB_PRIORITY : $jobdata->priorjobid;
$this->DeleteButton->Visible = true;
- $this->CancelButton->Visible = in_array($jobdata->jobstatus, $runningJobStates);
+ $this->CancelButton->Visible = $this->RefreshStart->Value = in_array($jobdata->jobstatus, $runningJobStates);
}
public function status($sender, $param) {
+ $refreshStart = false;
+ for ($i = 0; $i < count($_SESSION['monitor_data']['running_jobs']); $i++) {
+ if ($_SESSION['monitor_data']['running_jobs'][$i]->jobid == $this->JobID->Text) {
+ $refreshStart = true;
+ break;
+ }
+ }
+ $this->RefreshStart->Value = $refreshStart;
+
$joblog = $this->Application->getModule('api')->get(array('joblog', $this->JobID->Text))->output;
$this->Estimation->Text = is_array($joblog) ? implode(PHP_EOL, $joblog) : Prado::localize("Output for selected job is not available yet or you do not have enabled logging job logs to catalog database. For watching job log there is need to add to the job Messages resource next directive: console = all, !skipped, !saved");
}
<com:TCallback ID="ReloadJobs" OnCallback="Page.JobWindow.prepareData" ClientSide.OnComplete="SlideWindow.getObj('JobWindow').setLoadRequest();" />
<script type="text/javascript">
var job_callback_func = function() {
- var mainForm = Prado.Validation.getForm();
- var callback = <%=$this->ReloadJobs->ActiveControl->Javascript%>;
- if (Prado.Validation.managers[mainForm].getValidatorsWithError('JobGroup').length == 0) {
- SlideWindow.getObj('JobWindow').markAllChecked(false);
- callback.dispatch();
+ /*
+ * Check if Job list window is open and if any checkbox from actions is not checked.
+ * If yes, then is possible to refresh Job list window.
+ */
+ if(SlideWindow.getObj('JobWindow').isWindowOpen() === true && SlideWindow.getObj('JobWindow').areActionsOpen() === false) {
+ var mainForm = Prado.Validation.getForm();
+ var callback = <%=$this->ReloadJobs->ActiveControl->Javascript%>;
+ if (Prado.Validation.managers[mainForm].getValidatorsWithError('JobGroup').length == 0) {
+ SlideWindow.getObj('JobWindow').markAllChecked(false);
+ callback.dispatch();
+ }
}
}
</script>
<com:BActiveButton ID="Status" Text="<%[ Job status ]%>" CausesValidation="false" OnClick="status" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();" CssClass="bbutton" />
<com:TActiveLabel ID="DeleteButton"><com:BActiveButton ID="Delete" Text="<%[ Delete job ]%>" CausesValidation="false" OnClick="delete" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();" CssClass="bbutton" /> </com:TActiveLabel>
<com:TActiveLabel ID="CancelButton"><com:BActiveButton ID="Cancel" Text="<%[ Cancel job ]%>" CausesValidation="false" OnClick="cancel" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();" CssClass="bbutton" /> </com:TActiveLabel>
- <com:BActiveButton ID="Run" Text="<%[ Run job again ]%>" ValidationGroup="JobGroup" CausesValidation="true" OnClick="run_again" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();"/>
+ <com:BActiveButton ID="Run" Text="<%[ Run job again ]%>" ValidationGroup="JobGroup" CausesValidation="true" OnClick="run_again" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();oMonitor();"/>
</div>
+ <com:TCallback ID="RefreshStatus" OnCallback="status" ClientSide.OnComplete="status_callback_timeout = setTimeout('status_callback_func()', 10000);" />
+ <script type="text/javascript">
+ var status_callback_timeout;
+ var status_prev = false;
+ var status_callback_func = function() {
+ if(status_callback_timeout) {
+ clearTimeout(status_callback_timeout);
+ }
+ if($('<%=$this->getID()%>configuration').visible() && ($('<%=$this->RefreshStart->ClientID%>').value === 'true' || status_prev === true)) {
+ status_prev = ($('<%=$this->RefreshStart->ClientID%>').value === 'true');
+ var callback = <%=$this->RefreshStatus->ActiveControl->Javascript%>;
+ oMonitor();
+ callback.dispatch();
+ } else {
+ status_prev = false;
+ }
+ }
+ </script>
+ <com:TActiveHiddenField ID="RefreshStart" />
<div class="text small"><%[ Console status ]%></div>
<div class="field-full" style="min-height: 166px">
<com:TActiveTextBox ID="Estimation" TextMode="MultiLine" CssClass="textbox-auto" Style="height: 145px" ReadOnly="true" />
<prop:ClientSide.OnComplete>
ConfigurationWindow.getObj('JobWindow').show();
ConfigurationWindow.getObj('JobWindow').progress(false);
+ status_callback_func();
</prop:ClientSide.OnComplete>
</com:TCallback>
</com:TContent>
<div class="field"><com:TActiveCheckBox ID="Accurate" AutoPostBack="false" /></div>
</com:TPanel>
<com:TPanel ID="EstimateLine" CssClass="button">
- <com:Application.Portlets.BActiveButton ID="Estimate" Text="<%[ Estimate job ]%>" OnClick="estimate" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobRunWindow').progress(false);jobrun_callback_func();" />
+ <com:Application.Portlets.BActiveButton ID="Estimate" Text="<%[ Estimate job ]%>" OnClick="estimate" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobRunWindow').progress(false);jobrun_callback_func();oMonitor();" />
</com:TPanel>
</com:TActivePanel>
</com:TContent>
--- /dev/null
+
+<?php
+/**
+ * Bacula® - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2015 Marcin Haba
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The main 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.
+ *
+ * Bacula® is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('Application.Portlets.Portlets');
+
+class TrayBar extends Portlets {
+
+}
--- /dev/null
+<div id="tray_bar">
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/gearwheel-icon.png" alt="<%[ Running jobs: ]%>" /> <%[ Running jobs: ]%> <span class="bold" id="running_jobs"></span>
+ <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/check-icon.png" alt="<%[ Finished jobs: ]%>" /> <%[ Finished jobs: ]%> <span class="bold" id="finished_jobs"></span>
+</div>
+<script type="text/javascript">
+ var oMonitor;
+ var default_refresh_interval = 60000;
+ var default_fast_refresh_interval = 10000;
+ var timeout_handler;
+ document.observe("dom:loaded", function() {
+ oMonitor = function() {
+ return new Ajax.Request('<%=$this->Service->constructUrl("Monitor")%>', {
+ onSuccess: function(response) {
+ if (timeout_handler) {
+ clearTimeout(timeout_handler);
+ }
+ var jobs = (response.responseText).evalJSON();
+ if (jobs.running_jobs.length > 0) {
+ refreshInterval = default_fast_refresh_interval;
+ } else {
+ refreshInterval = default_refresh_interval;
+ }
+ job_callback_func();
+ $('running_jobs').update(jobs.running_jobs.length);
+ $('finished_jobs').update(jobs.terminated_jobs.length);
+ timeout_handler = setTimeout("oMonitor()", refreshInterval);
+ }
+ });
+ };
+ oMonitor();
+ });
+ </script>
<url ServiceParameter="ConfigurationWizard" pattern="wizard/" />
<url ServiceParameter="RestoreWizard" pattern="restore/" />
<url ServiceParameter="BaculumError" pattern="message/{error}/" parameters.error="\d+" />
+ <url ServiceParameter="Monitor" pattern="monitor/" />
<!-- START Directors -->
<url ServiceParameter="API.Directors" pattern="directors/" />
<!-- END Directors -->
z-index: 100;
}
-#directors, #panel_switcher {
+#directors, #panel_switcher, #tray_bar {
float: right;
font-size: 12px;
}
font-weight: bold;
}
+#tray_bar {
+ margin: 2px 30px 2px 0;
+}
+
+#tray_bar img {
+ float: none;
+ margin: 0;
+ padding: auto 12px;
+}
+
+#tray_bar span{
+ font-size: 14px;
+}
+
div.configuration {
width: 45%;
height: 575px;