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