Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Jan 7, 2025
1 parent 0b05d53 commit 396e079
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 77 deletions.
10 changes: 5 additions & 5 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions src-chart/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 0 additions & 38 deletions src-chart/public/index.html

This file was deleted.

6 changes: 3 additions & 3 deletions src-chart/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down Expand Up @@ -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)}`);
Expand Down
17 changes: 9 additions & 8 deletions src-chart/src/Components/ChartModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' });
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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') {
Expand All @@ -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;
}
}
Expand Down
24 changes: 12 additions & 12 deletions src-editor/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
12 changes: 7 additions & 5 deletions src-editor/src/MainChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
}
Expand Down

0 comments on commit 396e079

Please sign in to comment.