Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI fixes #290

Merged
merged 20 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0ef6aee
Jump from welcome dialog corrected: https://github.com/ioBroker/ioBro…
GermanBluefox Jan 6, 2025
65b314f
Replaced QR-Code scan: https://github.com/ioBroker/ioBroker.matter/is…
GermanBluefox Jan 6, 2025
93c435b
Replaced apple link: https://github.com/ioBroker/ioBroker.matter/issu…
GermanBluefox Jan 6, 2025
723c928
Do not show password: https://github.com/ioBroker/ioBroker.matter/iss…
GermanBluefox Jan 6, 2025
f712698
Added controllerFabricLabel: https://github.com/ioBroker/ioBroker.mat…
GermanBluefox Jan 6, 2025
faf163e
Corrected hint text: https://github.com/ioBroker/ioBroker.matter/issu…
GermanBluefox Jan 6, 2025
e9fe130
Correcting device edit dialog: https://github.com/ioBroker/ioBroker.m…
GermanBluefox Jan 6, 2025
d26f8ad
Correcting color of icon: https://github.com/ioBroker/ioBroker.matter…
GermanBluefox Jan 6, 2025
5369ca3
Added readme
GermanBluefox Jan 6, 2025
f732d09
Correcting naming: https://github.com/ioBroker/ioBroker.matter/issues…
GermanBluefox Jan 6, 2025
f1fbbfa
Added device name to QR-Code dialog: https://github.com/ioBroker/ioBr…
GermanBluefox Jan 6, 2025
01b96b5
Added hint: https://github.com/ioBroker/ioBroker.matter/issues/250
GermanBluefox Jan 6, 2025
b3ac11e
Added code check: https://github.com/ioBroker/ioBroker.matter/issues/260
GermanBluefox Jan 6, 2025
2b77d69
Added code check: https://github.com/ioBroker/ioBroker.matter/issues/260
GermanBluefox Jan 6, 2025
b79b1c6
Changed discovery behaviour: https://github.com/ioBroker/ioBroker.mat…
GermanBluefox Jan 6, 2025
49d5c83
Enhanced welcome dialog: https://github.com/ioBroker/ioBroker.matter/…
GermanBluefox Jan 6, 2025
50d5ef8
Trying to show the device being processed: https://github.com/ioBroke…
GermanBluefox Jan 6, 2025
4428aba
Fixing processing update
GermanBluefox Jan 7, 2025
b49563b
Update README.md
GermanBluefox Jan 7, 2025
24085d8
Update src-admin/src/App.tsx
GermanBluefox Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 32 additions & 28 deletions README.md

Large diffs are not rendered by default.

69 changes: 67 additions & 2 deletions src-admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@types/react-dom": "^18.3.5",
"@types/uuid": "^10.0.0",
"@vitejs/plugin-react": "^4.3.4",
"@yudiel/react-qr-scanner": "^2.1.0",
"qr-scanner": "^1.4.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand All @@ -21,7 +22,7 @@
"uuid": "^11.0.3"
},
"scripts": {
"start": "vite",
"start": "vite --host",
"build": "vite build",
"lint": "eslint -c eslint.config.mjs",
"check-ts": "tsc --noEmit --checkJS false",
Expand Down
92 changes: 82 additions & 10 deletions src-admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
type GenericAppProps,
type GenericAppState,
type IobTheme,
SaveCloseButtons,
DialogConfirm,
} from '@iobroker/adapter-react-v5';
import { clone, getText } from './Utils';

Expand All @@ -42,6 +44,7 @@ import type {
MatterAdapterConfig,
MatterConfig,
NodeStateResponse,
Processing,
} from './types';

import enLang from './i18n/en.json';
Expand Down Expand Up @@ -92,6 +95,8 @@ interface AppState extends GenericAppState {
matter: MatterConfig;
commissioning: CommissioningInfo | null;
nodeStates: { [uuid: string]: NodeStateResponse };
/** Information about nodes being processed */
inProcessing: Processing;
/** Undefined if no detection ran yet */
detectedDevices?: DetectedRoom[];
ready: boolean;
Expand Down Expand Up @@ -169,6 +174,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
progress: null,
showWelcomeDialog: false,
welcomeDialogShowed: false,
inProcessing: null,
});

