xref: /openbmc/webui-vue/src/views/HardwareStatus/Inventory/InventoryTableProcessors.vue (revision de23ea23d88451a2fa2774ec72053772603c23ae)
17affc529SSandeepa Singh<template>
27affc529SSandeepa Singh  <page-section :section-title="$t('pageInventory.processors')">
37affc529SSandeepa Singh    <!-- Search -->
47affc529SSandeepa Singh    <b-row class="align-items-end">
57affc529SSandeepa Singh      <b-col sm="6" md="5" xl="4">
67affc529SSandeepa Singh        <search
77affc529SSandeepa Singh          @change-search="onChangeSearchInput"
87affc529SSandeepa Singh          @clear-search="onClearSearchInput"
97affc529SSandeepa Singh        />
107affc529SSandeepa Singh      </b-col>
117affc529SSandeepa Singh      <b-col sm="6" md="3" xl="2">
127affc529SSandeepa Singh        <table-cell-count
137affc529SSandeepa Singh          :filtered-items-count="filteredRows"
147affc529SSandeepa Singh          :total-number-of-cells="processors.length"
157affc529SSandeepa Singh        ></table-cell-count>
167affc529SSandeepa Singh      </b-col>
177affc529SSandeepa Singh    </b-row>
187affc529SSandeepa Singh    <b-table
197affc529SSandeepa Singh      sort-icon-left
207affc529SSandeepa Singh      no-sort-reset
217affc529SSandeepa Singh      hover
227affc529SSandeepa Singh      responsive="md"
237affc529SSandeepa Singh      show-empty
247affc529SSandeepa Singh      :items="processors"
257affc529SSandeepa Singh      :fields="fields"
267affc529SSandeepa Singh      :sort-desc="true"
277affc529SSandeepa Singh      :filter="searchFilter"
287affc529SSandeepa Singh      :empty-text="$t('global.table.emptyMessage')"
297affc529SSandeepa Singh      :empty-filtered-text="$t('global.table.emptySearchMessage')"
3041057853SKenneth Fullbright      :busy="isBusy"
317affc529SSandeepa Singh      @filtered="onFiltered"
327affc529SSandeepa Singh    >
337affc529SSandeepa Singh      <!-- Expand button -->
347affc529SSandeepa Singh      <template #cell(expandRow)="row">
357affc529SSandeepa Singh        <b-button
367affc529SSandeepa Singh          variant="link"
377affc529SSandeepa Singh          data-test-id="hardwareStatus-button-expandProcessors"
387affc529SSandeepa Singh          :title="expandRowLabel"
397affc529SSandeepa Singh          class="btn-icon-only"
407affc529SSandeepa Singh          @click="toggleRowDetails(row)"
417affc529SSandeepa Singh        >
427affc529SSandeepa Singh          <icon-chevron />
437affc529SSandeepa Singh          <span class="sr-only">{{ expandRowLabel }}</span>
447affc529SSandeepa Singh        </b-button>
457affc529SSandeepa Singh      </template>
467affc529SSandeepa Singh      <!-- Health -->
477affc529SSandeepa Singh      <template #cell(health)="{ value }">
487affc529SSandeepa Singh        <status-icon :status="statusIcon(value)" />
497affc529SSandeepa Singh        {{ value }}
507affc529SSandeepa Singh      </template>
51f44b3fccSGlukhov Mikhail      <!-- StatusState -->
52f44b3fccSGlukhov Mikhail      <template #cell(statusState)="{ value }">
53f44b3fccSGlukhov Mikhail        <status-icon :status="statusStateIcon(value)" />
54f44b3fccSGlukhov Mikhail        {{ value }}
55f44b3fccSGlukhov Mikhail      </template>
567affc529SSandeepa Singh
577affc529SSandeepa Singh      <!-- Toggle identify LED -->
587affc529SSandeepa Singh      <template #cell(identifyLed)="row">
597affc529SSandeepa Singh        <b-form-checkbox
607affc529SSandeepa Singh          v-if="hasIdentifyLed(row.item.identifyLed)"
617affc529SSandeepa Singh          v-model="row.item.identifyLed"
627affc529SSandeepa Singh          name="switch"
637affc529SSandeepa Singh          switch
647affc529SSandeepa Singh          @change="toggleIdentifyLedValue(row.item)"
657affc529SSandeepa Singh        >
667affc529SSandeepa Singh          <span v-if="row.item.identifyLed">
677affc529SSandeepa Singh            {{ $t('global.status.on') }}
687affc529SSandeepa Singh          </span>
697affc529SSandeepa Singh          <span v-else> {{ $t('global.status.off') }} </span>
707affc529SSandeepa Singh        </b-form-checkbox>
717affc529SSandeepa Singh        <div v-else>--</div>
727affc529SSandeepa Singh      </template>
737affc529SSandeepa Singh
747affc529SSandeepa Singh      <template #row-details="{ item }">
757affc529SSandeepa Singh        <b-container fluid>
767affc529SSandeepa Singh          <b-row>
777affc529SSandeepa Singh            <b-col class="mt-2" sm="6" xl="6">
787affc529SSandeepa Singh              <dl>
797affc529SSandeepa Singh                <!-- Name -->
807affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.name') }}:</dt>
819726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.name) }}</dd>
827affc529SSandeepa Singh                <!-- Part Number -->
837affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
849726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.partNumber) }}</dd>
857affc529SSandeepa Singh                <!-- Serial Number -->
867affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
879726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.serialNumber) }}</dd>
887affc529SSandeepa Singh                <!-- Spare Part Number -->
897affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.sparePartNumber') }}:</dt>
909726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.sparePartNumber) }}</dd>
917affc529SSandeepa Singh                <!-- Model -->
927affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.model') }}:</dt>
939726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.model) }}</dd>
947affc529SSandeepa Singh                <!-- Asset Tag -->
957affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.assetTag') }}:</dt>
969726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.assetTag) }}</dd>
977affc529SSandeepa Singh              </dl>
987affc529SSandeepa Singh            </b-col>
997affc529SSandeepa Singh            <b-col class="mt-2" sm="6" xl="6">
1007affc529SSandeepa Singh              <dl>
1017affc529SSandeepa Singh                <!-- Status state -->
1027affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
1039726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.statusState) }}</dd>
1047affc529SSandeepa Singh                <!-- Health Rollup -->
1057affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt>
1069726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.healthRollup) }}</dd>
1077affc529SSandeepa Singh              </dl>
1087affc529SSandeepa Singh            </b-col>
1097affc529SSandeepa Singh          </b-row>
1107affc529SSandeepa Singh          <div class="section-divider mb-3 mt-3"></div>
1117affc529SSandeepa Singh          <b-row>
1127affc529SSandeepa Singh            <b-col class="mt-1" sm="6" xl="6">
1137affc529SSandeepa Singh              <dl>
1147affc529SSandeepa Singh                <!-- Manufacturer -->
1157affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
1169726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.manufacturer) }}</dd>
1177affc529SSandeepa Singh                <!-- Processor Type -->
1187affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.processorType') }}:</dt>
1199726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.processorType) }}</dd>
1207affc529SSandeepa Singh                <!-- Processor Architecture -->
1217affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.processorArchitecture') }}:</dt>
1229726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.processorArchitecture) }}</dd>
1237affc529SSandeepa Singh                <!-- Instruction Set -->
1247affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.instructionSet') }}:</dt>
1259726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.instructionSet) }}</dd>
1267affc529SSandeepa Singh                <!-- Version -->
1277affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.version') }}:</dt>
1289726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.version) }}</dd>
1297affc529SSandeepa Singh              </dl>
1307affc529SSandeepa Singh            </b-col>
1317affc529SSandeepa Singh            <b-col class="mt-1" sm="6" xl="6">
1327affc529SSandeepa Singh              <dl>
1337affc529SSandeepa Singh                <!-- Min Speed MHz -->
1347affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.minSpeedMHz') }}:</dt>
135d0b078f6SGlukhov Mikhail                <dd>
136d0b078f6SGlukhov Mikhail                  {{ dataFormatter(item.minSpeedMHz) }}
137d0b078f6SGlukhov Mikhail                  {{ $t('unit.MHz') }}
138d0b078f6SGlukhov Mikhail                </dd>
1397affc529SSandeepa Singh                <!-- Max Speed MHz -->
1407affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.maxSpeedMHz') }}:</dt>
141d0b078f6SGlukhov Mikhail                <dd>
142d0b078f6SGlukhov Mikhail                  {{ dataFormatter(item.maxSpeedMHz) }}
143d0b078f6SGlukhov Mikhail                  {{ $t('unit.MHz') }}
144d0b078f6SGlukhov Mikhail                </dd>
1457affc529SSandeepa Singh                <!-- Total Cores -->
1467affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.totalCores') }}:</dt>
1479726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.totalCores) }}</dd>
1487affc529SSandeepa Singh                <!-- Total Threads -->
1497affc529SSandeepa Singh                <dt>{{ $t('pageInventory.table.totalThreads') }}:</dt>
1509726f9a7SDixsie Wolmers                <dd>{{ dataFormatter(item.totalThreads) }}</dd>
1517affc529SSandeepa Singh              </dl>
1527affc529SSandeepa Singh            </b-col>
1537affc529SSandeepa Singh          </b-row>
1547affc529SSandeepa Singh        </b-container>
1557affc529SSandeepa Singh      </template>
1567affc529SSandeepa Singh    </b-table>
1577affc529SSandeepa Singh  </page-section>
1587affc529SSandeepa Singh</template>
1597affc529SSandeepa Singh
1607affc529SSandeepa Singh<script>
1617affc529SSandeepa Singhimport PageSection from '@/components/Global/PageSection';
1627affc529SSandeepa Singhimport IconChevron from '@carbon/icons-vue/es/chevron--down/20';
1637affc529SSandeepa Singhimport StatusIcon from '@/components/Global/StatusIcon';
1647affc529SSandeepa Singhimport TableCellCount from '@/components/Global/TableCellCount';
1657affc529SSandeepa Singhimport BVToastMixin from '@/components/Mixins/BVToastMixin';
1667affc529SSandeepa Singhimport TableSortMixin from '@/components/Mixins/TableSortMixin';
1679726f9a7SDixsie Wolmersimport DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
1687affc529SSandeepa Singhimport Search from '@/components/Global/Search';
1697affc529SSandeepa Singhimport SearchFilterMixin, {
1707affc529SSandeepa Singh  searchFilter,
1717affc529SSandeepa Singh} from '@/components/Mixins/SearchFilterMixin';
1727affc529SSandeepa Singhimport TableRowExpandMixin, {
1737affc529SSandeepa Singh  expandRowLabel,
1747affc529SSandeepa Singh} from '@/components/Mixins/TableRowExpandMixin';
175*de23ea23SSurya Vimport { useI18n } from 'vue-i18n';
176*de23ea23SSurya Vimport i18n from '@/i18n';
1777affc529SSandeepa Singh
1787affc529SSandeepa Singhexport default {
1797affc529SSandeepa Singh  components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
1807affc529SSandeepa Singh  mixins: [
1817affc529SSandeepa Singh    BVToastMixin,
1827affc529SSandeepa Singh    TableRowExpandMixin,
1839726f9a7SDixsie Wolmers    DataFormatterMixin,
1847affc529SSandeepa Singh    TableSortMixin,
1857affc529SSandeepa Singh    SearchFilterMixin,
1867affc529SSandeepa Singh  ],
1877affc529SSandeepa Singh  data() {
1887affc529SSandeepa Singh    return {
189*de23ea23SSurya V      $t: useI18n().t,
19041057853SKenneth Fullbright      isBusy: true,
1917affc529SSandeepa Singh      fields: [
1927affc529SSandeepa Singh        {
1937affc529SSandeepa Singh          key: 'expandRow',
1947affc529SSandeepa Singh          label: '',
1957affc529SSandeepa Singh          tdClass: 'table-row-expand',
1967affc529SSandeepa Singh          sortable: false,
1977affc529SSandeepa Singh        },
1987affc529SSandeepa Singh        {
1997affc529SSandeepa Singh          key: 'id',
200*de23ea23SSurya V          label: i18n.global.t('pageInventory.table.id'),
2019726f9a7SDixsie Wolmers          formatter: this.dataFormatter,
2027affc529SSandeepa Singh          sortable: true,
2037affc529SSandeepa Singh        },
2047affc529SSandeepa Singh        {
2057affc529SSandeepa Singh          key: 'health',
206*de23ea23SSurya V          label: i18n.global.t('pageInventory.table.health'),
2079726f9a7SDixsie Wolmers          formatter: this.dataFormatter,
2087affc529SSandeepa Singh          sortable: true,
2097affc529SSandeepa Singh          tdClass: 'text-nowrap',
2107affc529SSandeepa Singh        },
2117affc529SSandeepa Singh        {
212f44b3fccSGlukhov Mikhail          key: 'statusState',
213*de23ea23SSurya V          label: i18n.global.t('pageInventory.table.state'),
214f44b3fccSGlukhov Mikhail          formatter: this.dataFormatter,
215f44b3fccSGlukhov Mikhail          sortable: true,
216f44b3fccSGlukhov Mikhail          tdClass: 'text-nowrap',
217f44b3fccSGlukhov Mikhail        },
218f44b3fccSGlukhov Mikhail        {
2197affc529SSandeepa Singh          key: 'locationNumber',
220*de23ea23SSurya V          label: i18n.global.t('pageInventory.table.locationNumber'),
2219726f9a7SDixsie Wolmers          formatter: this.dataFormatter,
2227affc529SSandeepa Singh          sortable: true,
2237affc529SSandeepa Singh        },
2247affc529SSandeepa Singh        {
2257affc529SSandeepa Singh          key: 'identifyLed',
226*de23ea23SSurya V          label: i18n.global.t('pageInventory.table.identifyLed'),
2279726f9a7SDixsie Wolmers          formatter: this.dataFormatter,
2287affc529SSandeepa Singh          sortable: false,
2297affc529SSandeepa Singh        },
2307affc529SSandeepa Singh      ],
2317affc529SSandeepa Singh      searchFilter: searchFilter,
2327affc529SSandeepa Singh      searchTotalFilteredRows: 0,
2337affc529SSandeepa Singh      expandRowLabel: expandRowLabel,
2347affc529SSandeepa Singh    };
2357affc529SSandeepa Singh  },
2367affc529SSandeepa Singh  computed: {
2377affc529SSandeepa Singh    filteredRows() {
2387affc529SSandeepa Singh      return this.searchFilter
2397affc529SSandeepa Singh        ? this.searchTotalFilteredRows
2407affc529SSandeepa Singh        : this.processors.length;
2417affc529SSandeepa Singh    },
2427affc529SSandeepa Singh    processors() {
2437affc529SSandeepa Singh      return this.$store.getters['processors/processors'];
2447affc529SSandeepa Singh    },
2457affc529SSandeepa Singh  },
2467affc529SSandeepa Singh  created() {
2477affc529SSandeepa Singh    this.$store.dispatch('processors/getProcessorsInfo').finally(() => {
2487affc529SSandeepa Singh      // Emit initial data fetch complete to parent component
2497affc529SSandeepa Singh      this.$root.$emit('hardware-status-processors-complete');
25041057853SKenneth Fullbright      this.isBusy = false;
2517affc529SSandeepa Singh    });
2527affc529SSandeepa Singh  },
2537affc529SSandeepa Singh  methods: {
2547affc529SSandeepa Singh    onFiltered(filteredItems) {
2557affc529SSandeepa Singh      this.searchTotalFilteredRows = filteredItems.length;
2567affc529SSandeepa Singh    },
2577affc529SSandeepa Singh    toggleIdentifyLedValue(row) {
2587affc529SSandeepa Singh      this.$store
2597affc529SSandeepa Singh        .dispatch('processors/updateIdentifyLedValue', {
2607affc529SSandeepa Singh          uri: row.uri,
2617affc529SSandeepa Singh          identifyLed: row.identifyLed,
2627affc529SSandeepa Singh        })
263f11a1901SNikhil Ashoka        .then((message) => this.successToast(message))
2647affc529SSandeepa Singh        .catch(({ message }) => this.errorToast(message));
2657affc529SSandeepa Singh    },
2667affc529SSandeepa Singh    // TO DO: remove hasIdentifyLed when the following is merged:
2677affc529SSandeepa Singh    // https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/37045
2687affc529SSandeepa Singh    hasIdentifyLed(identifyLed) {
2697affc529SSandeepa Singh      return typeof identifyLed === 'boolean';
2707affc529SSandeepa Singh    },
271f44b3fccSGlukhov Mikhail    statusStateIcon(status) {
272f44b3fccSGlukhov Mikhail      switch (status) {
273f44b3fccSGlukhov Mikhail        case 'Enabled':
274f44b3fccSGlukhov Mikhail          return 'success';
275f44b3fccSGlukhov Mikhail        case 'Absent':
276f44b3fccSGlukhov Mikhail          return 'warning';
277f44b3fccSGlukhov Mikhail        default:
278f44b3fccSGlukhov Mikhail          return '';
279f44b3fccSGlukhov Mikhail      }
280f44b3fccSGlukhov Mikhail    },
2817affc529SSandeepa Singh  },
2827affc529SSandeepa Singh};
2837affc529SSandeepa Singh</script>
284