Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 1 | <template> |
| 2 | <b-container fluid="xl"> |
| 3 | <page-title /> |
SurenNeware | 787635a | 2020-11-24 22:42:42 +0530 | [diff] [blame] | 4 | <b-row class="align-items-start"> |
| 5 | <b-col sm="8" xl="6" class="d-sm-flex align-items-end"> |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 6 | <search |
| 7 | :placeholder="$t('pageEventLogs.table.searchLogs')" |
Sandeepa Singh | 99e20d8 | 2021-02-09 17:37:59 +0530 | [diff] [blame] | 8 | data-test-id="eventLogs-input-searchLogs" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 9 | @change-search="onChangeSearchInput" |
| 10 | @clear-search="onClearSearchInput" |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 11 | /> |
SurenNeware | 787635a | 2020-11-24 22:42:42 +0530 | [diff] [blame] | 12 | <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 Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 18 | </b-col> |
SurenNeware | 787635a | 2020-11-24 22:42:42 +0530 | [diff] [blame] | 19 | <b-col sm="8" md="7" xl="6"> |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 20 | <table-date-filter @change="onChangeDateTimeFilter" /> |
| 21 | </b-col> |
| 22 | </b-row> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 23 | <b-row> |
| 24 | <b-col class="text-right"> |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 25 | <table-filter :filters="tableFilters" @filter-change="onFilterChange" /> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 26 | </b-col> |
| 27 | </b-row> |
| 28 | <b-row> |
| 29 | <b-col> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 30 | <table-toolbar |
| 31 | ref="toolbar" |
| 32 | :selected-items-count="selectedRows.length" |
| 33 | :actions="batchActions" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 34 | @clear-selected="clearSelectedRows($refs.table)" |
| 35 | @batch-action="onBatchAction" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 36 | > |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 37 | <template #toolbar-buttons> |
| 38 | <b-button variant="primary" @click="resolveLogs"> |
| 39 | {{ $t('pageEventLogs.resolve') }} |
| 40 | </b-button> |
| 41 | <b-button variant="primary" @click="unresolveLogs"> |
| 42 | {{ $t('pageEventLogs.unresolve') }} |
| 43 | </b-button> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 44 | <table-toolbar-export |
| 45 | :data="batchExportData" |
SurenNeware | 96ebb0d | 2020-09-08 17:42:39 +0530 | [diff] [blame] | 46 | :file-name="exportFileNameByDate()" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 47 | /> |
| 48 | </template> |
| 49 | </table-toolbar> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 50 | <b-table |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 51 | id="table-event-logs" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 52 | ref="table" |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 53 | responsive="md" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 54 | selectable |
| 55 | no-select-on-click |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 56 | sort-icon-left |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 57 | hover |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 58 | no-sort-reset |
| 59 | sort-desc |
| 60 | show-empty |
Derick Montague | 6b140ba | 2020-09-03 16:26:33 -0500 | [diff] [blame] | 61 | sort-by="id" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 62 | :fields="fields" |
| 63 | :items="filteredLogs" |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 64 | :sort-compare="onSortCompare" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 65 | :empty-text="$t('global.table.emptyMessage')" |
SurenNeware | 156a0e6 | 2020-08-28 19:20:03 +0530 | [diff] [blame] | 66 | :empty-filtered-text="$t('global.table.emptySearchMessage')" |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 67 | :per-page="perPage" |
| 68 | :current-page="currentPage" |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 69 | :filter="searchFilter" |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 70 | @filtered="onFiltered" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 71 | @row-selected="onRowSelected($event, filteredLogs.length)" |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 72 | > |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 73 | <!-- Checkbox column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 74 | <template #head(checkbox)> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 75 | <b-form-checkbox |
| 76 | v-model="tableHeaderCheckboxModel" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 77 | data-test-id="eventLogs-checkbox-selectAll" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 78 | :indeterminate="tableHeaderCheckboxIndeterminate" |
| 79 | @change="onChangeHeaderCheckbox($refs.table)" |
Dixsie Wolmers | c42ad71 | 2020-11-19 17:29:24 -0600 | [diff] [blame] | 80 | > |
| 81 | <span class="sr-only">{{ $t('global.table.selectAll') }}</span> |
| 82 | </b-form-checkbox> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 83 | </template> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 84 | <template #cell(checkbox)="row"> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 85 | <b-form-checkbox |
| 86 | v-model="row.rowSelected" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 87 | :data-test-id="`eventLogs-checkbox-selectRow-${row.index}`" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 88 | @change="toggleSelectRow($refs.table, row.index)" |
Dixsie Wolmers | c42ad71 | 2020-11-19 17:29:24 -0600 | [diff] [blame] | 89 | > |
| 90 | <span class="sr-only">{{ $t('global.table.selectItem') }}</span> |
| 91 | </b-form-checkbox> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 92 | </template> |
| 93 | |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 94 | <!-- Expand chevron icon --> |
| 95 | <template #cell(expandRow)="row"> |
| 96 | <b-button |
| 97 | variant="link" |
| 98 | :aria-label="expandRowLabel" |
| 99 | :title="expandRowLabel" |
| 100 | class="btn-icon-only" |
| 101 | @click="toggleRowDetails(row)" |
| 102 | > |
| 103 | <icon-chevron /> |
| 104 | </b-button> |
| 105 | </template> |
| 106 | |
| 107 | <template #row-details="{ item }"> |
| 108 | <b-container fluid> |
| 109 | <b-row> |
Dixsie Wolmers | 8b1beff | 2021-06-14 11:29:44 -0500 | [diff] [blame] | 110 | <b-col> |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 111 | <dl> |
| 112 | <!-- Name --> |
| 113 | <dt>{{ $t('pageEventLogs.table.name') }}:</dt> |
| 114 | <dd>{{ tableFormatter(item.name) }}</dd> |
| 115 | </dl> |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 116 | <dl> |
| 117 | <!-- Type --> |
| 118 | <dt>{{ $t('pageEventLogs.table.type') }}:</dt> |
| 119 | <dd>{{ tableFormatter(item.type) }}</dd> |
| 120 | </dl> |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 121 | </b-col> |
Dixsie Wolmers | 8b1beff | 2021-06-14 11:29:44 -0500 | [diff] [blame] | 122 | <b-col> |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 123 | <dl> |
| 124 | <!-- Modified date --> |
| 125 | <dt>{{ $t('pageEventLogs.table.modifiedDate') }}:</dt> |
| 126 | <dd v-if="item.modifiedDate"> |
| 127 | {{ item.modifiedDate | formatDate }} |
| 128 | {{ item.modifiedDate | formatTime }} |
| 129 | </dd> |
| 130 | <dd v-else>--</dd> |
| 131 | </dl> |
| 132 | </b-col> |
Dixsie Wolmers | 8b1beff | 2021-06-14 11:29:44 -0500 | [diff] [blame] | 133 | <b-col class="text-nowrap"> |
| 134 | <b-button |
| 135 | class="btn btn-secondary float-right" |
| 136 | :href="item.additionalDataUri" |
| 137 | target="_blank" |
| 138 | > |
| 139 | <icon-download />{{ $t('pageEventLogs.additionalDataUri') }} |
| 140 | </b-button> |
| 141 | </b-col> |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 142 | </b-row> |
| 143 | </b-container> |
| 144 | </template> |
| 145 | |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 146 | <!-- Severity column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 147 | <template #cell(severity)="{ value }"> |
Mateusz Gapski | b1f1253 | 2020-07-24 08:15:23 +0200 | [diff] [blame] | 148 | <status-icon v-if="value" :status="statusIcon(value)" /> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 149 | {{ value }} |
| 150 | </template> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 151 | <!-- Date column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 152 | <template #cell(date)="{ value }"> |
Dixsie Wolmers | 949cdd5 | 2020-08-24 21:36:37 -0500 | [diff] [blame] | 153 | <p class="mb-0">{{ value | formatDate }}</p> |
| 154 | <p class="mb-0">{{ value | formatTime }}</p> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 155 | </template> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 156 | |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 157 | <!-- Status column --> |
| 158 | <template #cell(status)="row"> |
| 159 | <b-form-checkbox |
| 160 | v-model="row.item.status" |
| 161 | name="switch" |
| 162 | switch |
| 163 | @change="changelogStatus(row.item)" |
| 164 | > |
| 165 | <span v-if="row.item.status"> |
| 166 | {{ $t('pageEventLogs.resolved') }} |
| 167 | </span> |
| 168 | <span v-else> {{ $t('pageEventLogs.unresolved') }} </span> |
| 169 | </b-form-checkbox> |
| 170 | </template> |
| 171 | <template #cell(filterByStatus)="{ value }"> |
| 172 | {{ value }} |
| 173 | </template> |
| 174 | |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 175 | <!-- Actions column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 176 | <template #cell(actions)="row"> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 177 | <table-row-action |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 178 | v-for="(action, index) in row.item.actions" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 179 | :key="index" |
| 180 | :value="action.value" |
| 181 | :title="action.title" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 182 | :row-data="row.item" |
SurenNeware | 96ebb0d | 2020-09-08 17:42:39 +0530 | [diff] [blame] | 183 | :export-name="exportFileNameByDate()" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 184 | :data-test-id="`eventLogs-button-deleteRow-${row.index}`" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 185 | @click-table-action="onTableRowAction($event, row.item)" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 186 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 187 | <template #icon> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 188 | <icon-export v-if="action.value === 'export'" /> |
| 189 | <icon-trashcan v-if="action.value === 'delete'" /> |
| 190 | </template> |
| 191 | </table-row-action> |
| 192 | </template> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 193 | </b-table> |
| 194 | </b-col> |
| 195 | </b-row> |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 196 | |
| 197 | <!-- Table pagination --> |
| 198 | <b-row> |
SurenNeware | a35b5a1 | 2020-10-13 17:08:20 +0530 | [diff] [blame] | 199 | <b-col sm="6"> |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 200 | <b-form-group |
| 201 | class="table-pagination-select" |
| 202 | :label="$t('global.table.itemsPerPage')" |
| 203 | label-for="pagination-items-per-page" |
| 204 | > |
| 205 | <b-form-select |
| 206 | id="pagination-items-per-page" |
| 207 | v-model="perPage" |
| 208 | :options="itemsPerPageOptions" |
| 209 | /> |
| 210 | </b-form-group> |
SurenNeware | a35b5a1 | 2020-10-13 17:08:20 +0530 | [diff] [blame] | 211 | </b-col> |
| 212 | <b-col sm="6"> |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 213 | <b-pagination |
| 214 | v-model="currentPage" |
| 215 | first-number |
| 216 | last-number |
| 217 | :per-page="perPage" |
| 218 | :total-rows="getTotalRowCount(filteredLogs.length)" |
| 219 | aria-controls="table-event-logs" |
| 220 | /> |
| 221 | </b-col> |
| 222 | </b-row> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 223 | </b-container> |
| 224 | </template> |
| 225 | |
| 226 | <script> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 227 | import IconTrashcan from '@carbon/icons-vue/es/trash-can/20'; |
Sukanya Pandey | b2ca0c0 | 2020-07-20 23:23:29 +0530 | [diff] [blame] | 228 | import IconExport from '@carbon/icons-vue/es/document--export/20'; |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 229 | import IconChevron from '@carbon/icons-vue/es/chevron--down/20'; |
Dixsie Wolmers | 8b1beff | 2021-06-14 11:29:44 -0500 | [diff] [blame] | 230 | import IconDownload from '@carbon/icons-vue/es/download/20'; |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 231 | import { omit } from 'lodash'; |
| 232 | |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 233 | import PageTitle from '@/components/Global/PageTitle'; |
| 234 | import StatusIcon from '@/components/Global/StatusIcon'; |
Derick Montague | d853fba | 2020-07-16 11:24:10 -0500 | [diff] [blame] | 235 | import Search from '@/components/Global/Search'; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 236 | import TableCellCount from '@/components/Global/TableCellCount'; |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 237 | import TableDateFilter from '@/components/Global/TableDateFilter'; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 238 | import TableFilter from '@/components/Global/TableFilter'; |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 239 | import TableRowAction from '@/components/Global/TableRowAction'; |
| 240 | import TableToolbar from '@/components/Global/TableToolbar'; |
| 241 | import TableToolbarExport from '@/components/Global/TableToolbarExport'; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 242 | |
| 243 | import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; |
| 244 | import TableFilterMixin from '@/components/Mixins/TableFilterMixin'; |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 245 | import BVPaginationMixin, { |
| 246 | currentPage, |
| 247 | perPage, |
| 248 | itemsPerPageOptions, |
| 249 | } from '@/components/Mixins/BVPaginationMixin'; |
| 250 | import BVTableSelectableMixin, { |
| 251 | selectedRows, |
| 252 | tableHeaderCheckboxModel, |
| 253 | tableHeaderCheckboxIndeterminate, |
| 254 | } from '@/components/Mixins/BVTableSelectableMixin'; |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 255 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | 73e419a | 2020-06-18 13:08:19 -0700 | [diff] [blame] | 256 | import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin'; |
| 257 | import TableSortMixin from '@/components/Mixins/TableSortMixin'; |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 258 | import TableRowExpandMixin, { |
| 259 | expandRowLabel, |
| 260 | } from '@/components/Mixins/TableRowExpandMixin'; |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 261 | import SearchFilterMixin, { |
| 262 | searchFilter, |
| 263 | } from '@/components/Mixins/SearchFilterMixin'; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 264 | |
| 265 | export default { |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 266 | components: { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 267 | IconExport, |
| 268 | IconTrashcan, |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 269 | IconChevron, |
Dixsie Wolmers | 8b1beff | 2021-06-14 11:29:44 -0500 | [diff] [blame] | 270 | IconDownload, |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 271 | PageTitle, |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 272 | Search, |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 273 | StatusIcon, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 274 | TableCellCount, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 275 | TableFilter, |
| 276 | TableRowAction, |
| 277 | TableToolbar, |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 278 | TableToolbarExport, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 279 | TableDateFilter, |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 280 | }, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 281 | mixins: [ |
| 282 | BVPaginationMixin, |
| 283 | BVTableSelectableMixin, |
| 284 | BVToastMixin, |
| 285 | LoadingBarMixin, |
Yoshie Muranaka | 73e419a | 2020-06-18 13:08:19 -0700 | [diff] [blame] | 286 | TableFilterMixin, |
| 287 | TableDataFormatterMixin, |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 288 | TableSortMixin, |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 289 | TableRowExpandMixin, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 290 | SearchFilterMixin, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 291 | ], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 292 | beforeRouteLeave(to, from, next) { |
| 293 | // Hide loader if the user navigates to another page |
| 294 | // before request is fulfilled. |
| 295 | this.hideLoader(); |
| 296 | next(); |
| 297 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 298 | data() { |
| 299 | return { |
| 300 | fields: [ |
| 301 | { |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 302 | key: 'expandRow', |
| 303 | label: '', |
| 304 | tdClass: 'table-row-expand', |
| 305 | }, |
| 306 | { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 307 | key: 'checkbox', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 308 | sortable: false, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 309 | }, |
| 310 | { |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 311 | key: 'id', |
| 312 | label: this.$t('pageEventLogs.table.id'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 313 | sortable: true, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 314 | }, |
| 315 | { |
| 316 | key: 'severity', |
| 317 | label: this.$t('pageEventLogs.table.severity'), |
Dixsie Wolmers | a04d46f | 2020-10-22 06:34:56 -0500 | [diff] [blame] | 318 | sortable: true, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 319 | tdClass: 'text-nowrap', |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 320 | }, |
| 321 | { |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 322 | key: 'date', |
| 323 | label: this.$t('pageEventLogs.table.date'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 324 | sortable: true, |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 325 | tdClass: 'text-nowrap', |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 326 | }, |
| 327 | { |
| 328 | key: 'description', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 329 | label: this.$t('pageEventLogs.table.description'), |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 330 | tdClass: 'text-break', |
| 331 | }, |
| 332 | { |
| 333 | key: 'status', |
| 334 | label: this.$t('pageEventLogs.table.status'), |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 335 | }, |
| 336 | { |
| 337 | key: 'actions', |
| 338 | sortable: false, |
| 339 | label: '', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 340 | tdClass: 'text-right text-nowrap', |
| 341 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 342 | ], |
| 343 | tableFilters: [ |
| 344 | { |
Yoshie Muranaka | 0045400 | 2020-06-22 09:14:05 -0700 | [diff] [blame] | 345 | key: 'severity', |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 346 | label: this.$t('pageEventLogs.table.severity'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 347 | values: ['OK', 'Warning', 'Critical'], |
| 348 | }, |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 349 | { |
| 350 | key: 'filterByStatus', |
| 351 | label: this.$t('pageEventLogs.table.status'), |
| 352 | values: ['Resolved', 'Unresolved'], |
| 353 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 354 | ], |
Sukanya Pandey | 47b047c | 2020-12-23 13:18:55 +0530 | [diff] [blame] | 355 | expandRowLabel, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 356 | activeFilters: [], |
| 357 | batchActions: [ |
| 358 | { |
| 359 | value: 'delete', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 360 | label: this.$t('global.action.delete'), |
| 361 | }, |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 362 | ], |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 363 | currentPage: currentPage, |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 364 | filterStartDate: null, |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 365 | filterEndDate: null, |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 366 | itemsPerPageOptions: itemsPerPageOptions, |
| 367 | perPage: perPage, |
| 368 | searchFilter: searchFilter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 369 | searchTotalFilteredRows: 0, |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 370 | selectedRows: selectedRows, |
| 371 | tableHeaderCheckboxModel: tableHeaderCheckboxModel, |
| 372 | tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 373 | }; |
| 374 | }, |
| 375 | computed: { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 376 | filteredRows() { |
| 377 | return this.searchFilter |
| 378 | ? this.searchTotalFilteredRows |
| 379 | : this.filteredLogs.length; |
| 380 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 381 | allLogs() { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 382 | return this.$store.getters['eventLog/allEvents'].map((event) => { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 383 | return { |
| 384 | ...event, |
| 385 | actions: [ |
| 386 | { |
| 387 | value: 'export', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 388 | title: this.$t('global.action.export'), |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 389 | }, |
| 390 | { |
| 391 | value: 'delete', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 392 | title: this.$t('global.action.delete'), |
| 393 | }, |
| 394 | ], |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 395 | }; |
| 396 | }); |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 397 | }, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 398 | batchExportData() { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 399 | return this.selectedRows.map((row) => omit(row, 'actions')); |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 400 | }, |
| 401 | filteredLogsByDate() { |
| 402 | return this.getFilteredTableDataByDate( |
| 403 | this.allLogs, |
| 404 | this.filterStartDate, |
| 405 | this.filterEndDate |
| 406 | ); |
| 407 | }, |
| 408 | filteredLogs() { |
| 409 | return this.getFilteredTableData( |
| 410 | this.filteredLogsByDate, |
| 411 | this.activeFilters |
| 412 | ); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 413 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 414 | }, |
| 415 | created() { |
| 416 | this.startLoader(); |
| 417 | this.$store |
| 418 | .dispatch('eventLog/getEventLogData') |
| 419 | .finally(() => this.endLoader()); |
| 420 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 421 | methods: { |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 422 | changelogStatus(row) { |
| 423 | this.$store |
| 424 | .dispatch('eventLog/updateEventLogStatus', { |
| 425 | uri: row.uri, |
| 426 | status: row.status, |
| 427 | }) |
| 428 | .then((success) => { |
| 429 | this.successToast(success); |
| 430 | }) |
| 431 | .catch(({ message }) => this.errorToast(message)); |
| 432 | }, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 433 | deleteLogs(uris) { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 434 | this.$store |
| 435 | .dispatch('eventLog/deleteEventLogs', uris) |
| 436 | .then((messages) => { |
| 437 | messages.forEach(({ type, message }) => { |
| 438 | if (type === 'success') { |
| 439 | this.successToast(message); |
| 440 | } else if (type === 'error') { |
| 441 | this.errorToast(message); |
| 442 | } |
| 443 | }); |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 444 | }); |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 445 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 446 | onFilterChange({ activeFilters }) { |
| 447 | this.activeFilters = activeFilters; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 448 | }, |
| 449 | onSortCompare(a, b, key) { |
| 450 | if (key === 'severity') { |
Yoshie Muranaka | 73e419a | 2020-06-18 13:08:19 -0700 | [diff] [blame] | 451 | return this.sortStatus(a, b, key); |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 452 | } |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 453 | }, |
| 454 | onTableRowAction(action, { uri }) { |
| 455 | if (action === 'delete') { |
| 456 | this.$bvModal |
| 457 | .msgBoxConfirm(this.$tc('pageEventLogs.modal.deleteMessage'), { |
| 458 | title: this.$tc('pageEventLogs.modal.deleteTitle'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 459 | okTitle: this.$t('global.action.delete'), |
Sukanya Pandey | 3835713 | 2020-12-22 13:40:59 +0530 | [diff] [blame] | 460 | cancelTitle: this.$t('global.action.cancel'), |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 461 | }) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 462 | .then((deleteConfirmed) => { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 463 | if (deleteConfirmed) this.deleteLogs([uri]); |
| 464 | }); |
| 465 | } |
| 466 | }, |
| 467 | onBatchAction(action) { |
| 468 | if (action === 'delete') { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 469 | const uris = this.selectedRows.map((row) => row.uri); |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 470 | this.$bvModal |
| 471 | .msgBoxConfirm( |
| 472 | this.$tc( |
| 473 | 'pageEventLogs.modal.deleteMessage', |
| 474 | this.selectedRows.length |
| 475 | ), |
| 476 | { |
| 477 | title: this.$tc( |
| 478 | 'pageEventLogs.modal.deleteTitle', |
| 479 | this.selectedRows.length |
| 480 | ), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 481 | okTitle: this.$t('global.action.delete'), |
Sukanya Pandey | 3835713 | 2020-12-22 13:40:59 +0530 | [diff] [blame] | 482 | cancelTitle: this.$t('global.action.cancel'), |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 483 | } |
| 484 | ) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 485 | .then((deleteConfirmed) => { |
Sukanya Pandey | 2f6d552 | 2020-10-28 10:38:00 +0530 | [diff] [blame] | 486 | if (deleteConfirmed) { |
| 487 | if (this.selectedRows.length === this.allLogs.length) { |
| 488 | this.$store |
| 489 | .dispatch( |
| 490 | 'eventLog/deleteAllEventLogs', |
| 491 | this.selectedRows.length |
| 492 | ) |
| 493 | .then((message) => this.successToast(message)) |
| 494 | .catch(({ message }) => this.errorToast(message)); |
| 495 | } else { |
| 496 | this.deleteLogs(uris); |
| 497 | } |
| 498 | } |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 499 | }); |
| 500 | } |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 501 | }, |
| 502 | onChangeDateTimeFilter({ fromDate, toDate }) { |
| 503 | this.filterStartDate = fromDate; |
| 504 | this.filterEndDate = toDate; |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 505 | }, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 506 | onFiltered(filteredItems) { |
| 507 | this.searchTotalFilteredRows = filteredItems.length; |
| 508 | }, |
SurenNeware | 96ebb0d | 2020-09-08 17:42:39 +0530 | [diff] [blame] | 509 | // Create export file name based on date |
| 510 | exportFileNameByDate() { |
| 511 | let date = new Date(); |
| 512 | date = |
| 513 | date.toISOString().slice(0, 10) + |
| 514 | '_' + |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 515 | date.toString().split(':').join('-').split(' ')[4]; |
SurenNeware | 96ebb0d | 2020-09-08 17:42:39 +0530 | [diff] [blame] | 516 | return this.$t('pageEventLogs.exportFilePrefix') + date; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 517 | }, |
Dixsie Wolmers | 27d68af | 2021-05-02 18:20:27 -0500 | [diff] [blame] | 518 | resolveLogs() { |
| 519 | this.$store |
| 520 | .dispatch('eventLog/resolveEventLogs', this.selectedRows) |
| 521 | .then((messages) => { |
| 522 | messages.forEach(({ type, message }) => { |
| 523 | if (type === 'success') { |
| 524 | this.successToast(message); |
| 525 | } else if (type === 'error') { |
| 526 | this.errorToast(message); |
| 527 | } |
| 528 | }); |
| 529 | }); |
| 530 | }, |
| 531 | unresolveLogs() { |
| 532 | this.$store |
| 533 | .dispatch('eventLog/unresolveEventLogs', this.selectedRows) |
| 534 | .then((messages) => { |
| 535 | messages.forEach(({ type, message }) => { |
| 536 | if (type === 'success') { |
| 537 | this.successToast(message); |
| 538 | } else if (type === 'error') { |
| 539 | this.errorToast(message); |
| 540 | } |
| 541 | }); |
| 542 | }); |
| 543 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 544 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 545 | }; |
| 546 | </script> |