Skip to content

Commit

Permalink
FIX-499 review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasbruvik committed Aug 4, 2023
1 parent b4f3c12 commit 2c5591f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Src/WitsmlExplorer.Api/Workers/ImportLogDataWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private static WitsmlLogs CreateAddMnemonicsQuery(ImportLogDataJob job, WitsmlLo
{
Mnemonic = job.Mnemonics.ElementAt(i),
Unit = string.IsNullOrEmpty(job.Units.ElementAt(i)) ? "unitless" : job.Units.ElementAt(i), // Can't updateInStore with an empty unit
Uid = Guid.NewGuid().ToString(),
TypeLogData = (i == 0 && witsmlLog.IndexType == WitsmlLog.WITSML_INDEX_TYPE_DATE_TIME) ? WitsmlLogCurveInfo.LogDataTypeDatetime : WitsmlLogCurveInfo.LogDataTypeDouble
Uid = job.Mnemonics.ElementAt(i),
TypeLogData = WitsmlLogCurveInfo.LogDataTypeDouble
}).ToList(),
}.AsSingletonList()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { PropertiesModalMode } from "../Modals/ModalParts";
import ObjectPickerModal, { ObjectPickerProps } from "../Modals/ObjectPickerModal";
import TrimLogObjectModal, { TrimLogObjectModalProps } from "../Modals/TrimLogObject/TrimLogObjectModal";
import ContextMenu from "./ContextMenu";
import { menuItemText, StyledIcon } from "./ContextMenuUtils";
import { StyledIcon, menuItemText } from "./ContextMenuUtils";
import { onClickPaste } from "./CopyUtils";
import { ObjectContextMenuProps, ObjectMenuItems } from "./ObjectMenuItems";
import { useClipboardComponentReferencesOfType } from "./UseClipboardComponentReferences";
Expand All @@ -48,7 +48,7 @@ const LogObjectContextMenu = (props: ObjectContextMenuProps): React.ReactElement
};

const onClickImport = async () => {
const logDataImportModalProps: LogDataImportModalProps = { targetLog: checkedObjects[0], dispatchOperation };
const logDataImportModalProps: LogDataImportModalProps = { targetLog: checkedObjects[0] };
dispatchOperation({ type: OperationType.DisplayModal, payload: <LogDataImportModal {...logDataImportModalProps} /> });
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const columns: Column[] = [
{ name: "Source/target end", accessor: "endIndexes" }
];

const StyledAccordionHeader = styled(Accordion.Header)<{ colors: Colors }>`
export const StyledAccordionHeader = styled(Accordion.Header)<{ colors: Colors }>`
background-color: ${(props) => props.colors.ui.backgroundDefault};
&:hover {
background-color: ${(props) => props.colors.ui.backgroundLight};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Button, Tooltip, Typography } from "@material-ui/core";
import { Accordion, List } from "@equinor/eds-core-react";
import { Button, Tooltip, Typography } from "@material-ui/core";
import { CloudUpload } from "@material-ui/icons";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useContext, useEffect, useState } from "react";
import styled from "styled-components";
import { HideModalAction } from "../../contexts/operationStateReducer";
import OperationContext from "../../contexts/operationContext";
import OperationType from "../../contexts/operationType";
import { ComponentType } from "../../models/componentType";
import ImportLogDataJob from "../../models/jobs/importLogDataJob";
Expand All @@ -13,12 +14,11 @@ import { toObjectReference } from "../../models/objectOnWellbore";
import { truncateAbortHandler } from "../../services/apiClient";
import ComponentService from "../../services/componentService";
import JobService, { JobType } from "../../services/jobService";
import Icon from "../../styles/Icons";
import { StyledAccordionHeader } from "./LogComparisonModal";
import ModalDialog from "./ModalDialog";

export interface LogDataImportModalProps {
targetLog: LogObject;
dispatchOperation: (action: HideModalAction) => void;
}
interface ImportColumn {
index: number;
Expand All @@ -31,7 +31,11 @@ const MISSING_INDEX_CURVE = "The target index curve needs to be present in the c
const UNITLESS_UNIT = "unitless";

const LogDataImportModal = (props: LogDataImportModalProps): React.ReactElement => {
const { targetLog, dispatchOperation } = props;
const { targetLog } = props;
const {
dispatchOperation,
operationState: { colors }
} = useContext(OperationContext);
const [uploadedFile, setUploadedFile] = useState<File>(null);
const [uploadedFileData, setUploadedFileData] = useState<string[]>([]);
const [uploadedFileColumns, setUploadedFileColumns] = useState<ImportColumn[]>([]);
Expand Down Expand Up @@ -113,40 +117,39 @@ const LogDataImportModal = (props: LogDataImportModalProps): React.ReactElement
<ModalDialog
heading={`Import data into "${targetLog.name}"`}
content={
<FileContainer>
<Button
variant="contained"
color={"primary"}
component="label"
startIcon={<CloudUpload />}
endIcon={
<Tooltip
placement="right"
title={
<div>
Currently, only double values are supported as TypeLogData.
<br />
<Container>
<FileContainer>
<Button variant="contained" color={"primary"} component="label" startIcon={<CloudUpload />}>
<Typography noWrap>Upload File</Typography>
<input type="file" accept=".csv,text/csv" hidden onChange={handleFileChange} />
</Button>
<Tooltip placement={"top"} title={uploadedFile?.name ?? ""}>
<Typography noWrap>{uploadedFile?.name ?? "No file chosen"}</Typography>
</Tooltip>
</FileContainer>
<Accordion>
<Accordion.Item>
<StyledAccordionHeader colors={colors}>Limitations</StyledAccordionHeader>
<Accordion.Panel style={{ backgroundColor: colors.ui.backgroundLight }}>
<List>
<List.Item>Currently, only double values are supported as TypeLogData.</List.Item>
<List.Item>
The csv is expected to have this format:
<br />
IndexCurve[unit],Curve1[unit],Curve2[unit]
<br />
195.99,,2500
<br />
196.00,1,2501
</div>
}
>
<Icon name="infoCircle" size={18} />
</Tooltip>
}
>
<Typography noWrap>Upload File</Typography>
<input type="file" accept=".csv,text/csv" hidden onChange={handleFileChange} />
</Button>
<Tooltip placement={"top"} title={uploadedFile?.name ?? ""}>
<Typography noWrap>{uploadedFile?.name ?? "No file chosen"}</Typography>
</Tooltip>
</FileContainer>
<List>
<List.Item>
IndexCurve[unit],Curve1[unit],Curve2[unit]
<br />
195.99,,2500
<br />
196.00,1,2501
</List.Item>
</List>
</List.Item>
</List>
</Accordion.Panel>
</Accordion.Item>
</Accordion>
</Container>
}
confirmDisabled={!uploadedFile || !!error}
confirmText={"Import"}
Expand All @@ -169,4 +172,10 @@ const FileContainer = styled.div`
}
`;

const Container = styled.div`
display: flex;
flex-direction: column;
gap: 1.5rem;
`;

export default LogDataImportModal;

0 comments on commit 2c5591f

Please sign in to comment.