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