From 243ce3f2bb09e3c3b143670d53419765a8400156 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Sun, 14 Jan 2024 18:44:05 +0100 Subject: [PATCH] update admin details for home community --- .../Federation/FederationVisualizeItem.vue | 77 +++++++++++++++++-- admin/src/components/input/EditableLabel.vue | 64 +++++++++++++++ admin/src/graphql/updateHomeCommunity.js | 7 ++ admin/src/locales/de.json | 7 ++ admin/src/locales/en.json | 7 ++ admin/src/pages/FederationVisualize.vue | 3 +- backend/src/graphql/model/Community.ts | 32 +++++--- 7 files changed, 182 insertions(+), 15 deletions(-) create mode 100644 admin/src/components/input/EditableLabel.vue create mode 100644 admin/src/graphql/updateHomeCommunity.js diff --git a/admin/src/components/Federation/FederationVisualizeItem.vue b/admin/src/components/Federation/FederationVisualizeItem.vue index a947387f4..97a248aaa 100644 --- a/admin/src/components/Federation/FederationVisualizeItem.vue +++ b/admin/src/components/Federation/FederationVisualizeItem.vue @@ -1,24 +1,55 @@ diff --git a/admin/src/components/input/EditableLabel.vue b/admin/src/components/input/EditableLabel.vue new file mode 100644 index 000000000..674fcd3e7 --- /dev/null +++ b/admin/src/components/input/EditableLabel.vue @@ -0,0 +1,64 @@ + + + diff --git a/admin/src/graphql/updateHomeCommunity.js b/admin/src/graphql/updateHomeCommunity.js new file mode 100644 index 000000000..bce09f4d0 --- /dev/null +++ b/admin/src/graphql/updateHomeCommunity.js @@ -0,0 +1,7 @@ +import gql from 'graphql-tag' + +export const updateHomeCommunity = gql` + mutation ($uuid: String!, $gmsApiKey: String!) { + updateHomeCommunity(uuid: $uuid, gmsApiKey: $gmsApiKey) + } +` diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 7cc0affac..b22006a8f 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -69,13 +69,20 @@ "deleted_user": "Alle gelöschten Nutzer", "deny": "Ablehnen", "e_mail": "E-Mail", + "edit": "Bearbeiten", "enabled": "aktiviert", "error": "Fehler", "expired": "abgelaufen", "federation": { + "authenticatedAt": "Verifiziert am:", + "communityUuid": "Community UUID:", "createdAt": "Erstellt am", + "gmsApiKey": "GMS API Key:", + "toast_gmsApiKeyUpdated": "Der GMS Api Key wurde erfolgreich aktualisiert!", "gradidoInstances": "Gradido Instanzen", "lastAnnouncedAt": "letzte Bekanntgabe", + "name": "Name", + "publicKey": "PublicKey:", "url": "Url", "verified": "Verifiziert" }, diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 084e2104f..471bfc50c 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -69,13 +69,20 @@ "deleted_user": "All deleted user", "deny": "Reject", "e_mail": "E-mail", + "edit": "Edit", "enabled": "enabled", "error": "Error", "expired": "expired", "federation": { + "authenticatedAt": "verified at:", + "communityUuid": "Community UUID:", "createdAt": "Created At ", + "gmsApiKey": "GMS API Key:", + "toast_gmsApiKeyUpdated": "The GMS Api Key has been successfully updated!", "gradidoInstances": "Gradido Instances", "lastAnnouncedAt": "Last Announced", + "name": "Name", + "publicKey": "PublicKey:", "url": "Url", "verified": "Verified" }, diff --git a/admin/src/pages/FederationVisualize.vue b/admin/src/pages/FederationVisualize.vue index c6edba5aa..e29e0c02e 100644 --- a/admin/src/pages/FederationVisualize.vue +++ b/admin/src/pages/FederationVisualize.vue @@ -16,12 +16,13 @@ {{ $t('federation.verified') }} {{ $t('federation.url') }} + {{ $t('federation.name') }} {{ $t('federation.lastAnnouncedAt') }} {{ $t('federation.createdAt') }} diff --git a/backend/src/graphql/model/Community.ts b/backend/src/graphql/model/Community.ts index ef7561c3c..1d376b21f 100644 --- a/backend/src/graphql/model/Community.ts +++ b/backend/src/graphql/model/Community.ts @@ -2,29 +2,43 @@ import { Community as DbCommunity } from '@entity/Community' import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity' import { ObjectType, Field, Int } from 'type-graphql' +import { backendLogger as logger } from '@/server/logger' + import { FederatedCommunity } from './FederatedCommunity' @ObjectType() export class Community { constructor(dbCom: DbCommunity) { - this.id = dbCom.id - this.foreign = dbCom.foreign + if (dbCom.federatedCommunities && dbCom.federatedCommunities.length > 0) { + const federatedCommunity = dbCom.federatedCommunities[0] + this.foreign = federatedCommunity.foreign + const url = new URL(federatedCommunity.endPoint) + // use only the host part + this.url = url.protocol + '//' + url.host + this.publicKey = federatedCommunity.publicKey.toString('hex') + this.federatedCommunities = dbCom.federatedCommunities.map( + (federatedCom: DbFederatedCommunity) => new FederatedCommunity(federatedCom), + ) + } + this.id = dbCom.id ?? 0 + if (dbCom.foreign !== undefined) { + this.foreign = dbCom.foreign + } this.name = dbCom.name this.description = dbCom.description this.gmsApiKey = dbCom.gmsApiKey - this.url = dbCom.url - this.publicKey = dbCom.publicKey.toString('hex') + if (dbCom.url) { + this.url = dbCom.url + } + if (dbCom.publicKey && dbCom.publicKey.length === 32) { + this.publicKey = dbCom.publicKey.toString('hex') + } this.communityUuid = dbCom.communityUuid this.creationDate = dbCom.creationDate this.createdAt = dbCom.createdAt this.updatedAt = dbCom.updatedAt this.uuid = dbCom.communityUuid this.authenticatedAt = dbCom.authenticatedAt - if (dbCom.federatedCommunities) { - this.federatedCommunities = dbCom.federatedCommunities.map( - (federatedCom: DbFederatedCommunity) => new FederatedCommunity(federatedCom), - ) - } } @Field(() => Int)