diff --git a/io-package.json b/io-package.json index 3c056368..a9756171 100644 --- a/io-package.json +++ b/io-package.json @@ -98,15 +98,15 @@ "titleLang": { "en": "E-Charts", "de": "E-Charts", - "ru": "E-диаграмма", + "ru": "E-Charts", "pt": "E-Charts", - "nl": "E-Grafieken", + "nl": "E-Charts", "fr": "E-Charts", "it": "E-Charts", "es": "E-Charts", - "pl": "Wykresy elektroniczne", - "uk": "E-діаграма", - "zh-cn": "电子图" + "pl": "E-Charts", + "uk": "E-Charts", + "zh-cn": "E-Charts" }, "desc": { "en": "Build useful charts in ioBroker", diff --git a/src-chart/index.html b/src-chart/index.html index 8e713510..a42180e8 100644 --- a/src-chart/index.html +++ b/src-chart/index.html @@ -34,12 +34,7 @@ }; script.src = parseInt(window.location.port) >= 3000 && parseInt(window.location.port) <= 3020 - ? window.location.protocol + - '//' + - (query.host || window.location.hostname) + - ':' + - (query.port || 8081) + - '/lib/js/socket.io.js' + ? `${window.location.protocol}//${query.host || window.location.hostname}:${query.port || 8081}/lib/js/socket.io.js` : '../../lib/js/socket.io.js'; document.head.appendChild(script); diff --git a/src-chart/public/index.html b/src-chart/public/index.html deleted file mode 100644 index b6829912..00000000 --- a/src-chart/public/index.html +++ /dev/null @@ -1,38 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="utf-8"/> - <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"/> - <meta - name="viewport" - content="width=device-width, initial-scale=1, shrink-to-fit=no" - /> - <meta name="theme-color" content="#000000"/> - <!-- - manifest.json provides metadata used when your web app is added to the - homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/ - --> - <link rel="manifest" href="%PUBLIC_URL%/manifest.json"/> - <script> - var script = document.createElement('script'); - window.registerSocketOnLoad = function (cb) { - window.socketLoadedHandler = cb; - }; - const parts = (window.location.search || '').replace(/^\?/, '').split('&'); - const query = {}; - parts.forEach(item => { - const [name, val] = item.split('='); - query[decodeURIComponent(name)] = val !== undefined ? decodeURIComponent(val) : true; - }); - script.onload = function () { typeof window.socketLoadedHandler === 'function' && window.socketLoadedHandler(); }; - script.src = parseInt(window.location.port) >= 3000 && parseInt(window.location.port) <= 3020 ? window.location.protocol + '//' + (query.host || window.location.hostname) + ':' + (query.port || 8081) + '/lib/js/socket.io.js' : '%PUBLIC_URL%/../../lib/js/socket.io.js'; - - document.head.appendChild(script); - </script> - <title>Echarts [ioBroker]</title> -</head> -<body> -<noscript>You need to enable JavaScript to run this app.</noscript> -<div id="root"></div> -</body> -</html> diff --git a/src-chart/src/App.tsx b/src-chart/src/App.tsx index b0418440..59538330 100644 --- a/src-chart/src/App.tsx +++ b/src-chart/src/App.tsx @@ -164,6 +164,8 @@ class App extends Component<AppProps, AppState> { I18n.setTranslations(translations); + // window.socketUrl = 'http://192.168.1.67:8081/'; + if (window.socketUrl && window.socketUrl.startsWith(':')) { window.socketUrl = `${window.location.protocol}//${window.location.hostname}${window.socketUrl}`; } @@ -350,9 +352,7 @@ class App extends Component<AppProps, AppState> { const config: ChartConfigMore = this.chartData.getConfig() as ChartConfigMore; // get IDs hash - const hash = MD5( - JSON.stringify(((config && config.l && config.l.map(item => item.id)) || []).sort()), - ).toString(); + const hash = MD5(JSON.stringify((config?.l?.map(item => item.id) || []).sort())).toString(); if (this.state.seriesData && config.debug) { console.log(`seriesData: ${JSON.stringify(this.state.seriesData)}`); diff --git a/src-chart/src/Components/ChartModel.ts b/src-chart/src/Components/ChartModel.ts index 7f2a8e81..4329353c 100644 --- a/src-chart/src/Components/ChartModel.ts +++ b/src-chart/src/Components/ChartModel.ts @@ -330,7 +330,8 @@ function normalizeConfig(config: ChartConfigOld): ChartConfig { newConfig.marks = newConfig.marks || []; - if (!newConfig.l.length) { + if (!newConfig.l?.length) { + config.l = config.l || []; config.l.push({ id: '', unit: '' }); } @@ -880,7 +881,11 @@ class ChartModel { break; } } - } else if (typeof this.config.range === 'string' && this.config.range.includes('y') && this.config.l.length > 1) { + } else if ( + typeof this.config.range === 'string' && + this.config.range.includes('y') && + this.config.l.length > 1 + ) { const yearRange = parseInt(this.config.range as string, 10) || 1; for (let a = 0; a < this.config.l.length; a++) { if (this.config.l[a].offset) { @@ -1873,11 +1878,7 @@ class ChartModel { changed && this.onUpdateFunc(null, this.actualValues); }; - static addTime( - time: number | Date, - offset: string | number, - isOffsetInMinutes?: boolean, - ): number { + static addTime(time: number | Date, offset: string | number, isOffsetInMinutes?: boolean): number { const date: Date = new Date(time); if (typeof offset === 'string') { @@ -1893,7 +1894,7 @@ class ChartModel { time = date.getTime(); if (isOffsetInMinutes) { time -= (parseInt(offset, 10) || 0) * 60000; - }else { + } else { time -= (parseInt(offset, 10) || 0) * 1000; } } diff --git a/src-editor/src/App.tsx b/src-editor/src/App.tsx index 9e4c6c4a..adf3709d 100644 --- a/src-editor/src/App.tsx +++ b/src-editor/src/App.tsx @@ -133,23 +133,23 @@ function parseHash(): Record<string, any> | null { } interface AppState extends GenericAppState { - selectedId: SelectedChart; - scrollToSelect: boolean; + autoSave: boolean; + chartsList: { id: string; instance: string }[] | null; + discardChangesConfirmDialog: false | 'chart' | 'preset' | 'folder'; instances: ioBroker.InstanceObject[]; - ready: boolean; - splitSizes: [number, number]; + logHorzLayout: boolean; + menuOpened: boolean; menuSizes: [number, number]; - selectedPresetChanged: boolean; - presetData: null | ChartConfigMore; originalPresetData: null | string; - chartsList: { id: string; instance: string }[] | null; - systemConfig: ioBroker.SystemConfigObject; - menuOpened: boolean; + presetData: null | ChartConfigMore; progress: 0 | 1 | 2 | 3; - autoSave: boolean; - discardChangesConfirmDialog: false | 'chart' | 'preset' | 'folder'; + ready: boolean; resizing: boolean; - logHorzLayout: boolean; + scrollToSelect: boolean; + selectedId: SelectedChart; + selectedPresetChanged: boolean; + splitSizes: [number, number]; + systemConfig: ioBroker.SystemConfigObject; } class App extends GenericApp<GenericAppProps, AppState> { diff --git a/src-editor/src/MainChart.tsx b/src-editor/src/MainChart.tsx index 3e3a3d39..303a2f52 100644 --- a/src-editor/src/MainChart.tsx +++ b/src-editor/src/MainChart.tsx @@ -63,11 +63,13 @@ class MainChart extends React.Component<MainChartProps> { display: this.props.visible ? 'block' : 'none', }} > - <ChartFrame - src={`${URL}index.html?edit=1`} - presetData={data} - theme={this.props.theme} - /> + {this.props.visible ? ( + <ChartFrame + src={`${URL}index.html?edit=1`} + presetData={data} + theme={this.props.theme} + /> + ) : null} </div> ); }