iobroker-ucl 1.0.31 → 1.0.33

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.
@@ -0,0 +1,395 @@
1
+ "use strict";
2
+ /* export interface IColumn {
3
+ getOnTopColumnName() : string; // Zeile über dem Header
4
+ getOnTopColumnColSpan() : number; // Zeile über dem Header; wieviele Spalten umfasst dieser Header
5
+ getOnTopBackgroundColor() : string; // Zeile über dem Header; Hintergrundfarbe
6
+ getOnTopCellAlignment() : string; // Zeile über dem Header; Ausrichtung
7
+ getColumnName() : string;
8
+ getColumnHeaderBackgroundColor() : string;
9
+ getValueAt(rowObject: Object, rowIndex: number) : string;
10
+ getCellBackgroundColor(row: Object, rowIndex: number) : string;
11
+ getCellForegroundColor(row: Object, rowIndex: number) : string;
12
+ getCellAlignment(row: Object) : string;
13
+ getColumnnWidth() : number;
14
+ getColumnnFontSize() : number;
15
+ }*/
16
+ var __extends = (this && this.__extends) || (function () {
17
+ var extendStatics = function (d, b) {
18
+ extendStatics = Object.setPrototypeOf ||
19
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21
+ return extendStatics(d, b);
22
+ };
23
+ return function (d, b) {
24
+ if (typeof b !== "function" && b !== null)
25
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
26
+ extendStatics(d, b);
27
+ function __() { this.constructor = d; }
28
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
+ };
30
+ })();
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.AbstractStandardTextColumn = exports.StaticIconColumn = exports.HtmlCreator = exports.HtmlTable = exports.AbstractColumn = void 0;
33
+ var AbstractColumn = /** @class */ (function () {
34
+ function AbstractColumn(columnName) {
35
+ this.columnName = columnName;
36
+ }
37
+ AbstractColumn.prototype.getColumnName = function () {
38
+ return this.columnName;
39
+ };
40
+ return AbstractColumn;
41
+ }());
42
+ exports.AbstractColumn = AbstractColumn;
43
+ var HtmlTable = /** @class */ (function () {
44
+ function HtmlTable() {
45
+ this.columns = [];
46
+ }
47
+ HtmlTable.prototype.isHeaderVisible = function () {
48
+ return this.headerVisible;
49
+ };
50
+ HtmlTable.prototype.getTableTitle = function () {
51
+ return this.tableTitle;
52
+ };
53
+ HtmlTable.prototype.setTableTitle = function (tableTitle) {
54
+ this.tableTitle = tableTitle;
55
+ };
56
+ HtmlTable.prototype.getColumns = function () {
57
+ return this.columns;
58
+ };
59
+ HtmlTable.prototype.getRows = function () {
60
+ return this.rows;
61
+ };
62
+ HtmlTable.prototype.isDoubleHeaderVisible = function () {
63
+ return this.doubleHeaderVisible;
64
+ };
65
+ HtmlTable.prototype.setHeaderVisible = function (headerVisible) {
66
+ this.headerVisible = headerVisible;
67
+ };
68
+ HtmlTable.prototype.setDoubleHeaderVisible = function (doubleHeaderVisible) {
69
+ this.doubleHeaderVisible = doubleHeaderVisible;
70
+ };
71
+ HtmlTable.prototype.setRows = function (rows) {
72
+ this.rows = rows;
73
+ };
74
+ HtmlTable.prototype.addColumn = function (column) {
75
+ this.columns.push(column);
76
+ };
77
+ return HtmlTable;
78
+ }());
79
+ exports.HtmlTable = HtmlTable;
80
+ var HtmlCreator = /** @class */ (function () {
81
+ function HtmlCreator(adapter) {
82
+ this.adapter = adapter;
83
+ this.tables = [];
84
+ this.separatorRowAfterObjectThick = [];
85
+ this.separatorRowAfterObjectThin = [];
86
+ }
87
+ HtmlCreator.prototype.addTable = function (table) {
88
+ this.tables.push(table);
89
+ };
90
+ HtmlCreator.prototype.setBackgroundImage = function (backgroundImageUrl) {
91
+ this.backgroundImageUrl = backgroundImageUrl;
92
+ };
93
+ HtmlCreator.prototype.setAdditionalHTMLaboveTable = function (additionalHTMLaboveTable) {
94
+ this.additionalHTMLaboveTable = additionalHTMLaboveTable;
95
+ };
96
+ HtmlCreator.prototype.addSeparatorAfterObjectThick = function (separator) {
97
+ this.separatorRowAfterObjectThick.push(separator);
98
+ };
99
+ HtmlCreator.prototype.addSeparatorAfterObjectThin = function (separator) {
100
+ this.separatorRowAfterObjectThin.push(separator);
101
+ };
102
+ HtmlCreator.prototype.setHtmlState = function (htmlState) {
103
+ this.htmlState = htmlState;
104
+ this.adapter.createState(htmlState, "", {
105
+ name: htmlState,
106
+ desc: htmlState,
107
+ type: 'string',
108
+ read: true,
109
+ write: true
110
+ });
111
+ };
112
+ HtmlCreator.prototype.createHTML = function () {
113
+ var _this = this;
114
+ var html = "";
115
+ html += "<html> \n";
116
+ html += " <head> \n";
117
+ html += " <style> \n";
118
+ html += " table.style1 { \n";
119
+ html += " border: 1px solid #595959; \n";
120
+ html += " border-collapse: collapse; \n";
121
+ html += " vertical-align: middle; \n";
122
+ if (this.backgroundImageUrl != null) {
123
+ //html += "background: white url(\"" + this.backgroundImageUrl + "\") no-repeat; border-collapse: collapse; \n";
124
+ }
125
+ html += " } \n";
126
+ html += " table.style2 { \n";
127
+ html += " border: 0px solid #595959; \n";
128
+ html += " border-collapse: collapse; \n";
129
+ html += " vertical-align: middle; \n";
130
+ html += " } \n";
131
+ html += " th.style1 { \n";
132
+ html += " border: 1px solid #595959; \n";
133
+ html += " border-collapse: collapse; \n";
134
+ html += " vertical-align: middle; \n";
135
+ html += " } \n";
136
+ html += " th.style2 { \n";
137
+ html += " border: 0px solid #595959; \n";
138
+ html += " border-collapse: collapse; \n";
139
+ html += " vertical-align: middle; \n";
140
+ html += " } \n";
141
+ html += " td.style1 { \n";
142
+ html += " border: 1px solid #595959; \n";
143
+ html += " border-collapse: collapse; \n";
144
+ html += " vertical-align: middle; \n";
145
+ html += " } \n";
146
+ html += " td.style2 { \n";
147
+ html += " border: 0px solid #595959; \n";
148
+ html += " border-collapse: collapse; \n";
149
+ html += " vertical-align: middle; \n";
150
+ html += " } \n";
151
+ html += " td,th { \n";
152
+ html += " padding-top: 4px; \n";
153
+ html += " padding-bottom: 4px; \n";
154
+ html += " padding-left: 4px; \n";
155
+ html += " padding-right: 4px; \n";
156
+ html += " } \n";
157
+ html += " </style> \n";
158
+ html += " </head> \n";
159
+ html += " <body> \n";
160
+ if (this.additionalHTMLaboveTable != null) {
161
+ html += this.additionalHTMLaboveTable; // + "<p>";
162
+ }
163
+ if (this.backgroundImageUrl != null) {
164
+ //html += "background: white url(\"" + this.backgroundImageUrl + "\") no-repeat; border-collapse: collapse; \n";
165
+ html += " <table class=\"style1\" width=\"95%\" style=\"margin:5px\" background=\"" + this.backgroundImageUrl + "\"> \n";
166
+ }
167
+ else {
168
+ html += " <table class=\"style1\" width=\"95%\" style=\"margin:5px\"> \n";
169
+ }
170
+ //<table border=1 background="bg-red.png">
171
+ // Max. Columns ermitteln:
172
+ var maxCols = 0;
173
+ this.tables.forEach(function (table) {
174
+ if (table.getColumns().length > maxCols) {
175
+ maxCols = table.getColumns().length;
176
+ }
177
+ });
178
+ var tableIndex = 0;
179
+ this.tables.forEach(function (table) {
180
+ if (tableIndex++ != 0) {
181
+ html += " <tr class=\"style1\"><td class=\"style1\" colspan=\"" + maxCols + "\" style=\"padding: 6px; background-color:#212121\"></td></tr>";
182
+ }
183
+ if (table.isDoubleHeaderVisible() == true) {
184
+ html += " <tr class=\"style1\"> \n";
185
+ var skipColumns = 0;
186
+ table.getColumns().forEach(function (column) {
187
+ if (skipColumns == 0) {
188
+ var colSpan = column.getOnTopColumnColSpan();
189
+ if (colSpan == null) {
190
+ colSpan = 1;
191
+ }
192
+ // Alignment:
193
+ var userAlignemt = column.getOnTopCellAlignment();
194
+ var cellAlignment = " text-align:left";
195
+ if (userAlignemt != null) {
196
+ cellAlignment = " text-align:" + userAlignemt;
197
+ }
198
+ // Background-Color:
199
+ var userBackground = column.getOnTopBackgroundColor();
200
+ var cellBackground = "";
201
+ if (userBackground != null) {
202
+ cellBackground = " background-color:" + userBackground + ";";
203
+ }
204
+ //html += " <th colspan=\"" + colSpan + "\" style=\"text-align:left " + cellBackground + "\"><font size=2px\">" + column.getOnTopColumnName() + "</th></font> \n";
205
+ html += " <th class=\"style1\" colspan=\"" + colSpan + "\" + style=\" " + cellBackground + cellAlignment + "\">" + column.getOnTopColumnName() + "</th>";
206
+ skipColumns += colSpan - 1;
207
+ }
208
+ else {
209
+ skipColumns--;
210
+ }
211
+ });
212
+ html += " </tr> \n";
213
+ }
214
+ if (table.isHeaderVisible() == true) {
215
+ html += " <tr class=\"style1\"> \n";
216
+ table.getColumns().forEach(function (column) {
217
+ // Background-Color:
218
+ var userBackground = column.getColumnHeaderBackgroundColor();
219
+ if (userBackground != null) {
220
+ //html += " <th><font size=2px\">" + column.getColumnName() + "</th></font> \n";
221
+ var cellBackground = " background-color:" + userBackground + ";";
222
+ html += " <th class=\"style1\" style=\" " + cellBackground + "\">" + "<font size=2px\">" + column.getColumnName() + "</font></th>";
223
+ }
224
+ else {
225
+ html += " <th class=\"style1\"><font size=2px\">" + column.getColumnName() + "</th></font> \n";
226
+ }
227
+ });
228
+ html += " </tr> \n";
229
+ }
230
+ if (table.getTableTitle() != null) {
231
+ //html += " <tr><td colspan=\"" + maxCols + "\" style=\"padding: 6px; background-color:#212121\"></td></tr>";
232
+ html += " <tr class=\"style1\">\n";
233
+ html += " <td class=\"style1\" colspan=\"" + maxCols + "\">" + table.getTableTitle() + "</td> \n";
234
+ html += " </tr> \n";
235
+ }
236
+ var rowIndex = -1;
237
+ table.getRows().forEach(function (row) {
238
+ rowIndex++;
239
+ html += " <tr class=\"style1\"> \n";
240
+ table.getColumns().forEach(function (column) {
241
+ var cellValue = column.getValueAt(row, rowIndex);
242
+ // Alignment:
243
+ var userAlignemt = column.getCellAlignment(row);
244
+ var cellAlignment = "text-align:left";
245
+ if (userAlignemt != null) {
246
+ cellAlignment = "text-align:" + userAlignemt + ";";
247
+ }
248
+ // Width:
249
+ var userWidth = column.getColumnnWidth();
250
+ var cellWidth = "";
251
+ if (userWidth != null && userWidth != -1) {
252
+ cellWidth = "width=\"" + userWidth + "px\"; ";
253
+ }
254
+ // Background-Color:
255
+ var userBackground = column.getCellBackgroundColor(row, rowIndex);
256
+ var cellBackground = "";
257
+ if (userBackground != null) {
258
+ cellBackground = "background-color:" + userBackground + ";";
259
+ }
260
+ // Foreground-Color:
261
+ var userForeground = column.getCellForegroundColor(row, rowIndex);
262
+ var cellForegorund = "";
263
+ if (userForeground != null) {
264
+ cellForegorund = "color:" + userForeground + ";";
265
+ }
266
+ // Font size:
267
+ if (column.getColumnnFontSize() == null) {
268
+ html += " <td class=\"style1\"" + cellWidth + " style=\" " + cellForegorund + cellBackground + cellAlignment + " \">" + cellValue + "</td>";
269
+ }
270
+ else {
271
+ html += " <td class=\"style1\"" + cellWidth + " style=\" " + cellForegorund + cellBackground + cellAlignment + " \">" + "<font size=\"" + column.getColumnnFontSize() + "\" >" + cellValue + "</font></td>";
272
+ }
273
+ });
274
+ html += " </tr> \n";
275
+ // Separator Thick:
276
+ var found = false;
277
+ for (var i = 0; i < _this.separatorRowAfterObjectThick.length; i++) {
278
+ if (_this.separatorRowAfterObjectThick[i] == row) {
279
+ found = true;
280
+ break;
281
+ }
282
+ }
283
+ if (found) {
284
+ html += " <tr class=\"style1\"> \n";
285
+ html += " <td class=\"style1\" colspan=\"" + table.getColumns().length + "\" style=\"padding: 6px; background-color:#212121\"></td>";
286
+ html += " </tr> \n";
287
+ }
288
+ // Separator Thin:
289
+ var found = false;
290
+ for (var i = 0; i < _this.separatorRowAfterObjectThin.length; i++) {
291
+ if (_this.separatorRowAfterObjectThin[i] == row) {
292
+ found = true;
293
+ break;
294
+ }
295
+ }
296
+ if (found) {
297
+ html += " <tr class=\"style1\"> \n";
298
+ html += " <td class=\"style1\" colspan=\"" + table.getColumns().length + "\" style=\"padding: 2px; background-color:#AAAAAA\"></td>";
299
+ html += " </tr> \n";
300
+ }
301
+ });
302
+ });
303
+ html += "</table>\n";
304
+ html += "</body>\n";
305
+ html += "</html>\n";
306
+ this.adapter.setState(this.htmlState, html);
307
+ };
308
+ return HtmlCreator;
309
+ }());
310
+ exports.HtmlCreator = HtmlCreator;
311
+ // Icon Spalte die sich nie ändert
312
+ var StaticIconColumn = /** @class */ (function (_super) {
313
+ __extends(StaticIconColumn, _super);
314
+ function StaticIconColumn(iconURL) {
315
+ var _this = _super.call(this, iconURL) || this;
316
+ _this.iconURL = iconURL;
317
+ return _this;
318
+ }
319
+ StaticIconColumn.prototype.getOnTopBackgroundColor = function () {
320
+ return null;
321
+ };
322
+ StaticIconColumn.prototype.getColumnHeaderBackgroundColor = function () {
323
+ return null; // normaler Header-Hintergrundfarbe / null --> ohne, sonst "#FFFFFF"
324
+ };
325
+ StaticIconColumn.prototype.getCellBackgroundColor = function (row, rowIndex) {
326
+ return null; //"#484848";
327
+ };
328
+ StaticIconColumn.prototype.getOnTopCellAlignment = function () {
329
+ return null; //"center";
330
+ };
331
+ StaticIconColumn.prototype.getCellForegroundColor = function (row, rowIndex) {
332
+ return null; // null (für Standard) oder z.B. "#485A64";
333
+ };
334
+ StaticIconColumn.prototype.getCellAlignment = function (row) {
335
+ return "center"; // null (für Standard=left) oder left, right, center
336
+ };
337
+ StaticIconColumn.prototype.getColumnnWidth = function () {
338
+ return 40; // null oder z.B. 50 für "50 Pixel"
339
+ };
340
+ StaticIconColumn.prototype.getColumnnFontSize = function () {
341
+ return null; // null = Default
342
+ };
343
+ StaticIconColumn.prototype.getOnTopColumnName = function () {
344
+ return null; // null wenn Doppelt Header ausgeschalten
345
+ };
346
+ ;
347
+ StaticIconColumn.prototype.getOnTopColumnColSpan = function () {
348
+ return 1;
349
+ };
350
+ StaticIconColumn.prototype.getValueAt = function (rowObject, rowIndex) {
351
+ return "<img src=\"" + this.iconURL + "\" width=28px>";
352
+ };
353
+ return StaticIconColumn;
354
+ }(AbstractColumn));
355
+ exports.StaticIconColumn = StaticIconColumn;
356
+ var AbstractStandardTextColumn = /** @class */ (function (_super) {
357
+ __extends(AbstractStandardTextColumn, _super);
358
+ function AbstractStandardTextColumn() {
359
+ return _super.call(this, "") || this;
360
+ }
361
+ AbstractStandardTextColumn.prototype.getOnTopBackgroundColor = function () {
362
+ return null;
363
+ };
364
+ AbstractStandardTextColumn.prototype.getColumnHeaderBackgroundColor = function () {
365
+ return null; // normaler Header-Hintergrundfarbe / null --> ohne, sonst "#FFFFFF"
366
+ };
367
+ AbstractStandardTextColumn.prototype.getCellBackgroundColor = function (row, rowIndex) {
368
+ return null; //"#484848";
369
+ };
370
+ AbstractStandardTextColumn.prototype.getOnTopCellAlignment = function () {
371
+ return null; //"center";
372
+ };
373
+ AbstractStandardTextColumn.prototype.getCellForegroundColor = function (row, rowIndex) {
374
+ return null; // null (für Standard) oder z.B. "#485A64";
375
+ };
376
+ AbstractStandardTextColumn.prototype.getCellAlignment = function (row) {
377
+ return null; // null (für Standard=left) oder left, right, center
378
+ };
379
+ AbstractStandardTextColumn.prototype.getColumnnWidth = function () {
380
+ return null; // null oder z.B. 50 für "50 Pixel"
381
+ };
382
+ AbstractStandardTextColumn.prototype.getColumnnFontSize = function () {
383
+ return null; // null = Default
384
+ };
385
+ AbstractStandardTextColumn.prototype.getOnTopColumnName = function () {
386
+ return null; // null wenn Doppelt Header ausgeschalten
387
+ };
388
+ ;
389
+ AbstractStandardTextColumn.prototype.getOnTopColumnColSpan = function () {
390
+ return 1;
391
+ };
392
+ return AbstractStandardTextColumn;
393
+ }(AbstractColumn));
394
+ exports.AbstractStandardTextColumn = AbstractStandardTextColumn;
395
+ module.exports = { AbstractColumn: AbstractColumn, HtmlTable: HtmlTable, HtmlCreator: HtmlCreator, StaticIconColumn: StaticIconColumn, AbstractStandardTextColumn: AbstractStandardTextColumn };
@@ -0,0 +1,468 @@
1
+ /* export interface IColumn {
2
+ getOnTopColumnName() : string; // Zeile über dem Header
3
+ getOnTopColumnColSpan() : number; // Zeile über dem Header; wieviele Spalten umfasst dieser Header
4
+ getOnTopBackgroundColor() : string; // Zeile über dem Header; Hintergrundfarbe
5
+ getOnTopCellAlignment() : string; // Zeile über dem Header; Ausrichtung
6
+ getColumnName() : string;
7
+ getColumnHeaderBackgroundColor() : string;
8
+ getValueAt(rowObject: Object, rowIndex: number) : string;
9
+ getCellBackgroundColor(row: Object, rowIndex: number) : string;
10
+ getCellForegroundColor(row: Object, rowIndex: number) : string;
11
+ getCellAlignment(row: Object) : string;
12
+ getColumnnWidth() : number;
13
+ getColumnnFontSize() : number;
14
+ }*/
15
+
16
+ export abstract class AbstractColumn {
17
+ private columnName: string;
18
+
19
+ constructor(columnName: string) {
20
+ this.columnName = columnName;
21
+ }
22
+
23
+ public getColumnName() : string {
24
+ return this.columnName;
25
+ }
26
+
27
+ abstract getOnTopColumnName() : string; // Zeile über dem Header
28
+ abstract getOnTopColumnColSpan() : number; // Zeile über dem Header; wieviele Spalten umfasst dieser Header
29
+ abstract getOnTopBackgroundColor() : string; // Zeile über dem Header; Hintergrundfarbe
30
+ abstract getOnTopCellAlignment() : string; // Zeile über dem Header; Ausrichtung
31
+ abstract getColumnHeaderBackgroundColor() : string;
32
+ abstract getValueAt(rowObject: Object, rowIndex: number) : string;
33
+ abstract getCellBackgroundColor(row: Object, rowIndex: number) : string;
34
+ abstract getCellForegroundColor(row: Object, rowIndex: number) : string;
35
+ abstract getCellAlignment(row: Object) : string;
36
+ abstract getColumnnWidth() : number;
37
+ abstract getColumnnFontSize() : number;
38
+ }
39
+
40
+ export class HtmlTable {
41
+ private headerVisible: boolean;
42
+ private doubleHeaderVisible: boolean;
43
+ private columns: AbstractColumn[];
44
+ private rows: Object[];
45
+ private tableTitle: string;
46
+
47
+ constructor() {
48
+ this.columns = [];
49
+ }
50
+
51
+ public isHeaderVisible() : boolean {
52
+ return this.headerVisible;
53
+ }
54
+
55
+ public getTableTitle() : string {
56
+ return this.tableTitle;
57
+ }
58
+
59
+ public setTableTitle(tableTitle: string) {
60
+ this.tableTitle = tableTitle;
61
+ }
62
+
63
+ public getColumns() : AbstractColumn[] {
64
+ return this.columns;
65
+ }
66
+
67
+ public getRows() : Object[] {
68
+ return this.rows;
69
+ }
70
+
71
+ public isDoubleHeaderVisible() : boolean {
72
+ return this.doubleHeaderVisible;
73
+ }
74
+
75
+ public setHeaderVisible(headerVisible: boolean) {
76
+ this.headerVisible = headerVisible;
77
+ }
78
+
79
+ public setDoubleHeaderVisible(doubleHeaderVisible: boolean) {
80
+ this.doubleHeaderVisible = doubleHeaderVisible;
81
+ }
82
+
83
+ public setRows(rows: Object[]) {
84
+ this.rows = rows;
85
+ }
86
+
87
+ public addColumn(column: AbstractColumn) {
88
+ this.columns.push(column);
89
+ }
90
+ }
91
+
92
+
93
+ export class HtmlCreator {
94
+ private htmlState: string;
95
+ private additionalHTMLaboveTable: string;
96
+ private backgroundImageUrl: string;
97
+ private tables: HtmlTable[];
98
+ private separatorRowAfterObjectThick: Object[];
99
+ private separatorRowAfterObjectThin: Object[];
100
+
101
+ private adapter: any;
102
+
103
+ constructor(adapter: any) {
104
+ this.adapter = adapter;
105
+ this.tables = [];
106
+ this.separatorRowAfterObjectThick = [];
107
+ this.separatorRowAfterObjectThin = [];
108
+ }
109
+
110
+ public addTable(table: HtmlTable) {
111
+ this.tables.push(table);
112
+ }
113
+
114
+ public setBackgroundImage(backgroundImageUrl: string) {
115
+ this.backgroundImageUrl = backgroundImageUrl;
116
+ }
117
+
118
+ public setAdditionalHTMLaboveTable(additionalHTMLaboveTable: string) {
119
+ this.additionalHTMLaboveTable = additionalHTMLaboveTable;
120
+ }
121
+
122
+ public addSeparatorAfterObjectThick(separator: Object) {
123
+ this.separatorRowAfterObjectThick.push(separator);
124
+ }
125
+
126
+ public addSeparatorAfterObjectThin(separator: Object) {
127
+ this.separatorRowAfterObjectThin.push(separator);
128
+ }
129
+
130
+ public setHtmlState(htmlState: string) {
131
+ this.htmlState = htmlState;
132
+ this.adapter.createState(htmlState, "", {
133
+ name: htmlState,
134
+ desc: htmlState,
135
+ type: 'string',
136
+ read: true,
137
+ write: true
138
+ });
139
+ }
140
+
141
+
142
+ public createHTML() {
143
+ var html = "";
144
+
145
+ html += "<html> \n";
146
+ html += " <head> \n";
147
+ html += " <style> \n";
148
+ html += " table.style1 { \n";
149
+ html += " border: 1px solid #595959; \n";
150
+ html += " border-collapse: collapse; \n";
151
+ html += " vertical-align: middle; \n";
152
+
153
+ if (this.backgroundImageUrl != null) {
154
+ //html += "background: white url(\"" + this.backgroundImageUrl + "\") no-repeat; border-collapse: collapse; \n";
155
+ }
156
+
157
+ html += " } \n";
158
+ html += " table.style2 { \n";
159
+ html += " border: 0px solid #595959; \n";
160
+ html += " border-collapse: collapse; \n";
161
+ html += " vertical-align: middle; \n";
162
+ html += " } \n";
163
+ html += " th.style1 { \n";
164
+ html += " border: 1px solid #595959; \n";
165
+ html += " border-collapse: collapse; \n";
166
+ html += " vertical-align: middle; \n";
167
+ html += " } \n";
168
+ html += " th.style2 { \n";
169
+ html += " border: 0px solid #595959; \n";
170
+ html += " border-collapse: collapse; \n";
171
+ html += " vertical-align: middle; \n";
172
+ html += " } \n";
173
+ html += " td.style1 { \n";
174
+ html += " border: 1px solid #595959; \n";
175
+ html += " border-collapse: collapse; \n";
176
+ html += " vertical-align: middle; \n";
177
+ html += " } \n";
178
+ html += " td.style2 { \n";
179
+ html += " border: 0px solid #595959; \n";
180
+ html += " border-collapse: collapse; \n";
181
+ html += " vertical-align: middle; \n";
182
+ html += " } \n";
183
+ html += " td,th { \n";
184
+ html += " padding-top: 4px; \n";
185
+ html += " padding-bottom: 4px; \n";
186
+ html += " padding-left: 4px; \n";
187
+ html += " padding-right: 4px; \n";
188
+ html += " } \n";
189
+ html += " </style> \n";
190
+ html += " </head> \n";
191
+ html += " <body> \n";
192
+
193
+
194
+ if (this.additionalHTMLaboveTable != null) {
195
+ html += this.additionalHTMLaboveTable;// + "<p>";
196
+ }
197
+
198
+ if (this.backgroundImageUrl != null) {
199
+ //html += "background: white url(\"" + this.backgroundImageUrl + "\") no-repeat; border-collapse: collapse; \n";
200
+ html += " <table class=\"style1\" width=\"95%\" style=\"margin:5px\" background=\"" + this.backgroundImageUrl + "\"> \n";
201
+ } else {
202
+ html += " <table class=\"style1\" width=\"95%\" style=\"margin:5px\"> \n";
203
+ }
204
+
205
+ //<table border=1 background="bg-red.png">
206
+
207
+
208
+ // Max. Columns ermitteln:
209
+ var maxCols = 0;
210
+ this.tables.forEach(table => {
211
+ if (table.getColumns().length > maxCols) {
212
+ maxCols = table.getColumns().length;
213
+ }
214
+ });
215
+
216
+
217
+
218
+ var tableIndex = 0;
219
+ this.tables.forEach(table => {
220
+ if (tableIndex++ != 0) {
221
+ html += " <tr class=\"style1\"><td class=\"style1\" colspan=\"" + maxCols + "\" style=\"padding: 6px; background-color:#212121\"></td></tr>";
222
+ }
223
+
224
+ if (table.isDoubleHeaderVisible() == true) {
225
+ html += " <tr class=\"style1\"> \n";
226
+ var skipColumns : number = 0;
227
+ table.getColumns().forEach(column => {
228
+ if (skipColumns == 0) {
229
+ var colSpan = column.getOnTopColumnColSpan();
230
+ if (colSpan == null) {
231
+ colSpan = 1;
232
+ }
233
+
234
+ // Alignment:
235
+ var userAlignemt = column.getOnTopCellAlignment();
236
+ var cellAlignment = " text-align:left";
237
+ if (userAlignemt != null) {
238
+ cellAlignment = " text-align:" + userAlignemt;
239
+ }
240
+
241
+ // Background-Color:
242
+ var userBackground = column.getOnTopBackgroundColor();
243
+ var cellBackground = "";
244
+ if (userBackground != null) {
245
+ cellBackground = " background-color:" + userBackground + ";";
246
+ }
247
+
248
+ //html += " <th colspan=\"" + colSpan + "\" style=\"text-align:left " + cellBackground + "\"><font size=2px\">" + column.getOnTopColumnName() + "</th></font> \n";
249
+ html += " <th class=\"style1\" colspan=\"" + colSpan + "\" + style=\" " + cellBackground + cellAlignment + "\">" + column.getOnTopColumnName() + "</th>";
250
+
251
+
252
+ skipColumns += colSpan -1;
253
+ } else {
254
+ skipColumns--;
255
+ }
256
+ });
257
+ html += " </tr> \n";
258
+ }
259
+
260
+
261
+ if (table.isHeaderVisible() == true) {
262
+ html += " <tr class=\"style1\"> \n";
263
+ table.getColumns().forEach(column => {
264
+
265
+ // Background-Color:
266
+ var userBackground = column.getColumnHeaderBackgroundColor();
267
+ if (userBackground != null) {
268
+ //html += " <th><font size=2px\">" + column.getColumnName() + "</th></font> \n";
269
+ var cellBackground = " background-color:" + userBackground + ";";
270
+ html += " <th class=\"style1\" style=\" " + cellBackground + "\">" + "<font size=2px\">" + column.getColumnName() + "</font></th>";
271
+ } else {
272
+ html += " <th class=\"style1\"><font size=2px\">" + column.getColumnName() + "</th></font> \n";
273
+ }
274
+ });
275
+
276
+ html += " </tr> \n";
277
+ }
278
+
279
+ if (table.getTableTitle() != null) {
280
+ //html += " <tr><td colspan=\"" + maxCols + "\" style=\"padding: 6px; background-color:#212121\"></td></tr>";
281
+ html += " <tr class=\"style1\">\n";
282
+ html += " <td class=\"style1\" colspan=\"" + maxCols+"\">" + table.getTableTitle() + "</td> \n";
283
+ html += " </tr> \n";
284
+ }
285
+
286
+
287
+ var rowIndex: number = -1;
288
+ table.getRows().forEach(row=> {
289
+ rowIndex++;
290
+ html += " <tr class=\"style1\"> \n";
291
+ table.getColumns().forEach(column => {
292
+ var cellValue = column.getValueAt(row, rowIndex);
293
+
294
+ // Alignment:
295
+ var userAlignemt = column.getCellAlignment(row);
296
+ var cellAlignment = "text-align:left";
297
+ if (userAlignemt != null) {
298
+ cellAlignment = "text-align:" + userAlignemt + ";";
299
+ }
300
+
301
+ // Width:
302
+ var userWidth = column.getColumnnWidth();
303
+ var cellWidth = "";
304
+ if (userWidth != null && userWidth != -1) {
305
+ cellWidth = "width=\"" + userWidth + "px\"; ";
306
+ }
307
+
308
+ // Background-Color:
309
+ var userBackground = column.getCellBackgroundColor(row, rowIndex);
310
+ var cellBackground = "";
311
+ if (userBackground != null) {
312
+ cellBackground = "background-color:" + userBackground + ";";
313
+ }
314
+
315
+ // Foreground-Color:
316
+ var userForeground = column.getCellForegroundColor(row, rowIndex);
317
+ var cellForegorund = "";
318
+ if (userForeground != null) {
319
+ cellForegorund = "color:" + userForeground + ";";
320
+ }
321
+
322
+ // Font size:
323
+ if (column.getColumnnFontSize() == null) {
324
+ html += " <td class=\"style1\"" + cellWidth + " style=\" " + cellForegorund + cellBackground + cellAlignment + " \">" + cellValue + "</td>";
325
+ } else {
326
+ html += " <td class=\"style1\"" + cellWidth + " style=\" " + cellForegorund + cellBackground + cellAlignment + " \">" + "<font size=\"" + column.getColumnnFontSize() + "\" >" + cellValue + "</font></td>";
327
+ }
328
+
329
+ });
330
+ html += " </tr> \n";
331
+
332
+ // Separator Thick:
333
+ var found = false;
334
+ for(var i = 0; i < this.separatorRowAfterObjectThick.length; i++) {
335
+ if (this.separatorRowAfterObjectThick[i] == row) {
336
+ found = true;
337
+ break;
338
+ }
339
+ }
340
+ if (found) {
341
+ html += " <tr class=\"style1\"> \n";
342
+ html += " <td class=\"style1\" colspan=\"" + table.getColumns().length + "\" style=\"padding: 6px; background-color:#212121\"></td>";
343
+ html += " </tr> \n";
344
+ }
345
+
346
+ // Separator Thin:
347
+ var found = false;
348
+ for(var i = 0; i < this.separatorRowAfterObjectThin.length; i++) {
349
+ if (this.separatorRowAfterObjectThin[i] == row) {
350
+ found = true;
351
+ break;
352
+ }
353
+ }
354
+ if (found) {
355
+ html += " <tr class=\"style1\"> \n";
356
+ html += " <td class=\"style1\" colspan=\"" + table.getColumns().length + "\" style=\"padding: 2px; background-color:#AAAAAA\"></td>";
357
+ html += " </tr> \n";
358
+ }
359
+
360
+
361
+ });
362
+ });
363
+
364
+
365
+
366
+
367
+ html += "</table>\n";
368
+ html += "</body>\n";
369
+ html += "</html>\n";
370
+ this.adapter.setState(this.htmlState, html);
371
+ }
372
+ }
373
+
374
+ // Icon Spalte die sich nie ändert
375
+ export class StaticIconColumn extends AbstractColumn {
376
+ private iconURL: string;
377
+
378
+ constructor(iconURL: string) {
379
+ super(iconURL);
380
+ this.iconURL = iconURL;
381
+ }
382
+
383
+ public getOnTopBackgroundColor() : string {
384
+ return null;
385
+ }
386
+
387
+ public getColumnHeaderBackgroundColor() : string {
388
+ return null; // normaler Header-Hintergrundfarbe / null --> ohne, sonst "#FFFFFF"
389
+ }
390
+ public getCellBackgroundColor(row: Object, rowIndex: number) : string {
391
+ return null;//"#484848";
392
+ }
393
+ public getOnTopCellAlignment() : string {
394
+ return null;//"center";
395
+ }
396
+ public getCellForegroundColor(row: Object, rowIndex: number) : string {
397
+ return null;// null (für Standard) oder z.B. "#485A64";
398
+ }
399
+ public getCellAlignment(row: Object) : string {
400
+ return "center"; // null (für Standard=left) oder left, right, center
401
+ }
402
+ public getColumnnWidth() : number {
403
+ return 40; // null oder z.B. 50 für "50 Pixel"
404
+ }
405
+ public getColumnnFontSize() : number {
406
+ return null; // null = Default
407
+ }
408
+ public getOnTopColumnName() : string {
409
+ return null;// null wenn Doppelt Header ausgeschalten
410
+ };
411
+ public getOnTopColumnColSpan() : number {
412
+ return 1;
413
+ }
414
+ public getValueAt(rowObject: Object, rowIndex: number) : string {
415
+ return "<img src=\"" + this.iconURL + "\" width=28px>";
416
+ }
417
+ }
418
+
419
+
420
+
421
+ export abstract class AbstractStandardTextColumn extends AbstractColumn {
422
+ constructor() {
423
+ super("");
424
+ }
425
+ public getOnTopBackgroundColor() : string {
426
+ return null;
427
+ }
428
+ public getColumnHeaderBackgroundColor() : string {
429
+ return null; // normaler Header-Hintergrundfarbe / null --> ohne, sonst "#FFFFFF"
430
+ }
431
+ public getCellBackgroundColor(row: Object,rowIndex: number) : string {
432
+ return null;//"#484848";
433
+ }
434
+ public getOnTopCellAlignment() : string {
435
+ return null;//"center";
436
+ }
437
+ public getCellForegroundColor(row: Object,rowIndex: number) : string {
438
+ return null;// null (für Standard) oder z.B. "#485A64";
439
+ }
440
+ public getCellAlignment(row: Object) : string {
441
+ return null; // null (für Standard=left) oder left, right, center
442
+ }
443
+ public getColumnnWidth() : number {
444
+ return null; // null oder z.B. 50 für "50 Pixel"
445
+ }
446
+ public getColumnnFontSize() : number {
447
+ return null; // null = Default
448
+ }
449
+ public getOnTopColumnName() : string {
450
+ return null;// null wenn Doppelt Header ausgeschalten
451
+ };
452
+ public getOnTopColumnColSpan() : number {
453
+ return 1;
454
+ }
455
+ abstract getValueAt(rowObject: Object, rowIndex: number) : string;
456
+ }
457
+
458
+
459
+ module.exports = {AbstractColumn, HtmlTable, HtmlCreator, StaticIconColumn, AbstractStandardTextColumn };
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
package/main.js CHANGED
@@ -1,6 +1,12 @@
1
1
  var DateHelper = require('./date.js').DateHelper;
