mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Updated sudoers to accomodate restarting dhcpcd to apply network settings.
Updated installer to insert new lines Created files to generate / modify / save dhcpcd files and networking configuration
This commit is contained in:
63
js/custom.js
63
js/custom.js
@@ -1,3 +1,13 @@
|
||||
function msgShow(retcode,msg) {
|
||||
if(retcode == 0) {
|
||||
var alertType = 'success';
|
||||
} else if(retcode == 2 || retcode == 1) {
|
||||
var alertType = 'danger';
|
||||
}
|
||||
var htmlMsg = '<div class="alert alert-'+alertType+' alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'+msg+'</div>';
|
||||
return htmlMsg;
|
||||
}
|
||||
|
||||
function createNetmaskAddr(bitCount) {
|
||||
var mask=[];
|
||||
for(i=0;i<4;i++) {
|
||||
@@ -23,7 +33,9 @@ function loadSummary(strInterface) {
|
||||
function getAllInterfaces() {
|
||||
$.get('/ajax/networking/get_all_interfaces.php',function(data){
|
||||
jsonData = JSON.parse(data);
|
||||
$.each(jsonData,function(ind,value){loadSummary(value)});
|
||||
$.each(jsonData,function(ind,value){
|
||||
loadSummary(value)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,20 +52,24 @@ function setupTabs() {
|
||||
function loadCurrentSettings(strInterface) {
|
||||
$.post('/ajax/networking/get_int_config.php',{interface:strInterface,csrf_token:csrf},function(data){
|
||||
jsonData = JSON.parse(data);
|
||||
//console.log(data);
|
||||
$.each(jsonData['output'],function(i,v) {
|
||||
//console.log(i);
|
||||
var int = v['interface'];
|
||||
//console.log('interface : '+int);
|
||||
$.each(v,function(i2,v2) {
|
||||
//console.log(i2+":"+v2);
|
||||
switch(i2) {
|
||||
case "static":
|
||||
if(v2 == 'true') {
|
||||
$('#'+int+'-static').click();
|
||||
$('#'+int+'-nofailover').click();
|
||||
} else {
|
||||
$('#'+int+'-dhcp').click();
|
||||
}
|
||||
break;
|
||||
case "interface":
|
||||
case "failover":
|
||||
if(v2 === 'true') {
|
||||
$('#'+int+'-failover').click();
|
||||
} else {
|
||||
$('#'+int+'-nofailover').click();
|
||||
}
|
||||
break;
|
||||
case "ip_address":
|
||||
var arrIPNetmask = v2.split('/');
|
||||
@@ -74,10 +90,8 @@ function loadCurrentSettings(strInterface) {
|
||||
});
|
||||
}
|
||||
|
||||
function setupBtns() {
|
||||
$('#btnSummaryRefresh').click(function(){getAllInterfaces();});
|
||||
$('.intsave').click(function(){
|
||||
var int = $(this).data('int');
|
||||
function saveNetworkSettings(int) {
|
||||
|
||||
var frmInt = $('#frm-'+int).find(':input');
|
||||
var arrFormData = {};
|
||||
$.each(frmInt,function(i3,v3){
|
||||
@@ -90,8 +104,34 @@ function setupBtns() {
|
||||
arrFormData['interface'] = int;
|
||||
arrFormData['csrf_token'] = csrf;
|
||||
$.post('/ajax/networking/save_int_config.php',arrFormData,function(data){
|
||||
console.log(data);
|
||||
//console.log(data);
|
||||
var jsonData = JSON.parse(data);
|
||||
$('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output']));
|
||||
});
|
||||
}
|
||||
|
||||
function applyNetworkSettings() {
|
||||
var int = $(this).data('int');
|
||||
arrFormData = {};
|
||||
arrFormData['csrf_token'] = csrf;
|
||||
arrFormData['generate'] = '';
|
||||
$.post('/ajax/networking/gen_int_config.php',arrFormData,function(data){
|
||||
console.log(data);
|
||||
var jsonData = JSON.parse(data);
|
||||
$('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output']));
|
||||
});
|
||||
}
|
||||
|
||||
function setupBtns() {
|
||||
$('#btnSummaryRefresh').click(function(){getAllInterfaces();});
|
||||
|
||||
$('.intsave').click(function(){
|
||||
var int = $(this).data('int');
|
||||
saveNetworkSettings(int);
|
||||
});
|
||||
|
||||
$('.intapply').click(function(){
|
||||
applyNetworkSettings();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,6 +139,7 @@ $().ready(function(){
|
||||
csrf = $('#csrf_token').val();
|
||||
pageCurrent = window.location.href.split("?")[1].split("=")[1];
|
||||
pageCurrent = pageCurrent.replace("#","");
|
||||
$('#side-menu').metisMenu();
|
||||
switch(pageCurrent) {
|
||||
case "network_conf":
|
||||
getAllInterfaces();
|
||||
|
Reference in New Issue
Block a user