NVP-1109 and more fixes 73/50073/1
authorElisha Oren <elisha.oren@hpe.com>
Tue, 3 Jan 2017 09:43:56 +0000 (11:43 +0200)
committerDavid Goldberg <gdavid@hpe.com>
Thu, 5 Jan 2017 16:42:26 +0000 (18:42 +0200)
Change-Id: I002595c6836b1067fe1492daafe2ec0f4329d2d2
Signed-off-by: Elisha Oren <elisha.oren@hpe.com>
dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.controller.js
dlux/cpeui/cpeui-module/src/main/resources/cpeui/admin.tpl.html
dlux/cpeui/cpeui-module/src/main/resources/cpeui/cpeui.controller.js
dlux/cpeui/cpeui-module/src/main/resources/cpeui/cpeui.module.js
dlux/cpeui/cpeui-module/src/main/resources/cpeui/dialogs/AddProfile.tpl.html
dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/cpeui.dialogs.js
dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/utils.js [new file with mode: 0644]
dlux/cpeui/cpeui-module/src/main/resources/cpeui/utils.js [deleted file]

index edcf42a2c9ac8f03d1b10ff514f1da055ad4b7e0..91bad4d7e634b15f2dd65991366acd805195e436 100644 (file)
@@ -47,24 +47,35 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
           });
         };
 
-        $scope.addProfile = new CpeuiDialogs.Dialog('AddProfile', {}, function(obj) {
-            if (obj.default_cbs) {
-                obj.cbs = Math.floor(obj.cir/10);
+        var profileDialogController = function($scope, $mdDialog) {
+
+            $scope.getDefualtCbs = function(cir) {
+                return Math.round(cir * 0.0125);
             }
+
+            $scope.done = function() {
+                if ($scope.obj.default_cbs) {
+                    $scope.obj.cbs = $scope.getDefualtCbs($scope.obj.cir);
+                }
+                if ($scope.projectForm.$valid) {
+                  $scope.callback($scope.obj);
+                  $mdDialog.hide();
+                }
+              };
+          };
+
+        $scope.addProfile = new CpeuiDialogs.Dialog('AddProfile', {}, function(obj) {
             CpeuiSvc.addProfile(obj['bw-profile'], obj.cir, obj.cbs, function() {
               $scope.updateProfilesView();
             });
-        });
+        }, profileDialogController);
 
         $scope.editProfile = function(profileName, cbs, cir) {
             new CpeuiDialogs.Dialog('AddProfile', {}, function(obj) {
-                if (obj.default_cbs) {
-                    obj.cbs = Math.floor(obj.cir/10);
-                }
                 CpeuiSvc.editProfile(obj['bw-profile'], obj.cir, obj.cbs, function() {
                   $scope.updateProfilesView();
                 });
-            }).show(null,{edit:true, profileName:profileName, cbs:cbs, cir:cir});
+            }, profileDialogController).show(null,{edit:true, profileName:profileName, cbs:cbs, cir:cir});
         };
 
         $scope.deleteProfile = function(profileName) {
index 8827a486c59d5c15367f61bd936c80e61d352fa3..3ded6f0d94a984c84e91fff7d7490ed24e5d0b63 100644 (file)
                        <thead>
                                <tr>
                                        <th>Profile Name</th>
-                                       <th>Committed Information Rate (KB/s)</th>
-                                       <th>Committed Burst Size (bytes)</th>
+                                       <th>Committed Information Rate (kb/s)</th>
+                                       <th>Committed Burst Size (Bytes)</th>
                                        <th></th>
                                </tr>
                        </thead>
index a381bcc9260b7368d32b18df88bdb6106a8b32c4..046e45786093d21c08619074ae98fd51f8897057 100644 (file)
@@ -3,6 +3,7 @@ var controllers = ['app/cpeui/cpeui.controller',
                    'app/cpeui/tenant.controller', 
                    'app/cpeui/tenantsTable.controller' ];
 var services = ['app/cpeui/services/cpeui.services',
+                'app/cpeui/services/utils',
                 'app/cpeui/services/cpeui.dialogs', ];
 var directives = [];
 var modules = [ 'app/cpeui/cpeui.module' ];
@@ -11,10 +12,6 @@ define([].concat(modules).concat(services).concat(directives).concat(controllers
 
   cpeui.controller('CpeuiCtrl', function($scope, $rootScope, $state, $mdDialog,$mdMedia) {
 
-    $rootScope['section_logo'] = 'static/cpe.png'; // Add your topbar logo
-                                                    // location here such as
-                                                    // 'assets/images/logo_topology.gif'
-
     $rootScope.section_logo = 'src/app/cpeui/static/logo_hpe.gif';
 
     var mainTabIndexs = {
index 1bf1e32ec4bf5f72b1073096a8082747ca675189..071e04b7bf435e29d8840aa063b360cb3351efdd 100644 (file)
@@ -3,11 +3,11 @@ define([ 'angularAMD', 'app/routingConfig', 'app/core/core.services',
     'app/cpeui/assets/angular-material.min',
     'app/cpeui/assets/angular-animate.min',
     'app/cpeui/assets/angular-aria.min',
-    'app/cpeui/assets/angular-messages.min', 'app/cpeui/utils' ], function(ng) {
+    'app/cpeui/assets/angular-messages.min'], function(ng) {
 
   var cpeui = angular.module('app.cpeui', [ 'app.core', 'ui.router.state','restangular', 'config', 'ngMaterial', 'ngMessages', 'ngAnimate' ]);
 
-  cpeui.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider) {
+  cpeui.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider, $urlRouterProvider) {
 
     cpeui.register = cpeui; // for adding services, controllers, directives etc.
                             // to angular module before bootstrap
@@ -19,6 +19,8 @@ define([ 'angularAMD', 'app/routingConfig', 'app/core/core.services',
       service : $provide.service
 
     };
+    
+    $urlRouterProvider.otherwise("/cpeui/admin/");
 
     NavHelperProvider.addControllerUrl('app/cpeui/cpeui.controller');
     NavHelperProvider.addToMenu('cpe', {
index c298373f6570060f4df43a8d60b6ecf1212a4899..dd2355dd2775386d109d45b20d200b60ea8816ea 100644 (file)
                                <md-content layout-padding>
                                        <md-input-container class="md-block" ng-init="obj['bw-profile'] = params.profileName">
                                                <label>Profile Name</label>
-                                               <input name="profilename" ng-model="obj['bw-profile']" ng-disabled="params.edit">
+                                               <input name="profilename" required ng-model="obj['bw-profile']" ng-disabled="params.edit">
                                                <div ng-messages="projectForm.profilename.$error">
                                                        <div ng-message="required">This is required!</div>
                                                </div>
                                        </md-input-container>
                                        <md-input-container class="md-block" ng-init="obj.cir = params.cir">
-                                               <label>Committed Information Rate (KB/s)</label>
+                                               <label>Committed Information Rate (kb/s)</label>
                                                <input type="number" required name="cir" ng-model="obj.cir" min="0">
                                                <div ng-messages="projectForm.cir.$error">
                                                        <div ng-message="required">Number is required!</div>
                                                        <div ng-message="min">Number must be positive!</div>
                                                </div>
                                        </md-input-container>
-                                       <md-checkbox name="" ng-model="obj.default_cbs" ng-init="obj.default_cbs = true">
-                                          Use default Committed Burst Size {{obj.cir ? '('+((obj.cir - (obj.cir % 10)) / 10) + ' bytes)': ''}}
+                                       <md-checkbox name="" ng-model="obj.default_cbs" ng-init="obj.default_cbs = (!params.edit || getDefualtCbs(params.cir) == params.cbs)">
+                                          Use default Committed Burst Size {{obj.cir ? ('(' + getDefualtCbs(obj.cir) + ' Bytes)') : ''}}
                                        </md-checkbox>
                                        <md-input-container class="md-block" ng-if="!obj.default_cbs" ng-init="obj.cbs = params.cbs">
-                                               <label>Committed Burst Size (bytes)</label>
+                                               <label>Committed Burst Size (Bytes)</label>
                                                <input type="number" required name="cbs" ng-model="obj.cbs" min="0">
                                                <div ng-messages="projectForm.cbs.$error">
                                                        <div ng-message="required">Number is required!</div>
index 27b52ec183b7f50ba436eaa75af284881cf3efa7..6d4a45561b07b03becd985ec11f4d86e59a66c42 100644 (file)
@@ -9,6 +9,7 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
 
       this.dialogController = function($scope, $mdDialog, params) {
         $scope.params = params;
+        $scope.callback = callback;
 
         $scope.obj = {};
         $scope.hide = function() {
@@ -19,7 +20,7 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
         };
         $scope.done = function() {
           if ($scope.projectForm.$valid) {
-            callback($scope.obj);
+            $scope.callback($scope.obj);
             $mdDialog.hide();
           }
         };
diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/utils.js b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/services/utils.js
new file mode 100644 (file)
index 0000000..c181d24
--- /dev/null
@@ -0,0 +1,11 @@
+define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
+
+  Array.prototype.filterByField = function(field_name, value, to_filter_out) {
+      if (to_filter_out == undefined) {
+          to_filter_out = false;
+      }
+      return this.filter(function(item) {
+          return (item[field_name] == value) != to_filter_out;
+      });
+  };
+});
diff --git a/dlux/cpeui/cpeui-module/src/main/resources/cpeui/utils.js b/dlux/cpeui/cpeui-module/src/main/resources/cpeui/utils.js
deleted file mode 100644 (file)
index 5eb3595..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-Array.prototype.filterByField = function(field_name, value, to_filter_out) {
-  if (to_filter_out == undefined) {
-    to_filter_out = false;
-  }
-  return this.filter(function(item) {
-    return (item[field_name] == value) != to_filter_out;
-  });
-};
\ No newline at end of file