blob: 19f2c076a74b8f34e7ef417c620e2fa01ccff569 [file] [log] [blame]
Bri Prebilic Cole96f26472015-03-31 13:07:05 -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 -- Intent View Module
19 */
20
21(function () {
22 'use strict';
23
24 angular.module('ovIntent', [])
25 .controller('OvIntentCtrl',
Simon Hunt4a6b54b2015-10-27 22:08:25 -070026 ['$log', '$scope', 'TableBuilderService', 'NavService',
Bri Prebilic Cole96f26472015-03-31 13:07:05 -070027
Simon Hunt4a6b54b2015-10-27 22:08:25 -070028 function ($log, $scope, tbs, ns) {
Bri Prebilic Cole96f26472015-03-31 13:07:05 -070029
Simon Hunt4e412732015-10-27 15:25:39 -070030 function selCb($event, row) {
31 $log.debug('Got a click on:', row);
Simon Hunt4a6b54b2015-10-27 22:08:25 -070032 var m = /(\d+)\s:\s(.*)/.exec(row.appId),
33 id = m ? m[1] : null,
34 name = m ? m[2] : null;
35
Simon Hunt144bd792015-10-28 11:46:36 -070036 $scope.intentData = ($scope.selId && m) ? {
Simon Hunt4a6b54b2015-10-27 22:08:25 -070037 intentAppId: id,
38 intentAppName: name,
39 intentKey: row.key
40 } : null;
Simon Hunt4e412732015-10-27 15:25:39 -070041 }
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 Hunt4a6b54b2015-10-27 22:08:25 -070053 var d = $scope.intentData;
Simon Hunt144bd792015-10-28 11:46:36 -070054 d && ns.navTo('topo', d);
Simon Hunt4e412732015-10-27 15:25:39 -070055 };
56
57 $log.log('OvIntentCtrl has been created');
58 }]);
Bri Prebilic Cole96f26472015-03-31 13:07:05 -070059}());