Skip to content

Commit 44e7058

Browse files
committed
Add group display to admin panel
1 parent 4123e7b commit 44e7058

File tree

4 files changed

+82
-2
lines changed

4 files changed

+82
-2
lines changed

webapp/GroupTable.vue

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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>

webapp/src/components/AdminDisplay.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<template>
22
<div class="admin-display">
33
<template v-if="selectedItem === 'Users'"> <UserTable /> </template>
4+
<template v-if="selectedItem === 'Groups'"> <GroupTable /> </template>
45
</div>
56
</template>
67

78
<script>
89
import UserTable from "./UserTable.vue";
10+
import GroupTable from "./GroupTable.vue";
911
1012
export default {
1113
name: "AdminDisplay",
12-
components: { UserTable },
14+
components: [UserTable, GroupTable],
1315
props: {
1416
selectedItem: {
1517
type: String,

webapp/src/server_fetch_utils.js

+13
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,19 @@ export function getUsersList() {
269269
});
270270
}
271271

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+
272285
export function getStartingMaterialList() {
273286
return fetch_get(`${API_URL}/starting-materials/`)
274287
.then(function (response_json) {

webapp/src/views/Admin.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
},
2424
data() {
2525
return {
26-
items: ["Users"],
26+
items: ["Users", "Groups"],
2727
selectedItem: "Users",
2828
user: null,
2929
};

0 commit comments

Comments
 (0)