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