1<template>
2  <page-section :section-title="$t('pageInventory.system')">
3    <b-table
4      responsive="md"
5      hover
6      show-empty
7      :items="systems"
8      :fields="fields"
9      :empty-text="$t('global.table.emptyMessage')"
10    >
11      <!-- Expand chevron icon -->
12      <template #cell(expandRow)="row">
13        <b-button
14          variant="link"
15          data-test-id="hardwareStatus-button-expandSystem"
16          :title="expandRowLabel"
17          class="btn-icon-only"
18          @click="toggleRowDetails(row)"
19        >
20          <icon-chevron />
21          <span class="sr-only">{{ expandRowLabel }}</span>
22        </b-button>
23      </template>
24
25      <!-- Health -->
26      <template #cell(health)="{ value }">
27        <status-icon :status="statusIcon(value)" />
28        {{ value }}
29      </template>
30
31      <template #cell(locationIndicatorActive)="{ item }">
32        <b-form-checkbox
33          id="identifyLedSwitchSystem"
34          v-model="item.locationIndicatorActive"
35          data-test-id="inventorySystem-toggle-identifyLed"
36          switch
37          @change="toggleIdentifyLedSwitch"
38        >
39          <span v-if="item.locationIndicatorActive">
40            {{ $t('global.status.on') }}
41          </span>
42          <span v-else>{{ $t('global.status.off') }}</span>
43        </b-form-checkbox>
44      </template>
45
46      <template #row-details="{ item }">
47        <b-container fluid>
48          <b-row>
49            <b-col class="mt-2" sm="6">
50              <dl>
51                <!-- Serial number -->
52                <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
53                <dd>{{ dataFormatter(item.serialNumber) }}</dd>
54                <!-- Model -->
55                <dt>{{ $t('pageInventory.table.model') }}:</dt>
56                <dd>{{ dataFormatter(item.model) }}</dd>
57                <!-- Asset tag -->
58                <dt>{{ $t('pageInventory.table.assetTag') }}:</dt>
59                <dd class="mb-2">
60                  {{ dataFormatter(item.assetTag) }}
61                </dd>
62              </dl>
63            </b-col>
64            <b-col class="mt-2" sm="6">
65              <dl>
66                <!-- Status state -->
67                <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
68                <dd>{{ dataFormatter(item.statusState) }}</dd>
69                <!-- Power state -->
70                <dt>{{ $t('pageInventory.table.power') }}:</dt>
71                <dd>{{ dataFormatter(item.powerState) }}</dd>
72                <!-- Health rollup -->
73                <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt>
74                <dd>{{ dataFormatter(item.healthRollup) }}</dd>
75              </dl>
76            </b-col>
77          </b-row>
78          <div class="section-divider mb-3 mt-3"></div>
79          <b-row>
80            <b-col class="mt-1" sm="6">
81              <dl>
82                <!-- Manufacturer -->
83                <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
84                <dd>{{ dataFormatter(item.manufacturer) }}</dd>
85                <!-- Description -->
86                <dt>{{ $t('pageInventory.table.description') }}:</dt>
87                <dd>{{ dataFormatter(item.description) }}</dd>
88                <!-- Sub Model -->
89                <dt>{{ $t('pageInventory.table.subModel') }}:</dt>
90                <dd>
91                  {{ dataFormatter(item.subModel) }}
92                </dd>
93                <!-- System Type -->
94                <dt>{{ $t('pageInventory.table.systemType') }}:</dt>
95                <dd>
96                  {{ dataFormatter(item.systemType) }}
97                </dd>
98              </dl>
99            </b-col>
100            <b-col sm="6">
101              <!-- Memory Summary -->
102              <p class="mt-1 mb-2 h6 float-none m-0">
103                {{ $t('pageInventory.table.memorySummary') }}
104              </p>
105              <dl class="ml-4">
106                <!-- Status state -->
107                <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
108                <dd>{{ dataFormatter(item.memorySummaryState) }}</dd>
109                <!-- Health -->
110                <dt>{{ $t('pageInventory.table.health') }}:</dt>
111                <dd>{{ dataFormatter(item.memorySummaryHealth) }}</dd>
112                <!-- Health Roll  -->
113                <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt>
114                <dd>{{ dataFormatter(item.memorySummaryHealthRoll) }}</dd>
115              </dl>
116              <!-- Processor Summary -->
117              <p class="mt-1 mb-2 h6 float-none m-0">
118                {{ $t('pageInventory.table.processorSummary') }}
119              </p>
120              <dl class="ml-4">
121                <!-- Status state -->
122                <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
123                <dd>{{ dataFormatter(item.processorSummaryState) }}</dd>
124                <!-- Health -->
125                <dt>{{ $t('pageInventory.table.health') }}:</dt>
126                <dd>{{ dataFormatter(item.processorSummaryHealth) }}</dd>
127                <!-- Health Rollup -->
128                <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt>
129                <dd>{{ dataFormatter(item.processorSummaryHealthRoll) }}</dd>
130                <!-- Count -->
131                <dt>{{ $t('pageInventory.table.count') }}:</dt>
132                <dd>{{ dataFormatter(item.processorSummaryCount) }}</dd>
133              </dl>
134            </b-col>
135          </b-row>
136        </b-container>
137      </template>
138    </b-table>
139  </page-section>
140</template>
141
142<script>
143import BVToastMixin from '@/components/Mixins/BVToastMixin';
144import PageSection from '@/components/Global/PageSection';
145import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
146
147import StatusIcon from '@/components/Global/StatusIcon';
148
149import TableRowExpandMixin, {
150  expandRowLabel,
151} from '@/components/Mixins/TableRowExpandMixin';
152import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
153
154export default {
155  components: { IconChevron, PageSection, StatusIcon },
156  mixins: [BVToastMixin, TableRowExpandMixin, DataFormatterMixin],
157  data() {
158    return {
159      fields: [
160        {
161          key: 'expandRow',
162          label: '',
163          tdClass: 'table-row-expand',
164        },
165        {
166          key: 'id',
167          label: this.$t('pageInventory.table.id'),
168          formatter: this.dataFormatter,
169        },
170        {
171          key: 'hardwareType',
172          label: this.$t('pageInventory.table.hardwareType'),
173          formatter: this.dataFormatter,
174          tdClass: 'text-nowrap',
175        },
176        {
177          key: 'health',
178          label: this.$t('pageInventory.table.health'),
179          formatter: this.dataFormatter,
180          tdClass: 'text-nowrap',
181        },
182        {
183          key: 'locationNumber',
184          label: this.$t('pageInventory.table.locationNumber'),
185          formatter: this.dataFormatter,
186        },
187        {
188          key: 'locationIndicatorActive',
189          label: this.$t('pageInventory.table.identifyLed'),
190          formatter: this.dataFormatter,
191        },
192      ],
193      expandRowLabel: expandRowLabel,
194    };
195  },
196  computed: {
197    systems() {
198      return this.$store.getters['system/systems'];
199    },
200  },
201  created() {
202    this.$store.dispatch('system/getSystem').finally(() => {
203      // Emit initial data fetch complete to parent component
204      this.$root.$emit('hardware-status-system-complete');
205    });
206  },
207  methods: {
208    toggleIdentifyLedSwitch(state) {
209      this.$store
210        .dispatch('system/changeIdentifyLedState', state)
211        .catch(({ message }) => this.errorToast(message));
212    },
213  },
214};
215</script>
216