blob: 4783f823465af561b0b62e593f508f152b91ee1c [file] [log] [blame]
Yoshie Muranaka22d4d522020-12-03 10:58:35 -08001<template>
2 <b-container fluid="xl">
3 <page-title />
4 <b-row>
5 <b-col sm="6" lg="5" xl="4">
Yoshie Muranakaf415a082020-12-07 13:04:11 -08006 <page-section :section-title="$t('pageDumps.initiateDump')">
Yoshie Muranaka22d4d522020-12-03 10:58:35 -08007 <dumps-form />
8 </page-section>
9 </b-col>
10 </b-row>
11 <b-row>
12 <b-col xl="10">
Yoshie Muranakaf415a082020-12-07 13:04:11 -080013 <page-section :section-title="$t('pageDumps.dumpsAvailableOnBmc')">
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080014 <b-row class="align-items-start">
15 <b-col sm="8" xl="6" class="d-sm-flex align-items-end">
16 <search
17 :placeholder="$t('pageDumps.table.searchDumps')"
18 @change-search="onChangeSearchInput"
19 @clear-search="onClearSearchInput"
20 />
21 <div class="ml-sm-4">
22 <table-cell-count
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053023 :filtered-items-count="filteredRows"
24 :total-number-of-cells="allDumps.length"
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080025 ></table-cell-count>
26 </div>
27 </b-col>
28 <b-col sm="8" md="7" xl="6">
29 <table-date-filter @change="onChangeDateTimeFilter" />
30 </b-col>
31 </b-row>
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053032 <b-row>
33 <b-col class="text-right">
34 <table-filter
35 :filters="tableFilters"
36 @filter-change="onFilterChange"
37 />
38 </b-col>
39 </b-row>
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080040 <table-toolbar
41 :selected-items-count="selectedRows.length"
42 :actions="batchActions"
43 @clear-selected="clearSelectedRows($refs.table)"
44 @batch-action="onTableBatchAction"
45 />
46 <b-table
47 ref="table"
48 show-empty
49 hover
50 sort-icon-left
51 no-sort-reset
Yoshie Muranakaf415a082020-12-07 13:04:11 -080052 sort-desc
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080053 selectable
54 no-select-on-click
55 responsive="md"
56 sort-by="dateTime"
57 :fields="fields"
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053058 :items="filteredDumps"
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080059 :empty-text="$t('global.table.emptyMessage')"
60 :empty-filtered-text="$t('global.table.emptySearchMessage')"
61 :filter="searchFilter"
Kenneth Fullbright41057852021-12-27 16:19:37 -060062 :busy="isBusy"
Nikhil Ashokad7cd12c2024-05-28 11:56:41 +053063 @filtered="onFiltered"
Kenneth Fullbright41057852021-12-27 16:19:37 -060064 @row-selected="onRowSelected($event, filteredTableItems.length)"
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080065 >
66 <!-- Checkbox column -->
67 <template #head(checkbox)>
68 <b-form-checkbox
69 v-model="tableHeaderCheckboxModel"
70 :indeterminate="tableHeaderCheckboxIndeterminate"
71 @change="onChangeHeaderCheckbox($refs.table)"
72 >
73 <span class="sr-only">{{ $t('global.table.selectAll') }}</span>
74 </b-form-checkbox>
75 </template>
76 <template #cell(checkbox)="row">
77 <b-form-checkbox
78 v-model="row.rowSelected"
79 @change="toggleSelectRow($refs.table, row.index)"
80 >
81 <span class="sr-only">{{ $t('global.table.selectItem') }}</span>
82 </b-form-checkbox>
83 </template>
84
85 <!-- Date and Time column -->
86 <template #cell(dateTime)="{ value }">
Surya Vde23ea22024-07-11 15:19:46 +053087 <p class="mb-0">{{ $filters.formatDate(value) }}</p>
88 <p class="mb-0">{{ $filters.formatTime(value) }}</p>
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080089 </template>
90
91 <!-- Size column -->
92 <template #cell(size)="{ value }">
93 {{ convertBytesToMegabytes(value) }} MB
94 </template>
95
96 <!-- Actions column -->
97 <template #cell(actions)="row">
98 <table-row-action
99 v-for="(action, index) in row.item.actions"
100 :key="index"
101 :value="action.value"
102 :title="action.title"
Yoshie Muranakaa87f3e72021-01-04 14:08:04 -0800103 :download-location="row.item.data"
Sneha Patel3f9cfa22021-06-04 16:06:08 -0500104 :export-name="exportFileName(row)"
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800105 @click-table-action="onTableRowAction($event, row.item)"
106 >
107 <template #icon>
Yoshie Muranakaa87f3e72021-01-04 14:08:04 -0800108 <icon-download v-if="action.value === 'download'" />
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800109 <icon-delete v-if="action.value === 'delete'" />
110 </template>
111 </table-row-action>
112 </template>
113 </b-table>
114 </page-section>
115 </b-col>
116 </b-row>
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530117 <!-- Table pagination -->
118 <b-row>
119 <b-col sm="6" xl="5">
120 <b-form-group
121 class="table-pagination-select"
122 :label="$t('global.table.itemsPerPage')"
123 label-for="pagination-items-per-page"
124 >
125 <b-form-select
126 id="pagination-items-per-page"
127 v-model="perPage"
128 :options="itemsPerPageOptions"
129 />
130 </b-form-group>
131 </b-col>
132 <b-col sm="6" xl="5">
133 <b-pagination
134 v-model="currentPage"
135 first-number
136 last-number
137 :per-page="perPage"
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530138 :total-rows="getTotalRowCount()"
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530139 aria-controls="table-dump-entries"
140 />
141 </b-col>
142 </b-row>
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800143 </b-container>
144</template>
145
146<script>
147import IconDelete from '@carbon/icons-vue/es/trash-can/20';
Yoshie Muranakaa87f3e72021-01-04 14:08:04 -0800148import IconDownload from '@carbon/icons-vue/es/download/20';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800149import DumpsForm from './DumpsForm';
150import PageSection from '@/components/Global/PageSection';
151import PageTitle from '@/components/Global/PageTitle';
152import Search from '@/components/Global/Search';
153import TableCellCount from '@/components/Global/TableCellCount';
154import TableDateFilter from '@/components/Global/TableDateFilter';
155import TableRowAction from '@/components/Global/TableRowAction';
156import TableToolbar from '@/components/Global/TableToolbar';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800157import BVTableSelectableMixin, {
158 selectedRows,
159 tableHeaderCheckboxModel,
160 tableHeaderCheckboxIndeterminate,
161} from '@/components/Mixins/BVTableSelectableMixin';
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800162import BVToastMixin from '@/components/Mixins/BVToastMixin';
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530163import BVPaginationMixin, {
164 currentPage,
165 perPage,
166 itemsPerPageOptions,
167} from '@/components/Mixins/BVPaginationMixin';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800168import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
169import SearchFilterMixin, {
170 searchFilter,
171} from '@/components/Mixins/SearchFilterMixin';
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530172import TableFilter from '@/components/Global/TableFilter';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800173import TableFilterMixin from '@/components/Mixins/TableFilterMixin';
Surya Vde23ea22024-07-11 15:19:46 +0530174import i18n from '@/i18n';
Paul Fertser6e53b142025-01-21 16:19:36 +0000175import { useI18n } from 'vue-i18n';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800176
177export default {
178 components: {
179 DumpsForm,
180 IconDelete,
Yoshie Muranakaa87f3e72021-01-04 14:08:04 -0800181 IconDownload,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800182 PageSection,
183 PageTitle,
184 Search,
185 TableCellCount,
186 TableDateFilter,
187 TableRowAction,
188 TableToolbar,
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530189 TableFilter,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800190 },
191 mixins: [
192 BVTableSelectableMixin,
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800193 BVToastMixin,
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530194 BVPaginationMixin,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800195 LoadingBarMixin,
196 SearchFilterMixin,
197 TableFilterMixin,
198 ],
199 beforeRouteLeave(to, from, next) {
200 // Hide loader if the user navigates to another page
201 // before request is fulfilled.
202 this.hideLoader();
203 next();
204 },
205 data() {
206 return {
Paul Fertser6e53b142025-01-21 16:19:36 +0000207 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600208 isBusy: true,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800209 fields: [
210 {
211 key: 'checkbox',
212 sortable: false,
213 },
214 {
215 key: 'dateTime',
Surya Vde23ea22024-07-11 15:19:46 +0530216 label: i18n.global.t('pageDumps.table.dateAndTime'),
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800217 sortable: true,
218 },
219 {
220 key: 'dumpType',
Surya Vde23ea22024-07-11 15:19:46 +0530221 label: i18n.global.t('pageDumps.table.dumpType'),
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800222 sortable: true,
223 },
224 {
225 key: 'id',
Surya Vde23ea22024-07-11 15:19:46 +0530226 label: i18n.global.t('pageDumps.table.id'),
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800227 sortable: true,
228 },
229 {
230 key: 'size',
Surya Vde23ea22024-07-11 15:19:46 +0530231 label: i18n.global.t('pageDumps.table.size'),
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800232 sortable: true,
233 },
234 {
235 key: 'actions',
236 sortable: false,
237 label: '',
238 tdClass: 'text-right text-nowrap',
239 },
240 ],
241 batchActions: [
242 {
243 value: 'delete',
Surya Vde23ea22024-07-11 15:19:46 +0530244 label: i18n.global.t('global.action.delete'),
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800245 },
246 ],
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530247 tableFilters: [
248 {
249 key: 'dumpType',
Surya Vde23ea22024-07-11 15:19:46 +0530250 label: i18n.global.t('pageDumps.table.dumpType'),
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530251 values: [
252 'BMC Dump Entry',
253 'Hostboot Dump Entry',
254 'Resource Dump Entry',
255 'System Dump Entry',
256 ],
257 },
258 ],
259 activeFilters: [],
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530260 currentPage: currentPage,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800261 filterEndDate: null,
262 filterStartDate: null,
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530263 itemsPerPageOptions: itemsPerPageOptions,
264 perPage: perPage,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800265 searchFilter,
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530266 searchTotalFilteredRows: 0,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800267 selectedRows,
268 tableHeaderCheckboxIndeterminate,
269 tableHeaderCheckboxModel,
270 };
271 },
272 computed: {
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530273 filteredRows() {
274 return this.searchFilter
275 ? this.searchTotalFilteredRows
276 : this.filteredDumps.length;
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800277 },
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530278 allDumps() {
279 return this.$store.getters['dumps/allDumps'].map((item) => {
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800280 return {
281 ...item,
282 actions: [
283 {
Yoshie Muranakaa87f3e72021-01-04 14:08:04 -0800284 value: 'download',
Surya Vde23ea22024-07-11 15:19:46 +0530285 title: i18n.global.t('global.action.download'),
Yoshie Muranakaa87f3e72021-01-04 14:08:04 -0800286 },
287 {
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800288 value: 'delete',
Surya Vde23ea22024-07-11 15:19:46 +0530289 title: i18n.global.t('global.action.delete'),
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800290 },
291 ],
292 };
293 });
294 },
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530295 filteredDumpsByDate() {
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800296 return this.getFilteredTableDataByDate(
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530297 this.allDumps,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800298 this.filterStartDate,
299 this.filterEndDate,
Ed Tanous81323992024-02-27 11:26:24 -0800300 'dateTime',
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800301 );
302 },
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530303 filteredDumps() {
304 return this.getFilteredTableData(
305 this.filteredDumpsByDate,
Ed Tanous81323992024-02-27 11:26:24 -0800306 this.activeFilters,
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530307 );
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800308 },
309 },
310 created() {
311 this.startLoader();
Kees Trommel210b1272024-06-26 13:10:50 +0200312 this.$store.dispatch('dumps/getAllDumps').finally(() => {
Kenneth Fullbright41057852021-12-27 16:19:37 -0600313 this.endLoader();
314 this.isBusy = false;
315 });
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800316 },
317 methods: {
318 convertBytesToMegabytes(bytes) {
319 return parseFloat((bytes / 1000000).toFixed(3));
320 },
Sukanya Pandeye39b95d2021-08-23 18:11:02 +0530321 onFilterChange({ activeFilters }) {
322 this.activeFilters = activeFilters;
323 },
324 onFiltered(filteredItems) {
325 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800326 },
327 onChangeDateTimeFilter({ fromDate, toDate }) {
328 this.filterStartDate = fromDate;
329 this.filterEndDate = toDate;
330 },
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800331 onTableRowAction(action, dump) {
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800332 if (action === 'delete') {
333 this.$bvModal
Surya Vde23ea22024-07-11 15:19:46 +0530334 .msgBoxConfirm(
335 i18n.global.t('pageDumps.modal.deleteDumpConfirmation'),
336 {
337 title: i18n.global.t('pageDumps.modal.deleteDump'),
338 okTitle: i18n.global.t('pageDumps.modal.deleteDump'),
339 cancelTitle: i18n.global.t('global.action.cancel'),
340 autoFocusButton: 'ok',
341 },
342 )
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800343 .then((deleteConfrimed) => {
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800344 if (deleteConfrimed) {
345 this.$store
346 .dispatch('dumps/deleteDumps', [dump])
347 .then((messages) => {
348 messages.forEach(({ type, message }) => {
349 if (type === 'success') {
350 this.successToast(message);
351 } else if (type === 'error') {
352 this.errorToast(message);
353 }
354 });
355 });
356 }
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800357 });
358 }
359 },
360 onTableBatchAction(action) {
361 if (action === 'delete') {
362 this.$bvModal
363 .msgBoxConfirm(
Surya Vde23ea22024-07-11 15:19:46 +0530364 i18n.global.t(
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800365 'pageDumps.modal.deleteDumpConfirmation',
Ed Tanous81323992024-02-27 11:26:24 -0800366 this.selectedRows.length,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800367 ),
368 {
Surya Vde23ea22024-07-11 15:19:46 +0530369 title: i18n.global.t(
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800370 'pageDumps.modal.deleteDump',
Ed Tanous81323992024-02-27 11:26:24 -0800371 this.selectedRows.length,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800372 ),
Surya Vde23ea22024-07-11 15:19:46 +0530373 okTitle: i18n.global.t(
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800374 'pageDumps.modal.deleteDump',
Ed Tanous81323992024-02-27 11:26:24 -0800375 this.selectedRows.length,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800376 ),
Surya Vde23ea22024-07-11 15:19:46 +0530377 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000378 autoFocusButton: 'ok',
Ed Tanous81323992024-02-27 11:26:24 -0800379 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800380 )
381 .then((deleteConfrimed) => {
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800382 if (deleteConfrimed) {
383 if (this.selectedRows.length === this.dumps.length) {
384 this.$store
385 .dispatch('dumps/deleteAllDumps')
386 .then((success) => this.successToast(success))
387 .catch(({ message }) => this.errorToast(message));
388 } else {
389 this.$store
390 .dispatch('dumps/deleteDumps', this.selectedRows)
391 .then((messages) => {
392 messages.forEach(({ type, message }) => {
393 if (type === 'success') {
394 this.successToast(message);
395 } else if (type === 'error') {
396 this.errorToast(message);
397 }
398 });
399 });
400 }
401 }
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800402 });
403 }
404 },
Sneha Patel3f9cfa22021-06-04 16:06:08 -0500405 exportFileName(row) {
Gunnar Millscc79a532021-11-30 19:33:42 -0600406 let filename = row.item.dumpType + '_' + row.item.id + '.tar.xz';
Sneha Patel3f9cfa22021-06-04 16:06:08 -0500407 filename = filename.replace(RegExp(' ', 'g'), '_');
408 return filename;
409 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800410 },
411};
412</script>