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

Extended info for separate devices in bridge #225

Merged
merged 9 commits into from
Dec 13, 2024
355 changes: 179 additions & 176 deletions io-package.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"scripts": {
"start": "vite",
"build": "vite build",
"lint": "eslint --fix --ext .js,.jsx,.tsx src",
"lint": "eslint -c eslint.config.mjs",
"check-ts": "tsc --noEmit --checkJS false",
"tsc": "tsc --project tsconfig.json"
},
Expand Down
58 changes: 57 additions & 1 deletion src-admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import {
DialogContent,
DialogContentText,
DialogTitle,
Fab,
LinearProgress,
Tab,
Tabs,
Tooltip,
} from '@mui/material';

import { SignalCellularOff as IconNotAlive } from '@mui/icons-material';
import { Help as IconHelp, SignalCellularOff as IconNotAlive } from '@mui/icons-material';

import {
AdminConnection,
Expand All @@ -32,6 +33,7 @@ import BridgesTab from './Tabs/Bridges';
import ControllerTab from './Tabs/Controller';
import DevicesTab from './Tabs/Devices';
import OptionsTab from './Tabs/Options';
import WelcomeDialog from './components/WelcomeDialog';

import type {
CommissioningInfo,
Expand Down Expand Up @@ -93,12 +95,14 @@ interface AppState extends GenericAppState {
/** Undefined if no detection ran yet */
detectedDevices?: DetectedRoom[];
ready: boolean;
showWelcomeDialog: boolean;
progress: {
title?: ioBroker.StringOrTranslated;
text?: ioBroker.StringOrTranslated;
indeterminate?: boolean;
value?: number;
} | null;
welcomeDialogShowed: boolean;
}

class App extends GenericApp<GenericAppProps, AppState> {
Expand Down Expand Up @@ -155,6 +159,8 @@ class App extends GenericApp<GenericAppProps, AppState> {
},
ready: false,
progress: null,
showWelcomeDialog: false,
welcomeDialogShowed: false,
});

this.alert = window.alert;
Expand Down Expand Up @@ -253,6 +259,8 @@ class App extends GenericApp<GenericAppProps, AppState> {

const alive = await this.socket.getState(`system.adapter.matter.${this.instance}.alive`);

const welcomeDialog = await this.socket.getState(`matter.${this.instance}.welcomeDialog`);

if (alive?.val) {
this.refreshBackendSubscription(true);
}
Expand All @@ -262,6 +270,8 @@ class App extends GenericApp<GenericAppProps, AppState> {
commissioning,
ready: true,
alive: !!alive?.val,
showWelcomeDialog: !welcomeDialog?.val,
welcomeDialogShowed: !!welcomeDialog?.val,
});
}

Expand All @@ -278,6 +288,28 @@ class App extends GenericApp<GenericAppProps, AppState> {
}
};

renderWelcomeDialog(): React.JSX.Element | null {
if (!this.state.showWelcomeDialog) {
return null;
}

return (
<WelcomeDialog
common={this.common}
instance={this.instance}
socket={this.socket}
onClose={async () => {
if (!this.state.welcomeDialogShowed) {
await this.socket.setState(`matter.${this.instance}.welcomeDialog`, true, true);
}
this.setState({ showWelcomeDialog: false, welcomeDialogShowed: true });
}}
login={this.state.native.login}
pass={this.state.native.pass}
/>
);
}

onBackendUpdates = (update: GUIMessage | null): void => {
if (!update) {
return;
Expand Down Expand Up @@ -440,6 +472,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
this.updateNativeValue(id, value, resolve);
});
}}
onShowWelcomeDialog={() => this.setState({ showWelcomeDialog: true })}
onLoad={(native: Record<string, any>) => this.onLoadConfig(native)}
socket={this.socket}
common={this.common}
Expand Down Expand Up @@ -625,6 +658,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
<ThemeProvider theme={this.state.theme}>
{this.renderToast()}
{this.renderProgressDialog()}
{this.renderWelcomeDialog()}
<div
className="App"
style={{
Expand Down Expand Up @@ -697,6 +731,28 @@ class App extends GenericApp<GenericAppProps, AppState> {
</div>
</Tooltip>
)}
{this.common && this.state.selectedTab !== 'options' ? (
<Tooltip
title={I18n.t('Show readme page')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
<Fab
size="small"
color="primary"
style={{
marginRight: 5,
marginTop: 5,
float: 'right',
}}
onClick={() => {
const win = window.open(this.common?.readme, '_blank');
win?.focus();
}}
>
<IconHelp />
</Fab>
</Tooltip>
) : null}
</Tabs>
</AppBar>

Expand Down
Loading
Loading