Skip to content

Commit

Permalink
Longitude not undefined (#2884)
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox authored Dec 29, 2024
1 parent e0284ce commit 7ba350b
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ packages/admin/README.md
/packages/jsonConfig/test/testSchema.js
/packages/jsonConfig/test/testSchema.js.map
/packages/adapter-react-v5/i18n/
/packages/adapter-react-v5/index.css
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The icons may not be reused in other projects without the proper flaticon licens
<!--
### **WORK IN PROGRESS**
-->
### 7.4.9 (2024-12-29)
### **WORK IN PROGRESS**

- (@GermanBluefox) Corrected JSON-Config tables
- (@GermanBluefox) Corrected translation on the update adapter dialog
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-react-v5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you want to create the configuration page with ReactJS:
- Change `name` from `src` to `ADAPTERNAME-admin` (Of course replace `ADAPTERNAME` with yours)
- Add to devDependencies:
```json
"@iobroker/adapter-react-v5": "^7.4.8",
"@iobroker/adapter-react-v5": "^7.4.9",
```
Versions can be higher.
So your `src/package.json` should look like:
Expand All @@ -24,7 +24,7 @@ If you want to create the configuration page with ReactJS:
"version": "0.1.0",
"private": true,
"dependencies": {
"@iobroker/adapter-react-v5": "^7.4.8",
"@iobroker/adapter-react-v5": "^7.4.9",
"@iobroker/build-tools": "^1.0.0",
"babel-eslint": "^10.1.0",
"react-scripts": "^5.0.1"
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-react-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"files": [
"build/",
"i18n/",
"index.css",
"LICENSE",
"tasksExample.js",
"craco-module-federation.js",
Expand Down
24 changes: 22 additions & 2 deletions packages/adapter-react-v5/src/Components/ObjectBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3277,9 +3277,29 @@ export class ObjectBrowserClass extends Component<ObjectBrowserProps, ObjectBrow
this.localStorage.removeItem(`${this.props.dialogName || 'App'}.objectSelected`);

if (this.state.selected.length) {
this.setState({ selected: [] }, () => this.props.onSelect && this.props.onSelect([], ''));
this.setState({ selected: [] }, () => {
if (this.props.onSelect) {
if (this.state.focused && this.props.allowNonObjects) {
// remove a task to select the pre-selected item if now we want to see another object
if (this.selectFirst && this.selectFirst !== this.state.selected[0]) {
this.selectFirst = '';
}
this.props.onSelect([this.state.focused], null, isDouble);
} else {
this.props.onSelect([], '');
}
}
});
} else if (this.props.onSelect) {
this.props.onSelect([], '');
if (this.state.focused && this.props.allowNonObjects) {
// remove a task to select the pre-selected item if now we want to see another object
if (this.selectFirst && this.selectFirst !== this.state.selected[0]) {
this.selectFirst = '';
}
this.props.onSelect([this.state.focused], null, isDouble);
} else {
this.props.onSelect([], '');
}
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion packages/adapter-react-v5/src/LegacyConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ declare global {
}
}

type LogMessage = {
/** Log message */
message: string;
/** origin */
from: string;
/** timestamp in ms */
ts: number;
/** Log message */
severity: ioBroker.LogLevel;
/** unique ID of the message */
_id: number;
};

export type Severity = 'info' | 'notify' | 'alert';

type DockerInformation =
Expand Down Expand Up @@ -178,7 +191,7 @@ interface ConnectionProps {
/** Ready callback. */
onReady?: (objects: Record<string, ioBroker.Object>) => void;
/** Log callback. */
onLog?: (text: string) => void;
onLog?: (message: LogMessage) => void;
/** Error callback. */
onError?: (error: any) => void;
/** Object change callback. */
Expand Down
15 changes: 14 additions & 1 deletion packages/adapter-react-v5/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ import type Router from './Components/Router';

export type Translate = (key: string, ...args: (string | number | boolean)[]) => string;

export type LogMessage = {
/** Log message */
message: string;
/** origin */
from: string;
/** timestamp in ms */
ts: number;
/** Log message */
severity: ioBroker.LogLevel;
/** unique ID of the message */
_id: number;
};

/**
* Properties for the connection to the admin or web instance.
*/
Expand Down Expand Up @@ -34,7 +47,7 @@ export interface ConnectionProps {
/** Ready callback. */
onReady?: (objects: Record<string, ioBroker.Object>) => void;
/** Log callback. */
onLog?: (text: string) => void;
onLog?: (text: LogMessage) => void;
/** Error callback. */
onError?: (error: any) => void;
/** Object change callback. */
Expand Down
1 change: 1 addition & 0 deletions packages/adapter-react-v5/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function copyAllFiles() {
'build/assets',
);
copyFiles(['src/i18n/*.json'], 'i18n');
copyFiles(['src/index.css'], './');
// copyFiles(['README.md', 'LICENSE'], 'build');
// copyFileSync('tasksExample.js', 'build/tasks.js');
copyFiles(['src/*.css'], 'build');
Expand Down
13 changes: 0 additions & 13 deletions packages/admin/io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@
"connectionType": "local",
"dataSource": "push",
"news": {
"7.4.9": {
"en": "Corrected JSON-Config tables\nCorrected translation on the update adapter dialog",
"de": "Korrektur der JSON-Config-Tabellen\nKorrigierte Übersetzung im Update Adapter Dialog",
"ru": "Исправленные таблицы JSON-Config\nИсправлен перевод на диалог адаптера обновления",
"pt": "Tabelas corretas de JSON-Config\nTradução correta na caixa de diálogo do adaptador de atualização",
"nl": "Gecorrigeerde JSON-config tabellen\nGecorrigeerde vertaling in het dialoogvenster Updateadapter",
"fr": "Tableaux JSON-Config corrigés\nTraduction corrigée sur la boîte de dialogue de l'adaptateur de mise à jour",
"it": "Tavoli JSON-Config corretti\nTraduzione corretta sulla finestra di dialogo dell'adattatore di aggiornamento",
"es": "Cuadros JSON-Config corregidos\nTraducción corregida en el diálogo del adaptador de actualización",
"pl": "Poprawione tabele JSON- Config\nPoprawione tłumaczenie w oknie aktualizacji adaptera",
"uk": "Виправлені JSON-Config таблиці\nВиправлений переклад на діалоговому вікні адаптера оновлення",
"zh-cn": "更正的 JSON 图表\n在更新适配器对话框上更正的翻译"
},
"7.4.8": {
"en": "Show latest/stable labels by updating/downgrading of adapters\nCorrected selection of chinese language",
"de": "Neueste/stabile Etiketten durch Aktualisierung/Abbau von Adaptern anzeigen\nKorrigierte Auswahl der chinesischen Sprache",
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@
}
]
],
"version": "7.4.8"
"version": "7.4.9"
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ class WizardSettingsTab extends Component<WizardSettingsTabProps, WizardSettings
}

positionReady(position: { coords: { latitude: number; longitude: number } }): void {
const latitude = parseFloat(position.coords.latitude.toFixed(8));
const longitude = parseFloat(position.coords.longitude.toFixed(8));

this.setState(
{
latitude: parseFloat(position.coords.latitude.toFixed(8)),
longitude: parseFloat(position.coords.longitude.toFixed(8)),
latitude: isNaN(latitude) ? '' : latitude,
longitude: isNaN(longitude) ? '' : longitude,
},
() => this.changeMapPosition(),
);
Expand All @@ -207,8 +210,8 @@ class WizardSettingsTab extends Component<WizardSettingsTabProps, WizardSettings
country: systemConfig.common.country,
city: systemConfig.common.city,
address: '',
longitude: systemConfig.common.longitude,
latitude: systemConfig.common.latitude,
longitude: systemConfig.common.longitude || '',
latitude: systemConfig.common.latitude || '',
firstDayOfWeek: systemConfig.common.firstDayOfWeek || 'monday',
},
() => this.getBrowserCoordinates(),
Expand Down Expand Up @@ -263,9 +266,9 @@ class WizardSettingsTab extends Component<WizardSettingsTabProps, WizardSettings
onChangePosition = (evt: { target: { value: string } }, id: string): void => {
const value = evt.target.value;
if (id === 'latitude') {
this.setState({ latitude: value });
this.setState({ latitude: value || '' });
} else {
this.setState({ longitude: value });
this.setState({ longitude: value || '' });
}

this.changeMapPosition();
Expand Down Expand Up @@ -806,7 +809,11 @@ class WizardSettingsTab extends Component<WizardSettingsTabProps, WizardSettings
variant="standard"
label={this.props.t('Longitude')}
style={styles.controlItem}
value={this.state.longitude}
value={
this.state.longitude === undefined || this.state.longitude === null
? ''
: this.state.longitude
}
onChange={e => this.onChangePosition(e, 'longitude')}
slotProps={{
input: {
Expand All @@ -829,7 +836,11 @@ class WizardSettingsTab extends Component<WizardSettingsTabProps, WizardSettings
variant="standard"
label={this.props.t('Latitude')}
style={styles.controlItem}
value={this.state.latitude}
value={
this.state.latitude === undefined || this.state.latitude === null
? ''
: this.state.latitude
}
onChange={e => this.onChangePosition(e, 'latitude')}
slotProps={{
input: {
Expand Down

0 comments on commit 7ba350b

Please sign in to comment.