blob: 0849cdb70b93a1c38ff676265deb23f829f3d89b [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',
26 ['$log', '$scope', '$location', 'WebSocketService',
27
28 function ($log, $scope, $location, wss) {
29 var self = this;
30 self.hostData = [];
31
32 $scope.responseCallback = function(data) {
33 self.hostData = data.devices;
34 $scope.$apply();
35 };
36
37 $scope.sortCallback = function (urlSuffix) {
38 // FIXME: fix hardcoded sort params
39 if (!urlSuffix) {
40 urlSuffix = '';
41 }
42 var payload = { sortCol: 'id', sortDir: 'asc' };
43 wss.sendEvent('hostDataRequest', payload);
44 };
45
46 var handlers = {
47 hostDataResponse: $scope.responseCallback
48 };
49 wss.bindHandlers(handlers);
50
51 // Cleanup on destroyed scope
52 $scope.$on('$destroy', function () {
53 wss.unbindHandlers(handlers);
54 });
55
56 $log.log('OvHostCtrl has been created');
57
58 $scope.sortCallback();
59 }]);
60}());