@iobroker/json-config 7.6.17 → 7.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -158,6 +158,7 @@ You can install it via GitHub icon in admin by entering `iobroker.jsonconfig-dem
158
158
  - [**`language`:**](#language) Selects the user interface language
159
159
  - [**`license`:**](#license) shows the license information if not already accepted.
160
160
  - [**`number`:**](#number) Numeric input field with min/max values and step size
161
+ - [**`oauth2`:**](#oauth2) Make OAuth2 authentication for the adapter (Admin 7.6.18 or newer)
161
162
  - [**`objectId`:**](#objectid) Selects an object ID with name, color, and icon
162
163
  - [**`panel`:**](#panel) Tab with items
163
164
  - [**`password`:**](#password) Password input field
@@ -513,6 +514,33 @@ saves image as a file of the `adapter.X` object or as base64 in attribute
513
514
  }
514
515
  ```
515
516
 
517
+ ### `oauth2`
518
+ (admin >= 6.17.18)
519
+
520
+ Shows OAuth2 Authentication button to get the refresh and access tokens for the adapter.
521
+
522
+ To use this, you must first provide the OAuth2 data (client ID, secret, etc.) to ioBroker maintenance team, so they can add it to the cloud.
523
+
524
+ | Property | Description |
525
+ |----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
526
+ | `identifier` | Oauth2 identifier, like `spotify`, `google`, `dropbox`, `microsoft` |
527
+ | `saveTokenIn` | Optional state name where the token will be saved. Default is `oauth2Tokens`. The path is relative to the adapter instance, like `adapterName.X.oauth2Tokens` |
528
+ | `scope` | Optional scopes divided by space, e.g. `user-read-private user-read-email` |
529
+ | `refreshLabel` | Optional button label for refreshing the token |
530
+
531
+ #### Example for `oauth2`
532
+
533
+ ```json
534
+ "_oauth2": {
535
+ "type": "oauth2",
536
+ "identifier": "spotify",
537
+ "label": "Get Spotify OAuth2 Token",
538
+ "refreshLabel": "Refresh Spotify OAuth2 Token",
539
+ "icon": "data:image/svg+xml;base64,...",
540
+ }
541
+ ```
542
+ See also [OAUTH2.md](OAUTH2.md) for more information.
543
+
516
544
  ### `objectId`
517
545
 
518
546
  object ID: show it with name, color and icon
@@ -1102,34 +1130,35 @@ Special input for ports. It checks automatically if port is used by other instan
1102
1130
  (admin >= 7.1.0) Show control or information from the state
1103
1131
  (admin >= 7.6.4) attributes `showEnterButton` and `setOnEnterKey`
1104
1132
 
1105
- | Property | Description |
1106
- |-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1107
- | `oid` | Which object ID should be taken for the controlling. The ID is without `adapter.X.` prefix |
1108
- | `system` | If true, the state will be taken from `system.adapter.X.` and not from `adapter.X` |
1109
- | `foreign` | The `oid` is absolute and no need to add `adapter.X` or `system.adapter.X.` to oid |
1110
- | `control` | How the value of the state should be shown: `text`, `html`, `input`, `slider`, `select`, `button`, `switch`, `number` |
1111
- | `controlled` | If true, the state will be shown as switch, select, button, slider or text input. Used only if no control property is defined |
1112
- | `unit` | Add unit to the value |
1113
- | `trueText` | this text will be shown if the value is true |
1114
- | `trueTextStyle` | Style of the text if the value is true |
1115
- | `falseText` | this text will be shown if the value is false or if the control is a "button" |
1116
- | `falseTextStyle` | Style of the text if the value is false or if the control is a "button" |
1117
- | `trueImage` | This image will be shown if the value is true |
1118
- | `falseImage` | This image will be shown if the value is false or if the control is a "button" |
1119
- | `min` | Minimum value for control type slider or number |
1120
- | `max` | Maximum value for control type slider or number |
1121
- | `step` | Step value for control type slider or number |
1122
- | `controlDelay` | delay in ms for slider or number |
1123
- | `variant` | Variant of button: `contained`, `outlined`, `text` |
1124
- | `readOnly` | Defines if the control is read-only |
1125
- | `narrow` | Normally the title and value are shown on the left and right of the line. With this flag, the value will appear just after the label |
1126
- | `blinkOnUpdate` | Value should blink when updated (true or color) |
1127
- | `size` | Font size: small, normal, large or number |
1128
- | `addColon` | Add to label the colon at the end if not exist in label |
1129
- | `labelIcon` | Base64 icon for label |
1130
- | `buttonValue` | Optional value, that will be sent for button |
1131
- | `showEnterButton` | Show SET button. The value in this case will be sent only when the button is pressed. You can define the text of the button. Default text is "Set" (Only for "input", "number" or "slider") |
1132
- | `setOnEnterKey` | The value in this case will be sent only when the "Enter" button is pressed. It can be combined with `showEnterButton` |
1133
+ | Property | Description |
1134
+ |-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1135
+ | `oid` | Which object ID should be taken for the controlling. The ID is without `adapter.X.` prefix |
1136
+ | `system` | If true, the state will be taken from `system.adapter.X.` and not from `adapter.X` |
1137
+ | `foreign` | The `oid` is absolute and no need to add `adapter.X` or `system.adapter.X.` to oid |
1138
+ | `control` | How the value of the state should be shown: `text`, `html`, `input`, `slider`, `select`, `button`, `switch`, `number` |
1139
+ | `controlled` | If true, the state will be shown as switch, select, button, slider or text input. Used only if no control property is defined |
1140
+ | `unit` | Add unit to the value |
1141
+ | `trueText` | this text will be shown if the value is true |
1142
+ | `trueTextStyle` | Style of the text if the value is true |
1143
+ | `falseText` | this text will be shown if the value is false or if the control is a "button" |
1144
+ | `falseTextStyle` | Style of the text if the value is false or if the control is a "button" |
1145
+ | `trueImage` | This image will be shown if the value is true |
1146
+ | `falseImage` | This image will be shown if the value is false or if the control is a "button" |
1147
+ | `min` | Minimum value for control type slider or number |
1148
+ | `max` | Maximum value for control type slider or number |
1149
+ | `step` | Step value for control type slider or number |
1150
+ | `controlDelay` | delay in ms for slider or number |
1151
+ | `variant` | Variant of button: `contained`, `outlined`, `text` |
1152
+ | `readOnly` | Defines if the control is read-only |
1153
+ | `narrow` | Normally the title and value are shown on the left and right of the line. With this flag, the value will appear just after the label |
1154
+ | `blinkOnUpdate` | Value should blink when updated (true or color) |
1155
+ | `size` | Font size: small, normal, large or number |
1156
+ | `addColon` | Add to label the colon at the end if not exist in label |
1157
+ | `labelIcon` | Base64 icon for label |
1158
+ | `buttonValue` | Optional value, that will be sent for button |
1159
+ | `showEnterButton` | Show SET button. The value in this case will be sent only when the button is pressed. You can define the text of the button. Default text is "Set" (Only for "input", "number" or "slider") |
1160
+ | `setOnEnterKey` | The value in this case will be sent only when the "Enter" button is pressed. It can be combined with `showEnterButton` |
1161
+ | `options` | Options for `select` in form `["value1", "value2", ...]` or `[{"value": "value", "label": "Value1", "color": "red"}, "value2", ...]`. If not defiled, the `common.states` in the object must exist. |
1133
1162
 
