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