Compare commits
4 Commits
a110d00a0f
...
1135dc91cc
| Author | SHA1 | Date | |
|---|---|---|---|
| 1135dc91cc | |||
| 6d0937813b | |||
| 288927e74c | |||
| 8b86e8ea40 |
35
build/build.js
Normal file
35
build/build.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
const fs = require("fs")
|
||||||
|
const Mustache = require('mustache');
|
||||||
|
|
||||||
|
// Load template
|
||||||
|
const htmlTemplate = fs.readFileSync("build/template/editor.html.mustache").toString()
|
||||||
|
|
||||||
|
const nodes = fs.readdirSync("src/nodes")
|
||||||
|
|
||||||
|
nodes.forEach((e)=>{
|
||||||
|
// Load html parts
|
||||||
|
const helpHtml = fs.readFileSync(`src/nodes/${e}/ui/editor.html`)
|
||||||
|
const editorHtml = fs.readFileSync(`src/nodes/${e}/ui/editor.html`)
|
||||||
|
|
||||||
|
// Load complied editor index js/ts
|
||||||
|
let indexHtml = fs.readFileSync(`dist/nodes/${e}/ui/index.js`).toString()
|
||||||
|
// Cut first 2 lines because typescript inserts some stuff that the browser does not like
|
||||||
|
// TODO: is is ugly but it works
|
||||||
|
const tmp = indexHtml.split("\n")
|
||||||
|
tmp.splice(0,2)
|
||||||
|
indexHtml = tmp.join("\n")
|
||||||
|
|
||||||
|
// Prepare view object to be injected into render
|
||||||
|
const view = {
|
||||||
|
helpHtml,
|
||||||
|
editorHtml,
|
||||||
|
indexHtml,
|
||||||
|
nodeName: e
|
||||||
|
}
|
||||||
|
|
||||||
|
const html = Mustache.render(htmlTemplate, view);
|
||||||
|
|
||||||
|
// Write generated html into dist
|
||||||
|
fs.writeFileSync(`dist/nodes/${e}/${e}.html`,html)
|
||||||
|
})
|
||||||
|
|
||||||
11
build/template/editor.html.mustache
Normal file
11
build/template/editor.html.mustache
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
{{{indexHtml}}}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" data-template-name="{{nodeName}}">
|
||||||
|
{{{editorHtml}}}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" data-help-name="{{nodeName}}">
|
||||||
|
{{{helpHtml}}}
|
||||||
|
</script>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --build && copyfiles -u 2 './src/nodes/**/*.{png,svg,html}' ./dist/nodes/"
|
"build": "tsc --build && copyfiles -u 2 './src/nodes/**/*.{png,svg}' ./dist/nodes/ && node build/build.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*"
|
"dist/**/*"
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^14.14.41",
|
"@types/node": "^14.14.41",
|
||||||
"@types/node-red": "^1.1.1",
|
"@types/node-red": "^1.1.1",
|
||||||
"copyfiles": "^2.4.1"
|
"copyfiles": "^2.4.1",
|
||||||
|
"mustache": "^4.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
<script type="text/javascript">
|
|
||||||
RED.nodes.registerType('ts3-config',{
|
|
||||||
category: 'config',
|
|
||||||
color: '#a6bbcf',
|
|
||||||
defaults: {
|
|
||||||
host: { value: ""},
|
|
||||||
nickname: {value: "ServerQuery"},
|
|
||||||
name: {value: ""}
|
|
||||||
},
|
|
||||||
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> Name</label>
|
|
||||||
<input type="text" id="node-config-input-name">
|
|
||||||
</div>
|
|
||||||
<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>
|
|
||||||
@@ -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{
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { NodeDef, Node } from "node-red";
|
import { NodeDef, Node, EditorNodeProperties } from "node-red";
|
||||||
import { TeamSpeak } from "ts3-nodejs-library"
|
import { TeamSpeak } from "ts3-nodejs-library"
|
||||||
|
|
||||||
export interface Ts3ConfigProps{
|
export interface Ts3ConfigProps{
|
||||||
host: string
|
host: string
|
||||||
nickname: string
|
nickname: string
|
||||||
name: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Ts3ConfigCreds {
|
export interface Ts3ConfigCreds {
|
||||||
@@ -16,7 +15,8 @@ export interface Ts3ConfigData {
|
|||||||
getConnection(): Promise<TeamSpeak>
|
getConnection(): Promise<TeamSpeak>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Ts3ConfigConfig extends NodeDef, Ts3ConfigProps, Ts3ConfigCreds { }
|
export interface Ts3ConfigConfig extends NodeDef, Ts3ConfigProps, Ts3ConfigCreds { }
|
||||||
|
|
||||||
export interface Ts3ConfigNode extends Node<Ts3ConfigCreds>, Ts3ConfigData {}
|
export interface Ts3ConfigNode extends Node<Ts3ConfigCreds>, Ts3ConfigData {}
|
||||||
|
|
||||||
|
export interface Ts3ConfigEditorNodeProperties extends EditorNodeProperties,Ts3ConfigProps {}
|
||||||
|
|||||||
20
src/nodes/ts3-config/ui/editor.html
Normal file
20
src/nodes/ts3-config/ui/editor.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="fa fa-globe"></i> Name</label>
|
||||||
|
<input type="text" id="node-config-input-name">
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
1
src/nodes/ts3-config/ui/help.html
Normal file
1
src/nodes/ts3-config/ui/help.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p>Connection config for a Teamspeak 3 server.</p>
|
||||||
20
src/nodes/ts3-config/ui/index.ts
Normal file
20
src/nodes/ts3-config/ui/index.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { EditorRED } from "node-red";
|
||||||
|
import { Ts3ConfigCreds, Ts3ConfigEditorNodeProperties } from "../types";
|
||||||
|
|
||||||
|
declare const RED: EditorRED;
|
||||||
|
|
||||||
|
RED.nodes.registerType<Ts3ConfigEditorNodeProperties,Ts3ConfigCreds>('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";
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { NodeInitializer } from "node-red";
|
import { NodeInitializer } from "node-red";
|
||||||
|
import { TeamSpeak } from "ts3-nodejs-library";
|
||||||
import { Ts3ConfigNode } from "../ts3-config/types";
|
import { Ts3ConfigNode } from "../ts3-config/types";
|
||||||
import { Ts3GetConfig, Ts3GetNode } from "./types";
|
import { Ts3GetConfig, Ts3GetNode } from "./types";
|
||||||
|
|
||||||
@@ -27,11 +28,22 @@ 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 })
|
const member: any = client[config.selection as keyof TeamSpeak]
|
||||||
|
if (typeof member === "function"){
|
||||||
msg.payload = clients
|
let args: any[] = []
|
||||||
|
|
||||||
|
if (msg.payload instanceof Array){
|
||||||
|
args = msg.payload
|
||||||
|
}else{
|
||||||
|
args = [msg.payload]
|
||||||
|
}
|
||||||
|
msg.payload = await member.apply(client,args)
|
||||||
|
|
||||||
|
send(msg)
|
||||||
|
}else{
|
||||||
|
this.error(`Failed to call ${config.selection}. Not a function`)
|
||||||
|
}
|
||||||
|
|
||||||
send(msg)
|
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { NodeDef, Node } from "node-red";
|
import { NodeDef, Node, EditorNodeProperties } from "node-red";
|
||||||
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 +11,5 @@ 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 interface Ts3GetEditorNodeProperties extends EditorNodeProperties,Ts3GetProps {}
|
||||||
|
|||||||
79
src/nodes/ts3-get/ui/editor.html
Normal file
79
src/nodes/ts3-get/ui/editor.html
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="fa fa-globe"></i> Name</label>
|
||||||
|
<input type="text" id="node-input-name">
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
<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 value="version" selected>version</option>
|
||||||
|
<option value="apiKeyList">apiKeyList</option>
|
||||||
|
<option value="hostInfo">hostInfo</option>
|
||||||
|
<option value="instanceInfo">instanceInfo</option>
|
||||||
|
<option value="bindingList">bindingList</option>
|
||||||
|
<option value="whoami">whoami</option>
|
||||||
|
<option value="serverInfo">serverInfo</option>
|
||||||
|
<option value="serverIdGetByPort">serverIdGetByPort</option>
|
||||||
|
<option value="connectionInfo">connectionInfo</option>
|
||||||
|
<option value="serverGroupClientList">serverGroupClientList</option>
|
||||||
|
<option value="serverGroupsByClientId">serverGroupsByClientId</option>
|
||||||
|
<option value="serverGroupPermList">serverGroupPermList</option>
|
||||||
|
<option value="serverTempPasswordList">serverTempPasswordList</option>
|
||||||
|
<option value="getChannelById">getChannelById</option>
|
||||||
|
<option value="channelPermList">channelPermList</option>
|
||||||
|
<option value="getClientById">getClientById</option>
|
||||||
|
<option value="getChannelByName">getChannelByName</option>
|
||||||
|
<option value="channelFind">channelFind</option>
|
||||||
|
<option value="channelInfo">channelInfo</option>
|
||||||
|
<option value="getClientByDbid">getClientByDbid</option>
|
||||||
|
<option value="getClientByUid">getClientByUid</option>
|
||||||
|
<option value="getClientByName">getClientByName</option>
|
||||||
|
<option value="clientInfo">clientInfo</option>
|
||||||
|
<option value="clientDbList">clientDbList</option>
|
||||||
|
<option value="clientDbInfo">clientDbInfo</option>
|
||||||
|
<option value="clientPermList">clientPermList</option>
|
||||||
|
<option value="customSearch">customSearch</option>
|
||||||
|
<option value="customInfo">customInfo</option>
|
||||||
|
<option value="getServerGroupById">getServerGroupById</option>
|
||||||
|
<option value="getServerGroupByName">getServerGroupByName</option>
|
||||||
|
<option value="getChannelGroupById">getChannelGroupById</option>
|
||||||
|
<option value="getChannelGroupByName">getChannelGroupByName</option>
|
||||||
|
<option value="setClientChannelGroup">setClientChannelGroup</option>
|
||||||
|
<option value="channelGroupPermList">channelGroupPermList</option>
|
||||||
|
<option value="channelGroupClientList">channelGroupClientList</option>
|
||||||
|
<option value="permOverview">permOverview</option>
|
||||||
|
<option value="permissionList">permissionList</option>
|
||||||
|
<option value="permIdGetByName">permIdGetByName</option>
|
||||||
|
<option value="permIdsGetByName">permIdsGetByName</option>
|
||||||
|
<option value="permGet">permGet</option>
|
||||||
|
<option value="permFind">permFind</option>
|
||||||
|
<option value="privilegeKeyList">privilegeKeyList</option>
|
||||||
|
<option value="messageList">messageList</option>
|
||||||
|
<option value="messageGet">messageGet</option>
|
||||||
|
<option value="complainList">complainList</option>
|
||||||
|
<option value="banList">banList</option>
|
||||||
|
<option value="logView">logView</option>
|
||||||
|
<option value="clientFind">clientFind</option>
|
||||||
|
<option value="clientGetIds">clientGetIds</option>
|
||||||
|
<option value="clientGetDbidFromUid">clientGetDbidFromUid</option>
|
||||||
|
<option value="clientGetNameFromUid">clientGetNameFromUid</option>
|
||||||
|
<option value="clientGetUidFromClid">clientGetUidFromClid</option>
|
||||||
|
<option value="clientGetNameFromDbid">clientGetNameFromDbid</option>
|
||||||
|
<option value="clientDbFind">clientDbFind</option>
|
||||||
|
<option value="serverList">serverList</option>
|
||||||
|
<option value="channelClientPermList">channelClientPermList</option>
|
||||||
|
<option value="channelGroupList">channelGroupList</option>
|
||||||
|
<option value="serverGroupList">serverGroupList</option>
|
||||||
|
<option value="channelList">channelList</option>
|
||||||
|
<option value="clientList">clientList</option>
|
||||||
|
<option value="ftList">ftList</option>
|
||||||
|
<option value="ftGetFileList">ftGetFileList</option>
|
||||||
|
<option value="ftGetFileInfo">ftGetFileInfo</option>
|
||||||
|
<option value="downloadFile">downloadFile</option>
|
||||||
|
<option value="downloadIcon">downloadIcon</option>
|
||||||
|
<option value="getIconId">getIconId</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
1
src/nodes/ts3-get/ui/help.html
Normal file
1
src/nodes/ts3-get/ui/help.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<p>Get information from a Teamspeak 3 server.</p>
|
||||||
18
src/nodes/ts3-get/ui/index.ts
Normal file
18
src/nodes/ts3-get/ui/index.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { EditorRED } from "node-red";
|
||||||
|
import { Ts3GetEditorNodeProperties } from "../types";
|
||||||
|
|
||||||
|
declare const RED: EditorRED;
|
||||||
|
|
||||||
|
RED.nodes.registerType<Ts3GetEditorNodeProperties>('ts3-get',{
|
||||||
|
category: 'function',
|
||||||
|
color: '#a6bbcf',
|
||||||
|
defaults: {
|
||||||
|
configid: { type:"ts3-config", value: "" },
|
||||||
|
selection: { value:"" }
|
||||||
|
},
|
||||||
|
inputs: 1,
|
||||||
|
outputs: 1,
|
||||||
|
label: function() {
|
||||||
|
return this.name || "Ts3 Get";
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -317,6 +317,11 @@ mkdirp@^1.0.4:
|
|||||||
resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz"
|
resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz"
|
||||||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
||||||
|
|
||||||
|
mustache@^4.2.0:
|
||||||
|
version "4.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64"
|
||||||
|
integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==
|
||||||
|
|
||||||
noms@0.0.0:
|
noms@0.0.0:
|
||||||
version "0.0.0"
|
version "0.0.0"
|
||||||
resolved "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz"
|
resolved "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz"
|
||||||
|
|||||||
Reference in New Issue
Block a user