public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] ui: prune: show which rule keeps backup
Date: Mon,  9 Nov 2020 15:53:07 +0100	[thread overview]
Message-ID: <20201109145308.29679-1-f.ebner@proxmox.com> (raw)

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





             reply	other threads:[~2020-11-09 14:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 14:53 Fabian Ebner [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201109145308.29679-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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