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