Fixed up/down link speed bug
diff --git a/views/ngXosViews/diagnostic/src/js/subscriber-modal.js b/views/ngXosViews/diagnostic/src/js/subscriber-modal.js
index 7870386..773be70 100644
--- a/views/ngXosViews/diagnostic/src/js/subscriber-modal.js
+++ b/views/ngXosViews/diagnostic/src/js/subscriber-modal.js
@@ -36,17 +36,21 @@
controllerAs: 'vm',
controller: function($log, $timeout, $scope, Subscribers){
+ const mb = 1000000;
+
$scope.$watch(() => this.open, () => {
this.success = null;
this.formError = null;
});
- $scope.$watch(() => this.subscriber, () => {
+ $scope.$watch(() => this.subscriber, (newVal, oldVal) => {
if(!this.subscriber){
return;
}
- this.subscriber.uplink_speed = parseInt(this.subscriber.uplink_speed, 10) / 1000000000;
- this.subscriber.downlink_speed = parseInt(this.subscriber.downlink_speed, 10) / 1000000000;
+ console.log(newVal, oldVal);
+ console.log('subscriber change', newVal === oldVal);
+ this.subscriber.uplink_speed = parseInt(this.subscriber.uplink_speed, 10) / mb;
+ this.subscriber.downlink_speed = parseInt(this.subscriber.downlink_speed, 10) / mb;
});
this.close = () => {
@@ -55,12 +59,16 @@
this.updateSubscriber = (subscriber) => {
- this.subscriber.uplink_speed = this.subscriber.uplink_speed * 1000000000;
- this.subscriber.downlink_speed = this.subscriber.downlink_speed * 1000000000;
+ // TODO Copy the subscriber, this will update the GUI also and we don't want
+ // TODO Change GBps to MBps
+ let body = angular.copy(subscriber, body);
- Subscribers.update(subscriber).$promise
- .then(() => {
+ body.uplink_speed = body.uplink_speed * mb;
+ body.downlink_speed = body.downlink_speed * mb;
+
+ Subscribers.update(body).$promise
+ .then((res) => {
this.success = 'Subscriber successfully updated!';
})
.catch((e) => {