Fixed dev server to work both mock and real data
Fixed bugs: enodeb position, profile dates, imsi creation
Change-Id: Ic2f9a46ac129acbeeba2b35f0a1464cecc84d3db
diff --git a/mCordPortal/src/app/components/related-profiles/related-profiles.tpl.html b/mCordPortal/src/app/components/related-profiles/related-profiles.tpl.html
index 9120656..c87ba23 100644
--- a/mCordPortal/src/app/components/related-profiles/related-profiles.tpl.html
+++ b/mCordPortal/src/app/components/related-profiles/related-profiles.tpl.html
@@ -20,8 +20,8 @@
{{profile.UlAllocRBRate}}
<i class="glyphicon glyphicon-arrow-up"></i>
</td>
- <td>{{profile.Start}}</td>
- <td>{{profile.End}}</td>
+ <td>{{profile.jsStart | date:'medium'}}</td>
+ <td>{{profile.jsEnd | date:'medium'}}</td>
<td ng-if="vm.config.delete">
<a href="" ng-click="vm.deleteProfile(profile.Name)">
<i class="glyphicon glyphicon-remove"></i>
diff --git a/mCordPortal/src/app/services/helpers.js b/mCordPortal/src/app/services/helpers.js
index c8772a2..9386dd9 100644
--- a/mCordPortal/src/app/services/helpers.js
+++ b/mCordPortal/src/app/services/helpers.js
@@ -23,7 +23,26 @@
return new Date(
start.getTime() + Math.random() * (end.getTime() - start.getTime())
);
- }
+ };
+
+ this.stringToTime = (string) => {
+ let jsDate;
+ jsDate = new Date();
+
+ let [date, time] = string.split(' ');
+
+ let [day, month, year] = date.split('.');
+ let [hour, minute] = time.split(':');
+
+
+ jsDate.setYear(year);
+ jsDate.setMonth(month);
+ jsDate.setDate(day);
+ jsDate.setHours(hour);
+ jsDate.setMinutes(minute);
+
+ return jsDate;
+ };
})
.factory('_', function(){
return window._;
diff --git a/mCordPortal/src/app/services/rest/enodeb.js b/mCordPortal/src/app/services/rest/enodeb.js
index d7d0f7c..9c1d2a2 100644
--- a/mCordPortal/src/app/services/rest/enodeb.js
+++ b/mCordPortal/src/app/services/rest/enodeb.js
@@ -1,6 +1,6 @@
(function () {
angular.module('mCord')
- .service('Enodeb', function($injector, $resource, $q, $http, baseUrl){
+ .service('Enodeb', function($injector, $resource, $q, $http, baseUrl, Helpers){
const r = $resource(`${baseUrl}onos/progran/enodeb/:id`, {id: '@eNBId'}, {
//save: {method: 'PUT'},
query: {
@@ -42,6 +42,11 @@
$http.get(`${baseUrl}onos/progran/enodeb/${this.eNBId}/profile`)
.then(res => {
+ res.data = res.data.map(p => {
+ p.jsStart = Helpers.stringToTime(p.Start);
+ p.jsEnd = Helpers.stringToTime(p.End);
+ return p;
+ })
d.resolve(res.data);
})
.catch(err => {
diff --git a/mCordPortal/src/app/services/rest/profiles.js b/mCordPortal/src/app/services/rest/profiles.js
index 5a7d435..432c25a 100644
--- a/mCordPortal/src/app/services/rest/profiles.js
+++ b/mCordPortal/src/app/services/rest/profiles.js
@@ -1,6 +1,7 @@
(function () {
+
angular.module('mCord')
- .service('Profile', function($injector, $resource, $q, $http, baseUrl){
+ .service('Profile', function($injector, $resource, $q, $http, baseUrl, Helpers){
const r = $resource(`${baseUrl}onos/progran/profile/:id`, {id: '@Name'}, {
save: {
method: 'PUT'
@@ -13,7 +14,11 @@
interceptor: {
response: function(res){
const Profile = $injector.get('Profile');
- return res.data.ProfileArray.map(p => new Profile(p));
+ return res.data.ProfileArray.map(p => new Profile(p)).map(p => {
+ p.jsStart = Helpers.stringToTime(p.Start);
+ p.jsEnd = Helpers.stringToTime(p.End);
+ return p;
+ });
}
}
},
@@ -22,6 +27,8 @@
interceptor: {
response: function(res){
const Profile = $injector.get('Profile');
+ res.data.ProfileArray[0].jsStart = Helpers.stringToTime(res.data.ProfileArray[0].Start);
+ res.data.ProfileArray[0].jsEnd = Helpers.stringToTime(res.data.ProfileArray[0].End);
return new Profile(res.data.ProfileArray[0]);
}
}
@@ -42,6 +49,18 @@
return {$promise: d.promise};
};
+ r.prototype.$save = function(){
+ const d = $q.defer();
+ $http.put(`${baseUrl}onos/progran/profile/${this.Name}`, this)
+ .then(res => {
+ d.resolve(res.data);
+ })
+ .catch(err => {
+ d.reject(err)
+ });
+ return {$promise: d.promise};
+ };
+
r.prototype.getImsis = function(){
const d = $q.defer();
diff --git a/mCordPortal/src/app/view/home/e-node-map.js b/mCordPortal/src/app/view/home/e-node-map.js
index 423a5c7..0771fa7 100644
--- a/mCordPortal/src/app/view/home/e-node-map.js
+++ b/mCordPortal/src/app/view/home/e-node-map.js
@@ -18,6 +18,7 @@
this.enodes = enodes;
bounds = new google.maps.LatLngBounds();
enodes.forEach(node => {
+ console.log(node.GpsCoordinate);
if(angular.isDefined(node.GpsCoordinate.Latitude) && angular.isDefined(node.GpsCoordinate.Longitude)){
const latlng = new google.maps.LatLng(node.GpsCoordinate.Latitude, node.GpsCoordinate.Longitude);
bounds.extend(latlng);
diff --git a/mCordPortal/src/app/view/profiles-details/profiles-details.js b/mCordPortal/src/app/view/profiles-details/profiles-details.js
index b6d73a7..2affd22 100644
--- a/mCordPortal/src/app/view/profiles-details/profiles-details.js
+++ b/mCordPortal/src/app/view/profiles-details/profiles-details.js
@@ -9,7 +9,7 @@
(function () {
'use strict';
angular.module('mCord')
- .directive('profileDetails', function ($uibModal, $q) {
+ .directive('profileDetails', function ($uibModal, $q, Helpers) {
return {
restrict: 'E',
scope: {},
@@ -48,7 +48,7 @@
];
this.formConfig = {
- exclude: ['IMSIRuleArray'],
+ exclude: ['IMSIRuleArray', 'Start', 'End'],
formName: 'updateProfiles',
fields: {
Name: {
@@ -83,14 +83,16 @@
required: true
}
},
- Start: {
- type: 'date',
+ jsStart: {
+ type: 'datetime-local',
+ label: 'Start',
validator: {
required: true
}
},
- End: {
- type: 'date',
+ jsEnd: {
+ type: 'datetime-local',
+ label: 'End',
validator: {
required: true
}
@@ -177,16 +179,31 @@
label: 'Save',
icon: 'ok',
cb: (profile) => {
+ profile.Start = moment(profile.jsStart).format('DD.MM.YYYY HH:mm');
+ profile.End = moment(profile.jsEnd).format('DD.MM.YYYY HH:mm');
+
+ delete profile.jsStart;
+ delete profile.jsEnd;
+
+ let p;
if(this.isNew){
- Profile.save(profile).$promise
- .then((profile) => {
- // TODO save imsi and enodes
- // and redirect to profile list
- });
+ p = Profile.save(profile).$promise
}
else{
- profile.$save();
+ p = profile.$save().$promise;
}
+ p.then(() => {
+ profile.jsStart = Helpers.stringToTime(profile.Start);
+ profile.jsEnd = Helpers.stringToTime(profile.End);
+
+ console.log(profile);
+
+ this.formConfig.feedback = {
+ show: true,
+ message: `Profile ${profile.Name} saved!`,
+ type: 'success'
+ };
+ });
},
class: 'primary-border'
}
diff --git a/mCordPortal/src/app/view/profiles-list/profiles-list.js b/mCordPortal/src/app/view/profiles-list/profiles-list.js
index 5cfdb56..66d1530 100644
--- a/mCordPortal/src/app/view/profiles-list/profiles-list.js
+++ b/mCordPortal/src/app/view/profiles-list/profiles-list.js
@@ -48,11 +48,13 @@
},
{
label: 'Start',
- prop: 'Start'
+ prop: 'jsStart',
+ type: 'date'
},
{
label: 'End',
- prop: 'End'
+ prop: 'jsEnd',
+ type: 'date'
}
]
};