2016-06-23 17:31:39 +02:00
|
|
|
|
|
|
|
function routeNodesPrivEvent(nodeid,attr,attr2){
|
|
|
|
return function (e){
|
|
|
|
var input = e.which || e.keyCode;
|
|
|
|
if (input === 13) { // 13 is enter
|
2016-06-24 03:17:12 +02:00
|
|
|
value = e.target.value || e.srcElement.value || ''
|
2016-06-23 17:31:39 +02:00
|
|
|
if(internal.aliases[nodeid] == undefined){
|
|
|
|
internal.aliases[nodeid] = {}
|
|
|
|
}
|
|
|
|
if(attr2 == undefined){
|
2016-06-24 03:17:12 +02:00
|
|
|
internal.aliases[nodeid][attr] = value
|
2016-06-23 17:31:39 +02:00
|
|
|
}else{
|
|
|
|
if(internal.aliases[nodeid][attr] == undefined){
|
|
|
|
internal.aliases[nodeid][attr] = {}
|
|
|
|
}
|
2016-06-24 03:17:12 +02:00
|
|
|
internal.aliases[nodeid][attr][attr2] = value
|
2016-06-23 17:31:39 +02:00
|
|
|
}
|
|
|
|
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>'
|
2016-06-24 03:17:12 +02:00
|
|
|
+ '<th>Edit</th>'
|
2016-06-23 17:31:39 +02:00
|
|
|
+ '<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;">'
|
2016-06-24 04:19:07 +02:00
|
|
|
+ '<span style="font-size:20px;color:'+((internal.nodes[key].flags.online)?'green':'red')+';">●</span><br/>'
|
2016-06-24 03:17:12 +02:00
|
|
|
+ moment(internal.nodes[key].lastseen).fromNow(true)
|
|
|
|
+'</td>'
|
|
|
|
+ '<td class="mdl-data-table__cell--non-numeric mdt-table__cell-input" rowspan="2">'
|
2016-06-23 17:31:39 +02:00
|
|
|
+ '<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>'
|
2016-06-24 03:17:12 +02:00
|
|
|
+ '<td class="mdl-data-table__cell--non-numeric" rowspan="2"><i class="material-icons" id="edit_'+key+'">edit</i></td>'
|
|
|
|
+ '<td class="mdl-data-table__cell--non-numeric" rowspan="2">'+sshUrl(key)+'</td>'
|
2016-06-23 17:31:39 +02:00
|
|
|
+ '</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'))
|
2016-06-24 03:17:12 +02:00
|
|
|
document.getElementById("edit_"+key).addEventListener('click', function(){
|
|
|
|
editModel(key)
|
|
|
|
})
|
2016-06-23 17:31:39 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
}
|