ui: switch summary repo status to widget toolkit one
Not only can we remove a few lines of duplicated code, we also get the "link to repo management" for free. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
0606432e9b
commit
6a7b673872
|
@ -62,17 +62,20 @@ Ext.define('PBS.Dashboard', {
|
|||
updateRepositoryStatus: function(store, records, success) {
|
||||
if (!success) { return; }
|
||||
let me = this;
|
||||
me.lookup('nodeInfo').setRepositoryInfo(records[0].data['standard-repos']);
|
||||
let view = me.getView();
|
||||
view.down('#repositoryStatus').setRepositoryInfo(records[0].data['standard-repos']);
|
||||
},
|
||||
|
||||
updateSubscription: function(store, records, success) {
|
||||
if (!success) { return; }
|
||||
let me = this;
|
||||
let view = me.getView();
|
||||
let status = records[0].data.status || 'unknown';
|
||||
// 2 = all good, 1 = different leves, 0 = none
|
||||
let subscriptionActive = status.toLowerCase() === 'active';
|
||||
let subStatus = status.toLowerCase() === 'active' ? 2 : 0;
|
||||
me.lookup('subscription').setSubStatus(subStatus);
|
||||
me.lookup('nodeInfo').setSubscriptionStatus(subStatus);
|
||||
view.down('#repositoryStatus').setSubscriptionStatus(subscriptionActive);
|
||||
},
|
||||
|
||||
updateTasks: function(store, records, success) {
|
||||
|
|
|
@ -20,37 +20,6 @@ Ext.define('PBS.NodeInfoPanel', {
|
|||
padding: '0 10 5 10',
|
||||
},
|
||||
|
||||
viewModel: {
|
||||
data: {
|
||||
subscriptionActive: '',
|
||||
noSubscriptionRepo: '',
|
||||
enterpriseRepo: '',
|
||||
testRepo: '',
|
||||
},
|
||||
formulas: {
|
||||
repoStatus: function(get) {
|
||||
if (get('subscriptionActive') === '' || get('enterpriseRepo') === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (get('noSubscriptionRepo') || get('testRepo')) {
|
||||
return 'non-production';
|
||||
} else if (get('subscriptionActive') && get('enterpriseRepo')) {
|
||||
return 'ok';
|
||||
} else if (!get('subscriptionActive') && get('enterpriseRepo')) {
|
||||
return 'no-sub';
|
||||
} else if (!get('enterpriseRepo') || !get('noSubscriptionRepo') || !get('testRepo')) {
|
||||
return 'no-repo';
|
||||
}
|
||||
return 'unknown';
|
||||
},
|
||||
repoStatusMessage: function(get) {
|
||||
const status = get('repoStatus');
|
||||
return Proxmox.Utils.formatNodeRepoStatus(status, 'Proxmox Backup Server');
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
controller: {
|
||||
xclass: 'Ext.app.ViewController',
|
||||
|
||||
|
@ -179,16 +148,10 @@ Ext.define('PBS.NodeInfoPanel', {
|
|||
value: '',
|
||||
},
|
||||
{
|
||||
xtype: 'pmxNodeInfoRepoStatus',
|
||||
itemId: 'repositoryStatus',
|
||||
colspan: 2,
|
||||
printBar: false,
|
||||
title: gettext('Repository Status'),
|
||||
setValue: function(value) { // for binding below
|
||||
this.updateValue(value);
|
||||
},
|
||||
bind: {
|
||||
value: '{repoStatusMessage}',
|
||||
},
|
||||
product: 'Proxmox Bacckup Server',
|
||||
repoLink: '#pbsServerAdministration:aptrepositories',
|
||||
},
|
||||
],
|
||||
|
||||
|
@ -198,31 +161,6 @@ Ext.define('PBS.NodeInfoPanel', {
|
|||
me.setTitle(Proxmox.NodeName + ' (' + gettext('Uptime') + ': ' + uptime + ')');
|
||||
},
|
||||
|
||||
setRepositoryInfo: function(standardRepos) {
|
||||
let me = this;
|
||||
let vm = me.getViewModel();
|
||||
|
||||
for (const standardRepo of standardRepos) {
|
||||
const handle = standardRepo.handle;
|
||||
const status = standardRepo.status;
|
||||
|
||||
if (handle === "enterprise") {
|
||||
vm.set('enterpriseRepo', status);
|
||||
} else if (handle === "no-subscription") {
|
||||
vm.set('noSubscriptionRepo', status);
|
||||
} else if (handle === "test") {
|
||||
vm.set('testRepo', status);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setSubscriptionStatus: function(status) {
|
||||
let me = this;
|
||||
let vm = me.getViewModel();
|
||||
|
||||
vm.set('subscriptionActive', status);
|
||||
},
|
||||
|
||||
initComponent: function() {
|
||||
let me = this;
|
||||
|
||||
|
|
Loading…
Reference in New Issue