Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 1 | <template> |
| 2 | <b-container fluid="xl"> |
| 3 | <page-title /> |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 4 | <b-row class="mb-3"> |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 5 | <b-col sm="7" xl="4" class="d-flex flex-column justify-content-end"> |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 6 | <search |
| 7 | :placeholder="$t('pageEventLogs.table.searchLogs')" |
| 8 | @changeSearch="onChangeSearchInput" |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 9 | @clearSearch="onClearSearchInput" |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 10 | /> |
| 11 | </b-col> |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 12 | <b-col sm="3" class="d-flex flex-column justify-content-end"> |
| 13 | <table-cell-count |
| 14 | :filtered-items-count="filteredRows" |
| 15 | :total-number-of-cells="allLogs.length" |
| 16 | ></table-cell-count> |
| 17 | </b-col> |
| 18 | <b-col sm="8" md="7" xl="5"> |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 19 | <table-date-filter @change="onChangeDateTimeFilter" /> |
| 20 | </b-col> |
| 21 | </b-row> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 22 | <b-row> |
| 23 | <b-col class="text-right"> |
| 24 | <table-filter :filters="tableFilters" @filterChange="onFilterChange" /> |
| 25 | </b-col> |
| 26 | </b-row> |
| 27 | <b-row> |
| 28 | <b-col> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 29 | <table-toolbar |
| 30 | ref="toolbar" |
| 31 | :selected-items-count="selectedRows.length" |
| 32 | :actions="batchActions" |
| 33 | @clearSelected="clearSelectedRows($refs.table)" |
| 34 | @batchAction="onBatchAction" |
| 35 | > |
| 36 | <template v-slot:export> |
| 37 | <table-toolbar-export |
| 38 | :data="batchExportData" |
SurenNeware | 96ebb0d | 2020-09-08 17:42:39 +0530 | [diff] [blame] | 39 | :file-name="exportFileNameByDate()" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 40 | /> |
| 41 | </template> |
| 42 | </table-toolbar> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 43 | <b-table |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 44 | id="table-event-logs" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 45 | ref="table" |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 46 | responsive="md" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 47 | selectable |
| 48 | no-select-on-click |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 49 | sort-icon-left |
| 50 | no-sort-reset |
| 51 | sort-desc |
| 52 | show-empty |
Derick Montague | 6b140ba | 2020-09-03 16:26:33 -0500 | [diff] [blame] | 53 | sort-by="id" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 54 | :fields="fields" |
| 55 | :items="filteredLogs" |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 56 | :sort-compare="onSortCompare" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 57 | :empty-text="$t('global.table.emptyMessage')" |
SurenNeware | 156a0e6 | 2020-08-28 19:20:03 +0530 | [diff] [blame] | 58 | :empty-filtered-text="$t('global.table.emptySearchMessage')" |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 59 | :per-page="perPage" |
| 60 | :current-page="currentPage" |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 61 | :filter="searchFilter" |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 62 | @filtered="onFiltered" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 63 | @row-selected="onRowSelected($event, filteredLogs.length)" |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 64 | > |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 65 | <!-- Checkbox column --> |
| 66 | <template v-slot:head(checkbox)> |
| 67 | <b-form-checkbox |
| 68 | v-model="tableHeaderCheckboxModel" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 69 | data-test-id="eventLogs-checkbox-selectAll" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 70 | :indeterminate="tableHeaderCheckboxIndeterminate" |
| 71 | @change="onChangeHeaderCheckbox($refs.table)" |
| 72 | /> |
| 73 | </template> |
| 74 | <template v-slot:cell(checkbox)="row"> |
| 75 | <b-form-checkbox |
| 76 | v-model="row.rowSelected" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 77 | :data-test-id="`eventLogs-checkbox-selectRow-${row.index}`" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 78 | @change="toggleSelectRow($refs.table, row.index)" |
| 79 | /> |
| 80 | </template> |
| 81 | |
| 82 | <!-- Severity column --> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 83 | <template v-slot:cell(severity)="{ value }"> |
Mateusz Gapski | b1f1253 | 2020-07-24 08:15:23 +0200 | [diff] [blame] | 84 | <status-icon v-if="value" :status="statusIcon(value)" /> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 85 | {{ value }} |
| 86 | </template> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 87 | |
| 88 | <!-- Date column --> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 89 | <template v-slot:cell(date)="{ value }"> |
Dixsie Wolmers | 949cdd5 | 2020-08-24 21:36:37 -0500 | [diff] [blame] | 90 | <p class="mb-0">{{ value | formatDate }}</p> |
| 91 | <p class="mb-0">{{ value | formatTime }}</p> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 92 | </template> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 93 | |
| 94 | <!-- Actions column --> |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 95 | <template v-slot:cell(actions)="row"> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 96 | <table-row-action |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 97 | v-for="(action, index) in row.item.actions" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 98 | :key="index" |
| 99 | :value="action.value" |
| 100 | :title="action.title" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 101 | :row-data="row.item" |
SurenNeware | 96ebb0d | 2020-09-08 17:42:39 +0530 | [diff] [blame] | 102 | :export-name="exportFileNameByDate()" |
Yoshie Muranaka | ed06dc1 | 2020-06-16 12:12:27 -0700 | [diff] [blame] | 103 | :data-test-id="`eventLogs-button-deleteRow-${row.index}`" |
| 104 | @click:tableAction="onTableRowAction($event, row.item)" |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 105 | > |
| 106 | <template v-slot:icon> |
| 107 | <icon-export v-if="action.value === 'export'" /> |
| 108 | <icon-trashcan v-if="action.value === 'delete'" /> |
| 109 | </template> |
| 110 | </table-row-action> |
| 111 | </template> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 112 | </b-table> |
| 113 | </b-col> |
| 114 | </b-row> |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 115 | |
| 116 | <!-- Table pagination --> |
| 117 | <b-row> |
| 118 | <b-col class="d-md-flex justify-content-between"> |
| 119 | <b-form-group |
| 120 | class="table-pagination-select" |
| 121 | :label="$t('global.table.itemsPerPage')" |
| 122 | label-for="pagination-items-per-page" |
| 123 | > |
| 124 | <b-form-select |
| 125 | id="pagination-items-per-page" |
| 126 | v-model="perPage" |
| 127 | :options="itemsPerPageOptions" |
| 128 | /> |
| 129 | </b-form-group> |
| 130 | <b-pagination |
| 131 | v-model="currentPage" |
| 132 | first-number |
| 133 | last-number |
| 134 | :per-page="perPage" |
| 135 | :total-rows="getTotalRowCount(filteredLogs.length)" |
| 136 | aria-controls="table-event-logs" |
| 137 | /> |
| 138 | </b-col> |
| 139 | </b-row> |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 140 | </b-container> |
| 141 | </template> |
| 142 | |
| 143 | <script> |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 144 | import IconTrashcan from '@carbon/icons-vue/es/trash-can/20'; |
Sukanya Pandey | b2ca0c0 | 2020-07-20 23:23:29 +0530 | [diff] [blame] | 145 | import IconExport from '@carbon/icons-vue/es/document--export/20'; |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 146 | import { omit } from 'lodash'; |
| 147 | |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 148 | import PageTitle from '@/components/Global/PageTitle'; |
| 149 | import StatusIcon from '@/components/Global/StatusIcon'; |
Derick Montague | d853fba | 2020-07-16 11:24:10 -0500 | [diff] [blame] | 150 | import Search from '@/components/Global/Search'; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 151 | import TableCellCount from '@/components/Global/TableCellCount'; |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 152 | import TableDateFilter from '@/components/Global/TableDateFilter'; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 153 | import TableFilter from '@/components/Global/TableFilter'; |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 154 | import TableRowAction from '@/components/Global/TableRowAction'; |
| 155 | import TableToolbar from '@/components/Global/TableToolbar'; |
| 156 | import TableToolbarExport from '@/components/Global/TableToolbarExport'; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 157 | |
| 158 | import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; |
| 159 | import TableFilterMixin from '@/components/Mixins/TableFilterMixin'; |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 160 | import BVPaginationMixin from '@/components/Mixins/BVPaginationMixin'; |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 161 | import BVTableSelectableMixin from '@/components/Mixins/BVTableSelectableMixin'; |
| 162 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | 73e419a | 2020-06-18 13:08:19 -0700 | [diff] [blame] | 163 | import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin'; |
| 164 | import TableSortMixin from '@/components/Mixins/TableSortMixin'; |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 165 | import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin'; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 166 | |
| 167 | export default { |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 168 | components: { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 169 | IconExport, |
| 170 | IconTrashcan, |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 171 | PageTitle, |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 172 | Search, |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 173 | StatusIcon, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 174 | TableCellCount, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 175 | TableFilter, |
| 176 | TableRowAction, |
| 177 | TableToolbar, |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 178 | TableToolbarExport, |
| 179 | TableDateFilter |
Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 180 | }, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 181 | mixins: [ |
| 182 | BVPaginationMixin, |
| 183 | BVTableSelectableMixin, |
| 184 | BVToastMixin, |
| 185 | LoadingBarMixin, |
Yoshie Muranaka | 73e419a | 2020-06-18 13:08:19 -0700 | [diff] [blame] | 186 | TableFilterMixin, |
| 187 | TableDataFormatterMixin, |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 188 | TableSortMixin, |
| 189 | SearchFilterMixin |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 190 | ], |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 191 | data() { |
| 192 | return { |
| 193 | fields: [ |
| 194 | { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 195 | key: 'checkbox', |
| 196 | sortable: false |
| 197 | }, |
| 198 | { |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 199 | key: 'id', |
| 200 | label: this.$t('pageEventLogs.table.id'), |
| 201 | sortable: true |
| 202 | }, |
| 203 | { |
| 204 | key: 'severity', |
| 205 | label: this.$t('pageEventLogs.table.severity'), |
| 206 | sortable: true |
| 207 | }, |
| 208 | { |
| 209 | key: 'type', |
| 210 | label: this.$t('pageEventLogs.table.type'), |
| 211 | sortable: true |
| 212 | }, |
| 213 | { |
| 214 | key: 'date', |
| 215 | label: this.$t('pageEventLogs.table.date'), |
| 216 | sortable: true |
| 217 | }, |
| 218 | { |
| 219 | key: 'description', |
| 220 | label: this.$t('pageEventLogs.table.description') |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 221 | }, |
| 222 | { |
| 223 | key: 'actions', |
| 224 | sortable: false, |
| 225 | label: '', |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 226 | tdClass: 'text-right text-nowrap' |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 227 | } |
| 228 | ], |
| 229 | tableFilters: [ |
| 230 | { |
Yoshie Muranaka | 0045400 | 2020-06-22 09:14:05 -0700 | [diff] [blame] | 231 | key: 'severity', |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 232 | label: this.$t('pageEventLogs.table.severity'), |
Yoshie Muranaka | 73e419a | 2020-06-18 13:08:19 -0700 | [diff] [blame] | 233 | values: ['OK', 'Warning', 'Critical'] |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 234 | } |
| 235 | ], |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 236 | activeFilters: [], |
| 237 | batchActions: [ |
| 238 | { |
| 239 | value: 'delete', |
| 240 | label: this.$t('global.action.delete') |
| 241 | } |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 242 | ], |
| 243 | filterStartDate: null, |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 244 | filterEndDate: null, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 245 | searchTotalFilteredRows: 0 |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 246 | }; |
| 247 | }, |
| 248 | computed: { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 249 | filteredRows() { |
| 250 | return this.searchFilter |
| 251 | ? this.searchTotalFilteredRows |
| 252 | : this.filteredLogs.length; |
| 253 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 254 | allLogs() { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 255 | return this.$store.getters['eventLog/allEvents'].map(event => { |
| 256 | return { |
| 257 | ...event, |
| 258 | actions: [ |
| 259 | { |
| 260 | value: 'export', |
| 261 | title: this.$t('global.action.export') |
| 262 | }, |
| 263 | { |
| 264 | value: 'delete', |
| 265 | title: this.$t('global.action.delete') |
| 266 | } |
| 267 | ] |
| 268 | }; |
| 269 | }); |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 270 | }, |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 271 | batchExportData() { |
| 272 | return this.selectedRows.map(row => omit(row, 'actions')); |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 273 | }, |
| 274 | filteredLogsByDate() { |
| 275 | return this.getFilteredTableDataByDate( |
| 276 | this.allLogs, |
| 277 | this.filterStartDate, |
| 278 | this.filterEndDate |
| 279 | ); |
| 280 | }, |
| 281 | filteredLogs() { |
| 282 | return this.getFilteredTableData( |
| 283 | this.filteredLogsByDate, |
| 284 | this.activeFilters |
| 285 | ); |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 286 | } |
| 287 | }, |
| 288 | created() { |
| 289 | this.startLoader(); |
| 290 | this.$store |
| 291 | .dispatch('eventLog/getEventLogData') |
| 292 | .finally(() => this.endLoader()); |
| 293 | }, |
Yoshie Muranaka | e3a8d69 | 2020-05-28 13:30:40 -0700 | [diff] [blame] | 294 | beforeRouteLeave(to, from, next) { |
| 295 | // Hide loader if the user navigates to another page |
| 296 | // before request is fulfilled. |
| 297 | this.hideLoader(); |
| 298 | next(); |
| 299 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 300 | methods: { |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 301 | deleteLogs(uris) { |
| 302 | this.$store.dispatch('eventLog/deleteEventLogs', uris).then(messages => { |
| 303 | messages.forEach(({ type, message }) => { |
| 304 | if (type === 'success') { |
| 305 | this.successToast(message); |
| 306 | } else if (type === 'error') { |
| 307 | this.errorToast(message); |
| 308 | } |
| 309 | }); |
| 310 | }); |
| 311 | }, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 312 | onFilterChange({ activeFilters }) { |
| 313 | this.activeFilters = activeFilters; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 314 | }, |
| 315 | onSortCompare(a, b, key) { |
| 316 | if (key === 'severity') { |
Yoshie Muranaka | 73e419a | 2020-06-18 13:08:19 -0700 | [diff] [blame] | 317 | return this.sortStatus(a, b, key); |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 318 | } |
Yoshie Muranaka | be3af33 | 2020-05-11 08:23:04 -0700 | [diff] [blame] | 319 | }, |
| 320 | onTableRowAction(action, { uri }) { |
| 321 | if (action === 'delete') { |
| 322 | this.$bvModal |
| 323 | .msgBoxConfirm(this.$tc('pageEventLogs.modal.deleteMessage'), { |
| 324 | title: this.$tc('pageEventLogs.modal.deleteTitle'), |
| 325 | okTitle: this.$t('global.action.delete') |
| 326 | }) |
| 327 | .then(deleteConfirmed => { |
| 328 | if (deleteConfirmed) this.deleteLogs([uri]); |
| 329 | }); |
| 330 | } |
| 331 | }, |
| 332 | onBatchAction(action) { |
| 333 | if (action === 'delete') { |
| 334 | const uris = this.selectedRows.map(row => row.uri); |
| 335 | this.$bvModal |
| 336 | .msgBoxConfirm( |
| 337 | this.$tc( |
| 338 | 'pageEventLogs.modal.deleteMessage', |
| 339 | this.selectedRows.length |
| 340 | ), |
| 341 | { |
| 342 | title: this.$tc( |
| 343 | 'pageEventLogs.modal.deleteTitle', |
| 344 | this.selectedRows.length |
| 345 | ), |
| 346 | okTitle: this.$t('global.action.delete') |
| 347 | } |
| 348 | ) |
| 349 | .then(deleteConfirmed => { |
| 350 | if (deleteConfirmed) this.deleteLogs(uris); |
| 351 | }); |
| 352 | } |
Yoshie Muranaka | 68bbba2 | 2020-05-18 09:49:37 -0700 | [diff] [blame] | 353 | }, |
| 354 | onChangeDateTimeFilter({ fromDate, toDate }) { |
| 355 | this.filterStartDate = fromDate; |
| 356 | this.filterEndDate = toDate; |
Yoshie Muranaka | 193c22a | 2020-06-30 20:54:10 -0700 | [diff] [blame] | 357 | }, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 358 | onFiltered(filteredItems) { |
| 359 | this.searchTotalFilteredRows = filteredItems.length; |
| 360 | }, |
SurenNeware | 96ebb0d | 2020-09-08 17:42:39 +0530 | [diff] [blame] | 361 | // Create export file name based on date |
| 362 | exportFileNameByDate() { |
| 363 | let date = new Date(); |
| 364 | date = |
| 365 | date.toISOString().slice(0, 10) + |
| 366 | '_' + |
| 367 | date |
| 368 | .toString() |
| 369 | .split(':') |
| 370 | .join('-') |
| 371 | .split(' ')[4]; |
| 372 | return this.$t('pageEventLogs.exportFilePrefix') + date; |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 373 | } |
| 374 | } |
| 375 | }; |
| 376 | </script> |