Skip to content

Commit

Permalink
Merge pull request #219 from yohamta/feat/start-params-webui
Browse files Browse the repository at this point in the history
Fix issues of Web UI
  • Loading branch information
yottahmd authored Jul 29, 2022
2 parents 5069982 + 00756b8 commit 78af441
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 26 deletions.
19 changes: 17 additions & 2 deletions admin/src/components/ConfigInfoTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Config } from '../models/Config';
import { Stack, Box } from '@mui/material';
import { Stack, Box, Chip } from '@mui/material';
import LabeledItem from './LabeledItem';

type Props = {
Expand All @@ -18,12 +18,27 @@ function ConfigInfoTable({ config }: Props) {
return (
<Stack direction="column" spacing={1}>
<LabeledItem label="Name">{config.Name}</LabeledItem>
<LabeledItem label="Schedule">
<Stack direction={'row'}>
{config.ScheduleExp.map((s) => (
<Chip
key={s}
sx={{
fontWeight: 'semibold',
marginRight: 1,
}}
size="small"
label={s}
/>
))}
</Stack>
</LabeledItem>
<LabeledItem label="Description">{config.Description}</LabeledItem>
<LabeledItem label="Max Active Runs">{config.MaxActiveRuns}</LabeledItem>
<LabeledItem label="Params">{config.Params}</LabeledItem>
<Stack direction={'column'}>
<React.Fragment>
<LabeledItem label="Pre Conditions">{null}</LabeledItem>
<LabeledItem label="Preconditions">{null}</LabeledItem>
<Box sx={{ pl: 2 }}>
<ul>{preconditions}</ul>
</Box>
Expand Down
19 changes: 17 additions & 2 deletions admin/src/components/DAGActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ type Props = {
status?: Status;
name: string;
label?: boolean;
redirectTo?: string;
refresh?: () => void;
};

function DAGActions({ status, name, refresh, label = true }: Props) {
function DAGActions({
status,
name,
refresh,
redirectTo,
label = true,
}: Props) {
const onSubmit = React.useCallback(
async (
warn: string,
Expand All @@ -33,6 +40,9 @@ function DAGActions({ status, name, refresh, label = true }: Props) {
mode: 'cors',
body: form,
});
if (redirectTo) {
window.location.href = redirectTo;
}
if (ret.ok) {
if (refresh) {
refresh();
Expand Down Expand Up @@ -142,7 +152,12 @@ function ActionButton({
{children}
</Button>
) : (
<IconButton color="primary" size="small" onClick={onClick} disabled={disabled}>
<IconButton
color="primary"
size="small"
onClick={onClick}
disabled={disabled}
>
{icon}
</IconButton>
);
Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/DAGHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function DAGHistory({ logData }: Props) {
{(props) => (
<React.Fragment>
<Box>
<SubTitle>Config</SubTitle>
<SubTitle>Execution History</SubTitle>
<StatusHistTable
logs={logs}
gridData={gridData}
Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/DAGLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function DAGLog({ log }: Props) {
}
return (
<Box>
<SubTitle>Log</SubTitle>
<SubTitle>Log Output</SubTitle>
<Stack spacing={1} direction="column" sx={{ width: '100%' }}>
<LabeledItem label="Log File">{log.LogFile}</LabeledItem>
{log.Step ? (
Expand Down
61 changes: 43 additions & 18 deletions admin/src/components/DAGTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
TableCell,
TableHead,
TableRow,
TableSortLabel,
TextField,
} from '@mui/material';
import { Link } from 'react-router-dom';
Expand All @@ -36,7 +35,12 @@ import {
getNextSchedule,
} from '../models/DAGData';
import StyledTableRow from './StyledTableRow';
import { KeyboardArrowDown, KeyboardArrowUp } from '@mui/icons-material';
import {
ArrowDownward,
ArrowUpward,
KeyboardArrowDown,
KeyboardArrowUp,
} from '@mui/icons-material';
import DAGSwitch from './DAGSwitch';

type Props = {
Expand All @@ -60,7 +64,12 @@ const defaultColumns = [
id: 'Expand',
header: ({ instance }) => {
return (
<IconButton onClick={instance.getToggleAllRowsExpandedHandler()}>
<IconButton
onClick={instance.getToggleAllRowsExpandedHandler()}
sx={{
color: 'white',
}}
>
{instance.getIsAllRowsExpanded() ? (
<KeyboardArrowUp />
) : (
Expand Down Expand Up @@ -471,24 +480,40 @@ function DAGTable({ DAGs = [], group = '', refreshFn }: Props) {
}}
>
{header.column.getCanSort() ? (
<Stack direction="column" spacing={1}>
<Box
{...{
sx: {
cursor: header.column.getCanSort()
? 'pointer'
: 'default',
},
onClick: header.column.getToggleSortingHandler(),
}}
>
<Box
{...{
sx: {
cursor: header.column.getCanSort()
? 'pointer'
: 'default',
},
onClick: header.column.getToggleSortingHandler(),
}}
>
<Stack direction="row" alignItems="center">
{header.isPlaceholder ? null : header.renderHeader()}
{{
asc: <TableSortLabel direction="asc" />,
desc: <TableSortLabel direction="desc" />,
asc: (
<ArrowUpward
sx={{
color: 'white',
fontSize: '0.95rem',
ml: 1,
}}
/>
),
desc: (
<ArrowDownward
sx={{
color: 'white',
fontSize: '0.95rem',
ml: 1,
}}
/>
),
}[header.column.getIsSorted() as string] ?? null}
</Box>
</Stack>
</Stack>
</Box>
) : (
header.renderHeader()
)}
Expand Down
7 changes: 6 additions & 1 deletion admin/src/pages/DAGDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ function DAGDetails() {
}}
>
<Title>{data.Title}</Title>
{tab == DetailTabId.Status ? (
{tab == DetailTabId.Status || tab == DetailTabId.Config ? (
<DAGActions
status={data.DAG.Status}
name={params.name!}
refresh={getData}
redirectTo={
tab == DetailTabId.Config
? `${baseUrl}?t=${DetailTabId.Status}`
: undefined
}
/>
) : null}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (a *Agent) setupSocketServer() (err error) {

func (a *Agent) checkPreconditions() error {
if len(a.DAG.Preconditions) > 0 {
log.Printf("checking pre conditions for \"%s\"", a.DAG.Name)
log.Printf("checking preconditions for \"%s\"", a.DAG.Name)
if err := config.EvalConditions(a.DAG.Preconditions); err != nil {
a.scheduler.Cancel(a.graph)
return err
Expand Down

0 comments on commit 78af441

Please sign in to comment.