xref: /openbmc/phosphor-webui/app/configuration/controllers/network-controller.js (revision ba5e3f3484c0de46f4f5fc5baf5804648179a9eb)
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
12cd789508SIftekharul Islam  angular
13cd789508SIftekharul Islam    .module('app.configuration')
14cd789508SIftekharul Islam    .controller('networkController', [
15cd789508SIftekharul Islam      '$scope',
16cd789508SIftekharul Islam      '$window',
17cd789508SIftekharul Islam      'APIUtils',
18cd789508SIftekharul Islam      'dataService',
19cd789508SIftekharul Islam      function($scope, $window, APIUtils, dataService) {
20cd789508SIftekharul Islam        $scope.dataService = dataService;
212a489554SIftekharul Islam        $scope.network = {};
222a489554SIftekharul Islam        $scope.interface = {};
232a489554SIftekharul Islam        $scope.networkDevice = false;
24*ba5e3f34SAndrew Geissler        $scope.hostname = '';
252a489554SIftekharul Islam
262a489554SIftekharul Islam        $scope.selectInterface = function(interfaceId) {
272a489554SIftekharul Islam          $scope.interface = $scope.network.interfaces[interfaceId];
282a489554SIftekharul Islam          $scope.selectedInterface = interfaceId;
292a489554SIftekharul Islam          $scope.networkDevice = false;
30*ba5e3f34SAndrew Geissler        };
312a489554SIftekharul Islam        APIUtils.getNetworkInfo().then(function(data) {
322a489554SIftekharul Islam          $scope.network = data.formatted_data;
332a489554SIftekharul Islam          $scope.hostname = data.hostname;
342a489554SIftekharul Islam          if ($scope.network.interface_ids.length) {
352a489554SIftekharul Islam            $scope.selectedInterface = $scope.network.interface_ids[0];
362a489554SIftekharul Islam            $scope.interface = $scope.network.interfaces[$scope.selectedInterface];
372a489554SIftekharul Islam          }
382a489554SIftekharul Islam        });
39cd789508SIftekharul Islam      }
40*ba5e3f34SAndrew Geissler    ]);
41cd789508SIftekharul Islam
42cd789508SIftekharul Islam})(angular);
43