Edit Profile, default burst time,draggable dialogs 45/50045/1
authorElisha Oren <elisha.oren@hpe.com>
Thu, 22 Dec 2016 15:29:40 +0000 (17:29 +0200)
committerDavid Goldberg <gdavid@hpe.com>
Thu, 5 Jan 2017 08:41:54 +0000 (10:41 +0200)
Change-Id: Iecf7544cb341a39df9e2bf0dd181d47e7468c9b5
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/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/cpeui.services.js

index 4d1426353fcf1d58e3065da622f78dfb599f6766..2dcd3bbef5ce75201faa1dec3392f6f558153299 100644 (file)
@@ -48,11 +48,25 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
         };
 
         $scope.addProfile = new CpeuiDialogs.Dialog('AddProfile', {}, function(obj) {
-          CpeuiSvc.addProfile(obj['bw-profile'], obj.cir, obj.cbs, function() {
-            $scope.updateProfilesView();
-          });
+            if (obj.default_cbs) {
+                obj.cbs = Math.floor(obj.cir/10);
+            }
+            CpeuiSvc.addProfile(obj['bw-profile'], obj.cir, obj.cbs, function() {
+              $scope.updateProfilesView();
+            });
         });
 
+        $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});
+        };
+
         $scope.deleteProfile = function(profileName) {
           CpeuiDialogs.confirm(function() {
             CpeuiSvc.deleteProfile(profileName, function() {
index c53b818ae491da7f4a4a13a7e0ed73274ee0b79c..8827a486c59d5c15367f61bd936c80e61d352fa3 100644 (file)
                        <thead>
                                <tr>
                                        <th>Profile Name</th>
-                                       <th>Committed Information Rate (Kb/s)</th>
+                                       <th>Committed Information Rate (KB/s)</th>
                                        <th>Committed Burst Size (bytes)</th>
                                        <th></th>
                                </tr>
                                        <td class="minimal-width">{{ profile.cir }}</td>
                                        <td class="minimal-width">{{ profile.cbs }}</td>
                                        <td class="delete-tr">
+                                          <button class="btn btn-md btn-info" ng-click="editProfile(profile['bw-profile'],profile.cbs,profile.cir)">
+                        <i class="icon-edit"></i>
+                        <md-tooltip>Edit Profile</md-tooltip>
+                        </button>
                                                <button class="btn btn-md btn-danger" ng-click="deleteProfile(profile['bw-profile'])">
                                                <i class="icon-trash"></i>
                                                <md-tooltip>Delete Profile</md-tooltip>
index 59b8a517492e5f822cb874e22c88605b5287d137..c298373f6570060f4df43a8d60b6ecf1212a4899 100644 (file)
@@ -1,7 +1,7 @@
 <md-dialog class="cpe-dialog" aria-label="Create Profile" ng-cloak>
        <md-toolbar>
                <div class="md-toolbar-tools">
-                       <h2>Create Profile</h2>
+                       <h2>{{params.edit ? 'Edit' : 'Create'}} Profile</h2>
                        <span flex></span>
                        <md-button class="md-icon-button" aria-label="Close dialog"
                                ng-click="cancel()"> <i class="icon-remove-sign"></i> </md-button>
                <md-dialog-content>
                        <div layout="column" ng-cloak>
                                <md-content layout-padding>
-                                       <md-input-container class="md-block">
+                                       <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']">
+                                               <input name="profilename" 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">
-                                               <label>Committed Information Rate (Kb/s)</label>
+                                       <md-input-container class="md-block" ng-init="obj.cir = params.cir">
+                                               <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-input-container class="md-block">
+                                       <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>
+                                       <md-input-container class="md-block" ng-if="!obj.default_cbs" ng-init="obj.cbs = params.cbs">
                                                <label>Committed Burst Size (bytes)</label>
                                                <input type="number" required name="cbs" ng-model="obj.cbs" min="0">
                                                <div ng-messages="projectForm.cbs.$error">
index 14706860fd83d3678e734784a7423c719e4a444a..27b52ec183b7f50ba436eaa75af284881cf3efa7 100644 (file)
@@ -41,7 +41,7 @@ define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
           locals : {
             params : params
           },
-        // onComplete: function() {$('md-dialog').draggable();}
+         onComplete: function() {$('md-dialog').draggable();}
         });
       };
     };
index 78c25809bae47d1bb8f3d6079923cb72d57dd576..cd64681cebeb77d4129f1916383080c8fbeb72b3 100644 (file)
@@ -80,6 +80,22 @@ define(['app/cpeui/cpeui.module'],function(cpeui) {
           });
       };
 
+      svc.editProfile = function(name, cir, cbs, callback){
+          $http({
+              method:'PUT',
+              url:"/restconf/config/mef-global:mef-global/profiles/ingress-bwp-flows/bwp-flow/"+name,
+              data: {"bwp-flow":{
+                      "bw-profile": name,
+                      cir: cir,
+                      cbs:cbs
+                    }}
+          }).then(function successCallback(response) {
+              if (callback != undefined) {
+                  callback();
+              }
+          });
+      };
+      
       svc.deleteProfile = function(name, callback) {
           $http({
               method:'DELETE',