/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
//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 = {};
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;
}, [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('<?xml'));
+ return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(imgStr);
+ } else if (/\.(svg|png|gif|jpeg|jpg)$/.test(imageString)) {
+ return '/composer/assets/logos/' + type + '/' + id + '/' + imageString;
+ // return require('../images/logos/' + imageString);
+ }
+ if(type == 'nsd' || type == 'vnfd') {
+ return require('style/img/catalog-'+type+'-default.svg');
+ }
+ return require('style/img/catalog-default.svg');
+}
+
module.exports = Utils;