This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/wso2/product-cep
- Loading branch information
Showing
4 changed files
with
243 additions
and
33 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
modules/distribution/repository/resources/jaggery/config/common-scripts.jag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
71 changes: 38 additions & 33 deletions
71
modules/distribution/repository/resources/jaggery/config/designer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
160
modules/distribution/repository/resources/jaggery/config/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters