mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
Merge pull request #3524 from gradido/admin_hiero_topic
feat(admin): add hiero topic id like gms api key
This commit is contained in:
commit
80fe1e480a
@ -28,6 +28,9 @@
|
||||
<BListGroupItem>
|
||||
{{ $t('federation.publicKey') }} {{ item.publicKey }}
|
||||
</BListGroupItem>
|
||||
<BListGroupItem v-if="item.hieroTopicId && item.foreign">
|
||||
{{ $t('federation.hieroTopicId') }} {{ item.hieroTopicId }}
|
||||
</BListGroupItem>
|
||||
<BListGroupItem v-if="!item.foreign">
|
||||
<editable-group
|
||||
:allow-edit="$store.state.moderator.roles.includes('ADMIN')"
|
||||
@ -39,6 +42,10 @@
|
||||
<p style="text-wrap: nowrap">{{ $t('federation.gmsApiKey') }} </p>
|
||||
<span class="d-block" style="overflow-x: auto">{{ gmsApiKey }}</span>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<p style="text-wrap: nowrap">{{ $t('federation.hieroTopicId') }} </p>
|
||||
<span class="d-block" style="overflow-x: auto">{{ hieroTopicId }}</span>
|
||||
</div>
|
||||
<BFormGroup>
|
||||
{{ $t('federation.coordinates') }}
|
||||
<span v-if="isValidLocation">
|
||||
@ -57,6 +64,11 @@
|
||||
:label="$t('federation.gmsApiKey')"
|
||||
id-name="home-community-api-key"
|
||||
/>
|
||||
<editable-groupable-label
|
||||
v-model="hieroTopicId"
|
||||
:label="$t('federation.hieroTopicId')"
|
||||
id-name="home-community-hiero-topic-id"
|
||||
/>
|
||||
<coordinates v-model="location" />
|
||||
</template>
|
||||
</editable-group>
|
||||
@ -111,9 +123,11 @@ const { toastSuccess, toastError } = useAppToast()
|
||||
|
||||
const details = ref(false)
|
||||
const gmsApiKey = ref(item.value.gmsApiKey)
|
||||
const hieroTopicId = ref(item.value.hieroTopicId)
|
||||
const location = ref(item.value.location)
|
||||
const originalGmsApiKey = ref(item.value.gmsApiKey)
|
||||
const originalLocation = ref(item.value.location)
|
||||
const originalHieroTopicId = ref(item.value.hieroTopicId)
|
||||
|
||||
const { mutate: updateHomeCommunityMutation } = useMutation(updateHomeCommunity)
|
||||
|
||||
@ -164,6 +178,7 @@ const createdAt = computed(() => {
|
||||
|
||||
const isLocationChanged = computed(() => originalLocation.value !== location.value)
|
||||
const isGMSApiKeyChanged = computed(() => originalGmsApiKey.value !== gmsApiKey.value)
|
||||
const isHieroTopicIdChanged = computed(() => originalHieroTopicId.value !== hieroTopicId.value)
|
||||
const isValidLocation = computed(
|
||||
() => location.value && location.value.latitude && location.value.longitude,
|
||||
)
|
||||
@ -178,6 +193,7 @@ const handleUpdateHomeCommunity = async () => {
|
||||
uuid: item.value.uuid,
|
||||
gmsApiKey: gmsApiKey.value,
|
||||
location: location.value,
|
||||
hieroTopicId: hieroTopicId.value,
|
||||
})
|
||||
|
||||
if (isLocationChanged.value && isGMSApiKeyChanged.value) {
|
||||
@ -187,8 +203,12 @@ const handleUpdateHomeCommunity = async () => {
|
||||
} else if (isLocationChanged.value) {
|
||||
toastSuccess(t('federation.toast_gmsLocationUpdated'))
|
||||
}
|
||||
if (isHieroTopicIdChanged.value) {
|
||||
toastSuccess(t('federation.toast_hieroTopicIdUpdated'))
|
||||
}
|
||||
originalLocation.value = location.value
|
||||
originalGmsApiKey.value = gmsApiKey.value
|
||||
originalHieroTopicId.value = hieroTopicId.value
|
||||
} catch (error) {
|
||||
toastError(error.message)
|
||||
}
|
||||
@ -197,5 +217,6 @@ const handleUpdateHomeCommunity = async () => {
|
||||
const resetHomeCommunityEditable = () => {
|
||||
location.value = originalLocation.value
|
||||
gmsApiKey.value = originalGmsApiKey.value
|
||||
hieroTopicId.value = originalHieroTopicId.value
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -15,6 +15,7 @@ export const allCommunities = gql`
|
||||
creationDate
|
||||
createdAt
|
||||
updatedAt
|
||||
hieroTopicId
|
||||
federatedCommunities {
|
||||
id
|
||||
apiVersion
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const updateHomeCommunity = gql`
|
||||
mutation ($uuid: String!, $gmsApiKey: String, $location: Location) {
|
||||
updateHomeCommunity(uuid: $uuid, gmsApiKey: $gmsApiKey, location: $location) {
|
||||
mutation ($uuid: String!, $gmsApiKey: String, $location: Location, $hieroTopicId: String) {
|
||||
updateHomeCommunity(
|
||||
uuid: $uuid
|
||||
gmsApiKey: $gmsApiKey
|
||||
location: $location
|
||||
hieroTopicId: $hieroTopicId
|
||||
) {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,9 +96,11 @@
|
||||
"coordinates": "Koordinaten:",
|
||||
"createdAt": "Erstellt am",
|
||||
"gmsApiKey": "GMS API Key:",
|
||||
"hieroTopicId": "Hiero Topic ID:",
|
||||
"toast_gmsApiKeyAndLocationUpdated": "Der GMS Api Key und die Location wurden erfolgreich aktualisiert!",
|
||||
"toast_gmsApiKeyUpdated": "Der GMS Api Key wurde erfolgreich aktualisiert!",
|
||||
"toast_gmsLocationUpdated": "Die GMS Location wurde erfolgreich aktualisiert!",
|
||||
"toast_hieroTopicIdUpdated": "Die Hiero Topic ID wurde erfolgreich aktualisiert!",
|
||||
"gradidoInstances": "Gradido Instanzen",
|
||||
"lastAnnouncedAt": "letzte Bekanntgabe",
|
||||
"lastErrorAt": "Letzer Fehler am",
|
||||
|
||||
@ -96,9 +96,11 @@
|
||||
"coordinates": "Coordinates:",
|
||||
"createdAt": "Created At ",
|
||||
"gmsApiKey": "GMS API Key:",
|
||||
"hieroTopicId": "Hiero Topic ID:",
|
||||
"toast_gmsApiKeyAndLocationUpdated": "The GMS Api Key and the location have been successfully updated!",
|
||||
"toast_gmsApiKeyUpdated": "The GMS Api Key has been successfully updated!",
|
||||
"toast_gmsLocationUpdated": "The GMS location has been successfully updated!",
|
||||
"toast_hieroTopicIdUpdated": "The Hiero Topic ID has been successfully updated!",
|
||||
"gradidoInstances": "Gradido Instances",
|
||||
"lastAnnouncedAt": "Last Announced",
|
||||
"lastErrorAt": "last error at",
|
||||
|
||||
@ -18,4 +18,8 @@ export class EditCommunityInput {
|
||||
@Field(() => Location, { nullable: true })
|
||||
@isValidLocation()
|
||||
location?: Location | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
@IsString()
|
||||
hieroTopicId?: string | null
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ export class AdminCommunityView {
|
||||
this.uuid = dbCom.communityUuid
|
||||
this.authenticatedAt = dbCom.authenticatedAt
|
||||
this.gmsApiKey = dbCom.gmsApiKey
|
||||
this.hieroTopicId = dbCom.hieroTopicId
|
||||
if (dbCom.location) {
|
||||
this.location = Point2Location(dbCom.location as Point)
|
||||
}
|
||||
@ -71,6 +72,9 @@ export class AdminCommunityView {
|
||||
@Field(() => Location, { nullable: true })
|
||||
location: Location | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
hieroTopicId: string | null
|
||||
|
||||
@Field(() => Date, { nullable: true })
|
||||
creationDate: Date | null
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ export class Community {
|
||||
this.uuid = dbCom.communityUuid
|
||||
this.authenticatedAt = dbCom.authenticatedAt
|
||||
this.gmsApiKey = dbCom.gmsApiKey
|
||||
this.hieroTopicId = dbCom.hieroTopicId
|
||||
}
|
||||
|
||||
@Field(() => Int)
|
||||
@ -41,4 +42,7 @@ export class Community {
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
gmsApiKey: string | null
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
hieroTopicId: string | null
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ export class CommunityResolver {
|
||||
@Authorized([RIGHTS.COMMUNITY_UPDATE])
|
||||
@Mutation(() => Community)
|
||||
async updateHomeCommunity(
|
||||
@Args() { uuid, gmsApiKey, location }: EditCommunityInput,
|
||||
@Args() { uuid, gmsApiKey, location, hieroTopicId }: EditCommunityInput,
|
||||
): Promise<Community> {
|
||||
const homeCom = await getCommunityByUuid(uuid)
|
||||
if (!homeCom) {
|
||||
@ -89,11 +89,16 @@ export class CommunityResolver {
|
||||
if (homeCom.foreign) {
|
||||
throw new LogError('Error: Only the HomeCommunity could be modified!')
|
||||
}
|
||||
if (homeCom.gmsApiKey !== gmsApiKey || homeCom.location !== location) {
|
||||
if (
|
||||
homeCom.gmsApiKey !== gmsApiKey ||
|
||||
homeCom.location !== location ||
|
||||
homeCom.hieroTopicId !== hieroTopicId
|
||||
) {
|
||||
homeCom.gmsApiKey = gmsApiKey ?? null
|
||||
if (location) {
|
||||
homeCom.location = Location2Point(location)
|
||||
}
|
||||
homeCom.hieroTopicId = hieroTopicId ?? null
|
||||
await DbCommunity.save(homeCom)
|
||||
}
|
||||
return new Community(homeCom)
|
||||
|
||||
@ -92,7 +92,7 @@ export const GMS_ACTIVE = Joi.boolean()
|
||||
.required()
|
||||
|
||||
export const GDT_ACTIVE = Joi.boolean()
|
||||
.description('Flag to indicate if the GMS (Geographic Member Search) service is used.')
|
||||
.description('Flag to indicate if the GDT (Gradido Transform) service is used.')
|
||||
.default(false)
|
||||
.required()
|
||||
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
/* MIGRATION TO ADD hiero topic id IN COMMUNITY TABLE
|
||||
*
|
||||
* This migration adds fields for the hiero topic id in the community.table
|
||||
*/
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn(
|
||||
'ALTER TABLE `communities` ADD COLUMN `hiero_topic_id` varchar(512) DEFAULT NULL AFTER `location`;',
|
||||
)
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn('ALTER TABLE `communities` DROP COLUMN `hiero_topic_id`;')
|
||||
}
|
||||
@ -73,6 +73,9 @@ export class Community extends BaseEntity {
|
||||
})
|
||||
location: Geometry | null
|
||||
|
||||
@Column({ name: 'hiero_topic_id', type: 'varchar', length: 255, nullable: true })
|
||||
hieroTopicId: string | null
|
||||
|
||||
@CreateDateColumn({
|
||||
name: 'created_at',
|
||||
type: 'datetime',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user