@5minds/node-red-dashboard-2-processcube-dynamic-list 1.0.0-master-23dd92-m848h39y

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Dynamic List
2
+
3
+ A UI-Node to display a list of process instances or usertasks.
4
+
5
+ ## Usage
6
+
7
+ Query ProcessInstance or UserTask data from the process engine.
8
+ Use a `function` node to transform the queried data into the required format for the `dynamic-list` node.
9
+ The `dyanmic-list` node expects an array of objects as its messages `payload`. The expected schema of these objects is:
10
+ - title: string;
11
+ - progress?:
12
+ - type: 'boolean' | 'percentage';
13
+ - value: number; (value between 0 and 100)
14
+ - details?: string;
15
+ - state?:
16
+ - text: string;
17
+ - backgroundColor: string;
18
+ - assignee?: string;
19
+
20
+ Pipe the `function` nodes result into the `dynamic-list` node.
21
+
22
+ The nodes default output will be triggered each time a list entry was clicked.
23
+ The `payload` property of the message that is ouput will be an object identifieng the clicked list entry.
24
+ This object will exactly equal one of the objects that where used as an input for the `dynamic-list` node.
25
+ Therefore, any amount of additional properties can be passed through this node, besides the ones used for displaying the list entry. I. e. a `processInstanceId`, `flowNodeInstanceId` or `userTask`.
26
+ Each additional output, generated by `actions`, will behave in the same manner, but is only triggered when clicking onto the corresponding button.
27
+
28
+ ## Actions
29
+
30
+ This field is used for configuring additional actions for each list entry. Actions will be displayed as buttons at the end of each row.
31
+
32
+ Each action is defined by:
33
+
34
+ - **Id**: The Id of the action. This will be the name of the nodes output.
35
+ - **Icon**: An URL for an image, that should be displayed. This will be used as the `src`-Property of a HTML `img`-Element. Therefore DataURLs can be used to add images/svgs etc., that are not available online.
36
+
37
+ For each action configured, the node will gain a new output, that is named as the linked actions id.
38
+
39
+ ## Item hover effect
40
+
41
+ When not checked, all hover effects for the list entries will not be shown. Clicking the card will still trigger a message from the nodes first output.
42
+
43
+ ## Reference
44
+
45
+ [https://processcube.io/docs/solutions/node-red](https://processcube.io/docs/solutions/node-red)
@@ -0,0 +1,8 @@
1
+ <svg width="40" height="60" viewBox="0 0 40 60" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 13C3.22386 13 3 13.2239 3 13.5V20.2778C3 20.5539 3.22386 20.7778 3.5 20.7778H9.5C9.77614 20.7778 10 20.5539 10 20.2778V13.5C10 13.2239 9.77614 13 9.5 13H3.5Z" fill="white"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 24.6667C3.22386 24.6667 3 24.8905 3 25.1667V31.9444C3 32.2206 3.22386 32.4444 3.5 32.4444H9.5C9.77614 32.4444 10 32.2206 10 31.9444V25.1667C10 24.8905 9.77614 24.6667 9.5 24.6667H3.5Z" fill="white"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M20.5 36.3333C21.5739 36.3333 22.4444 37.2039 22.4444 38.2778V46.0556C22.4444 47.1294 21.5739 48 20.5 48C19.4261 48 18.5556 47.1294 18.5556 46.0556V38.2778C18.5556 37.2039 19.4261 36.3333 20.5 36.3333Z" fill="white"/>
5
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M14.6667 42.1667C14.6667 41.0928 15.5372 40.2222 16.6111 40.2222H24.3889C25.4628 40.2222 26.3333 41.0928 26.3333 42.1667C26.3333 43.2406 25.4628 44.1111 24.3889 44.1111H16.6111C15.5372 44.1111 14.6667 43.2406 14.6667 42.1667Z" fill="white"/>
6
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M14.5 13C14.2239 13 14 13.2239 14 13.5V20.2778C14 20.5539 14.2239 20.7778 14.5 20.7778H37.5C37.7761 20.7778 38 20.5539 38 20.2778V13.5C38 13.2239 37.7761 13 37.5 13H14.5Z" fill="white"/>
7
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M14.5 24.6667C14.2239 24.6667 14 24.8905 14 25.1667V31.9444C14 32.2206 14.2239 32.4444 14.5 32.4444H37.5C37.7761 32.4444 38 32.2206 38 31.9444V25.1667C38 24.8905 37.7761 24.6667 37.5 24.6667H14.5Z" fill="white"/>
8
+ </svg>
@@ -0,0 +1,3 @@
1
+ <script type="text/html" data-help-name="ui-dynamic-list">
2
+ <p>A list that displays process instances or usertasks.</p>
3
+ </script>
@@ -0,0 +1,7 @@
1
+ {
2
+ "ui-dynamic-list": {
3
+ "label": {
4
+ "size": "Size"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,227 @@
1
+ <script type="text/javascript">
2
+ (function () {
3
+ function hasProperty(obj, prop) {
4
+ return Object.prototype.hasOwnProperty.call(obj, prop);
5
+ }
6
+
7
+ RED.nodes.registerType('ui-dynamic-list', {
8
+ category: 'ProcessCube UI',
9
+ color: '#00aed7',
10
+ defaults: {
11
+ name: { value: '' },
12
+ group: { type: 'ui-group', required: true },
13
+ order: { value: 1 },
14
+ itemHoverEffect: { value: true },
15
+ actions: {
16
+ value: [],
17
+ validate: function (v) {
18
+ const unique = new Set(
19
+ v.map(function (o) {
20
+ return o.id;
21
+ })
22
+ );
23
+ return v.length === unique.size;
24
+ },
25
+ },
26
+ width: {
27
+ value: 0,
28
+ validate: function (v) {
29
+ const width = v || 0;
30
+ const currentGroup = $('#node-input-group').val() || this.group;
31
+ const groupNode = RED.nodes.node(currentGroup);
32
+ const valid = !groupNode || +width <= +groupNode.width;
33
+ $('#node-input-size').toggleClass('input-error', !valid);
34
+ return valid;
35
+ },
36
+ },
37
+ height: { value: 0 },
38
+ outputs: { value: 1 },
39
+ },
40
+ inputs: 1,
41
+ outputs: 1,
42
+ outputLabels: function (index) {
43
+ return index !== 0 ? this.actions[index - 1].id : 'Entry clicked';
44
+ },
45
+ icon: 'ui_dynamic_list.svg',
46
+ paletteLabel: 'ui-dynamic-list',
47
+ label: function () {
48
+ return this.name || 'ui-dynamic-list';
49
+ },
50
+ oneditprepare: function () {
51
+ $('#node-input-size').elementSizer({
52
+ width: '#node-input-width',
53
+ height: '#node-input-height',
54
+ group: '#node-input-group',
55
+ });
56
+
57
+ function generateAction(i, action) {
58
+ const container = $('<li/>', {
59
+ style: 'background: var(--red-ui-secondary-background, #fff); margin:0; padding:8px 0px 0px;',
60
+ });
61
+
62
+ // Create input fields for icon and id
63
+ const row = $('<div/>').appendTo(container);
64
+
65
+ $('<input/>', {
66
+ class: 'node-input-action-id',
67
+ type: 'text',
68
+ style: 'margin-left:7px; width:calc(50% - 32px);',
69
+ placeholder: 'Id',
70
+ value: action.id,
71
+ })
72
+ .appendTo(row)
73
+ .typedInput({
74
+ type: 'str',
75
+ types: ['str'],
76
+ });
77
+
78
+ $('<input/>', {
79
+ class: 'node-input-action-icon',
80
+ type: 'text',
81
+ style: 'margin-left:7px; width:calc(50% - 32px);',
82
+ placeholder: 'Icon',
83
+ value: action.icon,
84
+ })
85
+ .appendTo(row)
86
+ .typedInput({
87
+ type: 'str',
88
+ types: ['str'],
89
+ });
90
+
91
+ // Create delete button for the action
92
+ const finalSpan = $('<span/>', {
93
+ style: 'float:right; margin-right:8px;',
94
+ }).appendTo(row);
95
+ const deleteButton = $('<a/>', {
96
+ href: '#',
97
+ class: 'editor-button editor-button-small',
98
+ style: 'margin-top:7px; margin-left:5px;',
99
+ }).appendTo(finalSpan);
100
+ $('<i/>', { class: 'fa fa-remove' }).appendTo(deleteButton);
101
+
102
+ deleteButton.click(function () {
103
+ container.css({
104
+ background: 'var(--red-ui-secondary-background-inactive, #fee)',
105
+ });
106
+ container.fadeOut(300, function () {
107
+ $(this).remove();
108
+ });
109
+ });
110
+
111
+ $('#node-input-action-container').append(container);
112
+ }
113
+
114
+ $('#node-input-add-action').click(function () {
115
+ generateAction($('#node-input-action-container').children().length + 1, {});
116
+ $('#node-input-action-container-div').scrollTop(
117
+ $('#node-input-action-container-div').get(0).scrollHeight
118
+ );
119
+ });
120
+
121
+ for (let i = 0; i < this.actions.length; i++) {
122
+ const action = this.actions[i];
123
+ generateAction(i + 1, action);
124
+ }
125
+
126
+ $('#node-input-action-container').sortable({
127
+ axis: 'y',
128
+ handle: '.node-input-action-handle',
129
+ cursor: 'move',
130
+ });
131
+ },
132
+ oneditsave: function () {
133
+ const actions = $('#node-input-action-container').children();
134
+ const node = this;
135
+ node.actions = [];
136
+ actions.each(function (i) {
137
+ const action = $(this);
138
+ const o = {
139
+ id: action.find('.node-input-action-id').val(),
140
+ icon: action.find('.node-input-action-icon').val(),
141
+ };
142
+
143
+ node.actions.push(o);
144
+ });
145
+ node.outputs = node.actions.length + 1;
146
+ },
147
+ });
148
+ })();
149
+ </script>
150
+
151
+ <script type="text/html" data-template-name="ui-dynamic-list">
152
+ <div class="form-row">
153
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
154
+ <input type="text" id="node-input-name" placeholder="Name">
155
+ </div>
156
+ <div class="form-row">
157
+ <label for="node-input-group"><i class="fa fa-table"></i> Group</label>
158
+ <input type="text" id="node-input-group">
159
+ </div>
160
+ <div class="form-row">
161
+ <label><i class="fa fa-object-group"></i> <span data-i18n="ui-dynamic-list.label.size"></label>
162
+ <input type="hidden" id="node-input-width">
163
+ <input type="hidden" id="node-input-height">
164
+ <button class="editor-button" id="node-input-size"></button>
165
+ </div>
166
+ <div class="form-row">
167
+ <label for="node-input-itemHoverEffect"><i class="fa fa-hand"></i>Item hover effect</label>
168
+ <input type="checkbox" id="node-input-itemHoverEffect" title="Uncheck to remove all hover effects from the list entries.">
169
+ </div>
170
+ <div class="form-row form-row-flex node-input-action-container-row" style="margin-bottom: 0px;width: 100%">
171
+ <label for="node-input-width" style="vertical-align:top"><i class="fa fa-list-alt"></i> Actions</label>
172
+ <div id="node-input-action-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%;">
173
+ <span id="valWarning" style="color: var(--red-ui-text-color-error, #910000)"><b>All Values must be unique.</b></span>
174
+ <ol id="node-input-action-container" style="list-style-type:none; margin:0;"></ol>
175
+ </div>
176
+ </div>
177
+ <!-- Add Action Button -->
178
+ <div class="form-row">
179
+ <a href="#" class="editor-button editor-button-small" id="node-input-add-action" style="margin-top:4px; margin-left:103px;"><i class="fa fa-plus"></i> <span>action</span></a>
180
+ </div>
181
+ </script>
182
+
183
+ <script type="text/markdown" data-help-name="ui-dynamic-list">
184
+ A UI-Node to display a list of process instances or usertasks.
185
+
186
+ ## Usage
187
+
188
+ Query ProcessInstance or UserTask data from the process engine.
189
+ Use a `function` node to transform the queried data into the required format for the `dynamic-list` node.
190
+ The `dyanmic-list` node expects an array of objects as its messages `payload`. The expected schema of these objects is:
191
+ - title: string;
192
+ - progress?:
193
+ - type: 'boolean' | 'percentage';
194
+ - value: number; (value between 0 and 100)
195
+ - details?: string;
196
+ - state?:
197
+ - text: string;
198
+ - backgroundColor: string;
199
+ - assignee?: string;
200
+
201
+ Pipe the `function` nodes result into the `dynamic-list` node.
202
+
203
+ The nodes default output will be triggered each time a list entry was clicked.
204
+ The `payload` property of the message that is ouput will be an object identifieng the clicked list entry.
205
+ This object will exactly equal one of the objects that where used as an input for the `dynamic-list` node.
206
+ Therefore, any amount of additional properties can be passed through this node, besides the ones used for displaying the list entry. I. e. a `processInstanceId`, `flowNodeInstanceId` or `userTask`.
207
+ Each additional output, generated by `actions`, will behave in the same manner, but is only triggered when clicking onto the corresponding button.
208
+
209
+ ## Actions
210
+
211
+ This field is used for configuring additional actions for each list entry. Actions will be displayed as buttons at the end of each row.
212
+
213
+ Each action is defined by:
214
+
215
+ - **Id**: The Id of the action. This will be the name of the nodes output.
216
+ - **Icon**: An URL for an image, that should be displayed. This will be used as the `src`-Property of a HTML `img`-Element. Therefore DataURLs can be used to add images/svgs etc., that are not available online.
217
+
218
+ For each action configured, the node will gain a new output, that is named as the linked actions id.
219
+
220
+ ## Item hover effect
221
+
222
+ When not checked, all hover effects for the list entries will not be shown. Clicking the card will still trigger a message from the nodes first output.
223
+
224
+ ## Reference
225
+
226
+ [https://processcube.io/docs/solutions/node-red](https://processcube.io/docs/solutions/node-red)
227
+ </script>
@@ -0,0 +1,34 @@
1
+ module.exports = function (RED) {
2
+ function DynamicListNode(config) {
3
+ RED.nodes.createNode(this, config);
4
+
5
+ const node = this;
6
+
7
+ const group = RED.nodes.getNode(config.group);
8
+
9
+ const base = group.getBase();
10
+
11
+ //server-side event handlers
12
+ const evts = {
13
+ onAction: true,
14
+ onInput: function (msg, send, done) {
15
+ base.stores.data.save(base, node, msg);
16
+ },
17
+ };
18
+
19
+ if (group) {
20
+ group.register(node, config, evts);
21
+ } else {
22
+ node.error('No group configured');
23
+ }
24
+ }
25
+
26
+ RED.nodes.registerType('ui-dynamic-list', DynamicListNode, {
27
+ defaults: {
28
+ outputs: { value: 1 },
29
+ },
30
+ outputs: function (config) {
31
+ return 1;
32
+ },
33
+ });
34
+ };
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@5minds/node-red-dashboard-2-processcube-dynamic-list",
3
+ "version": "1.0.0-master-23dd92-m848h39y",
4
+ "description": "A ui component for showing progress bars tracking a process",
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-dynamic-list.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": "Niclas Podzierski",
23
+ "url": "https://github.com/niclaspodzierski"
24
+ }
25
+ ],
26
+ "exports": {
27
+ "require": "./resources/ui-dynamic-list.umd.js"
28
+ },
29
+ "files": [
30
+ "dist/*",
31
+ "nodes/*",
32
+ "ui/*",
33
+ "resources/*"
34
+ ],
35
+ "scripts": {
36
+ "build": "vite build",
37
+ "build:dev": "NODE_ENV=development vite build",
38
+ "dev": "NODE_ENV=development vite build --watch",
39
+ "dev:prod": "vite build --watch",
40
+ "lint": "npm run lint:js && npm run lint:package",
41
+ "lint:fix": "npm run lint:js:fix && npm run lint:package:fix",
42
+ "lint:js": "eslint --ext .js,.vue,.cjs,.mjs .",
43
+ "lint:js:fix": "yarn lint:js --fix",
44
+ "lint:package": "sort-package-json --check 'package.json'",
45
+ "lint:package:fix": "sort-package-json 'package.json'"
46
+ },
47
+ "dependencies": {
48
+ "vue": "^3.3.8",
49
+ "vuex": "^4.1.0"
50
+ },
51
+ "devDependencies": {
52
+ "@vitejs/plugin-vue": "^4.5.0",
53
+ "eslint": "^8.53.0",
54
+ "eslint-config-standard": "^17.1.0",
55
+ "eslint-plugin-import": "^2.29.0",
56
+ "eslint-plugin-n": "^16.3.1",
57
+ "eslint-plugin-vue": "^9.18.1",
58
+ "vite": "^5.3.2",
59
+ "vite-plugin-css-injected-by-js": "^3.3.0"
60
+ },
61
+ "engines": {
62
+ "node": ">=14"
63
+ },
64
+ "node-red": {
65
+ "version": ">=3.0.0",
66
+ "nodes": {
67
+ "ui-dynamic-list": "nodes/ui-dynamic-list.js"
68
+ }
69
+ },
70
+ "node-red-dashboard-2": {
71
+ "version": "1.0.0",
72
+ "widgets": {
73
+ "ui-dynamic-list": {
74
+ "output": "ui-dynamic-list.umd.js",
75
+ "component": "UIDynamicList"
76
+ }
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,2 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".list-entry[data-v-a51b547e]{background:#fff;display:flex;justify-content:space-between;padding:16px;margin-bottom:24px;border-radius:8px;box-shadow:0 0 8px #bababa;transition:box-shadow .25s ease;align-items:center}.list-entry-hoverable[data-v-a51b547e]{cursor:pointer}.list-entry-hoverable[data-v-a51b547e]:hover{box-shadow:0 0 32px #bababa;transition:box-shadow .5s ease}.list-entry_left[data-v-a51b547e]{display:flex;align-items:center;gap:24px}.list-entry_left-progress[data-v-a51b547e]{font-size:24px;font-weight:400;color:#405fa5}.list-entry_left-texts[data-v-a51b547e]{display:flex;flex-direction:column;gap:4px;justify-content:center}.list-entry_left-title[data-v-a51b547e]{display:flex;gap:8px;align-items:center}.list-entry_left-title-text[data-v-a51b547e]{font-size:18px;font-weight:400}.list-entry_left-title-state[data-v-a51b547e]{font-size:12px;color:#fff;font-weight:700;padding:4px 8px;border-radius:8px;border:2px solid transparent}.list-entry_left-details[data-v-a51b547e]{font-size:18px;color:#7a7a99;font-weight:400}.list-entry_right[data-v-a51b547e]{display:flex;align-self:center;flex-direction:column;align-items:end;gap:4px}.list-entry_right-assignee[data-v-a51b547e]{font-size:18px;font-weight:400}.list-entry_right-actions[data-v-a51b547e]{display:flex;gap:8px}.list-entry_right-action[data-v-a51b547e]{cursor:pointer;padding:4px;opacity:.6}.list-entry_right-action[data-v-a51b547e]:hover{opacity:1}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ (function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n["ui-dynamic-list"]={},n.Vue))})(this,function(n,t){"use strict";const _=(e,o)=>{const i=e.__vccOpts||e;for(const[l,c]of o)i[l]=c;return i},C={name:"UIDynamicList",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!0,visible:!0})}},computed:{},data(){return{actions:[],entries:[],itemHoverEffect:!0}},mounted(){this.$socket.on("widget-load:"+this.id,e=>{var o,i;this.actions=((o=this.props)==null?void 0:o.actions)??[],this.entries=(e==null?void 0:e.payload)??[],this.itemHoverEffect=((i=this.props)==null?void 0:i.itemHoverEffect)??!0}),this.$socket.on("msg-input:"+this.id,e=>{this.entries=e.payload??[]}),this.$socket.emit("widget-load",this.id)},unmounted(){var e,o;(e=this.$socket)==null||e.off("widget-load"+this.id),(o=this.$socket)==null||o.off("msg-input:"+this.id)},methods:{send(e,o){const i=[];i[o]={payload:e},this.$socket.emit("widget-action",this.id,i)},entryClicked(e){this.send(e,0)},actionClicked(e,o,i){i.stopPropagation();const l=this.actions.findIndex(c=>c.id===e.id);l>-1&&this.send(o,l+1)}}},a=e=>(t.pushScopeId("data-v-a51b547e"),e=e(),t.popScopeId(),e),m=["onClick"],k={class:"list-entry_left"},f={key:0,class:"list-entry_left-progress"},g={key:0,width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},y=[a(()=>t.createElementVNode("path",{d:"M12.04 20.44L21.91 10.57L19.95 8.61L12.04 16.52L8.05 12.53L6.09 14.49L12.04 20.44ZM14 28C12.0633 28 10.2433 27.6325 8.54 26.8975C6.83667 26.1625 5.355 25.165 4.095 23.905C2.835 22.645 1.8375 21.1633 1.1025 19.46C0.3675 17.7567 0 15.9367 0 14C0 12.0633 0.3675 10.2433 1.1025 8.54C1.8375 6.83667 2.835 5.355 4.095 4.095C5.355 2.835 6.83667 1.8375 8.54 1.1025C10.2433 0.3675 12.0633 0 14 0C15.9367 0 17.7567 0.3675 19.46 1.1025C21.1633 1.8375 22.645 2.835 23.905 4.095C25.165 5.355 26.1625 6.83667 26.8975 8.54C27.6325 10.2433 28 12.0633 28 14C28 15.9367 27.6325 17.7567 26.8975 19.46C26.1625 21.1633 25.165 22.645 23.905 23.905C22.645 25.165 21.1633 26.1625 19.46 26.8975C17.7567 27.6325 15.9367 28 14 28Z",fill:"#405FA5"},null,-1))],B={key:1,width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},E=[a(()=>t.createElementVNode("path",{d:"M14 28C12.0633 28 10.2433 27.6325 8.54 26.8975C6.83667 26.1625 5.355 25.165 4.095 23.905C2.835 22.645 1.8375 21.1633 1.1025 19.46C0.3675 17.7567 0 15.9367 0 14C0 12.0633 0.3675 10.2433 1.1025 8.54C1.8375 6.83667 2.835 5.355 4.095 4.095C5.355 2.835 6.83667 1.8375 8.54 1.1025C10.2433 0.3675 12.0633 0 14 0C15.9367 0 17.7567 0.3675 19.46 1.1025C21.1633 1.8375 22.645 2.835 23.905 4.095C25.165 5.355 26.1625 6.83667 26.8975 8.54C27.6325 10.2433 28 12.0633 28 14C28 15.9367 27.6325 17.7567 26.8975 19.46C26.1625 21.1633 25.165 22.645 23.905 23.905C22.645 25.165 21.1633 26.1625 19.46 26.8975C17.7567 27.6325 15.9367 28 14 28ZM14 25.2C17.1267 25.2 19.775 24.115 21.945 21.945C24.115 19.775 25.2 17.1267 25.2 14C25.2 10.8733 24.115 8.225 21.945 6.055C19.775 3.885 17.1267 2.8 14 2.8C10.8733 2.8 8.225 3.885 6.055 6.055C3.885 8.225 2.8 10.8733 2.8 14C2.8 17.1267 3.885 19.775 6.055 21.945C8.225 24.115 10.8733 25.2 14 25.2Z",fill:"black"},null,-1))],w={class:"list-entry_left-texts"},b={class:"list-entry_left-title"},x={class:"list-entry_left-title-text"},V={key:0,class:"list-entry_left-details"},N={class:"list-entry_right"},S={class:"list-entry_right-actions"},L=["onClick","src"],I={key:0,class:"list-entry_right-assignee"};function D(e,o,i,l,c,d){return t.openBlock(),t.createElementBlock("div",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.entries,s=>{var p,h;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["list-entry",{"list-entry-hoverable":c.itemHoverEffect}]),onClick:r=>d.entryClicked(s)},[t.createElementVNode("div",k,[((p=s.progress)==null?void 0:p.type)==="percentage"?(t.openBlock(),t.createElementBlock("span",f,t.toDisplayString(s.progress.value)+" %",1)):((h=s.progress)==null?void 0:h.type)==="boolean"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[s.progress.value===100?(t.openBlock(),t.createElementBlock("svg",g,y)):(t.openBlock(),t.createElementBlock("svg",B,E))],64)):t.createCommentVNode("",!0),t.createElementVNode("div",w,[t.createElementVNode("div",b,[t.createElementVNode("span",x,t.toDisplayString(s.title),1),s.state?(t.openBlock(),t.createElementBlock("span",{key:0,class:"list-entry_left-title-state",style:t.normalizeStyle({backgroundColor:s.state.backgroundColor})},t.toDisplayString(s.state.text),5)):t.createCommentVNode("",!0)]),s.details?(t.openBlock(),t.createElementBlock("span",V,t.toDisplayString(s.details),1)):t.createCommentVNode("",!0)])]),t.createElementVNode("div",N,[t.createElementVNode("div",S,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.actions,r=>(t.openBlock(),t.createElementBlock("img",{onClick:j=>d.actionClicked(r,s,j),class:"list-entry_right-action",src:r.icon},null,8,L))),256))]),s.assignee?(t.openBlock(),t.createElementBlock("span",I,t.toDisplayString(s.assignee),1)):t.createCommentVNode("",!0)])],10,m)}),256))])}const $=_(C,[["render",D],["__scopeId","data-v-a51b547e"]]);n.UIDynamicList=$,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <div>
3
+ <div v-for="entry in entries" class="list-entry" :class="{ 'list-entry-hoverable': itemHoverEffect }" @click="entryClicked(entry)">
4
+ <div class="list-entry_left">
5
+ <span v-if="entry.progress?.type === 'percentage'" class="list-entry_left-progress">{{ entry.progress.value}} %</span>
6
+ <template v-else-if="entry.progress?.type === 'boolean'">
7
+ <svg v-if="entry.progress.value === 100" width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
8
+ <path d="M12.04 20.44L21.91 10.57L19.95 8.61L12.04 16.52L8.05 12.53L6.09 14.49L12.04 20.44ZM14 28C12.0633 28 10.2433 27.6325 8.54 26.8975C6.83667 26.1625 5.355 25.165 4.095 23.905C2.835 22.645 1.8375 21.1633 1.1025 19.46C0.3675 17.7567 0 15.9367 0 14C0 12.0633 0.3675 10.2433 1.1025 8.54C1.8375 6.83667 2.835 5.355 4.095 4.095C5.355 2.835 6.83667 1.8375 8.54 1.1025C10.2433 0.3675 12.0633 0 14 0C15.9367 0 17.7567 0.3675 19.46 1.1025C21.1633 1.8375 22.645 2.835 23.905 4.095C25.165 5.355 26.1625 6.83667 26.8975 8.54C27.6325 10.2433 28 12.0633 28 14C28 15.9367 27.6325 17.7567 26.8975 19.46C26.1625 21.1633 25.165 22.645 23.905 23.905C22.645 25.165 21.1633 26.1625 19.46 26.8975C17.7567 27.6325 15.9367 28 14 28Z" fill="#405FA5"/>
9
+ </svg>
10
+ <svg v-else width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
11
+ <path d="M14 28C12.0633 28 10.2433 27.6325 8.54 26.8975C6.83667 26.1625 5.355 25.165 4.095 23.905C2.835 22.645 1.8375 21.1633 1.1025 19.46C0.3675 17.7567 0 15.9367 0 14C0 12.0633 0.3675 10.2433 1.1025 8.54C1.8375 6.83667 2.835 5.355 4.095 4.095C5.355 2.835 6.83667 1.8375 8.54 1.1025C10.2433 0.3675 12.0633 0 14 0C15.9367 0 17.7567 0.3675 19.46 1.1025C21.1633 1.8375 22.645 2.835 23.905 4.095C25.165 5.355 26.1625 6.83667 26.8975 8.54C27.6325 10.2433 28 12.0633 28 14C28 15.9367 27.6325 17.7567 26.8975 19.46C26.1625 21.1633 25.165 22.645 23.905 23.905C22.645 25.165 21.1633 26.1625 19.46 26.8975C17.7567 27.6325 15.9367 28 14 28ZM14 25.2C17.1267 25.2 19.775 24.115 21.945 21.945C24.115 19.775 25.2 17.1267 25.2 14C25.2 10.8733 24.115 8.225 21.945 6.055C19.775 3.885 17.1267 2.8 14 2.8C10.8733 2.8 8.225 3.885 6.055 6.055C3.885 8.225 2.8 10.8733 2.8 14C2.8 17.1267 3.885 19.775 6.055 21.945C8.225 24.115 10.8733 25.2 14 25.2Z" fill="black"/>
12
+ </svg>
13
+ </template>
14
+ <div class="list-entry_left-texts">
15
+ <div class="list-entry_left-title">
16
+ <span class="list-entry_left-title-text">{{ entry.title }}</span>
17
+ <span
18
+ v-if="entry.state"
19
+ class="list-entry_left-title-state"
20
+ :style="{
21
+ backgroundColor: entry.state.backgroundColor
22
+ }"
23
+ >{{ entry.state.text }}</span>
24
+ </div>
25
+ <span v-if="entry.details" class="list-entry_left-details">{{ entry.details }}</span>
26
+ </div>
27
+ </div>
28
+ <div class="list-entry_right">
29
+ <div class="list-entry_right-actions">
30
+ <img v-for="action in actions" @click="(event) => actionClicked(action, entry, event)" class="list-entry_right-action" :src="action.icon" />
31
+ </div>
32
+ <span v-if="entry.assignee" class="list-entry_right-assignee">{{ entry.assignee }}</span>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </template>
37
+
38
+ <script>
39
+
40
+ export default {
41
+ name: 'UIDynamicList',
42
+ inject: ['$socket'],
43
+ props: {
44
+ /* do not remove entries from this - Dashboard's Layout Manager's will pass this data to your component */
45
+ id: { type: String, required: true },
46
+ props: { type: Object, default: () => ({}) },
47
+ /* state: { type: Object, default: () => ({ enabled: false, visible: false }) } // DEFAULT */
48
+ state: {
49
+ type: Object,
50
+ default: () => ({ enabled: true, visible: true }),
51
+ },
52
+ },
53
+ computed: {
54
+ },
55
+ data() {
56
+ return {
57
+ actions: [],
58
+ entries: [],
59
+ itemHoverEffect: true,
60
+ };
61
+ },
62
+ mounted() {
63
+ this.$socket.on('widget-load:' + this.id, (msg) => {
64
+ this.actions = this.props?.actions ?? [];
65
+ this.entries = msg?.payload ?? [];
66
+ this.itemHoverEffect = this.props?.itemHoverEffect ?? true;
67
+ });
68
+ this.$socket.on('msg-input:' + this.id, (msg) => {
69
+ this.entries = msg.payload ?? [];
70
+ });
71
+ this.$socket.emit('widget-load', this.id);
72
+ },
73
+ unmounted() {
74
+ this.$socket?.off('widget-load' + this.id);
75
+ this.$socket?.off('msg-input:' + this.id);
76
+ },
77
+ methods: {
78
+ send (entry, index) {
79
+ const msgArr = []
80
+ msgArr[index] = { payload: entry }
81
+ this.$socket.emit('widget-action', this.id, msgArr)
82
+ },
83
+ entryClicked(entry) {
84
+ this.send(entry, 0)
85
+ },
86
+ actionClicked(action, entry, event) {
87
+ event.stopPropagation();
88
+ const actionIndex = this.actions.findIndex(a => a.id === action.id);
89
+ if (actionIndex > -1) {
90
+ this.send(entry, actionIndex + 1)
91
+ }
92
+ }
93
+ },
94
+ };
95
+ </script>
96
+
97
+ <style scoped>
98
+ /* CSS is auto scoped, but using named classes is still recommended */
99
+ @import '../stylesheets/ui-dynamic-list.css'
100
+ </style>
package/ui/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /* Exports of all of the components in this node */
2
+ export { default as UIDynamicList } from './components/UIDynamicList.vue';
package/ui/main.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Used only for development (via `npm run dev`).
3
+ *
4
+ * This file is useful for testing your component in isolation from Node-RED.
5
+ */
6
+ import { createApp } from "vue";
7
+
8
+ import UIDyanmicList from "./components/UIDyanmicList.vue";
9
+
10
+ createApp(UIDyanmicList).mount("#app");
@@ -0,0 +1,96 @@
1
+ .list-entry {
2
+ background: #FFF;
3
+ display: flex;
4
+ justify-content: space-between;
5
+ padding: 16px;
6
+ margin-bottom: 24px;
7
+ border-radius: 8px;
8
+ box-shadow: 0px 0px 8px 0px #BABABA;
9
+ transition: box-shadow .25s ease;
10
+ align-items: center;
11
+ }
12
+
13
+ .list-entry-hoverable {
14
+ cursor: pointer;
15
+ }
16
+
17
+ .list-entry-hoverable:hover {
18
+ box-shadow: 0px 0px 32px 0px #BABABA;
19
+ transition: box-shadow .5s ease;
20
+ }
21
+
22
+ .list-entry_left {
23
+ display: flex;
24
+ align-items: center;
25
+ gap: 24px;
26
+ }
27
+
28
+ .list-entry_left-progress {
29
+ font-size: 24px;
30
+ font-weight: 400;
31
+ color: #405FA5;
32
+ }
33
+
34
+ .list-entry_left-texts {
35
+ display: flex;
36
+ flex-direction: column;
37
+ gap: 4px;
38
+ justify-content: center;
39
+ }
40
+
41
+ .list-entry_left-title {
42
+ display: flex;
43
+ gap: 8px;
44
+ align-items: center;
45
+ }
46
+
47
+ .list-entry_left-title-text {
48
+ font-size: 18px;
49
+ font-weight: 400;
50
+ }
51
+
52
+ .list-entry_left-title-state {
53
+ font-size: 12px;
54
+ color: #FFF;
55
+ font-weight: 700;
56
+ padding-left: 8px;
57
+ padding-right: 8px;
58
+ padding-top: 4px;
59
+ padding-bottom: 4px;
60
+ border-radius: 8px;
61
+ border: 2px solid transparent;
62
+ }
63
+
64
+ .list-entry_left-details {
65
+ font-size: 18px;
66
+ color: #7A7A99;
67
+ font-weight: 400;
68
+ }
69
+
70
+ .list-entry_right {
71
+ display: flex;
72
+ align-self: center;
73
+ flex-direction: column;
74
+ align-items: end;
75
+ gap: 4px
76
+ }
77
+
78
+ .list-entry_right-assignee {
79
+ font-size: 18px;
80
+ font-weight: 400;
81
+ }
82
+
83
+ .list-entry_right-actions {
84
+ display: flex;
85
+ gap: 8px;
86
+ }
87
+
88
+ .list-entry_right-action {
89
+ cursor: pointer;
90
+ padding: 4px;
91
+ opacity: .6;
92
+ }
93
+
94
+ .list-entry_right-action:hover {
95
+ opacity: 1;
96
+ }