-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
2,630 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
engine-strict=true | ||
engine-strict=true | ||
save-prefix= # prevent the caret (^) symbol use when installing new dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 2 additions & 10 deletions
12
webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Load.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
import { useOutletContext } from "react-router"; | ||
import useAppSelector from "../../../../../../redux/hooks/useAppSelector"; | ||
import { getCurrentAreaId } from "../../../../../../redux/selectors"; | ||
import { MatrixStats, StudyMetadata } from "../../../../../../common/types"; | ||
import MatrixInput from "../../../../../common/MatrixInput"; | ||
import { Root } from "./style"; | ||
import Matrix from "../../../../../common/MatrixGrid/Matrix"; | ||
|
||
function Load() { | ||
const { study } = useOutletContext<{ study: StudyMetadata }>(); | ||
const currentArea = useAppSelector(getCurrentAreaId); | ||
const url = `input/load/series/load_${currentArea}`; | ||
|
||
//////////////////////////////////////////////////////////////// | ||
// JSX | ||
//////////////////////////////////////////////////////////////// | ||
|
||
return ( | ||
<Root> | ||
<MatrixInput study={study} url={url} computStats={MatrixStats.STATS} /> | ||
</Root> | ||
); | ||
return <Matrix url={url} />; | ||
} | ||
|
||
export default Load; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { Divider, Skeleton } from "@mui/material"; | ||
import MatrixGrid from "."; | ||
import { useMatrix } from "./useMatrix"; | ||
import { useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import ImportDialog from "../dialogs/ImportDialog"; | ||
import { useOutletContext } from "react-router"; | ||
import { StudyMetadata } from "../../../common/types"; | ||
import { MatrixContainer, MatrixHeader, MatrixTitle } from "./style"; | ||
import MatrixActions from "./MatrixActions"; | ||
import EmptyView from "../page/SimpleContent"; | ||
|
||
interface MatrixProps { | ||
url: string; | ||
title?: string; | ||
enableTimeSeriesColumns?: boolean; | ||
enableAggregateColumns?: boolean; | ||
} | ||
|
||
function Matrix({ | ||
url, | ||
title = "global.timeSeries", | ||
enableTimeSeriesColumns = true, | ||
enableAggregateColumns = false, | ||
}: MatrixProps) { | ||
const { t } = useTranslation(); | ||
const { study } = useOutletContext<{ study: StudyMetadata }>(); | ||
const [openImportDialog, setOpenImportDialog] = useState(false); | ||
|
||
const { | ||
data, | ||
error, | ||
isLoading, | ||
isSubmitting, | ||
columns, | ||
dateTime, | ||
handleCellEdit, | ||
handleMultipleCellsEdit, | ||
handleImport, | ||
handleSaveUpdates, | ||
pendingUpdatesCount, | ||
undo, | ||
redo, | ||
canUndo, | ||
canRedo, | ||
} = useMatrix(study.id, url, enableTimeSeriesColumns, enableAggregateColumns); | ||
|
||
//////////////////////////////////////////////////////////////// | ||
// JSX | ||
//////////////////////////////////////////////////////////////// | ||
|
||
if (isLoading) { | ||
return <Skeleton sx={{ height: 1, transform: "none" }} />; | ||
} | ||
|
||
if (error) { | ||
return <EmptyView title={error.toString()} />; | ||
} | ||
|
||
if (!data || data.length === 0) { | ||
return <EmptyView title={t("matrix.message.matrixEmpty")} />; | ||
} | ||
|
||
return ( | ||
<MatrixContainer> | ||
<MatrixHeader> | ||
<MatrixTitle>{t(title)}</MatrixTitle> | ||
<MatrixActions | ||
onImport={() => setOpenImportDialog(true)} | ||
onSave={handleSaveUpdates} | ||
studyId={study.id} | ||
path={url} | ||
disabled={data.length === 0} | ||
pendingUpdatesCount={pendingUpdatesCount} | ||
isSubmitting={isSubmitting} | ||
undo={undo} | ||
redo={redo} | ||
canUndo={canUndo} | ||
canRedo={canRedo} | ||
/> | ||
</MatrixHeader> | ||
<Divider sx={{ width: 1, mt: 1, mb: 2 }} /> | ||
<MatrixGrid | ||
data={data} | ||
columns={columns} | ||
rows={data.length} | ||
dateTime={dateTime} | ||
onCellEdit={handleCellEdit} | ||
onMultipleCellsEdit={handleMultipleCellsEdit} | ||
readOnly={isSubmitting} | ||
/> | ||
{openImportDialog && ( | ||
<ImportDialog | ||
open={openImportDialog} | ||
title={t("matrix.importNewMatrix")} | ||
dropzoneText={t("matrix.message.importHint")} | ||
onCancel={() => setOpenImportDialog(false)} | ||
onImport={handleImport} | ||
accept={{ "text/*": [".csv", ".tsv", ".txt"] }} | ||
/> | ||
)} | ||
</MatrixContainer> | ||
); | ||
} | ||
|
||
export default Matrix; |
101 changes: 101 additions & 0 deletions
101
webapp/src/components/common/MatrixGrid/MatrixActions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { Box, Divider, IconButton, Tooltip } from "@mui/material"; | ||
import SplitButton from "../buttons/SplitButton"; | ||
import DownloadMatrixButton from "../DownloadMatrixButton"; | ||
import FileDownload from "@mui/icons-material/FileDownload"; | ||
import { useTranslation } from "react-i18next"; | ||
import { LoadingButton } from "@mui/lab"; | ||
import Save from "@mui/icons-material/Save"; | ||
import { Undo, Redo } from "@mui/icons-material"; | ||
|
||
interface MatrixActionsProps { | ||
onImport: VoidFunction; | ||
onSave: VoidFunction; | ||
studyId: string; | ||
path: string; | ||
disabled: boolean; | ||
pendingUpdatesCount: number; | ||
isSubmitting: boolean; | ||
undo: VoidFunction; | ||
redo: VoidFunction; | ||
canUndo: boolean; | ||
canRedo: boolean; | ||
} | ||
|
||
function MatrixActions({ | ||
onImport, | ||
onSave, | ||
studyId, | ||
path, | ||
disabled, | ||
pendingUpdatesCount, | ||
isSubmitting, | ||
undo, | ||
redo, | ||
canUndo, | ||
canRedo, | ||
}: MatrixActionsProps) { | ||
const { t } = useTranslation(); | ||
|
||
//////////////////////////////////////////////////////////////// | ||
// JSX | ||
//////////////////////////////////////////////////////////////// | ||
|
||
return ( | ||
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}> | ||
<Tooltip title={t("global.undo")}> | ||
<span> | ||
<IconButton | ||
onClick={undo} | ||
disabled={!canUndo} | ||
size="small" | ||
color="primary" | ||
> | ||
<Undo fontSize="small" /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
<Tooltip title={t("global.redo")}> | ||
<span> | ||
<IconButton | ||
onClick={redo} | ||
disabled={!canRedo} | ||
size="small" | ||
color="primary" | ||
> | ||
<Redo fontSize="small" /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
<LoadingButton | ||
onClick={onSave} | ||
loading={isSubmitting} | ||
loadingPosition="start" | ||
startIcon={<Save />} | ||
variant="contained" | ||
size="small" | ||
disabled={pendingUpdatesCount === 0} | ||
> | ||
({pendingUpdatesCount}) | ||
</LoadingButton> | ||
<Divider sx={{ mx: 2 }} orientation="vertical" flexItem /> | ||
<SplitButton | ||
options={[t("global.import.fromFile"), t("global.import.fromDatabase")]} | ||
onClick={onImport} | ||
size="small" | ||
ButtonProps={{ | ||
startIcon: <FileDownload />, | ||
}} | ||
disabled={isSubmitting} | ||
> | ||
{t("global.import")} | ||
</SplitButton> | ||
<DownloadMatrixButton | ||
studyId={studyId} | ||
path={path} | ||
disabled={disabled || isSubmitting} | ||
/> | ||
</Box> | ||
); | ||
} | ||
|
||
export default MatrixActions; |
Oops, something went wrong.