Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): reboot individual servers
- Loading branch information
Showing
3 changed files
with
111 additions
and
13 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
71 changes: 71 additions & 0 deletions
71
src/bp/ui-admin/src/Pages/Components/Monitoring/ServerControl.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,71 @@ | ||
import { Button, Classes, Dialog, Intent } from '@blueprintjs/core' | ||
import React, { FC, useEffect, useState } from 'react' | ||
import { toastFailure } from '~/utils/toaster' | ||
|
||
import api from '../../../api' | ||
|
||
interface Props { | ||
hostname: string | ||
isOpen?: boolean | ||
toggle: () => void | ||
} | ||
|
||
const ServerControl: FC<Props> = props => { | ||
const [isRestarting, setRestarting] = useState(false) | ||
|
||
useEffect(() => { | ||
setRestarting(false) | ||
}, [props.isOpen]) | ||
|
||
const restartServer = async () => { | ||
try { | ||
await api.getSecured().post(`/admin/server/rebootServer?hostname=${props.hostname}`) | ||
setRestarting(true) | ||
} catch (err) { | ||
toastFailure(err.message) | ||
} | ||
} | ||
|
||
return ( | ||
<Dialog | ||
title="Server Control" | ||
isOpen={props.isOpen} | ||
onClose={props.toggle} | ||
transitionDuration={0} | ||
canOutsideClickClose={false} | ||
> | ||
<div className={Classes.DIALOG_BODY}> | ||
{!isRestarting ? ( | ||
<div> | ||
You are about to restart the Botpress server hosted on <br /> <strong>{props.hostname}</strong>. <br />{' '} | ||
<br /> | ||
Are you sure? | ||
</div> | ||
) : ( | ||
<div> | ||
Server restart in progress. To know when the server is back up, watch the uptime for that server in the | ||
Overview. You can close this window safely. | ||
</div> | ||
)} | ||
</div> | ||
|
||
<div className={Classes.DIALOG_FOOTER}> | ||
<div className={Classes.DIALOG_FOOTER_ACTIONS}> | ||
{!isRestarting ? ( | ||
<div> | ||
<Button id="btn-cancel" text="Cancel" onClick={props.toggle} intent={Intent.NONE} /> | ||
<Button id="btn-restart" text="Restart server now" onClick={restartServer} intent={Intent.DANGER} /> | ||
</div> | ||
) : ( | ||
<div> | ||
{' '} | ||
<Button id="btn-cancel" text="Close" onClick={props.toggle} intent={Intent.NONE} /> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default ServerControl |
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