1818import { IconSet , IconSets , OrIconSet , createSvgIconSet } from '@openremote/or-icon' ;
1919import { html } from 'lit' ;
2020import * as Core from '@openremote/core' ;
21- import { APIService } from '../services/api-service' ;
2221import { getRootPath } from './util' ;
22+ import { manager } from '@openremote/core' ;
2323
2424/**
25- * Base theme settings
26- */
27- const BASE_THEME = {
28- color1 : Core . DefaultColor1 ,
29- color2 : Core . DefaultColor2 ,
30- color3 : Core . DefaultColor3 ,
31- color4 : Core . DefaultColor4 ,
32- color5 : Core . DefaultColor5 ,
33- color6 : Core . DefaultColor6
34- } ;
35-
36- /**
37- * Setup the MDI-Icons for or-icon element
25+ * Initialize icon sets, overriding the default createMdiIconSet with a custom implementation to allow custom urls
26+ * Creates a custom MDI icon set that uses static font files from the assets directory
27+ * and registers both MDI and OR icon sets for use with or-icon elements
3828 */
3929export function setupORIcons ( ) {
4030 function createMdiIconSet ( ) : IconSet {
@@ -67,6 +57,18 @@ export function setupORIcons() {
6757 IconSets . addIconSet ( 'or' , createSvgIconSet ( OrIconSet . size , OrIconSet . icons ) ) ;
6858}
6959
60+ /**
61+ * Base theme settings
62+ */
63+ const BASE_THEME = {
64+ color1 : Core . DefaultColor1 ,
65+ color2 : Core . DefaultColor2 ,
66+ color3 : Core . DefaultColor3 ,
67+ color4 : Core . DefaultColor4 ,
68+ color5 : Core . DefaultColor5 ,
69+ color6 : Core . DefaultColor6
70+ } ;
71+
7072/**
7173 * Theme settings
7274 */
@@ -92,9 +94,11 @@ export async function setRealmTheme(realm: string) {
9294 }
9395
9496 try {
95- const config = await APIService . getOpenRemoteRealmConfig ( realm ) ;
96- if ( config && config . styles ) {
97- const cssString = config . styles ;
97+ const config = ( await manager . rest . api . ConfigurationResource . getManagerConfig ( ) ) . data ;
98+ const styles = config . realms ?. [ realm ] ?. styles ;
99+
100+ if ( styles ) {
101+ const cssString = styles ;
98102 const colorRegex = / - - o r - a p p - c o l o r ( \d + ) : \s * ( # [ 0 - 9 a - f A - F ] { 6 } ) / g;
99103 let match : RegExpExecArray | null ;
100104
@@ -128,7 +132,6 @@ export async function setRealmTheme(realm: string) {
128132 } catch {
129133 console . warn ( 'Was unable to retrieve realm specific theme settings, falling back to default' ) ;
130134 }
131-
132135 setTheme ( theme ) ;
133136}
134137
0 commit comments