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