diff --git a/src/features/AddModelDialog/AddModelDialog.tsx b/src/features/AddModelDialog/AddModelDialog.tsx index b9c35172..6d9db7f9 100644 --- a/src/features/AddModelDialog/AddModelDialog.tsx +++ b/src/features/AddModelDialog/AddModelDialog.tsx @@ -1,3 +1,4 @@ +/* eslint-disable max-lines-per-function */ import { Button } from '@equinor/eds-core-react' import { useState } from 'react' import { ModelInputFilesTable } from '../ModelInputFilesTable/ModelInputFilesTable' @@ -10,12 +11,33 @@ interface AddModelDialogProps { cancel: () => void } +export default interface MetadataProps { + description?: string + field: string[] + zone?: string[] + formation: string[] + analogue?: string[] +} + export const AddModelDialog = ({ isOpen, confirm, cancel, }: AddModelDialogProps) => { const [isFileDisplay, setFileDisplay] = useState(false) + const [validationError, setValidationError] = useState<{ + field: boolean + formation: boolean + }>({ field: false, formation: false }) + const [metadata, setMetadata] = useState>() + + // const [description, setDescription] = useState() + // const [field, setField] = useState() + // const [zone, setZone] = useState() + // const [formation, setFormation] = useState() + // const [analogue, setAnalogue] = useState() + // const [fieldError, setFieldError] = useState(false) + // const [formationError, setFormationError] = useState(false) function toggleINIFileContent() { setFileDisplay(!isFileDisplay) @@ -23,6 +45,40 @@ export const AddModelDialog = ({ const INIFileContent = () =>

Not implemented yet...

+ const validateInput = (values: string[] | undefined, target: string) => { + // const value = e.selectedItems + // console.log('Kjører: Value => ' + values + ' target => ' + target) + + values === undefined || !typeof Object + ? setValidationError({ ...validationError, [target]: true }) + : setValidationError({ ...validationError, [target]: false }) + // onChange(metadata) + } + + const submit = () => { + /** + * + console.log('Metadata' + metadata) + + console.log('Field: ' + metadata?.field) + console.log('Formation: ' + metadata?.formation) + + console.log('Type Formation: ' + typeof metadata?.formation) + console.log('Type Field: ' + typeof metadata?.field) + */ + + validateInput(metadata?.field, 'field') + + validateInput(metadata?.formation, 'formation') + /** + * +console.log('Field error: ' + validationError.field) +console.log('Formation error: ' + validationError.formation) +*/ + + // confirm() + } + return ( @@ -36,10 +92,15 @@ export const AddModelDialog = ({ }} /> {isFileDisplay && } - + - + diff --git a/src/features/ModelInputFilesTable/ModelInputFilesTable.tsx b/src/features/ModelInputFilesTable/ModelInputFilesTable.tsx index 7cd1e9e1..cae56e0d 100644 --- a/src/features/ModelInputFilesTable/ModelInputFilesTable.tsx +++ b/src/features/ModelInputFilesTable/ModelInputFilesTable.tsx @@ -1,3 +1,4 @@ +/* eslint-disable no-magic-numbers */ import { Button, Table } from '@equinor/eds-core-react' import { delete_to_trash as deleteIcon } from '@equinor/eds-icons' import { ChangeEvent, useState } from 'react' diff --git a/src/features/ModelMetadata/ModelMetadata.styled.ts b/src/features/ModelMetadata/ModelMetadata.styled.ts index e72240bf..ad4750a5 100644 --- a/src/features/ModelMetadata/ModelMetadata.styled.ts +++ b/src/features/ModelMetadata/ModelMetadata.styled.ts @@ -10,6 +10,33 @@ export const ModelMetadata = styled.div` > .model-description { grid-column: 1 / span 2; + } + + > .model-required { + border-style: solid; + border-width: 2px; + border-color: red; + } + + + > .required-div { + > label { + color: red !important; + } + + > .model-required2 { + > div { + border-style: solid !important; + border-width: 2px !important; + border-color: red !important; + } + } + + } + + + + } } ` diff --git a/src/features/ModelMetadata/ModelMetadata.tsx b/src/features/ModelMetadata/ModelMetadata.tsx index d9a827ed..3fe02b4c 100644 --- a/src/features/ModelMetadata/ModelMetadata.tsx +++ b/src/features/ModelMetadata/ModelMetadata.tsx @@ -1,8 +1,38 @@ -import { Autocomplete, TextField, Typography } from '@equinor/eds-core-react' +/* eslint-disable max-lines-per-function */ +import { + Autocomplete, + AutocompleteChanges, + Label, + TextField, + Typography, +} from '@equinor/eds-core-react' +import MetadataProps from '../AddModelDialog/AddModelDialog' import * as Styled from './ModelMetadata.styled' -export const ModelMetadata = () => { - const fields = [{ name: 'Tor' }] +export const ModelMetadata = ({ + onValidate, + validationError, + metadata, + setMetadata, +}: { + onValidate: (values: string[], target: string) => void + validationError: { field: boolean; formation: boolean } + metadata: Partial | undefined + setMetadata: (metadata: Partial) => void +}) => { + const fields = { + description: 'Description string', + field: ['Tor', 'Pål'], + zone: ['Zone 1', 'Zone 2', 'Zone 3'], + formation: ['Rocky', 'Hilly', 'Flat'], + analogue: ['Analouge1', 'Analouge2'], + } + + const handleInput = (e: AutocompleteChanges, target: string) => { + onValidate(e.selectedItems, target) + setMetadata({ ...metadata, [target]: e.selectedItems }) + } + return ( Description and metadata @@ -10,12 +40,65 @@ export const ModelMetadata = () => { id="model-description" className="model-description" label="Model description (optional)" + value={metadata?.description} + onChange={(e: React.ChangeEvent) => + setMetadata({ ...metadata, description: e.currentTarget.value }) + } multiline /> - - - - +
+ ) => + handleInput(e, 'field') + } + > + {validationError.field && ( + + )} +
+ +
+ ) => + handleInput(e, 'formation') + } + > + {validationError.formation && ( + + )} +
+ + ) => + setMetadata({ ...metadata, analogue: e.selectedItems }) + } + > + ) => + setMetadata({ ...metadata, zone: e.selectedItems }) + } + >
) } diff --git a/src/models/schema.d.ts b/src/models/schema.d.ts index 6e45106f..43d34eec 100644 --- a/src/models/schema.d.ts +++ b/src/models/schema.d.ts @@ -18,6 +18,9 @@ export interface paths { "application/json": components["schemas"]["AddAnalogueModelParameterCommandForm"]; "text/json": components["schemas"]["AddAnalogueModelParameterCommandForm"]; "application/*+json": components["schemas"]["AddAnalogueModelParameterCommandForm"]; + "application/xml": components["schemas"]["AddAnalogueModelParameterCommandForm"]; + "text/xml": components["schemas"]["AddAnalogueModelParameterCommandForm"]; + "application/*+xml": components["schemas"]["AddAnalogueModelParameterCommandForm"]; }; }; responses: { @@ -25,6 +28,7 @@ export interface paths { 200: { content: { "application/json": components["schemas"]["AddAnalogueModelParameterCommandResponse"]; + "application/xml": components["schemas"]["AddAnalogueModelParameterCommandResponse"]; }; }; }; @@ -38,6 +42,7 @@ export interface paths { 200: { content: { "application/json": components["schemas"]["GetAnalogueModelListQueryResponse"]; + "application/xml": components["schemas"]["GetAnalogueModelListQueryResponse"]; }; }; }; @@ -50,6 +55,9 @@ export interface paths { "application/json": components["schemas"]["CreateAnalogueModelCommand"]; "text/json": components["schemas"]["CreateAnalogueModelCommand"]; "application/*+json": components["schemas"]["CreateAnalogueModelCommand"]; + "application/xml": components["schemas"]["CreateAnalogueModelCommand"]; + "text/xml": components["schemas"]["CreateAnalogueModelCommand"]; + "application/*+xml": components["schemas"]["CreateAnalogueModelCommand"]; }; }; responses: { @@ -57,12 +65,14 @@ export interface paths { 200: { content: { "application/json": components["schemas"]["CreateAnalogueModelCommandResponse"]; + "application/xml": components["schemas"]["CreateAnalogueModelCommandResponse"]; }; }; /** @description Bad Request */ 400: { content: { "application/json": components["schemas"]["ErrorResponse"]; + "application/xml": components["schemas"]["ErrorResponse"]; }; }; }; @@ -81,6 +91,7 @@ export interface paths { 200: { content: { "application/json": components["schemas"]["GetAnalogueModelQueryResponse"]; + "application/xml": components["schemas"]["GetAnalogueModelQueryResponse"]; }; }; }; @@ -98,6 +109,9 @@ export interface paths { "application/json": components["schemas"]["UpdateAnalogueModelCommandBody"]; "text/json": components["schemas"]["UpdateAnalogueModelCommandBody"]; "application/*+json": components["schemas"]["UpdateAnalogueModelCommandBody"]; + "application/xml": components["schemas"]["UpdateAnalogueModelCommandBody"]; + "text/xml": components["schemas"]["UpdateAnalogueModelCommandBody"]; + "application/*+xml": components["schemas"]["UpdateAnalogueModelCommandBody"]; }; }; responses: { @@ -105,18 +119,21 @@ export interface paths { 200: { content: { "application/json": components["schemas"]["UpdateAnalogueModelCommandResponse"]; + "application/xml": components["schemas"]["UpdateAnalogueModelCommandResponse"]; }; }; /** @description Bad Request */ 400: { content: { "application/json": components["schemas"]["ErrorResponse"]; + "application/xml": components["schemas"]["ErrorResponse"]; }; }; /** @description Not Found */ 404: { content: { "application/json": components["schemas"]["ErrorResponse"]; + "application/xml": components["schemas"]["ErrorResponse"]; }; }; }; @@ -130,17 +147,21 @@ export interface paths { }; responses: { /** @description No Content */ - 204: never; + 204: { + content: never; + }; /** @description Bad Request */ 400: { content: { "application/json": components["schemas"]["ErrorResponse"]; + "application/xml": components["schemas"]["ErrorResponse"]; }; }; /** @description Not Found */ 404: { content: { "application/json": components["schemas"]["ErrorResponse"]; + "application/xml": components["schemas"]["ErrorResponse"]; }; }; }; @@ -165,18 +186,49 @@ export interface paths { 200: { content: { "application/json": components["schemas"]["PatchAnalogueModelCommandResponse"]; + "application/xml": components["schemas"]["PatchAnalogueModelCommandResponse"]; }; }; /** @description Bad Request */ 400: { content: { "application/json": components["schemas"]["ErrorResponse"]; + "application/xml": components["schemas"]["ErrorResponse"]; }; }; /** @description Not Found */ 404: { content: { "application/json": components["schemas"]["ErrorResponse"]; + "application/xml": components["schemas"]["ErrorResponse"]; + }; + }; + }; + }; + }; + "/api/analoguemodels/{id}/input-models": { + /** Upload model files that later can be converted to PEPM models. */ + post: { + parameters: { + path: { + id: string; + }; + }; + requestBody?: { + content: { + "multipart/form-data": { + /** Format: binary */ + File?: string; + FileType?: components["schemas"]["UploadFileType"]; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": components["schemas"]["UploadAnalogueModelCommandResponse"]; + "application/xml": components["schemas"]["UploadAnalogueModelCommandResponse"]; }; }; }; @@ -200,6 +252,9 @@ export interface paths { "application/json": components["schemas"]["CreateAnalogueCommand"]; "text/json": components["schemas"]["CreateAnalogueCommand"]; "application/*+json": components["schemas"]["CreateAnalogueCommand"]; + "application/xml": components["schemas"]["CreateAnalogueCommand"]; + "text/xml": components["schemas"]["CreateAnalogueCommand"]; + "application/*+xml": components["schemas"]["CreateAnalogueCommand"]; }; }; responses: { @@ -279,6 +334,9 @@ export interface paths { "application/json": components["schemas"]["UpdateJobStatusCommand"]; "text/json": components["schemas"]["UpdateJobStatusCommand"]; "application/*+json": components["schemas"]["UpdateJobStatusCommand"]; + "application/xml": components["schemas"]["UpdateJobStatusCommand"]; + "text/xml": components["schemas"]["UpdateJobStatusCommand"]; + "application/*+xml": components["schemas"]["UpdateJobStatusCommand"]; }; }; responses: { @@ -291,7 +349,7 @@ export interface paths { }; }; }; - "/api/jobs/modelconversions": { + "/api/jobs/compute/model-conversions": { /** Convert AnalogueModels to the internal format used by PEPM in order to perform calculations. */ post: { requestBody?: { @@ -300,11 +358,38 @@ export interface paths { "application/json": components["schemas"]["ConvertAnalogueModelCommand"]; "text/json": components["schemas"]["ConvertAnalogueModelCommand"]; "application/*+json": components["schemas"]["ConvertAnalogueModelCommand"]; + "application/xml": components["schemas"]["ConvertAnalogueModelCommand"]; + "text/xml": components["schemas"]["ConvertAnalogueModelCommand"]; + "application/*+xml": components["schemas"]["ConvertAnalogueModelCommand"]; }; }; responses: { /** @description Accepted */ - 202: never; + 202: { + content: never; + }; + }; + }; + }; + "/api/jobs/compute/channel-estimations": { + /** Estimate channel on a Deltares based model. */ + post: { + requestBody?: { + content: { + "application/json-patch+json": components["schemas"]["EstimateChannelCommand"]; + "application/json": components["schemas"]["EstimateChannelCommand"]; + "text/json": components["schemas"]["EstimateChannelCommand"]; + "application/*+json": components["schemas"]["EstimateChannelCommand"]; + "application/xml": components["schemas"]["EstimateChannelCommand"]; + "text/xml": components["schemas"]["EstimateChannelCommand"]; + "application/*+xml": components["schemas"]["EstimateChannelCommand"]; + }; + }; + responses: { + /** @description Accepted */ + 202: { + content: never; + }; }; }; }; @@ -328,6 +413,9 @@ export interface paths { "application/json": components["schemas"]["CreateParameterCommand"]; "text/json": components["schemas"]["CreateParameterCommand"]; "application/*+json": components["schemas"]["CreateParameterCommand"]; + "application/xml": components["schemas"]["CreateParameterCommand"]; + "text/xml": components["schemas"]["CreateParameterCommand"]; + "application/*+xml": components["schemas"]["CreateParameterCommand"]; }; }; responses: { @@ -382,6 +470,9 @@ export interface paths { "application/json": components["schemas"]["UpdateParameterCommandBody"]; "text/json": components["schemas"]["UpdateParameterCommandBody"]; "application/*+json": components["schemas"]["UpdateParameterCommandBody"]; + "application/xml": components["schemas"]["UpdateParameterCommandBody"]; + "text/xml": components["schemas"]["UpdateParameterCommandBody"]; + "application/*+xml": components["schemas"]["UpdateParameterCommandBody"]; }; }; responses: { @@ -414,7 +505,9 @@ export interface paths { }; responses: { /** @description No Content */ - 204: never; + 204: { + content: never; + }; /** @description Bad Request */ 400: { content: { @@ -496,7 +589,7 @@ export interface paths { }; }; "/api/uploads/models": { - /** Upload model files that is converted to PEPM models. */ + /** Upload model files that later can be converted to PEPM models. */ post: { requestBody?: { content: { @@ -644,6 +737,10 @@ export interface components { validationErrors?: string[] | null; data: string; }; + EstimateChannelCommand: { + /** Format: uuid */ + modelId?: string; + }; GetAnalogueListQueryResponse: { success?: boolean; /** Format: int32 */ @@ -868,8 +965,10 @@ export interface components { UploadAnalogueModelDto: { /** Format: uuid */ uploadId?: string; + originalFileName?: string | null; uploadStatus?: components["schemas"]["UploadStatus"]; - processed?: boolean; + uploadFileType?: components["schemas"]["UploadFileType"]; + uploadFileCategory?: components["schemas"]["UploadFileCategory"]; }; UploadDetail: { /** Format: uuid */ @@ -878,7 +977,6 @@ export interface components { uploadStatus?: components["schemas"]["UploadStatus"]; uploadFileType?: components["schemas"]["UploadFileType"]; uploadFileCategory?: components["schemas"]["UploadFileCategory"]; - processed?: boolean; }; /** @enum {string} */ UploadFileCategory: "InputModel" | "InputMetadata" | "ResQmlModel"; @@ -893,7 +991,6 @@ export interface components { uploadStatus?: components["schemas"]["UploadStatus"]; uploadFileType?: components["schemas"]["UploadFileType"]; uploadFileCategory?: components["schemas"]["UploadFileCategory"]; - processed?: boolean; }; /** @enum {string} */ UploadStatus: "Started" | "ReadyForProcessing" | "Processing" | "Processed" | "Failed"; @@ -905,6 +1002,8 @@ export interface components { pathItems: never; } +export type $defs = Record; + export type external = Record; export type operations = Record;