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

Changed some aspects: translations, reuse styles, ... #29

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Various content types

![Vorschau Colorpicker](img/preview_content_types.png)

Colorpicker
Color picker

![Vorschau Colorpicker](img/preview_colorpicker.png)

Expand All @@ -39,12 +39,15 @@ Switches
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* Removed styles libraries as they are not compatible with vis 2.0

### 0.1.9 (2024-05-24)
* Fixed missing object id if type is nav (#14)
* Fixed missing object id if a type is nav (#14)
* Fixed content color for icons not working (#22)

### 0.1.7 (2024-05-22)
* Fixed missing object id if type is nav (#14)
* Fixed missing object id if a type is nav (#14)
* Fixed image aspect ratio (#15)
* Added options to customize dialog

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
"visualization"
],
"devDependencies": {
"@alcalzone/release-script": "^3.7.0",
"@alcalzone/release-script-plugin-iobroker": "^3.7.0",
"@alcalzone/release-script": "^3.7.3",
"@alcalzone/release-script-plugin-iobroker": "^3.7.2",
"@alcalzone/release-script-plugin-license": "^3.7.0",
"@iobroker/vis-2-widgets-react-dev": "^1.0.6",
"@iobroker/vis-2-widgets-react-dev": "^2.0.1",
"@types/gulp": "^4.0.17",
"@types/mocha": "^10.0.6",
"@types/node": "^20.12.7",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.10",
"eslint": "^8.57.0",
"gulp": "^4.0.2",
"mocha": "^10.4.0",
"typescript": "^5.3.3",
"@iobroker/vis-2-widgets-testing": "^1.0.3"
"mocha": "^10.6.0",
"typescript": "^5.5.3",
"@iobroker/vis-2-widgets-testing": "^1.0.4"
},
"main": "widgets/vis-2-widgets-inventwo/customWidgets.js",
"files": [
Expand Down
26 changes: 10 additions & 16 deletions src-widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,27 @@
"dependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@craco/craco": "^7.1.0",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@iobroker/adapter-react-v5": "^4.13.11",
"@iobroker/dm-gui-components": "^6.17.13",
"@iobroker/vis-2-widgets-react-dev": "^1.0.6",
"@iobroker/adapter-react-v5": "^6.0.14",
"@iobroker/vis-2-widgets-react-dev": "^2.0.1",
"@jaames/iro": "^5.5.2",
"@mui/icons-material": "^5.15.15",
"@mui/material": "5.14.14",
"@mui/styles": "5.14.14",
"@mui/x-date-pickers": "^6.19.0",
"@mui/icons-material": "^5.16.0",
"craco-esbuild": "^0.6.1",
"craco-module-federation": "^1.1.0",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-eqeqeq-fix": "^1.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.1",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"node-sass": "^9.0.0",
"prop-types": "^15.8.1",
"react": "^18.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.1.0",
"react-icons": "^5.2.1",
"react-scripts": "^5.0.1",
"sass": "^1.75.5"
"sass": "^1.77.6"
},
"scripts": {
"start": "set PORT=4173 && craco start",
Expand All @@ -50,4 +44,4 @@
"not ie <= 11",
"not op_mini all"
]
}
}
60 changes: 60 additions & 0 deletions src-widgets/src/InventwoGeneric.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { VisRxWidget } from '@iobroker/vis-2-widgets-react-dev';

class InventwoGeneric extends (window.visRxWidget || VisRxWidget) {
static getI18nPrefix() {
return 'vis_2_widgets_inventwo_';
}

onChange(e, value) {
if (this.props.editMode) {
return;
}
const oid = this.state.rxData.oid;
this.props.context.setValue(oid, parseFloat(value));
}

getValue(oid) {
if (oid !== undefined && oid !== '' && oid !== 'nothing_selected') {
return this.state.values[`${oid}.val`];
}
return undefined;
}

getStyle(widgetFieldName, attrList) {
const trackStyle = {};
const wid = this.state.rxData[widgetFieldName];
if (wid) {
let found = false;
// first try to find widget in the same view
const thisView = this.props.context.views[this.props.view];
const widgetData = thisView?.widgets?.[wid]?.data;
if (widgetData) {
// extract palette settings from widget settings
attrList.forEach(attr => trackStyle[attr] = widgetData[attr]);
found = true;
} else {
// try to find this widget
const viewIds = Object.keys(this.props.context.views);
for (let v = 0; v < viewIds.length; v++) {
const view = this.props.context.views[viewIds[v]];
if (view !== this.props.view && view.widgets?.[wid]?.data) {
const widgetData1 = view.widgets[wid].data;
// extract palette settings from widget settings
attrList.forEach(attr => trackStyle[attr] = widgetData1[attr]);
found = true;
break;
}
}
}
if (!found) {
attrList.forEach(attr => trackStyle[attr] = this.state.rxData[attr]);
}
} else {
attrList.forEach(attr => trackStyle[attr] = this.state.rxData[attr]);
}

return trackStyle;
}
}

export default InventwoGeneric;
Loading
Loading