1<?php
2
3/**
4 *
5 * bareos-webui - Bareos Web-Frontend
6 *
7 * @link   https://github.com/bareos/bareos for the canonical source repository
8 * @copyright   Copyright (c) 2013-2019 Bareos GmbH & Co. KG (http://www.bareos.org/)
9 * @license   GNU Affero General Public License (http://www.gnu.org/licenses/)
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Affero General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Affero General Public License for more details.
20 *
21 * You should have received a copy of the GNU Affero General Public License
22 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 *
24 */
25
26$title = 'Job details';
27$this->headTitle($title);
28
29?>
30
31<ul class="nav nav-tabs">
32   <li class="active"><a href="<?php echo $this->url('job', array('action'=>'index')); ?>"><?php echo $this->translate('Show'); ?></a></li>
33   <li><a href="<?php echo $this->url('job', array('action'=>'actions')); ?>"><?php echo $this->translate('Actions'); ?></a></li>
34   <li><a href="<?php echo $this->url('job', array('action'=>'run')); ?>"><?php echo $this->translate('Run'); ?></a></li>
35</ul>
36
37<br />
38
39<?php if($this->acl_alert) : echo $this->ACLAlert($this->invalid_commands); elseif(!$this->acl_alert) : ?>
40
41<!-- Job -->
42<div class="row">
43
44<div class="col-md-12">
45
46<div class="panel panel-default">
47
48<div class="panel-heading">
49<h3 class="panel-title"><?php echo $this->translate("Job"); ?></h3>
50</div>
51
52<div class="panel-body">
53
54<table class="table table-no-bordered table-hover" id="jobdetails">
55
56<thead class="bg-primary">
57   <th><?php echo $this->translate("Job ID"); ?></th>
58   <th><?php echo $this->translate("Job name"); ?></th>
59   <th><?php echo $this->translate("Client"); ?></th>
60   <th><?php echo $this->translate("Type"); ?></th>
61   <th><?php echo $this->translate("Level"); ?></th>
62   <th><?php echo $this->translate("Files"); ?></th>
63   <th><?php echo $this->translate("Bytes"); ?></th>
64   <th><?php echo $this->translate("Errors"); ?></th>
65   <th><?php echo $this->translate("Status"); ?></th>
66   <th><?php echo $this->translate("Actions"); ?></th>
67</thead>
68
69</table>
70
71</div>
72</div>
73</div>
74</div>
75
76<div class="row">
77
78   <div class="col-md-8">
79      <div class="panel panel-default">
80         <div class="panel-heading">
81            <h3 class="panel-title"><?php echo $this->translate("Messages"); ?></h3>
82         </div>
83         <div class="panel-body">
84            <table class="table table-no-bordered table-hover" id="joblog">
85               <thead class="bg-primary">
86                  <th><?php echo $this->translate("Timestamp"); ?></th>
87                  <th><?php echo $this->translate("Message"); ?></th>
88               </thead>
89            </table>
90         </div>
91      </div>
92   </div>
93
94   <div class="col-md-4">
95      <div class="panel panel-default">
96         <div class="panel-heading">
97            <h3 class="panel-title"><?php echo $this->translate("Used Volumes"); ?></h3>
98         </div>
99         <div class="panel-body">
100            <table class="table table-no-bordered table-hover" id="jobmedia">
101               <thead class="bg-primary">
102                  <th><?php echo $this->translate("Volume"); ?></th>
103               </thead>
104            </table>
105         </div>
106      </div>
107   </div>
108
109</div>
110
111
112<?php
113   echo $this->headScript()->prependFile($this->basePath() . '/js/custom-functions.js');
114   echo $this->headLink()->prependStylesheet($this->basePath() . '/css/bootstrap-table.min.css');
115   echo $this->headScript()->prependFile($this->basePath() . '/js/bootstrap-table-locale-all.min.js');
116   echo $this->headScript()->prependFile($this->basePath() . '/js/bootstrap-table-cookie.min.js');
117   echo $this->headScript()->prependFile($this->basePath() . '/js/bootstrap-table.min.js');
118?>
119
120<!-- modal-001 start -->
121<div id="modal-001" class="modal fade modal-001" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
122  <div class="modal-dialog modal-md">
123    <div class="modal-content">
124   <div class="modal-header">
125   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
126   <h4 class="modal-title" id="myModalLabel"><?php echo $this->translate("Failed to retrieve data from Bareos director"); ?></h4>
127      </div>
128      <div class="modal-body">
129   <p><?php echo $this->translate("Error message received from director:"); ?></p>
130   <p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
131      </div>
132      <div class="modal-footer">
133         <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
134      </div>
135    </div>
136  </div>
137</div>
138<!-- modal-001 end -->
139
140<script>
141
142   var jobdetails = null;
143   var joblog = null;
144   var jobmedia = null;
145
146   function detailFormatterJobDetails(index, row) {
147      var html = [];
148      html.push('<div class="container-fluid">');
149      html.push('<table class="table table-bordered">');
150      html.push('<tr>');
151      html.push('<th><?php echo addslashes($this->translate("Fileset")); ?></th>');
152      html.push('<td><a href="<?php echo $this->basePath() . '/fileset/details/'; ?>' + row.filesetid + '">' + row.fileset +'</a></td>');
153      html.push('</tr>');
154      html.push('<tr>');
155      html.push('<th><?php echo addslashes($this->translate("Pool")); ?></th>');
156      html.push('<td><a href="<?php echo $this->basePath() . '/pool/details/'; ?>' + row.poolname + '">' + row.poolname + '</a></td>');
157      html.push('</tr>');
158      html.push('<tr>');
159      html.push('<th><?php echo addslashes($this->translate("Scheduled")); ?></th>');
160      html.push('<td>' + row.schedtime + '</td>');
161      html.push('</tr>');
162      html.push('<tr>');
163      html.push('<th><?php echo addslashes($this->translate("Start")); ?></th>');
164      html.push('<td>' + row.starttime + '</td>');
165      html.push('</tr>');
166      html.push('<tr>');
167      html.push('<th><?php echo addslashes($this->translate("End")); ?></th>');
168      html.push('<td>' + row.endtime + '</td>');
169      html.push('</tr>');
170      html.push('</table>');
171      html.push('</div>');
172      return html.join('');
173   }
174
175   function getJobDetails() {
176      jobdetails = $('#jobdetails').bootstrapTable({
177         locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
178         url: '<?php echo $this->url('job', array('action' => 'getData'), null) . '?data=details&jobid='.$this->jobid; ?>',
179         method: 'get',
180         dataType: 'json',
181         detailView: true,
182         detailFormatter: 'detailFormatterJobDetails',
183         columns: [
184            {
185               field: 'jobid',
186            },
187            {
188               field: 'name',
189               formatter: function(value) {
190                  return '<a href="<?php echo $this->basePath() . '/job/index?jobname='; ?>'+value+'">'+value+'</a>';
191               }
192            },
193            {
194               field: 'client',
195               formatter: function(value) {
196                  return '<a href="<?php echo $this->basePath() . '/client/details/'; ?>'+value+'">'+value+'</a>';
197               }
198            },
199            {
200               field: 'type',
201               formatter: function(value) {
202                  return formatJobType(value);
203               }
204            },
205            {
206               field: 'level',
207               formatter: function(value) {
208                  return formatJobLevel(value);
209               }
210            },
211            {
212               field: 'jobfiles',
213            },
214            {
215               field: 'jobbytes',
216               formatter: function(value) {
217                  return formatBytes(value);
218               }
219            },
220            {
221               field: 'joberrors',
222            },
223            {
224               field: 'jobstatus',
225               formatter: function(value) {
226                  return formatJobStatus(value);
227               }
228            },
229            {
230               field: 'action',
231               formatter: function(value, row, index) {
232                  if(row.type == 'B') {
233                     switch(row.jobstatus) {
234                        case 'T':
235                        case 'W':
236                           return '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath() . '/job/index?action=rerun&jobid='; ?>'+row.jobid+'" title="<?php echo $this->translate("Rerun"); ?>" id="btn-1"><span class="glyphicon glyphicon-repeat"></span></a>&nbsp;<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath(); ?>/restore/?mergefilesets=1&mergejobs=1&client='+row.client+'&jobid='+row.jobid+'" title="<?php echo $this->translate("Restore"); ?>" id="btn-1"><span class="glyphicon glyphicon-import"></span></a>';
237                        case 'E':
238                        case 'e':
239                        case 'f':
240                        case 'A':
241                           return '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath() . '/job/index?action=rerun&jobid='; ?>'+row.jobid+'" title="<?php echo $this->translate("Rerun"); ?>" id="btn-1"><span class="glyphicon glyphicon-repeat"></span></a>';
242                        case 'F':
243                        case 'S':
244                        case 'm':
245                        case 'M':
246                        case 's':
247                        case 'j':
248                        case 'c':
249                        case 'd':
250                        case 't':
251                        case 'p':
252                        case 'q':
253                        case 'C':
254                        case 'R':
255                        case 'l':
256                           return '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" href="<?php echo $this->basePath() . '/job/cancel/'; ?>'+row.jobid+'" title="<?php echo $this->translate("Cancel"); ?>" id="btn-1"><span class="glyphicon glyphicon-trash"></span></a>';
257                     }
258                  }
259                  return '';
260               }
261            }
262         ]
263      });
264   }
265
266   function getJobLog() {
267      joblog = $('#joblog').bootstrapTable({
268         locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
269         cookie: <?php echo $_SESSION['bareos']['dt_statesave']; ?>,
270         cookieIdTable: 'job_table_job_log',
271         url: '<?php echo $this->url('job', array('action' => 'getData'), null) . '?data=logs&jobid='.$this->jobid; ?>',
272         method: 'get',
273         dataType: 'json',
274         pagination : true,
275         sidePagination: 'client',
276         pageList: [ <?php echo $_SESSION['bareos']['dt_lengthmenu']; ?> ],
277         pageSize: <?php echo $_SESSION['bareos']['dt_pagelength']; ?>,
278         search: true,
279         sortName: 'time',
280         sortOrder: 'desc',
281         columns: [
282            {
283               field: 'time',
284               sortable: true,
285            },
286            {
287               field: 'logtext',
288               formatter: function(value) {
289                  var msg = (value).replace(/\n/g, "<br />");
290                  if(msg.search("Error") > 0) {
291                     return msg.replace(/Error/g, '<span class="bg-danger text-danger">Error</span>');
292                  }
293                  else if(msg.search("error") > 0) {
294                     return msg.replace(/error/g, '<span class="bg-danger text-danger">error</span>');
295                  }
296                  else if(msg.search("Warning") > 0) {
297                     return msg.replace(/Warning/g, '<span class="bg-warning text-warning">Warning</span>');
298                  }
299                  else {
300                     return msg;
301                  }
302               }
303            }
304         ]
305      });
306   }
307
308   function getJobMedia() {
309      jobmedia = $('#jobmedia').bootstrapTable({
310         locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
311         cookie: <?php echo $_SESSION['bareos']['dt_statesave']; ?>,
312         cookieIdTable: 'job_table_job_media',
313         url: '<?php echo $this->url('job', array('action' => 'getData'), null) . '?data=jobmedia&jobid='.$this->jobid; ?>',
314         method: 'get',
315         dataType: 'json',
316         pagination : true,
317         sidePagination: 'client',
318         pageList: [ <?php echo $_SESSION['bareos']['dt_lengthmenu']; ?> ],
319         pageSize: <?php echo $_SESSION['bareos']['dt_pagelength']; ?>,
320         search: true,
321         sortName: 'volumename',
322         sortOrder: 'asc',
323         columns: [
324            {
325               field: 'volumename',
326               sortable: true,
327               formatter: function(value) {
328                  return '<a href="<?php echo $this->basePath() . '/media/details/'; ?>' + value + '">' + value + '</a>';
329               }
330            }
331         ]
332      });
333   }
334
335   $(document).ready(function() {
336
337      setDtTextDomain('<?php echo $this->basePath() . '/js/locale'; ?>');
338      setDtLocale('<?php echo $_SESSION['bareos']['locale']; ?>');
339
340      getJobDetails();
341      getJobLog();
342      getJobMedia();
343
344   });
345
346   $('#joblog').on('load-error.bs.table', function(status, res) {
347      $("#modal-001").modal();
348   });
349
350</script>
351
352<?php endif; ?>
353