blob: e50be81996f95855aaeceda983d1d7d2dcdead30 [file] [log] [blame]
Yoshie Muranaka6f102342020-05-05 09:45:39 -07001<template>
2 <b-container fluid="xl">
3 <page-title />
SurenNeware787635a2020-11-24 22:42:42 +05304 <b-row class="align-items-start">
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -05005 <b-col sm="8" xl="6" class="d-sm-flex align-items-end mb-4">
Yoshie Muranaka193c22a2020-06-30 20:54:10 -07006 <search
7 :placeholder="$t('pageEventLogs.table.searchLogs')"
Sandeepa Singh99e20d82021-02-09 17:37:59 +05308 data-test-id="eventLogs-input-searchLogs"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +05309 @change-search="onChangeSearchInput"
10 @clear-search="onClearSearchInput"
Yoshie Muranaka193c22a2020-06-30 20:54:10 -070011 />
SurenNeware787635a2020-11-24 22:42:42 +053012 <div class="ml-sm-4">
13 <table-cell-count
14 :filtered-items-count="filteredRows"
15 :total-number-of-cells="allLogs.length"
16 ></table-cell-count>
17 </div>
Yoshie Muranaka193c22a2020-06-30 20:54:10 -070018 </b-col>
SurenNeware787635a2020-11-24 22:42:42 +053019 <b-col sm="8" md="7" xl="6">
Yoshie Muranaka68bbba22020-05-18 09:49:37 -070020 <table-date-filter @change="onChangeDateTimeFilter" />
21 </b-col>
22 </b-row>
Yoshie Muranaka6f102342020-05-05 09:45:39 -070023 <b-row>
24 <b-col class="text-right">
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053025 <table-filter :filters="tableFilters" @filter-change="onFilterChange" />
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -050026 <b-button
27 variant="link"
28 :disabled="allLogs.length === 0"
29 @click="deleteAllLogs"
30 >
31 <icon-delete /> {{ $t('global.action.deleteAll') }}
32 </b-button>
33 <b-button
34 variant="primary"
35 :class="{ disabled: allLogs.length === 0 }"
36 :download="exportFileNameByDate()"
37 :href="href"
38 >
39 <icon-export /> {{ $t('global.action.exportAll') }}
40 </b-button>
Yoshie Muranaka6f102342020-05-05 09:45:39 -070041 </b-col>
42 </b-row>
43 <b-row>
44 <b-col>
Yoshie Muranakabe3af332020-05-11 08:23:04 -070045 <table-toolbar
46 ref="toolbar"
47 :selected-items-count="selectedRows.length"
48 :actions="batchActions"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053049 @clear-selected="clearSelectedRows($refs.table)"
50 @batch-action="onBatchAction"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070051 >
Dixsie Wolmers27d68af2021-05-02 18:20:27 -050052 <template #toolbar-buttons>
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +053053 <b-button v-if="!hideToggle" variant="primary" @click="resolveLogs">
Dixsie Wolmers27d68af2021-05-02 18:20:27 -050054 {{ $t('pageEventLogs.resolve') }}
55 </b-button>
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +053056 <b-button
57 v-if="!hideToggle"
58 variant="primary"
59 @click="unresolveLogs"
60 >
Dixsie Wolmers27d68af2021-05-02 18:20:27 -050061 {{ $t('pageEventLogs.unresolve') }}
62 </b-button>
Yoshie Muranakabe3af332020-05-11 08:23:04 -070063 <table-toolbar-export
64 :data="batchExportData"
SurenNeware96ebb0d2020-09-08 17:42:39 +053065 :file-name="exportFileNameByDate()"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070066 />
67 </template>
68 </table-toolbar>
Yoshie Muranaka6f102342020-05-05 09:45:39 -070069 <b-table
Yoshie Muranakaf9832b02020-05-12 12:04:46 -070070 id="table-event-logs"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070071 ref="table"
SurenNeware5e25e282020-07-08 15:57:23 +053072 responsive="md"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070073 selectable
74 no-select-on-click
Yoshie Muranaka6f102342020-05-05 09:45:39 -070075 sort-icon-left
Sukanya Pandeyfde429e2020-09-14 20:48:39 +053076 hover
Yoshie Muranaka6f102342020-05-05 09:45:39 -070077 no-sort-reset
78 sort-desc
79 show-empty
Derick Montague6b140ba2020-09-03 16:26:33 -050080 sort-by="id"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070081 :fields="fields"
82 :items="filteredLogs"
Yoshie Muranaka6f102342020-05-05 09:45:39 -070083 :sort-compare="onSortCompare"
SurenNeware307382e2020-07-27 20:45:14 +053084 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053085 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Yoshie Muranakaf9832b02020-05-12 12:04:46 -070086 :per-page="perPage"
87 :current-page="currentPage"
Yoshie Muranaka193c22a2020-06-30 20:54:10 -070088 :filter="searchFilter"
Kenneth Fullbright41057852021-12-27 16:19:37 -060089 :busy="isBusy"
Sukanya Pandey99010962020-07-27 21:44:47 +053090 @filtered="onFiltered"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070091 @row-selected="onRowSelected($event, filteredLogs.length)"
Yoshie Muranaka6f102342020-05-05 09:45:39 -070092 >
Yoshie Muranakabe3af332020-05-11 08:23:04 -070093 <!-- Checkbox column -->
Derick Montague602e98a2020-10-21 16:20:00 -050094 <template #head(checkbox)>
Yoshie Muranakabe3af332020-05-11 08:23:04 -070095 <b-form-checkbox
96 v-model="tableHeaderCheckboxModel"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -070097 data-test-id="eventLogs-checkbox-selectAll"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070098 :indeterminate="tableHeaderCheckboxIndeterminate"
99 @change="onChangeHeaderCheckbox($refs.table)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -0600100 >
101 <span class="sr-only">{{ $t('global.table.selectAll') }}</span>
102 </b-form-checkbox>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700103 </template>
Derick Montague602e98a2020-10-21 16:20:00 -0500104 <template #cell(checkbox)="row">
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700105 <b-form-checkbox
106 v-model="row.rowSelected"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700107 :data-test-id="`eventLogs-checkbox-selectRow-${row.index}`"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700108 @change="toggleSelectRow($refs.table, row.index)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -0600109 >
110 <span class="sr-only">{{ $t('global.table.selectItem') }}</span>
111 </b-form-checkbox>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700112 </template>
113
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530114 <!-- Expand chevron icon -->
115 <template #cell(expandRow)="row">
116 <b-button
117 variant="link"
118 :aria-label="expandRowLabel"
119 :title="expandRowLabel"
120 class="btn-icon-only"
121 @click="toggleRowDetails(row)"
122 >
123 <icon-chevron />
124 </b-button>
125 </template>
126
127 <template #row-details="{ item }">
128 <b-container fluid>
129 <b-row>
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500130 <b-col>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530131 <dl>
132 <!-- Name -->
133 <dt>{{ $t('pageEventLogs.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500134 <dd>{{ dataFormatter(item.name) }}</dd>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530135 </dl>
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500136 <dl>
137 <!-- Type -->
138 <dt>{{ $t('pageEventLogs.table.type') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500139 <dd>{{ dataFormatter(item.type) }}</dd>
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500140 </dl>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530141 </b-col>
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500142 <b-col>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530143 <dl>
144 <!-- Modified date -->
145 <dt>{{ $t('pageEventLogs.table.modifiedDate') }}:</dt>
146 <dd v-if="item.modifiedDate">
Surya V603cfbf2024-07-11 15:19:46 +0530147 {{ $filters.formatDate(item.modifiedDate) }}
148 {{ $filters.formatTime(item.modifiedDate) }}
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530149 </dd>
150 <dd v-else>--</dd>
151 </dl>
152 </b-col>
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500153 <b-col class="text-nowrap">
154 <b-button
155 class="btn btn-secondary float-right"
156 :href="item.additionalDataUri"
157 target="_blank"
158 >
159 <icon-download />{{ $t('pageEventLogs.additionalDataUri') }}
160 </b-button>
161 </b-col>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530162 </b-row>
163 </b-container>
164 </template>
165
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700166 <!-- Severity column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500167 <template #cell(severity)="{ value }">
Mateusz Gapskib1f12532020-07-24 08:15:23 +0200168 <status-icon v-if="value" :status="statusIcon(value)" />
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700169 {{ value }}
170 </template>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700171 <!-- Date column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500172 <template #cell(date)="{ value }">
Surya V603cfbf2024-07-11 15:19:46 +0530173 <p class="mb-0">{{ $filters.formatDate(value) }}</p>
174 <p class="mb-0">{{ $filters.formatTime(value) }}</p>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700175 </template>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700176
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500177 <!-- Status column -->
178 <template #cell(status)="row">
179 <b-form-checkbox
180 v-model="row.item.status"
181 name="switch"
182 switch
183 @change="changelogStatus(row.item)"
184 >
185 <span v-if="row.item.status">
186 {{ $t('pageEventLogs.resolved') }}
187 </span>
188 <span v-else> {{ $t('pageEventLogs.unresolved') }} </span>
189 </b-form-checkbox>
190 </template>
191 <template #cell(filterByStatus)="{ value }">
192 {{ value }}
193 </template>
194
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700195 <!-- Actions column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500196 <template #cell(actions)="row">
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700197 <table-row-action
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700198 v-for="(action, index) in row.item.actions"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700199 :key="index"
200 :value="action.value"
201 :title="action.title"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700202 :row-data="row.item"
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500203 :export-name="exportFileNameByDate('export')"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700204 :data-test-id="`eventLogs-button-deleteRow-${row.index}`"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530205 @click-table-action="onTableRowAction($event, row.item)"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700206 >
Derick Montague602e98a2020-10-21 16:20:00 -0500207 <template #icon>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700208 <icon-export v-if="action.value === 'export'" />
209 <icon-trashcan v-if="action.value === 'delete'" />
210 </template>
211 </table-row-action>
212 </template>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700213 </b-table>
214 </b-col>
215 </b-row>
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700216
217 <!-- Table pagination -->
218 <b-row>
SurenNewarea35b5a12020-10-13 17:08:20 +0530219 <b-col sm="6">
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700220 <b-form-group
221 class="table-pagination-select"
222 :label="$t('global.table.itemsPerPage')"
223 label-for="pagination-items-per-page"
224 >
225 <b-form-select
226 id="pagination-items-per-page"
227 v-model="perPage"
228 :options="itemsPerPageOptions"
229 />
230 </b-form-group>
SurenNewarea35b5a12020-10-13 17:08:20 +0530231 </b-col>
232 <b-col sm="6">
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700233 <b-pagination
234 v-model="currentPage"
235 first-number
236 last-number
237 :per-page="perPage"
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530238 :total-rows="getTotalRowCount(filteredRows)"
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700239 aria-controls="table-event-logs"
240 />
241 </b-col>
242 </b-row>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700243 </b-container>
244</template>
245
246<script>
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500247import IconDelete from '@carbon/icons-vue/es/trash-can/20';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700248import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
Sukanya Pandeyb2ca0c02020-07-20 23:23:29 +0530249import IconExport from '@carbon/icons-vue/es/document--export/20';
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530250import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500251import IconDownload from '@carbon/icons-vue/es/download/20';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700252import { omit } from 'lodash';
253
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700254import PageTitle from '@/components/Global/PageTitle';
255import StatusIcon from '@/components/Global/StatusIcon';
Derick Montagued853fba2020-07-16 11:24:10 -0500256import Search from '@/components/Global/Search';
Sukanya Pandey99010962020-07-27 21:44:47 +0530257import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700258import TableDateFilter from '@/components/Global/TableDateFilter';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700259import TableFilter from '@/components/Global/TableFilter';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700260import TableRowAction from '@/components/Global/TableRowAction';
261import TableToolbar from '@/components/Global/TableToolbar';
262import TableToolbarExport from '@/components/Global/TableToolbarExport';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700263
264import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
265import TableFilterMixin from '@/components/Mixins/TableFilterMixin';
SurenNewareba91c492020-10-27 14:18:54 +0530266import BVPaginationMixin, {
267 currentPage,
268 perPage,
269 itemsPerPageOptions,
270} from '@/components/Mixins/BVPaginationMixin';
271import BVTableSelectableMixin, {
272 selectedRows,
273 tableHeaderCheckboxModel,
274 tableHeaderCheckboxIndeterminate,
275} from '@/components/Mixins/BVTableSelectableMixin';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700276import BVToastMixin from '@/components/Mixins/BVToastMixin';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500277import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700278import TableSortMixin from '@/components/Mixins/TableSortMixin';
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530279import TableRowExpandMixin, {
280 expandRowLabel,
281} from '@/components/Mixins/TableRowExpandMixin';
SurenNewareba91c492020-10-27 14:18:54 +0530282import SearchFilterMixin, {
283 searchFilter,
284} from '@/components/Mixins/SearchFilterMixin';
Ed Tanousdbd37e02024-03-23 14:56:34 -0700285import { useI18n } from 'vue-i18n';
286import i18n from '@/i18n';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700287
288export default {
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700289 components: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500290 IconDelete,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700291 IconExport,
292 IconTrashcan,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530293 IconChevron,
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500294 IconDownload,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700295 PageTitle,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700296 Search,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700297 StatusIcon,
Sukanya Pandey99010962020-07-27 21:44:47 +0530298 TableCellCount,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700299 TableFilter,
300 TableRowAction,
301 TableToolbar,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700302 TableToolbarExport,
Derick Montague602e98a2020-10-21 16:20:00 -0500303 TableDateFilter,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700304 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700305 mixins: [
306 BVPaginationMixin,
307 BVTableSelectableMixin,
308 BVToastMixin,
309 LoadingBarMixin,
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700310 TableFilterMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500311 DataFormatterMixin,
Dixsie Wolmers9b22b492020-09-07 21:26:06 -0500312 TableSortMixin,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530313 TableRowExpandMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500314 SearchFilterMixin,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700315 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500316 beforeRouteLeave(to, from, next) {
317 // Hide loader if the user navigates to another page
318 // before request is fulfilled.
319 this.hideLoader();
320 next();
321 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700322 data() {
323 return {
Ed Tanousdbd37e02024-03-23 14:56:34 -0700324 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600325 isBusy: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700326 fields: [
327 {
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530328 key: 'expandRow',
329 label: '',
330 tdClass: 'table-row-expand',
331 },
332 {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700333 key: 'checkbox',
Derick Montague602e98a2020-10-21 16:20:00 -0500334 sortable: false,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700335 },
336 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700337 key: 'id',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700338 label: i18n.global.t('pageEventLogs.table.id'),
Derick Montague602e98a2020-10-21 16:20:00 -0500339 sortable: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700340 },
341 {
342 key: 'severity',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700343 label: i18n.global.t('pageEventLogs.table.severity'),
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500344 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500345 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700346 },
347 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700348 key: 'date',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700349 label: i18n.global.t('pageEventLogs.table.date'),
Derick Montague602e98a2020-10-21 16:20:00 -0500350 sortable: true,
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500351 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700352 },
353 {
354 key: 'description',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700355 label: i18n.global.t('pageEventLogs.table.description'),
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500356 tdClass: 'text-break',
357 },
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530358 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
359 ? {}
360 : {
361 key: 'status',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700362 label: i18n.global.t('pageEventLogs.table.status'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530363 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700364 {
365 key: 'actions',
366 sortable: false,
367 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500368 tdClass: 'text-right text-nowrap',
369 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700370 ],
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530371 tableFilters:
372 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
373 ? [
374 {
375 key: 'severity',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700376 label: i18n.global.t('pageEventLogs.table.severity'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530377 values: ['OK', 'Warning', 'Critical'],
378 },
379 ]
380 : [
381 {
382 key: 'severity',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700383 label: i18n.global.t('pageEventLogs.table.severity'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530384 values: ['OK', 'Warning', 'Critical'],
385 },
386 {
387 key: 'filterByStatus',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700388 label: i18n.global.t('pageEventLogs.table.status'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530389 values: ['Resolved', 'Unresolved'],
390 },
391 ],
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530392 expandRowLabel,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700393 activeFilters: [],
Damian Celicoef96c6d2022-03-01 12:47:52 +0100394 batchActions:
395 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true'
396 ? []
397 : [
398 {
399 value: 'delete',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700400 label: i18n.global.t('global.action.delete'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100401 },
402 ],
SurenNewareba91c492020-10-27 14:18:54 +0530403 currentPage: currentPage,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700404 filterStartDate: null,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700405 filterEndDate: null,
SurenNewareba91c492020-10-27 14:18:54 +0530406 itemsPerPageOptions: itemsPerPageOptions,
407 perPage: perPage,
408 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500409 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530410 selectedRows: selectedRows,
411 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
412 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530413 hideToggle:
414 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true',
Damian Celicoef96c6d2022-03-01 12:47:52 +0100415 hideDelete:
416 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700417 };
418 },
419 computed: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500420 href() {
421 return `data:text/json;charset=utf-8,${this.exportAllLogs()}`;
422 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530423 filteredRows() {
424 return this.searchFilter
425 ? this.searchTotalFilteredRows
426 : this.filteredLogs.length;
427 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700428 allLogs() {
Derick Montague602e98a2020-10-21 16:20:00 -0500429 return this.$store.getters['eventLog/allEvents'].map((event) => {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700430 return {
431 ...event,
Damian Celicoef96c6d2022-03-01 12:47:52 +0100432 actions: this.hideDelete
433 ? [
434 {
435 value: 'export',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700436 title: i18n.global.t('global.action.export'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100437 },
438 ]
439 : [
440 {
441 value: 'export',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700442 title: i18n.global.t('global.action.export'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100443 },
444 {
445 value: 'delete',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700446 title: i18n.global.t('global.action.delete'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100447 },
448 ],
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700449 };
450 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700451 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700452 batchExportData() {
Derick Montague602e98a2020-10-21 16:20:00 -0500453 return this.selectedRows.map((row) => omit(row, 'actions'));
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700454 },
455 filteredLogsByDate() {
456 return this.getFilteredTableDataByDate(
457 this.allLogs,
458 this.filterStartDate,
Ed Tanous81323992024-02-27 11:26:24 -0800459 this.filterEndDate,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700460 );
461 },
462 filteredLogs() {
463 return this.getFilteredTableData(
464 this.filteredLogsByDate,
Ed Tanous81323992024-02-27 11:26:24 -0800465 this.activeFilters,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700466 );
Derick Montague602e98a2020-10-21 16:20:00 -0500467 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700468 },
469 created() {
470 this.startLoader();
Kenneth Fullbright41057852021-12-27 16:19:37 -0600471 this.$store.dispatch('eventLog/getEventLogData').finally(() => {
472 this.endLoader();
473 this.isBusy = false;
474 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700475 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700476 methods: {
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500477 changelogStatus(row) {
478 this.$store
479 .dispatch('eventLog/updateEventLogStatus', {
480 uri: row.uri,
481 status: row.status,
482 })
483 .then((success) => {
484 this.successToast(success);
485 })
486 .catch(({ message }) => this.errorToast(message));
487 },
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500488 deleteAllLogs() {
489 this.$bvModal
Ed Tanousdbd37e02024-03-23 14:56:34 -0700490 .msgBoxConfirm(i18n.global.t('pageEventLogs.modal.deleteAllMessage'), {
491 title: i18n.global.t('pageEventLogs.modal.deleteAllTitle'),
492 okTitle: i18n.global.t('global.action.delete'),
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500493 okVariant: 'danger',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700494 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000495 autoFocusButton: 'cancel',
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500496 })
497 .then((deleteConfirmed) => {
498 if (deleteConfirmed) {
499 this.$store
500 .dispatch('eventLog/deleteAllEventLogs', this.allLogs)
501 .then((message) => this.successToast(message))
502 .catch(({ message }) => this.errorToast(message));
503 }
504 });
505 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700506 deleteLogs(uris) {
Derick Montague602e98a2020-10-21 16:20:00 -0500507 this.$store
508 .dispatch('eventLog/deleteEventLogs', uris)
509 .then((messages) => {
510 messages.forEach(({ type, message }) => {
511 if (type === 'success') {
512 this.successToast(message);
513 } else if (type === 'error') {
514 this.errorToast(message);
515 }
516 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700517 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700518 },
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500519 exportAllLogs() {
520 {
521 return this.$store.getters['eventLog/allEvents'].map((eventLogs) => {
522 const allEventLogsString = JSON.stringify(eventLogs);
523 return allEventLogsString;
524 });
525 }
526 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700527 onFilterChange({ activeFilters }) {
528 this.activeFilters = activeFilters;
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700529 },
530 onSortCompare(a, b, key) {
531 if (key === 'severity') {
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700532 return this.sortStatus(a, b, key);
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700533 }
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700534 },
535 onTableRowAction(action, { uri }) {
536 if (action === 'delete') {
537 this.$bvModal
Surya V603cfbf2024-07-11 15:19:46 +0530538 .msgBoxConfirm(i18n.global.t('pageEventLogs.modal.deleteMessage'), {
539 title: i18n.global.t('pageEventLogs.modal.deleteTitle'),
Ed Tanousdbd37e02024-03-23 14:56:34 -0700540 okTitle: i18n.global.t('global.action.delete'),
541 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000542 autoFocusButton: 'ok',
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700543 })
Derick Montague602e98a2020-10-21 16:20:00 -0500544 .then((deleteConfirmed) => {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700545 if (deleteConfirmed) this.deleteLogs([uri]);
546 });
547 }
548 },
549 onBatchAction(action) {
550 if (action === 'delete') {
Derick Montague602e98a2020-10-21 16:20:00 -0500551 const uris = this.selectedRows.map((row) => row.uri);
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700552 this.$bvModal
553 .msgBoxConfirm(
Surya V603cfbf2024-07-11 15:19:46 +0530554 i18n.global.t(
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700555 'pageEventLogs.modal.deleteMessage',
Ed Tanous81323992024-02-27 11:26:24 -0800556 this.selectedRows.length,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700557 ),
558 {
Surya V603cfbf2024-07-11 15:19:46 +0530559 title: i18n.global.t(
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700560 'pageEventLogs.modal.deleteTitle',
Ed Tanous81323992024-02-27 11:26:24 -0800561 this.selectedRows.length,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700562 ),
Ed Tanousdbd37e02024-03-23 14:56:34 -0700563 okTitle: i18n.global.t('global.action.delete'),
564 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000565 autoFocusButton: 'ok',
Ed Tanous81323992024-02-27 11:26:24 -0800566 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700567 )
Derick Montague602e98a2020-10-21 16:20:00 -0500568 .then((deleteConfirmed) => {
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530569 if (deleteConfirmed) {
570 if (this.selectedRows.length === this.allLogs.length) {
571 this.$store
572 .dispatch(
573 'eventLog/deleteAllEventLogs',
Ed Tanous81323992024-02-27 11:26:24 -0800574 this.selectedRows.length,
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530575 )
Nikhil Ashoka453ad922022-01-13 18:07:51 +0530576 .then(() => {
577 this.successToast(
Surya V603cfbf2024-07-11 15:19:46 +0530578 i18n.global.t(
Ed Tanous81323992024-02-27 11:26:24 -0800579 'pageEventLogs.toast.successDelete',
580 uris.length,
581 ),
Nikhil Ashoka453ad922022-01-13 18:07:51 +0530582 );
583 })
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530584 .catch(({ message }) => this.errorToast(message));
585 } else {
586 this.deleteLogs(uris);
587 }
588 }
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700589 });
590 }
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700591 },
592 onChangeDateTimeFilter({ fromDate, toDate }) {
593 this.filterStartDate = fromDate;
594 this.filterEndDate = toDate;
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700595 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530596 onFiltered(filteredItems) {
597 this.searchTotalFilteredRows = filteredItems.length;
598 },
SurenNeware96ebb0d2020-09-08 17:42:39 +0530599 // Create export file name based on date
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500600 exportFileNameByDate(value) {
SurenNeware96ebb0d2020-09-08 17:42:39 +0530601 let date = new Date();
602 date =
603 date.toISOString().slice(0, 10) +
604 '_' +
Derick Montague602e98a2020-10-21 16:20:00 -0500605 date.toString().split(':').join('-').split(' ')[4];
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500606 let fileName;
607 if (value === 'export') {
608 fileName = 'event_log_';
609 } else {
610 fileName = 'all_event_logs_';
611 }
612 return fileName + date;
Derick Montague602e98a2020-10-21 16:20:00 -0500613 },
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500614 resolveLogs() {
615 this.$store
616 .dispatch('eventLog/resolveEventLogs', this.selectedRows)
617 .then((messages) => {
618 messages.forEach(({ type, message }) => {
619 if (type === 'success') {
620 this.successToast(message);
621 } else if (type === 'error') {
622 this.errorToast(message);
623 }
624 });
625 });
626 },
627 unresolveLogs() {
628 this.$store
629 .dispatch('eventLog/unresolveEventLogs', this.selectedRows)
630 .then((messages) => {
631 messages.forEach(({ type, message }) => {
632 if (type === 'success') {
633 this.successToast(message);
634 } else if (type === 'error') {
635 this.errorToast(message);
636 }
637 });
638 });
639 },
Derick Montague602e98a2020-10-21 16:20:00 -0500640 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700641};
642</script>