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-2020 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 = 'Jobs';
27$this->headTitle($title);
28
29?>
30
31<ul class="nav nav-tabs">
32   <li><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 class="active"><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<div class="container-fluid col-md-6">
42
43<div class="panel panel-default">
44   <div class="panel-heading">
45      <h3 class="panel-title">Run jobs</h3>
46   </div>
47   <div class="panel-body">
48   <div class="container-fluid">
49
50<?php
51   $form->prepare();
52   $form->setAttribute('class','form-horizontal');
53   echo $this->form()->openTag($form);
54?>
55
56<div class="row">
57
58   <div class="form-group">
59      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('job')); ?>*</label>
60      <div class="control-input col-md-6">
61         <?php echo $this->formSelect($form->get('job')); ?>
62      </div>
63   </div>
64
65   <div class="form-group">
66      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('client')); ?></label>
67      <div class="control-input col-md-6">
68         <?php echo $this->formSelect($form->get('client')); ?>
69      </div>
70   </div>
71
72   <div class="form-group">
73      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('fileset')); ?></label>
74      <div class="control-input col-md-6">
75         <?php echo $this->formSelect($form->get('fileset')); ?>
76      </div>
77   </div>
78
79   <div class="form-group">
80      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('storage')); ?></label>
81      <div class="control-input col-md-6">
82         <?php echo $this->formSelect($form->get('storage')); ?>
83      </div>
84   </div>
85
86   <div class="form-group">
87      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('pool')); ?></label>
88      <div class="control-input col-md-6">
89         <?php echo $this->formSelect($form->get('pool')); ?>
90      </div>
91   </div>
92
93   <div class="form-group">
94      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('level')); ?></label>
95      <div class="control-input col-md-6">
96         <?php echo $this->formSelect($form->get('level')); ?>
97      </div>
98   </div>
99
100   <div class="form-group">
101      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('type')); ?></label>
102      <div class="control-input col-md-6">
103         <?php echo $this->formInput($form->get('type')); ?>
104      </div>
105   </div>
106
107   <div class="form-group">
108      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('nextpool')); ?></label>
109      <div class="control-input col-md-6">
110         <?php echo $this->formSelect($form->get('nextpool')); ?>
111      </div>
112   </div>
113
114   <div class="form-group">
115      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('priority')); ?></label>
116      <div class="control-input col-md-6">
117         <?php echo $this->formInput($form->get('priority')); ?>
118      </div>
119   </div>
120
121<!--
122   <div class="form-group">
123      <label class="control-label col-md-2"><?php // echo $this->formLabel($form->get('backupformat')); ?></label>
124      <div class="control-input col-md-6">
125         <?php // echo $this->formInput($form->get('backupformat')); ?>
126      </div>
127   </div>
128-->
129
130   <div class="form-group">
131      <label class="control-label col-md-2"><?php echo $this->formLabel($form->get('when')); ?></label>
132      <div class="col-md-6">
133         <div class="input-group date" id="when-datepicker">
134            <?php echo $this->formInput($form->get('when')); ?>
135            <span class="input-group-addon">
136               <span class="glyphicon glyphicon-calendar"></span>
137            </span>
138         </div>
139      </div>
140   </div>
141
142   <div class="form-group">
143      <div class="col-md-6 col-md-offset-2">
144         <span class="text-muted"><i>(Input fields marked with * are required.)</i></span>
145      </div>
146   </div>
147
148   <div class="form-group">
149      <div class="col-md-6 col-md-offset-2">
150         <?php echo $this->formSubmit($form->get('submit')->setAttribute('class','btn btn-primary')); ?>
151      </div>
152   </div>
153
154</div>
155
156</div>
157
158<?php
159   echo $this->form()->closeTag($form);
160?>
161
162</div>
163</div>
164
165</div>
166</div>
167
168<?php endif; ?>
169
170<script type="text/javascript">
171
172   let pool_nextpool_mapping = JSON.parse('<?php echo $form->getPoolNextPoolMapping(); ?>');
173
174   function updateQueryParams(k, v) {
175      var p = [];
176      var params = [];
177
178      p['jobname'] = '<?php echo $this->jobname; ?>';
179
180      p[k] = v;
181
182      for(key in p) {
183          params.push(key + "=" + p[key]);
184      }
185
186      return params.join('&');
187   }
188
189   function hasNextPoolOption() {
190      return $('#level').selectpicker('val') == "VirtualFull" ||
191         $('#type').val() == "Copy" ||
192         $('#type').val() == "Migrate"
193   }
194
195   $('#job').change(function(event) {
196      window.location.href = window.location.pathname + '?' + updateQueryParams('jobname', this.value);
197   });
198
199   $('#pool').change(function(event) {
200      if(hasNextPoolOption()) {
201         let nextpool = pool_nextpool_mapping[$('#pool').selectpicker('val')];
202
203         if(nextpool) {
204            $('#nextpool').selectpicker('val', nextpool);
205         }
206      }
207   });
208
209   $('#level').change(function() {
210      if(hasNextPoolOption()) {
211         $("#nextpool").parents(".form-group").fadeIn();
212         $('#pool').change();
213      } else {
214         $("#nextpool").parents(".form-group").hide();
215         $('#nextpool').selectpicker('val', '');
216      }
217   });
218
219   $(function() {
220      $('#when-datepicker').datetimepicker({
221         format: 'YYYY-MM-DD HH:mm:ss',
222         sideBySide: true
223      });
224
225      // This will enable/disable the Next Pool select based on the Level value on load
226      $('#level').change();
227   });
228
229</script>
230