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