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