fix statistics channel view

This commit is contained in:
Martin/Geno 2018-07-15 21:55:13 +02:00
parent cd511dce8e
commit 63f77d87c7
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
3 changed files with 53 additions and 32 deletions

View File

@ -190,11 +190,17 @@ setEvent('auth_status', (msg) => {
render(); render();
}); });
setEvent('node-system', (msg) => { addEvent('node-system', (msg) => {
store.updateNode(msg.body, true); store.updateNode(msg.body, true);
}); });
setEvent('node-current', (msg) => { addEvent('node-current', (msg) => {
store.updateNode(msg.body); store.updateNode(msg.body);
}); });
addEvent('channels_wifi24', (msg) => {
store.channelsWifi24 = msg.body.sort((a, b) => a - b);
});
addEvent('channels_wifi5', (msg) => {
store.channelsWifi5 = msg.body.sort((a, b) => a - b);
});
connect(); connect();

View File

@ -50,10 +50,21 @@ export class StatisticsView extends View {
this.clientsWifi.innerHTML = msg.body.ClientsWifi; this.clientsWifi.innerHTML = msg.body.ClientsWifi;
this.clientsWifi24.innerHTML = msg.body.ClientsWifi24; this.clientsWifi24.innerHTML = msg.body.ClientsWifi24;
this.clientsWifi5.innerHTML = msg.body.ClientsWifi5; this.clientsWifi5.innerHTML = msg.body.ClientsWifi5;
}
});
socket.addEvent('node-current', this.updateChannelTable.bind(this));
socket.addEvent('channels_wifi24', this.updateChannelTable.bind(this));
socket.addEvent('channels_wifi5', this.updateChannelTable.bind(this));
}
updateChannelTable (){
while(this.channelTabelle.hasChildNodes()) { while(this.channelTabelle.hasChildNodes()) {
this.channelTabelle.removeChild(this.channelTabelle.firstElementChild); this.channelTabelle.removeChild(this.channelTabelle.firstElementChild);
} }
if(!store.channelsWifi24 || !store.channelsWifi5) {
return
}
const storeNodes = store.getNodes(),
end = Math.max(store.channelsWifi24.length||0,store.channelsWifi5.length||0);
let tr = domlib.newAt(this.channelTabelle, 'tr'); let tr = domlib.newAt(this.channelTabelle, 'tr');
@ -64,21 +75,25 @@ export class StatisticsView extends View {
title = domlib.newAt(tr, 'th'); title = domlib.newAt(tr, 'th');
title.innerHTML = '5 Ghz'; title.innerHTML = '5 Ghz';
title.setAttribute('colspan', '2'); title.setAttribute('colspan', '2');
const storeNodes = store.getNodes();
for (let ch = 1; ch <= 33; ch++) { for (let i = 0; i <= end; i++) {
tr = domlib.newAt(this.channelTabelle, 'tr'); tr = domlib.newAt(this.channelTabelle, 'tr');
if (ch < 14) { const wifi24Channel = store.channelsWifi24[i],
domlib.newAt(tr, 'td').innerHTML = ch; wifi5Channel = store.channelsWifi5[i];
domlib.newAt(tr, 'td').innerHTML = storeNodes.reduce((c, node) => node.wireless.channel24 === ch ? c + 1 : c, 0); if (wifi24Channel) {
domlib.newAt(tr, 'td').innerHTML = wifi24Channel;
domlib.newAt(tr, 'td').innerHTML = storeNodes.reduce((c, node) => node.wireless.channel24 === wifi24Channel ? c + 1 : c, 0);
} else { } else {
domlib.newAt(tr, 'td'); domlib.newAt(tr, 'td');
domlib.newAt(tr, 'td'); domlib.newAt(tr, 'td');
} }
const ch5 = 32 + ch * 4; if (wifi5Channel) {
domlib.newAt(tr, 'td').innerHTML = ch5; domlib.newAt(tr, 'td').innerHTML = wifi5Channel;
domlib.newAt(tr, 'td').innerHTML = storeNodes.reduce((c, node) => node.wireless.channel5 === ch5 ? c + 1 : c, 0); domlib.newAt(tr, 'td').innerHTML = storeNodes.reduce((c, node) => node.wireless.channel5 === wifi5Channel ? c + 1 : c, 0);
} else {
domlib.newAt(tr, 'td');
domlib.newAt(tr, 'td');
} }
} }
});
} }
} }

View File

@ -7,8 +7,8 @@ const (
MessageTypeAuthStatus = "auth_status" MessageTypeAuthStatus = "auth_status"
MessageTypeLogout = "logout" MessageTypeLogout = "logout"
MessageTypeChannelsWifi24 = "channel_wifi24" MessageTypeChannelsWifi24 = "channels_wifi24"
MessageTypeChannelsWifi5 = "channel_wifi5" MessageTypeChannelsWifi5 = "channels_wifi5"
MessageTypeSystemNode = "node-system" MessageTypeSystemNode = "node-system"
MessageTypeCurrentNode = "node-current" MessageTypeCurrentNode = "node-current"