-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from yohamta/feat/suspend-dag
feat: suspend DAG schedule by switches on web UI
- Loading branch information
Showing
21 changed files
with
353 additions
and
53 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
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,47 @@ | ||
import { Switch } from '@mui/material'; | ||
import React from 'react'; | ||
import { DAG } from '../models/DAGData'; | ||
|
||
type Props = { | ||
DAG: DAG; | ||
refresh?: () => void; | ||
}; | ||
|
||
function DAGSwitch({ DAG, refresh }: Props) { | ||
const [checked, setChecked] = React.useState(!DAG.Suspended); | ||
|
||
const onSubmit = React.useCallback( | ||
async (params: { name: string; action: string; value: string }) => { | ||
const form = new FormData(); | ||
form.set('action', params.action); | ||
form.set('value', params.value); | ||
const url = `${API_URL}/dags/${params.name}`; | ||
const ret = await fetch(url, { | ||
method: 'POST', | ||
mode: 'cors', | ||
body: form, | ||
}); | ||
if (ret.ok) { | ||
if (refresh) { | ||
refresh(); | ||
} | ||
} else { | ||
const e = await ret.text(); | ||
alert(e); | ||
} | ||
}, | ||
[refresh] | ||
); | ||
|
||
const onChange = React.useCallback(() => { | ||
const enabled = !checked; | ||
setChecked(enabled); | ||
onSubmit({ | ||
name: DAG.Config.Name, | ||
action: 'suspend', | ||
value: enabled ? 'false' : 'true', | ||
}); | ||
}, [DAG, checked]); | ||
return <Switch checked={checked} onChange={onChange} />; | ||
} | ||
export default DAGSwitch; |
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
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
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
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
Oops, something went wrong.