public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/2] ui: prune: show which rule keeps backup
@ 2020-11-09 14:53 Fabian Ebner
  2020-11-09 14:53 ` [pbs-devel] [RFC proxmox-backup 2/2] ui: prune: show count for rule Fabian Ebner
  2020-11-10  8:24 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] ui: prune: show which rule keeps backup Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Ebner @ 2020-11-09 14:53 UTC (permalink / raw)
  To: pbs-devel

and adjust layout so the description fits.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 www/datastore/Prune.js | 51 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/www/datastore/Prune.js b/www/datastore/Prune.js
index 7475aa9e..531204f1 100644
--- a/www/datastore/Prune.js
+++ b/www/datastore/Prune.js
@@ -44,6 +44,46 @@ Ext.define('PBS.DataStorePruneInputPanel', {
 	reload: function() {
 	    var view = this.getView();
 
+	    // helper to allow showing why a backup is kept
+	    let addKeepReasons = function(backups, params) {
+		const rules = [
+		    'keep-last',
+		    'keep-hourly',
+		    'keep-daily',
+		    'keep-weekly',
+		    'keep-monthly',
+		    'keep-yearly',
+		    'keep-all', // when all keep options are not set
+		];
+		let counter = {};
+
+		backups.sort(function(a, b) {
+		    return a["backup-time"] < b["backup-time"];
+		});
+
+		let ruleIndex = -1;
+		let nextRule = function() {
+		    let rule;
+		    do {
+			ruleIndex++;
+			rule = rules[ruleIndex];
+		    } while (!params[rule] && rule !== 'keep-all');
+		    counter[rule] = 0;
+		    return rule;
+		};
+
+		let rule = nextRule();
+		for (let backup of backups) {
+		    if (backup.keep) {
+			counter[rule]++;
+			backup.keepReason = rule;
+			if (rule !== 'keep-all' && counter[rule] >= params[rule]) {
+			    rule = nextRule();
+			}
+		    }
+		}
+	    };
+
 	    let params = view.getValues();
 	    params["dry-run"] = true;
 
@@ -59,6 +99,7 @@ Ext.define('PBS.DataStorePruneInputPanel', {
 		},
 		success: function(response, options) {
 		    var data = response.result.data;
+		    addKeepReasons(data, params);
 		    view.prune_store.setData(data);
 		},
 	    });
@@ -146,6 +187,14 @@ Ext.define('PBS.DataStorePruneInputPanel', {
 		    {
 			text: "keep",
 			dataIndex: 'keep',
+			renderer: function(value, metaData, record) {
+			    if (record.data.keep) {
+				return 'true (' + record.data.keepReason + ')';
+			    } else {
+				return 'false';
+			    }
+			},
+			flex: 1,
 		    },
 		],
 	    },
@@ -163,6 +212,8 @@ Ext.define('PBS.DataStorePrune', {
 
     isCreate: true,
 
+    fieldDefaults: { labelWidth: 120 },
+
     initComponent: function() {
         var me = this;
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-10  8:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 14:53 [pbs-devel] [PATCH proxmox-backup 1/2] ui: prune: show which rule keeps backup Fabian Ebner
2020-11-09 14:53 ` [pbs-devel] [RFC proxmox-backup 2/2] ui: prune: show count for rule Fabian Ebner
2020-11-10  8:25   ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-10  8:24 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] ui: prune: show which rule keeps backup Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal