add statistics overview for admin area

This commit is contained in:
ogerly 2022-08-08 12:45:10 +02:00
parent 683f3b001e
commit f15d085450
5 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,63 @@
<template>
<div class="community-statistic">
<div>
<b-jumbotron bg-variant="info" text-variant="white" border-variant="dark">
<template #header>{{ $t('statistic.name') }}</template>
<template #lead>
{{ CONFIG.COMMUNITY_NAME }}
</template>
<hr class="my-4" />
<div>
{{ $t('statistic.totalUsers') }}{{ $t('math.colon') }}
<b>{{ value.totalUsers }}</b>
</div>
<div>
{{ $t('statistic.activeUsers') }}{{ $t('math.colon') }}
<b>{{ value.activeUsers }}</b>
</div>
<div>
{{ $t('statistic.deletedUsers') }}{{ $t('math.colon') }}
<b>{{ value.deletedUsers }}</b>
</div>
<div>
{{ $t('statistic.totalGradidoCreated') }}{{ $t('math.colon') }}
<b>{{ Math.round(value.totalGradidoCreated) }} {{ $t('GDD') }}</b>
<small class="ml-5">{{ value.totalGradidoCreated }}</small>
</div>
<div>
{{ $t('statistic.totalGradidoDecayed') }}{{ $t('math.colon') }}
<b>{{ Math.round(value.totalGradidoDecayed) }} {{ $t('GDD') }}</b>
<small class="ml-5">{{ value.totalGradidoDecayed }}</small>
</div>
<div>
{{ $t('statistic.totalGradidoAvailable') }}{{ $t('math.colon') }}
<b>{{ Math.round(value.totalGradidoAvailable) }} {{ $t('GDD') }}</b>
<small class="ml-5">{{ value.totalGradidoAvailable }}</small>
</div>
<div>
{{ $t('statistic.totalGradidoUnbookedDecayed') }}{{ $t('math.colon') }}
<b>{{ Math.round(value.totalGradidoUnbookedDecayed) }} {{ $t('GDD') }}</b>
<small class="ml-5">{{ value.totalGradidoUnbookedDecayed }}</small>
</div>
</b-jumbotron>
</div>
</div>
</template>
<script>
import CONFIG from '@/config'
export default {
name: 'CommunityStatistic',
props: {
value: { type: Object },
},
data() {
return {
CONFIG,
}
},
}
</script>

View File

@ -32,6 +32,10 @@ const endpoints = {
WALLET_URL: process.env.WALLET_URL || 'http://localhost/login',
}
const community = {
COMMUNITY_NAME: process.env.COMMUNITY_NAME || 'Gradido Entwicklung',
}
const debug = {
DEBUG_DISABLE_AUTH: process.env.DEBUG_DISABLE_AUTH === 'true' || false,
}
@ -53,6 +57,7 @@ const CONFIG = {
...version,
...environment,
...endpoints,
...community,
...debug,
}

View File

@ -73,6 +73,7 @@
"hide_details": "Details verbergen",
"lastname": "Nachname",
"math": {
"colon": ":",
"exclaim": "!",
"pipe": "|",
"plus": "+"
@ -105,6 +106,16 @@
"removeNotSelf": "Als Admin/Moderator kannst du dich nicht selber löschen.",
"remove_all": "alle Nutzer entfernen",
"save": "Speichern",
"statistic": {
"activeUsers": "aktive Mitglieder",
"deletedUsers": "gelöschte Mitglieder",
"name": "Statistik",
"totalGradidoAvailable": "GDD insgesamt im Umflauf",
"totalGradidoCreated": "GDD insgesamt geschöpft",
"totalGradidoDecayed": "GDD insgesamt verfallen",
"totalGradidoUnbookedDecayed": "GDD nicht gebuchter verfall",
"totalUsers": "Mitglieder"
},
"status": "Status",
"success": "Erfolg",
"text": "Text",

View File

@ -73,6 +73,7 @@
"hide_details": "Hide details",
"lastname": "Lastname",
"math": {
"colon": ":",
"exclaim": "!",
"pipe": "|",
"plus": "+"
@ -105,6 +106,16 @@
"removeNotSelf": "As an admin/moderator, you cannot delete yourself.",
"remove_all": "Remove all users",
"save": "Speichern",
"statistic": {
"activeUsers": "active members",
"deletedUsers": "deleted members",
"name": "Statistic",
"totalGradidoAvailable": "Total GDD in circulation",
"totalGradidoCreated": "GDD total created",
"totalGradidoDecayed": "Total GDD decayed",
"totalGradidoUnbookedDecayed": "GDD not booked decayed",
"totalUsers": "Members"
},
"status": "Status",
"success": "Success",
"text": "Text",

View File

@ -29,22 +29,36 @@
</b-card-text>
</b-card>
<contribution-link :items="items" :count="count" />
<community-statistic class="mt-5" v-model="statistics" />
</div>
</template>
<script>
import { listContributionLinks } from '@/graphql/listContributionLinks.js'
import { communityStatistics } from '@/graphql/communityStatistics.js'
import ContributionLink from '../components/ContributionLink.vue'
import CommunityStatistic from '../components/CommunityStatistic.vue'
import { listUnconfirmedContributions } from '../graphql/listUnconfirmedContributions'
export default {
name: 'overview',
components: {
ContributionLink,
CommunityStatistic,
},
data() {
return {
items: [],
count: 0,
statistics: {
membersCount: null,
totalUsers: null,
activeUsers: null,
deletedUsers: null,
totalGradidoCreated: null,
totalGradidoDecayed: null,
totalGradidoAvailable: null,
totalGradidoUnbookedDecayed: null,
},
}
},
methods: {
@ -72,9 +86,31 @@ export default {
this.toastError('listContributionLinks has no result, use default data')
})
},
async getCommunityStatistics() {
this.$apollo
.query({
query: communityStatistics,
fetchPolicy: 'network-only',
})
.then((result) => {
this.statistics.totalUsers = result.data.communityStatistics.totalUsers
this.statistics.activeUsers = result.data.communityStatistics.activeUsers
this.statistics.deletedUsers = result.data.communityStatistics.deletedUsers
this.statistics.totalGradidoCreated = result.data.communityStatistics.totalGradidoCreated
this.statistics.totalGradidoDecayed = result.data.communityStatistics.totalGradidoDecayed
this.statistics.totalGradidoAvailable =
result.data.communityStatistics.totalGradidoAvailable
this.statistics.totalGradidoUnbookedDecayed =
result.data.communityStatistics.totalGradidoUnbookedDecayed
})
.catch(() => {
this.toastError('listContributionLinks has no result, use default data')
})
},
},
created() {
this.getPendingCreations()
this.getCommunityStatistics()
this.getContributionLinks()
},
}