Moved related stats in a standalone component
diff --git a/mCordPortal/src/app/components/related-profiles/related-profiles.js b/mCordPortal/src/app/components/related-profiles/related-profiles.js
index 1fd03dc..9fbeddc 100644
--- a/mCordPortal/src/app/components/related-profiles/related-profiles.js
+++ b/mCordPortal/src/app/components/related-profiles/related-profiles.js
@@ -32,7 +32,6 @@
});
const loadProfiles = () => {
- console.log('loadProfiles');
this.model.getProfiles()
.then((profiles) => {
this.profiles = profiles;
diff --git a/mCordPortal/src/app/components/related-stats/related-stats.js b/mCordPortal/src/app/components/related-stats/related-stats.js
new file mode 100644
index 0000000..d40f6cf
--- /dev/null
+++ b/mCordPortal/src/app/components/related-stats/related-stats.js
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+angular.module('mCord')
+ .directive('relatedStats', function () {
+ return {
+ restrict: 'E',
+ templateUrl: 'app/components/related-stats/related-stats.tpl.html',
+ scope: {
+ model: '=',
+ type: '@'
+ },
+ bindToController: true,
+ controllerAs: 'vm',
+ controller: function($scope, $filter, _){
+ $scope.$watch(() => this.model, enode => {
+ if(enode){
+ loadStats();
+ }
+ });
+
+ const loadStats = () => {
+ this.model.getStats()
+ .then((stats) => {
+ this.selectedStats = 'download_data';
+ this.stats = formatStats(stats);
+ });
+ };
+
+ const formatStats = stats => {
+ let series = _.reduce(stats, (list, s) => {
+ return list.concat([s.Profile]);
+ }, []);
+ let labels = _.reduce(stats[0].StatsArray, (list, s) => {
+ return list.concat([$filter('date')(new Date(s.Time * 1000), 'shortTime')]);
+ }, []);
+ const download_data = _.reduce(stats, (list, stat) => {
+ let bitrate = _.reduce(stat.StatsArray, (data, s) => {
+ return data.concat([s.DlBitrate]);
+ }, []);
+ list.push(bitrate);
+ return list;
+ }, []);
+ const upload_data = _.reduce(stats, (list, stat) => {
+ let bitrate = _.reduce(stat.StatsArray, (data, s) => {
+ return data.concat([s.UlBitrate]);
+ }, []);
+ list.push(bitrate);
+ return list;
+ }, []);
+ return {
+ labels: labels,
+ series: series,
+ data: download_data,
+ upload_data: upload_data,
+ download_data: download_data
+ };
+ };
+
+ this.setChart = type => {
+ if(!this.stats){
+ return;
+ }
+ this.selectedStats = type;
+ this.stats.data = this.stats[type];
+ }
+ }
+ };
+ });
diff --git a/mCordPortal/src/app/components/related-stats/related-stats.tpl.html b/mCordPortal/src/app/components/related-stats/related-stats.tpl.html
new file mode 100644
index 0000000..a7aa183
--- /dev/null
+++ b/mCordPortal/src/app/components/related-stats/related-stats.tpl.html
@@ -0,0 +1,14 @@
+<div class="row text-center">
+ <div class="col-xs-6">
+ <a ng-click="vm.setChart('download_data')"
+ ng-class="{active: vm.selectedStats == 'download_data'}"
+ class="btn btn-primary-border">Download</a>
+ </div>
+ <div class="col-xs-6">
+ <a ng-click="vm.setChart('upload_data')"
+ ng-class="{active: vm.selectedStats == 'upload_data'}"
+ class="btn btn-primary-border">Upload</a>
+ </div>
+</div>
+<canvas id="line" class="chart chart-line" chart-data="vm.stats.data"
+ chart-labels="vm.stats.labels" chart-legend="true" chart-series="vm.stats.series"></canvas>
\ No newline at end of file
diff --git a/mCordPortal/src/app/view/enode-details/e-node-details.tpl.html b/mCordPortal/src/app/view/enode-details/e-node-details.tpl.html
index a6d8452..13b91de 100644
--- a/mCordPortal/src/app/view/enode-details/e-node-details.tpl.html
+++ b/mCordPortal/src/app/view/enode-details/e-node-details.tpl.html
@@ -16,7 +16,7 @@
<related-profiles model="vm.enode"></related-profiles>
</uib-tab>
<uib-tab index="1" heading="Stats">
-
+ <related-stats model="vm.enode" type="enode"></related-stats>
</uib-tab>
</uib-tabset>
</div>
diff --git a/mCordPortal/src/app/view/enode-details/enode-details.js b/mCordPortal/src/app/view/enode-details/enode-details.js
index d05c278..51894d2 100644
--- a/mCordPortal/src/app/view/enode-details/enode-details.js
+++ b/mCordPortal/src/app/view/enode-details/enode-details.js
@@ -8,15 +8,10 @@
scope: {},
controllerAs: 'vm',
templateUrl: 'app/view/enode-details/e-node-details.tpl.html',
- controller: function($stateParams, Enodeb, NgMap){
+ controller: function($stateParams, Enodeb){
Enodeb.get({id: $stateParams.id}).$promise
.then((enode) => {
this.enode = enode;
- return NgMap.getMap();
- })
- .then((map) => {
- const center = map.getCenter();
- console.log(center.lat(), center.lng());
});
this.config = {
diff --git a/mCordPortal/src/app/view/enode-list/enode-list.js b/mCordPortal/src/app/view/enode-list/enode-list.js
index 34a280c..98dffeb 100644
--- a/mCordPortal/src/app/view/enode-list/enode-list.js
+++ b/mCordPortal/src/app/view/enode-list/enode-list.js
@@ -12,7 +12,6 @@
Enodeb.query().$promise
.then((enodes) => {
- console.log(enodes);
this.enodes = enodes;
})
diff --git a/mCordPortal/src/app/view/home/e-node-map-panel.js b/mCordPortal/src/app/view/home/e-node-map-panel.js
index 94383c1..37ca7a9 100644
--- a/mCordPortal/src/app/view/home/e-node-map-panel.js
+++ b/mCordPortal/src/app/view/home/e-node-map-panel.js
@@ -11,62 +11,10 @@
bindToController: true,
controllerAs: 'vm',
templateUrl: 'app/view/home/e-node-map-panel.tpl.html',
- controller: function($scope, $filter, _){
+ controller: function(){
this.close = () => {
delete this.eNodeB;
- }
-
- $scope.$watch(() => this.eNodeB, enode => {
- if(enode){
- loadStats();
- }
- });
-
- const loadStats = () => {
- this.eNodeB.getStats()
- .then((stats) => {
- this.selectedStats = 'download_data';
- this.stats = formatStats(stats);
- });
};
-
- const formatStats = stats => {
- let series = _.reduce(stats, (list, s) => {
- return list.concat([s.Profile]);
- }, []);
- let labels = _.reduce(stats[0].StatsArray, (list, s) => {
- return list.concat([$filter('date')(new Date(s.Time * 1000), 'shortTime')]);
- }, []);
- const download_data = _.reduce(stats, (list, stat) => {
- let bitrate = _.reduce(stat.StatsArray, (data, s) => {
- return data.concat([s.DlBitrate]);
- }, []);
- list.push(bitrate);
- return list;
- }, []);
- const upload_data = _.reduce(stats, (list, stat) => {
- let bitrate = _.reduce(stat.StatsArray, (data, s) => {
- return data.concat([s.UlBitrate]);
- }, []);
- list.push(bitrate);
- return list;
- }, []);
- return {
- labels: labels,
- series: series,
- data: download_data,
- upload_data: upload_data,
- download_data: download_data
- };
- };
-
- this.setChart = type => {
- if(!this.stats){
- return;
- }
- this.selectedStats = type;
- this.stats.data = this.stats[type];
- }
}
}
});
diff --git a/mCordPortal/src/app/view/home/e-node-map-panel.tpl.html b/mCordPortal/src/app/view/home/e-node-map-panel.tpl.html
index 393a7bc..5b4ee1a 100644
--- a/mCordPortal/src/app/view/home/e-node-map-panel.tpl.html
+++ b/mCordPortal/src/app/view/home/e-node-map-panel.tpl.html
@@ -12,7 +12,7 @@
<small>{{vm.eNodeB.Description}}</small>
</div>
<div class="col-xs-12 text-right">
- <a href="" class="btn btn-primary-border">View Details</a>
+ <a href="#/enode/{{vm.eNodeB.eNBId}}" class="btn btn-primary-border">View Details</a>
</div>
</div>
<div class="row">
@@ -42,23 +42,7 @@
<h3 class="panel-title ng-binding">Stats</h3>
</div>
<div class="panel-body">
- <div class="row text-center">
- <div class="col-xs-6">
- <a
- ng-click="vm.setChart('download_data')"
- ng-class="{active: vm.selectedStats == 'download_data'}"
- class="btn btn-primary-border">Download</a>
- </div>
- <div class="col-xs-6">
- <a
- ng-click="vm.setChart('upload_data')"
- ng-class="{active: vm.selectedStats == 'upload_data'}"
- class="btn btn-primary-border">Upload</a>
- </div>
- </div>
- <canvas id="line" class="chart chart-line" chart-data="vm.stats.data"
- chart-labels="vm.stats.labels" chart-legend="true" chart-series="vm.stats.series">
- </canvas>
+ <related-stats model="vm.eNodeB" type="enode"></related-stats>
</div>
</div>
</div>
diff --git a/mCordPortal/src/app/view/home/e-node-map.js b/mCordPortal/src/app/view/home/e-node-map.js
index 2317276..b3818e7 100644
--- a/mCordPortal/src/app/view/home/e-node-map.js
+++ b/mCordPortal/src/app/view/home/e-node-map.js
@@ -11,11 +11,13 @@
templateUrl: 'app/view/home/e-node-map.tpl.html',
controller: function($log, Enodeb, NgMap){
- let bounds = new google.maps.LatLngBounds();
+ let bounds;
Enodeb.query().$promise
.then((enodes) => {
+ console.log('loaded enodes for map');
this.enodes = enodes;
+ bounds = new google.maps.LatLngBounds();
enodes.forEach(node => {
const latlng = new google.maps.LatLng(node.GpsCoordinate.Latitude, node.GpsCoordinate.Longitude);
bounds.extend(latlng);
diff --git a/mCordPortal/src/index.html b/mCordPortal/src/index.html
index 5139a70..8de5eb9 100644
--- a/mCordPortal/src/index.html
+++ b/mCordPortal/src/index.html
@@ -62,6 +62,7 @@
<script src="dist/components/footer/footer.js"></script>
<script src="dist/components/add-enodeb/add-enodeb.js"></script>
<script src="dist/components/related-profiles/related-profiles.js"></script>
+ <script src="dist/components/related-stats/related-stats.js"></script>
<script src="dist/view/login/login.js"></script>
<script src="dist/view/home/e-node-map.js"></script>