From 66083813f9a3e858c637987f1f481d4c0c82d1b0 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Wed, 18 Sep 2024 21:22:47 +0200 Subject: [PATCH] refactor: allow local shutdown --- apps/client/src/common/api/constants.ts | 1 + .../app-settings/panel/shutdown-panel/ShutdownPanel.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/client/src/common/api/constants.ts b/apps/client/src/common/api/constants.ts index 936317936..3c0873a9c 100644 --- a/apps/client/src/common/api/constants.ts +++ b/apps/client/src/common/api/constants.ts @@ -18,6 +18,7 @@ const location = window.location; const socketProtocol = location.protocol === 'https:' ? 'wss' : 'ws'; export const isProduction = import.meta.env.MODE === 'production'; export const isDev = !isProduction; +export const isLocalhost = location.hostname === 'localhost' || location.hostname === '127.0.0.1'; // resolve port const STATIC_PORT = 4001; diff --git a/apps/client/src/features/app-settings/panel/shutdown-panel/ShutdownPanel.tsx b/apps/client/src/features/app-settings/panel/shutdown-panel/ShutdownPanel.tsx index 54197e9ec..cf23a4d61 100644 --- a/apps/client/src/features/app-settings/panel/shutdown-panel/ShutdownPanel.tsx +++ b/apps/client/src/features/app-settings/panel/shutdown-panel/ShutdownPanel.tsx @@ -10,6 +10,7 @@ import { useDisclosure, } from '@chakra-ui/react'; +import { isLocalhost } from '../../../../common/api/constants'; import useElectronEvent from '../../../../common/hooks/useElectronEvent'; import * as Panel from '../PanelUtils'; @@ -31,7 +32,7 @@ export default function ShutdownPanel() { This will shutdown the Ontime server.
The runtime state will be lost, but your project is kept for next time. - Note: Ontime can only be shutdown from the machine it is running in.