Only building html with 200's in channel_list
This commit is contained in:
parent
24a49663d2
commit
41bfd1cd89
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
run() {
|
run() {
|
||||||
# Required to tests against the self certs we use in testing envs
|
# Required to tests against the self certs we use in testing envs
|
||||||
export NODE_TLS_REJECT_UNAUTHORIZED=0
|
export NODE_TLS_REJECT_UNAUTHORIZED='0'
|
||||||
export DEV_ENV=true
|
export DEV_ENV=true
|
||||||
./node_modules/electron/dist/electron main.js $@
|
./node_modules/electron/dist/electron main.js $@
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ const { ipcRenderer } = require('electron')
|
|||||||
const auth = require('./auth.js')
|
const auth = require('./auth.js')
|
||||||
const { Request } = require('./request.js')
|
const { Request } = require('./request.js')
|
||||||
|
|
||||||
|
const VOICE_KIND = 1
|
||||||
|
const TEXT_KIND = 2
|
||||||
class Channel {
|
class Channel {
|
||||||
constructor(name, id, type, description) {
|
constructor(name, id, type, description) {
|
||||||
this.name = name
|
this.name = name
|
||||||
@ -20,12 +22,25 @@ class Channel {
|
|||||||
* @param {Number} port | Should always be the default value of 4536 but other owner
|
* @param {Number} port | Should always be the default value of 4536 but other owner
|
||||||
* @param {Object} params | basic object with jwt + id fields
|
* @param {Object} params | basic object with jwt + id fields
|
||||||
*/
|
*/
|
||||||
function channels_list(domain, port, params) {
|
function update_channels_list(domain, port, params) {
|
||||||
|
|
||||||
Request('get', domain, port, '/channels/list', params).then(
|
Request('get', domain, port, '/channels/list', params).then(
|
||||||
channels => {
|
response => {
|
||||||
// fill the DOM with stuff here
|
if(response.status_code != 200) {
|
||||||
console.log('sucess', channels)
|
document.getElementById('channels-list').textContent = 'Could not fetch channels'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const channels = response.body
|
||||||
|
const voice = channels.filter(chan => chan.kind == VOICE_KIND)
|
||||||
|
const text = channels.filter(chan => chan.kind == TEXT_KIND)
|
||||||
|
|
||||||
|
const chans = voice.concat(text)
|
||||||
|
for(const channel of chans) {
|
||||||
|
const name = channel.name
|
||||||
|
let item = `<li> <p class="message"> <a href="#" class="btn btn-link channel-name">${name}</a> </p> </li>`
|
||||||
|
document.getElementById('channels-list').innerHTML += item
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
reason => {
|
reason => {
|
||||||
console.log('Request for /channels/list rejected', reason)
|
console.log('Request for /channels/list rejected', reason)
|
||||||
@ -46,5 +61,5 @@ exports.get_channels = function(server_conf) {
|
|||||||
jwt: server_conf['jwt']
|
jwt: server_conf['jwt']
|
||||||
}
|
}
|
||||||
|
|
||||||
channels_list(server_conf['domain'], server_conf['port'], params)
|
update_channels_list(server_conf['domain'], server_conf['port'], params)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user