X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fframework%2Fwidgets%2Fskyquake_container%2FskyquakeContainerSource.js;h=75cfec79fe967064ad94941b090c82e3b4b31867;hp=7ea5ffcdb6c8fa76ee5b35fc696006c0d07e9663;hb=80097691f3ed0adb4406906ef619c1042c2219ea;hpb=abf00ef39ee93f2a7ff05a4432eb3a50a88a487e diff --git a/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js b/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js index 7ea5ffcdb..75cfec79f 100644 --- a/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js +++ b/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js @@ -18,13 +18,14 @@ import Alt from './skyquakeAltInstance.js'; import $ from 'jquery'; import SkyquakeContainerActions from './skyquakeContainerActions' +import rw from 'utils/rw.js'; +import Utils from 'utils/utils.js'; -let Utils = require('utils/utils.js'); -let API_SERVER = require('utils/rw.js').getSearchParams(window.location).api_server; +let API_SERVER = rw.getSearchParams(window.location).api_server; let HOST = API_SERVER; -let NODE_PORT = require('utils/rw.js').getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000); -let DEV_MODE = require('utils/rw.js').getSearchParams(window.location).dev_mode || false; -let RW_REST_API_PORT = require('utils/rw.js').getSearchParams(window.location).rw_rest_api_port || 8008; +let NODE_PORT = rw.getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000); +let DEV_MODE = rw.getSearchParams(window.location).dev_mode || false; +let RW_REST_API_PORT = rw.getSearchParams(window.location).rw_rest_api_port || 8008; if (DEV_MODE) { HOST = window.location.protocol + '//' + window.location.hostname; @@ -160,9 +161,37 @@ export default { });; }); }, + loading: Alt.actions.global.showScreenLoader, success: SkyquakeContainerActions.getUserProfileSuccess } - } + }, + selectActiveProject() { + return { + remote: function(state, event) { + let projectId; + try { + projectId = JSON.parse(JSON.parse(event.currentTarget.value)); + } catch(e) { + console.log('Something went wrong in the selectActiveProject source function', e); + } + + return new Promise(function(resolve, reject) { + $.ajax({ + url: `/session/${projectId}?api_server=${API_SERVER}`, + type: 'PUT', + beforeSend: Utils.addAuthorizationStub, + success: function(data) { + resolve(projectId); + } + }).fail(function(xhr) { + //Authentication and the handling of fail states should be wrapped up into a connection class. + Utils.checkAuthentication(xhr.status); + });; + }); + }, + success: SkyquakeContainerActions.selectActiveProjectSuccess + } + } }