From 422f4729d854658dc6a702082340755b09668894 Mon Sep 17 00:00:00 2001 From: Arild Matsson Date: Mon, 18 Mar 2024 10:35:00 +0100 Subject: [PATCH] Store resource owner, fix #156 --- src/api/api.types.ts | 11 ++++++++++- src/library/AdminResourcesView.vue | 2 +- src/store/resource.store.ts | 12 +++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/api/api.types.ts b/src/api/api.types.ts index d7f2cd6..429ab1e 100644 --- a/src/api/api.types.ts +++ b/src/api/api.types.ts @@ -1,4 +1,4 @@ -import type { ByLang } from "@/util.types"; +import type { ByLang, SweEng } from "@/util.types"; import type { AxiosProgressEvent } from "axios"; /** Properties common to most backend responses */ @@ -61,10 +61,19 @@ export type ResourceInfoOneData = ResourceInfo; /** Data about a resource and its job status */ export type ResourceInfo = { + owner?: UserData; resource: ResourceData; job: CorpusStatus; }; +/** Data about a Mink user */ +export type UserData = { + id: string; + name: string; + email: string; + ui_language: SweEng; +}; + /** Basic data about a resource */ export type ResourceData = { type: ResourceType; diff --git a/src/library/AdminResourcesView.vue b/src/library/AdminResourcesView.vue index 3acead5..9c6f69c 100644 --- a/src/library/AdminResourcesView.vue +++ b/src/library/AdminResourcesView.vue @@ -81,7 +81,7 @@ async function load(resourceId: string) {
- {{ $t(resource.type) }} + {{ resource.owner.name }} { // current date (YYMMDD) if the state shape is changed, to make the browser // forget the old state. The actual number doesn't really matter, as long as // it's a new one. - const resourcesRef = useStorage("mink@230208.resources", {}); + const resourcesRef = useStorage("mink@240318.resources", {}); const resources: Record = reactive(resourcesRef.value); const corpora = computed>>(() => @@ -83,6 +89,9 @@ export const useResourceStore = defineStore("resource", () => { const resource = { type: info.resource.type, name: info.resource.name, + owner: info.owner + ? { name: info.owner.name, id: info.owner.id } + : undefined, }; if (isCorpus(resource)) { @@ -91,6 +100,7 @@ export const useResourceStore = defineStore("resource", () => { } if (isMetadata(resource)) { + resource.owner = info.owner; resource.publicId = info.resource.public_id; }