X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fframework%2Futils%2Futils.js;h=7b93fd5808e15e800b9db2fc53445f9aa5f35538;hp=d08fe5f83d1765e49d7bb676aac2936dc929f44c;hb=6bab01afa840a1f724c0ca84a3a889c5176a5133;hpb=8d06f92bda77338e7772a912ef3cde474f2a06ed diff --git a/skyquake/framework/utils/utils.js b/skyquake/framework/utils/utils.js index d08fe5f83..7b93fd580 100644 --- a/skyquake/framework/utils/utils.js +++ b/skyquake/framework/utils/utils.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,9 @@ //Login needs to be refactored. Too many cross dependencies var AuthActions = require('../widgets/login/loginAuthActions.js'); var $ = require('jquery'); -var rw = require('utils/rw.js'); +import rw from './rw.js'; var API_SERVER = rw.getSearchParams(window.location).api_server; -var NODE_PORT = 3000; +let NODE_PORT = rw.getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000); var SockJS = require('sockjs-client'); var Utils = {}; @@ -188,9 +188,20 @@ Utils.setAuthentication = function(username, password, cb) { var AuthBase64 = btoa(username + ":" + password); window.sessionStorage.setItem("auth", AuthBase64); self.detectInactivity(); - if (cb) { - cb(); - } + $.ajax({ + url: '//' + window.location.hostname + ':' + window.location.port + '/check-auth?api_server=' + API_SERVER, + type: 'GET', + beforeSend: Utils.addAuthorizationStub, + success: function(data) { + //console.log("LoggingSource.getLoggingConfig success call. data=", data); + if (cb) { + cb(); + }; + }, + error: function(data) { + Utils.clearAuthentication(); + } + }); } Utils.clearAuthentication = function(callback) { var self = this; @@ -284,4 +295,31 @@ Utils.arrayIntersperse = (arr, sep) => { }, [arr[0]]); } +Utils.cleanImageDataURI = (imageString, type, id) => { + if (/\bbase64\b/g.test(imageString)) { + return imageString; + } else if (/<\?xml\b/g.test(imageString)) { + const imgStr = imageString.substring(imageString.indexOf(' { + let displayMsg = JSON.parse(error); + if (displayMsg.errorMessage && displayMsg.errorMessage.body) { + displayMsg = displayMsg.errorMessage.body; + if(displayMsg['last-error'] && displayMsg['last-error']['rpc-error'] && displayMsg['last-error']['rpc-error']['error-message']) { + displayMsg = displayMsg['last-error']['rpc-error']['error-message']; + } + } + return displayMsg +} + module.exports = Utils;