]> git.proxmox.com Git - proxmox-backup.git/blob - www/tape/DriveConfig.js
ui: tape: fix eslint warnings
[proxmox-backup.git] / www / tape / DriveConfig.js
1 Ext.define('pbs-model-drives', {
2 extend: 'Ext.data.Model',
3 fields: [
4 'path', 'model', 'name', 'serial', 'vendor',
5 { name: 'changer', defaultValue: '' },
6 {
7 name: 'changer-drivenum',
8 defaultValue: 0,
9 },
10 'changer-slot',
11 ],
12 idProperty: 'name',
13 });
14
15 Ext.define('PBS.TapeManagement.DrivePanel', {
16 extend: 'Ext.grid.Panel',
17 alias: 'widget.pbsTapeDrivePanel',
18
19 controller: {
20 xclass: 'Ext.app.ViewController',
21
22 onAdd: function() {
23 let me = this;
24 Ext.create('PBS.TapeManagement.DriveEditWindow', {
25 listeners: {
26 destroy: function() {
27 me.reload();
28 },
29 },
30 }).show();
31 },
32
33 onEdit: function() {
34 let me = this;
35 let view = me.getView();
36 let selection = view.getSelection();
37 if (!selection || selection.length < 1) {
38 return;
39 }
40 Ext.create('PBS.TapeManagement.DriveEditWindow', {
41 driveid: selection[0].data.name,
42 autoLoad: true,
43 listeners: {
44 destroy: () => me.reload(),
45 },
46 }).show();
47 },
48
49 status: function(view, rI, cI, button, el, record) {
50 let me = this;
51 let drive = record.data.name;
52 PBS.Utils.driveCommand(drive, 'status', {
53 waitMsgTarget: me.getView(),
54 success: PBS.Utils.showDriveStatusWindow,
55 });
56 },
57
58 readLabel: function(view, rI, cI, button, el, record) {
59 let me = this;
60 let drive = record.data.name;
61
62 PBS.Utils.driveCommand(drive, 'read-label', {
63 waitMsgTarget: me.getView(),
64 success: PBS.Utils.showMediaLabelWindow,
65 });
66 },
67
68 volumeStatistics: function(view, rI, cI, button, el, record) {
69 let me = this;
70 let drive = record.data.name;
71 PBS.Utils.driveCommand(drive, 'volume-statistics', {
72 waitMsgTarget: me.getView(),
73 success: PBS.Utils.showVolumeStatisticsWindow,
74 });
75 },
76
77 cartridgeMemory: function(view, rI, cI, button, el, record) {
78 let me = this;
79 let drive = record.data.name;
80 PBS.Utils.driveCommand(drive, 'cartridge-memory', {
81 waitMsgTarget: me.getView(),
82 success: PBS.Utils.showCartridgeMemoryWindow,
83 });
84 },
85
86 reload: function() {
87 this.getView().getStore().rstore.load();
88 },
89
90 stopStore: function() {
91 this.getView().getStore().rstore.stopUpdate();
92 },
93
94 startStore: function() {
95 this.getView().getStore().rstore.startUpdate();
96 },
97 },
98
99 listeners: {
100 beforedestroy: 'stopStore',
101 deactivate: 'stopStore',
102 activate: 'startStore',
103 itemdblclick: 'onEdit',
104 },
105
106 store: {
107 type: 'diff',
108 rstore: {
109 type: 'update',
110 storeid: 'proxmox-tape-drives',
111 model: 'pbs-model-drives',
112 proxy: {
113 type: 'proxmox',
114 url: "/api2/json/tape/drive",
115 },
116 },
117 sorters: 'name',
118 groupField: 'changer',
119 },
120
121 features: [
122 {
123 ftype: 'grouping',
124 groupHeaderTpl: [
125 '{name:this.formatName} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})',
126 {
127 formatName: function(changer) {
128 if (changer === "") {
129 return "Standalone Drives";
130 } else {
131 return `Changer ${changer}`;
132 }
133 },
134 },
135 ],
136 },
137 ],
138
139 tbar: [
140 {
141 text: gettext('Add'),
142 xtype: 'proxmoxButton',
143 handler: 'onAdd',
144 selModel: false,
145 },
146 '-',
147 {
148 text: gettext('Edit'),
149 xtype: 'proxmoxButton',
150 handler: 'onEdit',
151 disabled: true,
152 },
153 {
154 xtype: 'proxmoxStdRemoveButton',
155 baseurl: '/api2/extjs/config/drive',
156 callback: 'reload',
157 },
158 ],
159 columns: [
160 {
161 text: gettext('Name'),
162 dataIndex: 'name',
163 flex: 1,
164 },
165 {
166 text: gettext('Path'),
167 dataIndex: 'path',
168 flex: 2,
169 },
170 {
171 text: gettext('Vendor'),
172 dataIndex: 'vendor',
173 flex: 1,
174 },
175 {
176 text: gettext('Model'),
177 dataIndex: 'model',
178 flex: 1,
179 },
180 {
181 text: gettext('Serial'),
182 dataIndex: 'serial',
183 flex: 1,
184 },
185 {
186 text: gettext('Drive Number'),
187 dataIndex: 'changer-drivenum',
188 renderer: function(value, mD, record) {
189 return record.data.changer ? value : '';
190 },
191 },
192 {
193 text: gettext('Actions'),
194 width: 140,
195 xtype: 'actioncolumn',
196 items: [
197 {
198 iconCls: 'fa fa-hdd-o',
199 handler: 'cartridgeMemory',
200 tooltip: gettext('Cartridge Memory'),
201 },
202 {
203 iconCls: 'fa fa-line-chart',
204 handler: 'volumeStatistics',
205 tooltip: gettext('Volume Statistics'),
206 },
207 {
208 iconCls: 'fa fa-tag',
209 handler: 'readLabel',
210 tooltip: gettext('Read Label'),
211 },
212 {
213 iconCls: 'fa fa-info-circle',
214 handler: 'status',
215 tooltip: gettext('Status'),
216 },
217 ],
218 },
219 ],
220 });
221