interfaces.js 1.31 KiB
var myApp = angular.module('inventoryApp', []);
myApp.controller('interfaces', function($scope, $http) {
$scope.routers = [];
$scope.router = '';
$scope.interfaces = [];
$scope.interface = '';
$scope.status = 'not yet loaded';
$http({
method: 'GET',
url: window.location.origin + "/data/routers"
}).then(
function(rsp) {$scope.routers = rsp.data;},
function(rsp) {$scope.routers = ['error'];}
);
$scope.update_interfaces = function() {
$http({
method: 'GET',
url: window.location.origin + "/data/interfaces/" + $scope.router
}).then(
function(rsp) {
$scope.interfaces = rsp.data.map(function(x){
return x.name
});
},
function(rsp) {$scope.interfaces = ['error'];}
);
}
$scope.update_status = function() {
$http({
method: 'GET',
url: window.location.origin
+ "/alarmsdb/interface-status?equipment="
+ $scope.router
+ "&interface="
+ $scope.interface
}).then(
function(rsp) {$scope.status = rsp.data.status;},
function(rsp) {$scope.interfaces = 'query error';}
);
}
});