Description and metadata
{data.data.description && (
-
+
{data.data.description}
@@ -34,7 +34,7 @@ export const ModelMetadataView = () => {
blandit, justo ex pellentesque nisl, eu placerat magna nisi et odio.
Donec laoreet est quam, id fringilla magna semper in. **
-
+
)}
diff --git a/src/features/ModelView/ModelSourceView/ModelSourceView.tsx b/src/features/ModelView/ModelSourceView/ModelSourceView.tsx
index 26bc2a2c..7c0c54d3 100644
--- a/src/features/ModelView/ModelSourceView/ModelSourceView.tsx
+++ b/src/features/ModelView/ModelSourceView/ModelSourceView.tsx
@@ -1,7 +1,7 @@
import { Table, Typography } from '@equinor/eds-core-react';
+import { useQuery } from '@tanstack/react-query';
import { useParams } from 'react-router-dom';
import { AnalogueModelsService, UploadList } from '../../../api/generated';
-import { useQuery } from '@tanstack/react-query';
export const ModelSourceView = () => {
const { id } = useParams();
diff --git a/src/pages/Browse/Browse.tsx b/src/pages/Browse/Browse.tsx
index fe8dc84e..9001e09f 100644
--- a/src/pages/Browse/Browse.tsx
+++ b/src/pages/Browse/Browse.tsx
@@ -1,13 +1,16 @@
+/* eslint-disable max-lines-per-function */
import { Button, Snackbar, Typography } from '@equinor/eds-core-react';
-import { useState } from 'react';
-import { Table } from '../../components/Table';
-import * as Styled from './Browse.styled';
import { useMutation } from '@tanstack/react-query';
+import { useState } from 'react';
import {
AnalogueModelsService,
+ ConvertAnalogueModelCommand,
CreateAnalogueModelCommand,
+ JobsService,
} from '../../api/generated';
+import { Table } from '../../components/Table';
import { AddModelDialog } from '../../features/AddModel/AddModelDialog/AddModelDialog';
+import * as Styled from './Browse.styled';
enum UploadProcess {
STARTED = 'We are uploading your new model. Please keep this browser tab open.',
@@ -20,6 +23,12 @@ type MutationContract = {
file: Blob;
};
+const ModelBody: CreateAnalogueModelCommand = {
+ name: 'Model test',
+ description: 'New test of the model',
+ sourceType: 'ResQML',
+};
+
export const Browse = () => {
const createModel = useMutation({
mutationFn: AnalogueModelsService.postApiAnalogueModels,
@@ -34,6 +43,12 @@ export const Browse = () => {
},
});
+ const convertModelFile = useMutation({
+ mutationFn: (modelId: ConvertAnalogueModelCommand) => {
+ return JobsService.postApiJobsComputeModelConversions(modelId);
+ },
+ });
+
const [isAddModelDialog, setAddModelDialog] = useState(false);
const [uploadStatus, setUploadStatus] = useState();
@@ -47,26 +62,30 @@ export const Browse = () => {
async function uploadModel(file: File) {
setUploadStatus(UploadProcess.STARTED);
- const modelUpload = await createModel.mutateAsync(
- // TODO
- {
- name: 'testModel',
- description: 'description',
- sourceType: 'Deltares',
- } as CreateAnalogueModelCommand,
- );
-
- if (createModel?.isSuccess) {
+
+ const modelUpload = await createModel.mutateAsync(ModelBody);
+
+ if (createModel.error === null && modelUpload.success) {
toggleDialog();
- const fileUpload = await uploadNCFile.mutateAsync({
+ const FileUploadBody: MutationContract = {
id: modelUpload.data.analogueModelId ?? '',
file: file,
- } as MutationContract);
+ };
+ const fileUpload = await uploadNCFile.mutateAsync(FileUploadBody);
- if (fileUpload && uploadNCFile.isSuccess)
+ if (uploadNCFile.error === null && fileUpload.success) {
setUploadStatus(UploadProcess.SUCCESS);
- else if (!uploadNCFile.isSuccess) {
+
+ const id = modelUpload.data.analogueModelId;
+ const convert = await convertModelFile.mutateAsync({
+ modelId: id,
+ });
+
+ // eslint-disable-next-line no-console
+ console.log(convert);
+ } else if (uploadNCFile.error) {
setUploadStatus(UploadProcess.FAILED);
+
// TODO: show validation message
}
}
@@ -78,7 +97,7 @@ export const Browse = () => {
Browse all models