2
2
  var DateCalendarTest = require('./test.js').DateCalendarTest;
3
+ var _a = require('./abstractHTML.js'), AbstractColumn = _a.AbstractColumn, HtmlTable = _a.HtmlTable, HtmlCreator = _a.HtmlCreator, StaticIconColumn = _a.StaticIconColumn, AbstractStandardTextColumn = _a.AbstractStandardTextColumn;
3
4
  module.exports = {
4
5
  DateHelper: DateHelper,
5
- DateCalendarTest: DateCalendarTest
6
+ DateCalendarTest: DateCalendarTest,
7
+ AbstractColumn: AbstractColumn,
8
+ HtmlTable: HtmlTable,
9
+ HtmlCreator: HtmlCreator,
10
+ StaticIconColumn: StaticIconColumn,
11
+ AbstractStandardTextColumn: AbstractStandardTextColumn
6
12
  };
package/main.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  const { DateHelper } = require('./date.js');
2
2
  const { DateCalendarTest } = require('./test.js');
3
+ const { AbstractColumn, HtmlTable, HtmlCreator, StaticIconColumn, AbstractStandardTextColumn } = require('./abstractHTML.js');
3
4
 
4
5
  module.exports = {
5
6
  DateHelper,
6
- DateCalendarTest
7
+ DateCalendarTest,
8
+ AbstractColumn, HtmlTable, HtmlCreator, StaticIconColumn, AbstractStandardTextColumn
7
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker-ucl",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "build": "tsc --build",