blob: 378f5971e810af733ad0cb7c8ef30842837335d3 [file] [log] [blame]
Thomas Vachuskae586b792015-03-26 13:59:38 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 ONOS GUI -- Host View Module
19 */
20
21(function () {
22 'use strict';
23
24 angular.module('ovHost', [])
25 .controller('OvHostCtrl',
Bri Prebilic Cole19a32dd2015-03-26 18:00:03 -070026 ['$log', '$scope', '$location', 'FnService', 'WebSocketService',
Thomas Vachuskae586b792015-03-26 13:59:38 -070027
Bri Prebilic Cole19a32dd2015-03-26 18:00:03 -070028 function ($log, $scope, $location, fs, wss) {
Thomas Vachuskae586b792015-03-26 13:59:38 -070029 var self = this;
30 self.hostData = [];
31
32 $scope.responseCallback = function(data) {
Bri Prebilic Cole19a32dd2015-03-26 18:00:03 -070033 self.hostData = data.hosts;
Thomas Vachuskae586b792015-03-26 13:59:38 -070034 $scope.$apply();
35 };
36
Bri Prebilic Cole19a32dd2015-03-26 18:00:03 -070037 $scope.sortCallback = function (requestParams) {
38 wss.sendEvent('hostDataRequest', requestParams);
Thomas Vachuskae586b792015-03-26 13:59:38 -070039 };
40
41 var handlers = {
42 hostDataResponse: $scope.responseCallback
43 };
44 wss.bindHandlers(handlers);
45
46 // Cleanup on destroyed scope
47 $scope.$on('$destroy', function () {
48 wss.unbindHandlers(handlers);
49 });
50
Thomas Vachuskae586b792015-03-26 13:59:38 -070051 $scope.sortCallback();
Bri Prebilic Cole19a32dd2015-03-26 18:00:03 -070052
53 $log.log('OvHostCtrl has been created');
Thomas Vachuskae586b792015-03-26 13:59:38 -070054 }]);
55}());