File tree 5 files changed +85
-3
lines changed
5 files changed +85
-3
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" admin-display" >
3
3
<template v-if =" selectedItem === ' Users' " > <UserTable /> </template >
4
+ <template v-else-if =" selectedItem === ' Groups' " > <GroupTable /> </template >
4
5
</div >
5
6
</template >
6
7
7
8
<script >
8
9
import UserTable from " ./UserTable.vue" ;
10
+ import GroupTable from " ./GroupTable.vue" ;
9
11
10
12
export default {
11
13
name: " AdminDisplay" ,
12
- components: { UserTable },
14
+ components: { UserTable, GroupTable },
13
15
props: {
14
16
selectedItem: {
15
17
type: String ,
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <table class =" table table-hover table-sm" data-testid =" user-table" >
3
+ <thead >
4
+ <tr >
5
+ <th scope =" col" >Group ID</th >
6
+ <th scope =" col" >Name</th >
7
+ <th scope =" col" >Description</th >
8
+ <th ></th >
9
+ </tr >
10
+ </thead >
11
+ <tbody >
12
+ <tr v-for =" group in groups" :key =" group.group_id" >
13
+ <td align =" left" >
14
+ <span class =" badge badge-light table-group-id" >{{ group.group_id }}</span >
15
+ </td >
16
+ <td align =" left" >{{ group.display_name }}</td >
17
+ <td align =" left" >{{ group.description }}</td >
18
+ <td align =" right" ><font-awesome-icon :icon =" ['far', 'plus-square']" /></td >
19
+ </tr >
20
+ </tbody >
21
+ </table >
22
+ </template >
23
+
24
+ <script >
25
+ import { getGroupsList } from " @/server_fetch_utils.js" ;
26
+
27
+ export default {
28
+ data () {
29
+ return {
30
+ groups: null ,
31
+ original_groups: null ,
32
+ };
33
+ },
34
+ created () {
35
+ this .getGroups ();
36
+ },
37
+ methods: {
38
+ async getGroups () {
39
+ let data = await getGroupsList ();
40
+ if (data != null ) {
41
+ this .groups = JSON .parse (JSON .stringify (data));
42
+ this .original_groups = JSON .parse (JSON .stringify (data));
43
+ }
44
+ },
45
+ },
46
+ };
47
+ </script >
48
+
49
+ <style scoped>
50
+ td {
51
+ vertical-align : middle ;
52
+ }
53
+
54
+ .table-group-id {
55
+ border : 2px solid #ccc ;
56
+ }
57
+
58
+ select {
59
+ border : 1px solid #ccc ;
60
+ border-radius : 0.25rem ;
61
+ }
62
+
63
+ .badge {
64
+ margin-left : 1em ;
65
+ font-family : " Andalé Mono" , monospace ;
66
+ }
67
+ </style >
Original file line number Diff line number Diff line change 9
9
</tr >
10
10
</thead >
11
11
<tbody >
12
- <tr v-for =" user in users" :key =" user._id " >
12
+ <tr v-for =" user in users" :key =" user.immutable_id " >
13
13
<td align =" left" >
14
14
{{ user.display_name }}
15
15
<span v-if =" user.account_status === 'active'" class =" badge badge-success text-uppercase" >
Original file line number Diff line number Diff line change @@ -269,6 +269,19 @@ export function getUsersList() {
269
269
} ) ;
270
270
}
271
271
272
+ export function getGroupsList ( ) {
273
+ return fetch_get ( `${ API_URL } /groups` )
274
+ . then ( function ( response_json ) {
275
+ const groups = response_json . data ;
276
+ return groups ;
277
+ } )
278
+ . catch ( ( error ) => {
279
+ console . error ( "Error when fetching groups list" ) ;
280
+ console . error ( error ) ;
281
+ throw error ;
282
+ } ) ;
283
+ }
284
+
272
285
export function getStartingMaterialList ( ) {
273
286
return fetch_get ( `${ API_URL } /starting-materials/` )
274
287
. then ( function ( response_json ) {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export default {
23
23
},
24
24
data () {
25
25
return {
26
- items: [" Users" ],
26
+ items: [" Users" , " Groups " ],
27
27
selectedItem: " Users" ,
28
28
user: null ,
29
29
};
You can’t perform that action at this time.
0 commit comments