From d5583231dfeab689e4a1e60d994e0c599089aa5f Mon Sep 17 00:00:00 2001 From: ION606 Date: Wed, 27 Jul 2022 15:34:38 +0300 Subject: [PATCH] Added the channel selection menu --- .gitignore | 3 ++- dashboard.html | 37 ++++++++++++++++++++++++++++++++----- index.html | 4 ++-- main.js | 2 +- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index c78c72c..4052dac 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ config.json .env node_modules index - old.html -makefile \ No newline at end of file +makefile +temp.html \ No newline at end of file diff --git a/dashboard.html b/dashboard.html index 4fdaf1c..adf3977 100644 --- a/dashboard.html +++ b/dashboard.html @@ -133,6 +133,12 @@ letter-spacing: 1px; } + .form-select { + width: 200px; + background-color:rgb(187, 183, 183); + border-color: #000000; + } + @@ -246,8 +252,22 @@ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xhr.setRequestHeader('serverNumber', serverSettings.Id); xhr.onloadend = (e) => { - window.localStorage.setItem('channels', (xhr.response)); - document.getElementById('body').classList.replace('hide', 'show'); + //Channel Section + const channels = JSON.parse(xhr.response); + // console.log(channels.text); + // window.localStorage.setItem('channels', (xhr.response)); + + for (let i = 0; i < channels.text.length; i ++) { + var channel = channels.text[i]; + if (channel.name && channel.id) { + var opt = document.createElement('option'); + opt.value = channel.id; + opt.innerHTML = channel.name; + document.getElementById('logchanneldropdown').appendChild(opt); + } + } + + // document.getElementById('body').classList.replace('hide', 'show'); //Welcome section let wc = serverSettings.WELCOME.welcomechannel || ''; @@ -306,6 +326,10 @@ function sendData(event, inp) { event.preventDefault(); + var values=Array.from($(".logchanneldropdown").find(':selected')).map(function(item){ + return $(item).text(); + }); + //Change saving status var b = document.getElementById('savstat'); b.classList.replace('saved', 'saving'); @@ -322,7 +346,7 @@ const sevlist = ['none', 'low', 'meduim', 'high'] serverSettings.LOG.severity = sevlist.indexOf(sevname); - serverSettings.LOG.logchannel = document.getElementById('lc').value || null; + serverSettings.LOG.logchannel = document.getElementById('logchanneldropdown').value || null; let kl = false; if (document.getElementById('kl').checked) { @@ -430,8 +454,11 @@

- -

+ +

Log Severity

diff --git a/index.html b/index.html index 79c7381..2e3f3f8 100644 --- a/index.html +++ b/index.html @@ -318,12 +318,12 @@
- + -
+

WELCOME TO THE SELMER BOT DASHBOARD

diff --git a/main.js b/main.js index d9aba6b..ea69c8a 100644 --- a/main.js +++ b/main.js @@ -112,7 +112,7 @@ app.get('/getChannels', async (req, res) => { } }) - res.send(JSON.stringify(arr)); + res.send(arr); });