Add firewall UI

This commit is contained in:
Girish Ramakrishnan
2020-08-31 21:45:56 -07:00
parent dbc53b8d09
commit 39f7a5be70
3 changed files with 108 additions and 0 deletions

View File

@@ -55,6 +55,51 @@ angular.module('Application').controller('NetworkController', ['$scope', '$locat
}
};
$scope.blocklist = {
busy: false,
error: {},
blocklist: '',
currentBlocklist: [],
refresh: function () {
Client.getBlocklist(function (error, result) {
if (error) return console.error(error);
$scope.blocklist.currentBlocklist = result;
});
},
show: function () {
$scope.blocklist.error = {};
$scope.blocklist.blocklist = $scope.blocklist.currentBlocklist.join('\n');
$('#blocklistModal').modal('show');
},
submit: function () {
$scope.blocklist.error = {};
$scope.blocklist.busy = true;
var blocklist = $scope.blocklist.blocklist.split('\n').filter(function (x) { return x !== ''; });
Client.setBlocklist(blocklist, function (error) {
$scope.blocklist.busy = false;
if (error) {
$scope.blocklist.error.blocklist = error.message;
$scope.blocklist.error.ip = error.message;
$scope.blocklistForm.$setPristine();
$scope.blocklistForm.$setUntouched();
return;
}
$scope.blocklist.refresh();
$('#blocklistModal').modal('hide');
});
}
},
$scope.sysinfo = {
busy: false,
error: {},
@@ -137,6 +182,7 @@ angular.module('Application').controller('NetworkController', ['$scope', '$locat
$scope.sysinfo.refresh();
$scope.dyndnsConfigure.refresh();
$scope.blocklist.refresh();
});
$('.modal-backdrop').remove();