Added the validation for name field in create pod function 81/40581/2
authorthuva4 <tharma.thuva@gmail.com>
Tue, 29 Aug 2017 10:30:58 +0000 (16:00 +0530)
committerthuva4 <tharma.thuva@gmail.com>
Wed, 30 Aug 2017 08:05:48 +0000 (13:35 +0530)
Change-Id: I18a072c7b2677794a64693135904cf97eb7b3349
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
utils/test/testapi/3rd_party/static/testapi-ui/components/pods/pods.html
utils/test/testapi/3rd_party/static/testapi-ui/components/pods/podsController.js

index cdfcfaf..7ce36ca 100644 (file)
@@ -63,7 +63,7 @@
         </tbody>
     </table>
 </div>
-
+<br>
 <div ng-show="ctrl.showError" class="alert alert-danger" role="alert">
     <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
     <span class="sr-only">Error:</span>
index 53e8b1e..2012586 100644 (file)
@@ -31,7 +31,6 @@
     function PodsController($scope, $http, $filter, $state, testapiApiUrl,
         raiseAlert) {
         var ctrl = this;
-
         ctrl.url = testapiApiUrl + '/pods';
 
         ctrl.create = create;
          */
         function create() {
             ctrl.showError = false;
-            var pods_url = ctrl.url;
-            var body = {
-                name: ctrl.name,
-                mode: ctrl.mode,
-                role: ctrl.role,
-                details: ctrl.details
-            };
 
-            ctrl.podsRequest =
-                $http.post(pods_url, body).error(function (error) {
-                    ctrl.showError = true;
-                    ctrl.error =
-                        'Error creating the new pod from server: ' +
-                        angular.toJson(error);
-                });
+            if(ctrl.name != ""){
+                var pods_url = ctrl.url;
+                var body = {
+                    name: ctrl.name,
+                    mode: ctrl.mode,
+                    role: ctrl.role,
+                    details: ctrl.details
+                };
+                ctrl.podsRequest =
+                    $http.post(pods_url, body).error(function (error) {
+                        ctrl.showError = true;
+                        ctrl.error =
+                            'Error creating the new pod from server: ' +
+                            angular.toJson(error);
+                    });
+            }
+            else{
+                ctrl.showError = true;
+                        ctrl.error = 'Name is missing.'
+            }
         }
 
         /**