1. Allow to work behind port forwarding
- 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>
diff --git a/skyquake/framework/utils/utils.js b/skyquake/framework/utils/utils.js
index 8a54ff3..e8e9ad1 100644
--- a/skyquake/framework/utils/utils.js
+++ b/skyquake/framework/utils/utils.js
@@ -189,7 +189,7 @@
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) {
diff --git a/skyquake/framework/widgets/JSONViewer/JSONViewer.scss b/skyquake/framework/widgets/JSONViewer/JSONViewer.scss
index 08fcefd..62495b2 100644
--- a/skyquake/framework/widgets/JSONViewer/JSONViewer.scss
+++ b/skyquake/framework/widgets/JSONViewer/JSONViewer.scss
@@ -1,4 +1,5 @@
.JSONViewer {
+ max-width: 640px;
/*
copied from node_modules/prismjs/themes/prismjs.css
*/
diff --git a/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js b/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js
index 49356a4..ae2147a 100644
--- a/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js
+++ b/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js
@@ -55,7 +55,7 @@
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 @@
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: {
diff --git a/skyquake/plugins/accounts/src/account/accountSource.js b/skyquake/plugins/accounts/src/account/accountSource.js
index b17af40..08fb9f3 100644
--- a/skyquake/plugins/accounts/src/account/accountSource.js
+++ b/skyquake/plugins/accounts/src/account/accountSource.js
@@ -38,7 +38,7 @@
return resolve(false);
}
$.ajax({
- url: '/socket-polling?api_server=' + API_SERVER ,
+ url: '/socket-polling',
type: 'POST',
beforeSend: Utils.addAuthorizationStub,
data: {
diff --git a/skyquake/plugins/composer/api/composer.js b/skyquake/plugins/composer/api/composer.js
index d83311f..ebe5636 100644
--- a/skyquake/plugins/composer/api/composer.js
+++ b/skyquake/plugins/composer/api/composer.js
@@ -312,7 +312,7 @@
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 @@
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 @@
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,
diff --git a/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js b/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js
index 95703b2..325d026 100644
--- a/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js
+++ b/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js
@@ -146,7 +146,7 @@
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 @@
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: {
diff --git a/skyquake/plugins/composer/src/src/libraries/PackageManagerApi.js b/skyquake/plugins/composer/src/src/libraries/PackageManagerApi.js
index 6b8862c..69fa4d6 100644
--- a/skyquake/plugins/composer/src/src/libraries/PackageManagerApi.js
+++ b/skyquake/plugins/composer/src/src/libraries/PackageManagerApi.js
@@ -76,7 +76,7 @@
}
new Promise(function(resolve, reject) {
$.ajax({
- url: '/socket-polling?api_server=' + API_SERVER ,
+ url: '/socket-polling',
type: 'POST',
beforeSend: Utils.addAuthorizationStub,
data: {
diff --git a/skyquake/plugins/composer/src/src/sources/RiftHeaderSource.js b/skyquake/plugins/composer/src/src/sources/RiftHeaderSource.js
index e479d33..3e61387 100644
--- a/skyquake/plugins/composer/src/src/sources/RiftHeaderSource.js
+++ b/skyquake/plugins/composer/src/src/sources/RiftHeaderSource.js
@@ -31,7 +31,7 @@
}
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',
diff --git a/skyquake/plugins/launchpad/src/createSource.js b/skyquake/plugins/launchpad/src/createSource.js
index d9271d6..6c837a7 100644
--- a/skyquake/plugins/launchpad/src/createSource.js
+++ b/skyquake/plugins/launchpad/src/createSource.js
@@ -29,7 +29,7 @@
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 @@
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 @@
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 @@
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) {
diff --git a/skyquake/plugins/launchpad/src/launchpadFleetSource.js b/skyquake/plugins/launchpad/src/launchpadFleetSource.js
index 0e9b34e..cde7116 100644
--- a/skyquake/plugins/launchpad/src/launchpadFleetSource.js
+++ b/skyquake/plugins/launchpad/src/launchpadFleetSource.js
@@ -106,7 +106,7 @@
return resolve(false);
}
$.ajax({
- url: '/socket-polling?api_server=' + API_SERVER ,
+ url: '/socket-polling',
type: 'POST',
beforeSend: Utils.addAuthorizationStub,
data: {
diff --git a/skyquake/plugins/launchpad/src/recordViewer/recordViewSource.js b/skyquake/plugins/launchpad/src/recordViewer/recordViewSource.js
index 49c3122..a3b2d67 100644
--- a/skyquake/plugins/launchpad/src/recordViewer/recordViewSource.js
+++ b/skyquake/plugins/launchpad/src/recordViewer/recordViewSource.js
@@ -94,7 +94,7 @@
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 @@
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 @@
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: {
diff --git a/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Source.js b/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Source.js
index e927984..fd38d84 100644
--- a/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Source.js
+++ b/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Source.js
@@ -41,7 +41,7 @@
return resolve(false);
}
$.ajax({
- url: '/socket-polling?api_server=' + API_SERVER ,
+ url: '/socket-polling',
type: 'POST',
beforeSend: Utils.addAuthorizationStub,
data: {
diff --git a/skyquake/plugins/launchpad/src/topologyView/topologySource.js b/skyquake/plugins/launchpad/src/topologyView/topologySource.js
index 23db982..04e1c66 100644
--- a/skyquake/plugins/launchpad/src/topologyView/topologySource.js
+++ b/skyquake/plugins/launchpad/src/topologyView/topologySource.js
@@ -42,7 +42,7 @@
return resolve(false);
}
$.ajax({
- url: '/socket-polling?api_server=' + API_SERVER ,
+ url: '/socket-polling',
type: 'POST',
beforeSend: Utils.addAuthorizationStub,
data: {
diff --git a/skyquake/plugins/launchpad/src/vnfr/vnfrSource.js b/skyquake/plugins/launchpad/src/vnfr/vnfrSource.js
index bcb8252..782f322 100644
--- a/skyquake/plugins/launchpad/src/vnfr/vnfrSource.js
+++ b/skyquake/plugins/launchpad/src/vnfr/vnfrSource.js
@@ -42,7 +42,7 @@
}
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: {
diff --git a/skyquake/skyquake.js b/skyquake/skyquake.js
index b9af78a..726757f 100644
--- a/skyquake/skyquake.js
+++ b/skyquake/skyquake.js
@@ -83,6 +83,9 @@
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 @@
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);