1. Allow to work behind port forwarding 03/1103/1
authorGennadiy Dubina <gennadiy.dubina@dataart.com>
Mon, 13 Feb 2017 09:01:23 +0000 (11:01 +0200)
committerGennadiy Dubina <gennadiy.dubina@dataart.com>
Mon, 13 Feb 2017 09:04:00 +0000 (11:04 +0200)
   - use request's port instead of hardcoded
2. Support deployemnt separately from SO:
   - add api_server as app parameter
   - remove unnecesary using on client side

Signed-off-by: Gennadiy Dubina <gennadiy.dubina@dataart.com>
15 files changed:
skyquake/framework/utils/utils.js
skyquake/framework/widgets/JSONViewer/JSONViewer.scss
skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js
skyquake/plugins/accounts/src/account/accountSource.js
skyquake/plugins/composer/api/composer.js
skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js
skyquake/plugins/composer/src/src/libraries/PackageManagerApi.js
skyquake/plugins/composer/src/src/sources/RiftHeaderSource.js
skyquake/plugins/launchpad/src/createSource.js
skyquake/plugins/launchpad/src/launchpadFleetSource.js
skyquake/plugins/launchpad/src/recordViewer/recordViewSource.js
skyquake/plugins/launchpad/src/topologyL2View/topologyL2Source.js
skyquake/plugins/launchpad/src/topologyView/topologySource.js
skyquake/plugins/launchpad/src/vnfr/vnfrSource.js
skyquake/skyquake.js

