* [pve-devel] [PATCH widget-toolkit] ui: SMART: show SMART data in correct columns
@ 2023-02-01 11:52 Matthias Heiserer
2023-02-07 15:07 ` Thomas Lamprecht
0 siblings, 1 reply; 3+ messages in thread
From: Matthias Heiserer @ 2023-02-01 11:52 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
---
Sorry for the long delay!
v1: https://lists.proxmox.com/pipermail/pve-devel/2022-July/053599.html
Changes from v1:
use Field.calculate as suggested by Dominik
src/window/DiskSmart.js | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/window/DiskSmart.js b/src/window/DiskSmart.js
index 3c8040b..490020d 100644
--- a/src/window/DiskSmart.js
+++ b/src/window/DiskSmart.js
@@ -38,12 +38,12 @@ Ext.define('Proxmox.window.DiskSmart', {
},
{
text: gettext('Value'),
- dataIndex: 'raw',
+ dataIndex: 'real-value',
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Normalized'),
- dataIndex: 'value',
+ dataIndex: 'real-normalized',
width: 60,
},
{
@@ -154,7 +154,26 @@ Ext.define('Proxmox.window.DiskSmart', {
Ext.define('pmx-smart-attribute', {
extend: 'Ext.data.Model',
fields: [
- { name: 'id', type: 'number' }, 'name', 'value', 'worst', 'threshold', 'flags', 'fail', 'raw',
+ { name: 'id', type: 'number' }, 'name', 'value', 'worst', 'threshold', 'flags', 'fail',
+ 'raw', 'normalized',
+ {
+ name: 'real-value',
+ calculate: function(data) {
+ if (data.normalized === undefined) {
+ return data.value; // FIXME remove with next major release (PBS 3.0)
+ }
+ return data.raw;
+ },
+ },
+ {
+ name: 'real-normalized',
+ calculate: function(data) {
+ if (data.normalized === undefined) {
+ return data.raw; // FIXME remove with next major release (PBS 3.0)
+ }
+ return data.normalized;
+ },
+ },
],
idProperty: 'name',
});
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH widget-toolkit] ui: SMART: show SMART data in correct columns
2023-02-01 11:52 [pve-devel] [PATCH widget-toolkit] ui: SMART: show SMART data in correct columns Matthias Heiserer
@ 2023-02-07 15:07 ` Thomas Lamprecht
2023-02-08 10:29 ` Matthias Heiserer
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lamprecht @ 2023-02-07 15:07 UTC (permalink / raw)
To: Proxmox VE development discussion, Matthias Heiserer
Am 01/02/2023 um 12:52 schrieb Matthias Heiserer:
> Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
> ---
>
> Sorry for the long delay!
> v1: https://lists.proxmox.com/pipermail/pve-devel/2022-July/053599.html
> Changes from v1:
> use Field.calculate as suggested by Dominik
>
> src/window/DiskSmart.js | 25 ++++++++++++++++++++++---
> 1 file changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/src/window/DiskSmart.js b/src/window/DiskSmart.js
> index 3c8040b..490020d 100644
> --- a/src/window/DiskSmart.js
> +++ b/src/window/DiskSmart.js
> @@ -38,12 +38,12 @@ Ext.define('Proxmox.window.DiskSmart', {
> },
> {
> text: gettext('Value'),
> - dataIndex: 'raw',
> + dataIndex: 'real-value',
> renderer: Ext.String.htmlEncode,
> },
> {
> text: gettext('Normalized'),
> - dataIndex: 'value',
> + dataIndex: 'real-normalized',
> width: 60,
> },
> {
> @@ -154,7 +154,26 @@ Ext.define('Proxmox.window.DiskSmart', {
> Ext.define('pmx-smart-attribute', {
> extend: 'Ext.data.Model',
> fields: [
> - { name: 'id', type: 'number' }, 'name', 'value', 'worst', 'threshold', 'flags', 'fail', 'raw',
> + { name: 'id', type: 'number' }, 'name', 'value', 'worst', 'threshold', 'flags', 'fail',
> + 'raw', 'normalized',
> + {
> + name: 'real-value',
> + calculate: function(data) {
> + if (data.normalized === undefined) {
> + return data.value; // FIXME remove with next major release (PBS 3.0)
> + }
> + return data.raw;
> + },
Couldn't we use a simple arrow fn? adding 1 instead of 6 line is quite the win
code readability and maintenance wise (it adds up quick ^^). E.g., something like:
calculate: data => data.normalized ? data.raw : data.value,
or if we want to lessen depending on JS's truthiness a bit (didn't recheck what the
API returns here for normalized):
calculate: data => (data.normalized ?? false) ? data.raw : data.value,
> + },
> + {
> + name: 'real-normalized',
> + calculate: function(data) {
> + if (data.normalized === undefined) {
> + return data.raw; // FIXME remove with next major release (PBS 3.0)
> + }
> + return data.normalized;
same here w.r.t. arrow fn line "bloat" reduction, e.g.:
calculate: data => data.normalized ?? data.raw,
> + },
> + },
> ],
> idProperty: 'name',
> });
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH widget-toolkit] ui: SMART: show SMART data in correct columns
2023-02-07 15:07 ` Thomas Lamprecht
@ 2023-02-08 10:29 ` Matthias Heiserer
0 siblings, 0 replies; 3+ messages in thread
From: Matthias Heiserer @ 2023-02-08 10:29 UTC (permalink / raw)
To: Thomas Lamprecht, Proxmox VE development discussion
On 07.02.2023 16:07, Thomas Lamprecht wrote:
> Am 01/02/2023 um 12:52 schrieb Matthias Heiserer:
>> Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
>> ---
>>
>> Sorry for the long delay!
>> v1: https://lists.proxmox.com/pipermail/pve-devel/2022-July/053599.html
>> Changes from v1:
>> use Field.calculate as suggested by Dominik
>>
>> src/window/DiskSmart.js | 25 ++++++++++++++++++++++---
>> 1 file changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/window/DiskSmart.js b/src/window/DiskSmart.js
>> index 3c8040b..490020d 100644
>> --- a/src/window/DiskSmart.js
>> +++ b/src/window/DiskSmart.js
>> @@ -38,12 +38,12 @@ Ext.define('Proxmox.window.DiskSmart', {
>> },
>> {
>> text: gettext('Value'),
>> - dataIndex: 'raw',
>> + dataIndex: 'real-value',
>> renderer: Ext.String.htmlEncode,
>> },
>> {
>> text: gettext('Normalized'),
>> - dataIndex: 'value',
>> + dataIndex: 'real-normalized',
>> width: 60,
>> },
>> {
>> @@ -154,7 +154,26 @@ Ext.define('Proxmox.window.DiskSmart', {
>> Ext.define('pmx-smart-attribute', {
>> extend: 'Ext.data.Model',
>> fields: [
>> - { name: 'id', type: 'number' }, 'name', 'value', 'worst', 'threshold', 'flags', 'fail', 'raw',
>> + { name: 'id', type: 'number' }, 'name', 'value', 'worst', 'threshold', 'flags', 'fail',
>> + 'raw', 'normalized',
>> + {
>> + name: 'real-value',
>> + calculate: function(data) {
>> + if (data.normalized === undefined) {
>> + return data.value; // FIXME remove with next major release (PBS 3.0)
>> + }
>> + return data.raw;
>> + },
>
> Couldn't we use a simple arrow fn? adding 1 instead of 6 line is quite the win
> code readability and maintenance wise (it adds up quick ^^). E.g., something like:
>
> calculate: data => data.normalized ? data.raw : data.value,
Right, I thought the long form is more readable.
IIRC this doesn't work because normalized can be falsy,
>
> or if we want to lessen depending on JS's truthiness a bit (didn't recheck what the
> API returns here for normalized):
>
> calculate: data => (data.normalized ?? false) ? data.raw : data.value,
but this one should work. Will send a v2.
>
>> + },
>> + {
>> + name: 'real-normalized',
>> + calculate: function(data) {
>> + if (data.normalized === undefined) {
>> + return data.raw; // FIXME remove with next major release (PBS 3.0)
>> + }
>> + return data.normalized;
>
> same here w.r.t. arrow fn line "bloat" reduction, e.g.:
>
> calculate: data => data.normalized ?? data.raw
For this also.
>
>> + },
>> + },
>> ],
>> idProperty: 'name',
>> });
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-08 10:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 11:52 [pve-devel] [PATCH widget-toolkit] ui: SMART: show SMART data in correct columns Matthias Heiserer
2023-02-07 15:07 ` Thomas Lamprecht
2023-02-08 10:29 ` Matthias Heiserer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox