]>
Commit | Line | Data |
---|---|---|
dec31475 DC |
1 | Ext.define('pbs-model-media-pool', { |
2 | extend: 'Ext.data.Model', | |
6c924497 DM |
3 | fields: [ |
4 | 'name', 'allocation', 'retention', 'template', 'encrypt', 'comment', | |
5 | { | |
6 | name: 'encryption', | |
7 | type: 'bool', | |
8 | calculate: function(data) { | |
9 | return !!data.encrypt; | |
10 | }, | |
11 | }, | |
12 | ], | |
dec31475 DC |
13 | idProperty: 'name', |
14 | }); | |
15 | ||
16 | Ext.define('PBS.TapeManagement.PoolPanel', { | |
17 | extend: 'Ext.grid.Panel', | |
18 | alias: 'widget.pbsMediaPoolPanel', | |
19 | ||
20 | controller: { | |
21 | xclass: 'Ext.app.ViewController', | |
22 | ||
23 | onAdd: function() { | |
24 | let me = this; | |
25 | Ext.create('PBS.TapeManagement.PoolEditWindow', { | |
26 | listeners: { | |
27 | destroy: function() { | |
28 | me.reload(); | |
29 | }, | |
30 | }, | |
31 | }).show(); | |
32 | }, | |
33 | ||
34 | onEdit: function() { | |
35 | let me = this; | |
36 | let view = me.getView(); | |
37 | let selection = view.getSelection(); | |
38 | if (!selection || selection.length < 1) { | |
39 | return; | |
40 | } | |
41 | Ext.create('PBS.TapeManagement.PoolEditWindow', { | |
42 | poolid: selection[0].data.name, | |
43 | autoLoad: true, | |
44 | listeners: { | |
45 | destroy: () => me.reload(), | |
46 | }, | |
47 | }).show(); | |
48 | }, | |
49 | ||
50 | reload: function() { | |
51 | this.getView().getStore().rstore.load(); | |
52 | }, | |
53 | ||
54 | stopStore: function() { | |
55 | this.getView().getStore().rstore.stopUpdate(); | |
56 | }, | |
57 | ||
58 | startStore: function() { | |
59 | this.getView().getStore().rstore.startUpdate(); | |
60 | }, | |
bec357e2 DC |
61 | |
62 | init: function(view) { | |
63 | Proxmox.Utils.monStoreErrors(view, view.getStore().rstore); | |
64 | }, | |
dec31475 DC |
65 | }, |
66 | ||
67 | listeners: { | |
68 | beforedestroy: 'stopStore', | |
69 | deactivate: 'stopStore', | |
70 | activate: 'startStore', | |
71 | itemdblclick: 'onEdit', | |
72 | }, | |
73 | ||
74 | store: { | |
75 | type: 'diff', | |
76 | rstore: { | |
77 | type: 'update', | |
78 | storeid: 'proxmox-tape-media-pools', | |
79 | model: 'pbs-model-media-pool', | |
80 | proxy: { | |
81 | type: 'proxmox', | |
82 | url: "/api2/json/config/media-pool", | |
83 | }, | |
84 | }, | |
85 | sorters: 'name', | |
86 | }, | |
87 | ||
88 | tbar: [ | |
89 | { | |
90 | text: gettext('Add'), | |
91 | xtype: 'proxmoxButton', | |
92 | handler: 'onAdd', | |
93 | selModel: false, | |
94 | }, | |
95 | '-', | |
96 | { | |
97 | text: gettext('Edit'), | |
98 | xtype: 'proxmoxButton', | |
99 | handler: 'onEdit', | |
100 | disabled: true, | |
101 | }, | |
102 | { | |
103 | xtype: 'proxmoxStdRemoveButton', | |
104 | baseurl: '/api2/extjs/config/media-pool', | |
105 | callback: 'reload', | |
106 | }, | |
107 | ], | |
108 | ||
109 | columns: [ | |
110 | { | |
111 | text: gettext('Name'), | |
112 | dataIndex: 'name', | |
11ecf058 | 113 | flex: 1, |
dec31475 | 114 | }, |
dec31475 DC |
115 | { |
116 | text: gettext('Allocation'), | |
117 | dataIndex: 'allocation', | |
118 | }, | |
119 | { | |
120 | text: gettext('Retention'), | |
121 | dataIndex: 'retention', | |
6c924497 DM |
122 | }, |
123 | { | |
124 | text: gettext('Encryption'), | |
125 | dataIndex: 'encryption', | |
126 | renderer: Proxmox.Utils.format_boolean, | |
dec31475 DC |
127 | }, |
128 | { | |
129 | text: gettext('Encryption Fingerprint'), | |
1a0eb863 | 130 | dataIndex: 'encrypt', |
6c924497 DM |
131 | hidden: true, |
132 | flex: 3, | |
133 | }, | |
134 | { | |
135 | text: gettext('Comment'), | |
136 | dataIndex: 'comment', | |
11ecf058 | 137 | flex: 3, |
dec31475 DC |
138 | }, |
139 | ], | |
140 | }); |