Skip to content
Snippets Groups Projects
Commit 329e8a2c authored by Erik Reid's avatar Erik Reid
Browse files

added interface/bgp/snmp data output

parent 02de16e1
Branches
Tags
No related merge requests found
...@@ -2,18 +2,47 @@ var myApp = angular.module('inventoryApp', []); ...@@ -2,18 +2,47 @@ var myApp = angular.module('inventoryApp', []);
myApp.controller('inventoryProvider', function($scope, $http) { myApp.controller('inventoryProvider', function($scope, $http) {
$scope.routers = [] $scope.routers = [];
$scope.router = '';
function onSuccess(response) { $scope.interfaces = 'not yet loaded';
$scope.routers = response.data; $scope.bgp = 'not yet loaded';
} $scope.snmp = 'not yet loaded';
function onError(response) {
$scope.routers = ['error'];
}
$http({ $http({
method: 'GET', method: 'GET',
url: window.location.origin + "/data/routers" url: window.location.origin + "/data/routers"
}).then(onSuccess, onError); }).then(
function(rsp) {$scope.routers = rsp.data;},
function(rsp) {$scope.routers = ['error'];}
);
$scope.update_interface = function() {
$http({
method: 'GET',
url: window.location.origin + "/data/interfaces/" + $scope.router
}).then(
function(rsp) {$scope.interfaces = rsp.data;},
function(rsp) {$scope.interfaces = 'error';}
);
$http({
method: 'GET',
url: window.location.origin + "/data/bgp/" + $scope.router
}).then(
function(rsp) {$scope.bgp = rsp.data;},
function(rsp) {$scope.bgp = 'error';}
);
$http({
method: 'GET',
url: window.location.origin + "/data/snmp/" + $scope.router
}).then(
function(rsp) {$scope.snmp = rsp.data;},
function(rsp) {$scope.snmp = 'error';}
);
}
}); });
\ No newline at end of file
...@@ -3,14 +3,40 @@ ...@@ -3,14 +3,40 @@
<head> <head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.5/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.5/angular.min.js"></script>
<script src="inventoryProvider.js"></script> <script src="inventoryProvider.js"></script>
<link rel="stylesheet" href="todo.css"> <link rel="stylesheet" href="style.css">
</head> </head>
<body> <body>
<h2>Todo</h2>
<!--
<h2>Routers</h2>
<div ng-controller="inventoryProvider"> <div ng-controller="inventoryProvider">
<ul name="routers" class="unstyled"> <ul name="routers" class="unstyled">
<li ng-repeat="router in routers">{{router}}</li> <li ng-repeat="r in routers">{{r}}</li>
</ul> </ul>
</div> </div>
-->
<div ng-controller="inventoryProvider">
<h2>Interfaces</h2>
<div>
<select
ng-options="r for r in routers"
ng-change="update_interface()"
ng-model="router"></select>
</div>
<div class="column">
<p><b>interfaces</b></p>
{{interfaces}}
</div>
<div class="column">
<p><b>bgp</b></p>
{{bgp}}
</div>
<div class="column">
<p><b>snmp</b></p>
{{snmp}}
</div>
</div>
</body> </body>
</html> </html>
\ No newline at end of file
.column {
float: left;
width: 33.33%;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment