iobroker.webui 1.17.3 → 1.18.0

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
@@ -129,6 +129,9 @@ runtime.html?screenName=screen2
129
129
  Placeholder for next versions:
130
130
  ### __WORK IN PROGRESS__
131
131
  -->
132
+ ### 1.18.0 (2024-11-01)
133
+ - screens are now ex- & imported as xml
134
+
132
135
  ### 1.17.3 (2024-11-01)
133
136
  - fix compilation
134
137
 
package/io-package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "webui",
4
- "version": "1.17.3",
4
+ "version": "1.18.0",
5
5
  "titleLang": {
6
6
  "en": "webui",
7
7
  "de": "webui",
@@ -29,6 +29,19 @@
29
29
  "zh-cn": "使用万维网传送器的高锰用户接口"
30
30
  },
31
31
  "news": {
32
+ "1.18.0": {
33
+ "en": "screens are now ex- & imported as xml",
34
+ "de": "bildschirme werden jetzt ex- & importiert als xml",
35
+ "ru": "экраны теперь экс-и импортированы как xml",
36
+ "pt": "telas são agora ex- & importadas como xml",
37
+ "nl": "schermen worden nu ex- & geïmporteerd als xml",
38
+ "fr": "les écrans sont maintenant ex- & importés comme xml",
39
+ "it": "schermi sono ora ex- & importati come xml",
40
+ "es": "pantallas ahora son ex- \" importadas como xml",
41
+ "pl": "ekrany są teraz ex- & importowane jako xml",
42
+ "uk": "екрани тепер екс- та імпортовані як xml",
43
+ "zh-cn": "屏幕现在以 xml 导入( i)"
44
+ },
32
45
  "1.17.3": {
33
46
  "en": "fix compilation",
34
47
  "de": "fix compilation",
@@ -106,19 +119,6 @@
106
119
  "pl": "błędne domyślne w skrypcie",
107
120
  "uk": "неправильний типовий скрипт",
108
121
  "zh-cn": "脚本默认错误"
109
- },
110
- "1.16.1": {
111
- "en": "fix base custom webcomp bindings",
112
- "de": "fix base benutzerdefinierte webcomp bindungen",
113
- "ru": "исправление базовых пользовательских веб-композиций",
114
- "pt": "corrigir ligações de webcomp de base personalizada",
115
- "nl": "fix basis aangepaste webcomp bindingen",
116
- "fr": "fixer les fixations webcomp personnalisées de base",
117
- "it": "fissaggio di base personalizzati webcomp binding",
118
- "es": "fijar bases de unión personalizadas webcomp",
119
- "pl": "fix bazowe niestandardowe wiązania webcomp",
120
- "uk": "фіксувати базові користувацькі прив'язки вебкомп'ютера",
121
- "zh-cn": "固定自定义网络comp 绑定"
122
122
  }
123
123
  },
124
124
  "icon": "logo.png",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.webui",
3
- "version": "1.17.3",
3
+ "version": "1.18.0",
4
4
  "description": "ioBroker webui",
5
5
  "type": "module",
6
6
  "main": "dist/backend/main.js",
@@ -87,7 +87,10 @@ export class IobrokerWebuiControlPropertiesEditor extends BaseCustomWebComponent
87
87
  this._bindingsRefresh();
88
88
  }
89
89
  addEnumProp() {
90
- this.properties.push({ name: '', type: 'enum', values: '["a", "b"]' });
90
+ let p = { name: '', type: 'enum', values: '["a", "b"]' };
91
+ if (this.defaultInternal)
92
+ p.internal = true;
93
+ this.properties.push(p);
91
94
  this._bindingsRefresh();
92
95
  }
