blob: e1497392568978d74b3b999123a6ad801354eaed [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 />
jason westoverd36ac8a2025-11-03 20:58:59 -060012 <div class="ms-sm-4">
SurenNeware787635a2020-11-24 22:42:42 +053013 <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>
jason westoverd36ac8a2025-11-03 20:58:59 -060024 <b-col class="text-end">
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
jason westoverd36ac8a2025-11-03 20:58:59 -060077 must-sort
78 thead-class="table-light"
79 :sort-desc="[true]"
Yoshie Muranaka6f102342020-05-05 09:45:39 -070080 show-empty
jason westoverd36ac8a2025-11-03 20:58:59 -060081 :sort-by="['id']"
Yoshie Muranakabe3af332020-05-11 08:23:04 -070082 :fields="fields"
83 :items="filteredLogs"
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"
jason westoverd36ac8a2025-11-03 20:58:59 -060099 @change="onChangeHeaderCheckbox($refs.table, $event)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -0600100 >
jason westoverd36ac8a2025-11-03 20:58:59 -0600101 <span class="visually-hidden-focusable">
102 {{ $t('global.table.selectAll') }}
103 </span>
Dixsie Wolmersc42ad712020-11-19 17:29:24 -0600104 </b-form-checkbox>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700105 </template>
Derick Montague602e98a2020-10-21 16:20:00 -0500106 <template #cell(checkbox)="row">
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700107 <b-form-checkbox
108 v-model="row.rowSelected"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700109 :data-test-id="`eventLogs-checkbox-selectRow-${row.index}`"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700110 @change="toggleSelectRow($refs.table, row.index)"
Dixsie Wolmersc42ad712020-11-19 17:29:24 -0600111 >
jason westoverd36ac8a2025-11-03 20:58:59 -0600112 <span class="visually-hidden-focusable">
113 {{ $t('global.table.selectItem') }}
114 </span>
Dixsie Wolmersc42ad712020-11-19 17:29:24 -0600115 </b-form-checkbox>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700116 </template>
117
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530118 <!-- Expand chevron icon -->
119 <template #cell(expandRow)="row">
120 <b-button
121 variant="link"
122 :aria-label="expandRowLabel"
123 :title="expandRowLabel"
124 class="btn-icon-only"
125 @click="toggleRowDetails(row)"
126 >
jason westoverd36ac8a2025-11-03 20:58:59 -0600127 <icon-chevron v-if="!row.detailsShowing" />
128 <icon-chevron-up v-else />
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530129 </b-button>
130 </template>
131
132 <template #row-details="{ item }">
133 <b-container fluid>
134 <b-row>
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500135 <b-col>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530136 <dl>
137 <!-- Name -->
138 <dt>{{ $t('pageEventLogs.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500139 <dd>{{ dataFormatter(item.name) }}</dd>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530140 </dl>
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500141 <dl>
142 <!-- Type -->
143 <dt>{{ $t('pageEventLogs.table.type') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500144 <dd>{{ dataFormatter(item.type) }}</dd>
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500145 </dl>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530146 </b-col>
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500147 <b-col>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530148 <dl>
149 <!-- Modified date -->
150 <dt>{{ $t('pageEventLogs.table.modifiedDate') }}:</dt>
151 <dd v-if="item.modifiedDate">
Surya Vde23ea22024-07-11 15:19:46 +0530152 {{ $filters.formatDate(item.modifiedDate) }}
153 {{ $filters.formatTime(item.modifiedDate) }}
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530154 </dd>
155 <dd v-else>--</dd>
156 </dl>
157 </b-col>
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500158 <b-col class="text-nowrap">
Sean Zhang582e9542024-07-05 12:48:45 +0300159 <b-button @click="downloadEntry(item.additionalDataUri)">
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500160 <icon-download />{{ $t('pageEventLogs.additionalDataUri') }}
161 </b-button>
162 </b-col>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530163 </b-row>
164 </b-container>
165 </template>
166
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700167 <!-- Severity column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500168 <template #cell(severity)="{ value }">
Mateusz Gapskib1f12532020-07-24 08:15:23 +0200169 <status-icon v-if="value" :status="statusIcon(value)" />
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700170 {{ value }}
171 </template>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700172 <!-- Date column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500173 <template #cell(date)="{ value }">
Surya Vde23ea22024-07-11 15:19:46 +0530174 <p class="mb-0">{{ $filters.formatDate(value) }}</p>
175 <p class="mb-0">{{ $filters.formatTime(value) }}</p>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700176 </template>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700177
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500178 <!-- Status column -->
179 <template #cell(status)="row">
180 <b-form-checkbox
181 v-model="row.item.status"
182 name="switch"
183 switch
184 @change="changelogStatus(row.item)"
185 >
186 <span v-if="row.item.status">
187 {{ $t('pageEventLogs.resolved') }}
188 </span>
jason westoverd36ac8a2025-11-03 20:58:59 -0600189 <span v-else>
190 {{ $t('pageEventLogs.unresolved') }}
191 </span>
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500192 </b-form-checkbox>
193 </template>
194 <template #cell(filterByStatus)="{ value }">
195 {{ value }}
196 </template>
197
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700198 <!-- Actions column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500199 <template #cell(actions)="row">
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700200 <table-row-action
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700201 v-for="(action, index) in row.item.actions"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700202 :key="index"
203 :value="action.value"
204 :title="action.title"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700205 :row-data="row.item"
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500206 :export-name="exportFileNameByDate('export')"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700207 :data-test-id="`eventLogs-button-deleteRow-${row.index}`"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530208 @click-table-action="onTableRowAction($event, row.item)"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700209 >
Derick Montague602e98a2020-10-21 16:20:00 -0500210 <template #icon>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700211 <icon-export v-if="action.value === 'export'" />
212 <icon-trashcan v-if="action.value === 'delete'" />
213 </template>
214 </table-row-action>
215 </template>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700216 </b-table>
217 </b-col>
218 </b-row>
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700219
220 <!-- Table pagination -->
221 <b-row>
SurenNewarea35b5a12020-10-13 17:08:20 +0530222 <b-col sm="6">
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700223 <b-form-group
224 class="table-pagination-select"
225 :label="$t('global.table.itemsPerPage')"
226 label-for="pagination-items-per-page"
227 >
228 <b-form-select
229 id="pagination-items-per-page"
230 v-model="perPage"
231 :options="itemsPerPageOptions"
232 />
233 </b-form-group>
SurenNewarea35b5a12020-10-13 17:08:20 +0530234 </b-col>
235 <b-col sm="6">
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700236 <b-pagination
237 v-model="currentPage"
238 first-number
239 last-number
240 :per-page="perPage"
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530241 :total-rows="getTotalRowCount(filteredRows)"
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700242 aria-controls="table-event-logs"
243 />
244 </b-col>
245 </b-row>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700246 </b-container>
247</template>
248
249<script>
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500250import IconDelete from '@carbon/icons-vue/es/trash-can/20';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700251import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
Sukanya Pandeyb2ca0c02020-07-20 23:23:29 +0530252import IconExport from '@carbon/icons-vue/es/document--export/20';
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530253import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
jason westoverd36ac8a2025-11-03 20:58:59 -0600254import IconChevronUp from '@carbon/icons-vue/es/chevron--up/20';
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500255import IconDownload from '@carbon/icons-vue/es/download/20';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700256import { omit } from 'lodash';
257
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700258import PageTitle from '@/components/Global/PageTitle';
259import StatusIcon from '@/components/Global/StatusIcon';
Derick Montagued853fba2020-07-16 11:24:10 -0500260import Search from '@/components/Global/Search';
Sukanya Pandey99010962020-07-27 21:44:47 +0530261import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700262import TableDateFilter from '@/components/Global/TableDateFilter';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700263import TableFilter from '@/components/Global/TableFilter';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700264import TableRowAction from '@/components/Global/TableRowAction';
265import TableToolbar from '@/components/Global/TableToolbar';
266import TableToolbarExport from '@/components/Global/TableToolbarExport';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700267
268import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
269import TableFilterMixin from '@/components/Mixins/TableFilterMixin';
SurenNewareba91c492020-10-27 14:18:54 +0530270import BVPaginationMixin, {
271 currentPage,
272 perPage,
273 itemsPerPageOptions,
274} from '@/components/Mixins/BVPaginationMixin';
275import BVTableSelectableMixin, {
276 selectedRows,
277 tableHeaderCheckboxModel,
278 tableHeaderCheckboxIndeterminate,
279} from '@/components/Mixins/BVTableSelectableMixin';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700280import BVToastMixin from '@/components/Mixins/BVToastMixin';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500281import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700282import TableSortMixin from '@/components/Mixins/TableSortMixin';
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530283import TableRowExpandMixin, {
284 expandRowLabel,
285} from '@/components/Mixins/TableRowExpandMixin';
SurenNewareba91c492020-10-27 14:18:54 +0530286import SearchFilterMixin, {
287 searchFilter,
288} from '@/components/Mixins/SearchFilterMixin';
Ed Tanous883a0d52024-03-23 14:56:34 -0700289import { useI18n } from 'vue-i18n';
290import i18n from '@/i18n';
jason westoverd36ac8a2025-11-03 20:58:59 -0600291import { useModal } from 'bootstrap-vue-next';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700292
293export default {
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700294 components: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500295 IconDelete,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700296 IconExport,
297 IconTrashcan,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530298 IconChevron,
jason westoverd36ac8a2025-11-03 20:58:59 -0600299 IconChevronUp,
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500300 IconDownload,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700301 PageTitle,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700302 Search,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700303 StatusIcon,
Sukanya Pandey99010962020-07-27 21:44:47 +0530304 TableCellCount,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700305 TableFilter,
306 TableRowAction,
307 TableToolbar,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700308 TableToolbarExport,
Derick Montague602e98a2020-10-21 16:20:00 -0500309 TableDateFilter,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700310 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700311 mixins: [
312 BVPaginationMixin,
313 BVTableSelectableMixin,
314 BVToastMixin,
315 LoadingBarMixin,
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700316 TableFilterMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500317 DataFormatterMixin,
Dixsie Wolmers9b22b492020-09-07 21:26:06 -0500318 TableSortMixin,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530319 TableRowExpandMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500320 SearchFilterMixin,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700321 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500322 beforeRouteLeave(to, from, next) {
323 // Hide loader if the user navigates to another page
324 // before request is fulfilled.
325 this.hideLoader();
326 next();
327 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600328 setup() {
329 const bvModal = useModal();
330 return { bvModal };
331 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700332 data() {
333 return {
Ed Tanous883a0d52024-03-23 14:56:34 -0700334 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600335 isBusy: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700336 fields: [
337 {
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530338 key: 'expandRow',
339 label: '',
340 tdClass: 'table-row-expand',
341 },
342 {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700343 key: 'checkbox',
Derick Montague602e98a2020-10-21 16:20:00 -0500344 sortable: false,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700345 },
346 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700347 key: 'id',
Ed Tanous883a0d52024-03-23 14:56:34 -0700348 label: i18n.global.t('pageEventLogs.table.id'),
Derick Montague602e98a2020-10-21 16:20:00 -0500349 sortable: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700350 },
351 {
352 key: 'severity',
Ed Tanous883a0d52024-03-23 14:56:34 -0700353 label: i18n.global.t('pageEventLogs.table.severity'),
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500354 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500355 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700356 },
357 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700358 key: 'date',
Ed Tanous883a0d52024-03-23 14:56:34 -0700359 label: i18n.global.t('pageEventLogs.table.date'),
Derick Montague602e98a2020-10-21 16:20:00 -0500360 sortable: true,
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500361 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700362 },
363 {
364 key: 'description',
Ed Tanous883a0d52024-03-23 14:56:34 -0700365 label: i18n.global.t('pageEventLogs.table.description'),
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500366 tdClass: 'text-break',
367 },
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530368 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
369 ? {}
370 : {
371 key: 'status',
Ed Tanous883a0d52024-03-23 14:56:34 -0700372 label: i18n.global.t('pageEventLogs.table.status'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530373 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700374 {
375 key: 'actions',
376 sortable: false,
377 label: '',
jason westoverd36ac8a2025-11-03 20:58:59 -0600378 tdClass: 'text-end text-nowrap',
Derick Montague602e98a2020-10-21 16:20:00 -0500379 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700380 ],
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530381 tableFilters:
382 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
383 ? [
384 {
385 key: 'severity',
Ed Tanous883a0d52024-03-23 14:56:34 -0700386 label: i18n.global.t('pageEventLogs.table.severity'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530387 values: ['OK', 'Warning', 'Critical'],
388 },
389 ]
390 : [
391 {
392 key: 'severity',
Ed Tanous883a0d52024-03-23 14:56:34 -0700393 label: i18n.global.t('pageEventLogs.table.severity'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530394 values: ['OK', 'Warning', 'Critical'],
395 },
396 {
397 key: 'filterByStatus',
Ed Tanous883a0d52024-03-23 14:56:34 -0700398 label: i18n.global.t('pageEventLogs.table.status'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530399 values: ['Resolved', 'Unresolved'],
400 },
401 ],
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530402 expandRowLabel,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700403 activeFilters: [],
Damian Celicoef96c6d2022-03-01 12:47:52 +0100404 batchActions:
405 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true'
406 ? []
407 : [
408 {
409 value: 'delete',
Ed Tanous883a0d52024-03-23 14:56:34 -0700410 label: i18n.global.t('global.action.delete'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100411 },
412 ],
SurenNewareba91c492020-10-27 14:18:54 +0530413 currentPage: currentPage,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700414 filterStartDate: null,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700415 filterEndDate: null,
SurenNewareba91c492020-10-27 14:18:54 +0530416 itemsPerPageOptions: itemsPerPageOptions,
417 perPage: perPage,
418 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500419 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530420 selectedRows: selectedRows,
421 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
422 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530423 hideToggle:
424 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true',
Damian Celicoef96c6d2022-03-01 12:47:52 +0100425 hideDelete:
426 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700427 };
428 },
429 computed: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500430 href() {
431 return `data:text/json;charset=utf-8,${this.exportAllLogs()}`;
432 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530433 filteredRows() {
434 return this.searchFilter
435 ? this.searchTotalFilteredRows
436 : this.filteredLogs.length;
437 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700438 allLogs() {
Derick Montague602e98a2020-10-21 16:20:00 -0500439 return this.$store.getters['eventLog/allEvents'].map((event) => {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700440 return {
441 ...event,
Damian Celicoef96c6d2022-03-01 12:47:52 +0100442 actions: this.hideDelete
443 ? [
444 {
445 value: 'export',
Ed Tanous883a0d52024-03-23 14:56:34 -0700446 title: i18n.global.t('global.action.export'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100447 },
448 ]
449 : [
450 {
451 value: 'export',
Ed Tanous883a0d52024-03-23 14:56:34 -0700452 title: i18n.global.t('global.action.export'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100453 },
454 {
455 value: 'delete',
Ed Tanous883a0d52024-03-23 14:56:34 -0700456 title: i18n.global.t('global.action.delete'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100457 },
458 ],
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700459 };
460 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700461 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700462 batchExportData() {
Derick Montague602e98a2020-10-21 16:20:00 -0500463 return this.selectedRows.map((row) => omit(row, 'actions'));
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700464 },
465 filteredLogsByDate() {
466 return this.getFilteredTableDataByDate(
467 this.allLogs,
468 this.filterStartDate,
Ed Tanous81323992024-02-27 11:26:24 -0800469 this.filterEndDate,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700470 );
471 },
472 filteredLogs() {
473 return this.getFilteredTableData(
474 this.filteredLogsByDate,
Ed Tanous81323992024-02-27 11:26:24 -0800475 this.activeFilters,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700476 );
Derick Montague602e98a2020-10-21 16:20:00 -0500477 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700478 },
479 created() {
480 this.startLoader();
Kenneth Fullbright41057852021-12-27 16:19:37 -0600481 this.$store.dispatch('eventLog/getEventLogData').finally(() => {
482 this.endLoader();
483 this.isBusy = false;
484 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700485 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700486 methods: {
Sean Zhang582e9542024-07-05 12:48:45 +0300487 downloadEntry(uri) {
488 let filename = uri?.split('LogServices/')?.[1];
489 filename.replace(RegExp('/', 'g'), '_');
490 this.$store
491 .dispatch('eventLog/downloadEntry', uri)
492 .then((blob) => {
493 const link = document.createElement('a');
494 link.href = URL.createObjectURL(blob);
495 link.download = filename;
496 link.click();
497 URL.revokeObjectURL(link.href);
498 })
499 .catch(({ message }) => this.errorToast(message));
500 },
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500501 changelogStatus(row) {
502 this.$store
503 .dispatch('eventLog/updateEventLogStatus', {
504 uri: row.uri,
505 status: row.status,
506 })
507 .then((success) => {
508 this.successToast(success);
509 })
510 .catch(({ message }) => this.errorToast(message));
511 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600512 async deleteAllLogs() {
513 const ok = await this.confirmDialog(
514 i18n.global.t('pageEventLogs.modal.deleteAllMessage'),
515 {
Ed Tanous883a0d52024-03-23 14:56:34 -0700516 title: i18n.global.t('pageEventLogs.modal.deleteAllTitle'),
517 okTitle: i18n.global.t('global.action.delete'),
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500518 okVariant: 'danger',
Ed Tanous883a0d52024-03-23 14:56:34 -0700519 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000520 autoFocusButton: 'cancel',
jason westoverd36ac8a2025-11-03 20:58:59 -0600521 },
522 );
523 if (ok) {
524 this.$store
525 .dispatch('eventLog/deleteAllEventLogs', this.allLogs)
526 .then((message) => this.successToast(message))
527 .catch(({ message }) => this.errorToast(message));
528 }
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500529 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700530 deleteLogs(uris) {
Derick Montague602e98a2020-10-21 16:20:00 -0500531 this.$store
532 .dispatch('eventLog/deleteEventLogs', uris)
533 .then((messages) => {
534 messages.forEach(({ type, message }) => {
535 if (type === 'success') {
536 this.successToast(message);
537 } else if (type === 'error') {
538 this.errorToast(message);
539 }
540 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700541 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700542 },
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500543 exportAllLogs() {
544 {
545 return this.$store.getters['eventLog/allEvents'].map((eventLogs) => {
546 const allEventLogsString = JSON.stringify(eventLogs);
547 return allEventLogsString;
548 });
549 }
550 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700551 onFilterChange({ activeFilters }) {
552 this.activeFilters = activeFilters;
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700553 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700554 onTableRowAction(action, { uri }) {
555 if (action === 'delete') {
jason westoverd36ac8a2025-11-03 20:58:59 -0600556 this.confirmDialog(i18n.global.t('pageEventLogs.modal.deleteMessage'), {
557 title: i18n.global.t('pageEventLogs.modal.deleteTitle'),
558 okTitle: i18n.global.t('global.action.delete'),
559 cancelTitle: i18n.global.t('global.action.cancel'),
560 autoFocusButton: 'ok',
561 }).then((deleteConfirmed) => {
562 if (deleteConfirmed) this.deleteLogs([uri]);
563 });
564 }
565 },
566 async onBatchAction(action) {
567 if (action === 'delete') {
568 const uris = this.selectedRows.map((row) => row.uri);
569 const count = this.selectedRows.length;
570 const ok = await this.confirmDialog(
571 i18n.global.t('pageEventLogs.modal.deleteMessage', count),
572 {
573 title: i18n.global.t('pageEventLogs.modal.deleteTitle', count),
Ed Tanous883a0d52024-03-23 14:56:34 -0700574 okTitle: i18n.global.t('global.action.delete'),
575 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000576 autoFocusButton: 'ok',
jason westoverd36ac8a2025-11-03 20:58:59 -0600577 },
578 );
579 if (ok) {
580 if (this.selectedRows.length === this.allLogs.length) {
581 this.$store
582 .dispatch('eventLog/deleteAllEventLogs', this.selectedRows.length)
583 .then(() => {
584 this.successToast(
585 i18n.global.t(
586 'pageEventLogs.toast.successDelete',
587 uris.length,
588 ),
589 );
590 })
591 .catch(({ message }) => this.errorToast(message));
592 } else {
593 this.deleteLogs(uris);
594 }
595 }
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700596 }
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700597 },
598 onChangeDateTimeFilter({ fromDate, toDate }) {
599 this.filterStartDate = fromDate;
600 this.filterEndDate = toDate;
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700601 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530602 onFiltered(filteredItems) {
603 this.searchTotalFilteredRows = filteredItems.length;
604 },
SurenNeware96ebb0d2020-09-08 17:42:39 +0530605 // Create export file name based on date
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500606 exportFileNameByDate(value) {
SurenNeware96ebb0d2020-09-08 17:42:39 +0530607 let date = new Date();
608 date =
609 date.toISOString().slice(0, 10) +
610 '_' +
Derick Montague602e98a2020-10-21 16:20:00 -0500611 date.toString().split(':').join('-').split(' ')[4];
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500612 let fileName;
613 if (value === 'export') {
614 fileName = 'event_log_';
615 } else {
616 fileName = 'all_event_logs_';
617 }
618 return fileName + date;
Derick Montague602e98a2020-10-21 16:20:00 -0500619 },
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500620 resolveLogs() {
621 this.$store
622 .dispatch('eventLog/resolveEventLogs', this.selectedRows)
623 .then((messages) => {
624 messages.forEach(({ type, message }) => {
625 if (type === 'success') {
626 this.successToast(message);
627 } else if (type === 'error') {
628 this.errorToast(message);
629 }
630 });
631 });
632 },
633 unresolveLogs() {
634 this.$store
635 .dispatch('eventLog/unresolveEventLogs', this.selectedRows)
636 .then((messages) => {
637 messages.forEach(({ type, message }) => {
638 if (type === 'success') {
639 this.successToast(message);
640 } else if (type === 'error') {
641 this.errorToast(message);
642 }
643 });
644 });
645 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600646 confirmDialog(message, options = {}) {
647 return this.$confirm({ message, ...options });
648 },
Derick Montague602e98a2020-10-21 16:20:00 -0500649 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700650};
651</script>