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', |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 26 | ['$log', '$scope', 'TableBuilderService', 'NavService', |
Bri Prebilic Cole | 96f2647 | 2015-03-31 13:07:05 -0700 | [diff] [blame] | 27 | |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 28 | function ($log, $scope, tbs, ns) { |
Bri Prebilic Cole | 96f2647 | 2015-03-31 13:07:05 -0700 | [diff] [blame] | 29 | |
Simon Hunt | 4e41273 | 2015-10-27 15:25:39 -0700 | [diff] [blame] | 30 | function selCb($event, row) { |
| 31 | $log.debug('Got a click on:', row); |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 32 | var m = /(\d+)\s:\s(.*)/.exec(row.appId), |
| 33 | id = m ? m[1] : null, |
| 34 | name = m ? m[2] : null; |
| 35 | |
Simon Hunt | 144bd79 | 2015-10-28 11:46:36 -0700 | [diff] [blame] | 36 | $scope.intentData = ($scope.selId && m) ? { |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 37 | intentAppId: id, |
| 38 | intentAppName: name, |
| 39 | intentKey: row.key |
| 40 | } : null; |
Simon Hunt | 4e41273 | 2015-10-27 15:25:39 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | tbs.buildTable({ |
| 44 | scope: $scope, |
| 45 | tag: 'intent', |
| 46 | selCb: selCb, |
| 47 | idKey: 'key' |
| 48 | }); |
| 49 | |
| 50 | $scope.topoTip = 'Show selected intent on topology view'; |
| 51 | |
| 52 | $scope.showIntent = function () { |
Simon Hunt | 4a6b54b | 2015-10-27 22:08:25 -0700 | [diff] [blame] | 53 | var d = $scope.intentData; |
Simon Hunt | 144bd79 | 2015-10-28 11:46:36 -0700 | [diff] [blame] | 54 | d && ns.navTo('topo', d); |
Simon Hunt | 4e41273 | 2015-10-27 15:25:39 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | $log.log('OvIntentCtrl has been created'); |
| 58 | }]); |
Bri Prebilic Cole | 96f2647 | 2015-03-31 13:07:05 -0700 | [diff] [blame] | 59 | }()); |