-
Notifications
You must be signed in to change notification settings - Fork 1
/
flows.json
2519 lines (2519 loc) · 119 KB
/
flows.json
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
{
"id": "562197b4f4a67922",
"type": "tab",
"label": "Prodn Dashboard Flow",
"disabled": true,
"locked": true,
"info": "",
"env": []
},
{
"id": "d9c16620383ec561",
"type": "tab",
"label": "Call SV,FM.DM,QC",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c7abb9e37b8610b1",
"type": "tab",
"label": "Call FG",
"disabled": false,
"locked": true,
"info": "",
"env": []
},
{
"id": "f2f642efde1fe996",
"type": "tab",
"label": "Call Kowake",
"disabled": false,
"locked": true,
"info": "",
"env": []
},
{
"id": "327571d15da5aceb",
"type": "tab",
"label": "Sys: MQTT Server",
"disabled": false,
"info": "",
"env": []
},
{
"id": "b7a483d0be44dbdd",
"type": "tab",
"label": "Sys: Send T/Gram Msg",
"disabled": false,
"locked": true,
"info": "",
"env": [
{
"name": "Chat Ids",
"value": "{\"asyraf\":21709557,\"Mgmt\":{\"id\":123,\"Press\":{\"id\":123,\"TRF\":{\"id\":123},\"Large\":{\"id\":123},\"Medium\":{\"id\":123},\"Rework\":{\"id\":123}},\"Assy\":{\"id\":123,\"AB\":{\"id\":123},\"C\":{\"id\":123},\"D\":{\"id\":123},\"EF\":{\"id\":123},\"H\":{\"id\":123}},\"QC\":{\"id\":123,\"Press\":{\"id\":123},\"Assy\":{\"id\":123},\"Incoming\":{\"id\":123},\"Delivery\":{\"id\":123}},\"FM\":{\"id\":123,\"Press\":{\"id\":-1001957517829},\"Assy\":{\"id\":123},\"Die\":{\"id\":123},\"Building\":{\"id\":123}},\"IT\":{\"id\":123}}}",
"type": "json"
}
]
},
{
"id": "47a130afcbdaced0",
"type": "tab",
"label": "Sys: Update Database",
"disabled": false,
"info": "",
"env": []
},
{
"id": "0ab2da76215ad380",
"type": "tab",
"label": "Sys: App Setup",
"disabled": false,
"locked": true,
"info": "",
"env": []
},
{
"id": "2924702c.b33a7",
"type": "subflow",
"name": "ui-table handler",
"info": "# ui-table handler\nUniversal handler for ui-table.\n## features\n- buffer table data\n- add or update individual rows or cells of the table\n- delete rows\n- clear tableData\n- handle column width\n- handle column order\n- hide und unhide columns\n- hide and unhide rows\n- records row order\n- support for nested columns [(column groups)](http://tabulator.info/examples/4.7#column-groups)\n- support for child rows (_children) [(nested data trees)](http://tabulator.info/examples/4.7#tree)\n\nFor real life example see:\n\n**syslog server** for logfile like table with filters\n\n**remote device table** for dynamically updated table with context menues\n\n**irrigation system** for sortable rows\n\n## sending data to ui-tabel\n\n- sending an `array` as discribed in ui-table will replace the complete table and delete all table edits\n \n if `msg.keepEdits=true` is added the existing edits will be kept.\n- send an `object` containing the updated properties of a table row by sending msg.<tableDataProp>.\n\n The table is updated using the `updateOrAddData` command. You can alter the command used by adding the `msg.tabulatorCommand` and `msg.tabulatorParameter`\n\n```\nmsg.tabulatorCommand=\"addData\";\nmsg.tabulatorParameter=[true];\n```\n## configuration\n- `tabulator` json formatted object containing configuration of the table. See ui-table for more details.\n- `property` property of the msg object that contains the data to be passed to ui-table. I.e. *state* `msg.state`\n- `index` index column to identify individual rows. Each message containing data must have a unique `msg.topic` to identify the row. Messages without this `msg.topic` will be droped. It is not nessesary but possible to display the index column in the table. Do not enable editing on this column otherwise you will loose the connection and another row will be added to the table as soon as a new message arrives!\n\n Defaults to *$topic* `msg.state.$topic`\n- `maxRows`maximum number of rows held by table widget. If grater than **0** the amount of rows in ui-table is limited. For this to work the index row must be a Number. ´rows < currentID-maxRows´ will be deleted.\n- `maxStore`maximum number of rows stored by this node for replay if a client connects. If grater than **0** the amount of rows in flow context is limited. for this to work the index row must be a Number. ´rows < currentID-maxStore´ will be deleted.\n- `dashboard` name of the dashboard tab to only update the table if the dashboard is visible. If empty the table will be updated on every tab change and connect.\n- `context` configuration of context data. The subflow will save or cache data in the flows context using `$parent.`. \n **tableData** caches the incoming data to restore it on `ui-control´ *change* messages.\n **tableConfig** saves column width and order to save the interactive table layot\n **tableEdit** saves edits on the table data otherwise it would be overwritten when new data arrives\n```json\n{\n \"tableData\": {\n \"name\": \"tableData\"\n },\n \"tableConfig\": {\n \"name\": \"tableConfig\",\n \"storage\": \"file\"\n },\n \"tableEdit\": {\n \"name\": \"tableEdit\",\n \"storage\": \"file\"\n }\n}\n```\n\n## commands\ncommands can be passed by sending a object as `msg.payload`\n\n```json\n{\n \"command\": \"delete\",\n \"object\": \"columnOrder\"\n}\n```\n\n- `deleteTable` tableCache\n- `deleteRow` delete single row. `object` matching index property\n- `ignoreRow` delete single row and put it on an ignore list. `object` matching index property\n- `unIgnoreRow`remove row from the ignore list. `object` matching index property\n- `unIgnoreRows`delte the ignore list. \n- `deleteRowOrder` delete custom row order\n- `deleteColumnOrder` delete custom column order\n This is important if you add or delete columns in the tabulator config otherwise the columns most likely don`t show up\n- `deleteColumnWidth` delete custom column width\n- `columnHide` hide a column. `object` matching column field\n- `columnUnHide` unhide a column. `object` matching column field\n- `columnsUnHide` unhide all hidden columns.\n- `setMaxStore` set maximum amount of rows in cache\n- `setMaxDisplay` set maximum amout of rows in ui-table\n- `getTable` get table data (as displayed) as an array (on 2nd output)\n \n## background\nui-table warps the powerfull tabluator library. This subflow makes it easier to unleash the powerfull features of ui-table",
"category": "dashboard",
"in": [
{
"x": 54,
"y": 85,
"wires": [
{
"id": "5eb0bd6b.74b794"
}
]
}
],
"out": [
{
"x": 360,
"y": 85,
"wires": [
{
"id": "5eb0bd6b.74b794",
"port": 1
}
]
},
{
"x": 360,
"y": 136,
"wires": [
{
"id": "5eb0bd6b.74b794",
"port": 2
}
]
}
],
"env": [
{
"name": "tabulator",
"type": "json",
"value": "{\"tabulator\":{\"responsiveLayout\":\"collapse\",\"responsiveLayoutCollapseStartOpen\":false,\"index\":\"$name\",\"layout\":\"fitColumns\",\"movableColumns\":true,\"groupBy\":\"\",\"columnResized\":\"function(column){ var newColumn = { field: column._column.field, visible: column._column.visible, width: column._column.width, widthFixed: column._column.widthFixed, widthStyled: column._column.widthStyled }; this.send({topic:this.config.topic,ui_control:{callback:'columnResized',columnWidths:newColumn}}); }\",\"columnMoved\":\"function(column, columns){ var newColumns=[]; columns.forEach(function (column) { newColumns.push({'field': column._column.definition.field, 'title': column._column.definition.title}); }); this.send({topic:this.config.topic,ui_control:{callback:'columnMoved',columns:newColumns}}); }\",\"rowFormatter\":\"function(row){ var data = row.getData(); switch (data.$state) { case \\\"lost\\\": row.getElement().style.backgroundColor = \\\"#9e2e66\\\"; row.getElement().style.color = \\\"#a6a6a6\\\"; break; case \\\"sleeping\\\": row.getElement().style.backgroundColor = \\\"#336699\\\"; break; case \\\"disconnected\\\": row.getElement().style.backgroundColor = \\\"#cc3300\\\"; row.getElement().style.color = \\\"#a6a6a6\\\"; break; case \\\"alert\\\": row.getElement().style.backgroundColor = \\\"#A6A6DF\\\"; break; case \\\"init\\\": row.getElement().style.backgroundColor = \\\"#f2f20d\\\"; break; case \\\"ready\\\": row.getElement().style.backgroundColor = \\\"\\\"; row.getElement().style.color = \\\"\\\"; break; } }\",\"columns\":[{\"formatter\":\"responsiveCollapse\",\"width\":30,\"minWidth\":30,\"align\":\"center\",\"resizable\":false,\"headerSort\":false,\"frozen\":true,\"title\":\"expand\",\"field\":\"expand\",\"headerVertical\":\"flip\"},{\"formatter\":\"function(cell, formatterParams, onRendered) { var html = cell.getValue(); return html; }\",\"title\":\"State\",\"field\":\"$stateIcon\",\"width\":100,\"frozen\":true,\"headerVertical\":\"flip\"},{\"formatter\":\"function(cell, formatterParams, onRendered) { var html = cell.getValue(); return html; }\",\"title\":\"Signal\",\"field\":\"signalIcon\",\"width\":100,\"frozen\":true,\"headerVertical\":\"flip\"},{\"title\":\"Name\",\"field\":\"$name\",\"width\":100,\"frozen\":true,\"headerVertical\":\"flip\"},{\"title\":\"State\",\"field\":\"$state\",\"width\":100,\"align\":\"center\",\"headerVertical\":\"flip\"},{\"title\":\"last-ready\",\"field\":\"lastSeenreadyFormatted\",\"width\":100,\"align\":\"left\",\"headerVertical\":\"flip\"},{\"title\":\"Homie\",\"field\":\"$homie\",\"width\":100,\"align\":\"left\",\"headerVertical\":\"flip\"},{\"title\":\"Platform\",\"field\":\"$implementation\",\"width\":100,\"align\":\"left\",\"headerVertical\":\"flip\"},{\"title\":\"Statistics\",\"columns\":[{\"title\":\"Interval\",\"field\":\"interval\",\"width\":100,\"headerVertical\":\"flip\"},{\"formatterParams\":{\"outputFormat\":\"d hh:mm:ss\",\"inputFormat\":\"seconds\",\"invalidPlaceholder\":\"(unknown)\"},\"title\":\"Uptime\",\"field\":\"uptime\",\"formatter\":\"function(cell, formatterParams, onRendered){ var pad = function (num) { return (\\\"0\\\"+num).slice(-2); }; var secs = Number(cell.getValue()); if (Number.isNaN(secs)) return; var minutes = Math.floor(secs / 60); secs = secs%60; var hours = Math.floor(minutes/60); minutes = minutes%60; var days = Math.floor(hours/24); hours = hours%24; if (days>0) return days+\\\"d \\\"+pad(hours)+\\\":\\\"+pad(minutes); else return pad(hours)+\\\":\\\"+pad(minutes)+\\\":\\\"+pad(secs); }\",\"width\":100,\"headerVertical\":\"flip\"},{\"formatterParams\":{\"min\":0,\"max\":100,\"color\":[\"red\",\"orange\",\"green\"],\"legend\":\"function (value) {if (value>0) return \\\"<span style='color:#FFFFFF;'>\\\"+value+\\\" %</span>\\\"; else return; }\",\"legendColor\":\"#FFFFFF\",\"legendAlign\":\"center\"},\"title\":\"Signal\",\"field\":\"signal\",\"formatter\":\"progress\",\"width\":100,\"headerVertical\":\"flip\"},{\"formatterParams\":{\"min\":2.5,\"max\":3.5,\"color\":[\"red\",\"green\",\"red\"],\"legend\":\"function (value) { if (value>0) return \\\"<span style='color:#FFFFFF;'>\\\"+value+\\\" V</span>\\\"; else return; }\",\"legendColor\":\"#101010\",\"legendAlign\":\"center\"},\"title\":\"Supply\",\"field\":\"supply\",\"formatter\":\"progress\",\"width\":100,\"headerVertical\":\"flip\"},{\"formatterParams\":{\"min\":0,\"max\":100,\"color\":[\"red\",\"orange\",\"green\"],\"legend\":\"function (value) { if (value>0) return \\\"<span style='color:#FFFFFF;'>\\\"+value+\\\" %</span>\\\"; else return; }\",\"legendColor\":\"#101010\",\"legendAlign\":\"center\"},\"title\":\"Battery\",\"field\":\"battery\",\"formatter\":\"progress\",\"width\":100,\"headerVertical\":\"flip\"},{\"formatterParams\":{\"min\":0,\"max\":100000,\"color\":[\"red\",\"orange\",\"green\"],\"legend\":\"function (value) { if (value>0) return \\\"<span style='color:#FFFFFF;'>\\\"+(value/1024).toFixed(2)+\\\" kB</span>\\\"; else return; }\",\"legendColor\":\"#101010\",\"legendAlign\":\"center\"},\"title\":\"Memory\",\"field\":\"freeheap\",\"formatter\":\"progress\",\"width\":100,\"headerVertical\":\"flip\"},{\"formatterParams\":{\"target\":\"_blank\",\"min\":0,\"max\":100,\"color\":[\"red\",\"orange\",\"green\"],\"legend\":\"function (value) { if (value>0) return \\\"<span style='color:#FFFFFF;'>\\\"+value+\\\" %</span>\\\"; else return; }\",\"legendColor\":\"#101010\",\"legendAlign\":\"center\"},\"title\":\"CPU load\",\"field\":\"cpuload\",\"formatter\":\"progress\",\"width\":100,\"headerVertical\":\"flip\"},{\"formatterParams\":{\"min\":20,\"max\":60,\"color\":[\"green\",\"orange\",\"red\"],\"legend\":\"function (value) { if (value>0) return \\\"<span style='color:#FFFFFF;'>\\\"+value+\\\" °C</span>\\\"; else return; }\",\"legendColor\":\"#101010\",\"legendAlign\":\"center\"},\"title\":\"CPU temp\",\"field\":\"cputemp\",\"formatter\":\"progress\",\"width\":100,\"headerVertical\":\"flip\"}]},{\"title\":\"Firmware\",\"columns\":[{\"formatter\":\"link\",\"formatterParams\":{\"labelField\":\"$localip\",\"urlPrefix\":\"http://\",\"target\":\"_blank\"},\"title\":\"IP\",\"field\":\"$localip\",\"width\":100},{\"title\":\"mac\",\"field\":\"$mac\",\"width\":100},{\"title\":\"Accsess Point\",\"field\":\"SSID\",\"width\":100},{\"title\":\"Firmware\",\"field\":\"name\",\"width\":100},{\"title\":\"Version\",\"field\":\"version\",\"width\":100},{\"title\":\"Last Boot Cause\",\"field\":\"lastBootCause\",\"width\":100},{\"title\":\"Reset Reason\",\"field\":\"resetReason\",\"width\":100}]}]},\"customHeight\":12}",
"ui": {
"icon": "font-awesome/fa-table",
"label": {
"en-US": "Tabulator"
},
"type": "input",
"opts": {
"types": [
"json",
"env"
]
}
}
},
{
"name": "tableDataProp",
"type": "str",
"value": "row",
"ui": {
"icon": "font-awesome/fa-tag",
"label": {
"en-US": "rowProperty"
}
}
},
{
"name": "tableIndex",
"type": "str",
"value": "$topic",
"ui": {
"icon": "font-awesome/fa-indent",
"label": {
"en-US": "Index"
},
"type": "input",
"opts": {
"types": [
"str",
"json",
"env"
]
}
}
},
{
"name": "maxRows",
"type": "num",
"value": "0",
"ui": {
"icon": "font-awesome/fa-list-ol",
"type": "input",
"opts": {
"types": [
"num",
"bool",
"env"
]
}
}
},
{
"name": "maxStore",
"type": "num",
"value": "0",
"ui": {
"icon": "font-awesome/fa-database",
"type": "input",
"opts": {
"types": [
"num",
"env"
]
}
}
},
{
"name": "dashboard",
"type": "str",
"value": "Remote Device Table",
"ui": {
"icon": "font-awesome/fa-dashboard",
"label": {
"en-US": "Dashboard"
},
"type": "input",
"opts": {
"types": [
"str",
"env"
]
}
}
},
{
"name": "tableContext",
"type": "json",
"value": "{\"tableData\":{\"name\":\"tableData\"},\"tableConfig\":{\"name\":\"tableConfig\",\"storage\":\"file\"},\"tableEdit\":{\"name\":\"tableEdit\",\"storage\":\"file\"}}",
"ui": {
"icon": "font-awesome/fa-database",
"label": {
"en-US": "Context"
},
"type": "input",
"opts": {
"types": [
"json",
"env"
]
}
}
}
],
"color": "#3FADB5",
"icon": "node-red-dashboard/ui_slider.png",
"status": {
"x": 360,
"y": 34,
"wires": [
{
"id": "5eb0bd6b.74b794",
"port": 0
}
]
}
},
{
"id": "5958c5854f8ba7cd",
"type": "subflow",
"name": "Route & Process MQTT",
"info": "Used for routing MQTT messages to the relevant database and table updates. \nAlso updates msg.caller with a 'type' property to be displayed on dashboards.\n\nThis is for multiple display handling within the call system\nfor example if you have the following displays within a system:\n 1. 1 dashboard for calling of SV, QC, Maintenance etc\n 2. 1 dashboard for displaying finished goods pickup queue\n 3. 1 dashboard for displaying child part supply queue\n \nFor each of these displays create one of these nodes and specify the `Message Type` it needs to react to. This needs to be specified in comma separated string of message values. If the value of said message is present within the mqtt msg.payload, then the router will pass on msg to the next node. otherwise, msg stops here. for example: \n\n 1. \"SV,QC,FM\" for calling dashboard\n 2. \"FG\" for finished goods dashboard\n 3. \"CP\" for child parts supply dashboard\n\n",
"category": "",
"in": [
{
"x": 60,
"y": 80,
"wires": [
{
"id": "ca29863c4aa8e8c4"
}
]
}
],
"out": [
{
"x": 1000,
"y": 80,
"wires": [
{
"id": "0a6feae435792b59",
"port": 0
},
{
"id": "2d346ea6aca78b20",
"port": 0
}
]
}
],
"env": [
{
"name": "Function Topic",
"type": "str",
"value": "call",
"ui": {
"type": "input",
"opts": {
"types": [
"str",
"env"
]
}
}
},
{
"name": "Message Types",
"type": "str",
"value": "SV,QC,FM",
"ui": {
"type": "input",
"opts": {
"types": [
"str"
]
}
}
},
{
"name": "Database Name",
"type": "str",
"value": "callList",
"ui": {
"label": {
"en-US": "DataBase Name (list/queue name)"
},
"type": "input",
"opts": {
"types": [
"str"
]
}
}
},
{
"name": "Database Type",
"type": "str",
"value": "list",
"ui": {
"type": "select",
"opts": {
"opts": [
{
"l": {
"en-US": "List"
},
"v": "list"
},
{
"l": {
"en-US": "Queue"
},
"v": "queue"
}
]
}
}
}
],
"meta": {},
"color": "#DDAA99"
},
{
"id": "da1f44dea6948311",
"type": "subflow",
"name": "Prep Display",
"info": "",
"category": "",
"in": [
{
"x": 80,
"y": 140,
"wires": [
{
"id": "cbe7722c78ec5828"
}
]
}
],
"out": [
{
"x": 900,
"y": 240,
"wires": [
{
"id": "60e11389bb8c4eeb",
"port": 0
},
{
"id": "4b1dda8b64c7e08b",
"port": 0
}
]
}
],
"env": [
{
"name": "List/Queue Name",
"type": "str",
"value": "callList",
"ui": {
"type": "input",
"opts": {
"types": [
"str"
]
}
}
},
{
"name": "Display Format",
"type": "json",
"value": "{\"tabulator\":{\"responsiveLayout\":\"collapse\",\"layout\":\"fitColumns\",\"movableColumns\":true,\"index\":\"Id\",\"columns\":[{\"title\":\"ID\",\"align\":\"center\",\"width\":\"7%\",\"formatter\":\"rownum\"},{\"title\":\"Dept\",\"field\":\"Department\"},{\"title\":\"Line\",\"field\":\"Line\"},{\"title\":\"Cell\",\"field\":\"Cell\"},{\"title\":\"For\",\"field\":\"Type\"},{\"title\":\"Time\",\"field\":\"Time\",\"width\":\"25%\"}]}}",
"ui": {
"label": {
"en-US": "Display Format (JSON)"
},
"type": "input",
"opts": {
"types": [
"json",
"env"
]
}
}
},
{
"name": "Refresh Interval",
"type": "num",
"value": "5",
"ui": {
"label": {
"en-US": "Refresh Rate (secondss)"
},
"type": "spinner"
}
}
],
"meta": {},
"color": "#DDAA99"
},
{
"id": "fa9ee2fc5ce99563",
"type": "subflow",
"name": "Prep T/gram Msg",
"info": "",
"category": "",
"in": [
{
"x": 80,
"y": 80,
"wires": [
{
"id": "9c847bce7cbf0393"
}
]
}
],
"out": [
{
"x": 620,
"y": 80,
"wires": [
{
"id": "b5800b192ab7eeeb",
"port": 0
}
]
}
],
"env": [
{
"name": "List/Queue Name",
"type": "str",
"value": "callList",
"ui": {
"type": "input",
"opts": {
"types": [
"str",
"env"
]
}
}
},
{
"name": "Recipients List",
"type": "json",
"value": "{\"SV\":\"Mgmt/Press\",\"QC\":\"Mgmt/QC/Press\",\"FM\":\"Mgmt/FM/Press\",\"DM\":\"Mgmt/FM/Die\"}",
"ui": {
"type": "input",
"opts": {
"types": [
"json"
]
}
}
},
{
"name": "Escalation Time",
"type": "num",
"value": "5",
"ui": {
"label": {
"en-US": "Escalation Time (mins)"
},
"type": "input",
"opts": {
"types": [
"num"
]
}
}
}
],
"meta": {},
"color": "#DDAA99"
},
{
"id": "f5b1a306a8b9c006",
"type": "subflow",
"name": "Ctrl Siren/Lights",
"info": "This a simple node that sends an output value of 1 \nto GPIO 17 of Raspberry Pi (pin no 11) whenever\nList or Queue is not empty. \n\nYou should connect a Solid State Relay that accepts a 3.3V activation voltage such as\nthe FOTEK SSR-40DA. wiring should be made with \nthe positive wire at pin 11, and ground wire (negative)\nat pin 9",
"category": "",
"in": [
{
"x": 100,
"y": 100,
"wires": [
{
"id": "bd6f401b4154c6fc"
}
]
}
],
"out": [],
"env": [
{
"name": "List/Queue Name",
"type": "str",
"value": "callList",
"ui": {
"type": "input",
"opts": {
"types": [
"str",
"env"
]
}
}
}
],
"meta": {},
"color": "#DDAA99"
},
{
"id": "2df0c70bc86dd6ae",
"type": "group",
"z": "327571d15da5aceb",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"aed69bd7994a8096",
"d3a0745948b821c9"
],
"x": 134,
"y": 339,
"w": 232,
"h": 122
},
{
"id": "80a9d3eddd3850f6",
"type": "group",
"z": "d9c16620383ec561",
"name": "In case you need to change dashboard pages when a call is made",
"style": {
"label": true,
"color": "#000000",
"stroke": "#ffC000"
},
"nodes": [
"80b1fb2dd47643d8",
"2022fca4a20f48d0",
"39f563b3717d924b",
"60ec8fc7c03081d6",
"eb8b7ad763ba6eb8"
],
"x": 134,
"y": 399,
"w": 552,
"h": 122
},
{
"id": "d2bd110790f6ae19",
"type": "ui_base",
"theme": {
"name": "theme-dark",
"lightTheme": {
"default": "#0094CE",
"baseColor": "#0075a3",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": true,
"reset": false
},
"darkTheme": {
"default": "#097479",
"baseColor": "#b01c1c",
"baseFont": "Arial Black,Arial Black,Gadget,sans-serif",
"edited": true,
"reset": false
},
"customTheme": {
"name": "Untitled Theme 1",
"default": "#4B7930",
"baseColor": "#4B7930",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"reset": false
},
"themeState": {
"base-color": {
"default": "#097479",
"value": "#b01c1c",
"edited": true
},
"page-titlebar-backgroundColor": {
"value": "#b01c1c",
"edited": false
},
"page-backgroundColor": {
"value": "#111111",
"edited": false
},
"page-sidebar-backgroundColor": {
"value": "#333333",
"edited": false
},
"group-textColor": {
"value": "#df3939",
"edited": false
},
"group-borderColor": {
"value": "#555555",
"edited": false
},
"group-backgroundColor": {
"value": "#333333",
"edited": false
},
"widget-textColor": {
"value": "#eeeeee",
"edited": false
},
"widget-backgroundColor": {
"value": "#b01c1c",
"edited": false
},
"widget-borderColor": {
"value": "#333333",
"edited": false
},
"base-font": {
"value": "Arial Black,Arial Black,Gadget,sans-serif"
}
},
"angularTheme": {
"primary": "indigo",
"accents": "blue",
"warn": "red",
"background": "grey",
"palette": "light"
}
},
"site": {
"name": "Node-RED Dashboard",
"hideToolbar": "true",
"allowSwipe": "false",
"lockMenu": "icon",
"allowTempTheme": "true",
"dateFormat": "DD/MM/YYYY",
"sizes": {
"sx": 48,
"sy": 48,
"gx": 10,
"gy": 10,
"cx": 6,
"cy": 6,
"px": 0,
"py": 0
}
}
},
{
"id": "85b12cf0fa38d858",
"type": "ui_group",
"name": "Production Output",
"tab": "d5e27fdb153bf0a3",
"order": 2,
"disp": false,
"width": "26",
"collapse": false,
"className": ""
},
{
"id": "d5e27fdb153bf0a3",
"type": "ui_tab",
"d": true,
"name": "Data",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
},
{
"id": "56edfd93d9c67181",
"type": "mqtt-broker",
"name": "",
"broker": "8a8b53b135b04c51bbc202862a1eddc9.s2.eu.hivemq.cloud",
"port": "8883",
"tls": "",
"clientid": "asyraf9-nodered",
"autoConnect": true,
"usetls": true,
"protocolVersion": "5",
"keepalive": "60",
"cleansession": false,
"autoUnsubscribe": false,
"birthTopic": "AKSB/SA/CONNECTION",
"birthQos": "0",
"birthPayload": "Node Red Line F Connected",
"birthMsg": {},
"closeTopic": "AKSB/SA/CONNECTION",
"closeQos": "0",
"closePayload": "Node Red Line F Disconnecting",
"closeMsg": {},
"willTopic": "AKSB/SA/CONNECTION",
"willQos": "0",
"willPayload": "Node Red Line F Disconnected",
"willMsg": {},
"userProps": "",
"sessionExpiry": "0"
},
{
"id": "7f97a1b59fccc5ce",
"type": "ui_tab",
"name": "Alert",
"icon": "dashboard",
"order": 5,
"disabled": false,
"hidden": false
},
{
"id": "ea1829c43a6e8ad0",
"type": "telegram bot",
"botname": "Autokeen Official Bot",
"usernames": "",
"chatids": "",
"baseapiurl": "",
"updatemode": "none",
"pollinterval": "1000",
"usesocks": false,
"sockshost": "",
"socksprotocol": "socks5",
"socksport": "6667",
"socksusername": "anonymous",
"sockspassword": "",
"bothost": "",
"botpath": "",
"localbotport": "8443",
"publicbotport": "8443",
"privatekey": "",
"certificate": "",
"useselfsignedcertificate": false,
"sslterminated": false,
"verboselogging": true
},
{
"id": "02f09ba258bf6625",
"type": "ui_group",
"name": "Call Queue",
"tab": "7f97a1b59fccc5ce",
"order": 2,
"disp": true,
"width": "28",
"collapse": false,
"className": "callqueue"
},
{
"id": "db830ddbd85f76c5",
"type": "ui_tab",
"d": true,
"name": "FG Queue",
"icon": "dashboard",
"order": 3,
"disabled": false,
"hidden": false
},
{
"id": "569dc256923818f6",
"type": "ui_group",
"name": "FG Queue",
"tab": "db830ddbd85f76c5",
"order": 1,
"disp": true,
"width": 25,
"collapse": false,
"className": ""
},
{
"id": "145f52da01ded04e",
"type": "ui_tab",
"d": true,
"name": "Kowake",
"icon": "dashboard",
"order": 4,
"disabled": false,
"hidden": false
},
{
"id": "e5276d6b5a48a00a",
"type": "ui_group",
"name": "Kowake Queue",
"tab": "145f52da01ded04e",
"order": 1,
"disp": true,
"width": 25,
"collapse": false,
"className": ""
},
{
"id": "5eb0bd6b.74b794",
"type": "function",
"z": "2924702c.b33a7",
"name": "handle tableData",
"func": "var status = {fill:\"red\",shape:\"dot\",text: \"payload \"};\nvar tableIndex = env.get(\"tableIndex\") || \"$topic\";\nvar tableDataProp = env.get(\"tableDataProp\") || \"row\";\nvar tableContext = env.get(\"tableContext\");\nvar dashboard = env.get(\"dashboard\");\nvar maxRows = env.get(\"maxRows\") || 0;\nvar maxStore = env.get(\"maxStore\") || 0;\n\nif (!tableContext.hasOwnProperty(\"tableData\") || !tableContext.hasOwnProperty(\"tableConfig\")) {\n status.text=\"tableContext not defined\";\n node.error(status.text);\n return [{payload:status},null];\n}\n\n// context store to cache table data (memoryOnly prefered)\nvar tableData = flow.get(\"$parent.\"+tableContext.tableData.name,tableContext.tableData.storage);\nif (tableData===undefined) {\n node.warn(\"[ui-table handler] tableData initialized!\");\n tableData={};\n flow.set(\"$parent.\"+tableContext.tableData.name,tableData,tableContext.tableData.storage);\n}\n\n// context Store to save table configuration (file)\nvar tableConfig = flow.get(\"$parent.\"+tableContext.tableConfig.name,tableContext.tableConfig.storage);\nif (tableConfig===undefined) {\n node.warn(\"[ui-table handler] tableConfig initialized!\");\n tableConfig={ResponsiveLayout:true};\n flow.set(\"$parent.\"+tableContext.tableConfig.name,tableConfig,tableContext.tableConfig.storage);\n}\n\nif (tableConfig.hasOwnProperty(\"maxStore\")) maxStore=tableConfig.maxStore;\nif (tableConfig.hasOwnProperty(\"maxRows\")) maxRows=tableConfig.maxRows;\n\n// context Store to save table configuration (file)\nvar tableEdit;\nif (tableContext.hasOwnProperty(\"tableEdit\")) {\n tableEdit = flow.get(\"$parent.\"+tableContext.tableEdit.name,tableContext.tableEdit.storage);\n if (tableEdit===undefined) {\n node.warn(\"[ui-table handler] tableEdit initialized!\");\n tableEdit={};\n flow.set(\"$parent.\"+tableContext.tableEdit.name,tableEdit,tableContext.tableEdit.storage);\n }\n}\n\n// function to merge partial data into existing table row\nvar mergeObject = function (destination, source, filter) {\n for (let currentSource in source) {\n if (source.hasOwnProperty(currentSource)) {\n if (filter!==undefined && tableEdit && tableEdit.hasOwnProperty(filter) && tableEdit[filter].hasOwnProperty(currentSource)) {\n destination[currentSource]= tableEdit[filter][currentSource];\n source[currentSource]=tableEdit[filter][currentSource];\n } else {\n destination[currentSource]= source[currentSource];\n }\n } \n }\n return source;\n};\n\n// merge edits into a destination object respecting _children\nvar mergeEdits = function(destination) {\n \n var mergeChildEdits = function(children) {\n children.forEach(child => {\n if (child.hasOwnProperty(tableIndex) && tableEdit.hasOwnProperty(child[tableIndex])) {\n// node.warn([\"mergeChild\",child])\n Object.keys(tableEdit[child[tableIndex]]).forEach(edit => {\n if (child.hasOwnProperty(edit)) {\n child[edit]=tableEdit[child[tableIndex]][edit];\n// node.warn([\"mergeChild edit \",edit,child[edit]])\n }\n });\n }\n if (child.hasOwnProperty(\"_children\")) {\n mergeChildEdits(child._children);\n }\n })\n }\n \n\n Object.keys(destination).forEach(row => {\n if (destination[row].hasOwnProperty(tableIndex)) {\n if (tableEdit.hasOwnProperty(row)) {\n Object.keys(tableEdit[row]).forEach(edit => {\n destination[row][edit]=tableEdit[row][edit];\n });\n }\n if (destination[row].hasOwnProperty(\"_children\")) {\n mergeChildEdits(destination[row]._children);\n }\n }\n });\n}\n\n// deep search for a column including nested columns\nvar searchTabulatorColumn = function (columns,key,match) {\n var result;\n for (let column of columns) {\n if (column.hasOwnProperty(\"columns\")) {\n result = searchTabulatorColumn(column.columns,key,match);\n if (result!==undefined) return result;\n } else if (column.hasOwnProperty(key) && column[key]===match) {\n return column;\n }\n }\n};\n\n// command message to update add or update data on ui-table\nvar msgToTable={};\nmsgToTable.payload={\n \"command\":msg.tabulatorCommand || \"updateOrAddData\",\n \"arguments\": [],\n \"returnPromise\": false\n};\n\n// store data in tableData\nif (msg.hasOwnProperty(tableDataProp)) {\n // store data for later recover\n if (!msg.hasOwnProperty(\"topic\")) { // check if index existst\n status.text=\"msg.topic not defined!\";\n return [{payload:status},null];\n }\n if (!tableData.hasOwnProperty(msg.topic)){ // first seen\n if (maxRows>0 && Object.keys(tableData).lenght===0) {\n tableConfig.currentFirstRow=msg.topic;\n }\n tableData[msg.topic]={};\n if (tableEdit && tableEdit.hasOwnProperty(msg.topic)) { // table edits available!\n Object.keys(tableEdit[msg.topic]).forEach((key) => {\n msg[tableDataProp][key]=tableEdit[msg.topic][key];\n tableData[msg.topic][key]=tableEdit[msg.topic][key];\n })\n }\n if (maxStore>0 && typeof msg.topic === \"number\") { // limit rows in tableData\n let rowKeys = Object.keys(tableData);\n if (rowKeys.length>maxStore) {\n for (let i=0; i<(rowKeys.length-maxStore); i++) {\n delete tableData[rowKeys[i]];\n }\n }\n }\n }\n if (!tableData[msg.topic].hasOwnProperty(tableIndex)) tableData[msg.topic][tableIndex]=msg.topic;\n msg[tableDataProp]=mergeObject(tableData[msg.topic],msg[tableDataProp],msg.topic);\n msg[tableDataProp][tableIndex]=msg.topic;\n msgToTable.payload.arguments=[[msg[tableDataProp]]];\n // add aditional parameters\n if (msg.hasOwnProperty(\"tabulatorParameter\") && Array.isArray(msg.tabulatorParameter)) {\n for (let arg in msg.tabulatorParameter) msgToTable.payload.arguments.push(arg);\n }\n // delete rows if rows exceed maxRows\n /*\n if (maxRows>0 && tableConfig.hasOwnProperty(\"currentFirstRow\") && typeof tableData[msg.topic][tableIndex]===\"number\") {\n //node.warn([maxRows,tableConfig.hasOwnProperty(\"currentFirstRow\"),typeof tableData[msg.topic][tableIndex],tableConfig.currentFirstRow,tableData[msg.topic][tableIndex]-maxRows])\n if (tableConfig.currentFirstRow<tableData[msg.topic][tableIndex]-maxRows) {\n node.warn([\"maxRowExeeded\",tableConfig.currentFirstRow]);\n node.send([null,{payload:{\"command\":\"deleteRow\",\"arguments\": [tableConfig.currentFirstRow],\"returnPromise\": false}},null]);\n tableConfig.currentFirstRow++;\n }\n }*/\n if (maxRows>0 && typeof tableData[msg.topic][tableIndex]===\"number\" && msg.topic-maxRows>0) {\n node.send([null,{payload:{\"command\":\"deleteRow\",\"arguments\": [msg.topic-maxRows],\"returnPromise\": false}},null]);\n }\n status.fill=\"green\";\n status.text=msg.topic+\" updated\";\n return [{payload:status},msgToTable,null];\n} if (msg.payload===\"connect\" || (msg.payload===\"change\" && msg.name===dashboard) || (msg.hasOwnProperty(\"payload\") && msg.payload.hasOwnProperty(\"command\"))) { \n if (!msg.hasOwnProperty(\"ui_control\")) {\n msg.ui_control = env.get('tabulator');\n status.text+=\" ui_control added\";\n }\n //process commands\n //node.warn({\"command\":msg.payload.command,\"msg\":msg,\"object\":msg.payload.object})\n if (msg.payload.hasOwnProperty(\"command\") && msg.payload.command!=='getTable') {\n status.fill=\"blue\";\n switch(msg.payload.command) {\n case 'deleteTable':\n flow.set(\"$parent.\"+tableContext.tableData.name,undefined,tableContext.tableData.storage);\n tableData={};\n status.text=\"tabledata deleted\";\n node.warn(\"[ui-table handler] \"+\"tabledata deleted\");\n break;\n case 'deleteRow':\n case 'deleteDevice':\n var deleteRow = function(id) {\n // check if row is in root\n if (tableData.hasOwnProperty(id)) {\n delete tableData[id]\n return true;\n }\n // check if row is a child\n let deleteChildRow = function(children, id) {\n for(let i = 0; i < children.length; i++){\n if (children[i].hasOwnProperty(tableIndex) && children[i][tableIndex]===id) {\n children.splice(i, 1); \n return true; \n }\n if (children[i].hasOwnProperty(\"_children\")) {\n if (deleteChildRow(children[i]._children,id)) {\n if (children[i]._children.length === 0) {\n delete children[i]._children;\n }\n return true;\n }\n }\n }\n return false;\n };\n \n for (let row in tableData) {\n if (tableData[row].hasOwnProperty(\"_children\")) {\n if (deleteChildRow(tableData[row]._children,id)) return true;\n }\n }\n return false;\n }\n \n if (deleteRow(msg.payload.object)) {\n status.text=msg.payload.object+\" deleted\";\n } else {\n status.fill=\"yellow\";\n status.text=msg.payload.object+\" undefined\";\n }\n break;\n case 'ignoreRow':\n case 'ignoreDevice':\n if (tableData.hasOwnProperty(msg.payload.object)) {\n delete tableData[msg.payload.object];\n status.text=msg.payload.object+\" will be ignored\";\n if (!tableConfig.hasOwnProperty('ignoreDevice')) tableConfig.ignoreDevice={};\n tableConfig.ignoreDevice[msg.payload.object]=true;\n }\n break;\n case 'unIgnoreRow':\n case 'unIgnoreDevice':\n if (tableConfig.hasOwnProperty('ignoreDevice')) {\n delete tableConfig.ignoreDevice[msg.payload.object];\n }\n break;\n case 'unIgnoreRows':\n case 'unIgnoreDevices':\n delete tableConfig.ignoreDevice;\n break;\n case 'updateData':\n status.text=\"column \"+msg.payload.column+\" updated\";\n delete msg.ui_control;\n return [{payload:status},msg];\n case 'updateTable':\n status.text=msg.payload.command+\": \";\n break;\n case 'columnHide':\n if (!tableConfig.hasOwnProperty('columnVisible')) tableConfig.columnVisible={};\n tableConfig.columnVisible[msg.payload.object]=false;\n break;\n case 'columnUnHide':\n if (!tableConfig.hasOwnProperty('columnVisible')) tableConfig.columnVisible={};\n tableConfig.columnVisible[msg.payload.object]=true;\n break;\n case 'columnsUnHide':\n for (let column in tableConfig.columnVisible) {\n if (tableConfig.columnVisible.hasOwnProperty(column)) tableConfig.columnVisible[column]=true;\n }\n break;\n case 'refreshTable':\n break;\n case 'deleteColumnOrder':\n case 'restoreColumnOrder':\n delete tableConfig.columns;\n break;\n case 'deleteColumnWidth':\n case 'resetColumnWidth':\n delete tableConfig.columnWidths;\n break;\n case 'setResponsiveLayout':\n tableConfig.ResponsiveLayout=!tableConfig.ResponsiveLayout;\n break;\n case 'deleteRowOrder':\n delete tableConfig.rowOrder;\n break;\n case 'setMaxStore':\n tableConfig.maxStore=msg.payload.object;\n maxStore=msg.payload.object;\n break;\n case 'setMaxRows':\n tableConfig.maxRows=msg.payload.object;\n maxRows=msg.payload.object;\n break;\n default:\n status.fill=\"red\";\n status.text=\"unknown command \"+msg.payload.command;\n node.warn(\"[ui-table handler] \"+status.text);\n break;\n }\n flow.set(\"$parent.\"+tableContext.tableConfig.name,tableConfig,tableContext.tableConfig.storage);\n node.send([{payload:status},null,null]);\n }\n\n // crawl through tabulator arrays and updated user defined values\n var crawlTabulator = function (columns,match,config,property) {\n for (let column of columns) {\n if (column.hasOwnProperty(\"columns\")) {\n crawlTabulator(column.columns,match,config,property);\n } else if (config.hasOwnProperty(column[match])) column[property]=config[column.field];\n }\n };\n \n // restore custom column width\n if (tableConfig.hasOwnProperty(\"columnWidths\") && msg.hasOwnProperty(\"ui_control\")) {\n crawlTabulator(msg.ui_control.tabulator.columns,\"field\",tableConfig.columnWidths,\"width\");\n }\n \n // restore custom column hide/show\n if (tableConfig.hasOwnProperty(\"columnVisible\") && msg.hasOwnProperty(\"ui_control\")) {\n crawlTabulator(msg.ui_control.tabulator.columns,\"field\",tableConfig.columnVisible,\"visible\");\n }\n \n // restore custom responsive / standard view\n if (tableConfig.hasOwnProperty(\"ResponsiveLayout\")) {\n if (!tableConfig.ResponsiveLayout) {\n msg.ui_control.tabulator.responsiveLayout=false;\n }\n msg.ui_control.tabulator.columns.forEach((column,index) => {\n if (column.formatter===\"responsiveCollapse\") { // hide expand column on any position\n column.visible=tableConfig.ResponsiveLayout;\n return;\n }\n });\n }\n\n // sort columns\n if (tableConfig.hasOwnProperty(\"columns\") && msg.hasOwnProperty(\"ui_control\") && msg.ui_control.hasOwnProperty(\"tabulator\")) {\n var addedColumns = 0;\n var sortColumnsByLayout = function (sortColumns, columnsLayout, targetColumns) {\n for (var layoutColumn=0; layoutColumn<columnsLayout.length; layoutColumn++) {\n for (var sortColumn in sortColumns) {\n if (sortColumns[sortColumn].hasOwnProperty(\"columns\")) {\n targetColumns.push({\"title\":sortColumns[sortColumn].title, \"columns\":[]});\n sortColumnsByLayout(sortColumns[sortColumn].columns,columnsLayout,targetColumns[targetColumns.length-1].columns);\n layoutColumn=addedColumns; // jump forward after childes added\n } else {\n if (columnsLayout[layoutColumn].field===sortColumns[sortColumn].field){\n targetColumns.push(sortColumns[sortColumn]);\n addedColumns++;\n break;\n }\n }\n }\n }\n }; \n var newColumns=[];\n sortColumnsByLayout(msg.ui_control.tabulator.columns,tableConfig.columns,newColumns);\n msg.ui_control.tabulator.columns=newColumns;\n }\n\n // restore stored lines after connect\n\n let command = msg.payload.command;\n var tableArray;\n if (command===\"getTable\") {\n msg.payload.tableArray=[];\n tableArray=msg.payload.tableArray\n } else {\n msg.payload=[];\n tableArray=msg.payload;\n }\n \n var pushRowData = function(rowData) {\n // ignore rows in ignoreRows array\n if (tableConfig && tableConfig.hasOwnProperty(\"ignoreDevice\") && tableConfig.ignoreDevice[rowData]) {\n // do nothing\n } else {\n // merge edits into table\n if (tableEdit && tableEdit.hasOwnProperty(rowData)) {\n let tableRow = RED.util.cloneMessage(tableData[rowData]);\n Object.keys(tableEdit[rowData]).forEach((field) => {\n tableRow[field]=tableEdit[rowData][field];\n });\n tableArray.push(tableRow);\n } else {\n tableArray.push(tableData[rowData]);\n }\n }\n }\n \n if (tableConfig.hasOwnProperty(\"rowOrder\")) {\n // first check if new rows exits which are not in rowOrder\n Object.keys(tableData).forEach((key) => {\n if (tableConfig.rowOrder.indexOf(tableData[key][tableIndex])<0) {\n tableConfig.rowOrder.push(tableData[key][tableIndex]); // add row to the end of rowOrder\n }\n });\n tableConfig.rowOrder.forEach((value,index) => {\n node.warn([\"pushRowOrder\",value,tableData.hasOwnProperty(value),tableData[value]]);\n if (tableData.hasOwnProperty(value)) { // push rows in rowOrder sequence\n pushRowData(value);\n } else { // delete not existing rows from rowOrder\n tableConfig.rowOrder.splice(index,1)\n }\n });\n } else {\n for (let rowData in tableData) {\n pushRowData(rowData);\n }\n }\n // store the first index if maxRows limits amount of displayed lines\n if (maxRows>0 && tableData) {\n let tableKeys=Object.keys(tableData);\n if (tableKeys.length>0 && typeof tableData[tableKeys[0]][tableIndex] === \"number\") {\n tableConfig.currentFirstRow=tableData[tableKeys[0]][tableIndex];\n }\n }\n \n if (command=='getTable'){\n status.fill=\"blue\";\n status.text+=\" \"+tableArray.length+\" rows emitted\";\n return [{payload:status},null,msg];\n } else {\n status.fill=\"blue\";\n status.text+=\" \"+tableArray.length+\" rows restored\";\n return [{payload:status},msg,[{topic:\"maxRows\",payload:maxRows},{topic:\"maxStore\",payload:maxStore}]];\n }\n} if (msg.hasOwnProperty(\"ui_control\")) {\n // callback from tabulator\n status.fill=\"blue\";\n status.text=\"callback \"+msg.ui_control.callback;\n switch(msg.ui_control.callback) {\n case \"columnResized\": // save new column width\n if (tableConfig.columnWidths===undefined) tableConfig.columnWidths={};\n tableConfig.columnWidths[msg.ui_control.columnWidths.field]=msg.ui_control.columnWidths.width;\n flow.set(\"$parent.\"+tableContext.tableConfig.name,tableConfig,tableContext.tableConfig.storage);\n status.text=msg.ui_control.columnWidths.field+\"=\"+msg.ui_control.columnWidths.width+\"px\";\n break;\n case \"columnMoved\": // save new column order\n if (tableConfig.columns===undefined) tableConfig.columns=[];\n tableConfig.columns=msg.ui_control.columns;\n flow.set(\"$parent.\"+tableContext.tableConfig.name,tableConfig,tableContext.tableConfig.storage);\n status.text=\"new column order\";\n break;\n case \"cellEdited\":\n if (tableEdit) {\n if (!tableEdit.hasOwnProperty(msg[tableIndex])) tableEdit[msg[tableIndex]]={};\n tableEdit[msg[tableIndex]][msg.field] = msg.payload; // save data and mark as edited field\n flow.set(\"$parent.\"+tableContext.tableEdit.name,tableEdit,tableContext.tableEdit.storage);\n mergeEdits(tableData);\n flow.set(\"$parent.\"+tableContext.tableData.name,tableData,tableContext.tableData.storage);\n status.text=msg[tableIndex]+\" \"+msg.field+\" edited to \"+msg.payload;\n msg[tableDataProp]={};\n msg[tableDataProp][tableIndex]=msg[tableIndex];\n msg[tableDataProp][msg.field]=msg.payload;\n msgToTable.payload.arguments=[[msg[tableDataProp]]];\n node.send([{payload:status},null,msg]); // was node.send([{payload:status},msgToTable,msg]);\n } else {\n node.error(\"[ui-table handler] no tableEdit store defined!\")\n }\n break;\n case \"rowContext\":\n msg.ignoredDevices=[];\n for (let rowData in tableConfig.ignoreDevice) {\n if (tableConfig.ignoreDevice.hasOwnProperty(rowData)) {\n msg.ignoredDevices.push({\"text\":rowData,\"icon\":\"fa fa-plug\",\"topic\":\"unIgnoreDevice\",\"payload\":rowData}) \n }\n }\n break;\n case \"headerContext\":\n msg.hiddenColumns=[];\n let tabulatorConfig = env.get('tabulator');\n for (let column in tableConfig.columnVisible) {\n if (tableConfig.columnVisible.hasOwnProperty(column) &&\n !tableConfig.columnVisible[column]) {\n let configColumn=searchTabulatorColumn(tabulatorConfig.tabulator.columns,\"field\",column);\n let icon;\n if (configColumn.hasOwnProperty('title') && configColumn.title.toLowerCase().includes('</i>')) {\n // <i class='fa fa-star-half-o'></i> State\n let start=configColumn.title.indexOf(\"'fa \");\n let end=configColumn.title.indexOf(\"'\",start+1);\n icon=configColumn.title.substring(start+4,end);\n }\n msg.hiddenColumns.push({\"text\":column,\"icon\":icon,\"topic\":\"columnUnHide\",\"payload\":configColumn.field}) \n }\n }\n break;\n case \"rowMoved\":\n if (tableConfig.rowOrder===undefined) tableConfig.rowOrder={};\n tableConfig.rowOrder=msg.ui_control.rowOrder;\n flow.set(\"$parent.\"+tableContext.tableConfig.name,tableConfig,tableContext.tableConfig.storage);\n status.text=\"new row order\";\n break;\n default:\n // if rowIndex exists pass complete object\n if (msg.hasOwnProperty(tableIndex)) {\n msg.rowData=tableData[msg[tableIndex]];\n }\n status.text=\"pass message\";\n }\n return [{payload:status},null,msg];\n} \nif (Array.isArray(msg.payload)) {\n tableData={};\n \n msg.payload.forEach((row) => {\n if (row.hasOwnProperty(tableIndex)) {\n tableData[row[tableIndex]]=row;\n }\n });\n if (msg.keepEdits) {\n mergeEdits(tableData);\n }\n\n \n flow.set(\"$parent.\"+tableContext.tableData.name,tableData,tableContext.tableData.storage);\n if (tableContext.hasOwnProperty(\"tableEdit\") && !msg.keepEdits) {\n tableEdit={};\n flow.set(\"$parent.\"+tableContext.tableEdit.name,tableEdit,tableContext.tableEdit.storage);\n }\n status.fill=\"blue\"\n status.text=\"table replaced \"+msg.payload.length+\" rows\";\n return [{payload:status},msg,null];\n} \n \n// nothing to do bejond this point\nstatus.text+=\" [\"+msg.payload+\"]\";\nreturn [{payload:status},null];\n",
"outputs": 3,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 190,
"y": 80,
"wires": [
[],
[],
[]
],
"icon": "font-awesome/fa-table"
},
{
"id": "ca29863c4aa8e8c4",
"type": "function",
"z": "5958c5854f8ba7cd",
"name": "Route MQTT Msg",
"func": "let target = env.get(\"Message Types\");\nlet dbType = env.get(\"Database Type\");\nlet message = JSON.parse(JSON.stringify(msg.payload)); //HACK:in the future can change this to structuredClone\nlet callText = \"\";\nlet callFor = [];\nlet targetFound = false;\nlet otherTargetFound = false;\nmsg.callBy = msg.callBy ? msg.callBy : {};\n\ntarget = target.split(\",\")\ntarget.forEach((val,i,arr) => {\n arr[i] = val.trim();\n});\n\nfor(let i in target){\n if(message[target[i]] == true){\n targetFound = true;\n callText += target[i] + \", \";\n callFor.push(target[i]);\n delete message[target[i]];\n } \n} \n\ncallText = callText.slice(0,-2);\nmsg.callBy.type = callText;\nmsg.callBy.callFor = callFor;\n\nif (Object.keys(message) > 0) {\n message.forEach((val) => {\n if(val) {\n otherTargetFound = true;\n }\n })\n}\n\nif(dbType == 'list') {\n // if dataType is list, return msg whether empty or not, but if other\n // targets (other than the set targets) are found don't return msg\n if(!otherTargetFound) {\n return msg;\n }\n} else if(dbType == 'queue'){\n // if dataType is queue return msg only when targetFound. \n if(targetFound){\n return msg;\n }\n} \n \nreturn null;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 210,
"y": 80,
"wires": [
[
"da8bd97b81da3575"
]
],
"info": "This node does exactly what it says: \n\nRoute MQTT message according to caller\n\nif the message defined in the subflow corresponds to the ones in the MQTT message, then the subflow continues. \n\nthis router checks for two different scenarios according to call type:\n\n1) List\nwhen the call is a list type, then router not only allows the subflow to continue the defined messages are present within the MQTT message, but when the defined messages are absent as well - provided, that there are no other messages within the call (meaning it is a call for something else) - this is because list type calls are deactivated by an empty MQTT message. \n\n2) Queue\nWhen the call is a queue type, then router will only allow the subflow to continue when the defined messages are present within the MQTT message. this is because queue type calls are deactivated by clicking on the corresponding row in the queue.\n\nrouter also updates msg.caller.type to the corresponding values found within the MQTT message. this is for processing further down the subflow and the calling system\n"
},
{
"id": "da8bd97b81da3575",
"type": "function",
"z": "5958c5854f8ba7cd",
"name": "Process MQTT Topic",
"func": "let callName = env.get(\"Function Topic\");\nlet topic = msg.topic.split(\"/\"+callName+\"/\");\nlet callBy = {\n \"plant\" : topic[0],\n \"id\" : topic[1],\n \"timestamp\": Date.now()\n}\ntopic = callBy.id.split(\"/\");\n\nfor (let word of topic) {\n word = word.split(\"-\");\n callBy[word[0]] = word[1].toUpperCase();\n}\n\nObject.assign(msg.callBy, callBy);\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 440,
"y": 80,
"wires": [
[
"82f3836ced33bc01"
]
]
},
{
"id": "82f3836ced33bc01",
"type": "switch",
"z": "5958c5854f8ba7cd",
"name": "List or Queue?",
"property": "Database Type",
"propertyType": "env",
"rules": [
{
"t": "eq",
"v": "list",
"vt": "str"
},
{
"t": "eq",
"v": "queue",
"vt": "str"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 660,
"y": 80,
"wires": [
[
"0a6feae435792b59"
],
[
"2d346ea6aca78b20"
]
]
},
{
"id": "0a6feae435792b59",
"type": "function",
"z": "5958c5854f8ba7cd",
"name": "Update List",
"func": "// caller is already prepared from previous nodes.\n// it will either have a list of call types, or be empty. \nlet list = \"$parent.\" + env.get(\"Database Name\");\nlet dbList = flow.get(list);\ndbList = dbList ? dbList : [];\nlet callBy = msg.callBy;\nmsg.saveData = {};\n// node.warn(dbList);\n\nif (callBy.type.length < 1){\n //if caller.type is empty, means call from caller is cleared\n //update msg.saveData\n msg.saveData = dbList.find((call) => { return call.id == callBy.id});\n msg.saveData.endTimeStamp = Date.now();\n //delete caller row in list\n dbList = dbList.filter((call) => { return call.id != callBy.id });\n flow.set(list, dbList);\n} else {\n //else if caller.type is not empty, means call from caller is a new call\n //if caller already exists in list, update that caller row\n //else add caller to list. \n let index = dbList.findIndex((call) => { return call.id == callBy.id });\n if (index > -1) {\n dbList[index] = callBy;\n } else { \n dbList.push(callBy);\n }\n flow.set(list, dbList);\n}\n\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 850,
"y": 60,
"wires": [
[]
]
},
{
"id": "2d346ea6aca78b20",
"type": "function",
"z": "5958c5854f8ba7cd",
"name": "Update Queue",
"func": "let queue = \"$parent.\"+env.get(\"Database Name\");\nlet dbQueue = flow.get(queue);\ndbQueue = dbQueue ? dbQueue : [];\nlet callBy = msg.callBy;\n\ndbQueue.push(callBy);\nflow.set(queue, dbQueue);\n\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 860,
"y": 100,
"wires": [
[]
]
},
{
"id": "60e11389bb8c4eeb",
"type": "change",
"z": "da1f44dea6948311",
"name": "transform timestamps",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload[].{ \t \"Plant\":plant,\t \"Department\":dept,\t \"Line\":line,\t \"Cell\":cell,\t \"Type\":type,\t \"Time\":$moment(timestamp).fromNow()\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 740,
"y": 120,
"wires": [
[
"130156beb9f78413"
]
]
},
{
"id": "d1149b483e78ed1d",
"type": "delay",
"z": "da1f44dea6948311",
"name": "Delay",
"pauseType": "delayv",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 470,
"y": 360,
"wires": [
[
"f032a993da54f785"
]