update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b third try
[osm/UI.git] / skyquake / plugins / launchpad / src / instantiate / launchNetworkServiceSource.js
index d2d950f..16eb884 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -46,26 +46,6 @@ export default function(Alt){
       success: Alt.actions.global.getCatalogSuccess,
       error: Alt.actions.global.getCatalogError
   },
-  getCloudAccount:{
-      remote (state, cb) {
-        return new Promise((resolve, reject) => {
-          $.ajax({
-            url: 'api/cloud-account?api_server=' +
-              API_SERVER,
-              type: 'GET',
-              beforeSend: Utils.addAuthorizationStub,
-              success: function (data) {
-                resolve(data);
-                if(cb) {
-                  cb();
-                }
-              }
-          })
-        })
-      },
-      success: Alt.actions.global.getLaunchCloudAccountSuccess,
-      error: Alt.actions.global.getLaunchCloudAccountError
-  },
   getDataCenters:{
       remote () {
         return new Promise((resolve, reject) => {
@@ -128,7 +108,7 @@ export default function(Alt){
           }).fail(function(xhr){
             //Authentication and the handling of fail states should be wrapped up into a connection class.
             Utils.checkAuthentication(xhr.status);
-            reject();
+            reject(xhr.responseText || 'An error occurred. Check your logs for more information');
           });
         })
       },
@@ -161,7 +141,7 @@ export default function(Alt){
       remote(state) {
         return new Promise((resolve, reject) => {
           $.ajax({
-            url: 'api/nsd/' + NSDId + '/input-param?api_server=' + API_SERVER,
+            url: 'api/nsd/' + encodeURIComponent(NSDId) + '/input-param?api_server=' + API_SERVER,
             type: 'GET',
               beforeSend: Utils.addAuthorizationStub,
               success: function (data) {
@@ -190,6 +170,50 @@ export default function(Alt){
       },
       success: Alt.actions.global.getConfigAgentSuccess,
       error: Alt.actions.global.getConfigAgentError
+  },
+  getResourceOrchestratorAccounts: {
+          remote: function(state, cb) {
+              return new Promise(function(resolve, reject) {
+                $.ajax({
+                  url: 'api/ro-account' + '?api_server=' + API_SERVER,
+                  type: 'GET',
+                  beforeSend: Utils.addAuthorizationStub,
+                  contentType: "application/json",
+                  success: function(data) {
+                    if(cb) {
+                      cb();
+                    }
+                    resolve(data);
+                  },
+                  error: function(error) {
+                    console.log("There was an error updating the account: ", arguments);
+
+                  }
+                }).fail(function(xhr){
+                  //Authentication and the handling of fail states should be wrapped up into a connection class.
+                  Utils.checkAuthentication(xhr.status);
+                  return reject('error');
+                });
+              });
+          },
+          interceptResponse: interceptResponse({
+            'error': 'There was an error retrieving the resource orchestrator information.'
+          }),
+          success: Alt.actions.global.getResourceOrchestratorAccountsSuccess,
+                    loading: Alt.actions.global.showScreenLoader,
+          error: Alt.actions.global.handleServerReportedError
+        }
   }
 }
+function interceptResponse (responses) {
+  return function(data, action, args) {
+    if(responses.hasOwnProperty(data)) {
+      return {
+        type: data,
+        msg: responses[data]
+      }
+    } else {
+      return data;
+    }
+  }
 }