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