Commit 10ad5fcd by Bence Dányi

firewall_gui: format js

parent f37d6bc9
......@@ -37,7 +37,7 @@ $.ajaxSetup({
});
function makeAddRemove($scope, name, model) {
$scope['add'+name] = function(entity) {
$scope['add' + name] = function(entity) {
for (var i in $scope.entity[model]) {
var item = $scope.entity[model][i];
if (item.name == entity && item.__destroyed) {
......@@ -52,7 +52,7 @@ function makeAddRemove($scope, name, model) {
__created: true,
});
}
$scope['remove'+name] = function(entity) {
$scope['remove' + name] = function(entity) {
for (var i in $scope.entity[model]) {
var item = $scope.entity[model][i];
if (item.name == entity.name && item.__created) {
......@@ -118,7 +118,8 @@ var controllers = {
* Configures AngularJS with the defined controllers
*/
var module = angular.module('firewall', []).config(
['$routeProvider', function($routeProvider) {
['$routeProvider',
function($routeProvider) {
for (var controller in controllers) {
var init = controllers[controller];
$routeProvider.when('/' + controller + 's/', {
......@@ -132,7 +133,8 @@ var module = angular.module('firewall', []).config(
$routeProvider.otherwise({
redirectTo: '/rules/'
});
}]);
}
]);
/**
* Generate range [a, b)
......@@ -271,19 +273,19 @@ function EntityController(url, init) {
data: JSON.stringify($scope.entity),
success: function(data) {
console.log(data);
$scope.$apply(function(){
$scope.$apply(function() {
$scope.errors = {};
})
}
}).error(function(data){
}).error(function(data) {
try {
data = JSON.parse(data.responseText);
var newErrors = {};
for (var i in data) {
var id = $('#'+i).length ? i : 'targetName';
newErrors[id]=data[i];
var id = $('#' + i).length ? i : 'targetName';
newErrors[id] = data[i];
}
$scope.$apply(function(){
$scope.$apply(function() {
$scope.errors = newErrors;
})
} catch (ex) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment