forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodered_nodes.ts
More file actions
38 lines (36 loc) · 1.24 KB
/
Copy pathnodered_nodes.ts
File metadata and controls
38 lines (36 loc) · 1.24 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
import * as RED from "node-red";
import { Red } from "node-red";
import { NoderedUtil } from "@openiap/openflow-api";
export interface Iget_pods {
name: string;
targetid: string;
}
export class get_pods {
public node: Red = null;
public name: string;
constructor(public config: Iget_pods) {
RED.nodes.createNode(this, config);
this.node = this;
this.node.status({});
this.name = config.name;
this.node.on("input", this.oninput);
this.node.on("close", this.onclose);
}
async oninput(msg: any) {
try {
this.node.status({});
const targetid = (!NoderedUtil.IsNullUndefinded(msg.targetid) ? msg.targetid : this.config.targetid);
let priority: number = 1;
if (!NoderedUtil.IsNullEmpty(msg.priority)) { priority = msg.priority; }
this.node.status({ fill: "blue", shape: "dot", text: "Getting pods" });
const result = await NoderedUtil.GetNoderedInstance({ _id: targetid, jwt: msg.jwt, priority });
msg.payload = result;
this.node.send(msg);
this.node.status({});
} catch (error) {
NoderedUtil.HandleError(this, error, msg);
}
}
onclose() {
}
}