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