Warning, /firebird/firebird-ng/src/app/services/persistent-config.service.backup.ts is written in an unsupported language. File is not indexed.
0001 import { Injectable } from '@angular/core';
0002 import {ConfigProperty} from '../utils/config-property';
0003
0004 @Injectable({
0005 providedIn: 'root',
0006 })
0007 export class PersistentConfigService {
0008 public geometryUrl: ConfigProperty<string>;
0009 public geometryThemeName: ConfigProperty<string>;
0010 public geometryCutListName: ConfigProperty<string>;
0011 public geometryFastAndUgly: ConfigProperty<boolean>;
0012 public geometryRootFilterName: ConfigProperty<string>;
0013 public dexJsonEventSource: ConfigProperty<string>;
0014 public rootEventSource: ConfigProperty<string>;
0015 public rootEventRange: ConfigProperty<string>;
0016 public localServerUseApi: ConfigProperty<boolean>;
0017 public localServerUrl: ConfigProperty<string>;
0018
0019 //public clippingEnabled: PersistentProperty<boolean>;
0020 public clippingStartAngle: ConfigProperty<number>;
0021 public clippingOpeningAngle: ConfigProperty<number>;
0022 public uiSelectedTheme: ConfigProperty<string>;
0023 public useController: ConfigProperty<boolean>;
0024
0025 public configsByName: Map<string, ConfigProperty<any>> = new Map();
0026
0027 // Generic getter with type safety
0028 public getConfig<T>(key: string): ConfigProperty<T> | undefined {
0029 return this.configsByName.get(key) as ConfigProperty<T> | undefined;
0030 }
0031
0032 // Generic getter that throws if property doesn't exist
0033 public getConfigOrThrow<T>(key: string): ConfigProperty<T> {
0034 const property = this.configsByName.get(key);
0035 if (!property) {
0036 throw new Error(`Property '${key}' not found`);
0037 }
0038 return property as ConfigProperty<T>;
0039 }
0040
0041 // Register a property
0042 public addConfig<T>(key: string, property: ConfigProperty<T>): void {
0043 this.configsByName.set(key, property);
0044 }
0045
0046
0047 constructor() {
0048
0049
0050 this.geometryUrl = new ConfigProperty('geometry.selectedGeometry', 'https://eic.github.io/epic/artifacts/tgeo/epic_craterlake.root');
0051 this.geometryFastAndUgly = new ConfigProperty('geometry.FastDefaultMaterial', false);
0052 this.geometryCutListName = new ConfigProperty('geometry.cutListName', "central");
0053 this.geometryThemeName = new ConfigProperty('geometry.themeName', "cool2");
0054 this.geometryRootFilterName = new ConfigProperty('geometry.rootFilterName', "default");
0055 this.dexJsonEventSource = new ConfigProperty('events.dexEventsSource', '');
0056 this.rootEventSource = new ConfigProperty('events.rootEventSource', '');
0057 this.rootEventRange = new ConfigProperty('events.rootEventRange', '0-5');
0058 this.localServerUseApi = new ConfigProperty('server.useApi', false);
0059 this.localServerUrl = new ConfigProperty('server.url', 'http://localhost:5454');
0060 //this.clippingEnabled = new PersistentProperty<boolean>('geometry.clippingEnabled', true);
0061
0062 this.configsByName.set('geometry.clippingEnabled', new ConfigProperty<boolean>('geometry.clippingEnabled', true));
0063
0064 this.uiSelectedTheme = new ConfigProperty('ui.theme', 'system', undefined,
0065 /* validator */ (val) => val === 'dark' || val === 'light' || val === 'system'
0066 );
0067
0068
0069 this.clippingStartAngle = new ConfigProperty<number>('geometry.clippingStartAngle', 90, undefined,
0070 /* validator */ (val) => val >= 0 && val <= 360 // Provide an optional validator ensuring 0 <= angle <= 360
0071 );
0072
0073 this.clippingOpeningAngle = new ConfigProperty<number>('clipping.openingAngle', 180, undefined,
0074 /* validator */ (val) => val >= 0 && val <= 360 // Provide an optional validator ensuring 0 <= angle <= 360
0075 );
0076
0077 this.useController = new ConfigProperty<boolean>('controls.useController', false);
0078 }
0079
0080 get clippingEnabled(): ConfigProperty<boolean> {
0081 return this.configsByName.get('geometry.clippingEnabled') as ConfigProperty<boolean>;
0082 }
0083
0084 }