blob: d2bab399ff757ca165a725beaddd0ed040c2f375 [file] [log] [blame]
Thomas Vachuska0fa583c2015-03-30 23:07:41 -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 -- App View Module
19 */
20
21(function () {
22 'use strict';
23
24 angular.module('ovApp', [])
25 .controller('OvAppCtrl',
26 ['$log', '$scope', '$location', 'FnService', 'WebSocketService',
27
28 function ($log, $scope, $location, fs, wss) {
29 var self = this;
30 self.appData = [];
31
32 $scope.responseCallback = function(data) {
33 self.appData = data.applications;
34 $scope.$apply();
35 };
36
37 $scope.sortCallback = function (requestParams) {
38 wss.sendEvent('appDataRequest', requestParams);
39 };
40
41 $scope.selectedAppId = null;
42 $scope.setSelected = function (appId) {
43 $scope.selectedAppId = appId;
44 };
45
46 var handlers = {
47 appDataResponse: $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 $scope.sortCallback();
57
58 $log.log('OvAppCtrl has been created');
59 }]);
60}());