From: Aaron Lauterer <a.lauterer@proxmox.com>
To: pve-devel@pve.proxmox.com
Subject: [pve-devel] [PATCH v4 manager 2/5] gui: dc/backup: move renderers to Utils.js
Date: Tue, 7 Jul 2020 11:48:59 +0200 [thread overview]
Message-ID: <20200707094902.24712-3-a.lauterer@proxmox.com> (raw)
In-Reply-To: <20200707094902.24712-1-a.lauterer@proxmox.com>
Moving the following renderers to Utils.js to be able to use them in
more than one place:
* render_backup_days_of_week
* render_backup_selection
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
v1 -> v2 -> v3 -> v4: rebased
www/manager6/Utils.js | 60 +++++++++++++++++++++++++++++++++++++++
www/manager6/dc/Backup.js | 59 ++------------------------------------
2 files changed, 62 insertions(+), 57 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 56a0407d..158b370b 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -219,6 +219,66 @@ Ext.define('PVE.Utils', { utilities: {
},
+ render_backup_days_of_week: function(val) {
+ var dows = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+ var selected = [];
+ var cur = -1;
+ val.split(',').forEach(function(day){
+ cur++;
+ var dow = (dows.indexOf(day)+6)%7;
+ if (cur === dow) {
+ if (selected.length === 0 || selected[selected.length-1] === 0) {
+ selected.push(1);
+ } else {
+ selected[selected.length-1]++;
+ }
+ } else {
+ while (cur < dow) {
+ cur++;
+ selected.push(0);
+ }
+ selected.push(1);
+ }
+ });
+
+ cur = -1;
+ var days = [];
+ selected.forEach(function(item) {
+ cur++;
+ if (item > 2) {
+ days.push(Ext.Date.dayNames[(cur+1)] + '-' + Ext.Date.dayNames[(cur+item)%7]);
+ cur += item-1;
+ } else if (item == 2) {
+ days.push(Ext.Date.dayNames[cur+1]);
+ days.push(Ext.Date.dayNames[(cur+2)%7]);
+ cur++;
+ } else if (item == 1) {
+ days.push(Ext.Date.dayNames[(cur+1)%7]);
+ }
+ });
+ return days.join(', ');
+ },
+
+ render_backup_selection: function(value, metaData, record) {
+ let allExceptText = gettext('All except {0}');
+ let allText = '-- ' + gettext('All') + ' --';
+ if (record.data.all) {
+ if (record.data.exclude) {
+ return Ext.String.format(allExceptText, record.data.exclude);
+ }
+ return allText;
+ }
+ if (record.data.vmid) {
+ return record.data.vmid;
+ }
+
+ if (record.data.pool) {
+ return "Pool '"+ record.data.pool + "'";
+ }
+
+ return "-";
+ },
+
get_kvm_osinfo: function(value) {
var info = { base: 'Other' }; // default
if (value) {
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index 13cd0528..1ef092c5 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -383,7 +383,6 @@ Ext.define('PVE.dc.BackupView', {
onlineHelp: 'chapter_vzdump',
allText: '-- ' + gettext('All') + ' --',
- allExceptText: gettext('All except {0}'),
initComponent : function() {
var me = this;
@@ -568,45 +567,7 @@ Ext.define('PVE.dc.BackupView', {
width: 200,
sortable: false,
dataIndex: 'dow',
- renderer: function(val) {
- var dows = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
- var selected = [];
- var cur = -1;
- val.split(',').forEach(function(day){
- cur++;
- var dow = (dows.indexOf(day)+6)%7;
- if (cur === dow) {
- if (selected.length === 0 || selected[selected.length-1] === 0) {
- selected.push(1);
- } else {
- selected[selected.length-1]++;
- }
- } else {
- while (cur < dow) {
- cur++;
- selected.push(0);
- }
- selected.push(1);
- }
- });
-
- cur = -1;
- var days = [];
- selected.forEach(function(item) {
- cur++;
- if (item > 2) {
- days.push(Ext.Date.dayNames[(cur+1)] + '-' + Ext.Date.dayNames[(cur+item)%7]);
- cur += item-1;
- } else if (item == 2) {
- days.push(Ext.Date.dayNames[cur+1]);
- days.push(Ext.Date.dayNames[(cur+2)%7]);
- cur++;
- } else if (item == 1) {
- days.push(Ext.Date.dayNames[(cur+1)%7]);
- }
- });
- return days.join(', ');
- }
+ renderer: PVE.Utils.render_backup_days_of_week
},
{
header: gettext('Start Time'),
@@ -625,23 +586,7 @@ Ext.define('PVE.dc.BackupView', {
flex: 1,
sortable: false,
dataIndex: 'vmid',
- renderer: function(value, metaData, record) {
- if (record.data.all) {
- if (record.data.exclude) {
- return Ext.String.format(me.allExceptText, record.data.exclude);
- }
- return me.allText;
- }
- if (record.data.vmid) {
- return record.data.vmid;
- }
-
- if (record.data.pool) {
- return "Pool '"+ record.data.pool + "'";
- }
-
- return "-";
- }
+ renderer: PVE.Utils.render_backup_selection
}
],
listeners: {
--
2.20.1
next prev parent reply other threads:[~2020-07-07 9:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 9:48 [pve-devel] [PATCH v4 manager 0/5] add backup detail and not backed up view Aaron Lauterer
2020-07-07 9:48 ` [pve-devel] [PATCH v4 manager 1/5] api: backup: add endpoint to list included guests and volumes Aaron Lauterer
2020-07-08 7:11 ` Thomas Lamprecht
2020-07-08 7:21 ` Aaron Lauterer
2020-07-07 9:48 ` Aaron Lauterer [this message]
2020-07-07 9:49 ` [pve-devel] [PATCH v4 manager 3/5] gui: dc/backup: add new backup job detail view Aaron Lauterer
2020-07-07 9:49 ` [pve-devel] [PATCH v4 manager 4/5] fix #2609 api: backupinfo: add non job specific endpoint Aaron Lauterer
2020-07-07 9:49 ` [pve-devel] [PATCH v4 manager 5/5] fix #2609 gui: backup: add window for not backed guests Aaron Lauterer
2020-07-09 18:06 ` [pve-devel] applied-series: Re: [PATCH v4 manager 0/5] add backup detail and not backed up view 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=20200707094902.24712-3-a.lauterer@proxmox.com \
--to=a.lauterer@proxmox.com \
--cc=pve-devel@pve.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal