Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/compute variogram #114

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dialog } from '@equinor/eds-core-react'
import styled from 'styled-components'
import { spacings } from '../../tokens/spacings'
import { spacings } from '../../../tokens/spacings'

const StyledDialog = styled(Dialog)`
min-width: 600px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Typography } from '@equinor/eds-core-react'
import styled from 'styled-components'
import { spacings } from '../../tokens/spacings'
import { spacings } from '../../../tokens/spacings'

/*
Note: Hiding the input element because it is ugly,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Icon } from '@equinor/eds-core-react'
import { subdirectory_arrow_right as arrowIcon } from '@equinor/eds-icons'
import { ChangeEvent, useRef } from 'react'
import { theme } from '../../tokens/theme'
import { theme } from '../../../tokens/theme'
import { FileUpload, SelectFile } from './FileUploader.styled'

interface FileUploaderProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Table } from '@equinor/eds-core-react'
import { delete_to_trash as deleteIcon } from '@equinor/eds-icons'
import { ChangeEvent } from 'react'
import IconButton from '../../components/IconButton/IconButton'
import IconButton from '../../../components/IconButton/IconButton'
import { FileUploader } from '../FileUploader/FileUploader'

type FileDisplay = { isVisible: boolean; toggle: () => void }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from 'styled-components'
import { spacings } from '../../tokens/spacings'
import { spacings } from '../../../tokens/spacings'

export const ModelMetadata = styled.div`
&.model-metadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ export const Case = styled.div`
padding: ${spacings.LARGE};
column-gap: ${spacings.MEDIUM};

border: solid thin ${theme.light.ui.background.medium};
border-bottom: solid thin ${theme.light.ui.background.medium};
`

export const Parameters = styled.div`
display: flex;
flex-direction: column;
row-gap: ${spacings.MEDIUM};

background-color: ${theme.light.ui.background.light};
padding: ${spacings.LARGE};
background-color: ${theme.light.ui.background.light};
border-radius: 0 0 ${spacings.CARD_ROUNDED} 0;
`

export const Wrapper = styled.div`
border-left: solid;
border-width: thick;
border-width: ${spacings.SMALL};
border-color: ${theme.light.primary.resting};
border-radius: ${spacings.X_SMALL};
border-radius: ${spacings.BORDER_ROUNDED};
`
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { theme } from '../../../../../tokens/theme'
export const Parameters = styled.div`
background-color: ${theme.light.ui.background.default};
padding: ${spacings.MEDIUM};
border-radius: ${spacings.X_SMALL};
border-radius: ${spacings.CARD_ROUNDED};
box-shadow: ${theme.light.ui.elevation.raised};

display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { Button, Table, Typography } from '@equinor/eds-core-react'
import { useParams } from 'react-router-dom'
import { useAnalogueModels } from '../../../hooks/useAnalogueModels'

export type ModelParam = {
id: string
}
export const ModelMetadataView = () => {
const { id } = useParams<{ id: string }>()
const { model } = useAnalogueModels(id!)
const { id } = useParams<keyof ModelParam>() as ModelParam
const { model } = useAnalogueModels(id)

if (model.isLoading) <p>Loading.....</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const NameFrame = styled.div`
width: 100%;
padding: ${spacings.LARGE} 0;
background-color: ${theme.light.ui.background.light};
border-left: solid ${spacings.XX_SMALL} ${theme.light.ui.background.medium};

> h1 {
margin: 0;
Expand Down
7 changes: 4 additions & 3 deletions src/features/ModelView/ModelSourceView/ModelSourceView.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Table, Typography } from '@equinor/eds-core-react'
import { useParams } from 'react-router-dom'
import { useAnalogueModels } from '../../../hooks/useAnalogueModels'
import { ModelParam } from '../ModelMetadataView/ModelMetadataView'
export const ModelSourceView = () => {
const { id } = useParams<{ id: string }>()
const { model } = useAnalogueModels(id!)
const { id } = useParams<keyof ModelParam>() as ModelParam
const { model } = useAnalogueModels(id)

if (model.isLoading) <p>Loading.....</p>

Expand All @@ -25,7 +26,7 @@ export const ModelSourceView = () => {
model.isFetched &&
(model.data.data.fileUploads?.length === undefined ||
model.data.data.fileUploads?.length > 0) ? (
model.data.data.fileUploads?.map((file: any) => (
model.data.data.fileUploads?.map((file: AnalogueModel) => (
<Table.Row key={file.uploadId} className="table-row">
<Table.Cell className="table-first-col">
{file.originalFileName}
Expand Down
25 changes: 10 additions & 15 deletions src/hooks/useAnalogueModels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function useAnalogueModels(id: string) {
const apiClient = useApiClient()
const token = useAccessToken()
const headers = new Headers({ Authorization: `Bearer ${token}` })
const modelId = id

async function fetchModels(): AnalogueModelResponse {
const { data } = await apiClient.GET(ANALOGUEMODELS_KEY, {
Expand Down Expand Up @@ -50,31 +49,27 @@ export function useAnalogueModels(id: string) {
return data
}

async function uploadNCFile(modelId: string, file: File) {
async function uploadNCFile(id: string, file: File) {
axios.defaults.baseURL = process.env.REACT_APP_BACKEND_ENV
const form = new FormData()
form.append('file', file)
const { data } = await axios.post(
NC_FILE_KEY.replace('{id}', modelId),
form,
{
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'multipart/form-data',
},
}
)
const { data } = await axios.post(NC_FILE_KEY.replace('{id}', id), form, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'multipart/form-data',
},
})
return data
}

const models = useQuery(['models', token], fetchModels, { enabled: !!token })
// TODO: might want to add queryFn to this:

const model: AnalogueModel = useQuery({
queryKey: ['model', token, modelId],
queryFn: () => fetchModel(modelId),
queryKey: ['model', token, id],
queryFn: () => fetchModel(id),

enabled: !!modelId,
enabled: !!id,
})

return {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Browse/Browse.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Snackbar, Typography } from '@equinor/eds-core-react'
import { useState } from 'react'
import { Table } from '../../components/Table'
import { AddModelDialog } from '../../features/AddModelDialog/AddModelDialog'
import { AddModelDialog } from '../../features/AddModel/AddModelDialog/AddModelDialog'
import { useAnalogueModels } from '../../hooks/useAnalogueModels'
import * as Styled from './Browse.styled'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ export const Case = styled.div`
display: flex;
flex-direction: column;

margin: ${spacings.X_LARGE};
padding: ${spacings.X_LARGE};
column-gap: ${spacings.MEDIUM};
row-gap: ${spacings.XXX_LARGE};

width: 70%;
width: 75%;

@media (max-width: 1450px) {
width: 95%;
}

border-left: solid ${spacings.XX_SMALL} ${theme.light.ui.background.medium};
`
export const CaseBorder = styled.div`
display: flex;
flex-direction: column;
row-gap: ${spacings.XXX_LARGE};

border-radius: ${spacings.X_SMALL};
border-radius: ${spacings.CARD_ROUNDED};
border: solid 1px ${theme.light.ui.background.medium};
`
export const AddCaseButton = styled(Button)`
Expand Down
4 changes: 4 additions & 0 deletions src/pages/ModelPages/Model/Model.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from 'styled-components'
import { theme } from '../../../tokens/theme'

export const Wrapper = styled.div`
display: flex;
Expand All @@ -16,4 +17,7 @@ export const ContentWrapper = styled.div`
export const SidebarWrapper = styled.div`
heigth: 100%;
max-width: 256px;
> div {
border-color: ${theme.light.ui.background.medium};
}
`
5 changes: 3 additions & 2 deletions src/pages/ModelPages/Model/Model.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Outlet, useParams } from 'react-router-dom'
import { ModelParam } from '../../../features/ModelView/ModelMetadataView/ModelMetadataView'
import { ModelNameFrame } from '../../../features/ModelView/ModelNameFrame/ModelNameFrame'
import { ModelNavigationBar } from '../../../features/ModelView/ModelNavigationBar/ModelNavigationBar'
import { useAnalogueModels } from '../../../hooks/useAnalogueModels'
import * as Styled from './Model.styled'

export const Model = () => {
const { id } = useParams<{ id: string }>()
const { model } = useAnalogueModels(id!)
const { id } = useParams<keyof ModelParam>() as ModelParam
const { model } = useAnalogueModels(id)

if (model.isLoading) <p>Loading.....</p>

Expand Down
4 changes: 4 additions & 0 deletions src/tokens/spacings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ export const spacings = {
XXXX_LARGE: '64px',
/** 92px */
COMPUTE_BUTTON: '92px',
/** 5px */
CARD_ROUNDED: '5px',
/** 4px */
BORDER_ROUNDED: '4px', // CARD_ROUNDED - 1px
}