forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodered.html
More file actions
73 lines (71 loc) · 2.82 KB
/
Copy pathnodered.html
File metadata and controls
73 lines (71 loc) · 2.82 KB
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
<script type="text/x-red" data-template-name="nodered get pods">
<div class="form-row">
<label for="node-input-targetid-search"><i class="fa fa-tasks"></i> Search</label>
<input type="text" id="node-input-targetid-search" placeholder="Search" >
</div>
<div class="form-row">
<label for="node-input-targetid"><i class="fa fa-tasks"></i> Target</label>
<select id="node-input-targetid-select">
<option>Loading...</option>
</select>
<input id="node-input-targetid" type="hidden">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="nodered get pods">
<p>Grab all nodered pods for current user.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('nodered get pods', {
category: 'api',
color: "#DEB887",
paletteLabel: 'get',
icon: "font-awesome/fa-database",
defaults: {
name: { value: "" },
targetid: { value: "result._id" },
},
inputs: 1,
outputs: 1,
label: function () {
return this.name || "get pods";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
const reloadUsers = function (firstrun) {
$('#node-input-targetid-select').empty();
$('#node-input-targetid-select').append($('<option>', {
value: -1,
text: "Loading..."
}));
$('#node-input-targetid-select').val(-1);
$.getJSON('api_users', { name: $('#node-input-targetid-search').val() }, function (data) {
$('#node-input-targetid-select').empty();
$.each(data, function (i, ele) {
$('#node-input-targetid-select').append($('<option>', {
value: ele._id,
text: ele.name
}));
});
$('#node-input-targetid-select').val($('#node-input-targetid').val());
}).error(function (jqXHR, textStatus, errorThrown) {
console.error("error " + textStatus);
console.error("incoming Text " + jqXHR.responseText);
alert("error:" + jqXHR.responseText);
});
}
$('#node-input-targetid-search').change(() => {
reloadUsers(false);
})
reloadUsers(true);
},
oneditsave: function () {
$('#node-input-targetid').val($('#node-input-targetid-select').val());
}
});
</script>