1134
1163
  ### `staticInfo`
1135
1164
 
@@ -1154,6 +1183,19 @@ This control is used mostly in dynamic forms
1154
1183
  | `highlight` | (optional) Highlight line on mouse over |
1155
1184
  | `booleanAsCheckbox` | (optional) Show boolean values as checkbox |
1156
1185
 
1186
+ ### `infoBox`
1187
+
1188
+ Shows closable static text with optional title and icon. (From admin >= 7.6.19)
1189
+
1190
+ | Property | Description |
1191
+ |----------------|---------------------------------------------------------------|
1192
+ | `text` | Text to be shown |
1193
+ | `title` | (optional) title for info box |
1194
+ | `boxType` | (optional) `warning`, `info`, `error`, `ok`. (Default `info`) |
1195
+ | `closeable` | (optional) If the box is closeable (Default `true`) |
1196
+ | `iconPosition` | (optional) `top`, `middle` (Default `middle`) |
1197
+ | `closed` | (optional) Will be shown as closed at the beginning |
1198
+
1157
1199
  ### `deviceManager`
1158
1200
 
1159
1201
  show device manager. For that, the adapter must support device manager protocol. See iobroker/dm-utils.
@@ -0,0 +1,10 @@
1
+ import { type JSX } from 'react';
2
+ import type { ConfigItemInfoBox } from '../types';
3
+ import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
4
+ interface ConfigInfoBoxProps extends ConfigGenericProps {
5
+ schema: ConfigItemInfoBox;
6
+ }
7
+ export default class ConfigInfoBox extends ConfigGeneric<ConfigInfoBoxProps, ConfigGenericState> {
8
+ renderItem(): JSX.Element;
9
+ }
10
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Box } from '@mui/material';
3
+ import { InfoBox } from '@iobroker/adapter-react-v5';
4
+ import ConfigGeneric from './ConfigGeneric';
5
+ export default class ConfigInfoBox extends ConfigGeneric {
6
+ renderItem() {
7
+ return (React.createElement(InfoBox, { type: this.props.schema.boxType || 'info', closeable: this.props.schema.closeable !== undefined ? this.props.schema.closeable : true, storeId: this.props.schema.closed !== undefined ? undefined : `${!!this.props.oContext.adapterName} ${this.props.attr}`, closed: this.props.schema.closed, style: { width: '100%', ...this.props.schema.style } },
8
+ this.props.schema.title ? (React.createElement(Box, { component: "div", sx: { fontWeight: 'bold', fontSize: 'larger' } }, this.getText(this.props.schema.title))) : null,
9
+ this.getText(this.props.schema.text)));
10
+ }
11
+ }
12
+ //# sourceMappingURL=ConfigInfoBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigInfoBox.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigInfoBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAMlG,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,aAAqD;IAC5F,UAAU;QACN,OAAO,CACH,oBAAC,OAAO,IACJ,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,EACzC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EACzF,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EACvH,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAChC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;YAEnD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACvB,oBAAC,GAAG,IACA,SAAS,EAAC,KAAK,EACf,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAE7C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CACpC,CACT,CAAC,CAAC,CAAC,IAAI;YACP,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAC/B,CACb,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Box } from '@mui/material';\n\nimport { InfoBox } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemInfoBox } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigInfoBoxProps extends ConfigGenericProps {\n schema: ConfigItemInfoBox;\n}\n\nexport default class ConfigInfoBox extends ConfigGeneric<ConfigInfoBoxProps, ConfigGenericState> {\n renderItem(): JSX.Element {\n return (\n <InfoBox\n type={this.props.schema.boxType || 'info'}\n closeable={this.props.schema.closeable !== undefined ? this.props.schema.closeable : true}\n storeId={this.props.schema.closed !== undefined ? undefined : `${!!this.props.oContext.adapterName} ${this.props.attr}`}\n closed={this.props.schema.closed}\n style={{ width: '100%', ...this.props.schema.style }}\n >\n {this.props.schema.title ? (\n <Box\n component=\"div\"\n sx={{ fontWeight: 'bold', fontSize: 'larger' }}\n >\n {this.getText(this.props.schema.title)}\n </Box>\n ) : null}\n {this.getText(this.props.schema.text)}\n </InfoBox>\n );\n }\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
3
+ import type { ConfigItemOAuth2 } from '../types';
4
+ declare global {
5
+ interface Window {
6
+ attachEvent: Window['addEventListener'];
7
+ detachEvent: Window['removeEventListener'];
8
+ }
9
+ }
10
+ interface ConfigOAuth2Props extends ConfigGenericProps {
11
+ schema: ConfigItemOAuth2;
12
+ }
13
+ export interface AccessTokens {
14
+ access_token: string;
15
+ expires_in: number;
16
+ access_token_expires_on: string;
17
+ ext_expires_in: number;
18
+ token_type: 'Bearer';
19
+ scope: string;
20
+ refresh_token: string;
21
+ }
22
+ interface ConfigOAuth2State extends ConfigGenericState {
23
+ accessTokens: string;
24
+ success: boolean;
25
+ blocked: boolean;
26
+ running: boolean;
27
+ pressed: boolean;
28
+ }
29
+ export default class ConfigOAuth2 extends ConfigGeneric<ConfigOAuth2Props, ConfigOAuth2State> {
30
+ private authWindow?;
31
+ private readonly oid;
32
+ private readonly url;
33
+ constructor(props: ConfigOAuth2Props);
34
+ componentDidMount(): Promise<void>;
35
+ onTokensUpdated: (_id: string, state: ioBroker.State | null | undefined) => void;
36
+ componentWillUnmount(): void;
37
+ saveToken(accessTokens: string): void;
38
+ onMessage: (event: MessageEvent) => void;
39
+ onOpenUrl(): void;
40
+ renderItem(): React.JSX.Element;
41
+ }
42
+ export {};
@@ -0,0 +1,170 @@
1
+ import React from 'react';
2
+ import { Button, TextField } from '@mui/material';
3
+ import { CloudUpload } from '@mui/icons-material';
4
+ import { I18n } from '@iobroker/adapter-react-v5';
5
+ import ConfigGeneric from './ConfigGeneric';
6
+ export default class ConfigOAuth2 extends ConfigGeneric {
7
+ authWindow;
8
+ oid;
9
+ url;
10
+ constructor(props) {
11
+ super(props);
12
+ this.state = {
13
+ ...this.state,
14
+ accessTokens: '',
15
+ success: false,
16
+ blocked: false,
17
+ running: false,
18
+ pressed: false,
19
+ };
20
+ this.url = `https://oauth2.iobroker.in/${props.schema.identifier}?redirect=true`;
21
+ if (props.schema.scope) {
22
+ this.url += `&scope=${encodeURIComponent(props.schema.scope)}`;
23
+ }
24
+ this.oid = `${this.props.oContext.adapterName}.${this.props.oContext.instance}.${this.props.schema.saveTokenIn || 'oauth2Tokens'}`;
25
+ }
26
+ async componentDidMount() {
27
+ super.componentDidMount();
28
+ if (window.addEventListener) {
29
+ window.addEventListener('message', this.onMessage, false);
30
+ }
31
+ else {
32
+ window.attachEvent('onmessage', this.onMessage, false);
33
+ }
34
+ await this.props.oContext.socket.subscribeState(this.oid, this.onTokensUpdated);
35
+ // read tokens
36
+ const tokens = await this.props.oContext.socket.getState(this.oid);
37
+ if (tokens) {
38
+ const accessTokens = JSON.parse(tokens.val);
39
+ if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {
40
+ this.setState({ accessTokens: tokens.val });
41
+ }
42
+ }
43
+ }
44
+ onTokensUpdated = (_id, state) => {
45
+ if (state?.val) {
46
+ const accessTokens = JSON.parse(state.val);
47
+ if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {
48
+ if (this.state.accessTokens !== state.val) {
49
+ this.setState({ accessTokens: state.val });
50
+ }
51
+ return;
52
+ }
53
+ }
54
+ this.setState({ accessTokens: '' });
55
+ };
56
+ componentWillUnmount() {
57
+ super.componentWillUnmount();
58
+ if (window.removeEventListener) {
59
+ window.removeEventListener('message', this.onMessage, false);
60
+ }
61
+ else {
62
+ window.detachEvent('onmessage', this.onMessage, false);
63
+ }
64
+ this.props.oContext.socket.unsubscribeState(this.oid, this.onTokensUpdated);
65
+ }
66
+ saveToken(accessTokens) {
67
+ try {
68
+ if (accessTokens && !accessTokens.startsWith('{')) {
69
+ // convert base64 to string
70
+ accessTokens = atob(accessTokens);
71
+ }
72
+ const accessTokensParsed = JSON.parse(accessTokens);
73
+ if (accessTokensParsed.access_token && accessTokensParsed.refresh_token && accessTokensParsed.expires_in) {
74
+ // Give 10 seconds to user to copy the token
75
+ accessTokensParsed.access_token_expires_on ||= new Date(Date.now() + accessTokensParsed.expires_in * 1000).toISOString();
76
+ this.props.oContext.socket
77
+ .setState(this.oid, JSON.stringify(accessTokensParsed), true)
78
+ .catch((e) => console.log(`Error occurred: ${e.toString()}`));
79
+ }
80
+ }
81
+ catch (e) {
82
+ // ignore
83
+ console.warn(e);
84
+ }
85
+ }
86
+ onMessage = (event) => {
87
+ if (event.origin !== 'https://oauth2.iobroker.in') {
88
+ return;
89
+ }
90
+ if ((typeof event.data === 'string' &&
91
+ event.data.startsWith(`${this.props.schema.identifier}-authentication:`)) ||
92
+ (typeof event.message === 'string' &&
93
+ event.message.startsWith(`${this.props.schema.identifier}-authentication:`))) {
94
+ const parts = (event.data || event.message).split(':');
95
+ if (parts[1] === 'success') {
96
+ this.setState({ accessTokens: parts[2], success: true, pressed: false }, () => this.saveToken(this.state.accessTokens));
97
+ // send message to auth window to close it
98
+ this.authWindow?.postMessage('close', event.origin);
99
+ this.authWindow = null;
100
+ }
101
+ else {
102
+ this.props.onError?.(parts[2]);
103
+ }
104
+ }
105
+ };
106
+ onOpenUrl() {
107
+ this.authWindow = window.open(this.url, this.props.schema.identifier);
108
+ if (!this.authWindow || this.authWindow.closed || typeof this.authWindow.closed === 'undefined') {
109
+ this.setState({ blocked: true });
110
+ }
111
+ else {
112
+ this.setState({ pressed: true });
113
+ }
114
+ }
115
+ renderItem() {
116
+ let validTill = '';
117
+ if (this.state.accessTokens) {
118
+ try {
119
+ const accessTokensParsed = JSON.parse(this.state.accessTokens);
120
+ validTill = new Date(accessTokensParsed.access_token_expires_on).toLocaleString();
121
+ }
122
+ catch {
123
+ // ignore
124
+ }
125
+ }
126
+ let label;
127
+ if (this.state.accessTokens) {
128
+ label = this.props.schema.refreshLabel
129
+ ? this.getText(this.props.schema.refreshLabel)
130
+ : I18n.t('ra_Renew %s access', this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1));
131
+ }
132
+ else {
133
+ label = this.props.schema.label
134
+ ? this.getText(this.props.schema.label)
135
+ : I18n.t('ra_Get %s access', this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1));
136
+ }
137
+ const icon = this.getIcon();
138
+ return (React.createElement("div", { style: { width: '100%', margin: '0 0 1rem 0' } },
139
+ React.createElement(Button, { disabled: this.state.running, endIcon: icon || React.createElement(CloudUpload, null), variant: "contained", onClick: () => this.onOpenUrl() }, label),
140
+ this.state.blocked ? (React.createElement("div", { style: { color: 'red', fontSize: 16, marginTop: 20 } }, I18n.t('ra_Please allow popups in your browser for this page!'))) : null,
141
+ this.state.accessTokens ? (React.createElement("div", { style: { color: 'green', fontSize: 16, marginTop: 20 } }, this.props.alive
142
+ ? I18n.t('ra_Successfully authorized. Token valid till %s and will be automatically renewed.', validTill)
143
+ : I18n.t('ra_Successfully authorized. Token valid till %s but it can expire as the instance is not running.', validTill))) : null,
144
+ this.state.pressed ? (React.createElement(React.Fragment, null,
145
+ React.createElement("div", { style: { width: '100%', margin: '1rem 0 1rem 0' } },
146
+ React.createElement("span", { style: { marginRight: 4 } },
147
+ `${I18n.t('ra_If the button above does not work, you can authorize manually this app by visiting this url')}`,
148
+ ":"),
149
+ React.createElement("br", null),
150
+ React.createElement("a", { target: this.props.schema.identifier, href: this.url, rel: "noreferrer" }, this.url)),
151
+ React.createElement(TextField, { value: this.state.accessTokens, label: I18n.t('ra_Enter the code from that page here'), variant: "standard", onChange: e => {
152
+ let accessTokens = e.target.value;
153
+ if (accessTokens && !accessTokens.startsWith('{')) {
154
+ // convert base64 to string
155
+ accessTokens = atob(accessTokens);
156
+ }
157
+ try {
158
+ const accessTokensParsed = JSON.parse(accessTokens);
159
+ if (accessTokensParsed.access_token) {
160
+ accessTokensParsed.access_token_expires_on = new Date(Date.now() + (accessTokensParsed.expires_in - 10) * 1000).toISOString();
161
+ this.setState({ accessTokens: JSON.stringify(accessTokensParsed) }, () => this.saveToken(this.state.accessTokens));
162
+ }
163
+ }
164
+ catch {
165
+ // ignore
166
+ }
167
+ }, fullWidth: true }))) : null));
168
+ }
169
+ }
170
+ //# sourceMappingURL=ConfigOAuth2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigO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AC,EAAE,CAAC;4BAChD,2BAA2B;4BAC3B,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;wBACtC,CAAC;wBACD,IAAI,CAAC;4BACD,MAAM,kBAAkB,GAAiB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BAClE,IAAI,kBAAkB,CAAC,YAAY,EAAE,CAAC;gCAClC,kBAAkB,CAAC,uBAAuB,GAAG,IAAI,IAAI,CACjD,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,kBAAkB,CAAC,UAAU,GAAG,EAAE,CAAC,GAAG,IAAI,CAC3D,CAAC,WAAW,EAAE,CAAC;gCAChB,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,CACrE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAC1C,CAAC;4BACN,CAAC;wBACL,CAAC;wBAAC,MAAM,CAAC;4BACL,SAAS;wBACb,CAAC;oBACL,CAAC,EACD,SAAS,SACX,CACH,CACN,CAAC,CAAC,CAAC,IAAI,CACN,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from 'react';\n\nimport { Button, TextField } from '@mui/material';\nimport { CloudUpload } from '@mui/icons-material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport type { ConfigItemOAuth2 } from '../types';\n\ndeclare global {\n interface Window {\n attachEvent: Window['addEventListener'];\n detachEvent: Window['removeEventListener'];\n }\n}\n\ninterface ConfigOAuth2Props extends ConfigGenericProps {\n schema: ConfigItemOAuth2;\n}\n\nexport interface AccessTokens {\n access_token: string;\n expires_in: number;\n access_token_expires_on: string;\n ext_expires_in: number;\n token_type: 'Bearer';\n scope: string;\n refresh_token: string;\n}\n\ninterface ConfigOAuth2State extends ConfigGenericState {\n accessTokens: string;\n success: boolean;\n blocked: boolean;\n running: boolean;\n pressed: boolean;\n}\n\nexport default class ConfigOAuth2 extends ConfigGeneric<ConfigOAuth2Props, ConfigOAuth2State> {\n private authWindow?: WindowProxy | null;\n private readonly oid: string;\n private readonly url: string;\n\n constructor(props: ConfigOAuth2Props) {\n super(props);\n\n this.state = {\n ...this.state,\n accessTokens: '',\n success: false,\n blocked: false,\n running: false,\n pressed: false,\n };\n\n this.url = `https://oauth2.iobroker.in/${props.schema.identifier}?redirect=true`;\n if (props.schema.scope) {\n this.url += `&scope=${encodeURIComponent(props.schema.scope)}`;\n }\n\n this.oid = `${this.props.oContext.adapterName}.${this.props.oContext.instance}.${this.props.schema.saveTokenIn || 'oauth2Tokens'}`;\n }\n\n async componentDidMount(): Promise<void> {\n super.componentDidMount();\n if (window.addEventListener) {\n window.addEventListener('message', this.onMessage as any, false);\n } else {\n window.attachEvent('onmessage', this.onMessage as any, false);\n }\n\n await this.props.oContext.socket.subscribeState(this.oid, this.onTokensUpdated);\n\n // read tokens\n const tokens = await this.props.oContext.socket.getState(this.oid);\n if (tokens) {\n const accessTokens: AccessTokens = JSON.parse(tokens.val as string);\n if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {\n this.setState({ accessTokens: tokens.val as string });\n }\n }\n }\n\n onTokensUpdated = (_id: string, state: ioBroker.State | null | undefined): void => {\n if (state?.val) {\n const accessTokens: AccessTokens = JSON.parse(state.val as string);\n if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {\n if (this.state.accessTokens !== state.val) {\n this.setState({ accessTokens: state.val as string });\n }\n return;\n }\n }\n this.setState({ accessTokens: '' });\n };\n\n componentWillUnmount(): void {\n super.componentWillUnmount();\n if (window.removeEventListener) {\n window.removeEventListener('message', this.onMessage as any, false);\n } else {\n window.detachEvent('onmessage', this.onMessage as any, false);\n }\n this.props.oContext.socket.unsubscribeState(this.oid, this.onTokensUpdated);\n }\n\n saveToken(accessTokens: string): void {\n try {\n if (accessTokens && !accessTokens.startsWith('{')) {\n // convert base64 to string\n accessTokens = atob(accessTokens);\n }\n\n const accessTokensParsed: AccessTokens = JSON.parse(accessTokens);\n if (accessTokensParsed.access_token && accessTokensParsed.refresh_token && accessTokensParsed.expires_in) {\n // Give 10 seconds to user to copy the token\n accessTokensParsed.access_token_expires_on ||= new Date(\n Date.now() + accessTokensParsed.expires_in * 1000,\n ).toISOString();\n\n this.props.oContext.socket\n .setState(this.oid, JSON.stringify(accessTokensParsed), true)\n .catch((e: Error) => console.log(`Error occurred: ${e.toString()}`));\n }\n } catch (e) {\n // ignore\n console.warn(e);\n }\n }\n\n onMessage = (event: MessageEvent): void => {\n if (event.origin !== 'https://oauth2.iobroker.in') {\n return;\n }\n if (\n (typeof event.data === 'string' &&\n event.data.startsWith(`${this.props.schema.identifier}-authentication:`)) ||\n (typeof (event as any).message === 'string' &&\n (event as any).message.startsWith(`${this.props.schema.identifier}-authentication:`))\n ) {\n const parts = (event.data || (event as any).message).split(':');\n if (parts[1] === 'success') {\n this.setState({ accessTokens: parts[2], success: true, pressed: false }, () =>\n this.saveToken(this.state.accessTokens),\n );\n\n // send message to auth window to close it\n this.authWindow?.postMessage('close', event.origin);\n this.authWindow = null;\n } else {\n this.props.onError?.(parts[2]);\n }\n }\n };\n\n onOpenUrl(): void {\n this.authWindow = window.open(this.url, this.props.schema.identifier);\n if (!this.authWindow || this.authWindow.closed || typeof this.authWindow.closed === 'undefined') {\n this.setState({ blocked: true });\n } else {\n this.setState({ pressed: true });\n }\n }\n\n renderItem(): React.JSX.Element {\n let validTill = '';\n if (this.state.accessTokens) {\n try {\n const accessTokensParsed: AccessTokens = JSON.parse(this.state.accessTokens);\n validTill = new Date(accessTokensParsed.access_token_expires_on).toLocaleString();\n } catch {\n // ignore\n }\n }\n\n let label: string;\n if (this.state.accessTokens) {\n label = this.props.schema.refreshLabel\n ? this.getText(this.props.schema.refreshLabel)\n : I18n.t(\n 'ra_Renew %s access',\n this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1),\n );\n } else {\n label = this.props.schema.label\n ? this.getText(this.props.schema.label)\n : I18n.t(\n 'ra_Get %s access',\n this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1),\n );\n }\n const icon = this.getIcon();\n\n return (\n <div style={{ width: '100%', margin: '0 0 1rem 0' }}>\n <Button\n disabled={this.state.running}\n endIcon={icon || <CloudUpload />}\n variant=\"contained\"\n onClick={() => this.onOpenUrl()}\n >\n {label}\n </Button>\n {this.state.blocked ? (\n <div style={{ color: 'red', fontSize: 16, marginTop: 20 }}>\n {I18n.t('ra_Please allow popups in your browser for this page!')}\n </div>\n ) : null}\n {this.state.accessTokens ? (\n <div style={{ color: 'green', fontSize: 16, marginTop: 20 }}>\n {this.props.alive\n ? I18n.t(\n 'ra_Successfully authorized. Token valid till %s and will be automatically renewed.',\n validTill,\n )\n : I18n.t(\n 'ra_Successfully authorized. Token valid till %s but it can expire as the instance is not running.',\n validTill,\n )}\n </div>\n ) : null}\n {this.state.pressed ? (\n <>\n <div style={{ width: '100%', margin: '1rem 0 1rem 0' }}>\n <span style={{ marginRight: 4 }}>\n {`${I18n.t('ra_If the button above does not work, you can authorize manually this app by visiting this url')}`}\n :\n </span>\n <br />\n <a\n target={this.props.schema.identifier}\n href={this.url}\n rel=\"noreferrer\"\n >\n {this.url}\n </a>\n </div>\n <TextField\n value={this.state.accessTokens}\n label={I18n.t('ra_Enter the code from that page here')}\n variant=\"standard\"\n onChange={e => {\n let accessTokens = e.target.value;\n if (accessTokens && !accessTokens.startsWith('{')) {\n // convert base64 to string\n accessTokens = atob(accessTokens);\n }\n try {\n const accessTokensParsed: AccessTokens = JSON.parse(accessTokens);\n if (accessTokensParsed.access_token) {\n accessTokensParsed.access_token_expires_on = new Date(\n Date.now() + (accessTokensParsed.expires_in - 10) * 1000,\n ).toISOString();\n this.setState({ accessTokens: JSON.stringify(accessTokensParsed) }, () =>\n this.saveToken(this.state.accessTokens),\n );\n }\n } catch {\n // ignore\n }\n }}\n fullWidth\n />\n </>\n ) : null}\n </div>\n );\n }\n}\n"]}
@@ -25,12 +25,14 @@ import ConfigFunc from './ConfigFunc';
25
25
  import ConfigIP from './ConfigIP';
