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