File tree 4 files changed +82
-2
lines changed
4 files changed +82
-2
lines changed 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
+ </tr >
9
+ </thead >
10
+ <tbody >
11
+ <tr v-for =" group in groups" :key =" group.group_id" >
12
+ <td align =" left" >
13
+ <span class =" badge" >{{ group.group_id }}</span >
14
+ </td >
15
+ <td align =" left" >{{ group.display_name }}</td >
16
+ <td align =" left" >{{ group.description }}</td >
17
+ </tr >
18
+ </tbody >
19
+ </table >
20
+ </template >
21
+
22
+ <script >
23
+ import { getGroupsList } from " @/server_fetch_utils.js" ;
24
+
25
+ export default {
26
+ data () {
27
+ return {
28
+ groups: null ,
29
+ original_groups: null ,
30
+ };
31
+ },
32
+ created () {
33
+ this .getGroups ();
34
+ },
35
+ methods: {
36
+ async getGroups () {
37
+ let data = await getGroupsList ();
38
+ if (data != null ) {
39
+ this .groups = JSON .parse (JSON .stringify (data));
40
+ this .original_groups = JSON .parse (JSON .stringify (data));
41
+ }
42
+ },
43
+ },
44
+ };
45
+ </script >
46
+
47
+ <style scoped>
48
+ td {
49
+ vertical-align : middle ;
50
+ }
51
+
52
+ .table-item-id {
53
+ font-size : 1.2em ;
54
+ font-weight : normal ;
55
+ }
56
+ select {
57
+ border : 1px solid #ccc ;
58
+ border-radius : 0.25rem ;
59
+ }
60
+
61
+ .badge {
62
+ margin-left : 1em ;
63
+ font-family : " Andalé Mono" , monospace ;
64
+ }
65
+ </style >
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-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 @@ -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