ui: Dashboard/TaskSummary: refactor types and title

by moving the definition into the controller and dynamically use them
in the updateTasks function

we will reuse/extend this later

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-10-06 12:25:26 +02:00 committed by Thomas Lamprecht
parent ad9d1625a6
commit 9608ac3486
1 changed files with 22 additions and 11 deletions

View File

@ -7,6 +7,20 @@ Ext.define('PBS.TaskSummary', {
controller: { controller: {
xclass: 'Ext.app.ViewController', xclass: 'Ext.app.ViewController',
types: [
"backup",
"prune",
"garbage_collection",
"sync",
],
titles: {
"backup": gettext('Backups'),
"prune": gettext('Prunes'),
"garbage_collection": gettext('Garbage collections'),
"sync": gettext('Syncs'),
},
render_icon: function(state, count) { render_icon: function(state, count) {
let cls = 'question'; let cls = 'question';
let color = 'faded'; let color = 'faded';
@ -40,18 +54,15 @@ Ext.define('PBS.TaskSummary', {
}, },
}, },
updateTasks: function(data) { updateTasks: function(source) {
let me = this; let me = this;
data.backup.type = gettext('Backups'); let controller = me.getController();
data.prune.type = gettext('Prunes'); let data = [];
data.garbage_collection.type = gettext('Garbage collections'); controller.types.forEach((type) => {
data.sync.type = gettext('Syncs'); source[type].type = controller.titles[type];
me.lookup('grid').getStore().setData([ data.push(source[type]);
data.backup, });
data.prune, me.lookup('grid').getStore().setData(data);
data.garbage_collection,
data.sync,
]);
}, },
layout: 'fit', layout: 'fit',