iobroker.webui 1.17.3 → 1.18.1

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,12 @@ runtime.html?screenName=screen2
129
129
  Placeholder for next versions:
130
130
  ### __WORK IN PROGRESS__
131
131
  -->
132
+ ### 1.18.1 (2024-11-01)
133
+ - fix screen settings
134
+
135
+ ### 1.18.0 (2024-11-01)
136
+ - screens are now ex- & imported as xml
137
+
132
138
  ### 1.17.3 (2024-11-01)
133
139
  - fix compilation
134
140
 
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.1",
5
5
  "titleLang": {
6
6
  "en": "webui",
7
7
  "de": "webui",
@@ -29,6 +29,32 @@
29
29
  "zh-cn": "使用万维网传送器的高锰用户接口"
30
30
  },
31
31
  "news": {
32
+ "1.18.1": {
33
+ "en": "fix screen settings",
34
+ "de": "einstellungen für den bildschirm",
35
+ "ru": "настройки экрана",
36
+ "pt": "corrigir configurações de tela",
37
+ "nl": "scherminstellingen herstellen",
38
+ "fr": "correction des paramètres de l'écran",
39
+ "it": "impostazioni della schermata di correzione",
40
+ "es": "ajuste de la pantalla",
41
+ "pl": "ustaw ustawienia ekranu",
42
+ "uk": "фіксувати налаштування екрану",
43
+ "zh-cn": "固定屏幕设置"
44
+ },
45
+ "1.18.0": {
46
+ "en": "screens are now ex- & imported as xml",
47
+ "de": "bildschirme werden jetzt ex- & importiert als xml",
48
+ "ru": "экраны теперь экс-и импортированы как xml",
49
+ "pt": "telas são agora ex- & importadas como xml",
50
+ "nl": "schermen worden nu ex- & geïmporteerd als xml",
51
+ "fr": "les écrans sont maintenant ex- & importés comme xml",
52
+ "it": "schermi sono ora ex- & importati come xml",
53
+ "es": "pantallas ahora son ex- \" importadas como xml",
54
+ "pl": "ekrany są teraz ex- & importowane jako xml",
55
+ "uk": "екрани тепер екс- та імпортовані як xml",
56
+ "zh-cn": "屏幕现在以 xml 导入( i)"
57
+ },
32
58
  "1.17.3": {
33
59
  "en": "fix compilation",
34
60
  "de": "fix compilation",
@@ -93,32 +119,6 @@
93
119
  "pl": "podnoszenie błędów w niewdrożonych poleceniach\nbłędne uaktualnienie skryptu",
94
120
  "uk": "підняти помилки на непристойних команд\nнеправильне оновлення сценарію",
95
121
  "zh-cn": "在未执行的命令上提出错误\n错误的脚本升级"
96
- },
97
- "1.16.2": {
98
- "en": "wrong default in script",
99
- "de": "falscher standard in skript",
100
- "ru": "неправильный по умолчанию",
101
- "pt": "padrão errado no script",
102
- "nl": "verkeerde standaard in script",
103
- "fr": "mauvais par défaut dans le script",
104
- "it": "default sbagliato nello script",
105
- "es": "default en script",
106
- "pl": "błędne domyślne w skrypcie",
107
- "uk": "неправильний типовий скрипт",
108
- "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.1",
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) {
@@ -49,7 +49,7 @@
49
49
  "type": "string"
50
50
  },
51
51
  "properties": {
52
- "$ref": "#/definitions/propertiesRecord"
52
+ "$ref": "#/definitions/Record<string,{type:string;values?:string[]|undefined;default?:any;internal?:boolean|undefined;}>"
53
53
  },
54
54
  "script": {
55
55
  "type": "string"
@@ -184,6 +184,65 @@
184
184
  ],
185
185
  "type": "object"
186
186
  },
187
+ "IScreen": {
188
+ "properties": {
189
+ "html": {
190
+ "type": "string"
191
+ },
192
+ "properties": {
193
+ "$ref": "#/definitions/Record<string,{type:string;values?:string[]|undefined;default?:any;internal?:boolean|undefined;}>_1"
194
+ },
195
+ "script": {
196
+ "type": "string"
197
+ },
198
+ "settings": {
199
+ "$ref": "#/definitions/IScreenSettings"
200
+ },
201
+ "style": {
202
+ "type": "string"
203
+ }
204
+ },
205
+ "propertyOrder": [
206
+ "html",
207
+ "style",
208
+ "script",
209
+ "properties",
210
+ "settings"
211
+ ],
212
+ "type": "object"
213
+ },
214
+ "IScreenSettings": {
215
+ "properties": {
216
+ "addoptedStyles": {
217
+ "items": {
218
+ "type": "string"
219
+ },
220
+ "type": "array"
221
+ },
222
+ "height": {
223
+ "type": "string"
224
+ },
225
+ "stretch": {
226
+ "enum": [
227
+ "fill",
228
+ "none",
229
+ "uniform",
230
+ "uniformToFill"
231
+ ],
232
+ "type": "string"
233
+ },
234
+ "width": {
235
+ "type": "string"
236
+ }
237
+ },
238
+ "propertyOrder": [
239
+ "width",
240
+ "height",
241
+ "addoptedStyles",
242
+ "stretch"
243
+ ],
244
+ "type": "object"
245
+ },
187
246
  "IScriptMultiplexValue": {
188
247
  "properties": {
189
248
  "name": {
@@ -239,7 +298,11 @@
239
298
  "propertyOrder": [],
240
299
  "type": "object"
241
300
  },
242
- "propertiesRecord": {
301
+ "Record<string,{type:string;values?:string[]|undefined;default?:any;internal?:boolean|undefined;}>": {
302
+ "propertyOrder": [],
303
+ "type": "object"
304
+ },
305
+ "Record<string,{type:string;values?:string[]|undefined;default?:any;internal?:boolean|undefined;}>_1": {
243
306
  "propertyOrder": [],
244
307
  "type": "object"
245
308
  }
@@ -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.1 - 56feb62
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>