Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 1 | <template> |
Yoshie Muranaka | 3111b6f | 2020-04-21 19:48:38 -0700 | [diff] [blame] | 2 | <b-container fluid="xl"> |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 3 | <page-title /> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 4 | <b-row> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 5 | <b-col xl="9" class="text-right"> |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 6 | <b-button variant="link" @click="initModalSettings"> |
Yoshie Muranaka | 996d2d5 | 2019-12-30 09:06:45 -0800 | [diff] [blame] | 7 | <icon-settings /> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 8 | {{ $t('pageUserManagement.accountPolicySettings') }} |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 9 | </b-button> |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 10 | <b-button |
| 11 | variant="primary" |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 12 | data-test-id="userManagement-button-addUser" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 13 | @click="initModalUser(null)" |
| 14 | > |
Yoshie Muranaka | 996d2d5 | 2019-12-30 09:06:45 -0800 | [diff] [blame] | 15 | <icon-add /> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 16 | {{ $t('pageUserManagement.addUser') }} |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 17 | </b-button> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 18 | </b-col> |
| 19 | </b-row> |
| 20 | <b-row> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 21 | <b-col xl="9"> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 22 | <table-toolbar |
| 23 | ref="toolbar" |
| 24 | :selected-items-count="selectedRows.length" |
| 25 | :actions="tableToolbarActions" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 26 | @clear-selected="clearSelectedRows($refs.table)" |
| 27 | @batch-action="onBatchAction" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 28 | /> |
| 29 | <b-table |
| 30 | ref="table" |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 31 | responsive="md" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 32 | selectable |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 33 | show-empty |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 34 | no-select-on-click |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 35 | hover |
Kenneth Fullbright | 4105785 | 2021-12-27 16:19:37 -0600 | [diff] [blame] | 36 | :busy="isBusy" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 37 | :fields="fields" |
| 38 | :items="tableItems" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 39 | :empty-text="$t('global.table.emptyMessage')" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 40 | @row-selected="onRowSelected($event, tableItems.length)" |
| 41 | > |
| 42 | <!-- Checkbox column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 43 | <template #head(checkbox)> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 44 | <b-form-checkbox |
| 45 | v-model="tableHeaderCheckboxModel" |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 46 | data-test-id="userManagement-checkbox-tableHeaderCheckbox" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 47 | :indeterminate="tableHeaderCheckboxIndeterminate" |
| 48 | @change="onChangeHeaderCheckbox($refs.table)" |
Dixsie Wolmers | c42ad71 | 2020-11-19 17:29:24 -0600 | [diff] [blame] | 49 | > |
| 50 | <span class="sr-only">{{ $t('global.table.selectAll') }}</span> |
| 51 | </b-form-checkbox> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 52 | </template> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 53 | <template #cell(checkbox)="row"> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 54 | <b-form-checkbox |
| 55 | v-model="row.rowSelected" |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 56 | data-test-id="userManagement-checkbox-toggleSelectRow" |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 57 | @change="toggleSelectRow($refs.table, row.index)" |
Dixsie Wolmers | c42ad71 | 2020-11-19 17:29:24 -0600 | [diff] [blame] | 58 | > |
| 59 | <span class="sr-only">{{ $t('global.table.selectItem') }}</span> |
| 60 | </b-form-checkbox> |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 61 | </template> |
| 62 | |
| 63 | <!-- table actions column --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 64 | <template #cell(actions)="{ item }"> |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 65 | <table-row-action |
| 66 | v-for="(action, index) in item.actions" |
| 67 | :key="index" |
| 68 | :value="action.value" |
| 69 | :enabled="action.enabled" |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 70 | :title="action.title" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 71 | @click-table-action="onTableRowAction($event, item)" |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 72 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 73 | <template #icon> |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 74 | <icon-edit |
| 75 | v-if="action.value === 'edit'" |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 76 | :data-test-id="`userManagement-tableRowAction-edit-${index}`" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 77 | /> |
| 78 | <icon-trashcan |
| 79 | v-if="action.value === 'delete'" |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 80 | :data-test-id="`userManagement-tableRowAction-delete-${index}`" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 81 | /> |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 82 | </template> |
| 83 | </table-row-action> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 84 | </template> |
| 85 | </b-table> |
| 86 | </b-col> |
| 87 | </b-row> |
| 88 | <b-row> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 89 | <b-col xl="8"> |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 90 | <b-button |
| 91 | v-b-toggle.collapse-role-table |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 92 | data-test-id="userManagement-button-viewPrivilegeRoleDescriptions" |
Dixsie Wolmers | fe1e658 | 2020-07-15 11:18:12 -0500 | [diff] [blame] | 93 | variant="link" |
| 94 | class="mt-3" |
| 95 | > |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 96 | <icon-chevron /> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 97 | {{ $t('pageUserManagement.viewPrivilegeRoleDescriptions') }} |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 98 | </b-button> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 99 | <b-collapse id="collapse-role-table" class="mt-3"> |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 100 | <table-roles /> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 101 | </b-collapse> |
| 102 | </b-col> |
| 103 | </b-row> |
| 104 | <!-- Modals --> |
kirankumarb07 | 6ad19aa | 2023-03-21 19:19:02 +0530 | [diff] [blame] | 105 | <modal-settings :settings="setting" @ok="saveAccountSettings" /> |
Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 106 | <modal-user |
| 107 | :user="activeUser" |
| 108 | :password-requirements="passwordRequirements" |
| 109 | @ok="saveUser" |
Yoshie Muranaka | 791622b | 2020-04-17 13:55:16 -0700 | [diff] [blame] | 110 | @hidden="activeUser = null" |
Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 111 | /> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 112 | </b-container> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 113 | </template> |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 114 | |
| 115 | <script> |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 116 | import IconTrashcan from '@carbon/icons-vue/es/trash-can/20'; |
| 117 | import IconEdit from '@carbon/icons-vue/es/edit/20'; |
| 118 | import IconAdd from '@carbon/icons-vue/es/add--alt/20'; |
| 119 | import IconSettings from '@carbon/icons-vue/es/settings/20'; |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 120 | import IconChevron from '@carbon/icons-vue/es/chevron--up/20'; |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 121 | |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 122 | import ModalUser from './ModalUser'; |
| 123 | import ModalSettings from './ModalSettings'; |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 124 | import PageTitle from '@/components/Global/PageTitle'; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 125 | import TableRoles from './TableRoles'; |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 126 | import TableToolbar from '@/components/Global/TableToolbar'; |
| 127 | import TableRowAction from '@/components/Global/TableRowAction'; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 128 | |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 129 | import BVTableSelectableMixin, { |
| 130 | selectedRows, |
| 131 | tableHeaderCheckboxModel, |
| 132 | tableHeaderCheckboxIndeterminate, |
| 133 | } from '@/components/Mixins/BVTableSelectableMixin'; |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 134 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 135 | import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 136 | |
| 137 | export default { |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 138 | name: 'UserManagement', |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 139 | components: { |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 140 | IconAdd, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 141 | IconChevron, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 142 | IconEdit, |
| 143 | IconSettings, |
| 144 | IconTrashcan, |
| 145 | ModalSettings, |
| 146 | ModalUser, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 147 | PageTitle, |
Yoshie Muranaka | 8d12910 | 2019-12-19 09:51:55 -0800 | [diff] [blame] | 148 | TableRoles, |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 149 | TableRowAction, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 150 | TableToolbar, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 151 | }, |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 152 | mixins: [BVTableSelectableMixin, BVToastMixin, LoadingBarMixin], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 153 | beforeRouteLeave(to, from, next) { |
| 154 | this.hideLoader(); |
| 155 | next(); |
| 156 | }, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 157 | data() { |
| 158 | return { |
Kenneth Fullbright | 4105785 | 2021-12-27 16:19:37 -0600 | [diff] [blame] | 159 | isBusy: true, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 160 | activeUser: null, |
kirankumarb07 | 6ad19aa | 2023-03-21 19:19:02 +0530 | [diff] [blame] | 161 | setting: {}, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 162 | fields: [ |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 163 | { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 164 | key: 'checkbox', |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 165 | }, |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 166 | { |
| 167 | key: 'username', |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 168 | label: this.$t('pageUserManagement.table.username'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 169 | }, |
| 170 | { |
| 171 | key: 'privilege', |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 172 | label: this.$t('pageUserManagement.table.privilege'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 173 | }, |
| 174 | { |
| 175 | key: 'status', |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 176 | label: this.$t('pageUserManagement.table.status'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 177 | }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 178 | { |
| 179 | key: 'actions', |
| 180 | label: '', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 181 | tdClass: 'text-right text-nowrap', |
| 182 | }, |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 183 | ], |
| 184 | tableToolbarActions: [ |
| 185 | { |
| 186 | value: 'delete', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 187 | label: this.$t('global.action.delete'), |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 188 | }, |
| 189 | { |
| 190 | value: 'enable', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 191 | label: this.$t('global.action.enable'), |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 192 | }, |
| 193 | { |
| 194 | value: 'disable', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 195 | label: this.$t('global.action.disable'), |
| 196 | }, |
| 197 | ], |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 198 | selectedRows: selectedRows, |
| 199 | tableHeaderCheckboxModel: tableHeaderCheckboxModel, |
| 200 | tableHeaderCheckboxIndeterminate: tableHeaderCheckboxIndeterminate, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 201 | }; |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 202 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 203 | computed: { |
| 204 | allUsers() { |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 205 | return this.$store.getters['userManagement/allUsers']; |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 206 | }, |
| 207 | tableItems() { |
| 208 | // transform user data to table data |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 209 | return this.allUsers.map((user) => { |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 210 | return { |
| 211 | username: user.UserName, |
| 212 | privilege: user.RoleId, |
| 213 | status: user.Locked |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 214 | ? 'Locked' |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 215 | : user.Enabled |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame^] | 216 | ? 'Enabled' |
| 217 | : 'Disabled', |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 218 | actions: [ |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 219 | { |
| 220 | value: 'edit', |
Sivaprabu Ganesan | 2897447 | 2023-01-05 18:52:51 +0530 | [diff] [blame] | 221 | enabled: this.editEnable(user), |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 222 | title: this.$t('pageUserManagement.editUser'), |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 223 | }, |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 224 | { |
| 225 | value: 'delete', |
Sivaprabu Ganesan | 2897447 | 2023-01-05 18:52:51 +0530 | [diff] [blame] | 226 | enabled: |
| 227 | user.UserName === this.$store.getters['global/username'] |
| 228 | ? false |
| 229 | : true && user.UserName === 'root' |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame^] | 230 | ? false |
| 231 | : true, |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 232 | title: this.$tc('pageUserManagement.deleteUser'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 233 | }, |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 234 | ], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 235 | ...user, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 236 | }; |
| 237 | }); |
Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 238 | }, |
| 239 | settings() { |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 240 | return this.$store.getters['userManagement/accountSettings']; |
Yoshie Muranaka | 52b0223 | 2020-02-20 08:00:45 -0800 | [diff] [blame] | 241 | }, |
| 242 | passwordRequirements() { |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 243 | return this.$store.getters['userManagement/accountPasswordRequirements']; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 244 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 245 | }, |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 246 | created() { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 247 | this.startLoader(); |
Kenneth Fullbright | 4105785 | 2021-12-27 16:19:37 -0600 | [diff] [blame] | 248 | this.$store.dispatch('userManagement/getUsers').finally(() => { |
| 249 | this.endLoader(); |
| 250 | this.isBusy = false; |
| 251 | }); |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 252 | this.$store.dispatch('userManagement/getAccountSettings'); |
| 253 | this.$store.dispatch('userManagement/getAccountRoles'); |
Derick Montague | 09e45cd | 2020-01-23 15:45:57 -0600 | [diff] [blame] | 254 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 255 | methods: { |
Sivaprabu Ganesan | 2897447 | 2023-01-05 18:52:51 +0530 | [diff] [blame] | 256 | editEnable(user) { |
| 257 | if ('root' === this.$store.getters['global/username']) { |
| 258 | return true; |
| 259 | } else { |
| 260 | return user.UserName === 'root' ? false : true; |
| 261 | } |
| 262 | }, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 263 | initModalUser(user) { |
| 264 | this.activeUser = user; |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 265 | this.$bvModal.show('modal-user'); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 266 | }, |
| 267 | initModalDelete(user) { |
| 268 | this.$bvModal |
| 269 | .msgBoxConfirm( |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 270 | this.$t('pageUserManagement.modal.deleteConfirmMessage', { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 271 | user: user.username, |
Yoshie Muranaka | eaa0480 | 2020-02-28 13:21:27 -0800 | [diff] [blame] | 272 | }), |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 273 | { |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 274 | title: this.$tc('pageUserManagement.deleteUser'), |
| 275 | okTitle: this.$tc('pageUserManagement.deleteUser'), |
Sukanya Pandey | 3835713 | 2020-12-22 13:40:59 +0530 | [diff] [blame] | 276 | cancelTitle: this.$t('global.action.cancel'), |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame^] | 277 | }, |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 278 | ) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 279 | .then((deleteConfirmed) => { |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 280 | if (deleteConfirmed) { |
| 281 | this.deleteUser(user); |
| 282 | } |
| 283 | }); |
| 284 | }, |
| 285 | initModalSettings() { |
kirankumarb07 | 6ad19aa | 2023-03-21 19:19:02 +0530 | [diff] [blame] | 286 | this.setting = this.settings; |
Yoshie Muranaka | 1b1c100 | 2020-02-20 10:18:36 -0800 | [diff] [blame] | 287 | this.$bvModal.show('modal-settings'); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 288 | }, |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 289 | saveUser({ isNewUser, userData }) { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 290 | this.startLoader(); |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 291 | if (isNewUser) { |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 292 | this.$store |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 293 | .dispatch('userManagement/createUser', userData) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 294 | .then((success) => this.successToast(success)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 295 | .catch(({ message }) => this.errorToast(message)) |
| 296 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 297 | } else { |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 298 | this.$store |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 299 | .dispatch('userManagement/updateUser', userData) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 300 | .then((success) => this.successToast(success)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 301 | .catch(({ message }) => this.errorToast(message)) |
| 302 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 463a570 | 2019-12-04 09:09:36 -0800 | [diff] [blame] | 303 | } |
| 304 | }, |
| 305 | deleteUser({ username }) { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 306 | this.startLoader(); |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 307 | this.$store |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 308 | .dispatch('userManagement/deleteUser', username) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 309 | .then((success) => this.successToast(success)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 310 | .catch(({ message }) => this.errorToast(message)) |
| 311 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 312 | }, |
| 313 | onBatchAction(action) { |
| 314 | switch (action) { |
| 315 | case 'delete': |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 316 | this.$bvModal |
| 317 | .msgBoxConfirm( |
| 318 | this.$tc( |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 319 | 'pageUserManagement.modal.batchDeleteConfirmMessage', |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame^] | 320 | this.selectedRows.length, |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 321 | ), |
| 322 | { |
| 323 | title: this.$tc( |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 324 | 'pageUserManagement.deleteUser', |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame^] | 325 | this.selectedRows.length, |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 326 | ), |
| 327 | okTitle: this.$tc( |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 328 | 'pageUserManagement.deleteUser', |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame^] | 329 | this.selectedRows.length, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 330 | ), |
Sukanya Pandey | 3835713 | 2020-12-22 13:40:59 +0530 | [diff] [blame] | 331 | cancelTitle: this.$t('global.action.cancel'), |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame^] | 332 | }, |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 333 | ) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 334 | .then((deleteConfirmed) => { |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 335 | if (deleteConfirmed) { |
Yoshie Muranaka | 8e4b5c3 | 2020-05-27 14:10:52 -0700 | [diff] [blame] | 336 | this.startLoader(); |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 337 | this.$store |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 338 | .dispatch('userManagement/deleteUsers', this.selectedRows) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 339 | .then((messages) => { |
Yoshie Muranaka | 2932165 | 2020-05-04 10:52:36 -0700 | [diff] [blame] | 340 | messages.forEach(({ type, message }) => { |
| 341 | if (type === 'success') this.successToast(message); |
| 342 | if (type === 'error') this.errorToast(message); |
| 343 | }); |
| 344 | }) |
| 345 | .finally(() => this.endLoader()); |
| 346 | } |
| 347 | }); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 348 | break; |
| 349 | case 'enable': |
Yoshie Muranaka | 8e4b5c3 | 2020-05-27 14:10:52 -0700 | [diff] [blame] | 350 | this.startLoader(); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 351 | this.$store |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 352 | .dispatch('userManagement/enableUsers', this.selectedRows) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 353 | .then((messages) => { |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 354 | messages.forEach(({ type, message }) => { |
| 355 | if (type === 'success') this.successToast(message); |
| 356 | if (type === 'error') this.errorToast(message); |
| 357 | }); |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 358 | }) |
| 359 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 360 | break; |
| 361 | case 'disable': |
Yoshie Muranaka | 8e4b5c3 | 2020-05-27 14:10:52 -0700 | [diff] [blame] | 362 | this.startLoader(); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 363 | this.$store |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 364 | .dispatch('userManagement/disableUsers', this.selectedRows) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 365 | .then((messages) => { |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 366 | messages.forEach(({ type, message }) => { |
| 367 | if (type === 'success') this.successToast(message); |
| 368 | if (type === 'error') this.errorToast(message); |
| 369 | }); |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 370 | }) |
| 371 | .finally(() => this.endLoader()); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 372 | break; |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 373 | } |
Yoshie Muranaka | 0e893f0 | 2020-02-18 13:39:45 -0800 | [diff] [blame] | 374 | }, |
| 375 | onTableRowAction(action, row) { |
| 376 | switch (action) { |
| 377 | case 'edit': |
| 378 | this.initModalUser(row); |
| 379 | break; |
| 380 | case 'delete': |
| 381 | this.initModalDelete(row); |
| 382 | break; |
| 383 | default: |
| 384 | break; |
| 385 | } |
Yoshie Muranaka | 1b1c100 | 2020-02-20 10:18:36 -0800 | [diff] [blame] | 386 | }, |
| 387 | saveAccountSettings(settings) { |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 388 | this.startLoader(); |
Yoshie Muranaka | 1b1c100 | 2020-02-20 10:18:36 -0800 | [diff] [blame] | 389 | this.$store |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 390 | .dispatch('userManagement/saveAccountSettings', settings) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 391 | .then((message) => this.successToast(message)) |
Yoshie Muranaka | 346be2a | 2020-04-28 11:12:14 -0700 | [diff] [blame] | 392 | .catch(({ message }) => this.errorToast(message)) |
| 393 | .finally(() => this.endLoader()); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 394 | }, |
| 395 | }, |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 396 | }; |
| 397 | </script> |
| 398 | |
| 399 | <style lang="scss" scoped> |
Yoshie Muranaka | 4b0fc1d | 2020-01-06 07:36:16 -0800 | [diff] [blame] | 400 | .btn.collapsed { |
| 401 | svg { |
| 402 | transform: rotate(180deg); |
| 403 | } |
| 404 | } |
Yoshie Muranaka | 35080ac | 2020-01-17 15:38:57 -0600 | [diff] [blame] | 405 | </style> |