2 * Copyright 2016 RIFT.IO Inc
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * STANDARD_RIFT_IO_COPYRIGHT
21 import NS_ACTIONS from './launchNetworkServiceActions.js';
22 import $ from 'jquery';
23 let Utils = require('utils/utils.js');
24 let rw = require('utils/rw.js');
25 const API_SERVER = require('utils/rw.js').getSearchParams(window.location).api_server;
26 const API_PORT = require('utils/rw.js').getSearchParams(window.location).api_port;
27 const NODE_PORT = API_PORT || 3000;
32 return new Promise((resolve,reject) => {
34 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
36 beforeSend: Utils.addAuthorizationStub,
37 success: function (data) {
39 typeof(data) == "string" ? JSON.parse(data):data
42 }).fail(function(xhr){
44 //Authentication and the handling of fail states should be wrapped up into a connection class.
45 Utils.checkAuthentication(xhr.status);
49 success: NS_ACTIONS.getCatalogSuccess,
50 error: NS_ACTIONS.getCatalogError
56 return new Promise((resolve, reject) => {
58 url: '//' + window.location.hostname + ':' +
59 NODE_PORT + '/launchpad/cloud-account?api_server=' +
62 beforeSend: Utils.addAuthorizationStub,
63 success: function (data) {
72 success: NS_ACTIONS.getCloudAccountSuccess,
73 error: NS_ACTIONS.getCloudAccountError
79 return new Promise((resolve, reject) => {
81 url: '//' + window.location.hostname + ':' +
82 NODE_PORT + '/launchpad/data-centers?api_server=' +
85 beforeSend: Utils.addAuthorizationStub,
86 success: function (data) {
92 success: NS_ACTIONS.getDataCentersSuccess,
93 error: NS_ACTIONS.getDataCentersError
98 remote (state, VNFDid) {
99 return new Promise((resolve,reject) => {
101 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/vnfd?api_server=' + API_SERVER,
103 beforeSend: Utils.addAuthorizationStub,
108 success: function (data) {
110 typeof(data) == "string" ? JSON.parse(data):data
116 success: NS_ACTIONS.getVDUSuccess,
117 error: NS_ACTIONS.getVDUError
122 remote (state, NSR) {
123 return new Promise((resolve, reject) => {
124 console.log('Attempting to instantiate NSR:', NSR)
126 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsr?api_server=' + API_SERVER,
128 beforeSend: Utils.addAuthorizationStub,
133 success: function (data) {
135 typeof(data) == "string" ? JSON.parse(data):data
138 error: function (err) {
144 loading: NS_ACTIONS.launchNSRLoading,
145 success: NS_ACTIONS.launchNSRSuccess,
146 error: NS_ACTIONS.launchNSRError
151 remote(state, NSDId) {
152 return new Promise((resolve, reject) => {
154 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsd/' + NSDId + '/input-param?api_server=' + API_SERVER,
156 beforeSend: Utils.addAuthorizationStub,
157 success: function (data) {
165 getLaunchpadConfig: function() {
168 return new Promise(function(resolve, reject) {
170 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/config?api_server=' + API_SERVER,
172 beforeSend: Utils.addAuthorizationStub,
173 success: function(data) {
179 success: NS_ACTIONS.getLaunchpadConfigSuccess,
180 error: NS_ACTIONS.getLaunchpadConfigError
186 // return new Promise((resolve,reject) => {
188 // url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
189 // success: function (data) {
191 // typeof(data) == "string" ? JSON.parse(data):data
197 // success: NS_ACTIONS.getCatalogSuccess,
198 // error: NS_ACTIONS.getCatalogError