]> git.proxmox.com Git - proxmox-backup.git/commitdiff
gui: preview prune selection
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 1 Apr 2020 12:14:44 +0000 (14:14 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 1 Apr 2020 12:14:44 +0000 (14:14 +0200)
www/DataStorePrune.js

index c5c5d3b2e80525c715f42a07b229a38712f69229..5c6bc9c09695300bdec285f1fadfc84fd182a660 100644 (file)
@@ -1,8 +1,76 @@
+Ext.define('pbs-prune-list', {
+    extend: 'Ext.data.Model',
+    fields: [
+       'backup-type',
+       'backup-id',
+       {
+           name: 'backup-time',
+           type: 'date',
+           dateFormat: 'timestamp'
+       },
+    ]
+});
+
 Ext.define('PBS.DataStorePruneInputPanel', {
     extend: 'Proxmox.panel.InputPanel',
     alias: 'widget.pbsDataStorePruneInputPanel',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    onGetValues: function(values) {
+       var me = this;
+
+       values["backup-type"] = me.backup_type;
+       values["backup-id"] = me.backup_id;
+       return values;
+    },
+
+    controller: {
+       xclass: 'Ext.app.ViewController',
 
-    items: [
+       init: function(view) {
+           if (!view.url) {
+               throw "no url specified";
+           }
+           if (!view.backup_type) {
+               throw "no backup_type specified";
+           }
+           if (!view.backup_id) {
+               throw "no backup_id specified";
+           }
+
+           this.reload(); // initial load
+       },
+
+       reload: function() {
+           var view = this.getView();
+
+           let params = view.getValues();
+           params["dry-run"] = true;
+
+           Proxmox.Utils.API2Request({
+               url: view.url,
+               method: "POST",
+               params: params,
+               callback: function() {
+                   console.log("DONE");
+               },
+               failure: function (response, opts) {
+                   Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+               },
+               success: function(response, options) {
+                   var data = response.result.data;
+                   console.log(data);
+                   view.prune_store.setData(data);
+               }
+           });
+       },
+
+       control: {
+           field: { change: 'reload' }
+       }
+    },
+
+    column1: [
        {
            xtype: 'proxmoxintegerfield',
            name: 'keep-last',
@@ -45,14 +113,47 @@ Ext.define('PBS.DataStorePruneInputPanel', {
            fieldLabel: gettext('keep-yearly'),
            minValue: 1,
        }
-       // fixme: howto handle dry-run?
-       //{
-       //    xtype: 'proxmoxcheckbox',
-       //    name: 'dry-run',
-       //    fieldLabel: gettext('dry-run'),
-       //}
-     ],
+    ],
+
+
+    initComponent : function() {
+        var me = this;
 
+       me.prune_store = Ext.create('Ext.data.Store', {
+           model: 'pbs-prune-list',
+           sorters: { property: 'backup-time', direction: 'DESC' }
+       });
+
+       me.column2 = [
+           {
+               xtype: 'grid',
+               height: 200,
+               store: me.prune_store,
+               columns: [
+                   {
+                       header: gettext('Backup Time'),
+                       sortable: true,
+                       dataIndex: 'backup-time',
+                       renderer: function(value, metaData, record) {
+                           let text = Ext.Date.format(value, 'Y-m-d H:i:s');
+                           if (record.data.keep) {
+                               return text;
+                           } else {
+                               return '<div style="text-decoration: line-through;">'+ text +'</div>';
+                           }
+                       },
+                       flex: 1,
+                   },
+                   {
+                       text: "keep",
+                       dataIndex: 'keep'
+                   }
+               ]
+           }
+       ];
+
+       me.callParent();
+    }
 });
 
 Ext.define('PBS.DataStorePrune', {
@@ -81,11 +182,9 @@ Ext.define('PBS.DataStorePrune', {
            title: "Prune Datastore '" + me.datastore + "'",
            items: [{
                xtype: 'pbsDataStorePruneInputPanel',
-               onGetValues: function(values) {
-                   values["backup-type"] = me.backup_type;
-                   values["backup-id"] = me.backup_id;
-                   return values;
-               }
+               url: '/api2/extjs/admin/datastore/' + me.datastore + "/prune",
+               backup_type: me.backup_type,
+               backup_id: me.backup_id
            }]
        });