Merge "Add switch filters"
This commit is contained in:
commit
6dc22eaf8a
@ -290,23 +290,17 @@ compassAppDev.run(function($httpBackend, settings, $http) {
|
||||
var switches = [{
|
||||
"id": 1,
|
||||
"ip": "172.29.8.40",
|
||||
"filters": {
|
||||
"ports": "1-10;20-51"
|
||||
},
|
||||
"filters": "allow ports 1-10,20-51",
|
||||
"state": "under_mointoring"
|
||||
}, {
|
||||
"id": 2,
|
||||
"ip": "172.29.8.41",
|
||||
"filters": {
|
||||
"ports": "1-100"
|
||||
},
|
||||
"filters": "deny ports 1-100",
|
||||
"state": "under_mointoring"
|
||||
}, {
|
||||
"id": 3,
|
||||
"ip": "172.29.8.42",
|
||||
"filters": {
|
||||
"ports": "1-100"
|
||||
},
|
||||
"filters": "allow ports 1-50",
|
||||
"state": "under_mointoring"
|
||||
}];
|
||||
return [200, switches, {}];
|
||||
@ -325,14 +319,18 @@ compassAppDev.run(function($httpBackend, settings, $http) {
|
||||
var sw = {
|
||||
"id": id,
|
||||
"ip": "172.29.8.40",
|
||||
"filters": {
|
||||
"ports": "1-10;20-51"
|
||||
},
|
||||
"filters": "allow ports 1-10,20-51",
|
||||
"state": state
|
||||
};
|
||||
return [200, sw, {}];
|
||||
});
|
||||
|
||||
$httpBackend.whenPUT(/\.*\/switches\/([0-9]|[1-9][0-9])$/).respond(function(method, url, data) {
|
||||
console.log(method, url, data);
|
||||
var sw = JSON.parse(data);
|
||||
return [200, sw, {}];
|
||||
});
|
||||
|
||||
$httpBackend.whenPOST(settings.apiUrlBase + '/switches').respond(function(method, url, data) {
|
||||
console.log(method, url, data);
|
||||
var switchData = JSON.parse(data);
|
||||
|
@ -37,7 +37,7 @@ angular.module('compass.server', [
|
||||
|
||||
$scope.tableParams = new ngTableParams({
|
||||
page: 1, // show first page
|
||||
count: $scope.allservers.length // count per page
|
||||
count: $scope.allservers.length + 1 // count per page
|
||||
}, {
|
||||
counts: [], // hide count-per-page box
|
||||
total: $scope.allservers.length, // length of data
|
||||
|
@ -65,6 +65,11 @@ angular.module('compass.services', [])
|
||||
this.postSwitches = function(sw) {
|
||||
return $http.post(settings.apiUrlBase + '/switches', angular.toJson(sw));
|
||||
};
|
||||
|
||||
this.putSwitches = function(id, sw) {
|
||||
return $http.put(settings.apiUrlBase + '/switches/' + id, angular.toJson(sw));
|
||||
};
|
||||
|
||||
/*
|
||||
this.postSwitchFilters = function(filters) {
|
||||
return $http.post(settings.apiUrlBase + '/switch-filters', angular.toJson(filters));
|
||||
|
@ -31,9 +31,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label no-padding-right">Port Filter</label>
|
||||
<label class="col-sm-3 control-label no-padding-right">Filters</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" ng-model="filters.ports" placeholder="Port Filter">
|
||||
<input type="text" ng-model="newswitch.filters" placeholder="Filters" popover-placement="right" popover-trigger="focus" popover-title="Example" popover="allow ports 1-100,150-200;">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -42,6 +42,17 @@
|
||||
<button class="btn btn-primary" ng-click="addSwitch()" ng-disabled="addSwitchForm.$invalid">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="space-10"></div>
|
||||
<alert ng-repeat="alert in alerts" type="danger" close="closeAlert()" >
|
||||
<span ng-if="alert.message">
|
||||
{{alert.message}}
|
||||
</span>
|
||||
<span ng-if="!alert.message">
|
||||
Unknown error
|
||||
</span>
|
||||
</alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6">
|
||||
@ -90,7 +101,7 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>{{switch.ip}}</td>
|
||||
<td>{{switch.filters.ports}}</td>
|
||||
<td>{{switch.filters}}</td>
|
||||
<td>
|
||||
<i class="ace-icon fa fa-pencil bigger-120 action green"></i>
|
||||
</td>
|
||||
|
@ -33,14 +33,13 @@ angular.module('compass.findservers', [])
|
||||
dataService.getSwitchById(scope.switchinfo.id).success(function(data) {
|
||||
if (data.state == "under_monitoring") {
|
||||
getMachines();
|
||||
} else if(data.state === "initialized" || data.state === "repolling")
|
||||
} else if (data.state === "initialized" || data.state === "repolling")
|
||||
if (fireTimer && checkSwitchCount < 15) {
|
||||
checkSwitchTimer = $timeout(checkSwitchState, 2000);
|
||||
} else {
|
||||
scope.polling = false;
|
||||
scope.result = "error";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
scope.polling = false;
|
||||
scope.result = "error";
|
||||
}
|
||||
@ -48,7 +47,7 @@ angular.module('compass.findservers', [])
|
||||
};
|
||||
|
||||
scope.$watch('polling', function(newval, oldval) {
|
||||
if(newval != oldval) {
|
||||
if (newval != oldval) {
|
||||
if (newval == true) {
|
||||
checkSwitchCount = 0;
|
||||
fireTimer = true;
|
||||
@ -145,23 +144,24 @@ angular.module('compass.findservers', [])
|
||||
|
||||
scope.newswitch = {}
|
||||
scope.newswitch.credentials = {};
|
||||
scope.filters = {};
|
||||
scope.alerts = [];
|
||||
|
||||
scope.addSwitch = function() {
|
||||
scope.alerts = [];
|
||||
dataService.postSwitches(scope.newswitch).success(function(switchData) {
|
||||
|
||||
if (scope.filters) {
|
||||
var filters = {
|
||||
"filters": scope.filters
|
||||
};
|
||||
dataService.putSwitchFilters(switchData.id, filters).success(function(filterData) {
|
||||
switchData.filters = filterData.filters;
|
||||
scope.newswitch = {};
|
||||
scope.filters = {};
|
||||
|
||||
|
||||
scope.switches.push(switchData);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}).error(function(response) {
|
||||
scope.alerts[0] = response;
|
||||
});
|
||||
};
|
||||
|
||||
scope.closeAlert = function() {
|
||||
scope.alerts = [];
|
||||
};
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user