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