mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 08:39:34 +00:00
refactor: allow local shutdown
This commit is contained in:
committed by
Carlos Valente
parent
d8cf1abb37
commit
66083813f9
@@ -18,6 +18,7 @@ const location = window.location;
|
|||||||
const socketProtocol = location.protocol === 'https:' ? 'wss' : 'ws';
|
const socketProtocol = location.protocol === 'https:' ? 'wss' : 'ws';
|
||||||
export const isProduction = import.meta.env.MODE === 'production';
|
export const isProduction = import.meta.env.MODE === 'production';
|
||||||
export const isDev = !isProduction;
|
export const isDev = !isProduction;
|
||||||
|
export const isLocalhost = location.hostname === 'localhost' || location.hostname === '127.0.0.1';
|
||||||
|
|
||||||
// resolve port
|
// resolve port
|
||||||
const STATIC_PORT = 4001;
|
const STATIC_PORT = 4001;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
useDisclosure,
|
useDisclosure,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
|
|
||||||
|
import { isLocalhost } from '../../../../common/api/constants';
|
||||||
import useElectronEvent from '../../../../common/hooks/useElectronEvent';
|
import useElectronEvent from '../../../../common/hooks/useElectronEvent';
|
||||||
import * as Panel from '../PanelUtils';
|
import * as Panel from '../PanelUtils';
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ export default function ShutdownPanel() {
|
|||||||
This will shutdown the Ontime server. <br />
|
This will shutdown the Ontime server. <br />
|
||||||
The runtime state will be lost, but your project is kept for next time.
|
The runtime state will be lost, but your project is kept for next time.
|
||||||
</Panel.Paragraph>
|
</Panel.Paragraph>
|
||||||
<Button colorScheme='red' onClick={onOpen} maxWidth='350px' isDisabled={!isElectron}>
|
<Button colorScheme='red' onClick={onOpen} maxWidth='350px' isDisabled={!(isElectron || isLocalhost)}>
|
||||||
Shutdown ontime
|
Shutdown ontime
|
||||||
</Button>
|
</Button>
|
||||||
<Panel.Description>Note: Ontime can only be shutdown from the machine it is running in.</Panel.Description>
|
<Panel.Description>Note: Ontime can only be shutdown from the machine it is running in.</Panel.Description>
|
||||||
|
|||||||
Reference in New Issue
Block a user