Skip to content

Commit

Permalink
* (bluefox) Corrected the Device Manager Component
Browse files Browse the repository at this point in the history
Fixing #2548
  • Loading branch information
GermanBluefox committed Jul 15, 2024
1 parent 89891c2 commit d67b3f7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ The icons may not be reused in other projects without the proper flaticon licens
-->
## Changelog
### **WORK IN PROGRESS**
* (bluefox) Correcting CRON description
* (bluefox) Corrected the CRON description
* (bluefox) Corrected the Device Manager Component

### 7.0.16 (2024-07-15)
* (bluefox) Allowed playing mp3 and video files in the file browser
Expand Down
12 changes: 8 additions & 4 deletions packages/admin/src-admin/src/tabs/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ import {
import {
Router,
Icon,
Confirm as ConfirmDialog, type IobTheme, type AdminConnection, type ThemeName, type ThemeType, type Translate,
Confirm as ConfirmDialog,
type IobTheme,
type AdminConnection,
type ThemeName,
type ThemeType,
type Translate,
} from '@iobroker/adapter-react-v5';

import { JsonConfig } from '@iobroker/json-config';
import { type DeviceManagerPropsProps, JsonConfig } from '@iobroker/json-config';
import DeviceManager from '@iobroker/dm-gui-components';

import AdminUtils from '../AdminUtils';
Expand Down Expand Up @@ -414,8 +419,7 @@ class Config extends Component<ConfigProps, ConfigState> {
isFloatComma={this.props.isFloatComma}
configStored={this.props.configStored}
t={this.props.t}
// @ts-expect-error fix later
DeviceManager={DeviceManager}
DeviceManager={DeviceManager as unknown as React.FC<DeviceManagerPropsProps>}
/>;
}
const src = `adapter/${this.props.adapter}/` +
Expand Down
14 changes: 9 additions & 5 deletions packages/jsonConfig/src/JsonConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ interface JsonConfigProps {
instance: number;
isFloatComma: boolean;
dateFormat: string;
secret: string;
secret?: string;
socket: AdminConnection;
theme: IobTheme;
themeName: ThemeName;
Expand Down Expand Up @@ -213,7 +213,7 @@ class JsonConfig extends Router<JsonConfigProps, JsonConfigState> {

private fileLangSubscribed = '';

private secret = '';
private secret: string;

constructor(props: JsonConfigProps) {
super(props);
Expand All @@ -227,6 +227,8 @@ class JsonConfig extends Router<JsonConfigProps, JsonConfigState> {
hash: '_',
};

this.secret = props.secret || '';

this.getInstanceObject()
.then(obj => this.getConfigFile()
.then(schema =>
Expand Down Expand Up @@ -357,9 +359,11 @@ class JsonConfig extends Router<JsonConfigProps, JsonConfigState> {
const obj = await this.props.socket.getObject(`system.adapter.${this.props.adapterName}.${this.props.instance}`);
// decode all native attributes listed in obj.encryptedNative
if (Array.isArray(obj.encryptedNative)) {
const systemConfig = await this.props.socket.getSystemConfig();
await loadScript('../../lib/js/crypto-js/crypto-js.js', 'crypto-js');
this.secret = systemConfig.native.secret;
if (!this.secret) {
const systemConfig = await this.props.socket.getSystemConfig();
await loadScript('../../lib/js/crypto-js/crypto-js.js', 'crypto-js');
this.secret = systemConfig.native.secret;
}
obj.encryptedNative?.forEach(attr => {
if (obj.native[attr]) {
obj.native[attr] = decrypt(this.secret, obj.native[attr]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class ConfigAccordion extends ConfigGeneric<ConfigAccordionProps, ConfigAccordio
}}
onError={(error, attr) => this.onError(error, attr)}
table={this.props.table}
DeviceManager={this.props.DeviceManager}
theme={this.props.theme}
/>;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/jsonConfig/src/JsonConfigComponent/ConfigPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type JSXElementConstructor } from 'react';
import React from 'react';

import {
Grid,
Expand All @@ -12,6 +12,7 @@ import { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';

import { type IobTheme } from '@iobroker/adapter-react-v5';
import type { ConfigItemPanel } from '#JC/types';
import Utils from '#JC/Utils';

import ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';
// eslint-disable-next-line import/no-cycle
Expand Down Expand Up @@ -65,7 +66,6 @@ import ConfigTimePicker from './ConfigTimePicker';
import ConfigTopic from './ConfigTopic';
import ConfigUUID from './ConfigUUID';
import ConfigUser from './ConfigUser';
import Utils from "#JC/Utils";

const components: Record<string, typeof ConfigGeneric<any, any>> = {
accordion: ConfigAccordion,
Expand Down Expand Up @@ -231,6 +231,7 @@ class ConfigPanel extends ConfigGeneric<ConfigPanelProps, ConfigPanelState> {
instanceObj={this.props.instanceObj}
custom={this.props.custom}
schema={items[attr]}
DeviceManager={this.props.DeviceManager}
attr={attr}
table={this.props.table}
/>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ class ConfigTable extends ConfigGeneric<ConfigTableProps, ConfigTableState> {
originalData={this.props.originalData}
customs={this.props.customs}
theme={this.props.theme}
DeviceManager={this.props.DeviceManager}
onChange={(attr: string, valueChange: any) => {
const newObj: Record<string, any>[] = JSON.parse(JSON.stringify(this.state.value));
newObj[idx][attr] = valueChange;
Expand Down
1 change: 1 addition & 0 deletions packages/jsonConfig/src/JsonConfigComponent/ConfigTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class ConfigTabs extends ConfigGeneric<ConfigTabsProps, ConfigTabsState> {
schema={items[this.state.tab]}
table={this.props.table}
theme={this.props.theme}
DeviceManager={this.props.DeviceManager}
withIcons={withIcons}
/>
</div>;
Expand Down

0 comments on commit d67b3f7

Please sign in to comment.