Bri Prebilic Cole | 96f2647 | 2015-03-31 13:07:05 -0700 | [diff] [blame] | 1 | /* |
| 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 -- Intent View Module |
| 19 | */ |
| 20 | |
| 21 | (function () { |
| 22 | 'use strict'; |
| 23 | |
| 24 | angular.module('ovIntent', []) |
| 25 | .controller('OvIntentCtrl', |
| 26 | ['$log', '$scope', 'FnService', 'WebSocketService', |
| 27 | |
| 28 | function ($log, $scope, fs, wss) { |
| 29 | var self = this; |
| 30 | self.intentData = []; |
| 31 | |
| 32 | $scope.responseCallback = function(data) { |
| 33 | self.intentData = data.intents; |
| 34 | $scope.$apply(); |
| 35 | }; |
| 36 | |
| 37 | $scope.sortCallback = function (requestParams) { |
| 38 | wss.sendEvent('intentDataRequest', requestParams); |
| 39 | }; |
| 40 | |
| 41 | var handlers = { |
| 42 | intentDataResponse: $scope.responseCallback |
| 43 | }; |
| 44 | wss.bindHandlers(handlers); |
| 45 | |
| 46 | // Cleanup on destroyed scope |
| 47 | $scope.$on('$destroy', function () { |
| 48 | wss.unbindHandlers(handlers); |
| 49 | }); |
| 50 | |
| 51 | $scope.sortCallback(); |
| 52 | |
| 53 | $log.log('OvIntentCtrl has been created'); |
| 54 | }]); |
| 55 | }()); |