prune sim: move PruneList to more static declaration

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-10-04 16:32:18 +02:00
parent f44e2386df
commit bb044304aa

View File

@ -109,36 +109,30 @@ Ext.onReady(function() {
extend: 'Ext.panel.Panel', extend: 'Ext.panel.Panel',
alias: 'widget.prunesimulatorPruneList', alias: 'widget.prunesimulatorPruneList',
initComponent: function() { viewModel: {},
let me = this;
if (!me.store) { items: [{
throw "no store specified";
}
me.items = [
{
xtype: 'grid', xtype: 'grid',
store: me.store, bind: {
store: '{store}',
},
border: false, border: false,
columns: [ columns: [
{ {
header: 'Backup Time', header: 'Backup Time',
dataIndex: 'backuptime', dataIndex: 'backuptime',
renderer: function(value, metaData, record) { renderer: function(value, metaData, { data }) {
let text = Ext.Date.format(value, 'Y-m-d H:i:s'); let text = Ext.Date.format(value, 'Y-m-d H:i:s');
if (record.data.mark === 'keep') { if (data.mark !== 'keep') {
return `<div style="text-decoration: line-through;">${text}</div>`;
}
if (me.useColors) { if (me.useColors) {
let bgColor = COLORS[record.data.keepName]; let bgColor = COLORS[data.keepName];
let textColor = TEXT_COLORS[record.data.keepName]; let textColor = TEXT_COLORS[data.keepName];
return '<div style="background-color: ' + bgColor + '; ' + return `<div style="background-color: ${bgColor};color: ${textColor};">${text}</div>`;
'color: ' + textColor + ';">' + text + '</div>';
} else { } else {
return text; return text;
} }
} else {
return '<div style="text-decoration: line-through;">' + text + '</div>';
}
}, },
flex: 1, flex: 1,
sortable: false, sortable: false,
@ -146,26 +140,30 @@ Ext.onReady(function() {
{ {
header: 'Keep (reason)', header: 'Keep (reason)',
dataIndex: 'mark', dataIndex: 'mark',
renderer: function(value, metaData, record) { renderer: function(value, metaData, { data }) {
if (record.data.mark === 'keep') { if (data.mark !== 'keep') {
if (record.data.keepCount) {
return 'keep (' + record.data.keepName +
': ' + record.data.keepCount + ')';
} else {
return 'keep (' + record.data.keepName + ')';
}
} else {
return value; return value;
} }
if (data.keepCount) {
return `keep (${data.keepName}: ${data.keepCount})`;
} else {
return `keep (${data.keepName})`;
}
}, },
width: 200, width: 200,
sortable: false, sortable: false,
}, },
], ],
}, }],
];
initComponent: function() {
let me = this;
if (!me.store) {
throw "no store specified";
}
me.callParent(); me.callParent();
me.getViewModel().set('store', me.store);
}, },
}); });
@ -222,8 +220,7 @@ Ext.onReady(function() {
if (me.useColors) { if (me.useColors) {
let bgColor = COLORS[backup.data.keepName]; let bgColor = COLORS[backup.data.keepName];
let textColor = TEXT_COLORS[backup.data.keepName]; let textColor = TEXT_COLORS[backup.data.keepName];
html += `<span style="background-color: ${bgColor}; html += `<span style="background-color: ${bgColor}; color: ${textColor};">${text}</span>`;
color: ${textColor};">${text}</span>`;
} else { } else {
html += `<span class="black">${text}</span>`; html += `<span class="black">${text}</span>`;
} }