From c3a8bfa96e7cf17112255a479d80a99a0e7c8f16 Mon Sep 17 00:00:00 2001 From: Kevin Birk Date: Tue, 8 Oct 2024 15:42:07 -0400 Subject: [PATCH] Fix model 500s on main page (#5097) Co-authored-by: Yohann Paris --- .../client/hmi-client/src/services/model.ts | 8 ++++--- .../src/services/notificationEventHandlers.ts | 24 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/client/hmi-client/src/services/model.ts b/packages/client/hmi-client/src/services/model.ts index 42f8919e11..5fd3d17301 100644 --- a/packages/client/hmi-client/src/services/model.ts +++ b/packages/client/hmi-client/src/services/model.ts @@ -1,12 +1,12 @@ import API from '@/api/api'; import { useProjects } from '@/composables/project'; +import type { MMT } from '@/model-representation/mira/mira-common'; import * as EventService from '@/services/event'; import type { Initial, InterventionPolicy, Model, ModelConfiguration, ModelParameter } from '@/types/Types'; import { Artifact, EventType } from '@/types/Types'; import { AMRSchemaNames } from '@/types/common'; import { fileToJson } from '@/utils/file'; import { isEmpty } from 'lodash'; -import type { MMT } from '@/model-representation/mira/mira-common'; import { Ref } from 'vue'; export async function createModel(model: Model): Promise { @@ -38,8 +38,10 @@ export async function createModelAndModelConfig(file: File, progress?: Ref { - const response = await API.get(`/models/${modelId}`); +export async function getModel(modelId: string, projectId?: string): Promise { + const response = await API.get(`/models/${modelId}`, { + params: { 'project-id': projectId } + }); return response?.data ?? null; } diff --git a/packages/client/hmi-client/src/services/notificationEventHandlers.ts b/packages/client/hmi-client/src/services/notificationEventHandlers.ts index 6f1ce6ccf6..caee2e6d2e 100644 --- a/packages/client/hmi-client/src/services/notificationEventHandlers.ts +++ b/packages/client/hmi-client/src/services/notificationEventHandlers.ts @@ -1,3 +1,11 @@ +import { useProjects } from '@/composables/project'; +import { + CloneProjectStatusUpdate, + ExtractionStatusUpdate, + NotificationItem, + NotificationItemStatus +} from '@/types/common'; +import { ProjectPages } from '@/types/Project'; import { AssetType, ClientEvent, @@ -10,19 +18,11 @@ import { TaskStatus } from '@/types/Types'; import { logger } from '@/utils/logger'; -import { Ref } from 'vue'; -import { - CloneProjectStatusUpdate, - ExtractionStatusUpdate, - NotificationItem, - NotificationItemStatus -} from '@/types/common'; import { snakeToCapitalSentence } from '@/utils/text'; -import { ProjectPages } from '@/types/Project'; -import { useProjects } from '@/composables/project'; +import { Ref } from 'vue'; import { getDocumentAsset } from './document-assets'; -import { getWorkflow } from './workflow'; import { getModel } from './model'; +import { getWorkflow } from './workflow'; type NotificationEventData = TaskResponse | StatusUpdate; /** @@ -158,7 +158,9 @@ export const createNotificationEventHandlers = (notificationItems: Ref Object.assign(created, { sourceName: model?.name || '' })); + getModel(created.assetId, created.projectId).then((model) => + Object.assign(created, { sourceName: model?.name || '' }) + ); }); registerHandler(ClientEventType.TaskGollmConfigureModelFromDocument, (event, created) => { created.supportCancel = true;