Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Controller for network |
| 3 | * |
| 4 | * @module app/configuration |
| 5 | * @exports networkController |
| 6 | * @name networkController |
| 7 | * @version 0.1.0 |
| 8 | */ |
| 9 | |
| 10 | window.angular && (function (angular) { |
| 11 | 'use strict'; |
| 12 | |
| 13 | angular |
| 14 | .module('app.configuration') |
| 15 | .controller('networkController', [ |
Gunnar Mills | eedefd3 | 2018-02-28 17:02:34 -0600 | [diff] [blame^] | 16 | '$scope', |
| 17 | '$window', |
| 18 | 'APIUtils', |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 19 | 'dataService', |
| 20 | function($scope, $window, APIUtils, dataService){ |
| 21 | $scope.dataService = dataService; |
Iftekharul Islam | 2a48955 | 2017-11-02 13:23:08 -0500 | [diff] [blame] | 22 | $scope.network = {}; |
| 23 | $scope.interface = {}; |
| 24 | $scope.networkDevice = false; |
| 25 | $scope.hostname = ""; |
| 26 | |
| 27 | $scope.selectInterface = function(interfaceId){ |
| 28 | $scope.interface = $scope.network.interfaces[interfaceId]; |
| 29 | $scope.selectedInterface = interfaceId; |
| 30 | $scope.networkDevice = false; |
| 31 | } |
| 32 | APIUtils.getNetworkInfo().then(function(data){ |
| 33 | $scope.network = data.formatted_data; |
| 34 | $scope.hostname = data.hostname; |
| 35 | if($scope.network.interface_ids.length){ |
| 36 | $scope.selectedInterface = $scope.network.interface_ids[0]; |
| 37 | $scope.interface = $scope.network.interfaces[$scope.selectedInterface]; |
| 38 | } |
| 39 | }); |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 40 | } |
| 41 | ] |
| 42 | ); |
| 43 | |
| 44 | })(angular); |