fix: cloud should not give IP links

This commit is contained in:
Carlos Valente
2025-03-18 17:53:44 +01:00
committed by Carlos Valente
parent dc73e7e637
commit e28f692d3d
3 changed files with 22 additions and 8 deletions
+4 -3
View File
@@ -19,9 +19,10 @@ export const buyMeACoffeeUrl = 'https://buymeacoffee.com/cpvalente';
export const appVersion = version; export const appVersion = version;
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 = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'; export const currentHostName = window.location.hostname;
export const isLocalhost = currentHostName === 'localhost' || currentHostName === '127.0.0.1';
export const isDockerImage = Boolean(import.meta.env.VITE_IS_DOCKER); export const isDockerImage = Boolean(import.meta.env.VITE_IS_DOCKER);
export const isOntimeCloud = window.location.hostname.includes('cloud.getontime.no'); export const isOntimeCloud = currentHostName.includes('cloud.getontime.no');
// resolve entrypoint URLs // resolve entrypoint URLs
@@ -75,4 +76,4 @@ function resolveBaseURI(): string {
} }
return base; return base;
} }
@@ -39,6 +39,12 @@ export default function GenerateLinkForm() {
formState: { errors }, formState: { errors },
} = useForm<GenerateLinkFormOptions>({ } = useForm<GenerateLinkFormOptions>({
mode: 'onChange', mode: 'onChange',
defaultValues: {
baseUrl: currentHostName,
path: '',
lock: false,
authenticate: false,
},
resetOptions: { resetOptions: {
keepDirtyValues: true, keepDirtyValues: true,
}, },
@@ -72,8 +78,11 @@ export default function GenerateLinkForm() {
</Info> </Info>
<Panel.ListGroup> <Panel.ListGroup>
<Panel.ListItem> <Panel.ListItem>
<Panel.Field title='Host IP' description='Which IP address will be used' /> <Panel.Field
<Select variant='ontime' size='sm' {...register('baseUrl')}> title='Host IP'
description={`Which IP address will be used${isOntimeCloud ? ' (not applicable in Ontime Cloud)' : ''}`}
/>
<Select variant='ontime' isDisabled={isOntimeCloud} size='sm' {...register('baseUrl')}>
{infoData.networkInterfaces.map((nif) => { {infoData.networkInterfaces.map((nif) => {
return ( return (
<option key={nif.name} value={nif.address}> <option key={nif.name} value={nif.address}>
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
import useScrollIntoView from '../../../../common/hooks/useScrollIntoView'; import useScrollIntoView from '../../../../common/hooks/useScrollIntoView';
import { usePing } from '../../../../common/hooks/useSocket'; import { usePing } from '../../../../common/hooks/useSocket';
import { socketSendJson } from '../../../../common/utils/socket'; import { socketSendJson } from '../../../../common/utils/socket';
import { isDockerImage } from '../../../../externals'; import { isDockerImage, isOntimeCloud } from '../../../../externals';
import type { PanelBaseProps } from '../../panel-list/PanelList'; import type { PanelBaseProps } from '../../panel-list/PanelList';
import * as Panel from '../../panel-utils/PanelUtils'; import * as Panel from '../../panel-utils/PanelUtils';
import ClientControlPanel from '../client-control-panel/ClientControlPanel'; import ClientControlPanel from '../client-control-panel/ClientControlPanel';
@@ -30,8 +30,12 @@ export default function NetworkLogPanel({ location }: PanelBaseProps) {
<Panel.Card> <Panel.Card>
<Panel.SubHeader>Share Ontime Link</Panel.SubHeader> <Panel.SubHeader>Share Ontime Link</Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
<Panel.Paragraph>Ontime is streaming on the following network interfaces</Panel.Paragraph> {!isOntimeCloud && (
<InfoNif /> <>
<Panel.Paragraph>Ontime is streaming on the following network interfaces</Panel.Paragraph>
<InfoNif />
</>
)}
<GenerateLinkForm /> <GenerateLinkForm />
</Panel.Card> </Panel.Card>
</Panel.Section> </Panel.Section>