blob: 392125c7f228b1f6ef6f81bbec98172b6b145ff6 [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">
Sean Zhang7bf1b402024-07-05 12:48:45 +0300154 <b-button @click="downloadEntry(item.additionalDataUri)">
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500155 <icon-download />{{ $t('pageEventLogs.additionalDataUri') }}
156 </b-button>
157 </b-col>
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530158 </b-row>
159 </b-container>
160 </template>
161
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700162 <!-- Severity column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500163 <template #cell(severity)="{ value }">
Mateusz Gapskib1f12532020-07-24 08:15:23 +0200164 <status-icon v-if="value" :status="statusIcon(value)" />
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700165 {{ value }}
166 </template>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700167 <!-- Date column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500168 <template #cell(date)="{ value }">
Surya V603cfbf2024-07-11 15:19:46 +0530169 <p class="mb-0">{{ $filters.formatDate(value) }}</p>
170 <p class="mb-0">{{ $filters.formatTime(value) }}</p>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700171 </template>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700172
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500173 <!-- Status column -->
174 <template #cell(status)="row">
175 <b-form-checkbox
176 v-model="row.item.status"
177 name="switch"
178 switch
179 @change="changelogStatus(row.item)"
180 >
181 <span v-if="row.item.status">
182 {{ $t('pageEventLogs.resolved') }}
183 </span>
184 <span v-else> {{ $t('pageEventLogs.unresolved') }} </span>
185 </b-form-checkbox>
186 </template>
187 <template #cell(filterByStatus)="{ value }">
188 {{ value }}
189 </template>
190
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700191 <!-- Actions column -->
Derick Montague602e98a2020-10-21 16:20:00 -0500192 <template #cell(actions)="row">
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700193 <table-row-action
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700194 v-for="(action, index) in row.item.actions"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700195 :key="index"
196 :value="action.value"
197 :title="action.title"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700198 :row-data="row.item"
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500199 :export-name="exportFileNameByDate('export')"
Yoshie Muranakaed06dc12020-06-16 12:12:27 -0700200 :data-test-id="`eventLogs-button-deleteRow-${row.index}`"
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530201 @click-table-action="onTableRowAction($event, row.item)"
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700202 >
Derick Montague602e98a2020-10-21 16:20:00 -0500203 <template #icon>
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700204 <icon-export v-if="action.value === 'export'" />
205 <icon-trashcan v-if="action.value === 'delete'" />
206 </template>
207 </table-row-action>
208 </template>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700209 </b-table>
210 </b-col>
211 </b-row>
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700212
213 <!-- Table pagination -->
214 <b-row>
SurenNewarea35b5a12020-10-13 17:08:20 +0530215 <b-col sm="6">
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700216 <b-form-group
217 class="table-pagination-select"
218 :label="$t('global.table.itemsPerPage')"
219 label-for="pagination-items-per-page"
220 >
221 <b-form-select
222 id="pagination-items-per-page"
223 v-model="perPage"
224 :options="itemsPerPageOptions"
225 />
226 </b-form-group>
SurenNewarea35b5a12020-10-13 17:08:20 +0530227 </b-col>
228 <b-col sm="6">
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700229 <b-pagination
230 v-model="currentPage"
231 first-number
232 last-number
233 :per-page="perPage"
Sukanya Pandeyf7000cd2021-08-26 18:34:49 +0530234 :total-rows="getTotalRowCount(filteredRows)"
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700235 aria-controls="table-event-logs"
236 />
237 </b-col>
238 </b-row>
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700239 </b-container>
240</template>
241
242<script>
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500243import IconDelete from '@carbon/icons-vue/es/trash-can/20';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700244import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
Sukanya Pandeyb2ca0c02020-07-20 23:23:29 +0530245import IconExport from '@carbon/icons-vue/es/document--export/20';
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530246import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500247import IconDownload from '@carbon/icons-vue/es/download/20';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700248import { omit } from 'lodash';
249
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700250import PageTitle from '@/components/Global/PageTitle';
251import StatusIcon from '@/components/Global/StatusIcon';
Derick Montagued853fba2020-07-16 11:24:10 -0500252import Search from '@/components/Global/Search';
Sukanya Pandey99010962020-07-27 21:44:47 +0530253import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700254import TableDateFilter from '@/components/Global/TableDateFilter';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700255import TableFilter from '@/components/Global/TableFilter';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700256import TableRowAction from '@/components/Global/TableRowAction';
257import TableToolbar from '@/components/Global/TableToolbar';
258import TableToolbarExport from '@/components/Global/TableToolbarExport';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700259
260import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
261import TableFilterMixin from '@/components/Mixins/TableFilterMixin';
SurenNewareba91c492020-10-27 14:18:54 +0530262import BVPaginationMixin, {
263 currentPage,
264 perPage,
265 itemsPerPageOptions,
266} from '@/components/Mixins/BVPaginationMixin';
267import BVTableSelectableMixin, {
268 selectedRows,
269 tableHeaderCheckboxModel,
270 tableHeaderCheckboxIndeterminate,
271} from '@/components/Mixins/BVTableSelectableMixin';
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700272import BVToastMixin from '@/components/Mixins/BVToastMixin';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500273import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700274import TableSortMixin from '@/components/Mixins/TableSortMixin';
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530275import TableRowExpandMixin, {
276 expandRowLabel,
277} from '@/components/Mixins/TableRowExpandMixin';
SurenNewareba91c492020-10-27 14:18:54 +0530278import SearchFilterMixin, {
279 searchFilter,
280} from '@/components/Mixins/SearchFilterMixin';
Ed Tanousdbd37e02024-03-23 14:56:34 -0700281import { useI18n } from 'vue-i18n';
282import i18n from '@/i18n';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700283
284export default {
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700285 components: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500286 IconDelete,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700287 IconExport,
288 IconTrashcan,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530289 IconChevron,
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500290 IconDownload,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700291 PageTitle,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700292 Search,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700293 StatusIcon,
Sukanya Pandey99010962020-07-27 21:44:47 +0530294 TableCellCount,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700295 TableFilter,
296 TableRowAction,
297 TableToolbar,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700298 TableToolbarExport,
Derick Montague602e98a2020-10-21 16:20:00 -0500299 TableDateFilter,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700300 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700301 mixins: [
302 BVPaginationMixin,
303 BVTableSelectableMixin,
304 BVToastMixin,
305 LoadingBarMixin,
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700306 TableFilterMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500307 DataFormatterMixin,
Dixsie Wolmers9b22b492020-09-07 21:26:06 -0500308 TableSortMixin,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530309 TableRowExpandMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500310 SearchFilterMixin,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700311 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500312 beforeRouteLeave(to, from, next) {
313 // Hide loader if the user navigates to another page
314 // before request is fulfilled.
315 this.hideLoader();
316 next();
317 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700318 data() {
319 return {
Ed Tanousdbd37e02024-03-23 14:56:34 -0700320 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600321 isBusy: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700322 fields: [
323 {
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530324 key: 'expandRow',
325 label: '',
326 tdClass: 'table-row-expand',
327 },
328 {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700329 key: 'checkbox',
Derick Montague602e98a2020-10-21 16:20:00 -0500330 sortable: false,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700331 },
332 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700333 key: 'id',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700334 label: i18n.global.t('pageEventLogs.table.id'),
Derick Montague602e98a2020-10-21 16:20:00 -0500335 sortable: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700336 },
337 {
338 key: 'severity',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700339 label: i18n.global.t('pageEventLogs.table.severity'),
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500340 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500341 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700342 },
343 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700344 key: 'date',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700345 label: i18n.global.t('pageEventLogs.table.date'),
Derick Montague602e98a2020-10-21 16:20:00 -0500346 sortable: true,
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500347 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700348 },
349 {
350 key: 'description',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700351 label: i18n.global.t('pageEventLogs.table.description'),
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500352 tdClass: 'text-break',
353 },
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530354 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
355 ? {}
356 : {
357 key: 'status',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700358 label: i18n.global.t('pageEventLogs.table.status'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530359 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700360 {
361 key: 'actions',
362 sortable: false,
363 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500364 tdClass: 'text-right text-nowrap',
365 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700366 ],
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530367 tableFilters:
368 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
369 ? [
370 {
371 key: 'severity',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700372 label: i18n.global.t('pageEventLogs.table.severity'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530373 values: ['OK', 'Warning', 'Critical'],
374 },
375 ]
376 : [
377 {
378 key: 'severity',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700379 label: i18n.global.t('pageEventLogs.table.severity'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530380 values: ['OK', 'Warning', 'Critical'],
381 },
382 {
383 key: 'filterByStatus',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700384 label: i18n.global.t('pageEventLogs.table.status'),
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530385 values: ['Resolved', 'Unresolved'],
386 },
387 ],
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530388 expandRowLabel,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700389 activeFilters: [],
Damian Celicoef96c6d2022-03-01 12:47:52 +0100390 batchActions:
391 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true'
392 ? []
393 : [
394 {
395 value: 'delete',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700396 label: i18n.global.t('global.action.delete'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100397 },
398 ],
SurenNewareba91c492020-10-27 14:18:54 +0530399 currentPage: currentPage,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700400 filterStartDate: null,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700401 filterEndDate: null,
SurenNewareba91c492020-10-27 14:18:54 +0530402 itemsPerPageOptions: itemsPerPageOptions,
403 perPage: perPage,
404 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500405 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530406 selectedRows: selectedRows,
407 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
408 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530409 hideToggle:
410 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true',
Damian Celicoef96c6d2022-03-01 12:47:52 +0100411 hideDelete:
412 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700413 };
414 },
415 computed: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500416 href() {
417 return `data:text/json;charset=utf-8,${this.exportAllLogs()}`;
418 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530419 filteredRows() {
420 return this.searchFilter
421 ? this.searchTotalFilteredRows
422 : this.filteredLogs.length;
423 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700424 allLogs() {
Derick Montague602e98a2020-10-21 16:20:00 -0500425 return this.$store.getters['eventLog/allEvents'].map((event) => {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700426 return {
427 ...event,
Damian Celicoef96c6d2022-03-01 12:47:52 +0100428 actions: this.hideDelete
429 ? [
430 {
431 value: 'export',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700432 title: i18n.global.t('global.action.export'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100433 },
434 ]
435 : [
436 {
437 value: 'export',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700438 title: i18n.global.t('global.action.export'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100439 },
440 {
441 value: 'delete',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700442 title: i18n.global.t('global.action.delete'),
Damian Celicoef96c6d2022-03-01 12:47:52 +0100443 },
444 ],
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700445 };
446 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700447 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700448 batchExportData() {
Derick Montague602e98a2020-10-21 16:20:00 -0500449 return this.selectedRows.map((row) => omit(row, 'actions'));
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700450 },
451 filteredLogsByDate() {
452 return this.getFilteredTableDataByDate(
453 this.allLogs,
454 this.filterStartDate,
Ed Tanous81323992024-02-27 11:26:24 -0800455 this.filterEndDate,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700456 );
457 },
458 filteredLogs() {
459 return this.getFilteredTableData(
460 this.filteredLogsByDate,
Ed Tanous81323992024-02-27 11:26:24 -0800461 this.activeFilters,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700462 );
Derick Montague602e98a2020-10-21 16:20:00 -0500463 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700464 },
465 created() {
466 this.startLoader();
Kenneth Fullbright41057852021-12-27 16:19:37 -0600467 this.$store.dispatch('eventLog/getEventLogData').finally(() => {
468 this.endLoader();
469 this.isBusy = false;
470 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700471 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700472 methods: {
Sean Zhang7bf1b402024-07-05 12:48:45 +0300473 downloadEntry(uri) {
474 let filename = uri?.split('LogServices/')?.[1];
475 filename.replace(RegExp('/', 'g'), '_');
476 this.$store
477 .dispatch('eventLog/downloadEntry', uri)
478 .then((blob) => {
479 const link = document.createElement('a');
480 link.href = URL.createObjectURL(blob);
481 link.download = filename;
482 link.click();
483 URL.revokeObjectURL(link.href);
484 })
485 .catch(({ message }) => this.errorToast(message));
486 },
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500487 changelogStatus(row) {
488 this.$store
489 .dispatch('eventLog/updateEventLogStatus', {
490 uri: row.uri,
491 status: row.status,
492 })
493 .then((success) => {
494 this.successToast(success);
495 })
496 .catch(({ message }) => this.errorToast(message));
497 },
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500498 deleteAllLogs() {
499 this.$bvModal
Ed Tanousdbd37e02024-03-23 14:56:34 -0700500 .msgBoxConfirm(i18n.global.t('pageEventLogs.modal.deleteAllMessage'), {
501 title: i18n.global.t('pageEventLogs.modal.deleteAllTitle'),
502 okTitle: i18n.global.t('global.action.delete'),
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500503 okVariant: 'danger',
Ed Tanousdbd37e02024-03-23 14:56:34 -0700504 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000505 autoFocusButton: 'cancel',
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500506 })
507 .then((deleteConfirmed) => {
508 if (deleteConfirmed) {
509 this.$store
510 .dispatch('eventLog/deleteAllEventLogs', this.allLogs)
511 .then((message) => this.successToast(message))
512 .catch(({ message }) => this.errorToast(message));
513 }
514 });
515 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700516 deleteLogs(uris) {
Derick Montague602e98a2020-10-21 16:20:00 -0500517 this.$store
518 .dispatch('eventLog/deleteEventLogs', uris)
519 .then((messages) => {
520 messages.forEach(({ type, message }) => {
521 if (type === 'success') {
522 this.successToast(message);
523 } else if (type === 'error') {
524 this.errorToast(message);
525 }
526 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700527 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700528 },
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500529 exportAllLogs() {
530 {
531 return this.$store.getters['eventLog/allEvents'].map((eventLogs) => {
532 const allEventLogsString = JSON.stringify(eventLogs);
533 return allEventLogsString;
534 });
535 }
536 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700537 onFilterChange({ activeFilters }) {
538 this.activeFilters = activeFilters;
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700539 },
540 onSortCompare(a, b, key) {
541 if (key === 'severity') {
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700542 return this.sortStatus(a, b, key);
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700543 }
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700544 },
545 onTableRowAction(action, { uri }) {
546 if (action === 'delete') {
547 this.$bvModal
Surya V603cfbf2024-07-11 15:19:46 +0530548 .msgBoxConfirm(i18n.global.t('pageEventLogs.modal.deleteMessage'), {
549 title: i18n.global.t('pageEventLogs.modal.deleteTitle'),
Ed Tanousdbd37e02024-03-23 14:56:34 -0700550 okTitle: i18n.global.t('global.action.delete'),
551 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000552 autoFocusButton: 'ok',
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700553 })
Derick Montague602e98a2020-10-21 16:20:00 -0500554 .then((deleteConfirmed) => {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700555 if (deleteConfirmed) this.deleteLogs([uri]);
556 });
557 }
558 },
559 onBatchAction(action) {
560 if (action === 'delete') {
Derick Montague602e98a2020-10-21 16:20:00 -0500561 const uris = this.selectedRows.map((row) => row.uri);
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700562 this.$bvModal
563 .msgBoxConfirm(
Surya V603cfbf2024-07-11 15:19:46 +0530564 i18n.global.t(
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700565 'pageEventLogs.modal.deleteMessage',
Ed Tanous81323992024-02-27 11:26:24 -0800566 this.selectedRows.length,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700567 ),
568 {
Surya V603cfbf2024-07-11 15:19:46 +0530569 title: i18n.global.t(
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700570 'pageEventLogs.modal.deleteTitle',
Ed Tanous81323992024-02-27 11:26:24 -0800571 this.selectedRows.length,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700572 ),
Ed Tanousdbd37e02024-03-23 14:56:34 -0700573 okTitle: i18n.global.t('global.action.delete'),
574 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000575 autoFocusButton: 'ok',
Ed Tanous81323992024-02-27 11:26:24 -0800576 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700577 )
Derick Montague602e98a2020-10-21 16:20:00 -0500578 .then((deleteConfirmed) => {
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530579 if (deleteConfirmed) {
580 if (this.selectedRows.length === this.allLogs.length) {
581 this.$store
582 .dispatch(
583 'eventLog/deleteAllEventLogs',
Ed Tanous81323992024-02-27 11:26:24 -0800584 this.selectedRows.length,
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530585 )
Nikhil Ashoka453ad922022-01-13 18:07:51 +0530586 .then(() => {
587 this.successToast(
Surya V603cfbf2024-07-11 15:19:46 +0530588 i18n.global.t(
Ed Tanous81323992024-02-27 11:26:24 -0800589 'pageEventLogs.toast.successDelete',
590 uris.length,
591 ),
Nikhil Ashoka453ad922022-01-13 18:07:51 +0530592 );
593 })
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530594 .catch(({ message }) => this.errorToast(message));
595 } else {
596 this.deleteLogs(uris);
597 }
598 }
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700599 });
600 }
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700601 },
602 onChangeDateTimeFilter({ fromDate, toDate }) {
603 this.filterStartDate = fromDate;
604 this.filterEndDate = toDate;
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700605 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530606 onFiltered(filteredItems) {
607 this.searchTotalFilteredRows = filteredItems.length;
608 },
SurenNeware96ebb0d2020-09-08 17:42:39 +0530609 // Create export file name based on date
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500610 exportFileNameByDate(value) {
SurenNeware96ebb0d2020-09-08 17:42:39 +0530611 let date = new Date();
612 date =
613 date.toISOString().slice(0, 10) +
614 '_' +
Derick Montague602e98a2020-10-21 16:20:00 -0500615 date.toString().split(':').join('-').split(' ')[4];
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500616 let fileName;
617 if (value === 'export') {
618 fileName = 'event_log_';
619 } else {
620 fileName = 'all_event_logs_';
621 }
622 return fileName + date;
Derick Montague602e98a2020-10-21 16:20:00 -0500623 },
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500624 resolveLogs() {
625 this.$store
626 .dispatch('eventLog/resolveEventLogs', this.selectedRows)
627 .then((messages) => {
628 messages.forEach(({ type, message }) => {
629 if (type === 'success') {
630 this.successToast(message);
631 } else if (type === 'error') {
632 this.errorToast(message);
633 }
634 });
635 });
636 },
637 unresolveLogs() {
638 this.$store
639 .dispatch('eventLog/unresolveEventLogs', this.selectedRows)
640 .then((messages) => {
641 messages.forEach(({ type, message }) => {
642 if (type === 'success') {
643 this.successToast(message);
644 } else if (type === 'error') {
645 this.errorToast(message);
646 }
647 });
648 });
649 },
Derick Montague602e98a2020-10-21 16:20:00 -0500650 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700651};
652</script>