]> git.proxmox.com Git - proxmox-backup.git/blob - www/tape/BackupJobs.js
84b260b92c8eb76a680f5d18aa7eb81496a48c52
[proxmox-backup.git] / www / tape / BackupJobs.js
1 Ext.define('pbs-tape-backup-job-status', {
2 extend: 'Ext.data.Model',
3 fields: [
4 'id', 'store', 'pool', 'drive', 'store', 'schedule', 'comment',
5 { name: 'eject-media', type: 'boolean' },
6 { name: 'export-media-set', type: 'boolean' },
7 { name: 'latest-only', type: 'boolean' },
8 'next-run', 'last-run-upid', 'last-run-state', 'last-run-endtime',
9 {
10 name: 'duration',
11 calculate: function(data) {
12 let endtime = data['last-run-endtime'];
13 if (!endtime) return undefined;
14 let task = Proxmox.Utils.parse_task_upid(data['last-run-upid']);
15 return endtime - task.starttime;
16 },
17 },
18 ],
19 idProperty: 'id',
20 proxy: {
21 type: 'proxmox',
22 url: '/api2/json/tape/backup',
23 },
24 });
25
26 Ext.define('PBS.config.TapeBackupJobView', {
27 extend: 'Ext.grid.GridPanel',
28 alias: 'widget.pbsTapeBackupJobView',
29
30 stateful: true,
31 stateId: 'grid-tape-backup-jobs-v1',
32
33 title: gettext('Tape Backup Jobs'),
34
35 controller: {
36 xclass: 'Ext.app.ViewController',
37
38 addJob: function() {
39 let me = this;
40 Ext.create('PBS.TapeManagement.BackupJobEdit', {
41 autoShow: true,
42 listeners: {
43 destroy: function() {
44 me.reload();
45 },
46 },
47 }).show();
48 },
49
50 editJob: function() {
51 let me = this;
52 let view = me.getView();
53 let selection = view.getSelection();
54 if (!selection || selection.length < 1) {
55 return;
56 }
57
58 Ext.create('PBS.TapeManagement.BackupJobEdit', {
59 id: selection[0].data.id,
60 autoShow: true,
61 listeners: {
62 destroy: function() {
63 me.reload();
64 },
65 },
66 }).show();
67 },
68
69 openTaskLog: function() {
70 let me = this;
71 let view = me.getView();
72 let selection = view.getSelection();
73 if (selection.length < 1) return;
74
75 let upid = selection[0].data['last-run-upid'];
76 if (!upid) return;
77
78 Ext.create('Proxmox.window.TaskViewer', {
79 upid,
80 }).show();
81 },
82
83 runJob: function() {
84 let me = this;
85 let view = me.getView();
86 let selection = view.getSelection();
87 if (selection.length < 1) return;
88
89 let id = selection[0].data.id;
90 Proxmox.Utils.API2Request({
91 method: 'POST',
92 url: `/tape/backup/${id}`,
93 success: function(response, opt) {
94 Ext.create('Proxmox.window.TaskViewer', {
95 upid: response.result.data,
96 taskDone: function(success) {
97 me.reload();
98 },
99 }).show();
100 },
101 failure: function(response, opt) {
102 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
103 },
104 });
105 },
106
107 startStore: function() { this.getView().getStore().rstore.startUpdate(); },
108
109 stopStore: function() { this.getView().getStore().rstore.stopUpdate(); },
110
111 reload: function() { this.getView().getStore().rstore.load(); },
112
113 init: function(view) {
114 Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
115 },
116 },
117
118 listeners: {
119 activate: 'startStore',
120 deactivate: 'stopStore',
121 itemdblclick: 'editJob',
122 },
123
124 store: {
125 type: 'diff',
126 autoDestroy: true,
127 autoDestroyRstore: true,
128 sorters: 'id',
129 rstore: {
130 type: 'update',
131 storeid: 'pbs-tape-backup-job-status',
132 model: 'pbs-tape-backup-job-status',
133 interval: 5000,
134 },
135 },
136
137 viewConfig: {
138 trackOver: false,
139 },
140
141 tbar: [
142 {
143 xtype: 'proxmoxButton',
144 text: gettext('Add'),
145 selModel: false,
146 handler: 'addJob',
147 },
148 {
149 xtype: 'proxmoxButton',
150 text: gettext('Edit'),
151 handler: 'editJob',
152 disabled: true,
153 },
154 {
155 xtype: 'proxmoxStdRemoveButton',
156 baseurl: '/config/tape-backup-job/',
157 confirmMsg: gettext('Remove entry?'),
158 callback: 'reload',
159 },
160 '-',
161 {
162 xtype: 'proxmoxButton',
163 text: gettext('Show Log'),
164 handler: 'openTaskLog',
165 enableFn: (rec) => !!rec.data['last-run-upid'],
166 disabled: true,
167 },
168 {
169 xtype: 'proxmoxButton',
170 text: gettext('Run now'),
171 handler: 'runJob',
172 disabled: true,
173 },
174 ],
175
176 columns: [
177 {
178 header: gettext('Job ID'),
179 dataIndex: 'id',
180 renderer: Ext.String.htmlEncode,
181 maxWidth: 220,
182 minWidth: 75,
183 flex: 1,
184 sortable: true,
185 },
186 {
187 header: gettext('Datastore'),
188 dataIndex: 'store',
189 width: 120,
190 sortable: true,
191 },
192 {
193 header: gettext('Media Pool'),
194 dataIndex: 'pool',
195 width: 120,
196 sortable: true,
197 },
198 {
199 header: gettext('Drive'),
200 dataIndex: 'drive',
201 width: 120,
202 sortable: true,
203 },
204 {
205 header: gettext('Eject'),
206 dataIndex: 'eject-media',
207 renderer: Proxmox.Utils.format_boolean,
208 width: 60,
209 sortable: false,
210 },
211 {
212 header: gettext('Export'),
213 dataIndex: 'export-media-set',
214 renderer: Proxmox.Utils.format_boolean,
215 width: 60,
216 sortable: false,
217 },
218 {
219 header: gettext('Latest Only'),
220 dataIndex: 'latest-only',
221 renderer: Proxmox.Utils.format_boolean,
222 sortable: false,
223 },
224 {
225 header: gettext('Schedule'),
226 dataIndex: 'schedule',
227 maxWidth: 220,
228 minWidth: 80,
229 flex: 1,
230 sortable: true,
231 },
232 {
233 header: gettext('Last Backup'),
234 dataIndex: 'last-run-endtime',
235 renderer: PBS.Utils.render_optional_timestamp,
236 width: 150,
237 sortable: true,
238 },
239 {
240 text: gettext('Duration'),
241 dataIndex: 'duration',
242 renderer: Proxmox.Utils.render_duration,
243 width: 80,
244 },
245 {
246 header: gettext('Status'),
247 dataIndex: 'last-run-state',
248 renderer: PBS.Utils.render_task_status,
249 flex: 3,
250 },
251 {
252 header: gettext('Next Run'),
253 dataIndex: 'next-run',
254 renderer: PBS.Utils.render_next_task_run,
255 width: 150,
256 sortable: true,
257 },
258 {
259 header: gettext('Comment'),
260 dataIndex: 'comment',
261 renderer: Ext.String.htmlEncode,
262 flex: 2,
263 sortable: true,
264 },
265 ],
266
267 initComponent: function() {
268 let me = this;
269
270 me.callParent();
271 },
272 });