index 8a54ff3..e8e9ad1 100644 (file)
@@ -189,7 +189,7 @@ Utils.setAuthentication = function(username, password, cb) {
     window.sessionStorage.setItem("auth", AuthBase64);
     self.detectInactivity();
     $.ajax({
-            url: '//' + window.location.hostname + ':' + NODE_PORT + '/check-auth?api_server=' + API_SERVER,
+            url: '//' + window.location.hostname + ':' + window.location.port + '/check-auth?api_server=' + API_SERVER,
             type: 'GET',
             beforeSend: Utils.addAuthorizationStub,
             success: function(data) {
index 08fcefd..62495b2 100644 (file)
@@ -1,4 +1,5 @@
 .JSONViewer {
+       max-width: 640px;
        /*
        copied from node_modules/prismjs/themes/prismjs.css
 */
index 49356a4..ae2147a 100644 (file)
@@ -55,7 +55,7 @@ export default {
             remote: function(state, recordID) {
                 return new Promise(function(resolve, reject) {
                     $.ajax({
-                        url: '//' + window.location.hostname + ':' + NODE_PORT + '/api/operational/restconf-state/streams?api_server=' + API_SERVER,
+                        url: '//' + window.location.hostname + ':' + window.location.port + '/api/operational/restconf-state/streams?api_server=' + API_SERVER,
                         type: 'GET',
                         beforeSend: Utils.addAuthorizationStub,
                         success: function(data) {
@@ -78,7 +78,7 @@ export default {
             remote: function(state, location, streamSource) {
                 return new Promise((resolve, reject) => {
                     $.ajax({
-                        url: '//' + window.location.hostname + ':' + NODE_PORT + '/socket-polling?api_server=' + API_SERVER,
+                        url: '//' + window.location.hostname + ':' + window.location.port + '/socket-polling',
                         type: 'POST',
                         beforeSend: Utils.addAuthorizationStub,
                         data: {
index b17af40..08fb9f3 100644 (file)
@@ -38,7 +38,7 @@ module.exports = function(Alt) {
                 return resolve(false);
               }
                $.ajax({
-                url: '/socket-polling?api_server=' + API_SERVER ,
+                url: '/socket-polling',
                 type: 'POST',
                 beforeSend: Utils.addAuthorizationStub,
                 data: {
index d83311f..ebe5636 100644 (file)
@@ -312,7 +312,7 @@ Composer.update = function(req) {
     var download_host = req.query['dev_download_server'];
 
     if (!download_host) {
-        download_host = api_server + ':' + utils.getPortForProtocol(req.protocol);
+        download_host = req.protocol + '://' + req.get('host');//api_server + ':' + utils.getPortForProtocol(req.protocol);
     }
     var input = {
         'external-url': download_host + '/composer/update/' + req.file.filename,
@@ -368,7 +368,7 @@ Composer.upload = function(req) {
     var download_host = req.query['dev_download_server'];
 
     if (!download_host) {
-        download_host = api_server + ':' + utils.getPortForProtocol(req.protocol);
+        download_host = req.protocol + '://' + req.get('host');//req.api_server + ':' + utils.getPortForProtocol(req.protocol);
     }
 
     return new Promise(function(resolve, reject) {
@@ -425,7 +425,7 @@ Composer.addFile = function(req) {
     var package_type = req.query['package_type'].toUpperCase();
     var package_path = req.query['package_path'];
     if (!download_host) {
-        download_host = api_server + ':' + utils.getPortForProtocol(req.protocol);
+        download_host = req.protocol + '://' + req.get('host');//api_server + ':' + utils.getPortForProtocol(req.protocol);
     }
     var input = {
         'external-url': download_host + '/composer/upload/' + req.query['package_id'] + '/' + req.file.filename,
index 95703b2..325d026 100644 (file)
@@ -146,7 +146,7 @@ const FileManagerSource = {
                 return new Promise(function(resolve, reject) {
                     //api/operational/download-jobs/job/
                    $.ajax({
-                    url: '/socket-polling?api_server=' + API_SERVER ,
+                    url: '/socket-polling',
                     type: 'POST',
                     beforeSend: Utils.addAuthorizationStub,
                     data: {
@@ -171,7 +171,7 @@ const FileManagerSource = {
                 return new Promise(function(resolve, reject) {
                     //api/operational/download-jobs/job/
                    $.ajax({
-                    url: '/socket-polling?api_server=' + API_SERVER ,
+                    url: '/socket-polling',
                     type: 'POST',
                     beforeSend: Utils.addAuthorizationStub,
                     data: {
index 6b8862c..69fa4d6 100644 (file)
@@ -76,7 +76,7 @@ export default class PackageManager {
         }
         new Promise(function(resolve, reject) {
             $.ajax({
-                url: '/socket-polling?api_server=' + API_SERVER ,
+                url: '/socket-polling',
                 type: 'POST',
                 beforeSend: Utils.addAuthorizationStub,
                 data: {
index e479d33..3e61387 100644 (file)
@@ -31,7 +31,7 @@ function getApiServerOrigin() {
 }
 function ajaxRequest(path, catalogPackage, resolve, reject, method = 'GET') {
        $.ajax({
-               url: '//' + window.location.hostname + ':' + getApiServerOrigin() + path,
+               url: '//' + window.location.hostname + ':' + window.location.port + path,
                type: method,
                beforeSend: utils.addAuthorizationStub,
                dataType: 'json',
index d9271d6..6c837a7 100644 (file)
@@ -29,7 +29,7 @@ module.exports = {
       remote: function() {
         return new Promise(function(resolve, reject) {
           $.ajax({
-            url: '//' + window.location.hostname + ':' + NODE_PORT + '/api/launchpad/network-service?api_server=' + API_SERVER,
+            url: '//' + window.location.hostname + ':' + window.location.port + '/api/launchpad/network-service?api_server=' + API_SERVER,
             type: 'GET',
             beforeSend: Utils.addAuthorizationStub,
             success: function(data) {
@@ -46,7 +46,7 @@ module.exports = {
     return {
       remote: function(state, environment) {
         return $.ajax({
-          url: '//' + window.location.hostname + ':' + NODE_PORT + '/api/launchpad/environment?api_server=' + API_SERVER,
+          url: '//' + window.location.hostname + ':' + window.location.port + '/api/launchpad/environment?api_server=' + API_SERVER,
           type: 'POST',
           beforeSend: Utils.addAuthorizationStub,
           dataType: 'json',
@@ -65,7 +65,7 @@ module.exports = {
       remote: function() {
         return new Promise(function(resolve, reject) {
           $.ajax({
-            url: '//' + window.location.hostname + ':' + NODE_PORT + '/api/launchpad/pools?api_server=' + API_SERVER,
+            url: '//' + window.location.hostname + ':' + window.location.port + '/api/launchpad/pools?api_server=' + API_SERVER,
             type: 'GET',
             beforeSend: Utils.addAuthorizationStub,
             success: function(data) {
@@ -83,7 +83,7 @@ module.exports = {
       remote: function() {
         return new Promise(function(resolve, reject) {
           $.ajax({
-            url: '//' + window.location.hostname + ':' + NODE_PORT + '/api/launchpad/sla-params?api_server=' + API_SERVER,
+            url: '//' + window.location.hostname + ':' + window.location.port + '/api/launchpad/sla-params?api_server=' + API_SERVER,
             type: 'GET',
             beforeSend: Utils.addAuthorizationStub,
             success: function(data) {
index 0e9b34e..cde7116 100644 (file)
@@ -106,7 +106,7 @@ module.exports = function(Alt) {
             return resolve(false);
           }
            $.ajax({
-            url: '/socket-polling?api_server=' + API_SERVER ,
+            url: '/socket-polling',
             type: 'POST',
             beforeSend: Utils.addAuthorizationStub,
             data: {
index 49c3122..a3b2d67 100644 (file)
@@ -94,7 +94,7 @@ export default {
                 return new Promise(function(resolve, reject) {
                     console.log('Getting NSR Socket');
                     $.ajax({
-                        url: '/socket-polling?api_server=' + API_SERVER,
+                        url: '/socket-polling',
                         type: 'POST',
                         beforeSend: Utils.addAuthorizationStub,
                         data: {
@@ -117,7 +117,7 @@ export default {
                 return new Promise(function(resolve, reject) {
                     console.log('Getting Job Socket');
                     $.ajax({
-                        url: '/socket-polling?api_server=' + API_SERVER,
+                        url: '/socket-polling',
                         type: 'POST',
                         beforeSend: Utils.addAuthorizationStub,
                         data: {
@@ -139,7 +139,7 @@ export default {
                 return new Promise(function(resolve, reject) {
                     console.log('Getting VNFR Socket for: ' + state.recordID);
                     $.ajax({
-                        url: '/socket-polling?api_server=' + API_SERVER,
+                        url: '/socket-polling',
                         type: 'POST',
                         beforeSend: Utils.addAuthorizationStub,
                         data: {
index e927984..fd38d84 100644 (file)
@@ -41,7 +41,7 @@ export default {
             return resolve(false);
           }
            $.ajax({
-            url: '/socket-polling?api_server=' + API_SERVER ,
+            url: '/socket-polling',
             type: 'POST',
             beforeSend: Utils.addAuthorizationStub,
             data: {
index 23db982..04e1c66 100644 (file)
@@ -42,7 +42,7 @@ export default {
             return resolve(false);
           }
            $.ajax({
-            url: '/socket-polling?api_server=' + API_SERVER ,
+            url: '/socket-polling',
             type: 'POST',
             beforeSend: Utils.addAuthorizationStub,
             data: {
index bcb8252..782f322 100644 (file)
@@ -42,7 +42,7 @@ export default {
           }
           console.log(nsr_id)
           $.ajax({
-            url: '//' + window.location.hostname + ':' + NODE_PORT + '/socket-polling?api_server=' + API_SERVER,
+            url: '//' + window.location.hostname + ':' + window.location.port + '/socket-polling',
             type: 'POST',
             beforeSend: Utils.addAuthorizationStub,
             data: {
index b9af78a..726757f 100644 (file)
@@ -83,6 +83,9 @@ if (cluster.isMaster && clusteredLaunch) {
 
        var sslOptions = null;
 
+       var apiServer = argv['api-server'] ? argv['api-server'] : 'localhost';
+       var uploadServer = argv['upload-server'] ? argv['upload-server'] : null;
+
        try {
                if (argv['enable-https']) {
                        var keyFilePath = argv['keyfile-path'];
@@ -194,9 +197,16 @@ if (cluster.isMaster && clusteredLaunch) {
                app.use(inactivity_routes);
 
                // Configure global config with ssl enabled/disabled
-               configurationAPI.globalConfiguration.update({
-                       ssl_enabled: httpsConfigured
-               });
+               var globalConfig = {
+                       ssl_enabled: httpsConfigured,
+                       api_server: apiServer
+               };
+
+               if (uploadServer) {
+                       globalConfig.upload_server = uploadServer;
+               }
+
+               configurationAPI.globalConfiguration.update(globalConfig);
 
                // Configure configuration route(s)
                app.use(configuration_routes);