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