this.alert = window.alert;
Expand All @@ -182,7 +188,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
heartbeat?: number;
} | null,
): void => {
// backend is alive, so stop connection interval
// backend is alive, so stop a connection interval
if (this.connectToBackEndInterval) {
console.log(`Connected after ${this.connectToBackEndCounter} attempts`);
this.connectToBackEndCounter = 0;
Expand Down Expand Up @@ -303,19 +309,35 @@ class App extends GenericApp<GenericAppProps, AppState> {
return null;
}

const adapterSettings: MatterAdapterConfig = this.state.native as MatterAdapterConfig;

return (
<WelcomeDialog
common={this.common}
instance={this.instance}
socket={this.socket}
onClose={async () => {
themeType={this.state.themeType}
onClose={async (
login?: string,
password?: string,
navigateTo?: 'controller' | 'bridges',
): Promise<void> => {
if (login && password) {
if (adapterSettings.login !== login || adapterSettings.pass !== password) {
this.updateNativeValue('login', login, () => this.updateNativeValue('pass', password));
}
}
if (!this.state.welcomeDialogShowed) {
await this.socket.setState(`matter.${this.instance}.info.welcomeDialog`, true, true);
}
this.setState({ showWelcomeDialog: false, welcomeDialogShowed: true });
this.setState({ showWelcomeDialog: false, welcomeDialogShowed: true }, () => {
if (navigateTo) {
this.setState({ selectedTab: navigateTo });
}
});
}}
login={this.state.native.login}
pass={this.state.native.pass}
login={adapterSettings.login}
pass={adapterSettings.pass}
/>
);
}
Expand All @@ -325,7 +347,9 @@ class App extends GenericApp<GenericAppProps, AppState> {
return;
}

if (update.command === 'progress') {
if (update.command === 'processing') {
this.setState({ inProcessing: update.processing || null });
} else if (update.command === 'progress') {
if (update.progress) {
if (update.progress.close) {
if (this.state.progress) {
Expand Down Expand Up @@ -483,13 +507,16 @@ class App extends GenericApp<GenericAppProps, AppState> {
});
}}
onShowWelcomeDialog={() => this.setState({ showWelcomeDialog: true })}
onLoad={(native: Record<string, any>) => this.onLoadConfig(native)}
onLoad={(native: MatterAdapterConfig) => this.onLoadConfig(native)}
socket={this.socket}
common={this.common}
native={this.state.native as MatterAdapterConfig}
instance={this.instance}
matter={this.state.matter}
showToast={(text: string) => this.showToast(text)}
onError={(errorText: string): void => {
this.setConfigurationError(errorText);
}}
/>
);
}
Expand All @@ -507,6 +534,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
this.setState({ nodeStates: _nodeStates });
}}
nodeStates={this.state.nodeStates}
inProcessing={this.state.inProcessing}
themeName={this.state.themeName}
themeType={this.state.themeType}
theme={this.state.theme}
Expand Down Expand Up @@ -540,6 +568,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
this.setState({ nodeStates: _nodeStates });
}}
nodeStates={this.state.nodeStates}
inProcessing={this.state.inProcessing}
commissioning={this.state.commissioning?.devices || {}}
socket={this.socket}
themeName={this.state.themeName}
Expand All @@ -565,12 +594,14 @@ class App extends GenericApp<GenericAppProps, AppState> {
}

async getLicense(): Promise<string | false> {
if (this.state.native.login && this.state.native.pass) {
const adapterSettings: MatterAdapterConfig = this.state.native as MatterAdapterConfig;

if (adapterSettings.login && adapterSettings.pass) {
if (this.state.alive) {
// ask the instance
const result = await this.socket.sendTo(`matter.${this.instance}`, 'getLicense', {
login: this.state.native.login,
pass: this.state.native.pass,
login: adapterSettings.login,
pass: adapterSettings.pass,
});
if (result.error) {
this.showToast(result.error);
Expand Down Expand Up @@ -652,6 +683,47 @@ class App extends GenericApp<GenericAppProps, AppState> {
);
}

renderSaveCloseButtons(): React.JSX.Element | null {
if (!this.state.confirmClose && !this.state.bottomButtons) {
return null;
}

return (
<>
{this.state.bottomButtons ? (
<SaveCloseButtons
theme={this.state.theme}
newReact={this.newReact}
noTextOnButtons={
this.state.width === 'xs' || this.state.width === 'sm' || this.state.width === 'md'
}
changed={this.state.changed}
onSave={async (isClose: boolean): Promise<void> => await this.onSave(isClose)}
onClose={() => {
if (this.state.changed) {
this.setState({ confirmClose: true });
} else {
GenericApp.onClose();
}
}}
error={!!this.state.isConfigurationError}
/>
) : null}
{this.state.confirmClose ? (
<DialogConfirm
title={I18n.t('ra_Please confirm')}
text={I18n.t('ra_Some data are not stored. Discard?')}
ok={I18n.t('ra_Discard')}
cancel={I18n.t('ra_Cancel')}
onClose={(isYes: boolean): void =>
this.setState({ confirmClose: false }, () => isYes && GenericApp.onClose())
}
/>
) : null}
</>
);
}

render(): React.JSX.Element {
if (!this.state.ready) {
return (
Expand Down
3 changes: 2 additions & 1 deletion src-admin/src/Tabs/Bridges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1366,9 +1366,10 @@ export class Bridges extends BridgesAndDevices<BridgesProps, BridgesState> {
return (
<React.Fragment key={bridgeIndex}>
<TableRow
style={{ opacity: bridge.enabled ? 1 : 0.4 }}
style={{ opacity: bridge.enabled ? 1 : 0.4, position: 'relative' }}
sx={styles.bridgeButtonsAndTitle}
>
{this.renderProcessOverlay(bridge.uuid)}
<TableCell
style={{
width: 0,
Expand Down
Loading
Loading