]> git.proxmox.com Git - proxmox-backup.git/blame - www/DataStorePrune.js
tools/logrotate: fix compression logic
[proxmox-backup.git] / www / DataStorePrune.js
CommitLineData
d16122cd
DM
1Ext.define('pbs-prune-list', {
2 extend: 'Ext.data.Model',
3 fields: [
4 'backup-type',
5 'backup-id',
6 {
7 name: 'backup-time',
8 type: 'date',
264c1958 9 dateFormat: 'timestamp',
d16122cd 10 },
264c1958 11 ],
d16122cd
DM
12});
13
b1127fd0
DM
14Ext.define('PBS.DataStorePruneInputPanel', {
15 extend: 'Proxmox.panel.InputPanel',
16 alias: 'widget.pbsDataStorePruneInputPanel',
d16122cd
DM
17 mixins: ['Proxmox.Mixin.CBind'],
18
19 onGetValues: function(values) {
20 var me = this;
21
22 values["backup-type"] = me.backup_type;
23 values["backup-id"] = me.backup_id;
24 return values;
25 },
26
27 controller: {
28 xclass: 'Ext.app.ViewController',
b1127fd0 29
d16122cd
DM
30 init: function(view) {
31 if (!view.url) {
32 throw "no url specified";
33 }
34 if (!view.backup_type) {
35 throw "no backup_type specified";
36 }
37 if (!view.backup_id) {
38 throw "no backup_id specified";
39 }
40
41 this.reload(); // initial load
42 },
43
44 reload: function() {
45 var view = this.getView();
46
47 let params = view.getValues();
48 params["dry-run"] = true;
49
50 Proxmox.Utils.API2Request({
51 url: view.url,
52 method: "POST",
53 params: params,
54 callback: function() {
264c1958 55 // for easy breakpoint setting
d16122cd 56 },
264c1958 57 failure: function(response, opts) {
d16122cd
DM
58 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
59 },
60 success: function(response, options) {
61 var data = response.result.data;
d16122cd 62 view.prune_store.setData(data);
264c1958 63 },
d16122cd
DM
64 });
65 },
66
67 control: {
264c1958
TL
68 field: { change: 'reload' },
69 },
d16122cd
DM
70 },
71
72 column1: [
b1127fd0
DM
73 {
74 xtype: 'proxmoxintegerfield',
75 name: 'keep-last',
76 allowBlank: true,
77 fieldLabel: gettext('keep-last'),
78 minValue: 1,
79 },
80 {
81 xtype: 'proxmoxintegerfield',
82 name: 'keep-hourly',
83 allowBlank: true,
84 fieldLabel: gettext('keep-hourly'),
85 minValue: 1,
86 },
87 {
88 xtype: 'proxmoxintegerfield',
89 name: 'keep-daily',
90 allowBlank: true,
91 fieldLabel: gettext('keep-daily'),
92 minValue: 1,
93 },
94 {
95 xtype: 'proxmoxintegerfield',
96 name: 'keep-weekly',
97 allowBlank: true,
98 fieldLabel: gettext('keep-weekly'),
99 minValue: 1,
100 },
101 {
102 xtype: 'proxmoxintegerfield',
5b5ca60a 103 name: 'keep-monthly',
b1127fd0
DM
104 allowBlank: true,
105 fieldLabel: gettext('keep-monthly'),
106 minValue: 1,
107 },
108 {
109 xtype: 'proxmoxintegerfield',
110 name: 'keep-yearly',
111 allowBlank: true,
112 fieldLabel: gettext('keep-yearly'),
113 minValue: 1,
264c1958 114 },
d16122cd
DM
115 ],
116
117
264c1958 118 initComponent: function() {
d16122cd 119 var me = this;
b1127fd0 120
d16122cd
DM
121 me.prune_store = Ext.create('Ext.data.Store', {
122 model: 'pbs-prune-list',
264c1958 123 sorters: { property: 'backup-time', direction: 'DESC' },
d16122cd
DM
124 });
125
126 me.column2 = [
127 {
128 xtype: 'grid',
129 height: 200,
130 store: me.prune_store,
131 columns: [
132 {
133 header: gettext('Backup Time'),
134 sortable: true,
135 dataIndex: 'backup-time',
136 renderer: function(value, metaData, record) {
137 let text = Ext.Date.format(value, 'Y-m-d H:i:s');
138 if (record.data.keep) {
139 return text;
140 } else {
141 return '<div style="text-decoration: line-through;">'+ text +'</div>';
142 }
143 },
144 flex: 1,
145 },
146 {
147 text: "keep",
264c1958
TL
148 dataIndex: 'keep',
149 },
150 ],
151 },
d16122cd
DM
152 ];
153
154 me.callParent();
264c1958 155 },
b1127fd0
DM
156});
157
158Ext.define('PBS.DataStorePrune', {
159 extend: 'Proxmox.window.Edit',
160
161 method: 'POST',
162 submitText: "Prune",
163
164 isCreate: true,
165
264c1958 166 initComponent: function() {
b1127fd0
DM
167 var me = this;
168
169 if (!me.datastore) {
170 throw "no datastore specified";
171 }
172 if (!me.backup_type) {
173 throw "no backup_type specified";
174 }
175 if (!me.backup_id) {
176 throw "no backup_id specified";
177 }
178
179 Ext.apply(me, {
180 url: '/api2/extjs/admin/datastore/' + me.datastore + "/prune",
181 title: "Prune Datastore '" + me.datastore + "'",
182 items: [{
183 xtype: 'pbsDataStorePruneInputPanel',
d16122cd
DM
184 url: '/api2/extjs/admin/datastore/' + me.datastore + "/prune",
185 backup_type: me.backup_type,
264c1958
TL
186 backup_id: me.backup_id,
187 }],
b1127fd0
DM
188 });
189
190 me.callParent();
264c1958 191 },
b1127fd0 192});