Skip to content

Commit

Permalink
fixes submissions list data engine (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeySukhanov authored Sep 3, 2024
1 parent 148e4d4 commit ffddd99
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 124 deletions.
1 change: 1 addition & 0 deletions datanode-ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module.exports = {
"@typescript-eslint/no-duplicate-enum-values": 0,
"no-unsafe-optional-chaining": 0,
"react/react-in-jsx-scope": 0,
"no-duplicate-case": 0,
"no-undef": 0,
"indent": 0,
"linebreak-style": [
Expand Down
200 changes: 104 additions & 96 deletions datanode-ui/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,36 @@ export const colsTableSubmissions = (t: any): ColumnInterface<any>[] => [
accessor: "id",
id: "id",
},
// {
// Header: t("tables.cols.origin"),
// accessor: "origin",
// id: "origin",
// width: "3%",
// minWidth: 100,
// Cell: ({ value }: { value: OriginSubmission }) => {
// return <>{getItemFromConstantArray(originSubmissions, value).name}</>;
// },
// },
// {
// Header: t("tables.cols.study"),
// accessor: (row: SubmissionDTOInterface) => row.study || "-",
// id: "study",
// maxWidth: 100,
// minWidth: 100,
// width: "30%",
// Cell: NameCell,
// isCropped: true,
// },
{
Header: t("tables.cols.origin"),
accessor: "origin",
id: "origin",
width: "3%",
minWidth: 100,
Cell: ({ value }: { value: OriginSubmission }) => {
return <>{getItemFromConstantArray(originSubmissions, value).name}</>;
},
},
{
Header: t("tables.cols.study"),
accessor: (row: SubmissionDTOInterface) => row.study || "-",
id: "study",
maxWidth: 100,
minWidth: 100,
width: "30%",
Cell: NameCell,
Header: t("tables.cols.data_source"),
accessor: "dataSource.name",
id: "dataSource.name",
maxWidth: 150,
minWidth: 150,
isCropped: true,
Cell: (props): any => {
return props.value.includes('deleted_source_at') ? props.value.substring(0, props.value.indexOf('_deleted_source_at'))?.concat(' (Removed)') : props.value;
}
},
{
Header: t("tables.cols.author"),
Expand All @@ -88,17 +99,6 @@ export const colsTableSubmissions = (t: any): ColumnInterface<any>[] => [
Cell: NameCell,
isCropped: true,
},
{
Header: t("tables.cols.data_source"),
accessor: "dataSource.name",
id: "dataSource.name",
maxWidth: 150,
minWidth: 150,
isCropped: true,
Cell: (props): any => {
return props.value.includes('deleted_source_at') ?props.value.substring( 0,props.value.indexOf('_deleted_source_at') )?.concat(' (Removed)'): props.value;
}
},
{
Header: t("tables.cols.submitted"),
accessor: "submitted",
Expand Down Expand Up @@ -154,13 +154,18 @@ export const colsTableSubmissions = (t: any): ColumnInterface<any>[] => [
id: "status",
minWidth: 100,
width: "5%",
Cell: ({ value }: { value: SubmissionStatus }) => {
const status = getSubmissionStatusInfo(value);
return status ? (
<StatusTag text={status.name} color={status.color} />
) : (
<></>
);
Cell: (props: any) => {

const id = props?.row?.original?.id;
const stage = props?.row?.original?.stage;
const error = props?.row?.original?.error;
if (error) {
const status = getSubmissionStatusInfo(SubmissionStatus.FAILED);
return <StatusTag text={status.name} color={status.color} />;
}

const status = getSubmissionStatusInfo(stage);
return <StatusTag text={status.name} color={status.color} />;
},
},
{
Expand All @@ -171,9 +176,12 @@ export const colsTableSubmissions = (t: any): ColumnInterface<any>[] => [
minWidth: 30,
disableSortBy: true,
Cell: ({ row }: { row: { original: SubmissionDTOInterface } }) => {
const id = row.original.id;
const status = row.original.status;
return status === "EXECUTED" || status === "EXECUTION_FAILURE" ? (
const id = row?.original?.id;
const stage = row?.original?.stage;
const error = row?.original?.error;
return error ||
stage === SubmissionStatus.COMPLETED ||
stage === SubmissionStatus.FAILED ? (
<Tooltip text={t("common.tooltips.download_results")}>
<IconButton
color="info"
Expand All @@ -197,43 +205,43 @@ export const colsTableDatabase = (
t: any,
dbmsTypes: DBMSTypesInterface[]
): ColumnInterface[] => [
{
Header: t("tables.cols.name"),
accessor: "name",
id: "name",
minWidth: 200,
width: "30%",
isCropped: true,
Cell: NameCell,
},
{
Header: t("tables.cols.dbms_type"),
accessor: "dbmsType",
id: "dbmsType",
width: "10%",
minWidth: 110,
isCropped: true,
Cell: (props): any => {
const type = dbmsTypes?.find((elem) => elem.id === props.value);
return type ? type.name : "-";
{
Header: t("tables.cols.name"),
accessor: "name",
id: "name",
minWidth: 200,
width: "30%",
isCropped: true,
Cell: NameCell,
},
},
{
Header: t("tables.cols.database"),
accessor: "connectionString",
id: "connectionString",
minWidth: 120,
maxWidth: 240,
isCropped: true,
},
{
Header: t("tables.cols.cdm_schema"),
accessor: "cdmSchema",
id: "cdmSchema",
width: "5%",
minWidth: 80,
},
];
{
Header: t("tables.cols.dbms_type"),
accessor: "dbmsType",
id: "dbmsType",
width: "10%",
minWidth: 110,
isCropped: true,
Cell: (props): any => {
const type = dbmsTypes?.find((elem) => elem.id === props.value);
return type ? type.name : "-";
},
},
{
Header: t("tables.cols.database"),
accessor: "connectionString",
id: "connectionString",
minWidth: 120,
maxWidth: 240,
isCropped: true,
},
{
Header: t("tables.cols.cdm_schema"),
accessor: "cdmSchema",
id: "cdmSchema",
width: "5%",
minWidth: 80,
},
];
export const colsTableUsers = (t: any): ColumnInterface[] => [
{
Header: t("tables.cols.name"),
Expand Down Expand Up @@ -307,33 +315,33 @@ export const tabsSubmissionResult = (
t: any,
setActive: (value: SubmissionResultTabs) => void
): TabsInterface<SubmissionResultTabs>[] => [
{
value: SubmissionResultTabs.FILE_EXPLORER,
title: t("modals.files_results.tabs.file_explorer"),
onTabClick: setActive,
},
{
value: SubmissionResultTabs.LOG,
title: t("modals.files_results.tabs.logs"),
onTabClick: setActive,
},
];
{
value: SubmissionResultTabs.FILE_EXPLORER,
title: t("modals.files_results.tabs.file_explorer"),
onTabClick: setActive,
},
{
value: SubmissionResultTabs.LOG,
title: t("modals.files_results.tabs.logs"),
onTabClick: setActive,
},
];

export const tabsSubmissionForm = (
t: any,
setActive: (value: CreateSubmissionFormTabs) => void
): TabsInterface<CreateSubmissionFormTabs>[] => [
{
value: CreateSubmissionFormTabs.FILES_IN_ARCHIVE,
title: t("modals.create_submission.tabs.files_in_archive"),
onTabClick: setActive,
},
{
value: CreateSubmissionFormTabs.SEPARATE_FILES,
title: t("modals.create_submission.tabs.separate_files"),
onTabClick: setActive,
},
];
{
value: CreateSubmissionFormTabs.FILES_IN_ARCHIVE,
title: t("modals.create_submission.tabs.files_in_archive"),
onTabClick: setActive,
},
{
value: CreateSubmissionFormTabs.SEPARATE_FILES,
title: t("modals.create_submission.tabs.separate_files"),
onTabClick: setActive,
},
];

export const tabsAdmin = (t: any): TabsInterface[] => [
{
Expand Down
3 changes: 2 additions & 1 deletion datanode-ui/src/libs/components/PageList/PageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const PageList: React.FC<any> = (
totalElements,
removeEntity,
status,
engine,
error,
} = useEntityList(
{
Expand All @@ -128,7 +129,6 @@ export const PageList: React.FC<any> = (
}, []);

const onRowClick = (e: any) => {
console.log(e);
onRowClickOutSide ? onRowClickOutSide(e) : navigate(`${e.original[rowId]}`);
};

Expand Down Expand Up @@ -190,6 +190,7 @@ export const PageList: React.FC<any> = (
onCreate={onCreate}
onImport={onImport}
count={totalElements}
engine={engine}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export const Pagination: React.FC<PaginationProps> = ({
};

const entries = useMemo(() => {
console.log(pageIndex, pageSize, numberOfElements);
return t("tables.base.showing", { minRow: pageIndex * pageSize + 1, maxRow: pageIndex * pageSize + numberOfElements, totalRow: totalElements });
}, [pageIndex, numberOfElements, totalElements, t]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export interface ListHeaderProps {
onCreate?: () => void;
count?: number;
customButtons?: React.ReactNode;
engine?: any
}
16 changes: 16 additions & 0 deletions datanode-ui/src/libs/components/headers/ListHeaderPrimary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ import { Icon } from "../Icon/Icon";
import { transparentize } from "polished";
import { Box, Typography } from "@mui/material";
import { Button } from "../Button/Button";
import { StatusTag } from "../Table";

export const getStatusTagType = (engine) => {
return engine.status === "OK" ? {
color: "success",
text: "Engine available"
} : {
color: "error",
text: "Engine not available"
}
}

export const ListHeaderPrimary: React.FC<ListHeaderProps> = ({
iconName,
Expand All @@ -34,6 +45,7 @@ export const ListHeaderPrimary: React.FC<ListHeaderProps> = ({
canCreate,
count,
customButtons,
engine,
}) => {
return (
<>
Expand Down Expand Up @@ -88,11 +100,15 @@ export const ListHeaderPrimary: React.FC<ListHeaderProps> = ({
height: 23,
boxSizing: "border-box",
ml: 2,
mr: 2
})}
>
{count}
</Box>
)}
{engine && (
<StatusTag {...getStatusTagType(engine)}/>
)}
</Grid>

<Grid item>
Expand Down
9 changes: 8 additions & 1 deletion datanode-ui/src/libs/enums/SubmissionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@ export enum SubmissionStatus {
ABORTING = "ABORTING",
ABORT_FAILURE = "ABORT_FAILURE",
ABORTED = "ABORTED",
DEAD = "DEAD"
DEAD = "DEAD",
INITIALIZE = "INITIALIZE",
EXECUTE = "EXECUTE",
COMPLETED = "COMPLETED",
PENDING = "PENDING",
FAILED = "FAILED",


}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const reducer = (initialState: IEntityList, action: any) => {
draft.numberOfElements = action.payload.numberOfElements || action.payload.result.length;
draft.totalElements = action.payload.totalElements || action.payload.result.length;
draft.sort = action.payload.sort;
draft.engine = action.payload?.engine
draft.status = Status.SUCCESS;
break;
case EntityListConstants.FETCH_REQUEST_FAILED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export interface IEntityList<T extends object = object> {
totalElements: number;
numberOfElements: number;
error: any;
engine?: any;
}
3 changes: 3 additions & 0 deletions datanode-ui/src/libs/types/api/SubmissionDTOInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ export interface SubmissionDTOInterface {
submitted: string;
finished: string;
environment: string;
stage: string;
error: any

}
Loading

0 comments on commit ffddd99

Please sign in to comment.