1cd789508SIftekharul Islam/** 2cd789508SIftekharul Islam * Controller for network 3cd789508SIftekharul Islam * 4cd789508SIftekharul Islam * @module app/configuration 5cd789508SIftekharul Islam * @exports networkController 6cd789508SIftekharul Islam * @name networkController 7cd789508SIftekharul Islam */ 8cd789508SIftekharul Islam 9cd789508SIftekharul Islamwindow.angular && (function(angular) { 10cd789508SIftekharul Islam 'use strict'; 11cd789508SIftekharul Islam 12d27bb135SAndrew Geissler angular.module('app.configuration').controller('networkController', [ 139a0094dcSGunnar Mills '$scope', '$window', 'APIUtils', 'dataService', '$route', 149a0094dcSGunnar Mills function($scope, $window, APIUtils, dataService, $route) { 15cd789508SIftekharul Islam $scope.dataService = dataService; 162a489554SIftekharul Islam $scope.network = {}; 172a489554SIftekharul Islam $scope.interface = {}; 182a489554SIftekharul Islam $scope.networkDevice = false; 19ba5e3f34SAndrew Geissler $scope.hostname = ''; 207ddc7274SGunnar Mills $scope.set_network_error = ''; 217ddc7274SGunnar Mills $scope.set_network_success = false; 227ddc7274SGunnar Mills $scope.selectedInterface = ''; 23*d01504cfSGunnar Mills $scope.confirm_settings = false; 242a489554SIftekharul Islam 252a489554SIftekharul Islam $scope.selectInterface = function(interfaceId) { 262a489554SIftekharul Islam $scope.interface = $scope.network.interfaces[interfaceId]; 272a489554SIftekharul Islam $scope.selectedInterface = interfaceId; 282a489554SIftekharul Islam $scope.networkDevice = false; 29ba5e3f34SAndrew Geissler }; 307ddc7274SGunnar Mills $scope.setNetworkSettings = function() { 31*d01504cfSGunnar Mills // Hides the confirm network settings modal 32*d01504cfSGunnar Mills $scope.confirm_settings = false; 337ddc7274SGunnar Mills $scope.set_network_error = ''; 347ddc7274SGunnar Mills $scope.set_network_success = false; 357ddc7274SGunnar Mills // TODO openbmc/openbmc#3165: check if the network settings 367ddc7274SGunnar Mills // changed before setting 377ddc7274SGunnar Mills APIUtils 387ddc7274SGunnar Mills .setMACAddress( 397ddc7274SGunnar Mills $scope.selectedInterface, $scope.interface.MACAddress) 407ddc7274SGunnar Mills .then( 417ddc7274SGunnar Mills function(data) { 427ddc7274SGunnar Mills $scope.set_network_success = true; 437ddc7274SGunnar Mills }, 447ddc7274SGunnar Mills function(error) { 457ddc7274SGunnar Mills console.log(error); 467ddc7274SGunnar Mills $scope.set_network_error = 'MAC Address'; 477ddc7274SGunnar Mills }); 487ddc7274SGunnar Mills }; 499a0094dcSGunnar Mills $scope.refresh = function() { 509a0094dcSGunnar Mills $route.reload(); 519a0094dcSGunnar Mills }; 522a489554SIftekharul Islam APIUtils.getNetworkInfo().then(function(data) { 532a489554SIftekharul Islam $scope.network = data.formatted_data; 542a489554SIftekharul Islam $scope.hostname = data.hostname; 552a489554SIftekharul Islam if ($scope.network.interface_ids.length) { 562a489554SIftekharul Islam $scope.selectedInterface = $scope.network.interface_ids[0]; 57d27bb135SAndrew Geissler $scope.interface = 58d27bb135SAndrew Geissler $scope.network.interfaces[$scope.selectedInterface]; 592a489554SIftekharul Islam } 602a489554SIftekharul Islam }); 61cd789508SIftekharul Islam } 62ba5e3f34SAndrew Geissler ]); 63cd789508SIftekharul Islam 64cd789508SIftekharul Islam})(angular); 65