From 05388966bc9ff2d65e7696c209a5827e82d61297 Mon Sep 17 00:00:00 2001
From: Sukanya Pandey <sukapan1@in.ibm.com>
Date: Thu, 10 Jun 2021 15:35:21 +0530
Subject: Add system attention indicators

- Different LEDs and statuses will be added to hardware status page
- Status for power will be shown and LED included is System identify Led

Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com>
Change-Id: I8689f7bf3cc02a7a90379ec50b005bf344c091e4
---
 .../Inventory/InventoryServiceIndicator.vue        | 80 ++++++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 src/views/HardwareStatus/Inventory/InventoryServiceIndicator.vue

(limited to 'src/views/HardwareStatus/Inventory/InventoryServiceIndicator.vue')

diff --git a/src/views/HardwareStatus/Inventory/InventoryServiceIndicator.vue b/src/views/HardwareStatus/Inventory/InventoryServiceIndicator.vue
new file mode 100644
index 00000000..8acf43c5
--- /dev/null
+++ b/src/views/HardwareStatus/Inventory/InventoryServiceIndicator.vue
@@ -0,0 +1,80 @@
+<template>
+  <page-section
+    :section-title="$t('pageInventory.systemIndicator.sectionTitle')"
+  >
+    <div class="form-background pl-4 pt-4 pb-1">
+      <b-row>
+        <b-col sm="6" md="3">
+          <dl>
+            <dt>{{ $t('pageInventory.systemIndicator.powerStatus') }}</dt>
+            <dd>
+              {{ $t(powerStatus) }}
+            </dd>
+          </dl>
+        </b-col>
+        <b-col sm="6" md="3">
+          <dl>
+            <dt>
+              {{ $t('pageInventory.systemIndicator.identifyLed') }}
+            </dt>
+            <dd>
+              <b-form-checkbox
+                id="identifyLedSwitchService"
+                v-model="systems.locationIndicatorActive"
+                data-test-id="inventoryService-toggle-identifyLed"
+                switch
+                @change="toggleIdentifyLedSwitch"
+              >
+                <span class="sr-only">
+                  {{ $t('pageInventory.systemIndicator.identifyLed') }}
+                </span>
+                <span v-if="systems.locationIndicatorActive">
+                  {{ $t('global.status.on') }}
+                </span>
+                <span v-else>{{ $t('global.status.off') }}</span>
+              </b-form-checkbox>
+            </dd>
+          </dl>
+        </b-col>
+      </b-row>
+    </div>
+  </page-section>
+</template>
+<script>
+import PageSection from '@/components/Global/PageSection';
+import BVToastMixin from '@/components/Mixins/BVToastMixin';
+import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
+
+export default {
+  components: { PageSection },
+  mixins: [BVToastMixin, TableDataFormatterMixin],
+  computed: {
+    systems() {
+      let systemData = this.$store.getters['system/systems'][0];
+      return systemData ? systemData : {};
+    },
+    serverStatus() {
+      return this.$store.getters['global/serverStatus'];
+    },
+    powerStatus() {
+      if (this.serverStatus === 'unreachable') {
+        return `global.status.off`;
+      }
+      return `global.status.${this.serverStatus}`;
+    },
+  },
+  created() {
+    this.$store.dispatch('system/getSystem').finally(() => {
+      // Emit initial data fetch complete to parent component
+      this.$root.$emit('hardware-status-service-complete');
+    });
+  },
+  methods: {
+    toggleIdentifyLedSwitch(state) {
+      this.$store
+        .dispatch('system/changeIdentifyLedState', state)
+        .catch(({ message }) => this.errorToast(message));
+    },
+  },
+};
+</script>
-- 
cgit v1.2.3

