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