]>
Commit | Line | Data |
---|---|---|
6ac46211 DC |
1 | Ext.define('PVE.node.CreateDirectory', { |
2 | extend: 'Proxmox.window.Edit', | |
3 | xtype: 'pveCreateDirectory', | |
4 | ||
5 | subject: Proxmox.Utils.directoryText, | |
6 | ||
7 | showProgress: true, | |
8 | ||
9 | onlineHelp: 'chapter_storage', | |
10 | ||
8058410f | 11 | initComponent: function() { |
6ac46211 DC |
12 | var me = this; |
13 | ||
14 | if (!me.nodename) { | |
15 | throw "no node name specified"; | |
16 | } | |
17 | ||
18 | me.isCreate = true; | |
19 | ||
20 | Ext.applyIf(me, { | |
21 | url: "/nodes/" + me.nodename + "/disks/directory", | |
22 | method: 'POST', | |
23 | items: [ | |
24 | { | |
d0cfe2ea | 25 | xtype: 'pmxDiskSelector', |
6ac46211 DC |
26 | name: 'device', |
27 | nodename: me.nodename, | |
28 | diskType: 'unused', | |
6c356c92 | 29 | includePartitions: true, |
6ac46211 | 30 | fieldLabel: gettext('Disk'), |
f6710aac | 31 | allowBlank: false, |
6ac46211 DC |
32 | }, |
33 | { | |
34 | xtype: 'proxmoxKVComboBox', | |
35 | comboItems: [ | |
36 | ['ext4', 'ext4'], | |
f6710aac | 37 | ['xfs', 'xfs'], |
6ac46211 DC |
38 | ], |
39 | fieldLabel: gettext('Filesystem'), | |
40 | name: 'filesystem', | |
41 | value: '', | |
f6710aac | 42 | allowBlank: false, |
6ac46211 DC |
43 | }, |
44 | { | |
45 | xtype: 'proxmoxtextfield', | |
46 | name: 'name', | |
47 | fieldLabel: gettext('Name'), | |
f6710aac | 48 | allowBlank: false, |
6ac46211 DC |
49 | }, |
50 | { | |
51 | xtype: 'proxmoxcheckbox', | |
52 | name: 'add_storage', | |
53 | fieldLabel: gettext('Add Storage'), | |
f6710aac TL |
54 | value: '1', |
55 | }, | |
56 | ], | |
6ac46211 DC |
57 | }); |
58 | ||
59 | me.callParent(); | |
f6710aac | 60 | }, |
6ac46211 DC |
61 | }); |
62 | ||
63 | Ext.define('PVE.node.Directorylist', { | |
64 | extend: 'Ext.grid.Panel', | |
65 | xtype: 'pveDirectoryList', | |
66 | ||
14066c09 FE |
67 | viewModel: { |
68 | data: { | |
69 | path: '', | |
70 | }, | |
71 | formulas: { | |
72 | dirName: (get) => get('path')?.replace('/mnt/pve/', '') || undefined, | |
73 | }, | |
74 | }, | |
75 | ||
76 | controller: { | |
77 | xclass: 'Ext.app.ViewController', | |
78 | ||
79 | destroyDirectory: function() { | |
80 | let me = this; | |
81 | let vm = me.getViewModel(); | |
82 | let view = me.getView(); | |
83 | ||
84 | const dirName = vm.get('dirName'); | |
85 | ||
86 | if (!view.nodename) { | |
87 | throw "no node name specified"; | |
88 | } | |
89 | ||
90 | if (!dirName) { | |
91 | throw "no directory name specified"; | |
92 | } | |
93 | ||
bccfb43f | 94 | Ext.create('PVE.window.SafeDestroyStorage', { |
14066c09 FE |
95 | url: `/nodes/${view.nodename}/disks/directory/${dirName}`, |
96 | item: { id: dirName }, | |
14066c09 FE |
97 | taskName: 'dirremove', |
98 | taskDone: () => { view.reload(); }, | |
99 | }).show(); | |
100 | }, | |
101 | }, | |
102 | ||
6ac46211 DC |
103 | stateful: true, |
104 | stateId: 'grid-node-directory', | |
105 | columns: [ | |
106 | { | |
107 | text: gettext('Path'), | |
108 | dataIndex: 'path', | |
f6710aac | 109 | flex: 1, |
6ac46211 DC |
110 | }, |
111 | { | |
112 | header: gettext('Device'), | |
113 | flex: 1, | |
f6710aac | 114 | dataIndex: 'device', |
6ac46211 DC |
115 | }, |
116 | { | |
117 | header: gettext('Type'), | |
118 | width: 100, | |
f6710aac | 119 | dataIndex: 'type', |
6ac46211 DC |
120 | }, |
121 | { | |
122 | header: gettext('Options'), | |
123 | width: 100, | |
f6710aac | 124 | dataIndex: 'options', |
6ac46211 DC |
125 | }, |
126 | { | |
127 | header: gettext('Unit File'), | |
128 | hidden: true, | |
f6710aac TL |
129 | dataIndex: 'unitfile', |
130 | }, | |
6ac46211 DC |
131 | ], |
132 | ||
133 | rootVisible: false, | |
134 | useArrows: true, | |
135 | ||
136 | tbar: [ | |
137 | { | |
138 | text: gettext('Reload'), | |
139 | iconCls: 'fa fa-refresh', | |
140 | handler: function() { | |
76509256 | 141 | this.up('panel').reload(); |
f6710aac | 142 | }, |
6ac46211 DC |
143 | }, |
144 | { | |
978e2aeb | 145 | text: `${gettext('Create')}: ${gettext('Directory')}`, |
6ac46211 | 146 | handler: function() { |
76509256 TL |
147 | let view = this.up('panel'); |
148 | Ext.create('PVE.node.CreateDirectory', { | |
149 | nodename: view.nodename, | |
150 | listeners: { | |
151 | destroy: () => view.reload(), | |
152 | }, | |
153 | autoShow: true, | |
154 | }); | |
f6710aac TL |
155 | }, |
156 | }, | |
14066c09 FE |
157 | '->', |
158 | { | |
159 | xtype: 'tbtext', | |
160 | data: { | |
161 | dirName: undefined, | |
162 | }, | |
163 | bind: { | |
164 | data: { | |
165 | dirName: "{dirName}", | |
166 | }, | |
167 | }, | |
168 | tpl: [ | |
169 | '<tpl if="dirName">', | |
170 | gettext('Directory') + ' {dirName}:', | |
171 | '<tpl else>', | |
172 | Ext.String.format(gettext('No {0} selected'), gettext('directory')), | |
173 | '</tpl>', | |
174 | ], | |
175 | }, | |
176 | { | |
177 | text: gettext('More'), | |
178 | iconCls: 'fa fa-bars', | |
179 | disabled: true, | |
180 | bind: { | |
181 | disabled: '{!dirName}', | |
182 | }, | |
183 | menu: [ | |
184 | { | |
185 | text: gettext('Destroy'), | |
186 | itemId: 'remove', | |
187 | iconCls: 'fa fa-fw fa-trash-o', | |
188 | handler: 'destroyDirectory', | |
189 | disabled: true, | |
190 | bind: { | |
191 | disabled: '{!dirName}', | |
192 | }, | |
193 | }, | |
194 | ], | |
195 | }, | |
6ac46211 DC |
196 | ], |
197 | ||
198 | reload: function() { | |
76509256 | 199 | let me = this; |
6ac46211 DC |
200 | me.store.load(); |
201 | me.store.sort(); | |
202 | }, | |
203 | ||
204 | listeners: { | |
205 | activate: function() { | |
76509256 | 206 | this.reload(); |
f6710aac | 207 | }, |
14066c09 FE |
208 | selectionchange: function(model, selected) { |
209 | let me = this; | |
210 | let vm = me.getViewModel(); | |
211 | ||
212 | vm.set('path', selected[0]?.data.path || ''); | |
213 | }, | |
6ac46211 DC |
214 | }, |
215 | ||
216 | initComponent: function() { | |
76509256 | 217 | let me = this; |
6ac46211 DC |
218 | |
219 | me.nodename = me.pveSelNode.data.node; | |
220 | if (!me.nodename) { | |
221 | throw "no node name specified"; | |
222 | } | |
223 | ||
224 | Ext.apply(me, { | |
225 | store: { | |
8058410f | 226 | fields: ['path', 'device', 'type', 'options', 'unitfile'], |
6ac46211 DC |
227 | proxy: { |
228 | type: 'proxmox', | |
76509256 | 229 | url: `/api2/json/nodes/${me.nodename}/disks/directory`, |
6ac46211 | 230 | }, |
f6710aac TL |
231 | sorters: 'path', |
232 | }, | |
6ac46211 DC |
233 | }); |
234 | ||
235 | me.callParent(); | |
236 | ||
237 | Proxmox.Utils.monStoreErrors(me, me.getStore(), true); | |
238 | me.reload(); | |
f6710aac | 239 | }, |
6ac46211 DC |
240 | }); |
241 |