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