Added chart
diff --git a/mCordPortal/src/app/services/helpers.js b/mCordPortal/src/app/services/helpers.js
index a46833f..c8772a2 100644
--- a/mCordPortal/src/app/services/helpers.js
+++ b/mCordPortal/src/app/services/helpers.js
@@ -15,7 +15,7 @@
*/
(function () {
- "use strict";
+ 'use strict';
angular.module('mCord')
.service('Helpers', function(){
@@ -24,6 +24,9 @@
start.getTime() + Math.random() * (end.getTime() - start.getTime())
);
}
+ })
+ .factory('_', function(){
+ return window._;
});
}());
\ No newline at end of file
diff --git a/mCordPortal/src/app/services/rest/enodeb.js b/mCordPortal/src/app/services/rest/enodeb.js
index 42cd062..e0bdfc1 100644
--- a/mCordPortal/src/app/services/rest/enodeb.js
+++ b/mCordPortal/src/app/services/rest/enodeb.js
@@ -1,6 +1,36 @@
(function () {
angular.module('mCord')
- .service('Enodeb', function($resource, baseUrl){
- return $resource(`${baseUrl}api/enodeb/:id`, {id: '@id'});
+ .service('Enodeb', function($resource, $q, $http, baseUrl){
+ const r = $resource(`${baseUrl}api/enodeb/:id`, {id: '@id'});
+
+ r.prototype.getProfiles = function(){
+ const d = $q.defer();
+
+ $http.get(`${baseUrl}api/enodeb/${this.eNBId}/profile`)
+ .then(res => {
+ d.resolve(res.data);
+ })
+ .catch(err => {
+ d.reject(err)
+ });
+
+ return d.promise;
+ };
+
+ r.prototype.getStats = function(){
+ const d = $q.defer();
+
+ $http.get(`${baseUrl}api/stats/enodeb/${this.eNBId}/10`)
+ .then(res => {
+ d.resolve(res.data);
+ })
+ .catch(err => {
+ d.reject(err)
+ });
+
+ return d.promise;
+ };
+
+ return r;
})
})();
\ No newline at end of file
diff --git a/mCordPortal/src/app/services/rest/profiles.js b/mCordPortal/src/app/services/rest/profiles.js
new file mode 100644
index 0000000..ab9fca9
--- /dev/null
+++ b/mCordPortal/src/app/services/rest/profiles.js
@@ -0,0 +1,6 @@
+(function () {
+ angular.module('mCord')
+ .service('Profile', function($resource, baseUrl){
+ return $resource(`${baseUrl}api/profile/:id`, {id: '@id'});
+ })
+})();
\ No newline at end of file
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 a78ce12..d691246 100644
--- a/mCordPortal/src/app/view/home/e-node-map-panel.js
+++ b/mCordPortal/src/app/view/home/e-node-map-panel.js
@@ -11,10 +11,66 @@
bindToController: true,
controllerAs: 'vm',
templateUrl: 'app/view/home/e-node-map-panel.tpl.html',
- controller: function($scope){
+ controller: function($scope, $filter, _){
this.close = () => {
delete this.eNodeB;
}
+
+ $scope.$watch(() => this.eNodeB, enode => {
+ if(enode){
+ loadProfiles();
+ }
+ });
+
+ const loadProfiles = () => {
+ this.eNodeB.getProfiles()
+ .then((profiles) => {
+ this.profiles = profiles;
+ return 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 6f93f24..71e2182 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
@@ -22,20 +22,20 @@
<h3 class="panel-title ng-binding">Profiles</h3>
</div>
<table class="table">
- <tr>
- <td>Profile 30</td>
- <td>30%</td>
- <td>May 12</td>
- <td>May 15</td>
+ <tr ng-repeat="profile in vm.profiles">
+ <td>{{profile.Name}}</td>
+ <td>{{profile.DlAllocRBRate}}</td>
+ <td>{{profile.Start}}</td>
+ <td>{{profile.End}}</td>
</tr>
</table>
- <div class="panel-body ng-binding">
- <div class="row">
+ <div class="panel-body">
+ <div class="row text-center">
<div class="col-xs-6">
- <div class="btn btn-primary-border">Add Profile</div>
+ <a class="btn btn-primary-border">Add Profile</a>
</div>
<div class="col-xs-6">
- <div class="btn btn-primary-border">Create Profile</div>
+ <a class="btn btn-primary-border">Create Profile</a>
</div>
</div>
</div>
@@ -48,11 +48,27 @@
<div class="panel-heading">
<h3 class="panel-title ng-binding">Stats</h3>
</div>
- <div class="panel-body ng-binding">
-
+ <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>
</div>
</div>
</div>
</div>
- <pre>{{vm.eNodeB | json}}</pre>
+ <!-- <pre>{{vm.eNodeB | json}}</pre> -->
</div>
\ No newline at end of file
diff --git a/mCordPortal/src/app/view/home/e-node-map.js b/mCordPortal/src/app/view/home/e-node-map.js
index 05b5e7e..f8361de 100644
--- a/mCordPortal/src/app/view/home/e-node-map.js
+++ b/mCordPortal/src/app/view/home/e-node-map.js
@@ -15,6 +15,7 @@
Enodeb.query().$promise
.then((enodes) => {
+ this.selectedEnode = enodes[0];
this.enodes = enodes;
enodes.forEach(node => {
const latlng = new google.maps.LatLng(node.GpsCoordinate.Latitude, node.GpsCoordinate.Longitude);