}
if ($show_error === true && $resource->error != 0) {
- $url = $this->Service->constructUrl('BaculumError', (array)$resource, false);
- header("Location: $url");
- // write all logs before exiting, otherwise they will be lost
- $this->getModule('log')->collectLogs(null);
- exit();
+ $headers = $this->Request->getHeaders(CASE_UPPER);
+ if (!isset($headers['X-REQUESTED-WITH']) || $headers['X-REQUESTED-WITH'] !== 'XMLHttpRequest') {
+ // it is non-ajax request - redirect it to error page
+ $url = $this->Service->constructUrl('BaculumError', (array)$resource, false);
+ header("Location: $url");
+ // write all logs before exiting, otherwise they will be lost
+ $this->getModule('log')->collectLogs(null);
+ exit();
+ }
}
$this->Application->getModule('logging')->log(
msgid "Close Menu"
msgstr "Close Menu"
+
+msgid "Error code:"
+msgstr "Error code:"
+
+msgid "Message:"
+msgstr "Message:"
+
msgid "Close Menu"
msgstr "Close Menu"
+
+msgid "Error code:"
+msgstr "Error code:"
+
+msgid "Message:"
+msgstr "Message:"
+
msgid "Close Menu"
msgstr "Zamknij Menu"
+
+msgid "Error code:"
+msgstr "Kod błędu:"
+
+msgid "Message:"
+msgstr "Wiadomość:"
msgid "Close Menu"
msgstr "Fechar menu"
+
+msgid "Error code:"
+msgstr "Error code:"
+
+msgid "Message:"
+msgstr "Message:"
+
</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">
var is_small = $('#small').is(':visible');
if (timeout_handler) {
clearTimeout(timeout_handler);
}
+ if (response && response.hasOwnProperty('error') && response.error.error !== 0) {
+ 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 = response.error.error;
+ err_msg.textContent = response.error.output;
+ err_box.style.display = 'block';
+ }
+
oData = response;
if ('<%=get_class($this->Service->getRequestedPage())%>' == 'Dashboard') {
Statistics.grab_statistics(oData, JobStatus.get_states());
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<com:THead Title="Baculum - Bacula Web Interface" ShortcutIcon="<%=$this->getPage()->getTheme()->getBaseUrl()%>/favicon.ico" />
<body id="message-body">
- <com:TContentPlaceHolder ID="Message" />
+ <com:TForm>
+ <com:BClientScript ScriptUrl=<%~ ../JavaScript/fontawesome-all.js %> />
+ <com:TContentPlaceHolder ID="Message" />
+ </com:TForm>
</body>
</html>
-<%@ MasterClass="Application.Web.Layouts.MessageBox" Theme="Baculum-v1"%>
+<%@ MasterClass="Application.Web.Layouts.MessageBox" Theme="Baculum-v2"%>
<com:TContent ID="Message">
-<div id="message-box">
+<div class="w3-container w3-red">
<h2><%[ Baculum problem ]%></h2>
+</div>
+<div class="w3-container">
<h3>Error <%=$this->error%> - <%=$this->output%></h3>
<hr />
- <p class="center">
- <a href="<%=$this->Service->constructUrl('Dashboard')%>"><%[ TRY AGAIN ]%></a>
+ <div class="w3-center">
+ <a class="w3-button w3-green" href="<%=$this->Service->constructUrl('Dashboard')%>"><i class="fa fa-redo-alt"></i> <%[ TRY AGAIN ]%></a>
<%[ or run ]%>
- <a href="<%=$this->Service->constructUrl('WebConfigWizard')%>"><%[ Baculum Initial Wizard ]%></a>
- </p>
+ <a class="w3-button w3-green" href="<%=$this->Service->constructUrl('WebConfigWizard')%>"><i class="fa fa-reply"></i> <%[ Baculum Initial Wizard ]%></a>
+ </div>
</div>
<script type="text/javascript">
window.history.pushState('page', 'Title', '<%=$this->Service->constructUrl('Dashboard')%>');
'terminated_jobs' => array(),
'pools' => array(),
'jobtotals' => array(),
- 'dbsize' => array()
+ 'dbsize' => array(),
+ 'error' => array('error' => 0, 'output' => '')
);
$web_config = $this->getModule('web_config')->getConfig();
$job_limit = $web_config['baculum']['max_jobs'];
}
+ $error = null;
$params = $this->Request->contains('params') ? $this->Request['params'] : array();
if (in_array('jobs', $params)) {
$job_params = array('jobs');
if ($this->Request->contains('use_limit') && $this->Request['use_limit'] == 1) {
$job_params[] = '?limit=' . $job_limit;
}
- $monitor_data['jobs'] = $this->getModule('api')->get($job_params)->output;
+ $result = $this->getModule('api')->get($job_params);
+ if ($result->error === 0) {
+ $monitor_data['jobs'] = $result->output;
+ } else {
+ $error = $result;
+ }
}
- $monitor_data['running_jobs'] = $this->getModule('api')->get(array('jobs', '?jobstatus=CR'))->output;
- if (in_array('clients', $params)) {
- $monitor_data['clients'] = $this->getModule('api')->get(array('clients'))->output;
+ if (!$error) {
+ $result = $this->getModule('api')->get(array('jobs', '?jobstatus=CR'));
+ if ($result->error === 0) {
+ $monitor_data['running_jobs'] = $result->output;
+ } else {
+ $error = $result;
+ }
}
- if (in_array('pools', $params)) {
- $monitor_data['pools'] = $this->getModule('api')->get(array('pools'))->output;
+ if (!$error && in_array('clients', $params)) {
+ $result = $this->getModule('api')->get(array('clients'));
+ if ($result->error === 0) {
+ $monitor_data['clients'] = $result->output;
+ } else {
+ $error = $result;
+ }
}
- if (in_array('job_totals', $params)) {
- $monitor_data['jobtotals'] = $this->getModule('api')->get(array('jobs', 'totals'))->output;
+ if (!$error && in_array('pools', $params)) {
+ $result = $this->getModule('api')->get(array('pools'));
+ if ($result->error === 0) {
+ $monitor_data['pools'] = $result->output;
+ } else {
+ $error = $result;
+ }
}
- if ($_SESSION['admin'] && in_array('dbsize', $params)) {
- $monitor_data['dbsize'] = $this->getModule('api')->get(array('dbsize'))->output;
+ if (!$error && in_array('job_totals', $params)) {
+ $result = $this->getModule('api')->get(array('jobs', 'totals'));
+ if ($result->error === 0) {
+ $monitor_data['jobtotals'] = $result->output;
+ } else {
+ $error = $result;
+ }
+ }
+ if (!$error && $_SESSION['admin'] && in_array('dbsize', $params)) {
+ $result = $this->getModule('api')->get(array('dbsize'));
+ if ($result->error === 0) {
+ $monitor_data['dbsize'] = $result->output;
+ } else {
+ $error = $result;
+ }
}
$running_job_states = $this->Application->getModule('misc')->getRunningJobStates();
}
}
}
+ if (is_object($error)) {
+ $monitor_data['error'] = $error;
+ }
+
echo json_encode($monitor_data);
exit();
}