blob: 8474629980b11193dae88b0d9c1863715575c683 [file] [log] [blame]
Jian Li10a20702016-02-01 16:39:51 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jian Li10a20702016-02-01 16:39:51 -08003 *
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 -- Control Plane Manager View Module
19 */
20(function () {
21 'use strict';
22
Jian Li1aa07822016-04-19 17:58:02 -070023 // injected references
24 var $log, $scope, $location, ks, fs, cbs;
Jian Li10a20702016-02-01 16:39:51 -080025
Jian Li1aa07822016-04-19 17:58:02 -070026 var labels = new Array(60);
27 var data = new Array(new Array(60), new Array(60), new Array(60),
28 new Array(60), new Array(60), new Array(60));
Jian Li10a20702016-02-01 16:39:51 -080029
Jian Li1aa07822016-04-19 17:58:02 -070030 angular.module('ovCpman', ["chart.js"])
Jian Li10a20702016-02-01 16:39:51 -080031 .controller('OvCpmanCtrl',
Jian Li1aa07822016-04-19 17:58:02 -070032 ['$log', '$scope', '$location', 'FnService', 'ChartBuilderService',
Jian Li10a20702016-02-01 16:39:51 -080033
Jian Li1aa07822016-04-19 17:58:02 -070034 function (_$log_, _$scope_, _$location_, _fs_, _cbs_) {
35 var params;
Jian Li10a20702016-02-01 16:39:51 -080036 $log = _$log_;
37 $scope = _$scope_;
Jian Li1aa07822016-04-19 17:58:02 -070038 $location = _$location_;
39 fs = _fs_;
40 cbs = _cbs_;
Jian Li10a20702016-02-01 16:39:51 -080041
Jian Li1aa07822016-04-19 17:58:02 -070042 params = $location.search();
43 if (params.hasOwnProperty('devId')) {
44 $scope.devId = params['devId'];
45 }
Jian Li10a20702016-02-01 16:39:51 -080046
Jian Li1aa07822016-04-19 17:58:02 -070047 cbs.buildChart({
48 scope: $scope,
49 tag: 'cpman',
50 query: params
Jian Li10a20702016-02-01 16:39:51 -080051 });
52
Jian Li1aa07822016-04-19 17:58:02 -070053 var idx = 0;
54 var date;
55 $scope.$watch('chartData', function () {
56 idx = 0;
57 if (!fs.isEmptyObject($scope.chartData)) {
58 $scope.chartData.forEach(function (cm) {
59 data[0][idx] = cm.inbound_packet;
60 data[1][idx] = cm.outbound_packet;
61 data[2][idx] = cm.flow_mod_packet;
62 data[3][idx] = cm.flow_removed_packet;
63 data[4][idx] = cm.request_packet;
64 data[5][idx] = cm.reply_packet;
65 date = new Date(cm.label);
66 labels[idx] = date.getHours() + ":" + date.getMinutes();
67 idx++;
68 });
69 }
70 });
71
72 $scope.series = ['INBOUND', 'OUTBOUND', 'FLOW-MOD',
73 'FLOW-REMOVED', 'STATS-REQUEST', 'STATS-REPLY'];
74 $scope.labels = labels;
75
76 $scope.data = data;
77
Jian Li10a20702016-02-01 16:39:51 -080078 $log.log('OvCpmanCtrl has been created');
79 }]);
80
81}());