blob: cca068dcbe9bd076ec9d5c26011ce295feb991d8 [file] [log] [blame]
Derick Montaguea2988f42020-01-17 13:46:30 -06001<template>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -06002 <b-container fluid>
3 <b-row>
4 <b-col lg="8">
5 <h1>Local user management</h1>
6 </b-col>
7 </b-row>
8 <b-row>
9 <b-col lg="8" md="10">
10 <b-button v-b-modal.modal-settings variant="secondary"
11 >Account policy settings</b-button
12 >
13 <b-button v-b-modal.modal-add-user variant="primary">Add user</b-button>
14 </b-col>
15 </b-row>
16 <b-row>
17 <b-col lg="8" md="10">
18 <b-table bordered head-variant="dark" :items="tableItems" show-empty>
19 <template v-slot:head(actions)="data"></template>
20 <template v-slot:cell(actions)="data">
21 <b-button
22 :disabled="!data.value.edit"
23 v-b-modal.modal-user-settings
24 >
25 <Edit20 />
26 </b-button>
27 <b-button
28 :disabled="!data.value.delete"
29 v-b-modal.modal-user-delete
30 >
31 <TrashCan20 />
32 </b-button>
33 </template>
34 </b-table>
35 </b-col>
36 </b-row>
37 <b-row>
38 <b-col lg="6" md="8">
39 <b-button v-b-toggle.collapse-role-table variant="info" class="mt-3"
40 >View privilege role descriptions</b-button
41 >
42 <b-collapse id="collapse-role-table" class="mt-3">
43 <role-table />
44 </b-collapse>
45 </b-col>
46 </b-row>
47 <!-- Modals -->
48 <b-modal id="modal-add-user" title="Add user" ref="modal">
49 <template v-slot:modal-footer="{ ok, cancel, hide }">
50 <b-button
51 size="sm"
52 variant="secondary"
53 @click="$bvModal.hide('modal-add-user')"
54 >Cancel</b-button
55 >
56 <b-button
57 size="sm"
58 variant="primary"
59 @click="$bvModal.hide('modal-add-user')"
60 >Add user</b-button
61 >
62 </template>
63 </b-modal>
64 <b-modal id="modal-settings" title="Account policy settings"></b-modal>
65 <b-modal id="modal-user-delete" title="Delete user"></b-modal>
66 <b-modal id="modal-user-settings" title="User settings"></b-modal>
67 </b-container>
Derick Montaguea2988f42020-01-17 13:46:30 -060068</template>
Yoshie Muranaka35080ac2020-01-17 15:38:57 -060069
70<script>
71import LocalUserManagementRoleTable from "./LocalUserMangementRoleTable";
72import TrashCan20 from "@carbon/icons-vue/es/trash-can/20";
73import Edit20 from "@carbon/icons-vue/es/edit/20";
74
75export default {
76 name: "local-users",
77 components: {
78 TrashCan20,
79 Edit20,
80 roleTable: LocalUserManagementRoleTable
81 },
82 created() {
83 this.getUsers();
84 },
85 computed: {
86 allUsers() {
87 return this.$store.getters["localUsers/allUsers"];
88 },
89 tableItems() {
90 // transform user data to table data
91 return this.allUsers.map(user => {
92 return {
93 username: user.UserName,
94 privilege: user.RoleId,
95 status: user.Locked
96 ? "Locked"
97 : user.Enabled
98 ? "Enabled"
99 : "Disabled",
100 actions: {
101 edit: true,
102 delete: user.UserName === "root" ? false : true
103 }
104 };
105 });
106 }
107 },
108 methods: {
109 getUsers() {
110 this.$store.dispatch("localUsers/getUsers");
111 }
112 }
113};
114</script>
115
116<style lang="scss" scoped>
117h1 {
118 margin-bottom: 2rem;
119}
120</style>