mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-09 21:03:47 +00:00
node/APTRepositories: improve error/warning display
always show grid besides status, with the accumulated stati/warnings/errors Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
f59d1076d7
commit
5e0cecb7d5
@ -114,19 +114,25 @@ Ext.define('Proxmox.node.APTRepositoriesErrors', {
|
|||||||
|
|
||||||
viewConfig: {
|
viewConfig: {
|
||||||
stripeRows: false,
|
stripeRows: false,
|
||||||
getRowClass: () => 'proxmox-invalid-row',
|
getRowClass: (record) => {
|
||||||
|
switch (record.data.status) {
|
||||||
|
case 'warning': return 'proxmox-warning-row';
|
||||||
|
case 'critical': return 'proxmox-invalid-row';
|
||||||
|
default: return '';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
hideHeaders: true,
|
||||||
|
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
header: gettext('File'),
|
dataIndex: 'status',
|
||||||
dataIndex: 'path',
|
renderer: (value) => `<i class="fa fa-fw ${Proxmox.Utils.get_health_icon(value, true)}"></i>`,
|
||||||
renderer: value => `<i class='pve-grid-fa fa fa-fw fa-exclamation-triangle'></i>${value}`,
|
width: 50,
|
||||||
width: 350,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: gettext('Error'),
|
dataIndex: 'message',
|
||||||
dataIndex: 'error',
|
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -424,16 +430,19 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
let me = this;
|
let me = this;
|
||||||
let vm = me.getViewModel();
|
let vm = me.getViewModel();
|
||||||
|
|
||||||
if (vm.get('errorCount') > 0) {
|
let store = vm.get('errorstore');
|
||||||
vm.set('state', {
|
store.removeAll();
|
||||||
iconCls: Proxmox.Utils.get_health_icon('critical', true),
|
|
||||||
text: gettext('Error parsing repositories'),
|
let errors = vm.get('errors');
|
||||||
|
errors.forEach((error) => {
|
||||||
|
store.add({
|
||||||
|
status: 'critical',
|
||||||
|
message: `${error.path} - ${error.error}`,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let text = gettext('Repositories are configured in a recommended way');
|
let text = gettext('Repositories are configured in a recommended way');
|
||||||
let status = 'warning';
|
let status = 'good';
|
||||||
|
|
||||||
let activeSubscription = vm.get('subscriptionActive');
|
let activeSubscription = vm.get('subscriptionActive');
|
||||||
let enterprise = vm.get('enterpriseRepo');
|
let enterprise = vm.get('enterpriseRepo');
|
||||||
@ -441,18 +450,52 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
let test = vm.get('testRepo');
|
let test = vm.get('testRepo');
|
||||||
let wrongSuites = vm.get('suitesWarning');
|
let wrongSuites = vm.get('suitesWarning');
|
||||||
|
|
||||||
|
let addGood = function(message) {
|
||||||
|
store.add({
|
||||||
|
status: 'good',
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let addWarn = function(message) {
|
||||||
|
status = 'warning';
|
||||||
|
text = message;
|
||||||
|
store.add({
|
||||||
|
status,
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!enterprise && !nosubscription && !test) {
|
||||||
|
addWarn(Ext.String.format(gettext('No {0} repository is enabled!'), vm.get('product')));
|
||||||
|
} else if (enterprise && !nosubscription && !test && activeSubscription) {
|
||||||
|
addGood(Ext.String.format(gettext('You get supported updates for {0}'), vm.get('product')));
|
||||||
|
} else if (nosubscription || test) {
|
||||||
|
addGood(Ext.String.format(gettext('You get updates for {0}'), vm.get('product')));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wrongSuites) {
|
||||||
|
addWarn(gettext('Some Suites are misconfigured'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!activeSubscription && enterprise) {
|
if (!activeSubscription && enterprise) {
|
||||||
text = gettext('The enterprise repository is enabled, but there is no active subscription!');
|
addWarn(gettext('The enterprise repository is enabled, but there is no active subscription!'));
|
||||||
} else if (nosubscription) {
|
}
|
||||||
text = gettext('The no-subscription repository is not recommended for production use!');
|
|
||||||
} else if (test) {
|
if (nosubscription) {
|
||||||
text = gettext('The test repository is not recommended for production use!');
|
addWarn(gettext('The no-subscription repository is not recommended for production use!'));
|
||||||
} else if (!enterprise && !nosubscription && !test) {
|
}
|
||||||
text = Ext.String.format(gettext('No {0} repository is enabled!'), vm.get('product'));
|
|
||||||
} else if (wrongSuites) {
|
if (test) {
|
||||||
text = gettext('Some Suites are misconfigured');
|
addWarn(gettext('The test repository is not recommended for production use!'));
|
||||||
} else {
|
}
|
||||||
status = 'good';
|
|
||||||
|
if (errors.length > 0) {
|
||||||
|
vm.set('state', {
|
||||||
|
iconCls: Proxmox.Utils.get_health_icon('critical', true),
|
||||||
|
text: gettext('Error parsing repositories'),
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let iconCls = Proxmox.Utils.get_health_icon(status, true);
|
let iconCls = Proxmox.Utils.get_health_icon(status, true);
|
||||||
@ -467,7 +510,7 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
viewModel: {
|
viewModel: {
|
||||||
data: {
|
data: {
|
||||||
product: 'Proxmox VE', // default
|
product: 'Proxmox VE', // default
|
||||||
errorCount: 0,
|
errors: [],
|
||||||
suitesWarning: false,
|
suitesWarning: false,
|
||||||
subscriptionActive: '',
|
subscriptionActive: '',
|
||||||
noSubscriptionRepo: '',
|
noSubscriptionRepo: '',
|
||||||
@ -477,10 +520,14 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
state: {},
|
state: {},
|
||||||
},
|
},
|
||||||
formulas: {
|
formulas: {
|
||||||
noErrors: (get) => get('errorCount') === 0,
|
|
||||||
enableButtonText: (get) => get('selectionenabled')
|
enableButtonText: (get) => get('selectionenabled')
|
||||||
? gettext('Disable') : gettext('Enable'),
|
? gettext('Disable') : gettext('Enable'),
|
||||||
},
|
},
|
||||||
|
stores: {
|
||||||
|
errorstore: {
|
||||||
|
fields: ['status', 'message'],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
@ -497,7 +544,7 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
type: 'hbox',
|
type: 'hbox',
|
||||||
align: 'stretch',
|
align: 'stretch',
|
||||||
},
|
},
|
||||||
height: 150,
|
height: 200,
|
||||||
title: gettext('Status'),
|
title: gettext('Status'),
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
@ -523,10 +570,9 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
xtype: 'proxmoxNodeAPTRepositoriesErrors',
|
xtype: 'proxmoxNodeAPTRepositoriesErrors',
|
||||||
name: 'repositoriesErrors',
|
name: 'repositoriesErrors',
|
||||||
flex: 2,
|
flex: 2,
|
||||||
hidden: true,
|
|
||||||
margin: 10,
|
margin: 10,
|
||||||
bind: {
|
bind: {
|
||||||
hidden: '{noErrors}',
|
store: '{errorstore}',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -593,7 +639,6 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
let me = this;
|
let me = this;
|
||||||
let vm = me.getViewModel();
|
let vm = me.getViewModel();
|
||||||
let repoGrid = me.down('proxmoxNodeAPTRepositoriesGrid');
|
let repoGrid = me.down('proxmoxNodeAPTRepositoriesGrid');
|
||||||
let errorGrid = me.down('proxmoxNodeAPTRepositoriesErrors');
|
|
||||||
|
|
||||||
me.store.load(function(records, operation, success) {
|
me.store.load(function(records, operation, success) {
|
||||||
let gridData = [];
|
let gridData = [];
|
||||||
@ -657,11 +702,9 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
|
|
||||||
me.digest = digest;
|
me.digest = digest;
|
||||||
|
|
||||||
vm.set('errorCount', errors.length);
|
vm.set('errors', errors);
|
||||||
vm.set('suitesWarning', suitesWarning);
|
vm.set('suitesWarning', suitesWarning);
|
||||||
me.getController().updateState();
|
me.getController().updateState();
|
||||||
|
|
||||||
errorGrid.store.loadData(errors);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
me.check_subscription();
|
me.check_subscription();
|
||||||
|
Loading…
Reference in New Issue
Block a user