1. Allow to work behind port forwarding
[osm/UI.git] / skyquake / plugins / composer / src / src / sources / RiftHeaderSource.js
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 // NOTE: THIS FILE HAS BEEN DEPRECATED AND WILL BE REMOVED
21
22 'use strict';
23
24 import $ from 'jquery'
25 import alt from '../alt'
26 import utils from '../libraries/utils'
27 import RiftHeaderActions from '../actions/RiftHeaderActions'
28
29 function getApiServerOrigin() {
30 return utils.getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000);
31 }
32 function ajaxRequest(path, catalogPackage, resolve, reject, method = 'GET') {
33 $.ajax({
34 url: '//' + window.location.hostname + ':' + window.location.port + path,
35 type: method,
36 beforeSend: utils.addAuthorizationStub,
37 dataType: 'json',
38 success: function(data) {
39 if (typeof data == 'string') {
40 data = JSON.parse(data);
41 }
42 resolve({
43 data: data,
44 state: catalogPackage
45 });
46 },
47 error: function(error) {
48 if (typeof error == 'string') {
49 error = JSON.parse(error);
50 }
51 reject({
52 data: error,
53 state: catalogPackage
54 });
55 }
56 });
57 }
58
59 const RiftHeaderSource = {
60
61 requestLaunchpadConfig: function () {
62 return {
63 remote: function (state, download) {
64 return new Promise((resolve, reject) => {
65 // const path = '/launchpad/config?api_server=' + utils.getSearchParams(window.location).api_server;
66 // ajaxRequest(path, download, resolve, reject);
67 resolve();
68 });
69 },
70 success: RiftHeaderActions.requestLaunchpadConfigSuccess,
71 error: RiftHeaderActions.requestLaunchpadConfigError
72 };
73 },
74 };
75
76 export default RiftHeaderSource;