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 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 9 | window.angular && (function(angular) { |
| 10 | 'use strict'; |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 11 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 12 | angular |
| 13 | .module('app.configuration') |
| 14 | .controller('networkController', [ |
| 15 | '$scope', |
| 16 | '$window', |
| 17 | 'APIUtils', |
| 18 | 'dataService', |
| 19 | function($scope, $window, APIUtils, dataService) { |
| 20 | $scope.dataService = dataService; |
| 21 | $scope.network = {}; |
| 22 | $scope.interface = {}; |
| 23 | $scope.networkDevice = false; |
| 24 | $scope.hostname = ''; |
Iftekharul Islam | 2a48955 | 2017-11-02 13:23:08 -0500 | [diff] [blame] | 25 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 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 | }); |
| 39 | } |
| 40 | ]); |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 41 | |
| 42 | })(angular); |