mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-18 05:44:05 +00:00
disk: smart: code & indentation level cleanup
drop some intermediate variables that are 1:1 the original Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
53ecc2ad95
commit
511c7843d0
@ -22,7 +22,7 @@ Ext.define('Proxmox.window.DiskSmart', {
|
|||||||
emptyText: gettext('No S.M.A.R.T. Values'),
|
emptyText: gettext('No S.M.A.R.T. Values'),
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
itemId: 'smarts',
|
itemId: 'smartGrid',
|
||||||
reserveScrollbar: true,
|
reserveScrollbar: true,
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ Ext.define('Proxmox.window.DiskSmart', {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'component',
|
xtype: 'component',
|
||||||
itemId: 'text',
|
itemId: 'smartPlainText',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
@ -101,46 +101,42 @@ Ext.define('Proxmox.window.DiskSmart', {
|
|||||||
],
|
],
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
var me = this;
|
let me = this;
|
||||||
|
|
||||||
if (!me.baseurl) {
|
if (!me.baseurl) {
|
||||||
throw "no baseurl specified";
|
throw "no baseurl specified";
|
||||||
}
|
}
|
||||||
|
if (!me.dev) {
|
||||||
var dev = me.dev;
|
|
||||||
if (!dev) {
|
|
||||||
throw "no device specified";
|
throw "no device specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
me.title = gettext('S.M.A.R.T. Values') + ` (${dev})`;
|
me.title = `${gettext('S.M.A.R.T. Values')} (${me.dev})`;
|
||||||
|
|
||||||
me.store = Ext.create('Ext.data.Store', {
|
me.store = Ext.create('Ext.data.Store', {
|
||||||
model: 'pmx-disk-smart',
|
model: 'pmx-disk-smart',
|
||||||
proxy: {
|
proxy: {
|
||||||
type: 'proxmox',
|
type: 'proxmox',
|
||||||
url: `${me.baseurl}/smart?disk=${dev}`,
|
url: `${me.baseurl}/smart?disk=${me.dev}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
me.callParent();
|
me.callParent();
|
||||||
|
|
||||||
let grid = me.down('#smarts');
|
let grid = me.down('#smartGrid'), plainText = me.down('#smartPlainText');
|
||||||
|
|
||||||
Proxmox.Utils.monStoreErrors(grid, me.store);
|
Proxmox.Utils.monStoreErrors(grid, me.store);
|
||||||
me.mon(me.store, 'load', function(s, records, success) {
|
me.mon(me.store, 'load', function(_store, records, success) {
|
||||||
if (success && records.length > 0) {
|
if (!success || records.length <= 0) {
|
||||||
let rec = records[0];
|
return; // FIXME: clear displayed info?
|
||||||
if (rec.data.type === 'text') {
|
}
|
||||||
grid.setVisible(false);
|
let isPlainText = records[0].data.type === 'text';
|
||||||
|
if (isPlainText) {
|
||||||
me.down('#text').setHtml(Ext.String.htmlEncode(rec.data.text));
|
plainText.setHtml(Ext.String.htmlEncode(records[0].data.text));
|
||||||
me.down('#text').setVisible(true);
|
|
||||||
} else {
|
} else {
|
||||||
grid.setVisible(true);
|
grid.setStore(records[0].attributes());
|
||||||
me.down('#text').setVisible(false);
|
|
||||||
grid.setStore(rec.attributes());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
grid.setVisible(!isPlainText);
|
||||||
|
plainText.setVisible(isPlainText);
|
||||||
});
|
});
|
||||||
|
|
||||||
me.store.load();
|
me.store.load();
|
||||||
|
Loading…
Reference in New Issue
Block a user