26
26
  import ConfigImageSendTo from './ConfigImageSendTo';
27
27
  import ConfigImageUpload from './ConfigImageUpload';
28
+ import ConfigInfoBox from './ConfigInfoBox';
28
29
  import ConfigInstanceSelect from './ConfigInstanceSelect';
29
30
  import ConfigInterface from './ConfigInterface';
30
31
  import ConfigJsonEditor from './ConfigJsonEditor';
31
32
  import ConfigLanguage from './ConfigLanguage';
32
33
  import ConfigLicense from './ConfigLicense';
33
34
  import ConfigNumber from './ConfigNumber';
35
+ import ConfigOauth2 from './ConfigOAuth2';
34
36
  import ConfigObjectId from './ConfigObjectId';
35
37
  import ConfigPassword from './ConfigPassword';
36
38
  import ConfigPattern from './ConfigPattern';
@@ -80,6 +82,7 @@ const components = {
80
82
  header: ConfigStaticHeader,
81
83
  image: ConfigImageUpload,
82
84
  imageSendTo: ConfigImageSendTo,
85
+ infoBox: ConfigInfoBox,
83
86
  instance: ConfigInstanceSelect,
84
87
  interface: ConfigInterface,
85
88
  ip: ConfigIP,
@@ -87,6 +90,7 @@ const components = {
87
90
  language: ConfigLanguage,
88
91
  license: ConfigLicense,
89
92
  number: ConfigNumber,
93
+ oauth2: ConfigOauth2,
90
94
  objectId: ConfigObjectId,
91
95
  password: ConfigPassword,
92
96
  pattern: ConfigPattern,
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigPanel.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEtG,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAuC,K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AI,SAAS;oBAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;oBAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;iBAC7B,EACD,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,IAE/E,OAAO,CACJ,CACX,CAAC;YAEF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,OAAO,CACH;oBACI,6BAAK,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAI;oBAC/C,IAAI,CACN,CACN,CAAC;YACN,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,eAAe,WAAW,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Grid2, Accordion, AccordionSummary, AccordionDetails, Typography, Box } from '@mui/material';\n\nimport { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';\n\nimport { type AdminConnection, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemPanel } from '../types';\n\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\nimport ConfigAccordion from './ConfigAccordion';\nimport ConfigAlive from './ConfigAlive';\nimport ConfigAutocomplete from './ConfigAutocomplete';\nimport ConfigAutocompleteSendTo from './ConfigAutocompleteSendTo';\nimport ConfigCRON from './ConfigCRON';\nimport ConfigCertificateSelect from './ConfigCertificateSelect';\nimport ConfigCertificates from './ConfigCertificates';\nimport ConfigCertCollection from './ConfigCertCollection';\nimport ConfigCheckLicense from './ConfigCheckLicense';\nimport ConfigCheckbox from './ConfigCheckbox';\nimport ConfigChip from './ConfigChip';\nimport ConfigColor from './ConfigColor';\nimport ConfigCoordinates from './ConfigCoordinates';\nimport ConfigCustom from './ConfigCustom';\nimport ConfigDatePicker from './ConfigDatePicker';\nimport ConfigDeviceManager from './ConfigDeviceManager';\nimport ConfigFile from './ConfigFile';\nimport ConfigFileSelector from './ConfigFileSelector';\nimport ConfigFunc from './ConfigFunc';\nimport ConfigIP from './ConfigIP';\nimport ConfigImageSendTo from './ConfigImageSendTo';\nimport ConfigImageUpload from './ConfigImageUpload';\nimport ConfigInstanceSelect from './ConfigInstanceSelect';\nimport ConfigInterface from './ConfigInterface';\nimport ConfigJsonEditor from './ConfigJsonEditor';\nimport ConfigLanguage from './ConfigLanguage';\nimport ConfigLicense from './ConfigLicense';\nimport ConfigNumber from './ConfigNumber';\nimport ConfigObjectId from './ConfigObjectId';\nimport ConfigPassword from './ConfigPassword';\nimport ConfigPattern from './ConfigPattern';\nimport ConfigPort from './ConfigPort';\nimport ConfigRoom from './ConfigRoom';\nimport ConfigSelect from './ConfigSelect';\nimport ConfigSelectSendTo from './ConfigSelectSendTo';\nimport ConfigSendTo from './ConfigSendto';\nimport ConfigSetState from './ConfigSetState';\nimport ConfigSlider from './ConfigSlider';\nimport ConfigState from './ConfigState';\nimport ConfigStaticDivider from './ConfigStaticDivider';\nimport ConfigStaticHeader from './ConfigStaticHeader';\nimport ConfigStaticImage from './ConfigStaticImage';\nimport ConfigStaticInfo from './ConfigStaticInfo';\nimport ConfigStaticText from './ConfigStaticText';\nimport ConfigTable from './ConfigTable';\nimport ConfigText from './ConfigText';\nimport ConfigTextSendTo from './ConfigTextSendTo';\nimport ConfigTimePicker from './ConfigTimePicker';\nimport ConfigTopic from './ConfigTopic';\nimport ConfigUUID from './ConfigUUID';\nimport ConfigUser from './ConfigUser';\nimport ConfigQrCode from './ConfigQrCode';\n\nconst components: Record<string, typeof ConfigGeneric<any, any>> = {\n accordion: ConfigAccordion,\n alive: ConfigAlive,\n autocomplete: ConfigAutocomplete,\n autocompleteSendTo: ConfigAutocompleteSendTo,\n certCollection: ConfigCertCollection,\n certificate: ConfigCertificateSelect,\n certificates: ConfigCertificates,\n checkbox: ConfigCheckbox,\n checkLicense: ConfigCheckLicense,\n chip: ConfigChip, // deprecated. Use \"chips\"\n chips: ConfigChip,\n color: ConfigColor,\n coordinates: ConfigCoordinates,\n cron: ConfigCRON,\n custom: ConfigCustom,\n datePicker: ConfigDatePicker,\n deviceManager: ConfigDeviceManager,\n divider: ConfigStaticDivider,\n file: ConfigFile,\n fileSelector: ConfigFileSelector,\n func: ConfigFunc,\n header: ConfigStaticHeader,\n image: ConfigImageUpload,\n imageSendTo: ConfigImageSendTo,\n instance: ConfigInstanceSelect,\n interface: ConfigInterface,\n ip: ConfigIP,\n jsonEditor: ConfigJsonEditor,\n language: ConfigLanguage,\n license: ConfigLicense,\n number: ConfigNumber,\n objectId: ConfigObjectId,\n password: ConfigPassword,\n pattern: ConfigPattern,\n port: ConfigPort,\n qrCode: ConfigQrCode,\n room: ConfigRoom,\n select: ConfigSelect,\n selectSendTo: ConfigSelectSendTo,\n // @deprecated Use \"sendTo\"\n sendto: ConfigSendTo,\n sendTo: ConfigSendTo,\n setState: ConfigSetState,\n slider: ConfigSlider,\n state: ConfigState,\n staticImage: ConfigStaticImage,\n staticInfo: ConfigStaticInfo,\n staticLink: ConfigStaticText,\n staticText: ConfigStaticText,\n table: ConfigTable,\n text: ConfigText,\n textSendTo: ConfigTextSendTo,\n timePicker: ConfigTimePicker,\n topic: ConfigTopic,\n uuid: ConfigUUID,\n user: ConfigUser,\n};\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n // height: '100%',\n },\n paper: {\n margin: 1,\n width: 'auto !important',\n overflowY: 'auto',\n paddingBottom: 1,\n },\n paperWithIcons: {\n height: 'calc(100vh - 259px) !important',\n },\n paperWithoutIcons: {\n height: 'calc(100vh - 235px) !important',\n },\n padding: {\n padding: '10px',\n },\n heading: {},\n primary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.primary.main,\n color: theme.palette.mode === 'dark' ? 'inherit' : '#FFF',\n }),\n secondary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.secondary.main,\n }),\n};\n\ninterface ConfigPanelProps extends ConfigGenericProps {\n schema: ConfigItemPanel;\n withIcons?: boolean;\n withoutSaveButtons?: boolean;\n}\ninterface ConfigPanelState extends ConfigGenericState {\n expanded?: boolean;\n}\n\nclass ConfigPanel extends ConfigGeneric<ConfigPanelProps, ConfigPanelState> {\n componentDidMount(): void {\n super.componentDidMount();\n if (this.props.schema?.collapsable) {\n this.setState({\n expanded:\n (((window as any)._localStorage as Storage) || window.localStorage).getItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n ) === 'true',\n });\n }\n }\n\n renderItems(items: Record<string, any>, disabled: boolean): JSX.Element[] | null {\n return items\n ? Object.keys(items).map(attr => {\n if (this.props.oContext.multiEdit && items[attr].noMultiEdit) {\n return null;\n }\n\n const type = items[attr].type || 'panel';\n let ItemComponent: typeof ConfigGeneric<ConfigGenericProps, any>;\n let socket: string | AdminConnection = 'Use this.props.oContext.socket!';\n if (type === 'custom') {\n // name\n // url\n if (items[attr].url) {\n ItemComponent = ConfigCustom;\n } else if (this.props.oContext.customs && this.props.oContext.customs[items[attr].component]) {\n ItemComponent = this.props.oContext.customs[items[attr].component];\n } else {\n console.error(`Cannot find custom component: ${items[attr].component}`);\n ItemComponent = ConfigGeneric;\n }\n socket = this.props.oContext.socket;\n } else if (type === 'panel') {\n ItemComponent = ConfigPanel;\n } else {\n ItemComponent = components[type] || ConfigGeneric;\n }\n\n return (\n <ItemComponent\n // @ts-expect-error Temporary work-around, till all custom components will not migrate to oContext\n socket={socket}\n globalData={this.props.globalData}\n oContext={this.props.oContext}\n key={`${attr}_${this.props.index === undefined ? '' : this.props.index}`}\n index={this.props.index}\n changed={this.props.changed}\n arrayIndex={this.props.arrayIndex}\n expertMode={this.props.expertMode}\n commandRunning={this.props.commandRunning}\n style={styles.panel}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={this.props.data}\n originalData={this.props.originalData}\n onError={this.props.onError}\n onChange={this.props.onChange}\n disabled={disabled}\n customObj={this.props.customObj}\n custom={this.props.custom}\n schema={items[attr]}\n attr={attr}\n table={this.props.table}\n />\n );\n })\n : null;\n }\n\n render(): JSX.Element | null {\n const schema = this.props.schema;\n\n if (!schema) {\n return null;\n }\n\n const { disabled, hidden } = this.calculate(schema);\n\n const items = this.props.schema.items;\n const schemaStyle = this.props.schema.style || {};\n\n if (hidden) {\n if (schema.hideOnlyControl) {\n const item = (\n <Grid2\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { marginBottom: 0, textAlign: 'left' /* marginRight: 8, */ },\n schemaStyle,\n this.props.oContext.themeType === 'dark' && schema.darkStyle,\n )}\n />\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return null;\n }\n\n if (this.props.table) {\n return this.renderItems(items, disabled) as any as JSX.Element;\n }\n\n if (this.props.custom) {\n return (\n <Grid2\n key={`${this.props.attr}_${this.props.index}`}\n container\n style={styles.fullWidth}\n columnSpacing={2}\n rowSpacing={1}\n sx={schemaStyle}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n );\n }\n\n let content;\n if (schema.collapsable) {\n content = (\n <Accordion\n key={`${this.props.attr}_${this.props.index}`}\n style={styles.fullWidth}\n expanded={!!this.state.expanded}\n onChange={() => {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n this.state.expanded ? 'false' : 'true',\n );\n this.setState({ expanded: !this.state.expanded });\n }}\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n schemaStyle,\n this.props.oContext.themeType && schema.darkStyle,\n schema.color === 'primary'\n ? styles.primary\n : schema.color === 'secondary' && styles.secondary,\n { width: '100%' },\n )}\n >\n <Typography style={styles.heading}>{this.getText(schema.label)}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={{ ...schemaStyle, width: '100%', padding: '10px' }}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </AccordionDetails>\n </Accordion>\n );\n } else {\n const sx = Utils.getStyle(\n this.props.oContext.theme,\n this.props.style,\n schemaStyle,\n { width: '100%' },\n this.props.isParentTab && styles.paper,\n this.props.isParentTab &&\n (this.props.withoutSaveButtons\n ? this.props.withIcons\n ? { height: 'calc(100% - 88px) !important' }\n : { height: 'calc(100% - 64px) !important' }\n : this.props.withIcons\n ? styles.paperWithIcons\n : styles.paperWithoutIcons),\n );\n\n content = (\n <Box\n component=\"div\"\n key={`${this.props.attr}_${this.props.index}`}\n className={this.props.className}\n sx={sx}\n >\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { width: '100%' },\n this.props.isParentTab && styles.padding,\n this.props.schema.innerStyle,\n )}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </Box>\n );\n }\n\n if (!this.props.isParentTab) {\n const item = (\n <Grid2\n title={this.getText(schema.tooltip)}\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={{ marginBottom: 0, /* marginRight: 8, */ textAlign: 'left', ...schemaStyle }}\n >\n {content}\n </Grid2>\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return content;\n }\n}\n\nexport default ConfigPanel;\n"]}
1
+ {"version":3,"file":"ConfigPanel.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,SAA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K,CAAC,WAAW,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,CACT,oBAAC,KAAK,IACF,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EACnC,IAAI,EAAE;oBACF,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;oBAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;oBAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;oBAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;oBAC1B,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;iBAC7B,EACD,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,IAE/E,OAAO,CACJ,CACX,CAAC;YAEF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,OAAO,CACH;oBACI,6BAAK,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAI;oBAC/C,IAAI,CACN,CACN,CAAC;YACN,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,eAAe,WAAW,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Grid2, Accordion, AccordionSummary, AccordionDetails, Typography, Box } from '@mui/material';\n\nimport { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';\n\nimport { type AdminConnection, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemPanel } from '../types';\n\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\nimport ConfigAccordion from './ConfigAccordion';\nimport ConfigAlive from './ConfigAlive';\nimport ConfigAutocomplete from './ConfigAutocomplete';\nimport ConfigAutocompleteSendTo from './ConfigAutocompleteSendTo';\nimport ConfigCRON from './ConfigCRON';\nimport ConfigCertificateSelect from './ConfigCertificateSelect';\nimport ConfigCertificates from './ConfigCertificates';\nimport ConfigCertCollection from './ConfigCertCollection';\nimport ConfigCheckLicense from './ConfigCheckLicense';\nimport ConfigCheckbox from './ConfigCheckbox';\nimport ConfigChip from './ConfigChip';\nimport ConfigColor from './ConfigColor';\nimport ConfigCoordinates from './ConfigCoordinates';\nimport ConfigCustom from './ConfigCustom';\nimport ConfigDatePicker from './ConfigDatePicker';\nimport ConfigDeviceManager from './ConfigDeviceManager';\nimport ConfigFile from './ConfigFile';\nimport ConfigFileSelector from './ConfigFileSelector';\nimport ConfigFunc from './ConfigFunc';\nimport ConfigIP from './ConfigIP';\nimport ConfigImageSendTo from './ConfigImageSendTo';\nimport ConfigImageUpload from './ConfigImageUpload';\nimport ConfigInfoBox from './ConfigInfoBox';\nimport ConfigInstanceSelect from './ConfigInstanceSelect';\nimport ConfigInterface from './ConfigInterface';\nimport ConfigJsonEditor from './ConfigJsonEditor';\nimport ConfigLanguage from './ConfigLanguage';\nimport ConfigLicense from './ConfigLicense';\nimport ConfigNumber from './ConfigNumber';\nimport ConfigOauth2 from './ConfigOAuth2';\nimport ConfigObjectId from './ConfigObjectId';\nimport ConfigPassword from './ConfigPassword';\nimport ConfigPattern from './ConfigPattern';\nimport ConfigPort from './ConfigPort';\nimport ConfigRoom from './ConfigRoom';\nimport ConfigSelect from './ConfigSelect';\nimport ConfigSelectSendTo from './ConfigSelectSendTo';\nimport ConfigSendTo from './ConfigSendto';\nimport ConfigSetState from './ConfigSetState';\nimport ConfigSlider from './ConfigSlider';\nimport ConfigState from './ConfigState';\nimport ConfigStaticDivider from './ConfigStaticDivider';\nimport ConfigStaticHeader from './ConfigStaticHeader';\nimport ConfigStaticImage from './ConfigStaticImage';\nimport ConfigStaticInfo from './ConfigStaticInfo';\nimport ConfigStaticText from './ConfigStaticText';\nimport ConfigTable from './ConfigTable';\nimport ConfigText from './ConfigText';\nimport ConfigTextSendTo from './ConfigTextSendTo';\nimport ConfigTimePicker from './ConfigTimePicker';\nimport ConfigTopic from './ConfigTopic';\nimport ConfigUUID from './ConfigUUID';\nimport ConfigUser from './ConfigUser';\nimport ConfigQrCode from './ConfigQrCode';\n\nconst components: Record<string, typeof ConfigGeneric<any, any>> = {\n accordion: ConfigAccordion,\n alive: ConfigAlive,\n autocomplete: ConfigAutocomplete,\n autocompleteSendTo: ConfigAutocompleteSendTo,\n certCollection: ConfigCertCollection,\n certificate: ConfigCertificateSelect,\n certificates: ConfigCertificates,\n checkbox: ConfigCheckbox,\n checkLicense: ConfigCheckLicense,\n chip: ConfigChip, // deprecated. Use \"chips\"\n chips: ConfigChip,\n color: ConfigColor,\n coordinates: ConfigCoordinates,\n cron: ConfigCRON,\n custom: ConfigCustom,\n datePicker: ConfigDatePicker,\n deviceManager: ConfigDeviceManager,\n divider: ConfigStaticDivider,\n file: ConfigFile,\n fileSelector: ConfigFileSelector,\n func: ConfigFunc,\n header: ConfigStaticHeader,\n image: ConfigImageUpload,\n imageSendTo: ConfigImageSendTo,\n infoBox: ConfigInfoBox,\n instance: ConfigInstanceSelect,\n interface: ConfigInterface,\n ip: ConfigIP,\n jsonEditor: ConfigJsonEditor,\n language: ConfigLanguage,\n license: ConfigLicense,\n number: ConfigNumber,\n oauth2: ConfigOauth2,\n objectId: ConfigObjectId,\n password: ConfigPassword,\n pattern: ConfigPattern,\n port: ConfigPort,\n qrCode: ConfigQrCode,\n room: ConfigRoom,\n select: ConfigSelect,\n selectSendTo: ConfigSelectSendTo,\n // @deprecated Use \"sendTo\"\n sendto: ConfigSendTo,\n sendTo: ConfigSendTo,\n setState: ConfigSetState,\n slider: ConfigSlider,\n state: ConfigState,\n staticImage: ConfigStaticImage,\n staticInfo: ConfigStaticInfo,\n staticLink: ConfigStaticText,\n staticText: ConfigStaticText,\n table: ConfigTable,\n text: ConfigText,\n textSendTo: ConfigTextSendTo,\n timePicker: ConfigTimePicker,\n topic: ConfigTopic,\n uuid: ConfigUUID,\n user: ConfigUser,\n};\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n // height: '100%',\n },\n paper: {\n margin: 1,\n width: 'auto !important',\n overflowY: 'auto',\n paddingBottom: 1,\n },\n paperWithIcons: {\n height: 'calc(100vh - 259px) !important',\n },\n paperWithoutIcons: {\n height: 'calc(100vh - 235px) !important',\n },\n padding: {\n padding: '10px',\n },\n heading: {},\n primary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.primary.main,\n color: theme.palette.mode === 'dark' ? 'inherit' : '#FFF',\n }),\n secondary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.secondary.main,\n }),\n};\n\ninterface ConfigPanelProps extends ConfigGenericProps {\n schema: ConfigItemPanel;\n withIcons?: boolean;\n withoutSaveButtons?: boolean;\n}\ninterface ConfigPanelState extends ConfigGenericState {\n expanded?: boolean;\n}\n\nclass ConfigPanel extends ConfigGeneric<ConfigPanelProps, ConfigPanelState> {\n componentDidMount(): void {\n super.componentDidMount();\n if (this.props.schema?.collapsable) {\n this.setState({\n expanded:\n (((window as any)._localStorage as Storage) || window.localStorage).getItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n ) === 'true',\n });\n }\n }\n\n renderItems(items: Record<string, any>, disabled: boolean): JSX.Element[] | null {\n return items\n ? Object.keys(items).map(attr => {\n if (this.props.oContext.multiEdit && items[attr].noMultiEdit) {\n return null;\n }\n\n const type = items[attr].type || 'panel';\n let ItemComponent: typeof ConfigGeneric<ConfigGenericProps, any>;\n let socket: string | AdminConnection = 'Use this.props.oContext.socket!';\n if (type === 'custom') {\n // name\n // url\n if (items[attr].url) {\n ItemComponent = ConfigCustom;\n } else if (this.props.oContext.customs && this.props.oContext.customs[items[attr].component]) {\n ItemComponent = this.props.oContext.customs[items[attr].component];\n } else {\n console.error(`Cannot find custom component: ${items[attr].component}`);\n ItemComponent = ConfigGeneric;\n }\n socket = this.props.oContext.socket;\n } else if (type === 'panel') {\n ItemComponent = ConfigPanel;\n } else {\n ItemComponent = components[type] || ConfigGeneric;\n }\n\n return (\n <ItemComponent\n // @ts-expect-error Temporary work-around, till all custom components will not migrate to oContext\n socket={socket}\n globalData={this.props.globalData}\n oContext={this.props.oContext}\n key={`${attr}_${this.props.index === undefined ? '' : this.props.index}`}\n index={this.props.index}\n changed={this.props.changed}\n arrayIndex={this.props.arrayIndex}\n expertMode={this.props.expertMode}\n commandRunning={this.props.commandRunning}\n style={styles.panel}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={this.props.data}\n originalData={this.props.originalData}\n onError={this.props.onError}\n onChange={this.props.onChange}\n disabled={disabled}\n customObj={this.props.customObj}\n custom={this.props.custom}\n schema={items[attr]}\n attr={attr}\n table={this.props.table}\n />\n );\n })\n : null;\n }\n\n render(): JSX.Element | null {\n const schema = this.props.schema;\n\n if (!schema) {\n return null;\n }\n\n const { disabled, hidden } = this.calculate(schema);\n\n const items = this.props.schema.items;\n const schemaStyle = this.props.schema.style || {};\n\n if (hidden) {\n if (schema.hideOnlyControl) {\n const item = (\n <Grid2\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { marginBottom: 0, textAlign: 'left' /* marginRight: 8, */ },\n schemaStyle,\n this.props.oContext.themeType === 'dark' && schema.darkStyle,\n )}\n />\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return null;\n }\n\n if (this.props.table) {\n return this.renderItems(items, disabled) as any as JSX.Element;\n }\n\n if (this.props.custom) {\n return (\n <Grid2\n key={`${this.props.attr}_${this.props.index}`}\n container\n style={styles.fullWidth}\n columnSpacing={2}\n rowSpacing={1}\n sx={schemaStyle}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n );\n }\n\n let content;\n if (schema.collapsable) {\n content = (\n <Accordion\n key={`${this.props.attr}_${this.props.index}`}\n style={styles.fullWidth}\n expanded={!!this.state.expanded}\n onChange={() => {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n this.state.expanded ? 'false' : 'true',\n );\n this.setState({ expanded: !this.state.expanded });\n }}\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n schemaStyle,\n this.props.oContext.themeType && schema.darkStyle,\n schema.color === 'primary'\n ? styles.primary\n : schema.color === 'secondary' && styles.secondary,\n { width: '100%' },\n )}\n >\n <Typography style={styles.heading}>{this.getText(schema.label)}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={{ ...schemaStyle, width: '100%', padding: '10px' }}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </AccordionDetails>\n </Accordion>\n );\n } else {\n const sx = Utils.getStyle(\n this.props.oContext.theme,\n this.props.style,\n schemaStyle,\n { width: '100%' },\n this.props.isParentTab && styles.paper,\n this.props.isParentTab &&\n (this.props.withoutSaveButtons\n ? this.props.withIcons\n ? { height: 'calc(100% - 88px) !important' }\n : { height: 'calc(100% - 64px) !important' }\n : this.props.withIcons\n ? styles.paperWithIcons\n : styles.paperWithoutIcons),\n );\n\n content = (\n <Box\n component=\"div\"\n key={`${this.props.attr}_${this.props.index}`}\n className={this.props.className}\n sx={sx}\n >\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { width: '100%' },\n this.props.isParentTab && styles.padding,\n this.props.schema.innerStyle,\n )}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </Box>\n );\n }\n\n if (!this.props.isParentTab) {\n const item = (\n <Grid2\n title={this.getText(schema.tooltip)}\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={{ marginBottom: 0, /* marginRight: 8, */ textAlign: 'left', ...schemaStyle }}\n >\n {content}\n </Grid2>\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return content;\n }\n}\n\nexport default ConfigPanel;\n"]}
@@ -10,6 +10,7 @@ interface ConfigInstanceSelectState extends ConfigGenericState {
10
10
  value: number | string;
11
11
  group?: boolean;
12
12
  hidden?: string | boolean;
13
+ color?: string;
13
14
  }[];
14
15
  }
15
16
  declare class ConfigSelect extends ConfigGeneric<ConfigInstanceSelectProps, ConfigInstanceSelectState> {