@iobroker/gui-components 10.3.3 → 10.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/build/Components/Schedule.d.ts +2 -0
- package/build/Components/Schedule.js +12 -4
- package/build/Components/Schedule.js.map +1 -1
- package/build/Components/Utils.d.ts +10 -1
- package/build/Components/Utils.js +29 -1
- package/build/Components/Utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2018-
|
|
2
|
+
* Copyright 2018-2026 Denis Haev <dogafox@gmail.com>
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import type { Types } from '@iobroker/type-detector';
|
|
9
|
+
import type { Connection } from '../Connection';
|
|
9
10
|
import type { IobTheme, ThemeName, ThemeType } from '../types';
|
|
10
11
|
type SmartNameObject = {
|
|
11
12
|
[lang in ioBroker.Languages]?: string;
|
|
@@ -105,6 +106,14 @@ export declare class Utils {
|
|
|
105
106
|
* Get the icon for the given object.
|
|
106
107
|
*/
|
|
107
108
|
static getObjectIcon(id: string | ioBroker.PartialObject, obj?: ioBroker.PartialObject): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Finds the icon for the given object id, searching up the hierarchy if necessary.
|
|
111
|
+
*
|
|
112
|
+
* @param id The object id to find the icon for.
|
|
113
|
+
* @param socket The socket connection to use for fetching objects.
|
|
114
|
+
* @param objects Optional pre-fetched objects to avoid redundant socket calls.
|
|
115
|
+
*/
|
|
116
|
+
static findObjectIcon(id: string, socket: Connection, objects?: Record<string, ioBroker.Object>): Promise<string | null>;
|
|
108
117
|
/**
|
|
109
118
|
* Converts word1_word2 to word1Word2.
|
|
110
119
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2018-
|
|
2
|
+
* Copyright 2018-2026 Denis Haev <dogafox@gmail.com>
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -409,6 +409,34 @@ export class Utils {
|
|
|
409
409
|
}
|
|
410
410
|
return null;
|
|
411
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* Finds the icon for the given object id, searching up the hierarchy if necessary.
|
|
414
|
+
*
|
|
415
|
+
* @param id The object id to find the icon for.
|
|
416
|
+
* @param socket The socket connection to use for fetching objects.
|
|
417
|
+
* @param objects Optional pre-fetched objects to avoid redundant socket calls.
|
|
418
|
+
*/
|
|
419
|
+
static async findObjectIcon(id, socket, objects) {
|
|
420
|
+
objects ||= {};
|
|
421
|
+
if (objects[id]?.common?.icon) {
|
|
422
|
+
return Promise.resolve(Utils.getObjectIcon(id, objects[id]));
|
|
423
|
+
}
|
|
424
|
+
const state = await socket.getObject(id);
|
|
425
|
+
if (state && (state.type === 'state' || state.type === 'channel' || state.type === 'device')) {
|
|
426
|
+
objects[id] = state;
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
return Promise.resolve(null);
|
|
430
|
+
}
|
|
431
|
+
if (state.common?.icon) {
|
|
432
|
+
return Promise.resolve(Utils.getObjectIcon(id, state));
|
|
433
|
+
}
|
|
434
|
+
if (state.type === 'state' || state.type === 'channel') {
|
|
435
|
+
const parentId = id.substring(0, id.lastIndexOf('.'));
|
|
436
|
+
return Utils.findObjectIcon(parentId, socket, objects);
|
|
437
|
+
}
|
|
438
|
+
return Promise.resolve(null);
|
|
439
|
+
}
|
|
412
440
|
/**
|
|
413
441
|
* Converts word1_word2 to word1Word2.
|
|
414
442
|
*/
|