summaryrefslogtreecommitdiff
path: root/src/views/Health/Sensors
diff options
context:
space:
mode:
authorYoshie Muranaka <yoshiemuranaka@gmail.com>2020-03-11 22:44:24 +0300
committerYoshie Muranaka <yoshiemuranaka@gmail.com>2020-03-26 00:30:01 +0300
commit30abccbed83aee950016c2da0ae5bf512df769dc (patch)
tree6444a2695de5a4b39c4c64fcfa279beaa990033c /src/views/Health/Sensors
parent5f263e8f47068b802252af36b36f6c6939a4dc81 (diff)
downloadwebui-vue-30abccbed83aee950016c2da0ae5bf512df769dc.tar.xz
Add Sensors page
- Update api calls to use Redfish - Add column sort to name and status columns - Set default table sort to status column - Added lodash package Github story: https://github.com/openbmc/webui-vue/issues/4 Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com> Change-Id: Ic6e76107475fbf5fb34deb01a4de4a4a9ccfeabf
Diffstat (limited to 'src/views/Health/Sensors')
-rw-r--r--src/views/Health/Sensors/Sensors.vue126
-rw-r--r--src/views/Health/Sensors/index.js2
2 files changed, 128 insertions, 0 deletions
diff --git a/src/views/Health/Sensors/Sensors.vue b/src/views/Health/Sensors/Sensors.vue
new file mode 100644
index 00000000..70d4f90d
--- /dev/null
+++ b/src/views/Health/Sensors/Sensors.vue
@@ -0,0 +1,126 @@
+<template>
+ <b-container fluid>
+ <page-title />
+ <b-row>
+ <b-col xl="12">
+ <b-table
+ sort-icon-left
+ no-sort-reset
+ sticky-header="75vh"
+ sort-by="status"
+ :items="allSensors"
+ :fields="fields"
+ :sort-desc="true"
+ :sort-compare="sortCompare"
+ >
+ <template v-slot:cell(status)="{ value }">
+ <status-icon :status="statusIcon(value)" />
+ {{ value }}
+ </template>
+ <template v-slot:cell(currentValue)="data">
+ {{ data.value }} {{ data.item.units }}
+ </template>
+ <template v-slot:cell(lowerCaution)="data">
+ {{ data.value }} {{ data.item.units }}
+ </template>
+ <template v-slot:cell(upperCaution)="data">
+ {{ data.value }} {{ data.item.units }}
+ </template>
+ <template v-slot:cell(lowerCritical)="data">
+ {{ data.value }} {{ data.item.units }}
+ </template>
+ <template v-slot:cell(upperCritical)="data">
+ {{ data.value }} {{ data.item.units }}
+ </template>
+ </b-table>
+ </b-col>
+ </b-row>
+ </b-container>
+</template>
+
+<script>
+import PageTitle from '../../../components/Global/PageTitle';
+import StatusIcon from '../../../components/Global/StatusIcon';
+
+const valueFormatter = value => {
+ if (value === null || value === undefined) {
+ return '--';
+ }
+ return parseFloat(value.toFixed(3));
+};
+
+export default {
+ name: 'Sensors',
+ components: { PageTitle, StatusIcon },
+ data() {
+ return {
+ fields: [
+ {
+ key: 'name',
+ sortable: true,
+ label: this.$t('pageSensors.table.name')
+ },
+ {
+ key: 'status',
+ sortable: true,
+ label: this.$t('pageSensors.table.status')
+ },
+ {
+ key: 'lowerCritical',
+ formatter: valueFormatter,
+ label: this.$t('pageSensors.table.lowerCritical')
+ },
+ {
+ key: 'lowerCaution',
+ formatter: valueFormatter,
+ label: this.$t('pageSensors.table.lowerWarning')
+ },
+
+ {
+ key: 'currentValue',
+ formatter: valueFormatter,
+ label: this.$t('pageSensors.table.currentValue')
+ },
+ {
+ key: 'upperCaution',
+ formatter: valueFormatter,
+ label: this.$t('pageSensors.table.upperWarning')
+ },
+ {
+ key: 'upperCritical',
+ formatter: valueFormatter,
+ label: this.$t('pageSensors.table.upperCritical')
+ }
+ ]
+ };
+ },
+ computed: {
+ allSensors() {
+ return this.$store.getters['sensors/sensors'];
+ }
+ },
+ created() {
+ this.$store.dispatch('sensors/getAllSensors');
+ },
+ methods: {
+ statusIcon(status) {
+ switch (status) {
+ case 'OK':
+ return 'success';
+ case 'Warning':
+ return 'warning';
+ case 'Critical':
+ return 'danger';
+ default:
+ return '';
+ }
+ },
+ sortCompare(a, b, key) {
+ if (key === 'status') {
+ const status = ['OK', 'Warning', 'Critical'];
+ return status.indexOf(a.status) - status.indexOf(b.status);
+ }
+ }
+ }
+};
+</script>
diff --git a/src/views/Health/Sensors/index.js b/src/views/Health/Sensors/index.js
new file mode 100644
index 00000000..fc71b611
--- /dev/null
+++ b/src/views/Health/Sensors/index.js
@@ -0,0 +1,2 @@
+import Sensors from './Sensors.vue';
+export default Sensors;