mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 10:53:51 +00:00
use data in <base> componenet to mark ontime cloud status (#1872)
This commit is contained in:
committed by
GitHub
parent
70846aefbe
commit
6f55d8a6c9
@@ -14,4 +14,11 @@ describe('linkToOTherHost', () => {
|
||||
const destination = linkToOtherHost('cloud.getontime.no', 'path', serverUrl, baseUri);
|
||||
expect(destination).toBe('https://cloud.getontime.no/user-hash/path');
|
||||
});
|
||||
|
||||
it('should handle ontime app links', () => {
|
||||
const serverUrl = 'https://app.getontime.no/user-hash';
|
||||
const baseUri = 'user-hash';
|
||||
const destination = linkToOtherHost('app.getontime.no', 'path', serverUrl, baseUri);
|
||||
expect(destination).toBe('https://app.getontime.no/user-hash/path');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ export const isProduction = import.meta.env.PROD;
|
||||
export const isDev = import.meta.env.DEV;
|
||||
export const currentHostName = window.location.hostname;
|
||||
export const isLocalhost = currentHostName === 'localhost' || currentHostName === '127.0.0.1';
|
||||
export const isOntimeCloud = currentHostName.includes('cloud.getontime.no');
|
||||
export const isOntimeCloud = document.querySelector('base')?.hasAttribute('data-is-cloud')
|
||||
|
||||
// resolve entrypoint URLs
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
|
||||
import { srcFiles } from './setup/index.js';
|
||||
import { isOntimeCloud } from './setup/environment.js';
|
||||
|
||||
// =================================================
|
||||
export const password = process.env.SESSION_PASSWORD;
|
||||
@@ -23,7 +24,7 @@ export function updateRouterPrefix(prefix: string | undefined = routerPrefix): s
|
||||
try {
|
||||
const data = readFileSync(srcFiles.clientIndexHtml, { encoding: 'utf-8', flag: 'r' }).replace(
|
||||
'<base href="/" />',
|
||||
`<base href="/${prefix}/" />`,
|
||||
`<base href="/${prefix}/" ${isOntimeCloud ? 'data-is-cloud' : ''}/>`,
|
||||
);
|
||||
writeFileSync(srcFiles.clientIndexHtml, data, { encoding: 'utf-8', flag: 'w' });
|
||||
} catch (_error) {
|
||||
|
||||
+2
-2
@@ -22,13 +22,13 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "turbo run dev",
|
||||
"dev:prefix": "cross-env ROUTER_PREFIX=test turbo run dev --filter=ontime-server",
|
||||
"dev:prefix": "cross-env ROUTER_PREFIX=test cross-env IS_CLOUD=True turbo run dev --filter=ontime-server",
|
||||
"dev:electron": "turbo run dev:electron",
|
||||
"lint": "turbo run lint",
|
||||
"typecheck": "turbo run typecheck",
|
||||
"build": "turbo run build",
|
||||
"build:docker": "cross-env NODE_ENV=docker turbo run build --filter=ontime-server --filter=ontime-ui",
|
||||
"build:resolver": "cross-env turbo run build --filter=@getontime/resolver",
|
||||
"build:resolver": "turbo run build --filter=@getontime/resolver",
|
||||
"dist-win": "turbo run dist-win",
|
||||
"dist-mac": "turbo run dist-mac",
|
||||
"dist-linux": "turbo run dist-linux",
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
"dev": {
|
||||
"cache": false,
|
||||
"persistent": true,
|
||||
"env": ["ROUTER_PREFIX"]
|
||||
"env": ["ROUTER_PREFIX", "IS_CLOUD"]
|
||||
},
|
||||
"dev:electron": {
|
||||
"cache": false,
|
||||
|
||||
Reference in New Issue
Block a user