diff --git a/packages/admin/src/src/components/Instances/LinksDialog.tsx b/packages/admin/src/src/components/Instances/LinksDialog.tsx index ed7fcf505..9e262fd66 100644 --- a/packages/admin/src/src/components/Instances/LinksDialog.tsx +++ b/packages/admin/src/src/components/Instances/LinksDialog.tsx @@ -11,9 +11,11 @@ import { Avatar, } from '@mui/material'; +import { I18n } from '@iobroker/adapter-react-v5'; import type { ThemeType } from '@iobroker/adapter-react-v5/types'; import Utils from '../Utils'; +import BasicUtils from '../../Utils'; const styles: Record = { img: { @@ -23,7 +25,7 @@ const styles: Record = { }; interface LinksDialogProps { - links: { name: string; link: string; port: number; color: string }[]; + links: { name: ioBroker.StringOrTranslated; link: string; port: number; color: string }[]; onClose: () => void; t: (text: string, ...args: any[]) => string; instanceId: string; @@ -56,14 +58,14 @@ class LinksDialog extends Component { window.open(url, this.props.instanceId); this.props.onClose(); }} - key={link.name} + key={BasicUtils.getText(link.name, I18n.getLanguage())} > {this.props.instanceId} - + )} ; diff --git a/packages/admin/src/src/components/ObjectBrowser.tsx b/packages/admin/src/src/components/ObjectBrowser.tsx index 877d0328f..38c20e916 100644 --- a/packages/admin/src/src/components/ObjectBrowser.tsx +++ b/packages/admin/src/src/components/ObjectBrowser.tsx @@ -277,24 +277,6 @@ export interface TreeItemData { // language in what the rooms and functions where translated lang?: ioBroker.Languages; state?: { - /** value for copy as text */ - val?: string; - valText: { - /** value as string */ - v: string; - /** value unit */ - u?: string; - /** value not replaced by `common.states` */ - s?: string; - }; - valFull: { - /** label */ - t: string; - /** value */ - v: string; - /** no break */ - nbr?: boolean; - }[] | null; valFullRx?: React.JSX.Element[] | null; valTextRx?: React.JSX.Element[] | null; style?: React.CSSProperties; @@ -2606,7 +2588,7 @@ class ObjectBrowser extends Component { selected = selected.map(id => id.replace(/["']/g, '')).filter(id => id); const columnsStr = this.localStorage.getItem(`${props.dialogName || 'App'}.columns`); - let columns: string[] | null = null; + let columns: string[] | null; try { columns = columnsStr ? JSON.parse(columnsStr) : null; } catch (e) { @@ -3414,19 +3396,22 @@ class ObjectBrowser extends Component { ; } - private getAdditionalColumns(): Promise | null> { - return this.props.socket - .getAdapters() - .then(instances => { - let columnsForAdmin: Record | null = null; - // find all additional columns - instances.forEach(obj => (columnsForAdmin = this.parseObjectForAdmins(columnsForAdmin, obj))); + private async getAdditionalColumns(): Promise | null> { + try { + const instances = await this.props.socket + .getAdapters(); - return columnsForAdmin; - }) + let columnsForAdmin: Record | null = null; + // find all additional columns + instances.forEach(obj => (columnsForAdmin = this.parseObjectForAdmins(columnsForAdmin, obj))); + + return columnsForAdmin; + } catch (err) { // window.alert('Cannot get adapters: ' + e); // Object browser in Web has no additional columns - .catch(() => null); + console.error(`Cannot get adapters: ${err}`); + return null; + } } private checkUnsubscribes() { @@ -5068,17 +5053,18 @@ class ObjectBrowser extends Component { let info = item.data.state; if (!info) { - item.data.state = formatValue({ + const { valFull, valText } = formatValue({ state, obj: obj as ioBroker.StateObject, texts: this.texts, dateFormat: this.props.dateFormat, isFloatComma: this.props.isFloatComma, }); + item.data.state = { valFullRx: [], valTextRx: [] }; + info = item.data.state; - info.valFullRx = []; - info.valFull.forEach(_item => { + valFull.forEach(_item => { if (_item.t === this.texts.quality && state.q) { info.valFullRx.push(
{_item.t} @@ -5117,24 +5103,23 @@ class ObjectBrowser extends Component { />); } - const copyText = info.valText.v || ''; - info.val = copyText; + const copyText = valText.v || ''; info.valTextRx = []; - info.valTextRx.push( - {info.valText.v.toString()} + info.valTextRx.push( + {valText.v.toString()} ); - info.valText.u && info.valTextRx.push( - {info.valText.u} + {valText.u} ); - info.valText.s !== undefined && info.valTextRx.push( ( - {info.valText.s} + {valText.s} ) ); info.valTextRx.push( { /** * Find the id from the root - * - * @param {Record} root The current root - * @param {string} id the object id - * - * @returns {any} */ - getItemFromRoot(root: TreeItem, id: string) { + private getItemFromRoot( + /** The current root */ + root: TreeItem, + /** the object id to find */ + id: string, + ): TreeItem | null { const idArr = id.split('.'); let currId = '';