Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/wso2/product-cep
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanvive committed Feb 19, 2016
2 parents 4769c99 + 42552c5 commit e065254
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%
var log = new Log();
var process = require('process');
//TODO: fix carbon module and use it
var httpPort = process.getProperty('mgt.transport.http.port');
var httpsPort = process.getProperty('mgt.transport.https.port');
if(!urlDomain && !userDomain){
urlDomain = 'carbon.super';
}

%>
<script>
ues.global.userDomain = <%=JSON.stringify(userDomain)%>;
ues.global.urlDomain = <%=JSON.stringify(urlDomain)%>;
ues.global.tenantPrefix = <%=JSON.stringify(tenantPrefix)%>;
ues.global.type = 'default';
ues.global.anon = false;
ues.global.host = <%=require('/configs/designer.json').host%>;

ues.global.context = <%=JSON.stringify(request.getContextPath())%>;
ues.global.server = {
httpPort: <%=JSON.stringify(httpPort)%>,
httpsPort: <%=JSON.stringify(httpsPort)%>
};
</script>
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
{
"store": {
"type": "fs"
},
"authentication": {
"activeMethod": "basic",
"methods": {
"sso": {
"attributes": {
"issuer": "portal",
"identityProviderURL": "https://localhost:9443/samlsso",
"responseSigningEnabled": "false",
"acs": "https://localhost:9444/portal/acs",
"identityAlias": "wso2carbon",
"useTenantKey": false
"store": {
"type": "fs"
},
"authentication": {
"activeMethod": "basic",
"methods": {
"sso": {
"attributes": {
"issuer": "portal",
"identityProviderURL": "https://localhost:9443/samlsso",
"responseSigningEnabled": "false",
"acs": "https://localhost:9444/portal/acs",
"identityAlias": "wso2carbon",
"useTenantKey": false
}
},
"basic": {
"attributes": {}
}
}
},
"basic": {
"attributes": {}
}
},
"designers": [
"Internal/everyone"
],
"tenantPrefix": "/t",
"shareStore": false,
"theme": "basic",
"cacheTimeoutSeconds": "5",
"cacheSizeBytes": "1073741824",
"defaultDashboardRedirect": false,
"isCreateGadgetEnable": true,
"oauth": {
"username": "admin",
"password": "admin"
},
"host": {
"hostname": "localhost",
"port": "",
"protocol": ""
}
},
"designers": [
"Internal/everyone"
],
"tenantPrefix": "/t",
"shareStore": false,
"theme": "basic",
"cacheTimeoutSeconds": "5",
"cacheSizeBytes": "1073741824",
"defaultDashboardRedirect": false,
"isCreateGadgetEnable": true,
"oauth": {
"username": "admin",
"password": "admin"
}
}
160 changes: 160 additions & 0 deletions modules/distribution/repository/resources/jaggery/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
(function () {

var gadgetPrefix = (osapi.container.GadgetHolder.IFRAME_ID_PREFIX_ = 'sandbox-');

var containerPrefix = 'gadget-';

var gadgets = {};

var server = ues.global.server;

var resolveURI = ues.dashboards.resolveURI;

var context = ues.global.context;

var host = ues.global.host;

var resolveGadgetURL = function (uri) {
uri = resolveURI(uri);
if (uri.match(/^https?:\/\//i)) {
return uri;
}
uri = uri.replace(/^(..\/)*/i, '');

var hostname = host.hostname ? host.hostname : window.location.hostname,
port = host.port ? host.port : window.location.port,
protocol = host.protocol ? (host.protocol + ":") : window.location.protocol;

return protocol + '//' + hostname + ":" + port + context + '/' + uri;
};

var subscribeForClient = ues.hub.subscribeForClient;

var containerId = function (id) {
return containerPrefix + id;
};

var gadgetId = function (id) {
return gadgetPrefix + containerPrefix + id;
};

ues.hub.subscribeForClient = function (container, topic, conSubId) {
var clientId = container.getClientID();
var data = gadgets[clientId];
if (!data) {
return subscribeForClient.apply(ues.hub, [container, topic, conSubId]);
}
var component = data.component;
var channel = component.id + '.' + topic;
console.log('subscribing container:%s topic:%s, channel:%s by %s', clientId, topic, channel);
return subscribeForClient.apply(ues.hub, [container, channel, conSubId]);
};

var component = (ues.plugins.components['gadget'] = {});

var hasCustomUserPrefView = function (metadata, comp) {
if(metadata.views.hasOwnProperty('settings')){
comp.hasCustomUserPrefView= true;
}
};

var hasCustomFullView = function (metadata, comp) {
if(metadata.views.hasOwnProperty('full')){
comp.hasCustomFullView= true;
}
};

var loadLocalizedTitle = function (styles, comp) {
var userLang = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage || navigator.browserLanguage);
var locale_titles = comp.content.locale_titles || {};
styles.title = locale_titles[userLang] || comp.content.title;
comp.content.locale_titles = locale_titles || {};
};

component.create = function (sandbox, comp, hub, done) {
var content = comp.content,
url = resolveGadgetURL(content.data.url),
settings = content.settings || {},
styles = content.styles || {},
options = content.options || (content.options = {});
ues.gadgets.preload(url, function (err, metadata) {
var pref,
name,
option,
params = {},
prefs = metadata.userPrefs;

for (pref in prefs) {
if (prefs.hasOwnProperty(pref)) {
pref = prefs[pref];
name = pref.name;
option = options[name] || {};
options[name] = {
type: option.type || pref.dataType,
title: option.title || pref.displayName,
value: option.value || pref.defaultValue,
options: option.options || pref.orderedEnumValues,
required: option.required || pref.required
};
params[name] = option.value;
}
}

loadLocalizedTitle(styles, comp);
var cid = containerId(comp.id),
gid = gadgetId(comp.id);

sandbox.find('.ues-component-title').text(styles.title);

if (styles.borders) {
sandbox.removeClass('ues-borderless');
} else {
sandbox.addClass('ues-borderless');
}

var titlePositon = 'ues-component-title-' + (styles.titlePosition || 'left');

sandbox.find('.ues-component-header')
.removeClass('ues-component-title-left ues-component-title-center ues-component-title-right')
.addClass(titlePositon);

if (ues.global.dbType === 'default') {
hasCustomUserPrefView(metadata, comp);
hasCustomFullView(metadata, comp);
}

var container = $('<div />').attr('id', cid);
sandbox.find('.ues-component-body').html(container);

var renderParams = {};
renderParams[osapi.container.RenderParam.HEIGHT] = sandbox.closest('.ues-component-box').height() - 66;
renderParams[osapi.container.RenderParam.VIEW] = comp.viewOption || 'home';

var site = ues.gadgets.render(container, url, params, renderParams);
gadgets[gid] = {
component: comp,
site: site
};
done(false, comp);
});
};

component.update = function (sandbox, comp, hub, done) {
component.destroy(sandbox, comp, hub, function (err) {
if (err) {
throw err;
}
component.create(sandbox, comp, hub, done);
});
};

component.destroy = function (sandbox, comp, hub, done) {
var gid = gadgetId(comp.id);
var data = gadgets[gid];
var site = data.site;
ues.gadgets.remove(site.getId());
$('.ues-component-box-gadget', sandbox).remove();
done(false);
};

}());
20 changes: 20 additions & 0 deletions modules/distribution/src/assembly/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@
</includes>
<excludes>
<exclude>**/configs/designer.json</exclude>
<exclude>**/controllers/includes/common-scripts.jag</exclude>
<exclude>**/extensions/components/gadget/index.js</exclude>
<exclude>**/js/VizGrammar.min.js</exclude>
<exclude>**/templates/gadgets/igviz/js/VizGrammar.min.js</exclude>
</excludes>
Expand Down Expand Up @@ -692,6 +694,24 @@
<fileMode>644</fileMode>
</file>

<!--Copying jaggery file for hostname fix -->
<file>
<source>repository/resources/jaggery/config/common-scripts.jag</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/portal/controllers/includes
</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>

<!--Copying jaggery file for hostname fix -->
<file>
<source>repository/resources/jaggery/config/index.js</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/portal/extensions/components/gadget
</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>

<!-- Copying the identity file -->
<file>
<source>
Expand Down

0 comments on commit e065254

Please sign in to comment.