Sort and decorate groups

This commit is contained in:
Douglas Barone 2022-10-25 12:39:39 -04:00
parent 40b0e148e8
commit 4394c7e112
2 changed files with 55 additions and 5 deletions

View File

@ -7,10 +7,15 @@ const User = {
displayName: parent => displayName: parent =>
parent.displayName ? parent.displayName.capitalize() : '', parent.displayName ? parent.displayName.capitalize() : '',
groups: async (parent, args, { ad }) => groups: async (parent, args, { ad }) => {
parent.groups const groups = parent.groups
? parent.groups ? parent.groups
: ad.getGroupMembershipForUser(parent.sAMAccountName), : ad.getGroupMembershipForUser(parent.sAMAccountName)
const sortedGroups = groups.sort((a, b) => a.cn.localeCompare(b.cn))
return sortedGroups
},
lastLogin: parent => parent.lastLogin?.toISOString(), lastLogin: parent => parent.lastLogin?.toISOString(),

View File

@ -1,17 +1,62 @@
<template> <template>
<v-chip class="ma-1" small outlined> <v-chip class="ma-1" small outlined :color="groupColor">
<v-icon left x-small>mdi-account-group</v-icon> <v-icon left x-small>{{ groupIcon }}</v-icon>
{{ group }} {{ group }}
</v-chip> </v-chip>
</template> </template>
<script> <script>
const especialGroups = [
{
name: 'G_SERVIDORES',
color: 'green',
icon: 'mdi-account-tie'
},
{
name: 'Estudantes',
color: 'blue',
icon: 'mdi-book-account'
},
{
name: 'SETIS',
color: 'red',
icon: 'mdi-guy-fawkes-mask'
},
{
name: 'SERTI',
color: 'orange',
icon: 'mdi-guy-fawkes-mask'
},
{
name: 'Estagiarios',
color: 'brown',
icon: 'mdi-account-tie'
},
{
name: 'IFMS-ADMINISTRATIVO',
color: 'green',
icon: 'mdi-wifi'
}
]
export default { export default {
props: { props: {
group: { group: {
type: String, type: String,
required: true required: true
} }
},
computed: {
groupColor() {
const group = especialGroups.find(({ name }) =>
this.group.toLowerCase().includes(name.toLowerCase())
)
return group ? group.color : undefined
},
groupIcon() {
const group = especialGroups.find(({ name }) => this.group.includes(name))
return group ? group.icon : 'mdi-account-group'
}
} }
} }
</script> </script>