Skip to content

Commit

Permalink
UI changes related to file and job deletion based on start and end dates
Browse files Browse the repository at this point in the history
Changes related to file and job deletion based on start and end dates
  • Loading branch information
NaveenKinnal authored Jan 20, 2023
2 parents 7c5d89c + beee82f commit 47a7b10
Show file tree
Hide file tree
Showing 18 changed files with 219 additions and 26 deletions.
1 change: 1 addition & 0 deletions components/lab-job-scheduler/backend/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ignore =
E731,
# line break before binary operator
W503,

max-line-length = 88
# select = B,C,E,F,W,T4,B9
# max-complexity = 18
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from contaxy.schema.deployment import JobInput
from pydantic import BaseModel, Field

Expand Down Expand Up @@ -27,13 +25,13 @@ class ScheduledJob(ScheduledJobInput):
description="The time the job was created in ISO format.",
example="2022-09-29T11:39:52.441287",
)
last_run: Optional[str] = Field(
None,
last_run: str = Field(
"",
description="The last time the job was run in ISO format.",
example="2022-09-29T11:39:52.441287",
)
next_run: Optional[str] = Field(
None,
next_run: str = Field(
"",
description="The next time the job will be run in ISO format.",
example="2022-09-29T11:39:52.441287",
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def job_without_last_run(job_input: JobInput):
return ScheduledJob(
job_id=str(uuid.uuid4()),
created=datetime.datetime(2021, 1, 1, 0, 0, 0).isoformat(),
last_run=None,
last_run="",
cron_string="0 1 * * *",
job_input=job_input,
)
Expand Down
6 changes: 3 additions & 3 deletions components/lab-job-scheduler/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
},
"scripts": {
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"start-debug": "REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080/ yarn start",
"start-debug": "GENERATE_SOURCEMAP=false REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080/ yarn start",
"container": "run(){ docker build -t project-template-dev ../.github/actions/build-environment && echo 'Starting the container. That can take a moment...' && docker run -it --rm -p 3000:3000 -p 6006:6006 -v $(pwd):/workspace:delegated --entrypoint \"/bin/bash\" project-template-dev -c \"cd workspace/ && yarn $1\"; }; run",
"build": "react-scripts build",
"test": "react-scripts test a --watchAll=false",
"build": "GENERATE_SOURCEMAP=false react-scripts build",
"test": "react-scripts test a --watchAll=false --passWithNoTests",
"test-interactive": "react-scripts test",
"eject": "react-scripts eject",
"lint": "yarn run lint:js ; yarn run lint:css",
Expand Down
1 change: 1 addition & 0 deletions components/lab-mlflow-manager/backend/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ignore =
E731,
# line break before binary operator
W503,

max-line-length = 88
# select = B,C,E,F,W,T4,B9
# max-complexity = 18
Expand Down
6 changes: 3 additions & 3 deletions components/lab-mlflow-manager/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"stylelint-config-standard": "^20.0.0"
},
"scripts": {
"start": "react-scripts start",
"start-debug": "REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080/ yarn start",
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"start-debug": "GENERATE_SOURCEMAP=false REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080/ yarn start",
"container": "run(){ docker build -t project-template-dev ../.github/actions/build-environment && echo 'Starting the container. That can take a moment...' && docker run -it --rm -p 3000:3000 -p 6006:6006 -v $(pwd):/workspace:delegated --entrypoint \"/bin/bash\" project-template-dev -c \"cd workspace/ && yarn $1\"; }; run",
"build": "react-scripts build",
"build": "GENERATE_SOURCEMAP=false react-scripts build",
"test": "react-scripts test a --watchAll=false --passWithNoTests",
"test-interactive": "react-scripts test",
"eject": "react-scripts eject",
Expand Down
1 change: 1 addition & 0 deletions components/lab-workspace-manager/backend/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ignore =
E731,
# line break before binary operator
W503,

max-line-length = 88
# select = B,C,E,F,W,T4,B9
# max-complexity = 18
Expand Down
6 changes: 3 additions & 3 deletions components/lab-workspace-manager/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"stylelint-config-standard": "^20.0.0"
},
"scripts": {
"start": "react-scripts start",
"start-debug": "REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080 yarn start",
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"start-debug": "GENERATE_SOURCEMAP=false REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080 yarn start",
"container": "run(){ docker build -t project-template-dev ../.github/actions/build-environment && echo 'Starting the container. That can take a moment...' && docker run -it --rm -p 3000:3000 -p 6006:6006 -v $(pwd):/workspace:delegated --entrypoint \"/bin/bash\" project-template-dev -c \"cd workspace/ && yarn $1\"; }; run",
"build": "react-scripts build",
"build": "GENERATE_SOURCEMAP=false react-scripts build",
"test": "react-scripts test a --watchAll=false",
"test-interactive": "react-scripts test",
"eject": "react-scripts eject",
Expand Down
1 change: 1 addition & 0 deletions components/template/backend/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ignore =
E731,
# line break before binary operator
W503,

max-line-length = 88
# select = B,C,E,F,W,T4,B9
# max-complexity = 18
Expand Down
6 changes: 3 additions & 3 deletions components/template/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"stylelint-config-standard": "^20.0.0"
},
"scripts": {
"start": "react-scripts start",
"start-debug": "REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080/ yarn start",
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"start-debug": "GENERATE_SOURCEMAP=false REACT_APP_CONTAXY_ENDPOINT=http://localhost:30010/api REACT_APP_EXTENSION_ENDPOINT=http://localhost:8080/ yarn start",
"container": "run(){ docker build -t project-template-dev ../.github/actions/build-environment && echo 'Starting the container. That can take a moment...' && docker run -it --rm -p 3000:3000 -p 6006:6006 -v $(pwd):/workspace:delegated --entrypoint \"/bin/bash\" project-template-dev -c \"cd workspace/ && yarn $1\"; }; run",
"build": "react-scripts --openssl-legacy-provider build",
"build": "GENERATE_SOURCEMAP=false react-scripts --openssl-legacy-provider build",
"test": "react-scripts test a --watchAll=false",
"test-interactive": "react-scripts test",
"eject": "react-scripts eject",
Expand Down
6 changes: 3 additions & 3 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
"stylelint-config-standard": "^20.0.0"
},
"scripts": {
"start": "react-scripts start",
"start-debug": "REACT_APP_ENDPOINT=http://localhost:30010/api yarn start",
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"start-debug": "GENERATE_SOURCEMAP=false REACT_APP_ENDPOINT=http://localhost:30010/api yarn start",
"container": "run(){ docker build -t project-template-dev ../.github/actions/build-environment && echo 'Starting the container. That can take a moment...' && docker run -it --rm -p 3000:3000 -p 6006:6006 -v $(pwd):/workspace:delegated --entrypoint \"/bin/bash\" project-template-dev -c \"cd workspace/ && yarn $1\"; }; run",
"build": "react-scripts build",
"build": "GENERATE_SOURCEMAP=false react-scripts build",
"test": "react-scripts test a --watchAll=false",
"test-interactive": "react-scripts test",
"eject": "react-scripts eject",
Expand Down
97 changes: 97 additions & 0 deletions webapp/src/components/Dialogs/DeleteMany.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React, { useState } from 'react';

import PropTypes from 'prop-types';

import { Grid } from '@material-ui/core';
import Button from '@material-ui/core/Button';
import CircularProgress from '@material-ui/core/CircularProgress';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import TextField from '@material-ui/core/TextField';

const ConfirmDeleteManyDialog = ({
onClose,
onDelete,
dialogTitle,
dialogText,
}) => {
const [deletionStarted, setDeletionStarted] = useState(false);
const defaultDate = new Date().toISOString().slice(0, 10);
const [startDate, setStartDate] = useState(defaultDate);
const [endDate, setEndDate] = useState(defaultDate);
const handelDeleteClick = () => {
setDeletionStarted(true);
onDelete(onClose, startDate, endDate);
};
const onSetStartDate = (event) => {
setStartDate(new Date(event.target.value).toISOString().slice(0, 10));
};

const onSetEndDate = (event) => {
setEndDate(new Date(event.target.value).toISOString().slice(0, 10));
};

return (
<Dialog open>
<DialogTitle>{dialogTitle}</DialogTitle>
<DialogContent>
<DialogContentText>{dialogText}</DialogContentText>
<Grid container spacing={2}>
<Grid item xs={6}>
<TextField
id="date"
label="From"
type="date"
margin="dense"
defaultValue={startDate}
value={startDate}
onChange={onSetStartDate}
InputLabelProps={{
shrink: true,
}}
/>
</Grid>
<Grid item xs={6}>
<TextField
id="date"
label="To"
type="date"
margin="dense"
defaultValue={endDate}
value={endDate}
onChange={onSetEndDate}
InputLabelProps={{
shrink: true,
}}
/>
</Grid>
</Grid>
</DialogContent>
<DialogActions>
<Button onClick={onClose} color="primary">
CANCEL
</Button>
<Button
disabled={deletionStarted}
onClick={handelDeleteClick}
color="primary"
>
DELETE
</Button>
{deletionStarted ? <CircularProgress size="25px" /> : null}
</DialogActions>
</Dialog>
);
};

ConfirmDeleteManyDialog.propTypes = {
onClose: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
dialogTitle: PropTypes.string.isRequired,
dialogText: PropTypes.string.isRequired,
};

export default ConfirmDeleteManyDialog;
34 changes: 34 additions & 0 deletions webapp/src/pages/Files/Files.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import {
getFileDownloadUrl,
getFileUploadUrl,
} from '../../services/contaxy-api';
import { useShowAppDialog } from '../../app/AppDialogServiceProvider';
import FilesTable from './FilesTable';

import ConfirmDeleteManyDialog from '../../components/Dialogs/DeleteMany';
import GlobalStateContainer from '../../app/store';
import UploadFilesDialog from '../../components/Dialogs/UploadFilesDialog';
import Widget from '../../components/Widget';
Expand All @@ -27,6 +29,7 @@ function Files(props) {
const { className, folder, uploadNote } = props;
const [data, setData] = useState([]);
const { activeProject } = GlobalStateContainer.useContainer();
const showAppDialog = useShowAppDialog();
const projectId = activeProject.id;
const [widgetData, setWidgetData] = useState({
totalSize: '0',
Expand Down Expand Up @@ -90,6 +93,36 @@ function Files(props) {
[projectId, reloadFiles]
);

const onDeleteMany = useCallback(
async (projectId) => {
try {
showAppDialog(ConfirmDeleteManyDialog, {
dialogTitle: 'Delete Datasets',
dialogText: `Do you really want to delete the datasets?`,
onDelete: async (onClose, startDate, endDate) => {
try {
const opts = {
startDate: new Date(startDate),
endDate: new Date(endDate),
};
await filesApi.deleteFiles(projectId, opts);
showStandardSnackbar(`Deleted datasets`);
reloadFiles();
} catch (err) {
// showStandardSnackbar(
// `Could not delete user ${rowData.id}! ${err.body.message}.`
// );
}
onClose();
},
});
} catch (err) {
showStandardSnackbar('Could not load files metadata');
}
},
[showAppDialog, reloadFiles]
);

const onFileDownload = useCallback(
(rowData) => {
const a = document.createElement('a');
Expand Down Expand Up @@ -118,6 +151,7 @@ function Files(props) {
data={data}
onFileDownload={onFileDownload}
onFileDelete={onFileDelete}
onDeleteMany={(rowData) => onDeleteMany(activeProject.id, rowData)}
onReload={reloadFiles}
/>
);
Expand Down
19 changes: 17 additions & 2 deletions webapp/src/pages/Files/FilesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ const COLUMNS = [
];

function FilesTable(props) {
const { className, title, data, onFileDelete, onFileDownload, onReload } =
props;
const {
className,
title,
data,
onFileDelete,
onDeleteMany,
onFileDownload,
onReload,
} = props;
return (
<MaterialTable
title={title || 'Files'}
Expand Down Expand Up @@ -87,6 +94,12 @@ function FilesTable(props) {
},
tooltip: 'Download File',
},
{
icon: 'delete',
isFreeAction: true,
onClick: onDeleteMany,
tooltip: 'Delete Many',
},
{
icon: 'content_copy',
iconProps: { className: `${className} actionIcon` },
Expand Down Expand Up @@ -116,6 +129,7 @@ FilesTable.propTypes = {
data: PropTypes.arrayOf(Object),
onFileDownload: PropTypes.func,
onFileDelete: PropTypes.func,
onDeleteMany: PropTypes.func,
onReload: PropTypes.func,
};

Expand All @@ -124,6 +138,7 @@ FilesTable.defaultProps = {
title: '',
data: [],
onFileDelete: () => {},
onDeleteMany: () => {},
onFileDownload: () => {},
onReload: () => {},
};
Expand Down
Loading

0 comments on commit 47a7b10

Please sign in to comment.