ts3 config get
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-lower-case-credsID"><i class="fa fa-database"></i> Creds</label>
|
||||
<label for="node-input-credsID"><i class="fa fa-database"></i> Creds</label>
|
||||
<input type="text" id="node-input-credsID">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
40
src/nodes/ts3-config/ts3-config.html
Normal file
40
src/nodes/ts3-config/ts3-config.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('ts3-config',{
|
||||
category: 'config',
|
||||
color: '#a6bbcf',
|
||||
defaults: {
|
||||
host: { value: ""},
|
||||
nickname: {value: "ServerQuery"}
|
||||
},
|
||||
credentials: {
|
||||
username: {type: "text"},
|
||||
password: {type: "password"}
|
||||
},
|
||||
label: function() {
|
||||
return this.name || "Ts3 Config";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-template-name="ts3-config">
|
||||
<div class="form-row">
|
||||
<label for="node-input-host"><i class="fa fa-globe"></i>Hostname</label>
|
||||
<input type="text" id="node-config-input-host">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-nickname"><i class="fa fa-comment"></i>Nickname</label>
|
||||
<input type="text" id="node-config-input-nickname">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-username"><i class="fa fa-user"></i>Username</label>
|
||||
<input type="text" id="node-config-input-username">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-password"><i class="fa fa-key"></i>Password</label>
|
||||
<input type="password" id="node-config-input-password">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="ts3-config">
|
||||
<p>Connection config for a Teamspeak 3 server.</p>
|
||||
</script>
|
||||
24
src/nodes/ts3-config/ts3-config.ts
Normal file
24
src/nodes/ts3-config/ts3-config.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { NodeDef, NodeInitializer, Node } from "node-red";
|
||||
import { Ts3ConfigConfig, Ts3ConfigNode } from "./types";
|
||||
|
||||
const nodeInit: NodeInitializer = (RED): void => {
|
||||
function Ts3Config(
|
||||
this: Ts3ConfigNode,
|
||||
config: Ts3ConfigConfig
|
||||
): void {
|
||||
RED.nodes.createNode(this, config);
|
||||
this.host = config.host
|
||||
this.nickname = config.nickname
|
||||
|
||||
// TODO connect ts3 query here
|
||||
}
|
||||
|
||||
RED.nodes.registerType("ts3-config", Ts3Config,{
|
||||
credentials: {
|
||||
username: {type: "text"},
|
||||
password: {type: "password"}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export = nodeInit;
|
||||
15
src/nodes/ts3-config/types.ts
Normal file
15
src/nodes/ts3-config/types.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { NodeDef, Node } from "node-red";
|
||||
|
||||
export interface Ts3ConfigProps{
|
||||
host: string,
|
||||
nickname: string
|
||||
}
|
||||
|
||||
export interface Ts3ConfigCreds {
|
||||
username: string,
|
||||
password: string
|
||||
}
|
||||
|
||||
export interface Ts3ConfigConfig extends NodeDef, Ts3ConfigProps, Ts3ConfigCreds { }
|
||||
|
||||
export interface Ts3ConfigNode extends Node<Ts3ConfigCreds>, Ts3ConfigProps {}
|
||||
25
src/nodes/ts3-get/ts3-get.html
Normal file
25
src/nodes/ts3-get/ts3-get.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('ts3-get',{
|
||||
category: 'function',
|
||||
color: '#a6bbcf',
|
||||
defaults: {
|
||||
configid: {type:"ts3-config"}
|
||||
},
|
||||
inputs: 1,
|
||||
outputs: 1,
|
||||
label: function() {
|
||||
return this.name || "Ts3 Get";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-template-name="ts3-get">
|
||||
<div class="form-row">
|
||||
<label for="node-input-configid"><i class="fa fa-database"></i> Connection</label>
|
||||
<input type="text" id="node-input-configid">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="ts3-get">
|
||||
<p>Get information from a Teamspeak 3 server.</p>
|
||||
</script>
|
||||
23
src/nodes/ts3-get/ts3-get.ts
Normal file
23
src/nodes/ts3-get/ts3-get.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NodeInitializer } from "node-red";
|
||||
import { Ts3ConfigNode } from "../ts3-config/types";
|
||||
import { Ts3GetConfig, Ts3GetNode } from "./types";
|
||||
|
||||
const nodeInit: NodeInitializer = (RED): void => {
|
||||
function Ts3Get(
|
||||
this: Ts3GetNode,
|
||||
config: Ts3GetConfig
|
||||
): void {
|
||||
RED.nodes.createNode(this, config);
|
||||
this.warn(config.configid)
|
||||
this.ts3Config = RED.nodes.getNode(config.configid) as Ts3ConfigNode
|
||||
|
||||
this.on("input", (msg) => {
|
||||
msg.payload = this.ts3Config.credentials.username
|
||||
this.send(msg)
|
||||
})
|
||||
}
|
||||
|
||||
RED.nodes.registerType("ts3-get", Ts3Get);
|
||||
};
|
||||
|
||||
export = nodeInit;
|
||||
14
src/nodes/ts3-get/types.ts
Normal file
14
src/nodes/ts3-get/types.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { NodeDef, Node } from "node-red";
|
||||
import { Ts3ConfigNode } from "../ts3-config/types";
|
||||
|
||||
export interface Ts3GetProps {
|
||||
configid: string
|
||||
}
|
||||
|
||||
export interface Ts3GetData {
|
||||
ts3Config: Ts3ConfigNode
|
||||
}
|
||||
|
||||
export interface Ts3GetConfig extends NodeDef, Ts3GetProps { }
|
||||
|
||||
export interface Ts3GetNode extends Node, Ts3GetData {}
|
||||
Reference in New Issue
Block a user