@5minds/node-red-dashboard-2-processcube-dynamic-table 1.1.1 → 1.1.3
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/nodes/dynamic-table.html +345 -293
- package/nodes/dynamic-table.js +33 -28
- package/nodes/locales/en-US/dynamic-table.html +2 -2
- package/nodes/locales/en-US/dynamic-table.json +4 -4
- package/package.json +77 -77
- package/resources/ui-dynamic-table.umd.js +2 -0
- package/ui/main.js +3 -3
- package/resources/dynamic-table.umd.js +0 -3
- package/resources/dynamic-table.umd.js.map +0 -1
package/nodes/dynamic-table.html
CHANGED
|
@@ -1,310 +1,362 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
(function () {
|
|
3
|
+
function hasProperty(obj, prop) {
|
|
4
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
RED.nodes.registerType("ui-dynamic-table", {
|
|
8
|
+
category: "ProcessCube UI",
|
|
9
|
+
color: "#00aed7",
|
|
10
|
+
defaults: {
|
|
11
|
+
name: { value: "" },
|
|
12
|
+
tableName: { value: "" },
|
|
13
|
+
group: { type: "ui-group", required: true },
|
|
14
|
+
order: { value: 1 },
|
|
15
|
+
data: { value: "payload" },
|
|
16
|
+
data_type: { value: "msg" },
|
|
17
|
+
options: {
|
|
18
|
+
value: [{ label: "", condition: "" }],
|
|
19
|
+
validate: function (v) {
|
|
20
|
+
const unique = new Set(
|
|
21
|
+
v.map(function (o) {
|
|
22
|
+
return o.label;
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
return v.length === unique.size;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
columns: {
|
|
29
|
+
value: [{ value: "", label: "" }],
|
|
30
|
+
validate: function (v) {
|
|
31
|
+
const unique = new Set(
|
|
32
|
+
v.map(function (o) {
|
|
33
|
+
return o.value;
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
return v.length === unique.size;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
width: {
|
|
40
|
+
value: 0,
|
|
41
|
+
validate: function (v) {
|
|
42
|
+
const width = v || 0;
|
|
43
|
+
const currentGroup = $("#node-input-group").val() || this.group;
|
|
44
|
+
const groupNode = RED.nodes.node(currentGroup);
|
|
45
|
+
const valid = !groupNode || +width <= +groupNode.width;
|
|
46
|
+
$("#node-input-size").toggleClass("input-error", !valid);
|
|
47
|
+
return valid;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
height: { value: 0 },
|
|
51
|
+
outputs: { value: 1 },
|
|
52
|
+
},
|
|
53
|
+
inputs: 1,
|
|
54
|
+
outputs: 1,
|
|
55
|
+
outputLabels: function (index) {
|
|
56
|
+
return this.options[index].label;
|
|
57
|
+
},
|
|
58
|
+
icon: "file.svg",
|
|
59
|
+
paletteLbel: "file",
|
|
60
|
+
label: function () {
|
|
61
|
+
return this.name || "dynamic-table";
|
|
62
|
+
},
|
|
63
|
+
oneditprepare: function () {
|
|
64
|
+
$("#node-input-size").elementSizer({
|
|
65
|
+
width: "#node-input-width",
|
|
66
|
+
height: "#node-input-height",
|
|
67
|
+
group: "#node-input-group",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
function generateOption(i, option) {
|
|
71
|
+
const container = $("<li/>", {
|
|
72
|
+
style:
|
|
73
|
+
"background: var(--red-ui-secondary-background, #fff); margin:0; padding:8px 0px 0px;",
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Create input fields for value and label
|
|
77
|
+
const row = $("<div/>").appendTo(container);
|
|
78
|
+
$("<input/>", {
|
|
79
|
+
class: "node-input-option-label",
|
|
80
|
+
type: "text",
|
|
81
|
+
style: "margin-left:7px; width:calc(50% - 32px);",
|
|
82
|
+
placeholder: "Label",
|
|
83
|
+
value: option.label,
|
|
84
|
+
})
|
|
85
|
+
.appendTo(row)
|
|
86
|
+
.typedInput({
|
|
87
|
+
type: "str",
|
|
88
|
+
types: ["str"],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
$("<input/>", {
|
|
92
|
+
class: "node-input-option-condition",
|
|
93
|
+
type: "text",
|
|
94
|
+
style: "margin-left:7px; width:calc(50% - 32px);",
|
|
95
|
+
placeholder: "Condition",
|
|
96
|
+
value: option.condition,
|
|
97
|
+
})
|
|
98
|
+
.appendTo(row)
|
|
99
|
+
.typedInput({
|
|
100
|
+
type: "str",
|
|
101
|
+
types: ["str"],
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Create delete button for the option
|
|
105
|
+
const finalSpan = $("<span/>", {
|
|
106
|
+
style: "float:right; margin-right:8px;",
|
|
107
|
+
}).appendTo(row);
|
|
108
|
+
const deleteButton = $("<a/>", {
|
|
109
|
+
href: "#",
|
|
110
|
+
class: "editor-button editor-button-small",
|
|
111
|
+
style: "margin-top:7px; margin-left:5px;",
|
|
112
|
+
}).appendTo(finalSpan);
|
|
113
|
+
$("<i/>", { class: "fa fa-remove" }).appendTo(deleteButton);
|
|
114
|
+
|
|
115
|
+
deleteButton.click(function () {
|
|
116
|
+
container.css({
|
|
117
|
+
background: "var(--red-ui-secondary-background-inactive, #fee)",
|
|
118
|
+
});
|
|
119
|
+
container.fadeOut(300, function () {
|
|
120
|
+
$(this).remove();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
$("#node-input-option-container").append(container);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function generateColumn(i, column) {
|
|
128
|
+
const container = $("<li/>", {
|
|
129
|
+
style:
|
|
130
|
+
"background: var(--red-ui-secondary-background, #fff); margin:0; padding:8px 0px 0px;",
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Create input fields for value and label
|
|
134
|
+
const row = $("<div/>").appendTo(container);
|
|
135
|
+
$("<input/>", {
|
|
136
|
+
class: "node-input-column-value",
|
|
137
|
+
type: "text",
|
|
138
|
+
style: "margin-left:7px; width:calc(50% - 32px);",
|
|
139
|
+
placeholder: "Value",
|
|
140
|
+
value: column.value,
|
|
141
|
+
})
|
|
142
|
+
.appendTo(row)
|
|
143
|
+
.typedInput({ default: column.type || "str", types: ["str"] });
|
|
144
|
+
|
|
145
|
+
$("<input/>", {
|
|
146
|
+
class: "node-input-column-label",
|
|
147
|
+
type: "text",
|
|
148
|
+
style: "margin-left:7px; width:calc(50% - 32px);",
|
|
149
|
+
placeholder: "Label",
|
|
150
|
+
value: column.label,
|
|
151
|
+
})
|
|
152
|
+
.appendTo(row)
|
|
153
|
+
.typedInput({
|
|
154
|
+
type: "str",
|
|
155
|
+
types: ["str"],
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Create delete button for the column
|
|
159
|
+
const finalSpan = $("<span/>", {
|
|
160
|
+
style: "float:right; margin-right:8px;",
|
|
161
|
+
}).appendTo(row);
|
|
162
|
+
const deleteButton = $("<a/>", {
|
|
163
|
+
href: "#",
|
|
164
|
+
class: "editor-button editor-button-small",
|
|
165
|
+
style: "margin-top:7px; margin-left:5px;",
|
|
166
|
+
}).appendTo(finalSpan);
|
|
167
|
+
$("<i/>", { class: "fa fa-remove" }).appendTo(deleteButton);
|
|
168
|
+
|
|
169
|
+
deleteButton.click(function () {
|
|
170
|
+
container.css({
|
|
171
|
+
background: "var(--red-ui-secondary-background-inactive, #fee)",
|
|
172
|
+
});
|
|
173
|
+
container.fadeOut(300, function () {
|
|
174
|
+
$(this).remove();
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
$("#node-input-column-container").append(container);
|
|
5
179
|
}
|
|
6
180
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
validate: function (v) {
|
|
27
|
-
const unique = new Set(v.map(function (o) { return o.value }));
|
|
28
|
-
return v.length === unique.size;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
width: {
|
|
32
|
-
value: 0,
|
|
33
|
-
validate: function (v) {
|
|
34
|
-
const width = v || 0
|
|
35
|
-
const currentGroup = $('#node-input-group').val() || this.group
|
|
36
|
-
const groupNode = RED.nodes.node(currentGroup)
|
|
37
|
-
const valid = !groupNode || +width <= +groupNode.width
|
|
38
|
-
$('#node-input-size').toggleClass('input-error', !valid)
|
|
39
|
-
return valid
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
height: { value: 0 },
|
|
43
|
-
outputs: { value: 1 }
|
|
44
|
-
},
|
|
45
|
-
inputs: 1,
|
|
46
|
-
outputs: 1,
|
|
47
|
-
outputLabels: function(index) {
|
|
48
|
-
return this.options[index].label
|
|
49
|
-
},
|
|
50
|
-
icon: "file.svg",
|
|
51
|
-
label: function() {
|
|
52
|
-
return this.name || "dynamic-table";
|
|
53
|
-
},
|
|
54
|
-
oneditprepare: function () {
|
|
55
|
-
$('#node-input-size').elementSizer({
|
|
56
|
-
width: '#node-input-width',
|
|
57
|
-
height: '#node-input-height',
|
|
58
|
-
group: '#node-input-group'
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
function generateOption(i, option) {
|
|
62
|
-
const container = $('<li/>', {
|
|
63
|
-
style: 'background: var(--red-ui-secondary-background, #fff); margin:0; padding:8px 0px 0px;'
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// Create input fields for value and label
|
|
67
|
-
const row = $('<div/>').appendTo(container);
|
|
68
|
-
$('<input/>', {
|
|
69
|
-
class: 'node-input-option-label',
|
|
70
|
-
type: 'text',
|
|
71
|
-
style: 'margin-left:7px; width:calc(50% - 32px);',
|
|
72
|
-
placeholder: 'Label',
|
|
73
|
-
value: option.label
|
|
74
|
-
}).appendTo(row).typedInput({
|
|
75
|
-
type: 'str', types: ['str']
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
$('<input/>', {
|
|
79
|
-
class: 'node-input-option-condition',
|
|
80
|
-
type: 'text',
|
|
81
|
-
style: 'margin-left:7px; width:calc(50% - 32px);',
|
|
82
|
-
placeholder: 'Condition',
|
|
83
|
-
value: option.condition
|
|
84
|
-
}).appendTo(row).typedInput({
|
|
85
|
-
type: 'str', types: ['str']
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Create delete button for the option
|
|
89
|
-
const finalSpan = $('<span/>', { style: 'float:right; margin-right:8px;' }).appendTo(row);
|
|
90
|
-
const deleteButton = $('<a/>', { href: '#', class: 'editor-button editor-button-small', style: 'margin-top:7px; margin-left:5px;' }).appendTo(finalSpan);
|
|
91
|
-
$('<i/>', { class: 'fa fa-remove' }).appendTo(deleteButton);
|
|
92
|
-
|
|
93
|
-
deleteButton.click(function () {
|
|
94
|
-
container.css({ background: 'var(--red-ui-secondary-background-inactive, #fee)' });
|
|
95
|
-
container.fadeOut(300, function () {
|
|
96
|
-
$(this).remove();
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
$('#node-input-option-container').append(container);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function generateColumn(i, column) {
|
|
104
|
-
const container = $('<li/>', {
|
|
105
|
-
style: 'background: var(--red-ui-secondary-background, #fff); margin:0; padding:8px 0px 0px;'
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// Create input fields for value and label
|
|
109
|
-
const row = $('<div/>').appendTo(container);
|
|
110
|
-
$('<input/>', {
|
|
111
|
-
class: 'node-input-column-value',
|
|
112
|
-
type: 'text',
|
|
113
|
-
style: 'margin-left:7px; width:calc(50% - 32px);',
|
|
114
|
-
placeholder: 'Value',
|
|
115
|
-
value: column.value
|
|
116
|
-
}).appendTo(row).typedInput({ default: column.type || 'str', types: ['str'] });
|
|
117
|
-
|
|
118
|
-
$('<input/>', {
|
|
119
|
-
class: 'node-input-column-label',
|
|
120
|
-
type: 'text',
|
|
121
|
-
style: 'margin-left:7px; width:calc(50% - 32px);',
|
|
122
|
-
placeholder: 'Label',
|
|
123
|
-
value: column.label
|
|
124
|
-
}).appendTo(row).typedInput({
|
|
125
|
-
type: 'str', types: ['str']
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Create delete button for the column
|
|
129
|
-
const finalSpan = $('<span/>', { style: 'float:right; margin-right:8px;' }).appendTo(row);
|
|
130
|
-
const deleteButton = $('<a/>', { href: '#', class: 'editor-button editor-button-small', style: 'margin-top:7px; margin-left:5px;' }).appendTo(finalSpan);
|
|
131
|
-
$('<i/>', { class: 'fa fa-remove' }).appendTo(deleteButton);
|
|
132
|
-
|
|
133
|
-
deleteButton.click(function () {
|
|
134
|
-
container.css({ background: 'var(--red-ui-secondary-background-inactive, #fee)' });
|
|
135
|
-
container.fadeOut(300, function () {
|
|
136
|
-
$(this).remove();
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
$('#node-input-column-container').append(container);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
$('#node-input-add-column').click(function () {
|
|
144
|
-
generateColumn($('#node-input-column-container').children().length + 1, {});
|
|
145
|
-
$('#node-input-column-container-div').scrollTop($('#node-input-column-container-div').get(0).scrollHeight);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
for (let i = 0; i < this.columns.length; i++) {
|
|
149
|
-
const column = this.columns[i];
|
|
150
|
-
generateColumn(i + 1, column);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
$('#node-input-column-container').sortable({
|
|
154
|
-
axis: 'y',
|
|
155
|
-
handle: '.node-input-column-handle',
|
|
156
|
-
cursor: 'move'
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
$('#node-input-add-option').click(function () {
|
|
160
|
-
generateOption($('#node-input-option-container').children().length + 1, {});
|
|
161
|
-
$('#node-input-option-container-div').scrollTop($('#node-input-option-container-div').get(0).scrollHeight);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
for (let i = 0; i < this.options.length; i++) {
|
|
165
|
-
const option = this.options[i];
|
|
166
|
-
generateOption(i + 1, option);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
$('#node-input-option-container').sortable({
|
|
170
|
-
axis: 'y',
|
|
171
|
-
handle: '.node-input-option-handle',
|
|
172
|
-
cursor: 'move'
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
$("#node-input-data").typedInput({
|
|
176
|
-
default: 'msg',
|
|
177
|
-
types: ['msg', 'json', 'flow', 'global']
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
$("#node-input-data").typedInput('value', this.data);
|
|
181
|
-
$("#node-input-data").typedInput('type', this.data_type);
|
|
182
|
-
},
|
|
183
|
-
oneditsave: function () {
|
|
184
|
-
const options = $('#node-input-option-container').children();
|
|
185
|
-
const node = this;
|
|
186
|
-
node.options = [];
|
|
187
|
-
options.each(function (i) {
|
|
188
|
-
const option = $(this);
|
|
189
|
-
const o = {
|
|
190
|
-
label: option.find('.node-input-option-label').val(),
|
|
191
|
-
condition: option.find('.node-input-option-condition').val()
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
node.options.push(o);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const columns = $('#node-input-column-container').children();
|
|
198
|
-
node.columns = [];
|
|
199
|
-
columns.each(function (i) {
|
|
200
|
-
const column = $(this);
|
|
201
|
-
const c = {
|
|
202
|
-
label: column.find('.node-input-column-label').val(),
|
|
203
|
-
value: column.find('.node-input-column-value').typedInput('value'),
|
|
204
|
-
type: column.find('.node-input-column-value').typedInput('type')
|
|
205
|
-
};
|
|
206
|
-
if (column.find('.node-input-column-value').typedInput('type') === 'num') {
|
|
207
|
-
c.value = Number(c.value);
|
|
208
|
-
}
|
|
209
|
-
if (column.find('.node-input-column-value').typedInput('type') === 'bool') {
|
|
210
|
-
c.value = (c.value === 'true');
|
|
211
|
-
}
|
|
212
|
-
node.columns.push(c);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
this.outputs = node.options.length || 1
|
|
216
|
-
|
|
217
|
-
this.data = $("#node-input-data").typedInput('value'),
|
|
218
|
-
this.data_type = $("#node-input-data").typedInput('type')
|
|
219
|
-
},
|
|
181
|
+
$("#node-input-add-column").click(function () {
|
|
182
|
+
generateColumn(
|
|
183
|
+
$("#node-input-column-container").children().length + 1,
|
|
184
|
+
{}
|
|
185
|
+
);
|
|
186
|
+
$("#node-input-column-container-div").scrollTop(
|
|
187
|
+
$("#node-input-column-container-div").get(0).scrollHeight
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
192
|
+
const column = this.columns[i];
|
|
193
|
+
generateColumn(i + 1, column);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
$("#node-input-column-container").sortable({
|
|
197
|
+
axis: "y",
|
|
198
|
+
handle: ".node-input-column-handle",
|
|
199
|
+
cursor: "move",
|
|
220
200
|
});
|
|
221
|
-
})();
|
|
222
|
-
</script>
|
|
223
201
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
202
|
+
$("#node-input-add-option").click(function () {
|
|
203
|
+
generateOption(
|
|
204
|
+
$("#node-input-option-container").children().length + 1,
|
|
205
|
+
{}
|
|
206
|
+
);
|
|
207
|
+
$("#node-input-option-container-div").scrollTop(
|
|
208
|
+
$("#node-input-option-container-div").get(0).scrollHeight
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
for (let i = 0; i < this.options.length; i++) {
|
|
213
|
+
const option = this.options[i];
|
|
214
|
+
generateOption(i + 1, option);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
$("#node-input-option-container").sortable({
|
|
218
|
+
axis: "y",
|
|
219
|
+
handle: ".node-input-option-handle",
|
|
220
|
+
cursor: "move",
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
$("#node-input-data").typedInput({
|
|
224
|
+
default: "msg",
|
|
225
|
+
types: ["msg", "json", "flow", "global"],
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
$("#node-input-data").typedInput("value", this.data);
|
|
229
|
+
$("#node-input-data").typedInput("type", this.data_type);
|
|
230
|
+
},
|
|
231
|
+
oneditsave: function () {
|
|
232
|
+
const options = $("#node-input-option-container").children();
|
|
233
|
+
const node = this;
|
|
234
|
+
node.options = [];
|
|
235
|
+
options.each(function (i) {
|
|
236
|
+
const option = $(this);
|
|
237
|
+
const o = {
|
|
238
|
+
label: option.find(".node-input-option-label").val(),
|
|
239
|
+
condition: option.find(".node-input-option-condition").val(),
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
node.options.push(o);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const columns = $("#node-input-column-container").children();
|
|
246
|
+
node.columns = [];
|
|
247
|
+
columns.each(function (i) {
|
|
248
|
+
const column = $(this);
|
|
249
|
+
const c = {
|
|
250
|
+
label: column.find(".node-input-column-label").val(),
|
|
251
|
+
value: column.find(".node-input-column-value").typedInput("value"),
|
|
252
|
+
type: column.find(".node-input-column-value").typedInput("type"),
|
|
253
|
+
};
|
|
254
|
+
if (
|
|
255
|
+
column.find(".node-input-column-value").typedInput("type") === "num"
|
|
256
|
+
) {
|
|
257
|
+
c.value = Number(c.value);
|
|
258
|
+
}
|
|
259
|
+
if (
|
|
260
|
+
column.find(".node-input-column-value").typedInput("type") ===
|
|
261
|
+
"bool"
|
|
262
|
+
) {
|
|
263
|
+
c.value = c.value === "true";
|
|
264
|
+
}
|
|
265
|
+
node.columns.push(c);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
this.outputs = node.options.length || 1;
|
|
269
|
+
|
|
270
|
+
(this.data = $("#node-input-data").typedInput("value")),
|
|
271
|
+
(this.data_type = $("#node-input-data").typedInput("type"));
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
})();
|
|
284
275
|
</script>
|
|
285
276
|
|
|
286
|
-
<script type="text/
|
|
287
|
-
|
|
277
|
+
<script type="text/html" data-template-name="ui-dynamic-table">
|
|
278
|
+
<div class="form-row">
|
|
279
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
280
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
281
|
+
</div>
|
|
282
|
+
<div class="form-row">
|
|
283
|
+
<label for="node-input-tableName"><i class="fa fa-tag"></i> Table name</label>
|
|
284
|
+
<input type="text" id="node-input-tableName" placeholder="My Table">
|
|
285
|
+
</div>
|
|
286
|
+
<div class="form-row">
|
|
287
|
+
<label for="node-input-group"><i class="fa fa-table"></i> Group</label>
|
|
288
|
+
<input type="text" id="node-input-group">
|
|
289
|
+
</div>
|
|
290
|
+
<div class="form-row">
|
|
291
|
+
<label><i class="fa fa-object-group"></i> <span data-i18n="ui-dynamic-table.label.size"></label>
|
|
292
|
+
<input type="hidden" id="node-input-width">
|
|
293
|
+
<input type="hidden" id="node-input-height">
|
|
294
|
+
<button class="editor-button" id="node-input-size"></button>
|
|
295
|
+
</div>
|
|
296
|
+
<div class="form-row">
|
|
297
|
+
<label for="node-input-data"><i class="fa fa-tag"></i> Data</label>
|
|
298
|
+
<input type="text" id="node-input-data" placeholder="Data">
|
|
299
|
+
</div>
|
|
300
|
+
<div class="form-row form-row-flex node-input-option-container-row" style="margin-bottom: 0px;width: 100%">
|
|
301
|
+
<label for="node-input-width" style="vertical-align:top"><i class="fa fa-list-alt"></i> Actions</label>
|
|
302
|
+
<div id="node-input-option-container-div" style="box-sizing:border-box; border-radius:5px; height:257px; padding:5px; border:1px solid var(--red-ui-form-input-border-color, #ccc); overflow-y:scroll; display:inline-block; width: 70%;">
|
|
303
|
+
<span id="valWarning" style="color: var(--red-ui-text-color-error, #910000)"><b>All Values must be unique.</b></span>
|
|
304
|
+
<ol id="node-input-option-container" style="list-style-type:none; margin:0;"></ol>
|
|
305
|
+
</div>
|
|
306
|
+
<a
|
|
307
|
+
data-html="true"
|
|
308
|
+
title="Dynamic Property: Send 'msg.options' in order to override this property."
|
|
309
|
+
class="red-ui-button ui-node-popover-title"
|
|
310
|
+
style="margin-left: 4px; cursor: help; font-size: 0.625rem; border-radius: 50%; width: 24px; height: 24px; display: inline-flex; justify-content: center; align-items: center;">
|
|
311
|
+
<i style="font-family: ui-serif;">fx</i>
|
|
312
|
+
</a>
|
|
313
|
+
</div>
|
|
314
|
+
<!-- Add Option Button -->
|
|
315
|
+
<div class="form-row">
|
|
316
|
+
<a href="#" class="editor-button editor-button-small" id="node-input-add-option" style="margin-top:4px; margin-left:103px;"><i class="fa fa-plus"></i> <span>action</span></a>
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
<div class="form-row form-row-flex node-input-column-container-row" style="margin-bottom: 0px;width: 100%">
|
|
320
|
+
<label for="node-input-width" style="vertical-align:top"><i class="fa fa-list-alt"></i> Columns</label>
|
|
321
|
+
<div id="node-input-column-container-div" style="box-sizing:border-box; border-radius:5px; height:257px; padding:5px; border:1px solid var(--red-ui-form-input-border-color, #ccc); overflow-y:scroll; display:inline-block; width: 70%;">
|
|
322
|
+
<span id="valWarning" style="color: var(--red-ui-text-color-error, #910000)"><b>All Values must be unique.</b></span>
|
|
323
|
+
<ol id="node-input-column-container" style="list-style-type:none; margin:0;"></ol>
|
|
324
|
+
</div>
|
|
325
|
+
<a
|
|
326
|
+
data-html="true"
|
|
327
|
+
title="Dynamic Property: Send 'msg.columns' in order to override this property."
|
|
328
|
+
class="red-ui-button ui-node-popover-title"
|
|
329
|
+
style="margin-left: 4px; cursor: help; font-size: 0.625rem; border-radius: 50%; width: 24px; height: 24px; display:inline-flex; justify-content: center; align-items: center;">
|
|
330
|
+
<i style="font-family: ui-serif;">fx</i>
|
|
331
|
+
</a>
|
|
332
|
+
</div>
|
|
333
|
+
<!-- Add Column Button -->
|
|
334
|
+
<div class="form-row">
|
|
335
|
+
<a href="#" class="editor-button editor-button-small" id="node-input-add-column" style="margin-top:4px; margin-left:103px;"><i class="fa fa-plus"></i> <span>column</span></a>
|
|
336
|
+
</div>
|
|
337
|
+
</script>
|
|
288
338
|
|
|
289
|
-
|
|
339
|
+
<script type="text/markdown" data-help-name="ui-dynamic-table">
|
|
340
|
+
Dyanmic-Table ProcessCube UI-Component
|
|
290
341
|
|
|
291
|
-
|
|
292
|
-
: Group (string) : The groud in which the Component is rendered.
|
|
293
|
-
: Size (string) : The size of the table within the group.
|
|
294
|
-
: Data (string) : The property of msg.payload from where the table data is sourced.
|
|
295
|
-
: Actions (string) : The actions of each row. Each action corresponds to an output of the node.
|
|
296
|
-
: Columns (string) : The columns of the table. Must correspond to a key of the data property.
|
|
342
|
+
### Inputs
|
|
297
343
|
|
|
298
|
-
|
|
344
|
+
: Table name (string) : The name of the table.
|
|
345
|
+
: Group (string) : The groud in which the Component is rendered.
|
|
346
|
+
: Size (string) : The size of the table within the group.
|
|
347
|
+
: Data (string) : The property of msg.payload from where the table data is sourced.
|
|
348
|
+
: Actions (string) : The actions of each row. Each action corresponds to an output of the node.
|
|
349
|
+
: Columns (string) : The columns of the table. Must correspond to a key of the data property.
|
|
299
350
|
|
|
300
|
-
|
|
351
|
+
### Outputs
|
|
301
352
|
|
|
302
|
-
|
|
353
|
+
The outputs are generated dynamicly based on the actions of the table.
|
|
303
354
|
|
|
304
|
-
|
|
355
|
+
### Details
|
|
305
356
|
|
|
306
|
-
|
|
357
|
+
`msg.payload` is used as the base for the data form there on the data source can be specified further with the `data` input field.
|
|
307
358
|
|
|
308
|
-
|
|
359
|
+
### Referece
|
|
309
360
|
|
|
361
|
+
[https://processcube.io/docs/solutions/node-red](https://processcube.io/docs/solutions/node-red)
|
|
310
362
|
</script>
|
package/nodes/dynamic-table.js
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
module.exports = function (RED) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
function DynamicTableNode(config) {
|
|
3
|
+
RED.nodes.createNode(this, config);
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const node = this;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const group = RED.nodes.getNode(config.group);
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const base = group.getBase();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
//server-side event handlers
|
|
12
|
+
const evts = {
|
|
13
|
+
onAction: true,
|
|
14
|
+
onInput: function (msg, send, done) {
|
|
15
|
+
console.log(config.data_type);
|
|
16
|
+
columns = RED.util.evaluateNodeProperty(
|
|
17
|
+
config.data,
|
|
18
|
+
config.data_type,
|
|
19
|
+
node,
|
|
20
|
+
msg
|
|
21
|
+
);
|
|
22
|
+
base.stores.data.save(base, node, columns);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
+
if (group) {
|
|
27
|
+
group.register(node, config, evts);
|
|
28
|
+
} else {
|
|
29
|
+
node.error("No group configured");
|
|
26
30
|
}
|
|
31
|
+
}
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
33
|
+
RED.nodes.registerType("ui-dynamic-table", DynamicTableNode, {
|
|
34
|
+
defaults: {
|
|
35
|
+
outputs: { value: 1 },
|
|
36
|
+
},
|
|
37
|
+
outputs: function (config) {
|
|
38
|
+
return config.outputs || 1;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<script type="text/html" data-help-name="dynamic-table">
|
|
2
|
-
|
|
1
|
+
<script type="text/html" data-help-name="ui-dynamic-table">
|
|
2
|
+
<p>A table that shows dynamic data with actions.</p>
|
|
3
3
|
</script>
|
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"exports": {
|
|
27
|
-
"import": "./resources/dynamic-table.esm.js",
|
|
28
|
-
"require": "./resources/dynamic-table.umd.js"
|
|
29
|
-
},
|
|
30
|
-
"files": [
|
|
31
|
-
"dist/*",
|
|
32
|
-
"nodes/*",
|
|
33
|
-
"ui/*",
|
|
34
|
-
"resources/*"
|
|
35
|
-
],
|
|
36
|
-
"scripts": {
|
|
37
|
-
"build": "vite build",
|
|
38
|
-
"build:dev": "NODE_ENV=development vite build",
|
|
39
|
-
"dev": "NODE_ENV=development vite build --watch",
|
|
40
|
-
"dev:prod": "vite build --watch",
|
|
41
|
-
"lint": "npm run lint:js && npm run lint:package",
|
|
42
|
-
"lint:fix": "npm run lint:js:fix && npm run lint:package:fix",
|
|
43
|
-
"lint:js": "eslint --ext .js,.vue,.cjs,.mjs .",
|
|
44
|
-
"lint:js:fix": "yarn lint:js --fix",
|
|
45
|
-
"lint:package": "sort-package-json --check 'package.json'",
|
|
46
|
-
"lint:package:fix": "sort-package-json 'package.json'"
|
|
47
|
-
},
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"vue": "^3.3.8",
|
|
50
|
-
"vuex": "^4.1.0"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@vitejs/plugin-vue": "^4.5.0",
|
|
54
|
-
"eslint": "^8.53.0",
|
|
55
|
-
"eslint-config-standard": "^17.1.0",
|
|
56
|
-
"eslint-plugin-import": "^2.29.0",
|
|
57
|
-
"eslint-plugin-n": "^16.3.1",
|
|
58
|
-
"eslint-plugin-vue": "^9.18.1",
|
|
59
|
-
"vite": "^5.3.2",
|
|
60
|
-
"vite-plugin-css-injected-by-js": "^3.3.0"
|
|
61
|
-
},
|
|
62
|
-
"engines": {
|
|
63
|
-
"node": ">=14"
|
|
64
|
-
},
|
|
65
|
-
"node-red": {
|
|
66
|
-
"version": ">=3.0.0",
|
|
67
|
-
"nodes": {
|
|
68
|
-
"dynamic-table": "nodes/dynamic-table.js"
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"node-red-dashboard-2": {
|
|
72
|
-
"version": "1.0.0",
|
|
73
|
-
"widgets": {
|
|
74
|
-
"dynamic-table": {
|
|
75
|
-
"output": "dynamic-table.umd.js",
|
|
76
|
-
"component": "DynamicTable"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
2
|
+
"name": "@5minds/node-red-dashboard-2-processcube-dynamic-table",
|
|
3
|
+
"version": "1.1.3",
|
|
4
|
+
"description": "A ui component for showing dynamic Data with actions in a table",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"processcube",
|
|
7
|
+
"usertask",
|
|
8
|
+
"node-red",
|
|
9
|
+
"node-red-dashboard-2"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/5minds/node-red-dashboard-2-processcube-usertask-table.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Martin Moellenbeck",
|
|
18
|
+
"url": "https://github.com/moellenbeck"
|
|
19
|
+
},
|
|
20
|
+
"contributors": [
|
|
21
|
+
{
|
|
22
|
+
"name": "Luis Thieme",
|
|
23
|
+
"url": "https://github.com/luisthieme"
|
|
79
24
|
}
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
"import": "./resources/dynamic-table.esm.js",
|
|
28
|
+
"require": "./resources/dynamic-table.umd.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist/*",
|
|
32
|
+
"nodes/*",
|
|
33
|
+
"ui/*",
|
|
34
|
+
"resources/*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"build:dev": "NODE_ENV=development vite build",
|
|
39
|
+
"dev": "NODE_ENV=development vite build --watch",
|
|
40
|
+
"dev:prod": "vite build --watch",
|
|
41
|
+
"lint": "npm run lint:js && npm run lint:package",
|
|
42
|
+
"lint:fix": "npm run lint:js:fix && npm run lint:package:fix",
|
|
43
|
+
"lint:js": "eslint --ext .js,.vue,.cjs,.mjs .",
|
|
44
|
+
"lint:js:fix": "yarn lint:js --fix",
|
|
45
|
+
"lint:package": "sort-package-json --check 'package.json'",
|
|
46
|
+
"lint:package:fix": "sort-package-json 'package.json'"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"vue": "^3.3.8",
|
|
50
|
+
"vuex": "^4.1.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@vitejs/plugin-vue": "^4.5.0",
|
|
54
|
+
"eslint": "^8.53.0",
|
|
55
|
+
"eslint-config-standard": "^17.1.0",
|
|
56
|
+
"eslint-plugin-import": "^2.29.0",
|
|
57
|
+
"eslint-plugin-n": "^16.3.1",
|
|
58
|
+
"eslint-plugin-vue": "^9.18.1",
|
|
59
|
+
"vite": "^5.3.2",
|
|
60
|
+
"vite-plugin-css-injected-by-js": "^3.3.0"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=14"
|
|
64
|
+
},
|
|
65
|
+
"node-red": {
|
|
66
|
+
"version": ">=3.0.0",
|
|
67
|
+
"nodes": {
|
|
68
|
+
"ui-dynamic-table": "nodes/dynamic-table.js"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"node-red-dashboard-2": {
|
|
72
|
+
"version": "1.0.0",
|
|
73
|
+
"widgets": {
|
|
74
|
+
"ui-dynamic-table": {
|
|
75
|
+
"output": "ui-dynamic-table.umd.js",
|
|
76
|
+
"component": "DynamicTable"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
80
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var d=document.createElement("style");d.appendChild(document.createTextNode("h1[data-v-3b78dd72]{margin-bottom:10px}h2[data-v-3b78dd72]{margin-top:1.5rem;margin-bottom:.75rem}h3[data-v-3b78dd72]{margin-top:1rem}p[data-v-3b78dd72]{margin-bottom:5px}ul li[data-v-3b78dd72]{list-style-type:circle;list-style-position:inside;margin-left:15px}pre[data-v-3b78dd72]{padding:12px;margin:12px;background-color:#eee}code[data-v-3b78dd72]{font-size:.825rem;color:#ae0000}input[data-v-3b78dd72]{padding:12px;margin:12px;background-color:#eee}.task-div[data-v-3b78dd72]{padding:8px;margin:16px;border:solid;border-radius:4px;border-color:#303030}.action-button-container[data-v-3b78dd72]{width:100%;display:flex;justify-content:center}")),document.head.appendChild(d)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vuex"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vuex","vue"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o["ui-dynamic-table"]={},o.vuex,o.Vue))})(this,function(o,a,t){"use strict";const h=(e,n)=>{const i=e.__vccOpts||e;for(const[l,s]of n)i[l]=s;return i},m={name:"DynamicTable",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!0,visible:!0})}},data(){return{search:"",actions:[],tasks:[],headers:[]}},mounted(){this.$socket.on("widget-load:"+this.id,e=>{this.initialize(e),this.$store.commit("data/bind",{widgetId:this.id,columns:e})}),this.$socket.on("msg-input:"+this.id,e=>{this.initialize(e),this.$store.commit("data/bind",{widgetId:this.id,columns:e})}),this.$socket.emit("widget-load",this.id)},unmounted(){var e,n;(e=this.$socket)==null||e.off("widget-load"+this.id),(n=this.$socket)==null||n.off("msg-input:"+this.id)},methods:{send(e,n){const i=[];i[n]=e,this.$socket.emit("widget-action",this.id,i)},actionFn(e,n){this.send({payload:n},this.actions.findIndex(i=>i.label===e.label))},initialize(e){this.tasks=e,this.actions=this.props.options,this.headers=this.props.columns.map(n=>({title:n.label,key:n.value})),this.headers.push({title:"Action",align:"center",key:"actions"})},conditionCheck(e,n){if(e=="")return!0;try{return new Function("row",`return ${e}`)(n)}catch(i){return console.error("Error evaluating condition:",i),!1}}}};function f(e,n,i,l,s,d){const u=t.resolveComponent("v-text-field"),k=t.resolveComponent("v-toolbar"),b=t.resolveComponent("v-btn"),p=t.resolveComponent("v-container"),x=t.resolveComponent("v-alert"),y=t.resolveComponent("v-data-table");return t.openBlock(),t.createBlock(y,{headers:s.headers,items:s.tasks,search:s.search,class:"full-width-table"},{top:t.withCtx(()=>[t.createVNode(k,{flat:"",class:"py-2"},{default:t.withCtx(()=>[t.createVNode(u,{class:"mx-3",modelValue:s.search,"onUpdate:modelValue":n[0]||(n[0]=r=>s.search=r),label:"Search","prepend-inner-icon":"mdi-magnify",variant:"outlined","hide-details":"","single-line":""},null,8,["modelValue"])]),_:1})]),"item.actions":t.withCtx(({item:r})=>[t.createVNode(p,{class:"action-button-container"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.actions,(c,g)=>(t.openBlock(),t.createBlock(p,{style:{padding:"0px",display:"inline",width:"fit-content",margin:"0px"}},{default:t.withCtx(()=>[d.conditionCheck(c.condition,r)?(t.openBlock(),t.createBlock(b,{style:{margin:"0px 2px"},key:g,size:"small",onClick:C=>d.actionFn(c,r)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(c.label),1)]),_:2},1032,["onClick"])):t.createCommentVNode("",!0)]),_:2},1024))),256))]),_:2},1024)]),"no-data":t.withCtx(()=>[t.createVNode(x,{text:"No data"})]),_:1},8,["headers","items","search"])}const _=h(m,[["render",f],["__scopeId","data-v-3b78dd72"]]);o.DynamicTable=_,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/ui/main.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This file is useful for testing your component in isolation from Node-RED.
|
|
5
5
|
*/
|
|
6
|
-
import { createApp } from
|
|
6
|
+
import { createApp } from "vue";
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import DynamicTable from "./components/DynamicTable.vue";
|
|
9
9
|
|
|
10
|
-
createApp(
|
|
10
|
+
createApp(DynamicTable).mount("#app");
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("h1[data-v-6cc3f2ce]{margin-bottom:10px}h2[data-v-6cc3f2ce]{margin-top:1.5rem;margin-bottom:.75rem}h3[data-v-6cc3f2ce]{margin-top:1rem}p[data-v-6cc3f2ce]{margin-bottom:5px}ul li[data-v-6cc3f2ce]{list-style-type:circle;list-style-position:inside;margin-left:15px}pre[data-v-6cc3f2ce]{padding:12px;margin:12px;background-color:#eee}code[data-v-6cc3f2ce]{font-size:.825rem;color:#ae0000}input[data-v-6cc3f2ce]{padding:12px;margin:12px;background-color:#eee}.task-div[data-v-6cc3f2ce]{padding:8px;margin:16px;border:solid;border-radius:4px;border-color:#303030}.action-button-container[data-v-6cc3f2ce]{width:100%;display:flex;justify-content:center}")),document.head.appendChild(e)}}catch(c){console.error("vite-plugin-css-injected-by-js",c)}})();
|
|
2
|
-
(function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vuex"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vuex","vue"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i["dynamic-table"]={},i.vuex,i.Vue))})(this,function(i,a,e){"use strict";const h=(t,n)=>{const o=t.__vccOpts||t;for(const[l,s]of n)o[l]=s;return o},m={name:"DynamicTable",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!0,visible:!0})}},data(){return{search:"",actions:[],tasks:[],headers:[]}},mounted(){this.$socket.on("widget-load:"+this.id,t=>{this.initialize(t),this.$store.commit("data/bind",{widgetId:this.id,columns:t})}),this.$socket.on("msg-input:"+this.id,t=>{this.initialize(t),this.$store.commit("data/bind",{widgetId:this.id,columns:t})}),this.$socket.emit("widget-load",this.id)},unmounted(){var t,n;(t=this.$socket)==null||t.off("widget-load"+this.id),(n=this.$socket)==null||n.off("msg-input:"+this.id)},methods:{send(t,n){const o=[];o[n]=t,this.$socket.emit("widget-action",this.id,o)},actionFn(t,n){this.send({payload:n},this.actions.findIndex(o=>o.label===t.label))},initialize(t){this.tasks=t,this.actions=this.props.options,this.headers=this.props.columns.map(n=>({title:n.label,key:n.value})),this.headers.push({title:"Action",align:"center",key:"actions"})},conditionCheck(t,n){if(t=="")return!0;try{return new Function("row",`return ${t}`)(n)}catch(o){return console.error("Error evaluating condition:",o),!1}}}};function f(t,n,o,l,s,d){const u=e.resolveComponent("v-text-field"),b=e.resolveComponent("v-toolbar"),k=e.resolveComponent("v-btn"),p=e.resolveComponent("v-container"),x=e.resolveComponent("v-alert"),y=e.resolveComponent("v-data-table");return e.openBlock(),e.createBlock(y,{headers:s.headers,items:s.tasks,search:s.search,class:"full-width-table"},{top:e.withCtx(()=>[e.createVNode(b,{flat:"",class:"py-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"mx-3",modelValue:s.search,"onUpdate:modelValue":n[0]||(n[0]=r=>s.search=r),label:"Search","prepend-inner-icon":"mdi-magnify",variant:"outlined","hide-details":"","single-line":""},null,8,["modelValue"])]),_:1})]),"item.actions":e.withCtx(({item:r})=>[e.createVNode(p,{class:"action-button-container"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.actions,(c,g)=>(e.openBlock(),e.createBlock(p,{style:{padding:"0px",display:"inline",width:"fit-content",margin:"0px"}},{default:e.withCtx(()=>[d.conditionCheck(c.condition,r)?(e.openBlock(),e.createBlock(k,{style:{margin:"0px 2px"},key:g,size:"small",onClick:C=>d.actionFn(c,r)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:2},1032,["onClick"])):e.createCommentVNode("v-if",!0)]),_:2},1024))),256))]),_:2},1024)]),"no-data":e.withCtx(()=>[e.createVNode(x,{text:"No data"})]),_:1},8,["headers","items","search"])}const _=h(m,[["render",f],["__scopeId","data-v-6cc3f2ce"],["__file","/Users/moellenbeck/projects/5minds/reps/node-red-dashboard-2-processcube-usertask-table/ui/components/DynamicTable.vue"]]);i.DynamicTable=_,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
3
|
-
//# sourceMappingURL=dynamic-table.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-table.umd.js","sources":["../ui/components/DynamicTable.vue"],"sourcesContent":["<template>\n <v-data-table\n :headers=\"headers\"\n :items=\"tasks\"\n :search=\"search\"\n class=\"full-width-table\"\n >\n <template v-slot:top>\n <v-toolbar flat class=\"py-2\">\n <v-text-field\n class=\"mx-3\"\n v-model=\"search\"\n label=\"Search\"\n prepend-inner-icon=\"mdi-magnify\"\n variant=\"outlined\"\n hide-details\n single-line\n ></v-text-field>\n </v-toolbar>\n </template>\n <template v-slot:item.actions=\"{ item }\">\n <v-container class=\"action-button-container\">\n <v-container\n v-for=\"(action, index) in actions\"\n style=\"padding: 0px; display: inline; width: fit-content; margin: 0px\"\n >\n <v-btn\n style=\"margin: 0px 2px\"\n v-if=\"conditionCheck(action.condition, item)\"\n :key=\"index\"\n size=\"small\"\n @click=\"actionFn(action, item)\"\n >\n {{ action.label }}\n </v-btn>\n </v-container>\n </v-container>\n </template>\n <template v-slot:no-data>\n <v-alert text=\"No data\"></v-alert>\n </template>\n </v-data-table>\n</template>\n\n<script>\nimport { mapState } from \"vuex\";\n\nexport default {\n name: \"DynamicTable\",\n inject: [\"$socket\"],\n props: {\n /* do not remove entries from this - Dashboard's Layout Manager's will pass this data to your component */\n id: { type: String, required: true },\n props: { type: Object, default: () => ({}) },\n /* state: { type: Object, default: () => ({ enabled: false, visible: false }) } // DEFAULT */\n state: { type: Object, default: () => ({ enabled: true, visible: true }) },\n },\n data() {\n return {\n search: \"\",\n actions: [],\n tasks: [],\n headers: [],\n };\n },\n mounted() {\n this.$socket.on(\"widget-load:\" + this.id, (columns) => {\n this.initialize(columns);\n this.$store.commit(\"data/bind\", {\n widgetId: this.id,\n columns,\n });\n });\n this.$socket.on(\"msg-input:\" + this.id, (columns) => {\n this.initialize(columns);\n this.$store.commit(\"data/bind\", {\n widgetId: this.id,\n columns,\n });\n });\n this.$socket.emit(\"widget-load\", this.id);\n },\n unmounted() {\n this.$socket?.off(\"widget-load\" + this.id);\n this.$socket?.off(\"msg-input:\" + this.id);\n },\n methods: {\n send(msg, index) {\n const msgArr = [];\n msgArr[index] = msg;\n this.$socket.emit(\"widget-action\", this.id, msgArr);\n },\n actionFn(action, item) {\n this.send(\n { payload: item },\n this.actions.findIndex((element) => element.label === action.label)\n );\n },\n initialize(tasks) {\n this.tasks = tasks;\n this.actions = this.props.options;\n\n this.headers = this.props.columns.map((item) => ({\n title: item.label,\n key: item.value,\n }));\n\n this.headers.push({ title: \"Action\", align: \"center\", key: \"actions\" });\n },\n conditionCheck(condition, row) {\n if (condition == \"\") return true;\n try {\n const func = new Function(\"row\", `return ${condition}`);\n return func(row);\n } catch (error) {\n console.error(\"Error evaluating condition:\", error);\n return false;\n }\n },\n },\n};\n</script>\n\n<style scoped>\n/* CSS is auto scoped, but using named classes is still recommended */\n@import \"../stylesheets/dynamic-table.css\";\n</style>\n"],"names":["_sfc_main","columns","_a","_b","msg","index","msgArr","action","item","element","tasks","condition","row","error","_createBlock","_component_v_data_table","$data","_createVNode","_component_v_toolbar","_withCtx","_component_v_text_field","_cache","$event","_component_v_container","_openBlock","_createElementBlock","_Fragment","_renderList","$options","_component_v_btn","_createTextVNode","_toDisplayString","_createCommentVNode","_component_v_alert"],"mappings":"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"}
|