prepared function selection
This commit is contained in:
@@ -44,7 +44,6 @@ const nodeInit: NodeInitializer = (RED): void => {
|
|||||||
if (client != null){
|
if (client != null){
|
||||||
await client.reconnect(-1, 1000)
|
await client.reconnect(-1, 1000)
|
||||||
}else{
|
}else{
|
||||||
// TODO: Emit error
|
|
||||||
this.emit("error")
|
this.emit("error")
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
13
src/nodes/ts3-get/handleGet.ts
Normal file
13
src/nodes/ts3-get/handleGet.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { NodeMessageInFlow } from "node-red";
|
||||||
|
import { TeamSpeak } from "ts3-nodejs-library";
|
||||||
|
import { GetFunctions } from "./types";
|
||||||
|
|
||||||
|
export default async function handleGet(func: GetFunctions, client: TeamSpeak, options: any): Promise<any>{
|
||||||
|
switch (func) {
|
||||||
|
case GetFunctions.CLIENTS_LIST:
|
||||||
|
return client.clientList(options)
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
category: 'function',
|
category: 'function',
|
||||||
color: '#a6bbcf',
|
color: '#a6bbcf',
|
||||||
defaults: {
|
defaults: {
|
||||||
configid: {type:"ts3-config"}
|
configid: {type:"ts3-config"},
|
||||||
|
selection: {default: ""}
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
@@ -18,6 +19,12 @@
|
|||||||
<label for="node-input-configid"><i class="fa fa-database"></i> Connection</label>
|
<label for="node-input-configid"><i class="fa fa-database"></i> Connection</label>
|
||||||
<input type="text" id="node-input-configid">
|
<input type="text" id="node-input-configid">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-configid"><i class="fa fa-database"></i> Connection</label>
|
||||||
|
<select class="form-select" id="node-input-selection">
|
||||||
|
<option selected>Open this select menu</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="ts3-get">
|
<script type="text/html" data-help-name="ts3-get">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { NodeInitializer } from "node-red";
|
import { NodeInitializer } from "node-red";
|
||||||
import { Ts3ConfigNode } from "../ts3-config/types";
|
import { Ts3ConfigNode } from "../ts3-config/types";
|
||||||
import { Ts3GetConfig, Ts3GetNode } from "./types";
|
import handleGet from "./handleGet";
|
||||||
|
import { GetFunctions, Ts3GetConfig, Ts3GetNode } from "./types";
|
||||||
|
|
||||||
const nodeInit: NodeInitializer = (RED): void => {
|
const nodeInit: NodeInitializer = (RED): void => {
|
||||||
function Ts3Get(
|
function Ts3Get(
|
||||||
@@ -27,9 +28,9 @@ const nodeInit: NodeInitializer = (RED): void => {
|
|||||||
this.on("input", async (msg,send,done) => {
|
this.on("input", async (msg,send,done) => {
|
||||||
const client = await ts3Config.getConnection()
|
const client = await ts3Config.getConnection()
|
||||||
|
|
||||||
let clients = await client.clientList({ clientType: 0 })
|
let payload = await handleGet(GetFunctions.CLIENTS_LIST,client,msg.payload)
|
||||||
|
|
||||||
msg.payload = clients
|
msg.payload = payload
|
||||||
|
|
||||||
send(msg)
|
send(msg)
|
||||||
done()
|
done()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Ts3ConfigNode } from "../ts3-config/types";
|
|||||||
|
|
||||||
export interface Ts3GetProps {
|
export interface Ts3GetProps {
|
||||||
configid: string
|
configid: string
|
||||||
|
selection: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Ts3GetData {
|
export interface Ts3GetData {
|
||||||
@@ -11,3 +12,7 @@ export interface Ts3GetData {
|
|||||||
export interface Ts3GetConfig extends NodeDef, Ts3GetProps { }
|
export interface Ts3GetConfig extends NodeDef, Ts3GetProps { }
|
||||||
|
|
||||||
export interface Ts3GetNode extends Node, Ts3GetData {}
|
export interface Ts3GetNode extends Node, Ts3GetData {}
|
||||||
|
|
||||||
|
export enum GetFunctions {
|
||||||
|
CLIENTS_LIST,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user