]>
git.proxmox.com Git - proxmox-backup.git/blob - www/tape/DriveConfig.js
1 Ext
.define('pbs-model-drives', {
2 extend
: 'Ext.data.Model',
3 fields
: ['path', 'model', 'name', 'serial', 'vendor', 'changer', 'changer-slot'],
7 Ext
.define('PBS.TapeManagement.DrivePanel', {
8 extend
: 'Ext.grid.Panel',
9 alias
: 'widget.pbsTapeDrivePanel',
12 xclass
: 'Ext.app.ViewController',
16 Ext
.create('PBS.TapeManagement.DriveEditWindow', {
27 let view
= me
.getView();
28 let selection
= view
.getSelection();
29 if (!selection
|| selection
.length
< 1) {
32 Ext
.create('PBS.TapeManagement.DriveEditWindow', {
33 driveid
: selection
[0].data
.name
,
36 destroy
: () => me
.reload(),
41 status: function(view
, rI
, cI
, button
, el
, record
) {
43 let drive
= record
.data
.name
;
44 me
.driveCommand(drive
, 'status', function(response
) {
46 for (const [key
, val
] of Object
.entries(response
.result
.data
)) {
47 lines
.push(`${key}: ${val}`);
50 let txt
= lines
.join('<br>');
53 title
: gettext('Label Information'),
60 catalog: function(view
, rI
, cI
, button
, el
, record
) {
62 let drive
= record
.data
.name
;
63 me
.driveCommand(drive
, 'catalog', function(response
) {
64 Ext
.create('Proxmox.window.TaskViewer', {
65 upid
: response
.result
.data
,
70 readLabel: function(view
, rI
, cI
, button
, el
, record
) {
72 let drive
= record
.data
.name
;
73 me
.driveCommand(drive
, 'read-label', function(response
) {
75 for (const [key
, val
] of Object
.entries(response
.result
.data
)) {
76 lines
.push(`${key}: ${val}`);
79 let txt
= lines
.join('<br>');
82 title
: gettext('Label Information'),
89 volumeStatistics: function(view
, rI
, cI
, button
, el
, record
) {
91 let drive
= record
.data
.name
;
92 me
.driveCommand(drive
, 'volume-statistics', function(response
) {
93 Ext
.create('Ext.window.Window', {
94 title
: gettext('Volume Statistics'),
104 data
: response
.result
.data
,
113 text
: gettext('Name'),
118 text
: gettext('Value'),
129 cartridgeMemory: function(view
, rI
, cI
, button
, el
, record
) {
131 let drive
= record
.data
.name
;
132 me
.driveCommand(drive
, 'cartridge-memory', function(response
) {
133 Ext
.create('Ext.window.Window', {
134 title
: gettext('Cartridge Memory'),
144 data
: response
.result
.data
,
153 text
: gettext('Name'),
158 text
: gettext('Value'),
169 driveCommand: function(driveid
, command
, callback
, params
, method
) {
171 let view
= me
.getView();
172 params
= params
|| {};
173 method
= method
|| 'GET';
174 Proxmox
.Utils
.API2Request({
175 url
: `/api2/extjs/tape/drive/${driveid}/${command}`,
179 success: function(response
) {
182 failure: function(response
) {
183 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
188 labelMedia: function(button
, event
, record
) {
190 let driveid
= record
.data
.name
;
192 Ext
.create('PBS.TapeManagement.LabelMediaWindow', {
198 this.getView().getStore().rstore
.load();
201 stopStore: function() {
202 this.getView().getStore().rstore
.stopUpdate();
205 startStore: function() {
206 this.getView().getStore().rstore
.startUpdate();
211 beforedestroy
: 'stopStore',
212 deactivate
: 'stopStore',
213 activate
: 'startStore',
214 itemdblclick
: 'onEdit',
221 storeid
: 'proxmox-tape-drives',
222 model
: 'pbs-model-drives',
225 url
: "/api2/json/tape/drive",
233 text
: gettext('Add'),
234 xtype
: 'proxmoxButton',
240 text
: gettext('Edit'),
241 xtype
: 'proxmoxButton',
246 xtype
: 'proxmoxStdRemoveButton',
247 baseurl
: '/api2/extjs/config/drive',
252 text
: gettext('Label Media'),
253 xtype
: 'proxmoxButton',
254 handler
: 'labelMedia',
255 iconCls
: 'fa fa-barcode',
261 text
: gettext('Name'),
266 text
: gettext('Path'),
271 text
: gettext('Vendor'),
276 text
: gettext('Model'),
281 text
: gettext('Serial'),
286 text
: gettext('Changer'),
288 dataIndex
: 'changer',
289 renderer: function(value
, mD
, record
) {
293 let drive_num
= record
.data
['changer-drivenum'] || 0;
294 let drive_text
= gettext("Drive {0}");
295 return `${value} (${Ext.String.format(drive_text, drive_num)})`;
297 sorter: function(a
, b
) {
298 let ch_a
= a
.data
.changer
|| "";
299 let ch_b
= b
.data
.changer
|| "";
300 let num_a
= a
.data
['changer-drivenum'] || 0;
301 let num_b
= b
.data
['changer-drivenum'] || 0;
302 return ch_a
> ch_b
? -1 : ch_a
< ch_b
? 1 : num_b
- num_a
;
306 text
: gettext('Actions'),
308 xtype
: 'actioncolumn',
311 iconCls
: 'fa fa-hdd-o',
312 handler
: 'cartridgeMemory',
313 tooltip
: gettext('Cartridge Memory'),
316 iconCls
: 'fa fa-line-chart',
317 handler
: 'volumeStatistics',
318 tooltip
: gettext('Volume Statistics'),
321 iconCls
: 'fa fa-tag',
322 handler
: 'readLabel',
323 tooltip
: gettext('Read Label'),
326 iconCls
: 'fa fa-book',
328 tooltip
: gettext('Catalog'),
331 iconCls
: 'fa fa-info-circle',
333 tooltip
: gettext('Status'),