X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fframework%2Fwidgets%2Fskyquake_container%2FskyquakeContainerSource.js;h=a26de2b3da433016e604b531877eed3613a50899;hb=54e4cde9338a0c798477422905cdd3b194d33a42;hp=49356a4245a135d2ba45f41feb943de4ba8103e1;hpb=05b0bf7615e179d26d14d5d40f021fa3db9142a6;p=osm%2FUI.git diff --git a/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js b/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js index 49356a424..a26de2b3d 100644 --- a/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js +++ b/skyquake/framework/widgets/skyquake_container/skyquakeContainerSource.js @@ -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: { @@ -113,6 +113,84 @@ export default { success: SkyquakeContainerActions.openNotificationsSocketSuccess, error: SkyquakeContainerActions.openNotificationsSocketError } + }, + openProjectSocket() { + return { + remote: function(state) { + return new Promise(function(resolve, reject) { + //If socket connection already exists, eat the request. + if(state.socket) { + return resolve(false); + } + $.ajax({ + url: '/socket-polling', + type: 'POST', + beforeSend: Utils.addAuthorizationStub, + data: { + url: '/project?api_server=' + API_SERVER + }, + success: function(data, textStatus, jqXHR) { + Utils.checkAndResolveSocketRequest(data, resolve, reject); + } + }) + .fail(function(xhr){ + //Authentication and the handling of fail states should be wrapped up into a connection class. + Utils.checkAuthentication(xhr.status); + });; + }); + }, + success: SkyquakeContainerActions.openProjectSocketSuccess + } + }, + + getUserProfile() { + return { + remote: function(state, recordID) { + return new Promise(function(resolve, reject) { + $.ajax({ + url: '/user-profile?api_server=' + API_SERVER, + type: 'GET', + beforeSend: Utils.addAuthorizationStub, + success: function(data) { + resolve(data); + } + }).fail(function(xhr) { + //Authentication and the handling of fail states should be wrapped up into a connection class. + Utils.checkAuthentication(xhr.status); + });; + }); + }, + 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 + } } }