summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitalii Lysak <v.lysak@dunice.net>2022-08-03 17:10:44 +0300
committerVitalii Lysak <v.lysak@dunice.net>2022-08-03 17:10:44 +0300
commit3bce3e1f788debaf7e964655c9727a179fa78e1d (patch)
tree68ff143b2851a9ba37eb6c27b73ca4ecaec771cf
parentc9923b6fc173fdbb4ec61dbee7285bce24a0c62c (diff)
downloadwebui-vue-3bce3e1f788debaf7e964655c9727a179fa78e1d.tar.xz
upd serialization for new back api
-rw-r--r--src/components/_sila/Global/Chart.vue8
-rw-r--r--src/store/modules/HardwareStatus/FanStore.js4
-rw-r--r--src/store/modules/HardwareStatus/MemoryStore.js5
-rw-r--r--src/store/modules/HardwareStatus/MotherboardStore.js5
-rw-r--r--src/store/modules/HardwareStatus/ProcessorStore.js9
-rw-r--r--src/utilities/_sila/metricProperties.js30
6 files changed, 25 insertions, 36 deletions
diff --git a/src/components/_sila/Global/Chart.vue b/src/components/_sila/Global/Chart.vue
index fa66683a..4da58798 100644
--- a/src/components/_sila/Global/Chart.vue
+++ b/src/components/_sila/Global/Chart.vue
@@ -76,7 +76,7 @@ export default {
computed: {
readyData() {
let filteredData = this.data.filter((metric) => {
- return metric.MetricValue !== 'nan';
+ return metric.Value !== 'nan';
});
filteredData.sort((a, b) => {
@@ -90,7 +90,7 @@ export default {
return {
...metric,
Timestamp: time,
- MetricValue: Math.round(metric.MetricValue),
+ Value: Math.round(metric.Value),
};
});
@@ -101,7 +101,7 @@ export default {
},
metricData() {
let group = this.readyData.reduce(function (rv, x) {
- (rv[x['MetricProperty']] = rv[x['MetricProperty']] || []).push(x);
+ (rv[x['Sensor']] = rv[x['Sensor']] || []).push(x);
return rv;
}, {});
@@ -116,7 +116,7 @@ export default {
const { length } = arr;
return Math.round(
arr.reduce((acc, val) => {
- return acc + val.MetricValue / length;
+ return acc + val.Value / length;
}, 0)
);
};
diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js
index fed3f742..e58296b5 100644
--- a/src/store/modules/HardwareStatus/FanStore.js
+++ b/src/store/modules/HardwareStatus/FanStore.js
@@ -54,9 +54,9 @@ const FanStore = {
let url = null;
if (lastHour) {
url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=fans&period=last_hour';
+ '/redfish/v1/TelemetryService/MetricReports/fans&period=last_hour';
} else {
- url = '/redfish/v1/TelemetryService/MetricReports/hour_data&id=fans';
+ url = '/redfish/v1/TelemetryService/MetricReports/fans';
}
return await api
.get(url)
diff --git a/src/store/modules/HardwareStatus/MemoryStore.js b/src/store/modules/HardwareStatus/MemoryStore.js
index 358ca725..924d52a1 100644
--- a/src/store/modules/HardwareStatus/MemoryStore.js
+++ b/src/store/modules/HardwareStatus/MemoryStore.js
@@ -68,10 +68,9 @@ const MemoryStore = {
let url = null;
if (lastHour) {
url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=dimm_temp&period=last_hour';
+ '/redfish/v1/TelemetryService/MetricReports/dimm_temp&period=last_hour';
} else {
- url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=dimm_temp';
+ url = '/redfish/v1/TelemetryService/MetricReports/dimm_temp';
}
return await api
.get(url)
diff --git a/src/store/modules/HardwareStatus/MotherboardStore.js b/src/store/modules/HardwareStatus/MotherboardStore.js
index 7b2fe032..09f24498 100644
--- a/src/store/modules/HardwareStatus/MotherboardStore.js
+++ b/src/store/modules/HardwareStatus/MotherboardStore.js
@@ -23,10 +23,9 @@ const MotherboardStore = {
let url = null;
if (lastHour) {
url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=other_temp&period=last_hour';
+ '/redfish/v1/TelemetryService/MetricReports/other_temp&period=last_hour';
} else {
- url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=other_temp';
+ url = '/redfish/v1/TelemetryService/MetricReports/other_temp';
}
return await api
.get(url)
diff --git a/src/store/modules/HardwareStatus/ProcessorStore.js b/src/store/modules/HardwareStatus/ProcessorStore.js
index 5466b85e..68b29ab6 100644
--- a/src/store/modules/HardwareStatus/ProcessorStore.js
+++ b/src/store/modules/HardwareStatus/ProcessorStore.js
@@ -84,9 +84,9 @@ const ProcessorStore = {
let url = null;
if (lastHour) {
url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=power&period=last_hour';
+ '/redfish/v1/TelemetryService/MetricReports/power&period=last_hour';
} else {
- url = '/redfish/v1/TelemetryService/MetricReports/hour_data&id=power';
+ url = '/redfish/v1/TelemetryService/MetricReports/power';
}
return await api
.get(url)
@@ -103,10 +103,9 @@ const ProcessorStore = {
let url = null;
if (lastHour) {
url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=cpu_temp&period=last_hour';
+ '/redfish/v1/TelemetryService/MetricReports/cpu_temp&period=last_hour';
} else {
- url =
- '/redfish/v1/TelemetryService/MetricReports/hour_data&id=cpu_temp';
+ url = '/redfish/v1/TelemetryService/MetricReports/cpu_temp';
}
return await api
.get(url)
diff --git a/src/utilities/_sila/metricProperties.js b/src/utilities/_sila/metricProperties.js
index 32495605..389c4683 100644
--- a/src/utilities/_sila/metricProperties.js
+++ b/src/utilities/_sila/metricProperties.js
@@ -1,6 +1,6 @@
export function getItems(data) {
let filteredData = data.filter((metric) => {
- return metric.MetricValue !== 'nan';
+ return metric.Value !== 'nan';
});
let transform = filteredData.map((metric) => {
@@ -12,19 +12,19 @@ export function getItems(data) {
date.getHours() + ':' + String(date.getMinutes()).padStart(2, '0'),
date: formatDate(date),
},
- MetricValue: Math.round(metric.MetricValue),
+ Value: Math.round(metric.Value),
};
});
let group = transform.reduce(function (rv, x) {
- (rv[x['MetricProperty']] = rv[x['MetricProperty']] || []).push(x);
+ (rv[x['Sensor']] = rv[x['Sensor']] || []).push(x);
return rv;
}, {});
return Object.keys(group).map((metric) => {
return {
name: metric,
- current: group[metric][group[metric].length - 1].MetricValue,
+ current: group[metric][group[metric].length - 1].Value,
middle: findAverage(group[metric]),
min: findMin(group[metric]),
minDate: findDateOfMin(group[metric]),
@@ -50,33 +50,25 @@ function findAverage(arr) {
const { length } = arr;
return Math.round(
arr.reduce((acc, val) => {
- return acc + val.MetricValue / length;
+ return acc + val.Value / length;
}, 0)
);
}
function findMin(arr) {
- return arr.reduce(
- (min, p) => (p.MetricValue < min ? p.MetricValue : min),
- arr[0].MetricValue
- );
+ return arr.reduce((min, p) => (p.Value < min ? p.Value : min), arr[0].Value);
}
function findMax(arr) {
- return arr.reduce(
- (max, p) => (p.MetricValue > max ? p.MetricValue : max),
- arr[0].MetricValue
- );
+ return arr.reduce((max, p) => (p.Value > max ? p.Value : max), arr[0].Value);
}
function findDateOfMin(arr) {
- return arr.reduce((res, obj) =>
- obj.MetricValue < res.MetricValue ? obj : res
- ).Timestamp;
+ return arr.reduce((res, obj) => (obj.Value < res.Value ? obj : res))
+ .Timestamp;
}
function findDateOfMax(arr) {
- return arr.reduce((res, obj) =>
- obj.MetricValue > res.MetricValue ? obj : res
- ).Timestamp;
+ return arr.reduce((res, obj) => (obj.Value > res.Value ? obj : res))
+ .Timestamp;
}