]> git.proxmox.com Git - proxmox-backup.git/blob - www/config/DataStoreConfig.js
ui: consistently spell Datastore without space between words
[proxmox-backup.git] / www / config / DataStoreConfig.js
1 Ext.define('pbs-datastore-list', {
2 extend: 'Ext.data.Model',
3 fields: [ 'name', 'comment' ],
4 proxy: {
5 type: 'proxmox',
6 url: "/api2/json/admin/datastore"
7 },
8 idProperty: 'store'
9 });
10
11 Ext.define('pbs-data-store-config', {
12 extend: 'Ext.data.Model',
13 fields: [
14 'name', 'path', 'comment', 'gc-schedule', 'prune-schedule', 'keep-last',
15 'keep-hourly', 'keep-daily', 'keep-weekly', 'keep-monthly', 'keep-yearly',
16 ],
17 proxy: {
18 type: 'proxmox',
19 url: "/api2/json/config/datastore",
20 },
21 idProperty: 'name',
22 });
23
24 Ext.define('PBS.DataStoreConfig', {
25 extend: 'Ext.grid.GridPanel',
26 alias: 'widget.pbsDataStoreConfig',
27
28 title: gettext('Datastore Configuration'),
29
30 controller: {
31 xclass: 'Ext.app.ViewController',
32
33 createDataStore: function() {
34 let me = this;
35 Ext.create('PBS.DataStoreEdit', {
36 listeners: {
37 destroy: function() {
38 me.reload();
39 },
40 },
41 }).show();
42 },
43
44 editDataStore: function() {
45 let me = this;
46 let view = me.getView();
47 let selection = view.getSelection();
48 if (selection.length < 1) return;
49
50 let name = encodeURIComponent(selection[0].data.name);
51 Ext.create('PBS.DataStoreEdit', {
52 name: name,
53 listeners: {
54 destroy: function() {
55 me.reload();
56 },
57 },
58 }).show();
59 },
60
61 onVerify: function() {
62 var view = this.getView();
63
64 let rec = view.selModel.getSelection()[0];
65 if (!(rec && rec.data)) return;
66 let data = rec.data;
67
68 Proxmox.Utils.API2Request({
69 url: `/admin/datastore/${data.name}/verify`,
70 method: 'POST',
71 failure: function(response) {
72 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
73 },
74 success: function(response, options) {
75 Ext.create('Proxmox.window.TaskViewer', {
76 upid: response.result.data,
77 }).show();
78 },
79 });
80 },
81
82 garbageCollect: function() {
83 let me = this;
84 let view = me.getView();
85 let selection = view.getSelection();
86 if (selection.length < 1) return;
87
88 let name = encodeURIComponent(selection[0].data.name);
89 Proxmox.Utils.API2Request({
90 url: `/admin/datastore/${name}/gc`,
91 method: 'POST',
92 failure: function(response) {
93 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
94 },
95 success: function(response, options) {
96 Ext.create('Proxmox.window.TaskViewer', {
97 upid: response.result.data,
98 }).show();
99 },
100 });
101 },
102
103 reload: function() { this.getView().getStore().rstore.load(); },
104
105 init: function(view) {
106 Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
107 },
108 },
109
110 store: {
111 type: 'diff',
112 autoDestroy: true,
113 autoDestroyRstore: true,
114 sorters: 'name',
115 rstore: {
116 type: 'update',
117 storeid: 'pbs-data-store-config',
118 model: 'pbs-data-store-config',
119 autoStart: true,
120 interval: 10000,
121 },
122 },
123
124 tbar: [
125 {
126 xtype: 'proxmoxButton',
127 selModel: false,
128 text: gettext('Create'),
129 handler: 'createDataStore',
130 },
131 {
132 xtype: 'proxmoxButton',
133 text: gettext('Edit'),
134 disabled: true,
135 handler: 'editDataStore',
136 },
137 // remove_btn
138 '-',
139 {
140 xtype: 'proxmoxButton',
141 text: gettext('Verify'),
142 disabled: true,
143 handler: 'onVerify',
144 },
145 {
146 xtype: 'proxmoxButton',
147 text: gettext('Start GC'),
148 disabled: true,
149 handler: 'garbageCollect',
150 },
151 ],
152
153 columns: [
154 {
155 header: gettext('Name'),
156 sortable: true,
157 dataIndex: 'name',
158 flex: 1,
159 },
160 {
161 header: gettext('Path'),
162 sortable: true,
163 dataIndex: 'path',
164 flex: 1,
165 },
166 {
167 header: gettext('GC Schedule'),
168 sortable: false,
169 width: 120,
170 dataIndex: 'gc-schedule',
171 },
172 {
173 header: gettext('Prune Schedule'),
174 sortable: false,
175 width: 120,
176 dataIndex: 'prune-schedule',
177 },
178 {
179 header: gettext('Keep'),
180 columns: [
181 {
182 text: gettext('Last'),
183 dataIndex: 'keep-last',
184 width: 70,
185 },
186 {
187 text: gettext('Hourly'),
188 dataIndex: 'keep-hourly',
189 width: 70,
190 },
191 {
192 text: gettext('Daily'),
193 dataIndex: 'keep-daily',
194 width: 70,
195 },
196 {
197 text: gettext('Weekly'),
198 dataIndex: 'keep-weekly',
199 width: 70,
200 },
201 {
202 text: gettext('Monthly'),
203 dataIndex: 'keep-monthly',
204 width: 70,
205 },
206 {
207 text: gettext('Yearly'),
208 dataIndex: 'keep-yearly',
209 width: 70,
210 },
211 ]
212 },
213 {
214 header: gettext('Comment'),
215 sortable: false,
216 dataIndex: 'comment',
217 renderer: Ext.String.htmlEncode,
218 flex: 2,
219 },
220 ],
221
222 listeners: {
223 activate: 'reload',
224 itemdblclick: 'editDataStore',
225 },
226 });