node-red-contrib-unifi-ultimate 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/nodes/readme-assets/youtube-icon.svg +5 -0
- package/nodes/unifi-access-config.html +18 -40
- package/nodes/unifi-access-device.html +33 -18
- package/nodes/unifi-network-config.html +21 -38
- package/nodes/unifi-network-control-poe.html +98 -41
- package/nodes/unifi-network-device.html +33 -20
- package/nodes/unifi-network-presence.html +22 -19
- package/nodes/unifi-protect-config.html +18 -38
- package/nodes/unifi-protect-device.html +33 -18
- package/nodes/utils/http-response-utils.js +61 -0
- package/nodes/utils/unifi-access-utils.js +1 -23
- package/nodes/utils/unifi-network-utils.js +1 -23
- package/nodes/utils/unifi-protect-utils.js +1 -23
- package/package.json +2 -2
- package/resources/editor/unifi-ultimate-editor-common.css +50 -37
- package/resources/logos/youtube-icon.svg +5 -0
package/README.md
CHANGED
|
@@ -20,6 +20,11 @@ Control and monitor `UniFi Network`, `UniFi Protect`, and `UniFi Access` from No
|
|
|
20
20
|
|
|
21
21
|
[View Changelog](CHANGELOG.md)
|
|
22
22
|
|
|
23
|
+
<a href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ">
|
|
24
|
+
<img src="resources/logos/youtube-icon.svg" alt="YouTube" width="24" height="18" align="absmiddle">
|
|
25
|
+
Watch news and tutorials on YouTube
|
|
26
|
+
</a>
|
|
27
|
+
|
|
23
28
|
## Install
|
|
24
29
|
|
|
25
30
|
In Node-RED:
|
|
@@ -310,4 +315,4 @@ Import from `examples/`:
|
|
|
310
315
|
[license-image]: https://img.shields.io/badge/license-MIT-green.svg
|
|
311
316
|
[license-url]: https://opensource.org/licenses/MIT
|
|
312
317
|
[youtube-image]: https://img.shields.io/badge/YouTube-Subscribe-red?logo=youtube&logoColor=white
|
|
313
|
-
[youtube-url]: https://www.youtube.com
|
|
318
|
+
[youtube-url]: https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 20" role="img" aria-labelledby="title">
|
|
2
|
+
<title id="title">YouTube</title>
|
|
3
|
+
<path fill="#FF0000" d="M27.4 3.1c-.3-1.2-1.3-2.1-2.5-2.4C22.7.1 14 .1 14 .1S5.3.1 3.1.7C1.9 1 .9 1.9.6 3.1 0 5.3 0 10 0 10s0 4.7.6 6.9c.3 1.2 1.3 2.1 2.5 2.4 2.2.6 10.9.6 10.9.6s8.7 0 10.9-.6c1.2-.3 2.1-1.2 2.5-2.4.6-2.2.6-6.9.6-6.9s0-4.7-.6-6.9z"/>
|
|
4
|
+
<path fill="#FFFFFF" d="M11.2 14.2 18.5 10l-7.3-4.2v8.4z"/>
|
|
5
|
+
</svg>
|
|
@@ -16,36 +16,17 @@
|
|
|
16
16
|
},
|
|
17
17
|
oneditprepare: function () {
|
|
18
18
|
const $host = $("#node-config-input-host");
|
|
19
|
-
const $
|
|
19
|
+
const $apiToken = $("#node-config-input-apiToken");
|
|
20
|
+
const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
|
|
21
|
+
const $apiTokenRow = $apiToken.closest(".form-row");
|
|
22
|
+
const $securityRow = $rejectUnauthorized.closest(".form-row");
|
|
23
|
+
const $advancedRow = $("#node-config-row-advanced");
|
|
20
24
|
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.replace(/</g, "<")
|
|
27
|
-
.replace(/>/g, ">")
|
|
28
|
-
.replace(/"/g, """)
|
|
29
|
-
.replace(/'/g, "'");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function refreshConnectionHint() {
|
|
33
|
-
const host = String($host.val() || "").trim();
|
|
34
|
-
if (!host) {
|
|
35
|
-
$connectionHint.html("<strong>Enter your controller address</strong>The node uses the standard UniFi Access API connection automatically.");
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// UniFi Access defaults to port 12445. Show the fully resolved
|
|
40
|
-
// host in the preview even when the user omitted the port.
|
|
41
|
-
const normalizedHost = host.replace(/^https?:\/\//i, "").replace(/\/+$/, "");
|
|
42
|
-
const hasPort = /:\d+$/.test(normalizedHost);
|
|
43
|
-
const previewHost = hasPort ? normalizedHost : normalizedHost + ":12445";
|
|
44
|
-
$connectionHint.html(
|
|
45
|
-
"<strong>Connection preview</strong>Will connect to <code>https://" +
|
|
46
|
-
escapeHtml(previewHost) +
|
|
47
|
-
"</code>"
|
|
48
|
-
);
|
|
25
|
+
function syncProgressiveRows() {
|
|
26
|
+
const hasHost = String($host.val() || "").trim() !== "";
|
|
27
|
+
$apiTokenRow.toggle(hasHost);
|
|
28
|
+
$securityRow.toggle(hasHost);
|
|
29
|
+
$advancedRow.toggle(hasHost);
|
|
49
30
|
}
|
|
50
31
|
|
|
51
32
|
try {
|
|
@@ -55,11 +36,10 @@
|
|
|
55
36
|
} catch (error) {
|
|
56
37
|
}
|
|
57
38
|
|
|
58
|
-
|
|
39
|
+
syncProgressiveRows();
|
|
59
40
|
|
|
60
41
|
$host.on("change input", function () {
|
|
61
|
-
|
|
62
|
-
refreshConnectionHint();
|
|
42
|
+
syncProgressiveRows();
|
|
63
43
|
});
|
|
64
44
|
}
|
|
65
45
|
});
|
|
@@ -70,12 +50,11 @@
|
|
|
70
50
|
<img class="unifi-ultimate-product-logo" src="resources/node-red-contrib-unifi-ultimate/logos/unifi-access-black.svg" alt="UniFi Access logo" onerror="this.closest('.unifi-ultimate-product-logo-row').style.display='none';">
|
|
71
51
|
</div>
|
|
72
52
|
<div class="form-row unifi-ultimate-hero">
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<span>
|
|
76
|
-
</
|
|
53
|
+
<a class="unifi-ultimate-youtube-link" href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer">
|
|
54
|
+
<img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18">
|
|
55
|
+
<span>Youtube Tutorials</span>
|
|
56
|
+
</a>
|
|
77
57
|
</div>
|
|
78
|
-
<div class="unifi-ultimate-section-title">Connection</div>
|
|
79
58
|
<div class="form-row">
|
|
80
59
|
<label for="node-config-input-host"><i class="fa fa-globe"></i> Controller</label>
|
|
81
60
|
<input type="text" id="node-config-input-host" placeholder="192.168.1.10 or access.local:12445">
|
|
@@ -89,9 +68,6 @@
|
|
|
89
68
|
<input type="checkbox" id="node-config-input-rejectUnauthorized" style="display:inline-block; width:auto; vertical-align:top;">
|
|
90
69
|
<span style="margin-left:8px;">Secure connection only</span>
|
|
91
70
|
</div>
|
|
92
|
-
<div class="form-row">
|
|
93
|
-
<div id="node-config-input-connectionHint" class="unifi-ultimate-card"></div>
|
|
94
|
-
</div>
|
|
95
71
|
<div id="node-config-row-advanced" class="unifi-ultimate-advanced">
|
|
96
72
|
<div class="form-row">
|
|
97
73
|
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
@@ -101,6 +77,8 @@
|
|
|
101
77
|
</script>
|
|
102
78
|
|
|
103
79
|
<script type="text/html" data-help-name="unifi-access-config">
|
|
80
|
+
<p><a href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer"><img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18" style="vertical-align:text-bottom; margin-right:6px;">Youtube Tutorials</a></p>
|
|
81
|
+
|
|
104
82
|
<p>Shared connection for UniFi Access nodes.</p>
|
|
105
83
|
|
|
106
84
|
<h3>Configuration</h3>
|
|
@@ -86,8 +86,10 @@
|
|
|
86
86
|
const $capabilityConfigRow = $("#node-row-capabilityConfig");
|
|
87
87
|
const $capabilityConfigContainer = $("#node-input-capabilityConfigContainer");
|
|
88
88
|
const $refresh = $("#node-input-refreshDevices");
|
|
89
|
-
const $
|
|
90
|
-
const $
|
|
89
|
+
const $deviceTypeRow = $deviceType.closest(".form-row");
|
|
90
|
+
const $deviceIdRow = $deviceId.closest(".form-row");
|
|
91
|
+
const $capabilityRow = $capability.closest(".form-row");
|
|
92
|
+
const $advancedRow = $("#node-row-advanced");
|
|
91
93
|
let capabilityConfig = parseCapabilityConfig(node.capabilityConfig);
|
|
92
94
|
let capabilityListRequestId = 0;
|
|
93
95
|
let capabilityOptionsRequestId = 0;
|
|
@@ -95,6 +97,26 @@
|
|
|
95
97
|
let isInitializingEditor = true;
|
|
96
98
|
let deviceTypeDefinitions = [];
|
|
97
99
|
let capabilityDefinitions = [];
|
|
100
|
+
|
|
101
|
+
function hasSelection($field) {
|
|
102
|
+
const value = String($field.val() || "").trim();
|
|
103
|
+
return value !== "" && value !== "_ADD_";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function syncProgressiveRows() {
|
|
107
|
+
const hasServer = hasSelection($server);
|
|
108
|
+
const hasDeviceType = hasSelection($deviceType);
|
|
109
|
+
const hasDevice = hasSelection($deviceId);
|
|
110
|
+
const hasCapability = hasSelection($capability);
|
|
111
|
+
const hasCapabilityFields = $capabilityConfigRow.data("has-fields") === true;
|
|
112
|
+
|
|
113
|
+
$deviceTypeRow.toggle(hasServer);
|
|
114
|
+
$deviceIdRow.toggle(hasServer && hasDeviceType);
|
|
115
|
+
$capabilityRow.toggle(hasServer && hasDeviceType && hasDevice);
|
|
116
|
+
$capabilityConfigRow.toggle(hasServer && hasDeviceType && hasDevice && hasCapability && hasCapabilityFields);
|
|
117
|
+
$advancedRow.toggle(hasServer && hasDeviceType && hasDevice && hasCapability);
|
|
118
|
+
}
|
|
119
|
+
|
|
98
120
|
function parseCapabilityConfig(rawValue) {
|
|
99
121
|
if (rawValue && typeof rawValue === "object" && !Array.isArray(rawValue)) {
|
|
100
122
|
return rawValue;
|
|
@@ -498,9 +520,7 @@
|
|
|
498
520
|
} else if (capabilityDefinition && capabilityDefinition.description) {
|
|
499
521
|
detail = capabilityDefinition.description;
|
|
500
522
|
}
|
|
501
|
-
|
|
502
|
-
$selectionSummary.text(summary);
|
|
503
|
-
$selectionDetail.text(detail);
|
|
523
|
+
syncProgressiveRows();
|
|
504
524
|
}
|
|
505
525
|
|
|
506
526
|
function syncNameFromSelection() {
|
|
@@ -664,6 +684,7 @@
|
|
|
664
684
|
$capabilityConfigContainer.empty();
|
|
665
685
|
|
|
666
686
|
if (fields.length === 0) {
|
|
687
|
+
$capabilityConfigRow.data("has-fields", false);
|
|
667
688
|
$capabilityConfigRow.hide();
|
|
668
689
|
if (renderOptions.clearStoredConfig) {
|
|
669
690
|
capabilityConfig = {};
|
|
@@ -679,6 +700,7 @@
|
|
|
679
700
|
writeCapabilityConfig();
|
|
680
701
|
}
|
|
681
702
|
|
|
703
|
+
$capabilityConfigRow.data("has-fields", true);
|
|
682
704
|
$capabilityConfigRow.show();
|
|
683
705
|
fields.forEach(function (field) {
|
|
684
706
|
const fieldId = "node-input-capability-config-" + field.id;
|
|
@@ -1027,17 +1049,15 @@
|
|
|
1027
1049
|
<img class="unifi-ultimate-product-logo" src="resources/node-red-contrib-unifi-ultimate/logos/unifi-access-black.svg" alt="UniFi Access logo" onerror="this.closest('.unifi-ultimate-product-logo-row').style.display='none';">
|
|
1028
1050
|
</div>
|
|
1029
1051
|
<div class="form-row unifi-ultimate-hero">
|
|
1030
|
-
<
|
|
1031
|
-
<
|
|
1032
|
-
<span>
|
|
1033
|
-
</
|
|
1052
|
+
<a class="unifi-ultimate-youtube-link" href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer">
|
|
1053
|
+
<img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18">
|
|
1054
|
+
<span>Youtube Tutorials</span>
|
|
1055
|
+
</a>
|
|
1034
1056
|
</div>
|
|
1035
|
-
<div class="unifi-ultimate-section-title">Connection</div>
|
|
1036
1057
|
<div class="form-row">
|
|
1037
1058
|
<label for="node-input-server"><i class="fa fa-cog"></i> Connection</label>
|
|
1038
1059
|
<input type="text" id="node-input-server">
|
|
1039
1060
|
</div>
|
|
1040
|
-
<div class="unifi-ultimate-section-title">Target</div>
|
|
1041
1061
|
<div class="form-row">
|
|
1042
1062
|
<label for="node-input-deviceType"><i class="fa fa-cubes"></i> Control</label>
|
|
1043
1063
|
<select id="node-input-deviceType"></select>
|
|
@@ -1049,17 +1069,10 @@
|
|
|
1049
1069
|
<i class="fa fa-refresh"></i>
|
|
1050
1070
|
</a>
|
|
1051
1071
|
</div>
|
|
1052
|
-
<div class="unifi-ultimate-section-title">Action</div>
|
|
1053
1072
|
<div class="form-row">
|
|
1054
1073
|
<label for="node-input-capability"><i class="fa fa-tasks"></i> Action</label>
|
|
1055
1074
|
<select id="node-input-capability"></select>
|
|
1056
1075
|
</div>
|
|
1057
|
-
<div class="form-row">
|
|
1058
|
-
<div class="unifi-ultimate-card">
|
|
1059
|
-
<strong id="node-input-selectionSummary">Choose a connection to begin.</strong>
|
|
1060
|
-
<div id="node-input-selectionDetail">The editor only shows actions supported by the selected UniFi Access device.</div>
|
|
1061
|
-
</div>
|
|
1062
|
-
</div>
|
|
1063
1076
|
<div class="form-row" id="node-row-capabilityConfig" style="display:none;">
|
|
1064
1077
|
<label><i class="fa fa-sliders"></i> Action options</label>
|
|
1065
1078
|
<div id="node-input-capabilityConfigContainer" style="width:70%; display:inline-block;"></div>
|
|
@@ -1079,6 +1092,8 @@
|
|
|
1079
1092
|
</script>
|
|
1080
1093
|
|
|
1081
1094
|
<script type="text/html" data-help-name="unifi-access-device">
|
|
1095
|
+
<p><a href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer"><img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18" style="vertical-align:text-bottom; margin-right:6px;">Youtube Tutorials</a></p>
|
|
1096
|
+
|
|
1082
1097
|
<p>Use this node to execute a configured UniFi Access action or listen for live Access events.</p>
|
|
1083
1098
|
|
|
1084
1099
|
<h3>Configuration</h3>
|
|
@@ -18,34 +18,20 @@
|
|
|
18
18
|
},
|
|
19
19
|
oneditprepare: function () {
|
|
20
20
|
const $host = $("#node-config-input-host");
|
|
21
|
-
const $
|
|
21
|
+
const $apiKey = $("#node-config-input-apiKey");
|
|
22
|
+
const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
|
|
23
|
+
const $powerObservationIntervalSeconds = $("#node-config-input-powerObservationIntervalSeconds");
|
|
24
|
+
const $apiKeyRow = $apiKey.closest(".form-row");
|
|
25
|
+
const $securityRow = $rejectUnauthorized.closest(".form-row");
|
|
26
|
+
const $powerObservationRow = $powerObservationIntervalSeconds.closest(".form-row");
|
|
27
|
+
const $advancedRow = $("#node-config-row-advanced");
|
|
22
28
|
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.replace(/>/g, ">")
|
|
30
|
-
.replace(/\"/g, """)
|
|
31
|
-
.replace(/'/g, "'");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function refreshConnectionHint() {
|
|
35
|
-
const host = String($host.val() || "").trim();
|
|
36
|
-
if (!host) {
|
|
37
|
-
$connectionHint.html("<strong>Enter your controller address</strong>The node builds the UniFi Network connection automatically.");
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// The runtime accepts either a bare host or a full URL, but the
|
|
42
|
-
// preview intentionally shows the normalized integration endpoint.
|
|
43
|
-
const normalizedHost = host.replace(/^https?:\/\//i, "").replace(/\/+$/, "");
|
|
44
|
-
$connectionHint.html(
|
|
45
|
-
"<strong>Connection preview</strong>Will connect to <code>https://" +
|
|
46
|
-
escapeHtml(normalizedHost) +
|
|
47
|
-
"/proxy/network/integration</code>"
|
|
48
|
-
);
|
|
29
|
+
function syncProgressiveRows() {
|
|
30
|
+
const hasHost = String($host.val() || "").trim() !== "";
|
|
31
|
+
$apiKeyRow.toggle(hasHost);
|
|
32
|
+
$securityRow.toggle(hasHost);
|
|
33
|
+
$powerObservationRow.toggle(hasHost);
|
|
34
|
+
$advancedRow.toggle(hasHost);
|
|
49
35
|
}
|
|
50
36
|
|
|
51
37
|
try {
|
|
@@ -55,10 +41,9 @@
|
|
|
55
41
|
} catch (error) {
|
|
56
42
|
}
|
|
57
43
|
|
|
58
|
-
|
|
44
|
+
syncProgressiveRows();
|
|
59
45
|
$host.on("change input", function () {
|
|
60
|
-
|
|
61
|
-
refreshConnectionHint();
|
|
46
|
+
syncProgressiveRows();
|
|
62
47
|
});
|
|
63
48
|
}
|
|
64
49
|
});
|
|
@@ -69,12 +54,11 @@
|
|
|
69
54
|
<img class="unifi-ultimate-product-logo" src="resources/node-red-contrib-unifi-ultimate/logos/unifi-network-black.svg" alt="UniFi Network logo" onerror="this.closest('.unifi-ultimate-product-logo-row').style.display='none';">
|
|
70
55
|
</div>
|
|
71
56
|
<div class="form-row unifi-ultimate-hero">
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
<span>
|
|
75
|
-
</
|
|
57
|
+
<a class="unifi-ultimate-youtube-link" href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer">
|
|
58
|
+
<img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18">
|
|
59
|
+
<span>Youtube Tutorials</span>
|
|
60
|
+
</a>
|
|
76
61
|
</div>
|
|
77
|
-
<div class="unifi-ultimate-section-title">Connection</div>
|
|
78
62
|
<div class="form-row">
|
|
79
63
|
<label for="node-config-input-host"><i class="fa fa-globe"></i> Controller</label>
|
|
80
64
|
<input type="text" id="node-config-input-host" placeholder="192.168.1.10">
|
|
@@ -92,9 +76,6 @@
|
|
|
92
76
|
<label for="node-config-input-powerObservationIntervalSeconds"><i class="fa fa-repeat"></i> Power Poll (s)</label>
|
|
93
77
|
<input type="text" id="node-config-input-powerObservationIntervalSeconds" placeholder="15">
|
|
94
78
|
</div>
|
|
95
|
-
<div class="form-row">
|
|
96
|
-
<div id="node-config-input-connectionHint" class="unifi-ultimate-card"></div>
|
|
97
|
-
</div>
|
|
98
79
|
<div id="node-config-row-advanced" class="unifi-ultimate-advanced">
|
|
99
80
|
<div class="form-row">
|
|
100
81
|
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
@@ -104,6 +85,8 @@
|
|
|
104
85
|
</script>
|
|
105
86
|
|
|
106
87
|
<script type="text/html" data-help-name="unifi-network-config">
|
|
88
|
+
<p><a href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer"><img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18" style="vertical-align:text-bottom; margin-right:6px;">Youtube Tutorials</a></p>
|
|
89
|
+
|
|
107
90
|
<p>Shared connection for UniFi Network nodes.</p>
|
|
108
91
|
|
|
109
92
|
<h3>Configuration</h3>
|
|
@@ -61,14 +61,68 @@
|
|
|
61
61
|
const $rowSwitch = $("#node-row-deviceId");
|
|
62
62
|
const $rowClient = $("#node-row-clientLookupId");
|
|
63
63
|
const $rowPort = $("#node-row-portIdx");
|
|
64
|
-
const $
|
|
65
|
-
const $
|
|
64
|
+
const $selectionModeRow = $selectionMode.closest(".form-row");
|
|
65
|
+
const $actionRow = $action.closest(".form-row");
|
|
66
|
+
const $warningRow = $(".unifi-ultimate-warning").closest(".form-row");
|
|
67
|
+
const $advancedRow = $("#node-row-advanced");
|
|
66
68
|
let suspendChangeHandling = false;
|
|
67
69
|
let isInitializingEditor = true;
|
|
68
70
|
let clientTargetsPopulated = false;
|
|
69
71
|
let clientTargetsLoading = false;
|
|
70
72
|
let clientsLoadedForServerId = "";
|
|
71
73
|
let clientsRequestPromise = null;
|
|
74
|
+
let clientWaitOverlayDepth = 0;
|
|
75
|
+
|
|
76
|
+
function hasSelection($field) {
|
|
77
|
+
const value = String($field.val() || "").trim();
|
|
78
|
+
return value !== "" && value !== "_ADD_";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function syncProgressiveRows() {
|
|
82
|
+
const hasServer = hasSelection($server);
|
|
83
|
+
const mode = getSelectionMode();
|
|
84
|
+
const hasSwitch = hasSelection($deviceId);
|
|
85
|
+
const hasPort = hasSelection($portIdx);
|
|
86
|
+
const hasClient = hasSelection($clientLookupId);
|
|
87
|
+
const hasTarget = mode === "client" ? hasClient : (hasSwitch && hasPort);
|
|
88
|
+
const hasAction = hasSelection($action);
|
|
89
|
+
|
|
90
|
+
$selectionModeRow.toggle(hasServer);
|
|
91
|
+
$rowSwitch.toggle(hasServer && mode === "switchPort");
|
|
92
|
+
$rowPort.toggle(hasServer && mode === "switchPort" && hasSwitch);
|
|
93
|
+
$rowClient.toggle(hasServer && mode === "client");
|
|
94
|
+
$actionRow.toggle(hasServer && hasTarget);
|
|
95
|
+
$warningRow.toggle(hasServer && hasTarget && hasAction);
|
|
96
|
+
$advancedRow.toggle(hasServer && hasTarget && hasAction);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function setClientWaitOverlay(visible, message) {
|
|
100
|
+
const $overlay = $("#node-input-clientWaitOverlay");
|
|
101
|
+
const $message = $("#node-input-clientWaitMessage");
|
|
102
|
+
if ($overlay.length === 0) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (message) {
|
|
107
|
+
$message.text(message);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
$overlay.css("display", visible === true ? "flex" : "none");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function withClientWait(message, work) {
|
|
114
|
+
clientWaitOverlayDepth += 1;
|
|
115
|
+
setClientWaitOverlay(true, message || "Loading client target...");
|
|
116
|
+
|
|
117
|
+
return Promise.resolve()
|
|
118
|
+
.then(work)
|
|
119
|
+
.finally(function () {
|
|
120
|
+
clientWaitOverlayDepth = Math.max(0, clientWaitOverlayDepth - 1);
|
|
121
|
+
if (clientWaitOverlayDepth === 0) {
|
|
122
|
+
setClientWaitOverlay(false);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
72
126
|
|
|
73
127
|
function getSelectedActionValue() {
|
|
74
128
|
return String($action.val() || node.action || "msgPayload").trim().toLowerCase();
|
|
@@ -392,16 +446,7 @@
|
|
|
392
446
|
}
|
|
393
447
|
|
|
394
448
|
function refreshSelectionModeUi() {
|
|
395
|
-
|
|
396
|
-
if (mode === "client") {
|
|
397
|
-
$rowClient.show();
|
|
398
|
-
$rowSwitch.hide();
|
|
399
|
-
$rowPort.hide();
|
|
400
|
-
} else {
|
|
401
|
-
$rowClient.hide();
|
|
402
|
-
$rowSwitch.show();
|
|
403
|
-
$rowPort.show();
|
|
404
|
-
}
|
|
449
|
+
syncProgressiveRows();
|
|
405
450
|
updateDerivedTargetFieldsState();
|
|
406
451
|
}
|
|
407
452
|
|
|
@@ -410,7 +455,9 @@
|
|
|
410
455
|
if (getSelectionMode() !== "client" || clientTargetsLoading) {
|
|
411
456
|
return;
|
|
412
457
|
}
|
|
413
|
-
|
|
458
|
+
withClientWait("Loading client targets...", function () {
|
|
459
|
+
return loadClients({ showLoading: false });
|
|
460
|
+
});
|
|
414
461
|
}
|
|
415
462
|
|
|
416
463
|
$clientLookupId
|
|
@@ -465,9 +512,7 @@
|
|
|
465
512
|
if (selectedActionUsesPayloadControl()) {
|
|
466
513
|
detail = "Send msg.payload=true to enable PoE, or msg.payload=false to disable PoE.";
|
|
467
514
|
}
|
|
468
|
-
|
|
469
|
-
$selectionSummary.text(summary);
|
|
470
|
-
$selectionDetail.text(detail);
|
|
515
|
+
syncProgressiveRows();
|
|
471
516
|
}
|
|
472
517
|
|
|
473
518
|
function refreshActionUi() {
|
|
@@ -692,8 +737,6 @@
|
|
|
692
737
|
.prop("disabled", true);
|
|
693
738
|
bindLazyClientLookupLoad();
|
|
694
739
|
updateDerivedTargetFieldsState();
|
|
695
|
-
$selectionSummary.text("Loading client targets...");
|
|
696
|
-
$selectionDetail.text("Please wait while UniFi returns clients and switch-port attachments.");
|
|
697
740
|
}
|
|
698
741
|
|
|
699
742
|
function hasOptionValue($select, value) {
|
|
@@ -882,10 +925,19 @@
|
|
|
882
925
|
return;
|
|
883
926
|
}
|
|
884
927
|
clientsLoadedForServerId = "";
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
928
|
+
if (getSelectionMode() === "client") {
|
|
929
|
+
withClientWait("Loading client targets...", function () {
|
|
930
|
+
return loadEditorData({
|
|
931
|
+
loadClients: true,
|
|
932
|
+
forceClients: true
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
} else {
|
|
936
|
+
loadEditorData({
|
|
937
|
+
loadClients: false,
|
|
938
|
+
forceClients: true
|
|
939
|
+
});
|
|
940
|
+
}
|
|
889
941
|
});
|
|
890
942
|
|
|
891
943
|
$deviceId.on("change", function () {
|
|
@@ -913,8 +965,10 @@
|
|
|
913
965
|
refreshSelectionModeUi();
|
|
914
966
|
rememberSelectedTargetName();
|
|
915
967
|
if (getSelectionMode() === "client") {
|
|
916
|
-
|
|
917
|
-
return
|
|
968
|
+
withClientWait("Loading client targets...", function () {
|
|
969
|
+
return loadClients({ showLoading: false }).then(function () {
|
|
970
|
+
return applySelectedClientTarget();
|
|
971
|
+
});
|
|
918
972
|
});
|
|
919
973
|
} else {
|
|
920
974
|
refreshSummary();
|
|
@@ -928,7 +982,9 @@
|
|
|
928
982
|
const isUserSelection = $clientLookupId.data("unifi-user-selection") === true;
|
|
929
983
|
$clientLookupId.removeData("unifi-user-selection");
|
|
930
984
|
if (getSelectionMode() === "client") {
|
|
931
|
-
|
|
985
|
+
withClientWait("Resolving client switch and port...", function () {
|
|
986
|
+
return applySelectedClientTarget({ syncName: isUserSelection });
|
|
987
|
+
});
|
|
932
988
|
} else {
|
|
933
989
|
refreshSummary();
|
|
934
990
|
}
|
|
@@ -944,10 +1000,12 @@
|
|
|
944
1000
|
});
|
|
945
1001
|
$refreshClients.on("click", function (event) {
|
|
946
1002
|
event.preventDefault();
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1003
|
+
withClientWait("Loading client targets...", function () {
|
|
1004
|
+
return loadClients({ force: true }).then(function () {
|
|
1005
|
+
if (getSelectionMode() === "client") {
|
|
1006
|
+
return applySelectedClientTarget();
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
951
1009
|
});
|
|
952
1010
|
});
|
|
953
1011
|
|
|
@@ -976,17 +1034,21 @@
|
|
|
976
1034
|
<img class="unifi-ultimate-product-logo" src="resources/node-red-contrib-unifi-ultimate/logos/unifi-network-black.svg" alt="UniFi Network logo" onerror="this.closest('.unifi-ultimate-product-logo-row').style.display='none';">
|
|
977
1035
|
</div>
|
|
978
1036
|
<div class="form-row unifi-ultimate-hero">
|
|
979
|
-
<
|
|
980
|
-
<
|
|
981
|
-
<span>
|
|
1037
|
+
<a class="unifi-ultimate-youtube-link" href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer">
|
|
1038
|
+
<img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18">
|
|
1039
|
+
<span>Youtube Tutorials</span>
|
|
1040
|
+
</a>
|
|
1041
|
+
</div>
|
|
1042
|
+
<div id="node-input-clientWaitOverlay" class="unifi-ultimate-wait-overlay" style="display:none;">
|
|
1043
|
+
<div class="unifi-ultimate-wait-dialog">
|
|
1044
|
+
<div class="unifi-ultimate-wait-spinner"></div>
|
|
1045
|
+
<div id="node-input-clientWaitMessage">Loading client target...</div>
|
|
982
1046
|
</div>
|
|
983
1047
|
</div>
|
|
984
|
-
<div class="unifi-ultimate-section-title">Connection</div>
|
|
985
1048
|
<div class="form-row">
|
|
986
1049
|
<label for="node-input-server"><i class="fa fa-cog"></i> Connection</label>
|
|
987
1050
|
<input type="text" id="node-input-server">
|
|
988
1051
|
</div>
|
|
989
|
-
<div class="unifi-ultimate-section-title">Target</div>
|
|
990
1052
|
<div class="form-row">
|
|
991
1053
|
<label for="node-input-selectionMode"><i class="fa fa-crosshairs"></i> Search by</label>
|
|
992
1054
|
<select id="node-input-selectionMode">
|
|
@@ -1012,7 +1074,6 @@
|
|
|
1012
1074
|
<label for="node-input-portIdx"><i class="fa fa-plug"></i> Port</label>
|
|
1013
1075
|
<select id="node-input-portIdx"></select>
|
|
1014
1076
|
</div>
|
|
1015
|
-
<div class="unifi-ultimate-section-title">Action</div>
|
|
1016
1077
|
<div class="form-row">
|
|
1017
1078
|
<label for="node-input-action"><i class="fa fa-power-off"></i> Action</label>
|
|
1018
1079
|
<select id="node-input-action">
|
|
@@ -1023,12 +1084,6 @@
|
|
|
1023
1084
|
<option value="emitPowerConsumption">Emit Power Consumption</option>
|
|
1024
1085
|
</select>
|
|
1025
1086
|
</div>
|
|
1026
|
-
<div class="form-row">
|
|
1027
|
-
<div class="unifi-ultimate-card">
|
|
1028
|
-
<strong id="node-input-selectionSummary">Choose a switch and a port.</strong>
|
|
1029
|
-
<div id="node-input-selectionDetail">This node sends a port action request to UniFi Network.</div>
|
|
1030
|
-
</div>
|
|
1031
|
-
</div>
|
|
1032
1087
|
<div class="form-row">
|
|
1033
1088
|
<div class="unifi-ultimate-card unifi-ultimate-warning">
|
|
1034
1089
|
<strong>Power actions can disconnect devices.</strong>
|
|
@@ -1049,6 +1104,8 @@
|
|
|
1049
1104
|
</script>
|
|
1050
1105
|
|
|
1051
1106
|
<script type="text/html" data-help-name="unifi-network-control-poe">
|
|
1107
|
+
<p><a href="https://www.youtube.com/watch?v=ZOq7M5mgUBk&list=PL9Yh1bjbLAYrWKtMlopN0swuQXbdJ8MFJ" target="_blank" rel="noopener noreferrer"><img src="resources/node-red-contrib-unifi-ultimate/logos/youtube-icon.svg" alt="YouTube" width="24" height="18" style="vertical-align:text-bottom; margin-right:6px;">Youtube Tutorials</a></p>
|
|
1108
|
+
|
|
1052
1109
|
<p>Controls PoE on a selected UniFi switch port.</p>
|
|
1053
1110
|
|
|
1054
1111
|
<h3>Configuration</h3>
|