ui: cleanup - reuse existing code

This commit is contained in:
Dietmar Maurer 2021-02-19 09:14:31 +01:00
parent 9e860ac01a
commit e6122a657e
2 changed files with 6 additions and 106 deletions

View File

@ -101,56 +101,6 @@ Ext.define('PBS.config.SyncJobView', {
});
},
render_sync_status: function(value, metadata, record) {
if (!record.data['last-run-upid']) {
return '-';
}
if (!record.data['last-run-endtime']) {
metadata.tdCls = 'x-grid-row-loading';
return '';
}
let parsed = Proxmox.Utils.parse_task_status(value);
let text = value;
let icon = '';
switch (parsed) {
case 'unknown':
icon = 'question faded';
text = Proxmox.Utils.unknownText;
break;
case 'error':
icon = 'times critical';
text = Proxmox.Utils.errorText + ': ' + value;
break;
case 'warning':
icon = 'exclamation warning';
break;
case 'ok':
icon = 'check good';
text = gettext("OK");
}
return `<i class="fa fa-${icon}"></i> ${text}`;
},
render_next_run: function(value, metadat, record) {
if (!value) return '-';
let now = new Date();
let next = new Date(value*1000);
if (next < now) {
return gettext('pending');
}
return Proxmox.Utils.render_timestamp(value);
},
render_optional_timestamp: function(value, metadata, record) {
if (!value) return '-';
return Proxmox.Utils.render_timestamp(value);
},
render_optional_owner: function(value, metadata, record) {
if (!value) return '-';
return Ext.String.htmlEncode(value, metadata, record);
@ -275,7 +225,7 @@ Ext.define('PBS.config.SyncJobView', {
{
header: gettext('Last Sync'),
dataIndex: 'last-run-endtime',
renderer: 'render_optional_timestamp',
renderer: PBS.Utils.render_optional_timestamp,
width: 150,
sortable: true,
},
@ -288,13 +238,13 @@ Ext.define('PBS.config.SyncJobView', {
{
header: gettext('Status'),
dataIndex: 'last-run-state',
renderer: 'render_sync_status',
renderer: PBS.Utils.render_task_status,
flex: 3,
},
{
header: gettext('Next Run'),
dataIndex: 'next-run',
renderer: 'render_next_run',
renderer: PBS.Utils.render_next_task_run,
width: 150,
sortable: true,
},

View File

@ -101,56 +101,6 @@ Ext.define('PBS.config.VerifyJobView', {
});
},
render_verify_status: function(value, metadata, record) {
if (!record.data['last-run-upid']) {
return '-';
}
if (!record.data['last-run-endtime']) {
metadata.tdCls = 'x-grid-row-loading';
return '';
}
let parsed = Proxmox.Utils.parse_task_status(value);
let text = value;
let icon = '';
switch (parsed) {
case 'unknown':
icon = 'question faded';
text = Proxmox.Utils.unknownText;
break;
case 'error':
icon = 'times critical';
text = Proxmox.Utils.errorText + ': ' + value;
break;
case 'warning':
icon = 'exclamation warning';
break;
case 'ok':
icon = 'check good';
text = gettext("OK");
}
return `<i class="fa fa-${icon}"></i> ${text}`;
},
render_next_run: function(value, metadat, record) {
if (!value) return '-';
let now = new Date();
let next = new Date(value*1000);
if (next < now) {
return gettext('pending');
}
return Proxmox.Utils.render_timestamp(value);
},
render_optional_timestamp: function(value, metadata, record) {
if (!value) return '-';
return Proxmox.Utils.render_timestamp(value);
},
startStore: function() { this.getView().getStore().rstore.startUpdate(); },
stopStore: function() { this.getView().getStore().rstore.stopUpdate(); },
@ -264,7 +214,7 @@ Ext.define('PBS.config.VerifyJobView', {
{
header: gettext('Last Verification'),
dataIndex: 'last-run-endtime',
renderer: 'render_optional_timestamp',
renderer: PBS.Utils.render_optional_timestamp,
width: 150,
sortable: true,
},
@ -277,13 +227,13 @@ Ext.define('PBS.config.VerifyJobView', {
{
header: gettext('Status'),
dataIndex: 'last-run-state',
renderer: 'render_verify_status',
renderer: PBS.Utils.render_task_status,
flex: 3,
},
{
header: gettext('Next Run'),
dataIndex: 'next-run',
renderer: 'render_next_run',
renderer: PBS.Utils.render_next_task_run,
width: 150,
sortable: true,
},