6 import NS_ACTIONS from './launchNetworkServiceActions.js';
7 import $ from 'jquery';
8 let Utils = require('../../utils/utils.js');
10 const API_SERVER = rw.getSearchParams(window.location).api_server;
11 const API_PORT = rw.getSearchParams(window.location).api_port;
12 const NODE_PORT = API_PORT || 3000;
17 return new Promise((resolve,reject) => {
19 url: 'http://' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
21 beforeSend: Utils.addAuthorizationStub,
22 success: function (data) {
24 typeof(data) == "string" ? JSON.parse(data):data
27 }).fail(function(xhr){
29 //Authentication and the handling of fail states should be wrapped up into a connection class.
30 Utils.checkAuthentication(xhr.status);
34 success: NS_ACTIONS.getCatalogSuccess,
35 error: NS_ACTIONS.getCatalogError
41 return new Promise((resolve, reject) => {
43 url: 'http://' + window.location.hostname + ':' +
44 NODE_PORT + '/launchpad/cloud-account?api_server=' +
47 beforeSend: Utils.addAuthorizationStub,
48 success: function (data) {
57 success: NS_ACTIONS.getCloudAccountSuccess,
58 error: NS_ACTIONS.getCloudAccountError
64 return new Promise((resolve, reject) => {
66 url: 'http://' + window.location.hostname + ':' +
67 NODE_PORT + '/launchpad/data-centers?api_server=' +
70 beforeSend: Utils.addAuthorizationStub,
71 success: function (data) {
77 success: NS_ACTIONS.getDataCentersSuccess,
78 error: NS_ACTIONS.getDataCentersError
83 remote (state, VNFDid) {
84 return new Promise((resolve,reject) => {
86 url: 'http://' + window.location.hostname + ':' + NODE_PORT + '/launchpad/vnfd?api_server=' + API_SERVER,
88 beforeSend: Utils.addAuthorizationStub,
93 success: function (data) {
95 typeof(data) == "string" ? JSON.parse(data):data
101 success: NS_ACTIONS.getVDUSuccess,
102 error: NS_ACTIONS.getVDUError
107 remote (state, NSR) {
108 return new Promise((resolve, reject) => {
110 url: 'http://' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsr?api_server=' + API_SERVER,
112 beforeSend: Utils.addAuthorizationStub,
117 success: function (data) {
119 typeof(data) == "string" ? JSON.parse(data):data
122 error: function (err) {
128 loading: NS_ACTIONS.launchNSRLoading,
129 success: NS_ACTIONS.launchNSRSuccess,
130 error: NS_ACTIONS.launchNSRError
136 remote(state, NSDId) {
137 return new Promise((resolve, reject) => {
139 url: 'http://' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsd/' + NSDId + '/input-param?api_server=' + API_SERVER,
141 beforeSend: Utils.addAuthorizationStub,
142 success: function (data) {
150 getLaunchpadConfig: function() {
153 return new Promise(function(resolve, reject) {
155 url: 'http://' + window.location.hostname + ':' + NODE_PORT + '/launchpad/config?api_server=' + API_SERVER,
157 beforeSend: Utils.addAuthorizationStub,
158 success: function(data) {
164 success: NS_ACTIONS.getLaunchpadConfigSuccess,
165 error: NS_ACTIONS.getLaunchpadConfigError
172 // return new Promise((resolve,reject) => {
174 // url: 'http://' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
175 // success: function (data) {
177 // typeof(data) == "string" ? JSON.parse(data):data
183 // success: NS_ACTIONS.getCatalogSuccess,
184 // error: NS_ACTIONS.getCatalogError