mirror of
https://github.com/jwetzell/showbridge-webui.git
synced 2026-08-12 09:53:40 +00:00
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { computed, Injectable, signal } from '@angular/core';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class SettingsService {
|
|
public isDummySite: boolean = false;
|
|
public configPath = signal('/api/v1/config');
|
|
public configSchemaPath = signal('/schema/config.schema.json');
|
|
public modulesSchemaPath = signal('/schema/modules.schema.json');
|
|
public routesSchemaPath = signal('/schema/routes.schema.json');
|
|
public processorsSchemaPath = signal('/schema/processors.schema.json');
|
|
public wsPath = signal('/ws');
|
|
public baseUrl = signal('http://localhost:8080');
|
|
|
|
public configUrl = computed(() => {
|
|
return new URL(this.configPath(), this.baseUrl());
|
|
});
|
|
|
|
public configSchemaUrl = computed(() => {
|
|
return new URL(this.configSchemaPath(), this.baseUrl());
|
|
});
|
|
|
|
public modulesSchemaUrl = computed(() => {
|
|
return new URL(this.modulesSchemaPath(), this.baseUrl());
|
|
});
|
|
|
|
public routesSchemaUrl = computed(() => {
|
|
return new URL(this.routesSchemaPath(), this.baseUrl());
|
|
});
|
|
|
|
public processorsSchemaUrl = computed(() => {
|
|
return new URL(this.processorsSchemaPath(), this.baseUrl());
|
|
});
|
|
|
|
public wsUrl = computed(() => {
|
|
const url = new URL(this.baseUrl());
|
|
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
url.pathname = this.wsPath();
|
|
return url;
|
|
});
|
|
|
|
constructor() {
|
|
const storedBaseUrl = localStorage.getItem('baseUrl');
|
|
if (storedBaseUrl) {
|
|
this.baseUrl.set(storedBaseUrl);
|
|
}
|
|
}
|
|
|
|
updateBaseUrl(baseUrl: string) {
|
|
this.baseUrl.set(baseUrl);
|
|
localStorage.setItem('baseUrl', baseUrl);
|
|
}
|
|
}
|