]>
git.proxmox.com Git - proxmox-backup.git/blob - www/datastore/Prune.js
1 Ext
.define('pbs-prune-list', {
2 extend
: 'Ext.data.Model',
9 dateFormat
: 'timestamp',
14 Ext
.define('PBS.PruneKeepInput', {
15 extend
: 'Proxmox.form.field.Integer',
16 alias
: 'widget.pbsPruneKeepInput',
22 change: function(field
, newValue
, oldValue
) {
23 if (newValue
!== this.originalValue
) {
24 this.triggers
.clear
.setVisible(true);
30 cls
: 'pmx-clear-trigger',
34 this.triggers
.clear
.setVisible(false);
35 this.setValue(this.originalValue
);
42 Ext
.define('PBS.Datastore.PruneInputPanel', {
43 extend
: 'Proxmox.panel.InputPanel',
44 alias
: 'widget.pbsDataStorePruneInputPanel',
45 mixins
: ['Proxmox.Mixin.CBind'],
47 onGetValues: function(values
) {
50 values
["backup-type"] = me
.backup_type
;
51 values
["backup-id"] = me
.backup_id
;
56 xclass
: 'Ext.app.ViewController',
58 init: function(view
) {
60 throw "no url specified";
62 if (!view
.backup_type
) {
63 throw "no backup_type specified";
65 if (!view
.backup_id
) {
66 throw "no backup_id specified";
69 this.reload(); // initial load
73 var view
= this.getView();
75 // helper to allow showing why a backup is kept
76 let addKeepReasons = function(backups
, params
) {
84 'keep-all', // when all keep options are not set
88 backups
.sort(function(a
, b
) {
89 return a
["backup-time"] < b
["backup-time"];
93 let nextRule = function() {
97 rule
= rules
[ruleIndex
];
98 } while (!params
[rule
] && rule
!== 'keep-all');
103 let rule
= nextRule();
104 for (let backup
of backups
) {
107 if (rule
!== 'keep-all') {
108 backup
.keepReason
= rule
+ ': ' + counter
[rule
];
109 if (counter
[rule
] >= params
[rule
]) {
113 backup
.keepReason
= rule
;
119 let params
= view
.getValues();
120 params
["dry-run"] = true;
122 Proxmox
.Utils
.API2Request({
126 callback: function() {
127 // for easy breakpoint setting
129 failure: function(response
, opts
) {
130 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
132 success: function(response
, options
) {
133 var data
= response
.result
.data
;
134 addKeepReasons(data
, params
);
135 view
.prune_store
.setData(data
);
141 field
: { change
: 'reload' },
147 xtype
: 'pbsPruneKeepInput',
149 fieldLabel
: gettext('keep-last'),
152 xtype
: 'pbsPruneKeepInput',
154 fieldLabel
: gettext('keep-hourly'),
157 xtype
: 'pbsPruneKeepInput',
159 fieldLabel
: gettext('keep-daily'),
162 xtype
: 'pbsPruneKeepInput',
164 fieldLabel
: gettext('keep-weekly'),
167 xtype
: 'pbsPruneKeepInput',
168 name
: 'keep-monthly',
169 fieldLabel
: gettext('keep-monthly'),
172 xtype
: 'pbsPruneKeepInput',
174 fieldLabel
: gettext('keep-yearly'),
179 initComponent: function() {
182 me
.prune_store
= Ext
.create('Ext.data.Store', {
183 model
: 'pbs-prune-list',
184 sorters
: { property
: 'backup-time', direction
: 'DESC' },
191 store
: me
.prune_store
,
194 header
: gettext('Backup Time'),
196 dataIndex
: 'backup-time',
197 renderer: function(value
, metaData
, record
) {
198 let text
= Ext
.Date
.format(value
, 'Y-m-d H:i:s');
199 if (record
.data
.keep
) {
202 return '<div style="text-decoration: line-through;">'+ text
+'</div>';
208 text
: 'Keep (reason)',
210 renderer: function(value
, metaData
, record
) {
211 if (record
.data
.keep
) {
212 return 'true (' + record
.data
.keepReason
+ ')';
227 Ext
.define('PBS.DataStorePrune', {
228 extend
: 'Proxmox.window.Edit',
235 fieldDefaults
: { labelWidth
: 130 },
237 initComponent: function() {
241 throw "no datastore specified";
243 if (!me
.backup_type
) {
244 throw "no backup_type specified";
247 throw "no backup_id specified";
251 url
: '/api2/extjs/admin/datastore/' + me
.datastore
+ "/prune",
252 title
: "Prune Datastore '" + me
.datastore
+ "'",
254 xtype
: 'pbsDataStorePruneInputPanel',
255 url
: '/api2/extjs/admin/datastore/' + me
.datastore
+ "/prune",
256 backup_type
: me
.backup_type
,
257 backup_id
: me
.backup_id
,