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