blob: f52e211e6190f14b61d8685d02cb1d2b3b80d96b [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">
Ed Tanous9c729792024-03-23 14:56:34 -0700147 {{ item.modifiedDate }}
148 {{ 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 }">
Ed Tanous9c729792024-03-23 14:56:34 -0700173 <p class="mb-0">{{ value }}</p>
174 <p class="mb-0">{{ 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';
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700285
286export default {
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700287 components: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500288 IconDelete,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700289 IconExport,
290 IconTrashcan,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530291 IconChevron,
Dixsie Wolmers8b1beff2021-06-14 11:29:44 -0500292 IconDownload,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700293 PageTitle,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700294 Search,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700295 StatusIcon,
Sukanya Pandey99010962020-07-27 21:44:47 +0530296 TableCellCount,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700297 TableFilter,
298 TableRowAction,
299 TableToolbar,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700300 TableToolbarExport,
Derick Montague602e98a2020-10-21 16:20:00 -0500301 TableDateFilter,
Yoshie Muranakaf9832b02020-05-12 12:04:46 -0700302 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700303 mixins: [
304 BVPaginationMixin,
305 BVTableSelectableMixin,
306 BVToastMixin,
307 LoadingBarMixin,
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700308 TableFilterMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500309 DataFormatterMixin,
Dixsie Wolmers9b22b492020-09-07 21:26:06 -0500310 TableSortMixin,
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530311 TableRowExpandMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500312 SearchFilterMixin,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700313 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500314 beforeRouteLeave(to, from, next) {
315 // Hide loader if the user navigates to another page
316 // before request is fulfilled.
317 this.hideLoader();
318 next();
319 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700320 data() {
321 return {
Kenneth Fullbright41057852021-12-27 16:19:37 -0600322 isBusy: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700323 fields: [
324 {
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530325 key: 'expandRow',
326 label: '',
327 tdClass: 'table-row-expand',
328 },
329 {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700330 key: 'checkbox',
Derick Montague602e98a2020-10-21 16:20:00 -0500331 sortable: false,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700332 },
333 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700334 key: 'id',
335 label: this.$t('pageEventLogs.table.id'),
Derick Montague602e98a2020-10-21 16:20:00 -0500336 sortable: true,
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700337 },
338 {
339 key: 'severity',
340 label: this.$t('pageEventLogs.table.severity'),
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500341 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500342 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700343 },
344 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700345 key: 'date',
346 label: this.$t('pageEventLogs.table.date'),
Derick Montague602e98a2020-10-21 16:20:00 -0500347 sortable: true,
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500348 tdClass: 'text-nowrap',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700349 },
350 {
351 key: 'description',
Derick Montague602e98a2020-10-21 16:20:00 -0500352 label: this.$t('pageEventLogs.table.description'),
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500353 tdClass: 'text-break',
354 },
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530355 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
356 ? {}
357 : {
358 key: 'status',
359 label: this.$t('pageEventLogs.table.status'),
360 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700361 {
362 key: 'actions',
363 sortable: false,
364 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500365 tdClass: 'text-right text-nowrap',
366 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700367 ],
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530368 tableFilters:
369 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true'
370 ? [
371 {
372 key: 'severity',
373 label: this.$t('pageEventLogs.table.severity'),
374 values: ['OK', 'Warning', 'Critical'],
375 },
376 ]
377 : [
378 {
379 key: 'severity',
380 label: this.$t('pageEventLogs.table.severity'),
381 values: ['OK', 'Warning', 'Critical'],
382 },
383 {
384 key: 'filterByStatus',
385 label: this.$t('pageEventLogs.table.status'),
386 values: ['Resolved', 'Unresolved'],
387 },
388 ],
Sukanya Pandey47b047c2020-12-23 13:18:55 +0530389 expandRowLabel,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700390 activeFilters: [],
Damian Celicoef96c6d2022-03-01 12:47:52 +0100391 batchActions:
392 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true'
393 ? []
394 : [
395 {
396 value: 'delete',
397 label: this.$t('global.action.delete'),
398 },
399 ],
SurenNewareba91c492020-10-27 14:18:54 +0530400 currentPage: currentPage,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700401 filterStartDate: null,
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700402 filterEndDate: null,
SurenNewareba91c492020-10-27 14:18:54 +0530403 itemsPerPageOptions: itemsPerPageOptions,
404 perPage: perPage,
405 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500406 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530407 selectedRows: selectedRows,
408 tableHeaderCheckboxModel: tableHeaderCheckboxModel,
409 tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate,
Sivaprabu Ganesan0f6147c2023-04-12 19:08:20 +0530410 hideToggle:
411 process.env.VUE_APP_EVENT_LOGS_TOGGLE_BUTTON_DISABLED === 'true',
Damian Celicoef96c6d2022-03-01 12:47:52 +0100412 hideDelete:
413 process.env.VUE_APP_EVENT_LOGS_DELETE_BUTTON_DISABLED === 'true',
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700414 };
415 },
416 computed: {
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500417 href() {
418 return `data:text/json;charset=utf-8,${this.exportAllLogs()}`;
419 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530420 filteredRows() {
421 return this.searchFilter
422 ? this.searchTotalFilteredRows
423 : this.filteredLogs.length;
424 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700425 allLogs() {
Derick Montague602e98a2020-10-21 16:20:00 -0500426 return this.$store.getters['eventLog/allEvents'].map((event) => {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700427 return {
428 ...event,
Damian Celicoef96c6d2022-03-01 12:47:52 +0100429 actions: this.hideDelete
430 ? [
431 {
432 value: 'export',
433 title: this.$t('global.action.export'),
434 },
435 ]
436 : [
437 {
438 value: 'export',
439 title: this.$t('global.action.export'),
440 },
441 {
442 value: 'delete',
443 title: this.$t('global.action.delete'),
444 },
445 ],
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700446 };
447 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700448 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700449 batchExportData() {
Derick Montague602e98a2020-10-21 16:20:00 -0500450 return this.selectedRows.map((row) => omit(row, 'actions'));
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700451 },
452 filteredLogsByDate() {
453 return this.getFilteredTableDataByDate(
454 this.allLogs,
455 this.filterStartDate,
Ed Tanous81323992024-02-27 11:26:24 -0800456 this.filterEndDate,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700457 );
458 },
459 filteredLogs() {
460 return this.getFilteredTableData(
461 this.filteredLogsByDate,
Ed Tanous81323992024-02-27 11:26:24 -0800462 this.activeFilters,
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700463 );
Derick Montague602e98a2020-10-21 16:20:00 -0500464 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700465 },
466 created() {
467 this.startLoader();
Kenneth Fullbright41057852021-12-27 16:19:37 -0600468 this.$store.dispatch('eventLog/getEventLogData').finally(() => {
469 this.endLoader();
470 this.isBusy = false;
471 });
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700472 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700473 methods: {
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500474 changelogStatus(row) {
475 this.$store
476 .dispatch('eventLog/updateEventLogStatus', {
477 uri: row.uri,
478 status: row.status,
479 })
480 .then((success) => {
481 this.successToast(success);
482 })
483 .catch(({ message }) => this.errorToast(message));
484 },
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500485 deleteAllLogs() {
486 this.$bvModal
487 .msgBoxConfirm(this.$t('pageEventLogs.modal.deleteAllMessage'), {
488 title: this.$t('pageEventLogs.modal.deleteAllTitle'),
489 okTitle: this.$t('global.action.delete'),
490 okVariant: 'danger',
491 cancelTitle: this.$t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000492 autoFocusButton: 'cancel',
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500493 })
494 .then((deleteConfirmed) => {
495 if (deleteConfirmed) {
496 this.$store
497 .dispatch('eventLog/deleteAllEventLogs', this.allLogs)
498 .then((message) => this.successToast(message))
499 .catch(({ message }) => this.errorToast(message));
500 }
501 });
502 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700503 deleteLogs(uris) {
Derick Montague602e98a2020-10-21 16:20:00 -0500504 this.$store
505 .dispatch('eventLog/deleteEventLogs', uris)
506 .then((messages) => {
507 messages.forEach(({ type, message }) => {
508 if (type === 'success') {
509 this.successToast(message);
510 } else if (type === 'error') {
511 this.errorToast(message);
512 }
513 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700514 });
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700515 },
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500516 exportAllLogs() {
517 {
518 return this.$store.getters['eventLog/allEvents'].map((eventLogs) => {
519 const allEventLogsString = JSON.stringify(eventLogs);
520 return allEventLogsString;
521 });
522 }
523 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700524 onFilterChange({ activeFilters }) {
525 this.activeFilters = activeFilters;
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700526 },
527 onSortCompare(a, b, key) {
528 if (key === 'severity') {
Yoshie Muranaka73e419a2020-06-18 13:08:19 -0700529 return this.sortStatus(a, b, key);
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700530 }
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700531 },
532 onTableRowAction(action, { uri }) {
533 if (action === 'delete') {
534 this.$bvModal
535 .msgBoxConfirm(this.$tc('pageEventLogs.modal.deleteMessage'), {
536 title: this.$tc('pageEventLogs.modal.deleteTitle'),
Derick Montague602e98a2020-10-21 16:20:00 -0500537 okTitle: this.$t('global.action.delete'),
Sukanya Pandey38357132020-12-22 13:40:59 +0530538 cancelTitle: this.$t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000539 autoFocusButton: 'ok',
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700540 })
Derick Montague602e98a2020-10-21 16:20:00 -0500541 .then((deleteConfirmed) => {
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700542 if (deleteConfirmed) this.deleteLogs([uri]);
543 });
544 }
545 },
546 onBatchAction(action) {
547 if (action === 'delete') {
Derick Montague602e98a2020-10-21 16:20:00 -0500548 const uris = this.selectedRows.map((row) => row.uri);
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700549 this.$bvModal
550 .msgBoxConfirm(
551 this.$tc(
552 'pageEventLogs.modal.deleteMessage',
Ed Tanous81323992024-02-27 11:26:24 -0800553 this.selectedRows.length,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700554 ),
555 {
556 title: this.$tc(
557 'pageEventLogs.modal.deleteTitle',
Ed Tanous81323992024-02-27 11:26:24 -0800558 this.selectedRows.length,
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700559 ),
Derick Montague602e98a2020-10-21 16:20:00 -0500560 okTitle: this.$t('global.action.delete'),
Sukanya Pandey38357132020-12-22 13:40:59 +0530561 cancelTitle: this.$t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000562 autoFocusButton: 'ok',
Ed Tanous81323992024-02-27 11:26:24 -0800563 },
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700564 )
Derick Montague602e98a2020-10-21 16:20:00 -0500565 .then((deleteConfirmed) => {
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530566 if (deleteConfirmed) {
567 if (this.selectedRows.length === this.allLogs.length) {
568 this.$store
569 .dispatch(
570 'eventLog/deleteAllEventLogs',
Ed Tanous81323992024-02-27 11:26:24 -0800571 this.selectedRows.length,
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530572 )
Nikhil Ashoka453ad922022-01-13 18:07:51 +0530573 .then(() => {
574 this.successToast(
Ed Tanous81323992024-02-27 11:26:24 -0800575 this.$tc(
576 'pageEventLogs.toast.successDelete',
577 uris.length,
578 ),
Nikhil Ashoka453ad922022-01-13 18:07:51 +0530579 );
580 })
Sukanya Pandey2f6d5522020-10-28 10:38:00 +0530581 .catch(({ message }) => this.errorToast(message));
582 } else {
583 this.deleteLogs(uris);
584 }
585 }
Yoshie Muranakabe3af332020-05-11 08:23:04 -0700586 });
587 }
Yoshie Muranaka68bbba22020-05-18 09:49:37 -0700588 },
589 onChangeDateTimeFilter({ fromDate, toDate }) {
590 this.filterStartDate = fromDate;
591 this.filterEndDate = toDate;
Yoshie Muranaka193c22a2020-06-30 20:54:10 -0700592 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530593 onFiltered(filteredItems) {
594 this.searchTotalFilteredRows = filteredItems.length;
595 },
SurenNeware96ebb0d2020-09-08 17:42:39 +0530596 // Create export file name based on date
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500597 exportFileNameByDate(value) {
SurenNeware96ebb0d2020-09-08 17:42:39 +0530598 let date = new Date();
599 date =
600 date.toISOString().slice(0, 10) +
601 '_' +
Derick Montague602e98a2020-10-21 16:20:00 -0500602 date.toString().split(':').join('-').split(' ')[4];
Dixsie Wolmers7e2ba542021-06-03 07:38:12 -0500603 let fileName;
604 if (value === 'export') {
605 fileName = 'event_log_';
606 } else {
607 fileName = 'all_event_logs_';
608 }
609 return fileName + date;
Derick Montague602e98a2020-10-21 16:20:00 -0500610 },
Dixsie Wolmers27d68af2021-05-02 18:20:27 -0500611 resolveLogs() {
612 this.$store
613 .dispatch('eventLog/resolveEventLogs', this.selectedRows)
614 .then((messages) => {
615 messages.forEach(({ type, message }) => {
616 if (type === 'success') {
617 this.successToast(message);
618 } else if (type === 'error') {
619 this.errorToast(message);
620 }
621 });
622 });
623 },
624 unresolveLogs() {
625 this.$store
626 .dispatch('eventLog/unresolveEventLogs', 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 },
Derick Montague602e98a2020-10-21 16:20:00 -0500637 },
Yoshie Muranaka6f102342020-05-05 09:45:39 -0700638};
639</script>