93
96
  removeProp(index) {
@@ -10,6 +10,7 @@ import wunderbaumStyle from 'wunderbaum/dist/wunderbaum.css' with { type: 'css'
10
10
  import { defaultNewStyle } from "./IobrokerWebuiScreenEditor.js";
11
11
  import { IobrokerWebuiIconsView } from "./IobrokerWebuiIconsView.js";
12
12
  import { IobrokerWebuiScreensView } from "./IobrokerWebuiScreensView.js";
13
+ import { convertToXml, parseXml } from "../helper/XmlHelper.js";
13
14
  export class IobrokerWebuiSolutionExplorer extends BaseCustomWebComponentConstructorAppend {
14
15
  static template = html `
15
16
  <div id="treeDiv" class="" style="overflow: auto; width:100%; height: 100%;">
@@ -95,11 +96,21 @@ export class IobrokerWebuiSolutionExplorer extends BaseCustomWebComponentConstru
95
96
  try {
96
97
  let files = await openFileDialog('.' + type, true, 'text');
97
98
  for (let f of files) {
98
- let data = JSON.parse(f.data);
99
+ let data = null;
100
+ if (f.data[0] === '<') {
101
+ data = parseXml(f.data);
102
+ }
103
+ else {
104
+ data = JSON.parse(f.data);
105
+ }
99
106
  let nm = f.name;
100
- if (nm.endsWith('.' + type))
107
+ if (nm.endsWith('.' + type)) {
101
108
  nm = nm.substring(0, nm.length - type.length - 1);
102
- await iobrokerHandler.saveObject(type, (dir ?? '') + '/' + nm, data);
109
+ }
110
+ nm = prompt('Import as:', nm);
111
+ if (nm) {
112
+ await iobrokerHandler.saveObject(type, (dir ?? '') + '/' + nm, data);
113
+ }
103
114
  }
104
115
  }
105
116
  catch (err) {
@@ -175,15 +186,10 @@ export class IobrokerWebuiSolutionExplorer extends BaseCustomWebComponentConstru
175
186
  ContextMenu.show([{
176
187
  title: 'Export ' + type, action: async () => {
177
188
  let data = await iobrokerHandler.getWebuiObject(type, (dir ?? '') + '/' + name);
178
- await exportData(JSON.stringify(data), name + '.' + type);
179
- }
180
- }, /*{
181
- title: 'Export Screen as XML', action: async () => {
182
- let data = await iobrokerHandler.getScreen(name);
183
- await exportData(screenToXml(data), name + '.screen')
189
+ let xml = convertToXml(type, data);
190
+ await exportData(xml, name + '.' + type);
184
191
  }
185
- },*/
186
- {
192
+ }, {
187
193
  title: 'Copy ' + type, action: async () => {
188
194
  let newName = prompt("New Name", name);
189
195
  if (newName && newName != name) {
@@ -5,20 +5,46 @@ export function parseXml(xml) {
5
5
  let doc = new DOMParser().parseFromString(xml, "text/xml");
6
6
  let obj = {};
7
7
  for (let childNode of doc.children[0].children) {
8
- let tx = childNode.textContent;
9
- if (tx[0] === '\n' && tx.endsWith('\n'))
10
- tx = tx.substring(1, tx.length - 2);
11
- else if (tx[0] === '\n')
12
- tx = tx.substring(1);
13
- else if (tx.endsWith('\n'))
14
- tx = tx.substring(0, tx.length - 1);
15
- obj[childNode.nodeName] = tx;
8
+ if (childNode.nodeName == 'properties') {
9
+ obj.properties = {};
10
+ for (let p of childNode.children) {
11
+ let prp = {
12
+ type: p.getAttribute('type')
13
+ };
14
+ let def = p.getAttribute('default');
15
+ if (def)
16
+ prp.default = def;
17
+ let values = p.getAttribute('values');
18
+ if (values)
19
+ prp.values = values.split('|');
20
+ let internal = p.getAttribute('internal');
21
+ if (internal)
22
+ prp.internal = internal;
23
+ obj.properties[p.getAttribute('name')] = prp;
24
+ }
25
+ }
26
+ else if (childNode.nodeName == 'settings') {
27
+ obj.settings = {};
28
+ for (let p of childNode.children) {
29
+ obj.settings[p.nodeName] = p.textContent;
30
+ }
31
+ }
32
+ else {
33
+ let tx = childNode.textContent;
34
+ if (tx[0] === '\n' && tx.endsWith('\n'))
35
+ tx = tx.substring(1, tx.length - 2);
36
+ else if (tx[0] === '\n')
37
+ tx = tx.substring(1);
38
+ else if (tx.endsWith('\n'))
39
+ tx = tx.substring(0, tx.length - 1);
40
+ obj[childNode.nodeName] = tx;
41
+ }
16
42
  }
17
43
  return obj;
18
44
  }
19
- export function screenToXml(screen) {
45
+ export function convertToXml(type, screen) {
20
46
  let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
21
- xml += "<screen>\n";
47
+ xml += type == 'screen' ? "<screen>\n" : "<control>\n";
22
48
  if (screen.html) {
23
49
  xml += " <html><![CDATA[\n";
24
50
  xml += escapeCData(screen.html);
@@ -29,43 +55,34 @@ export function screenToXml(screen) {
29
55
  xml += escapeCData(screen.style);
30
56
  xml += "\n]]></style>\n";
31
57
  }
32
- if (screen.settings && Object.getOwnPropertyNames(screen.settings).length) {
33
- xml += " <settings>\n";
34
- for (let p in screen.settings) {
35
- xml += " <" + p + ">" + screen.settings[p] + "</" + p + ">\n";
36
- }
37
- xml += "</settings>\n";
38
- }
39
- xml += "</screen>\n";
40
- return xml;
41
- }
42
- export function controlToXml(control) {
43
- let xml = '<?xml version="1.0" encoding="UTF-8"?>\n';
44
- xml += "<control>\n";
45
- if (control.html) {
46
- xml += " <html><![CDATA[\n";
47
- xml += escapeCData(control.html);
48
- xml += "\n]]></html>\n";
49
- }
50
- if (control.style) {
51
- xml += " <style><![CDATA[\n";
52
- xml += escapeCData(control.style);
53
- xml += "\n]]></style>\n";
58
+ if (screen.script) {
59
+ xml += " <script><![CDATA[\n";
60
+ xml += escapeCData(screen.script);
61
+ xml += "\n]]></script>\n";
54
62
  }
55
- if (control.properties && Object.getOwnPropertyNames(control.properties).length) {
63
+ if (screen.properties && Object.getOwnPropertyNames(screen.properties).length) {
56
64
  xml += " <properties>\n";
57
- for (let p in control.properties) {
58
- xml += ` <property name="${p}" default="${control.properties[p].default}" values="${control.properties[p].values.join('|')}">\n`;
65
+ for (let p in screen.properties) {
66
+ xml += ` <property name="${p}"`;
67
+ if (screen.properties[p].type)
68
+ xml += ` type="${screen.properties[p].type}"`;
69
+ if (screen.properties[p].default)
70
+ xml += ` default="${screen.properties[p].default}"`;
71
+ if (screen.properties[p].values)
72
+ xml += ` values="${screen.properties[p].values.join('|')}"`;
73
+ if (screen.properties[p].internal)
74
+ xml += ` internal="${screen.properties[p].internal}"`;
75
+ xml += " />\n";
59
76
  }
60
- xml += "\n</properties>\n";
77
+ xml += " </properties>\n";
61
78
  }
62
- if (control.settings && Object.getOwnPropertyNames(control.settings).length) {
79
+ if (screen.settings) {
63
80
  xml += " <settings>\n";
64
- for (let p in control.settings) {
65
- xml += " <" + p + ">" + control.settings[p] + "</" + p + ">\n";
81
+ for (let p in screen.settings) {
82
+ xml += " <" + p + ">" + screen.settings[p] + "</" + p + ">\n";
66
83
  }
67
- xml += "</settings>\n";
84
+ xml += " </settings>\n";
68
85
  }
69
- xml += "</control>\n";
86
+ xml += type == 'screen' ? "</screen>\n" : "</control>\n";
70
87
  return xml;
71
88
  }
package/www/index.html CHANGED
@@ -213,7 +213,7 @@
213
213
  </button>
214
214
  <button data-command="save" title="save" disabled><img src="./node_modules/@node-projects/web-component-designer/assets/icons/save.svg"></button>
215
215
  <div style="margin-left: 30px;">
216
- webui - 1.17.3 - cbb2ba5
216
+ webui - 1.18.0 - ccfc36f
217
217
  </div>
218
218
  <button style="margin-left: 30px;" data-command="paste" title="paste" disabled><img
219
219
  src="./node_modules/@node-projects/web-component-designer/assets/icons/paste.svg"></button>