Merge "run Functest daily in xci"
[releng.git] / utils / test / testapi / 3rd_party / static / testapi-ui / components / pods / podsController.js
index 53e8b1e..894fcc1 100644 (file)
@@ -20,7 +20,7 @@
         .controller('PodsController', PodsController);
 
     PodsController.$inject = [
-        '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
+        '$rootScope', '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
     ];
 
     /**
@@ -31,7 +31,6 @@
     function PodsController($scope, $http, $filter, $state, testapiApiUrl,
         raiseAlert) {
         var ctrl = this;
-
         ctrl.url = testapiApiUrl + '/pods';
 
         ctrl.create = create;
@@ -53,9 +52,6 @@
         ctrl.mode = 'metal';
         ctrl.details = '';
 
-        ctrl.pageHeader = 'Pods';
-        ctrl.pageParagraph = 'This page is used to create or query pods.';
-
         /**
          * This is called when the date filter calendar is opened. It
          * does some event handling, and sets a scope variable so the UI
          */
         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.'
+            }
         }
 
         /**