86 lines
4.0 KiB
JavaScript
86 lines
4.0 KiB
JavaScript
|
|
||
|
function routeNodesPrivEvent(nodeid,attr,attr2){
|
||
|
return function (e){
|
||
|
var input = e.which || e.keyCode;
|
||
|
if (input === 13) { // 13 is enter
|
||
|
if(internal.aliases[nodeid] == undefined){
|
||
|
internal.aliases[nodeid] = {}
|
||
|
}
|
||
|
if(attr2 == undefined){
|
||
|
internal.aliases[nodeid][attr] = e.srcElement.value
|
||
|
}else{
|
||
|
if(internal.aliases[nodeid][attr] == undefined){
|
||
|
internal.aliases[nodeid][attr] = {}
|
||
|
}
|
||
|
internal.aliases[nodeid][attr][attr2] = e.srcElement.value
|
||
|
}
|
||
|
send('POST',internal.config.api+'/aliases/alias/'+nodeid,internal.aliases[nodeid])
|
||
|
}
|
||
|
menuAliases.setAttribute("data-badge",Object.keys(internal.aliases).length)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function routeNodes(){
|
||
|
fill = '<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp nodes-table">'
|
||
|
+ '<thead>'
|
||
|
+ '<tr>'
|
||
|
+'<th></th>'
|
||
|
+ '<th class="mdl-data-table__cell--non-numeric">Hostname</th>'
|
||
|
+ '<th>Ports</th>'
|
||
|
+ '<th>Freq</th>'
|
||
|
+ '<th>Clients</th>'
|
||
|
+ '<th>Ch</th>'
|
||
|
+ '<th>Tx</th>'
|
||
|
+ '<th>Ort</th>'
|
||
|
+ '<th>SSH</th>'
|
||
|
+ '</tr>'
|
||
|
+ '</thead>'
|
||
|
+ '<tbody>'
|
||
|
Object.keys(internal.nodes).map(function(key){
|
||
|
fill += '<tr>'
|
||
|
+ '<td class="mdl-data-table__cell--non-numeric" rowspan="2" style="padding:0px 2px;text-align:center;">'
|
||
|
+ '<i class="material-icons" style="color:'+((internal.nodes[key].flags.online)?'green':'red')+';">camera</i></td>'
|
||
|
+ '<td class="mdl-data-table__cell--non-numeric mdt-table__cell-input" rowspan="2" style="padding-left:0px;">'
|
||
|
+ '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label is-dirty">'
|
||
|
+ '<input class="mdl-textfield__input" type="text" id="hostname_'+key+'" value="'+internal.nodes[key].nodeinfo.hostname+'"/>'
|
||
|
+ '<label class="mdl-textfield__label" for="hostname_'+key+'">'+key+'</label>'
|
||
|
+ '</div>'
|
||
|
+ '</td>'
|
||
|
+ '<td rowspan="2">100%</td>'
|
||
|
+ '<td class="mdl-data-table__cell--non-numeric">2Ghz</td>'
|
||
|
+ '<td>'+internal.nodes[key].statistics.clients.wifi24+'</td>'
|
||
|
+ '<td>'
|
||
|
+ '<input class="mdl-textfield__input" type="number" id="freq24_ch_'+key+'" value="'+((internal.nodes[key].nodeinfo.settings !== undefined)?internal.nodes[key].nodeinfo.settings.freq24.channel:'')+'"/>'
|
||
|
+ '</td>'
|
||
|
+ '<td>'
|
||
|
+ '<input class="mdl-textfield__input" type="number" id="freq24_tx_'+key+'" value="'+((internal.nodes[key].nodeinfo.settings !== undefined)?internal.nodes[key].nodeinfo.settings.freq24.txpower:'')+'"/>'
|
||
|
+ '</td>'
|
||
|
+ '<td class="mdl-data-table__cell--non-numeric" rowspan="2"><i class="material-icons">place</i></td>'
|
||
|
+ '<td class="mdl-data-table__cell--non-numeric" rowspan="2">SSH</td>'
|
||
|
+ '</tr>'
|
||
|
+ '<tr>'
|
||
|
+ '<td class="mdl-data-table__cell--non-numeric" style="padding-left:18px;">5Ghz</td>'
|
||
|
+ '<td>'+ internal.nodes[key].statistics.clients.wifi5+'</td>'
|
||
|
+ '<td>'
|
||
|
+ '<input class="mdl-textfield__input" type="number" id="freq5_ch_'+key+'" value="'+((internal.nodes[key].nodeinfo.settings !== undefined)?internal.nodes[key].nodeinfo.settings.freq5.channel:'')+'"/>'
|
||
|
+ '</td>'
|
||
|
+ '<td style="padding-right:18px;">'
|
||
|
+ '<input class="mdl-textfield__input" type="number" id="freq5_tx_'+key+'" value="'+((internal.nodes[key].nodeinfo.settings !== undefined)?internal.nodes[key].nodeinfo.settings.freq5.txpower:'')+'"/>'
|
||
|
+ '</td>'
|
||
|
+ '</td>'
|
||
|
+ '</tr>'
|
||
|
})
|
||
|
fill += '</tbody></table>'
|
||
|
container.innerHTML = fill
|
||
|
|
||
|
Object.keys(internal.nodes).map(function(key){
|
||
|
document.getElementById("hostname_"+key).addEventListener('keypress', routeNodesPrivEvent(key,'hostname',null))
|
||
|
document.getElementById("freq24_ch_"+key).addEventListener('keypress', routeNodesPrivEvent(key,'freq24','channel'))
|
||
|
document.getElementById("freq24_tx_"+key).addEventListener('keypress', routeNodesPrivEvent(key,'freq24','txpower'))
|
||
|
document.getElementById("freq5_ch_"+key).addEventListener('keypress', routeNodesPrivEvent(key,'freq5','channel'))
|
||
|
document.getElementById("freq5_tx_"+key).addEventListener('keypress', routeNodesPrivEvent(key,'freq5','txpower'))
|
||
|
})
|
||
|
|
||
|
}
|