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.
22 import NS_ACTIONS from './launchNetworkServiceActions.js';
23 import $ from 'jquery';
24 let Utils = require('../../utils/utils.js');
26 const API_SERVER = rw.getSearchParams(window.location).api_server;
27 const API_PORT = rw.getSearchParams(window.location).api_port;
28 const NODE_PORT = API_PORT || 3000;
33 return new Promise((resolve,reject) => {
35 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
37 beforeSend: Utils.addAuthorizationStub,
38 success: function (data) {
40 typeof(data) == "string" ? JSON.parse(data):data
43 }).fail(function(xhr){
45 //Authentication and the handling of fail states should be wrapped up into a connection class.
46 Utils.checkAuthentication(xhr.status);
50 success: NS_ACTIONS.getCatalogSuccess,
51 error: NS_ACTIONS.getCatalogError
57 return new Promise((resolve, reject) => {
59 url: '//' + window.location.hostname + ':' +
60 NODE_PORT + '/launchpad/cloud-account?api_server=' +
63 beforeSend: Utils.addAuthorizationStub,
64 success: function (data) {
73 success: NS_ACTIONS.getCloudAccountSuccess,
74 error: NS_ACTIONS.getCloudAccountError
80 return new Promise((resolve, reject) => {
82 url: '//' + window.location.hostname + ':' +
83 NODE_PORT + '/launchpad/data-centers?api_server=' +
86 beforeSend: Utils.addAuthorizationStub,
87 success: function (data) {
93 success: NS_ACTIONS.getDataCentersSuccess,
94 error: NS_ACTIONS.getDataCentersError
99 remote (state, VNFDid) {
100 return new Promise((resolve,reject) => {
102 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/vnfd?api_server=' + API_SERVER,
104 beforeSend: Utils.addAuthorizationStub,
109 success: function (data) {
111 typeof(data) == "string" ? JSON.parse(data):data
117 success: NS_ACTIONS.getVDUSuccess,
118 error: NS_ACTIONS.getVDUError
123 remote (state, NSR) {
124 return new Promise((resolve, reject) => {
125 console.log('Attempting to instantiate NSR:', NSR)
127 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsr?api_server=' + API_SERVER,
129 beforeSend: Utils.addAuthorizationStub,
134 success: function (data) {
136 typeof(data) == "string" ? JSON.parse(data):data
139 error: function (err) {
145 loading: NS_ACTIONS.launchNSRLoading,
146 success: NS_ACTIONS.launchNSRSuccess,
147 error: NS_ACTIONS.launchNSRError
152 remote(state, NSDId) {
153 return new Promise((resolve, reject) => {
155 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsd/' + NSDId + '/input-param?api_server=' + API_SERVER,
157 beforeSend: Utils.addAuthorizationStub,
158 success: function (data) {
166 getLaunchpadConfig: function() {
169 return new Promise(function(resolve, reject) {
171 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/config?api_server=' + API_SERVER,
173 beforeSend: Utils.addAuthorizationStub,
174 success: function(data) {
180 success: NS_ACTIONS.getLaunchpadConfigSuccess,
181 error: NS_ACTIONS.getLaunchpadConfigError
187 // return new Promise((resolve,reject) => {
189 // url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
190 // success: function (data) {
192 // typeof(data) == "string" ? JSON.parse(data):data
198 // success: NS_ACTIONS.getCatalogSuccess,
199 // error: NS_ACTIONS.getCatalogError