-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathc8y-alarms.html
142 lines (132 loc) · 4.57 KB
/
c8y-alarms.html
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
<script type="text/x-red" data-template-name="c8y-alarms">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name </label>
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
</div>
<div class="form-row">
<label for="node-input-cumulocityConfig"><i class="fa fa-user"></i> Cumulocity Config</label>
<input type="text" id="node-input-cumulocityConfig">
</div>
<div class="form-row">
<label for="node-input-deviceId"><i class="fa fa-barcode"></i> DeviceId </label>
<input type="text" id="node-input-deviceId" placeholder="(optional)">
</div>
<div class="form-row">
<label for="node-input-startDate"><i class="fa fa-calendar"></i> Start Date </label>
<input type="datetime-local" id="node-input-startDate" placeholder="(optional)">
</div>
<div class="form-row">
<label for="node-input-endDate"><i class="fa fa-calendar"></i> End Date </label>
<input type="datetime-local" id="node-input-endDate" placeholder="(optional)">
</div>
<div class="form-row">
<label for="node-input-severity"><i class="fa fa-exclamation-triangle"></i> Severity </label>
<select type="text" id="node-input-severity" style="width:70%;">
<option selected value="all">All</option>
<option value="critical">Critical</option>
<option value="major">Major</option>
<option value="minor">Minor</option>
<option value="warning">Warning</option>
</select> </div>
<div class="form-row">
<label for="node-input-alarmStatus"><i class="fa clipboard-check"></i> Status </label>
<select type="text" id="node-input-alarmStatus" style="width:70%;">
<option selected value="all">All</option>
<option value="active">Active</option>
<option value="acknowledged">Acknowledged</option>
<option value="cleared">Cleared</option>
</select>
</div>
<div class="form-row">
<label for="node-input-pageSize"><i class="fa fa-file-alt"></i> Page Size </label>
<input type="text" id="node-input-pageSize" placeholder="(optional)">
</div>
<div class="form-row">
<label for="node-input-ret"><i class="fa fa-arrow-left"></i><span> Return</span></label>
<select type="text" id="node-input-ret" style="width:70%;">
<option selected value="txt">UTF-8 string</option>
<option value="bin">Binary</option>
<option value="obj">a parsed JSON object</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="c8y-alarms">
<p>Get a list of alarms & their descriptions from a Cumulocity tenant</p>
<p>The tenant name must be configured in the node.</p>
<ul>
<li>Required inputs:
<ul>Cumulocity Configuration (add a new one or select from the list)</ul>
</li>
<li>Optional inputs (to filter results):
<ul>DeviceId (number) - filter by device</ul>
<ul>StartDate (ISO Date Format: YYYY-MM-DDTHH:MM:SSZ) - filter by date posted</ul>
<ul>EndDate (ISO Date Format: YYYY-MM-DDTHH:MM:SSZ) - filter by date posted</ul>
<ul>Severity (String) - filter by alarm severity (Critical, Major, Minor, or Warning)</ul>
<ul>Status (String) - filter by alarm status (Active, Acknowledged, or Cleared)</ul>
<ul>PageSize (number) - number of alarms to include per page. (Default: 25)</ul>
</li>
</ul>
<p>
The output message contains the following properties:
<ul>
<li><code>payload</code> is an array of all alarms</li>
<li><code>statusCode</code> is the status code of the response, or the error code if the request could not be completed</li>
<li><code>headers</code> is an object containing the response headers</li>
</ul>
</p>
<p>More information about the Cumulocity API can be found <a href="http://cumulocity.com/guides/reference/alarms/">here </a>.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('c8y-alarms', {
category: 'cumulocity',
color: "rgb(106, 210, 252)",
defaults: {
name: {
value: ""
},
ret: {
value: "txt"
},
cumulocityConfig: {
type: "c8y-config",
required: true
},
deviceId: {
value: ""
},
startDate: {
value: ""
},
endDate: {
value: ""
},
severity: {
value: "all"
},
alarmStatus: {
value: "all"
},
pageSize: {
value: "25"
}
},
inputs: 1,
outputs: 1,
icon: "cumulocity-logo.png",
label: function() {
return this.name || "c8y Alarms";
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
$("#node-input-ret").change(function() {
if ($("#node-input-ret").val() === "obj") {
$("#tip-json").show();
} else {
$("#tip-json").hide();
}
});
}
});
</script>