diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml index ea7fd4b7..5a695ddd 100644 --- a/modules/distribution/src/assembly/bin.xml +++ b/modules/distribution/src/assembly/bin.xml @@ -667,6 +667,16 @@ + + + + src/repository/jaggeryapps/ues/themes + + ${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/portal/extensions/themes + + **/* + + @@ -729,6 +739,12 @@ 755 + + src/repository/jaggeryapps/ues/configs/designer.json + ${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/portal/configs + + 755 + diff --git a/modules/distribution/src/repository/jaggeryapps/ues/configs/designer.json b/modules/distribution/src/repository/jaggeryapps/ues/configs/designer.json new file mode 100644 index 00000000..a35c8441 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/configs/designer.json @@ -0,0 +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 + } + }, + "basic": { + "attributes": {} + } + } + }, + "designers": [ + "Internal/everyone" + ], + "tenantPrefix": "/t", + "shareStore": false, + "theme": "analytics", + "cacheTimeoutSeconds": "5", + "cacheSizeBytes": "1073741824", + "defaultDashboardRedirect": false, + "isCreateGadgetEnable": false, + "oauth": { + "username": "admin", + "password": "admin" + }, + "host": { + "hostname": "localhost", + "port": "", + "protocol": "" + } +} diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/module.xml b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/module.xml new file mode 100644 index 00000000..9eafb944 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/module.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/module.xml b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/module.xml new file mode 100644 index 00000000..9eafb944 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/module.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/artifacts.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/artifacts.js new file mode 100644 index 00000000..49d5f54c --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/artifacts.js @@ -0,0 +1,596 @@ +(function (server, registry) { + + var log = new Log(); + + var GenericArtifactManager = Packages.org.wso2.carbon.governance.api.generic.GenericArtifactManager; + var GenericArtifactFilter = Packages.org.wso2.carbon.governance.api.generic.GenericArtifactFilter; + var ByteArrayInputStream = Packages.java.io.ByteArrayInputStream; + var QName = Packages.javax.xml.namespace.QName; + var IOUtils = Packages.org.apache.commons.io.IOUtils; + var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext; //Used regard tenant details + var CarbonContext = Packages.org.wso2.carbon.context.CarbonContext; + var MultitenantConstants = Packages.org.wso2.carbon.utils.multitenancy.MultitenantConstants; + var List = java.util.List; + var Map = java.util.Map; + var ArrayList = java.util.ArrayList; + var HashMap = java.util.HashMap; + + var GovernanceUtils = Packages.org.wso2.carbon.governance.api.util.GovernanceUtils;//Used to obtain Asset Types + var DEFAULT_MEDIA_TYPE = 'application/vnd.wso2.registry-ext-type+xml';//Used to obtain Asset types + var PaginationContext = Packages.org.wso2.carbon.registry.core.pagination.PaginationContext;//Used for pagination on register + + var REGISTRY_ABSOLUTE_PATH = "/_system/governance"; + + var HISTORY_PATH_SEPERATOR = '_'; + var ASSET_PATH_SEPERATOR = '/'; + var lcHistoryRegExpression = new RegExp(ASSET_PATH_SEPERATOR, 'g'); + var HISTORY_PATH = '/_system/governance/_system/governance/repository/components/org.wso2.carbon.governance/lifecycles/history/'; + + + var buildArtifact = function (manager, artifact) { + return { + id: String(artifact.id), + type: String(manager.type), + path: "/_system/governance" + String(artifact.getPath()), + lifecycle: artifact.getLifecycleName(), + lifecycleState: artifact.getLifecycleState(), + mediaType: String(artifact.getMediaType()), + attributes: (function () { + var i, name, + names = artifact.getAttributeKeys(), + length = names.length, + attributes = {}; + for (i = 0; i < length; i++) { + name = names[i]; + + var data = artifact.getAttributes(name); + + //Check if there is only one element + if (data.length == 1) { + attributes[name] = String(artifact.getAttribute(name)); + } + else { + attributes[name] = data; + } + } + return attributes; + }()), + content: function () { + return new Stream(new ByteArrayInputStream(artifact.getContent())); + } + }; + }; + + var createArtifact = function (manager, options) { + var name, attribute, i, length, lc, + artifact = manager.newGovernanceArtifact(new QName(options.name)), + attributes = options.attributes; + for (name in attributes) { + if (attributes.hasOwnProperty(name)) { + attribute = attributes[name]; + if (attribute instanceof Array) { + /*length = attribute.length; + for (i = 0; i < length; i++) { + artifact.addAttribute(name, attribute[i]); + }*/ + artifact.setAttributes(name, attribute); + } else { + artifact.setAttribute(name, attribute); + } + } + } + if (options.id) { + artifact.id = options.id; + } + if (options.content) { + if (options.content instanceof Stream) { + artifact.setContent(IOUtils.toByteArray(options.content.getStream())); + } else { + artifact.setContent(new java.lang.String(options.content).getBytes()); + } + } + lc = options.lifecycles; + if (lc) { + length = lc.length; + for (i = 0; i < length; i++) { + artifact.attachLifeCycle(lc[i]); + } + } + return artifact; + }; + + var ArtifactManager = function (registry, type) { + this.registry = registry; + this.manager = new GenericArtifactManager(registry.registry.getChrootedRegistry("/_system/governance"), type); + this.type = type; + }; + registry.ArtifactManager = ArtifactManager; + + ArtifactManager.prototype.find = function (fn, paging) { + var i, length, artifacts, + artifactz = []; + artifacts = this.manager.findGenericArtifacts(new GenericArtifactFilter({ + matches: function (artifact) { + return fn(buildArtifact(this, artifact)); + } + })); + length = artifacts.length; + for (i = 0; i < length; i++) { + artifactz.push(buildArtifact(this, artifacts[i])); + } + return artifactz; + }; + + + /* + * this funtion is used ArtifactManager find with map for query for solr basicly + * query - for maping attribute of resource + * pagin - pagination details + * return - list of artifacts under the seach request + * + */ + ArtifactManager.prototype.search = function (query, paging) { + + var list, map, key, artifacts, pagination, value, that, + artifactz = []; + pagination = generatePaginationForm(paging); + try { + PaginationContext.init(pagination.start, pagination.count, pagination.sortOrder, + pagination.sortBy, pagination.paginationLimit); + map = HashMap(); + //case senstive search as it using greg with solr 1.4.1 + if (!query) { + //listing for sorting + map = java.util.Collections.emptyMap(); + } else if (query instanceof String || typeof query === 'string') { + list = new ArrayList(); + list.add('*' + query + '*'); + map.put('overview_name', list); + } else { + //support for only on name of attribut - + for (key in query) { + // if attribute is string values + if (query.hasOwnProperty(key)) { + value = query[key]; + list = new ArrayList(); + if (value instanceof Array) { + value.forEach(function (val) { + //solr config update need have '*' as first char in below line + //check life_cycle state + list.add(key == 'lcState' ? val : '*' + val + '*'); + }); + } else { + //solr config update need have '*' as first char in below line + list.add(key == 'lcState' ? value : '*' + value + '*'); + } + map.put(key, list); + } + }//end of attribut looping (all attributes) + } + artifacts = this.manager.findGenericArtifacts(map); + that = this; + artifacts.forEach(function (artifact) { + artifactz.push(buildArtifact(that, artifact)); + }); + } finally { + PaginationContext.destroy(); + } + return artifactz; + }; + + ArtifactManager.prototype.get = function (id) { + return buildArtifact(this, this.manager.getGenericArtifact(id)) + }; + + ArtifactManager.prototype.count = function () { + return this.manager.getAllGenericArtifactIds().length; + }; + + /** + * @deprecated Please use search method instead + * @param paging + * @return {*} + */ + ArtifactManager.prototype.list = function (paging) { + return this.search(null, paging); + }; + + /* + The function returns an array of asset types + @mediaType - The media type of the assets + @return An array of strings containing the asset paths + */ + ArtifactManager.prototype.getAssetTypePaths = function (mediaType) { + + //Use the default media type if one is not provided + if (!mediaType) { + mediaType = DEFAULT_MEDIA_TYPE; + } + + //var assetArray=GovernanceUtils.findGovernanceArtifacts(mediaType,this.registry); + var result = Packages.org.wso2.carbon.governance.api.util.GovernanceUtils.findGovernanceArtifacts(mediaType, registry.registry); + + return result; + //Create an empty array if no asset types are found + //return (!assetArray)?[]:assetArray; + }; + + /* + { + name: 'AndroidApp1', + attributes: { + overview_status: "CREATED", + overview_name: 'AndroidApp1', + overview_version: '1.0.0', + overview_url: 'http://overview.com', + overview_provider: 'admin', + images_thumbnail: 'http://localhost:9763/portal/gadgets/co2-emission/thumbnail.jpg', + images_banner: 'http://localhost:9763/portal/gadgets/electric-power/banner.jpg' + }, + lifecycles : ['lc1', 'lc2'], + content : '' + } + */ + ArtifactManager.prototype.add = function (options) { + var asset=createArtifact(this.manager, options); + this.manager.addGenericArtifact(asset); + return asset.getId(); + }; + + ArtifactManager.prototype.update = function (options) { + this.manager.updateGenericArtifact(createArtifact(this.manager, options)); + }; + + ArtifactManager.prototype.remove = function (id) { + this.manager.removeGenericArtifact(id); + }; + + /* + Attaches the provided lifecycle name to the artifact + @lifecycleName: The name of a valid lifecycle.The lifecycle should be visible to the + registry. + @options: The artifact to which the life cycle must be attached. + */ + ArtifactManager.prototype.attachLifecycle = function (lifecycleName, options) { + var artifact = getArtifactFromImage(this.manager, options); + if (!artifact) { + throw new Error('Specified artifact cannot be found : ' + JSON.stringify(options)); + } + artifact.attachLifecycle(lifecycleName); + }; + + /* + Removes the attached lifecycle from the artifact + @options: The artifact from which the life cycle must be removed + */ + ArtifactManager.prototype.detachLifecycle = function (options) { + var artifact = getArtifactFromImage(this.manager, options); + if (!artifact) { + throw new Error('Specified artifact cannot be found : ' + JSON.stringify(options)); + } + var lifecycleName = getLifecycleName(artifact); + artifact.detachLifecycle(lifecycleName); + }; + + /* + Promotes the artifact to the next stage in its life cycle + @options: An artifact image (Not a real artifact) + */ + ArtifactManager.prototype.promoteLifecycleState = function (state, options) { + var checkListItems, + artifact = getArtifactFromImage(this.manager, options); + if (!artifact) { + throw new Error('Specified artifact cannot be found : ' + JSON.stringify(options)); + } + //checkListItems = artifact.getAllCheckListItemNames(); + var lifecycleName = getLifecycleName(artifact); + artifact.invokeAction(state,lifecycleName); + }; + + /* + Gets the current lifecycle state + @options: An artifact object + @returns: The life cycle state + */ + ArtifactManager.prototype.getLifecycleState = function (options) { + var artifact = getArtifactFromImage(this.manager, options); + if (!artifact) { + throw new Error('Specified artifact cannot be found : ' + JSON.stringify(options)); + } + return artifact.getLifecycleState(); + }; + + /* + The function returns the list of check list items for a given state + @options: The artifact + @returns: A String array containing the check list items.(Can be empty if no check list items are present) + */ + ArtifactManager.prototype.getCheckListItemNames = function (options) { + var artifact = getArtifactFromImage(this.manager, options); + var lifecycleName = getLifecycleName(artifact); + var checkListItems = artifact.getAllCheckListItemNames(lifecycleName) || []; + + var checkListItemArray = []; + + //Go through each check list item + for (var index in checkListItems) { + //Get whether the check list item is checked + var state = artifact.isLCItemChecked(index); + checkListItemArray.push({ 'name': checkListItems[index], 'checked': state }); + } + + return checkListItemArray; + }; + + /* + The function checks whether a given check list item at the provided index is checked for the current state + @index: The index of the check list item.This must be a value between 0 and the maximum check list item + that appears in the lifecycle definition + @options: An artifact object + @throws Exception: If the index is not within 0 and the max check list item or if there is an issue ticking the item + */ + ArtifactManager.prototype.isItemChecked = function (index, options) { + + var artifact = getArtifactFromImage(this.manager, options); + var lifecycleName = getLifecycleName(artifact); + var checkListItems = artifact.getAllCheckListItemNames(); + + var checkListLength = checkListItems.length; + + if ((index < 0) || (index > checkListLength)) { + throw "The index value: " + index + " must be between 0 and " + checkListLength + ".Please refer to the lifecycle definition in the registry.xml for the number of check list items."; + } + var result = artifact.isLCItemChecked(index,lifecycleName); + + return result; + }; + + /* + The method enables the check list item and the given index + @index: The index of the check list item.This must be a value between 0 and the maximum check list item + that appears in the lifecycle definition. + @options: An artifact object + @throws Exception: If the index is not within 0 and max check list item or if there is an issue ticking the item. + */ + ArtifactManager.prototype.checkItem = function (index, options) { + + var artifact = getArtifactFromImage(this.manager, options); + var lifecycleName = getLifecycleName(artifact); + var checkListItems = artifact.getAllCheckListItemNames(); + + var checkListLength = checkListItems.length; + + if ((index < 0) || (index > checkListLength)) { + throw "The index value: " + index + " must be between 0 and " + checkListLength + ".Please refer to the lifecycle definition in the registry.xml for the number of check list items."; + } + artifact.checkLCItem(index,lifecycleName); + }; + + /* + The method disables the check list item at the given index + @index: The index of the check list item.This must be a value between 0 and the maximum check list item + that appears in the lifecycle definition + @options: An artifact object + @throws Exception: If the index is not within 0 and max check list item or if there is an issue ticking the item + */ + ArtifactManager.prototype.uncheckItem = function (index, options) { + + var artifact = getArtifactFromImage(this.manager, options); + var lifecycleName = getLifecycleName(artifact); + var checkListItems = artifact.getAllCheckListItemNames(); + + var checkListLength = checkListItems.length; + + if ((index < 0) || (index > checkListLength)) { + throw "The index value: " + index + " must be between 0 and " + checkListLength + ".Please refer to the lifecycle definition in the registry.xml for the number of check list items."; + } + artifact.uncheckLCItem(index,lifecycleName); + }; + + /* + The method obtains the list of all available actions for the current state of the asset + @options: An artifact object + @returns: The list of available actions for the current state,else false + */ + ArtifactManager.prototype.availableActions = function (options) { + var artifact = getArtifactFromImage(this.manager, options); + if (!artifact) { + throw new Error('Specified artifact cannot be found : ' + JSON.stringify(options)); + } + var lifecycleName = getLifecycleName(artifact); + return artifact.getAllLifecycleActions(lifecycleName) || []; + }; + + /* + The function returns the life-cycle history path using + the provided asset. + @options: An asset. + @return: A string path of the life-cycle history. + */ + ArtifactManager.prototype.getLifecycleHistoryPath = function (options) { + + return getHistoryPath(options.path); + }; + + /* + The function obtains the lifecycle history for the provided asset + @options: An asset with a valid path.(A path which exists in the registry + @return: A resource object containing the history as an xml + */ + ArtifactManager.prototype.getLifecycleHistory=function(options){ + var historyPath=getHistoryPath(options.path); + return this.registry.get(historyPath); + }; + + /* + The function returns the life-cycle attached to the provided artifact + @options: An asset as returned by the ArtifactManager get method + @return: A string indicating the lifecycle name.If the artifact does not + have a life-cycle then an empty string is returned. + */ + ArtifactManager.prototype.getLifeCycleName = function (options) { + + var artifact = getArtifactFromImage(this.manager, options); + + var lifecycleName = ''; + + if (artifact != null) { + lifecycleName = artifact.getLifecycleName(); + } + + return lifecycleName; + }; + + /* + The function returns all versions of the provided artifact + @options: The artifact to be checked + @return: A list of all the different versions of the provided asset + */ + ArtifactManager.prototype.getAllAssetVersions = function (assetName) { + + var matchingArtifacts = []; + + var pred = { + overview_name: assetName || '' + }; + + this.find(function (artifact) { + + //Add to the matches if the artifact exists + if (assert(artifact.attributes, pred)) { + + //We only need the id and version + matchingArtifacts.push({id: artifact.id, version: artifact.attributes.overview_version}); + } + }); + + return matchingArtifacts; + }; + + /* + The function checks if the two objects a and b are equal.If a property in b is not + in a, then both objects are assumed to be different. + @a: The object to be compared + @b: The object containing properties that must match in a + @return: True if the objects are equal,else false. + */ + var assert = function (a, b) { + + //Assume the objects will be same + var equal = true; + + for (var key in b) { + + + if (a.hasOwnProperty(key)) { + + //If the two keys are not equal + if (a[key] != b[key]) { + return false; + } + } + else { + return false; + } + } + + return equal; + }; + + /* + The function generates the history path of a given asset + using its path + @assetPath:The path of the asset to be retrieved. + @return: The path of lifecycle history information + */ + var getHistoryPath = function (assetPath) { + + //Replace the / in the assetPath + var partialHistoryPath = assetPath.replace(lcHistoryRegExpression, HISTORY_PATH_SEPERATOR); + + var fullPath = HISTORY_PATH + partialHistoryPath; + + return fullPath; + }; + + /* + generatePaginationForm will genrate json for registry pagination context, (pagination consistent handling) + @pagin:The pagination details from UI + @ + */ + var generatePaginationForm = function (pagin) { + + //pagination context for default + var paginationLimit = 300; + var paginationForm = { + 'start': 0, + 'count': 12, + 'sortOrder': 'ASC', + 'sortBy': 'overview_name', + 'paginationLimit': 2147483647 + }; + + if (!pagin) { + return paginationForm; + } + + if (pagin.count != null) { + paginationForm.count = pagin.count; + } + if (pagin.start != null) { + paginationForm.start = pagin.start; + } + if (pagin.paginationLimit != null) { + paginationForm.paginationLimit = pagin.paginationLimit; + } + if (pagin.sortBy != null) { + paginationForm.sortBy = pagin.sortBy; + } + if (paginationForm.sortOrder != null) { + paginationForm.sortOrder = pagin.sortOrder; + } + return paginationForm; + + }; + + /* + Helper function to create an artifact instance from a set of options (an image). + */ + var getArtifactFromImage = function (manager, options) { + + var path = options.path || ''; + var lcName = options.lifecycle || ''; + var artifact = createArtifact(manager, { + id: options.id, + attributes: options.attributes + }); + + path = path.replace(REGISTRY_ABSOLUTE_PATH, ''); + + artifact.setArtifactPath(path); + artifact.setLcName(lcName); + + return artifact; + }; + + /** + * The function was introduced as a fix to accomadate the goveerance API + * changes to support multiple lifecycles + * @param {Object artifact A governance artifact instance + * @return {String} The name of the default lifecycle + */ + var getLifecycleName = function(artifact){ + var lifecycleName; + if(!artifact){ + throw "The artifact is null, cannot retrieve the lifecycle name for lifecycle operations"; + } + try { + lifecycleName = artifact.getLifecycleName(); + } + catch(e){ + log.error(e); + throw e; + } + return lifecycleName; + }; +}(server, registry)); diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry-osgi.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry-osgi.js new file mode 100644 index 00000000..54c3e629 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry-osgi.js @@ -0,0 +1,452 @@ +var registry = registry || {}; + +(function (server, registry) { + var log = new Log(); + + var Resource = Packages.org.wso2.carbon.registry.core.Resource; + + var Collection = Packages.org.wso2.carbon.registry.core.Collection; + + var Comment = Packages.org.wso2.carbon.registry.core.Comment; + + var StaticConfiguration = Packages.org.wso2.carbon.registry.core.config.StaticConfiguration; + + var queryPath = '/_system/config/repository/components/org.wso2.carbon.registry/queries/'; + + var content = function (registry, resource, paging) { + if (resource instanceof Collection) { + // #1 : this always sort children by name, so sorting cannot be done for the chunk + return children(registry, resource, paging); + } + if (resource instanceof Comment) { + return String(resource.getText()); + } + try { + var stream = resource.getContentStream(); + if (stream) { + return new Stream(stream); + } + } catch (e) { + log.error(e); + //this is because getContentStream() throws an exception when content is empty + } + return String(resource.content); + }; + + var resourceSorter = function (key) { + var nameAsc = function (l, r) { + var lname, rname; + if (l instanceof Collection) { + lname = l.getName(); + lname = lname.substring(lname.lastIndexOf('/') + 1); + } else { + lname = l.name; + } + if (r instanceof Collection) { + rname = r.getName(); + rname = rname.substring(rname.lastIndexOf('/') + 1); + } else { + rname = r.name; + } + return lname === rname ? 0 : (lname > rname ? 1 : -1); + }; + switch (key) { + case 'time-created-asc' : + return function (l, r) { + return l.getCreatedTime().getTime() - r.getCreatedTime().getTime(); + }; + case 'time-created-des' : + return function (l, r) { + return r.getCreatedTime().getTime() - l.getCreatedTime().getTime(); + }; + case 'name-asc' : + return nameAsc; + case 'name-des' : + return function (l, r) { + return -nameAsc(l, r); + }; + default: + return resourceSorter('time-created-des'); + } + }; + + var children = function (registry, resource, paging) { + var resources = resource.getChildren(); + //we have to manually sort this due to the bug in registry.getChildren() (#1 above) + //resources.sort(resourceSorter(paging.sort)); + return resources.slice(paging.start, paging.start + paging.count); + }; + + var resource = function (registry, resource) { + var path = String(resource.path), + o = { + created: { + author: String(resource.authorUserName), + time: resource.createdTime.time + }, + content: content(registry, resource, { + start: 0, + count: 10 + }), + id: String(resource.id), + version: resource.versionNumber + }; + if (resource instanceof Comment) { + return o; + } + if (resource instanceof Collection) { + o.collection = (resource instanceof Collection); + } + o.uuid = String(resource.UUID); + o.path = String(path); + o.name = String(resource.name) || resolveName(path); + o.description = String(resource.description); + o.updated = { + author: String(resource.lastUpdaterUserName), + time: resource.lastModified.time + }; + o.mediaType = String(resource.mediaType); + o.properties = function () { + return properties(resource); + }; + o.aspects = function () { + return aspects(resource); + }; + return o; + }; + + var properties = function (resource) { + var prop, + properties = resource.properties, + props = properties.keySet().toArray(), + length = props.length, + o = {}; + for (var i = 0; i < length; i++) { + prop = props[i]; + o[prop] = resource.getPropertyValues(prop).toArray(); + } + return o; + }; + + var aspects = function (resource) { + var aspects = resource.getAspects(); + return aspects ? aspects.toArray() : []; + }; + + var resolveName = function (path) { + path = path.charAt(path.length - 1) === '/' ? path.substring(0, path.length - 1) : path; + return path.substring(path.lastIndexOf('/') + 1); + }; + + var merge = function (def, options) { + if (options) { + for (var op in def) { + if (def.hasOwnProperty(op)) { + def[op] = options[op] || def[op]; + } + } + } + return def; + }; + + var Registry = function (serv, options) { + var registryService = server.osgiService('org.wso2.carbon.registry.core.service.RegistryService'), + carbon = require('carbon'); + if (options) { + this.server = serv; + } else { + this.server = new server.Server(); + options = serv || {}; + } + + if (options.tenantId) { + this.tenantId = options.tenantId; + } else if (options.username || options.domain) { + this.tenantId = server.tenantId({ + domain: options.domain, + username: options.username + }); + } else { + this.tenantId = server.tenantId(); + } + + if (options.username) { + this.username = options.username; + } else if (options.system) { + this.username = carbon.user.systemUser; + } else { + this.username = carbon.user.anonUser; + } + + this.registry = registryService.getRegistry(this.username, this.tenantId); + this.versioning = { + comments: StaticConfiguration.isVersioningComments() + }; + }; + + registry.Registry = Registry; + + Registry.prototype.put = function (path, resource) { + var res; + if (resource.collection) { + res = this.registry.newCollection(); + } else { + res = this.registry.newResource(); + if (resource.content instanceof Stream) { + res.contentStream = resource.content.getStream(); + } else { + res.content = resource.content || ''; + } + res.mediaType = resource.mediaType || null; + } + res.name = resource.name; + res.description = resource.description || null; + res.UUID = resource.uuid || null; + + var values, length, i, ArrayList, + properties = resource.properties; + if (properties) { + ArrayList = java.util.ArrayList; + for (var name in properties) { + var list = new ArrayList(); + if (properties.hasOwnProperty(name)) { + values = properties[name]; + values = values instanceof Array ? values : [values]; + length = values.length; + for (i = 0; i < length; i++) { + list.add(values[i]); + } + res.setProperty(name, list); + } + } + } + + var aspects = resource.aspects; + if (aspects) { + length = aspects.length; + for (i = 0; i < length; i++) { + res.addAspect(aspects[i]); + } + } + + this.registry.put(path, res); + }; + + Registry.prototype.remove = function (path) { + this.registry.delete(path); + }; + + Registry.prototype.move = function (src, dest) { + this.registry.move(src, dest); + }; + + Registry.prototype.rename = function (current, newer) { + this.registry.rename(current, newer); + }; + + Registry.prototype.copy = function (src, dest) { + this.registry.copy(src, dest); + }; + + Registry.prototype.restore = function (path) { + this.registry.restoreVersion(path); + }; + + Registry.prototype.get = function (path) { + if (!this.exists(path)) { + return null; + } + var res = this.registry.get(path); + return resource(this, res); + }; + + Registry.prototype.exists = function (path) { + return this.registry.resourceExists(path); + }; + + Registry.prototype.content = function (path, paging) { + if (!this.exists(path)) { + return null; + } + var resource = this.registry.get(path); + paging = merge({ + start: 0, + count: 10, + sort: 'recent' + }, paging); + return content(this, resource, paging); + }; + + Registry.prototype.tags = function (path) { + var tags, i, length, + tagz = []; + tags = this.registry.getTags(path); + length = tags.length; + for (i = 0; i < length; i++) { + tagz.push(String(tags[i].tagName)); + } + return tagz; + }; + + Registry.prototype.tag = function (path, tags) { + var i, length; + tags = tags instanceof Array ? tags : [tags]; + length = tags.length; + for (i = 0; i < length; i++) { + this.registry.applyTag(path, tags[i]); + } + }; + + Registry.prototype.untag = function (path, tags) { + var i, length; + tags = tags instanceof Array ? tags : [tags]; + length = tags.length; + for (i = 0; i < length; i++) { + this.registry.removeTag(path, tags[i]); + } + }; + + Registry.prototype.associate = function (src, dest, type) { + this.registry.addAssociation(src, dest, type); + }; + + Registry.prototype.dissociate = function (src, dest, type) { + this.registry.removeAssociation(src, dest, type); + }; + + Registry.prototype.associations = function (path, type) { + var i, asso, + assos = type ? this.registry.getAssociations(path, type) : this.registry.getAllAssociations(path), + length = assos.length, + associations = []; + for (i = 0; i < length; i++) { + asso = assos[i]; + associations.push({ + type: String(asso.associationType), + src: String(asso.sourcePath), + dest: String(asso.destinationPath) + }); + } + return associations; + }; + + Registry.prototype.addProperty = function (path, name, value) { + var resource = this.registry.get(path); + resource.addProperty(name, value); + this.registry.put(path, resource); + }; + + Registry.prototype.removeProperty = function (path, name, value) { + var resource = this.registry.get(path); + (value ? resource.removePropertyValue(name, value) : resource.removeProperty(name)); + this.registry.put(path, resource); + }; + + Registry.prototype.properties = function (path) { + var resource = this.registry.get(path); + return properties(resource); + }; + + Registry.prototype.version = function (path) { + this.registry.createVersion(path); + }; + + Registry.prototype.versions = function (path) { + return this.registry.getVersions(path); + }; + + Registry.prototype.unversion = function (path, snapshot) { + this.registry.removeVersionHistory(path, snapshot); + }; + + Registry.prototype.comment = function (path, comment) { + this.registry.addComment(path, new Comment(comment)); + }; + + Registry.prototype.comments = function (path, paging) { + var i, length, comments, comment, key, + commentz = []; + paging = merge({ + start: 0, + count: 25, + sort: 'recent' + }, paging); + + comments = this.registry.getComments(path); + //we have to manually sort this due to the bug in registry.getChildren() (#1 above) + key = paging.sort; + key = (key === 'time-created-des' || key === 'time-created-asc') ? key : 'time-created-des'; + comments = comments.sort(resourceSorter(key)); + comments = comments.slice(paging.start, paging.start + paging.count); + length = comments.length; + for (i = 0; i < length; i++) { + comment = comments[i]; + commentz.push({ + content: comment.getText(), + created: { + author: comment.getUser(), + time: comment.getCreatedTime().getTime() + }, + path: comment.getCommentPath() + }); + } + return commentz; + }; + + Registry.prototype.commentCount = function (path) { + return this.registry.getComments(path).length; + }; + + Registry.prototype.uncomment = function (path) { + this.registry.removeComment(path); + }; + + Registry.prototype.rate = function (path, rating) { + this.registry.rateResource(path, rating); + }; + + Registry.prototype.unrate = function (path) { + this.registry.rateResource(path, 0); + }; + + Registry.prototype.rating = function (path, username) { + var rating = { + average: this.registry.getAverageRating(path) + }; + if (username) { + rating.user = this.registry.getRating(path, username); + } + return rating; + }; + + Registry.prototype.link = function (path, target) { + return this.registry.createLink(path, target); + }; + + Registry.prototype.unlink = function (path) { + return this.registry.removeLink(path); + }; + + Registry.prototype.search = function (query, paging) { + var res = this.registry.searchContent(query); + paging = merge({ + start: 0, + count: 10, + sort: 'recent' + }, paging); + return res ? content(this, res, paging) : []; + }; + + Registry.prototype.query = function (path, params) { + var res, name, + map = new java.util.HashMap(); + for (name in params) { + if (params.hasOwnProperty(name)) { + map.put(name, params[name]); + } + } + res = this.registry.executeQuery(path, map); + return res.getChildren(); + }; + +}(server, registry)); diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry-ws.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry-ws.js new file mode 100644 index 00000000..b79583f7 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry-ws.js @@ -0,0 +1,56 @@ +var log = new Log(); + +var Registry = function (server) { + this.server = server; +}; + +var Resource = function (name) { + +}; + +var Collection = function (name) { + +}; + +Registry.prototype.invoke = function (action, payload) { + var options, + ws = require('ws'), + client = new ws.WSRequest(), + server = this.server; + + options = { + useSOAP: 1.2, + useWSA: 1.0, + action: action, + HTTPHeaders: [ + { name: 'Cookie', value: server.cookie } + ] + }; + + try { + client.open(options, server.url + '/services/WSRegistryService', false); + client.send(payload); + return client.responseXML; + } catch (e) { + log.error(e.toString()); + throw new Error('Error while invoking action in WSRegistryService : ' + + action + ', user : ' + server.user.username); + } +}; + +Registry.prototype.putResource = function (path, resource) { + +}; + +Registry.prototype.getResource = function (path) { + var res, payload, + base64 = require('/modules/base64.js'); + + payload = + + {path} + ; + + res = this.invoke('urn:getContent', payload); + return base64.decode(String(res.*::['return'].text())); +}; \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry.js new file mode 100644 index 00000000..9a768492 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/registry/registry.js @@ -0,0 +1,24 @@ +var registry = {}; + +(function (registry) { + var ActionConstants = Packages.org.wso2.carbon.registry.core.ActionConstants, + AccessControlConstants = Packages.org.wso2.carbon.registry.core.utils.AccessControlConstants; + + registry.Registry = function (server, auth) { + var osgi = require('registry-osgi.js').registry, + o = new osgi.Registry(server, auth); + o.prototype = this; + return o; + }; + + registry.actions = {}; + + registry.actions.GET = ActionConstants.GET; + + registry.actions.PUT = ActionConstants.PUT; + + registry.actions.DELETE = ActionConstants.DELETE; + + registry.actions.AUTHORIZE = AccessControlConstants.AUTHORIZE; + +}(registry)); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/config.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/config.js new file mode 100644 index 00000000..586359d6 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/config.js @@ -0,0 +1,40 @@ +(function (server) { + var process = require('process'), + configDir = 'file:///' + process.getProperty('carbon.config.dir.path').replace(/[\\]/g, '/').replace(/^[\/]/g, '') + '/'; + server.loadConfig = function (path) { + var content, + index = path.lastIndexOf('.'), + ext = (index !== -1 && index < path.length) ? path.substring(index + 1) : '', + file = new File(configDir + path); + if (!file.isExists()) { + throw new Error('Specified config file does not exists : ' + path); + } + if (file.isDirectory()) { + throw new Error('Specified config file is a directory : ' + path); + } + file.open('r'); + content = file.readAll(); + file.close(); + switch (ext) { + case 'xml' : + return new XML(content); + case 'json' : + return parse(content); + case 'properties' : + default : + return content; + + } + }; + + server.home = 'file:///' + require('process').getProperty('carbon.home').replace(/[\\]/g, '/').replace(/^[\/]/g, ''); + + server.host = process.getProperty('server.host'); + + server.ip = process.getProperty('carbon.local.ip'); + + server.httpPort = process.getProperty('http.port'); + + server.httpsPort = process.getProperty('https.port'); + +}(server)); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/osgi.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/osgi.js new file mode 100644 index 00000000..caf57294 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/osgi.js @@ -0,0 +1,10 @@ +var server = {}; + +(function (server) { + var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext, + Class = java.lang.Class; + + server.osgiService = function (clazz) { + return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(Class.forName(clazz)); + }; +}(server)); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/server.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/server.js new file mode 100644 index 00000000..58913456 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/server.js @@ -0,0 +1,123 @@ +(function (server) { + var log = new Log(); + var process = require("process") + var login = function (url, username, password) { + var res, options, payload, + ws = require('ws'), + client = new ws.WSRequest(), + host = url.match(/.*:\/\/([^:\/]*)/)[1]; + + options = { + useSOAP: 1.2, + useWSA: 1.0, + action: 'urn:login' + }; + + payload = + + {username} + {password} + {host} + ; + + try { + client.open(options, url + '/services/AuthenticationAdmin', false); + client.send(payload); + res = client.responseXML; + if (res.*::["return"].text() != 'true') { + return false; + } + return client.getResponseHeader('Set-Cookie'); + } catch (e) { + log.error(e.toString()); + throw new Error('Error while login to the server : ' + url + ', user : ' + username); + } + }; + + var logout = function (url, cookie) { + var options, + ws = require('ws'), + client = new ws.WSRequest(); + + options = { + useSOAP: 1.2, + useWSA: 1.0, + action: 'urn:logout', + mep: 'in-only', + HTTPHeaders: [ + { name: 'Cookie', value: cookie } + ] + }; + + try { + client.open(options, url + '/services/AuthenticationAdmin', false); + client.send(null); + return true; + } catch (e) { + log.error(e.toString()); + throw new Error('Error while logging out in server : ' + url + ', cookie : ' + cookie); + } + }; + + var Cookie = function (cookie) { + this.cookie = cookie; + }; + + server.Cookie = Cookie; + + var Server = function (options) { + this.url = (options && options.url) ? options.url : 'local:/'; + }; + server.Server = Server; + + Server.prototype.authenticate = function (username, password) { + var realm, user, + carbon = require('carbon'), + realmService = server.osgiService('org.wso2.carbon.user.core.service.RealmService'); + user = carbon.server.tenantUser(username); + realm = realmService.getTenantUserRealm(user.tenantId); + return realm.getUserStoreManager().authenticate(user.username, password); + }; + + Server.prototype.login = function (username, password) { + var cookie = login(this.url, username, password); + return new Cookie(cookie); + }; + /* + Description:- If the HostName is provided in carbon.xml it will be used to return the + address with the valid port. If HostName is not mentioned -local ip will be used + to return the address. + Usage:- Scenario where the address of the server is required based on host or ip + Parameters:- Transport is https or http. + */ + server.address = function(transport){ + var host = process.getProperty('server.host'), + ip = process.getProperty('carbon.local.ip'); + var port; + if(transport=="http"){ + port = process.getProperty('mgt.transport.http.proxyPort'); + if(!port){ + //can use http.port as well + port = process.getProperty('mgt.transport.http.port'); + } + }else if(transport=="https"){ + port = process.getProperty('mgt.transport.https.proxyPort'); + if(!port){ + //can use https.port as well + port = process.getProperty('mgt.transport.https.port'); + } + } + var postUrl; + if(host==null || host=="localhost"){ + postUrl = transport+"://" + ip + ":" + port; + }else{ + postUrl = transport+"://" + host+ ":" +port; + } + return postUrl; + } + + + Server.prototype.logout = function (cookie) { + return logout(this.url, cookie.cookie); + }; +}(server)); diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/tenant.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/tenant.js new file mode 100644 index 00000000..d6f498b0 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/server/tenant.js @@ -0,0 +1,69 @@ +(function (server) { + var log = new Log(), + PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext, + MultitenantConstants = Packages.org.wso2.carbon.utils.multitenancy.MultitenantConstants, + MultitenantUtils = Packages.org.wso2.carbon.utils.multitenancy.MultitenantUtils, + realmService = server.osgiService('org.wso2.carbon.user.core.service.RealmService'), + tenantManager = realmService.getTenantManager(); + + server.tenantDomain = function (options) { + if (!options) { + return PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + } + if (options.tenantId) { + return tenantManager.getDomain(options.tenantId); + } + if (options.username) { + return MultitenantUtils.getTenantDomain(options.username); + } + if (options.url) { + return MultitenantUtils.getTenantDomainFromRequestURL(options.url); + } + return null; + }; + + server.tenantId = function (options) { + var domain = options ? (options.domain || server.tenantDomain(options)) : server.tenantDomain(); + return domain ? tenantManager.getTenantId(domain) : null; + }; + + server.tenantUser = function (username) { + var domain = server.tenantDomain({ + username: username + }), + id = server.tenantId({ + domain: domain + }); + username = MultitenantUtils.getTenantAwareUsername(username); + return { + domain: domain, + username: username, + tenantId: id + }; + }; + + server.superTenant = { + tenantId: MultitenantConstants.SUPER_TENANT_ID, + domain: MultitenantConstants.SUPER_TENANT_DOMAIN_NAME + }; + + server.sandbox = function (options, fn) { + var context, + PrivilegedCarbonContext = org.wso2.carbon.context.PrivilegedCarbonContext; + PrivilegedCarbonContext.startTenantFlow(); + log.debug('startTenantFlow'); + try { + context = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + context.setTenantDomain(server.tenantDomain({ + tenantId: options.tenantId + })); + context.setTenantId(options.tenantId); + context.setUsername(options.username || null); + return fn(); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + log.debug('endTenantFlow'); + } + }; + +}(server)); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/registry-space.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/registry-space.js new file mode 100644 index 00000000..0fa8e564 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/registry-space.js @@ -0,0 +1,39 @@ +(function (server, registry, user) { + + var Space = function (user, space, options) { + var serv = new server.Server(options.serverUrl); + this.registry = new registry.Registry(serv, { + username: options.username || user, + domain: options.domain || server.tenantDomain() + }); + this.prefix = options.path + '/' + user + '/' + space; + if (!this.registry.exists(this.prefix)) { + this.registry.put(this.prefix, { + collection: true + }); + } + }; + user.Space = Space; + + Space.prototype.put = function (key, value) { + value = (!(value instanceof String) && typeof value !== "string") ? stringify(value) : value; + this.registry.put(this.prefix + '/' + key, { + content: value + }); + }; + + Space.prototype.get = function (key) { + var o = this.registry.content(this.prefix + '/' + key); + return o ? o.toString() : null; + }; + + Space.prototype.remove = function (key) { + this.registry.remove(this.prefix + '/' + key); + }; + + Space.prototype.find = function (filter) { + + }; + + +}(server, registry, user)); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/space.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/space.js new file mode 100644 index 00000000..1b7a996a --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/space.js @@ -0,0 +1,10 @@ +(function (server, user) { + + user.Space = function (user, space, options) { + var reg = require('registry-space.js').user, + o = new reg.Space(user, space, options); + o.prototype = this; + return o; + }; + +}(server, user)); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/user-manager.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/user-manager.js new file mode 100644 index 00000000..531f831c --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/user-manager.js @@ -0,0 +1,179 @@ +(function (server, user) { + + var log = new Log(); + + var processPerms = function (perms, fn) { + var perm, actions, i, length; + for (perm in perms) { + if (perms.hasOwnProperty(perm)) { + actions = perms[perm]; + length = actions.length; + for (i = 0; i < length; i++) { + fn(perm, actions[i]); + } + } + } + }; + + var UserManager = function (serv, tenantId) { + this.server = serv; + this.tenantId = tenantId || server.superTenant.tenantId; + var realmService = server.osgiService('org.wso2.carbon.user.core.service.RealmService'), + realm = realmService.getTenantUserRealm(this.tenantId); + this.manager = realm.getUserStoreManager(); + this.authorizer = realm.getAuthorizationManager(); + }; + user.UserManager = UserManager; + + UserManager.prototype.getUser = function (username) { + if (!this.manager.isExistingUser(username)) { + return null; + } + return new user.User(this, username); + }; + UserManager.prototype.getRoleListOfUser = function (username) { + return this.manager.getRoleListOfUser(username); + }; + UserManager.prototype.addUser = function (username, password, roles, claims, profile) { + this.manager.addUser(username, password, roles || [], claims || null, profile); + }; + UserManager.prototype.changePassword = function (username, newPassword, oldPassword) { + this.manager.updateCredential(username, newPassword, oldPassword); + }; + + UserManager.prototype.removeUser = function (username) { + this.manager.deleteUser(username); + }; + + UserManager.prototype.userExists = function (username) { + return this.manager.isExistingUser(username); + }; + + UserManager.prototype.roleExists = function (role) { + return this.manager.isExistingRole(role); + }; + UserManager.prototype.updateRole = function (previousRoleName, newRoleName) { + return this.manager.updateRoleName(previousRoleName, newRoleName); + }; + UserManager.prototype.getClaims = function (username, profile) { + return this.manager.getUserClaimValues(username, profile); + }; + UserManager.prototype.getClaimsForSet = function (username,claims, profile) { + return this.manager.getUserClaimValues(username,claims, profile); + }; + UserManager.prototype.getClaim = function (username, claim, profile) { + return this.manager.getUserClaimValue(username, claim, profile); + }; + + UserManager.prototype.setClaims = function (username, claims, profile) { + return this.manager.setUserClaimValues(username, claims, profile); + }; + + UserManager.prototype.setClaim = function (username, claim, value, profile) { + return this.manager.setUserClaimValue(username, claim, value, profile); + }; + + UserManager.prototype.isAuthorized = function (role, permission, action) { + return this.authorizer.isRoleAuthorized(role, permission, action); + }; + UserManager.prototype.updateRoleListOfUser = function(name, deletedRoles, newRoles){ + return this.manager.updateRoleListOfUser(name, deletedRoles, newRoles); + }; + UserManager.prototype.updateUserListOfRole = function(name, deletedUsers, newUsers){ + return this.manager.updateUserListOfRole(name, deletedUsers, newUsers); + }; + UserManager.prototype.listUsers = function (filter) { + if(filter){ + return this.manager.listUsers(filter, -1); + }else{ + return this.manager.listUsers("*", -1); + } + }; + UserManager.prototype.addRole = function (role, users, permissions) { + var perms = [], + Permission = Packages.org.wso2.carbon.user.api.Permission; + processPerms(permissions, function (id, action) { + perms.push(new Permission(id, action)); + }); + this.manager['addRole(java.lang.String,java.lang.String[],org.wso2.carbon.user.api.Permission[])'] + (role, users, perms); + }; + UserManager.prototype.clearResourceAuthorizations = function (resource) { + this.authorizer.clearResourceAuthorizations(resource) + }; + + UserManager.prototype.removeRole = function (role) { + this.manager.deleteRole(role); + }; + + UserManager.prototype.allRoles = function () { + return this.manager.getRoleNames(); + }; + UserManager.prototype.getUserListOfRole = function (role) { + return this.manager.getUserListOfRole(role); + }; + /** + * um.authorizeRole('store-admin', '/permissions/mypermission', 'ui-execute'); + * + * um.authorizeRole('store-admin', { + * '/permissions/myperm1' : ['read', 'write'], + * '/permissions/myperm2' : ['read', 'write'] + * }); + * + * @param role + * @param permission + * @param action + */ + UserManager.prototype.authorizeRole = function (role, permission, action) { + var that = this; + if (permission instanceof String || typeof permission === 'string') { + if (!that.isAuthorized(role, permission, action)) { + that.authorizer.authorizeRole(role, permission, action); + } + } else { + processPerms(permission, function (id, action) { + if (!that.isAuthorized(role, id, action)) { + that.authorizer.authorizeRole(role, id, action); + if (log.isDebugEnabled()) { + log.debug('permission added(role:permission:action) - ' + role + ':' + id + ':' + action); + } + } + }); + } + }; + + /** + * um.denyRole('store-admin', '/permissions/mypermission', 'ui-execute'); + * + * um.denyRole('store-admin', { + * '/permissions/myperm1' : ['read', 'write'], + * '/permissions/myperm2' : ['read', 'write'] + * }); + * + * @param role + * @param permission + * @param action + */ + UserManager.prototype.denyRole = function (role, permission, action) { + var that = this; + if (permission instanceof String || typeof permission === 'string') { + that.authorizer.denyRole(role, permission, action); + } else { + processPerms(permission, function (id, action) { + that.authorizer.denyRole(role, id, action); + }); + } + }; + + /** + * getAllowedUIResources This will return all allowed UI resource for given user + * @param userName User name + * @param permissionRootPath User permission root path + * @return Array with permission resource paths + */ + UserManager.prototype.getAllowedUIResources = function(userName, permissionRootPath){ + var allowedResources = this.authorizer.getAllowedUIResourcesForUser(userName, permissionRootPath); + return allowedResources; + }; + +}(server, user)); diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/user.js b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/user.js new file mode 100644 index 00000000..cdfae1ca --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/carbon/scripts/user/user.js @@ -0,0 +1,78 @@ +var user = {}; + +(function (user) { + + var CarbonConstants = Packages.org.wso2.carbon.CarbonConstants; + + user.systemUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME; + + user.anonUser = CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME; + + user.anonRole = CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME; + + var User = function (manager, username) { + this.um = manager; + this.tenantId = manager.tenantId; + this.username = username; + }; + user.User = User; + + User.prototype.getClaims = function (profile) { + return this.um.getClaims(this.username, profile); + }; + User.prototype.getClaimsForSet = function (claims,profile) { + return this.um.getClaimsForSet(this.username, claims, profile); + }; + + User.prototype.setClaims = function (claims, profile) { + this.um.setClaims(this.username, claims, profile); + }; + + User.prototype.getRoles = function () { + return this.um.manager.getRoleListOfUser(this.username); + }; + + User.prototype.hasRoles = function (roles) { + var i, j, role, + rs = this.getRoles(), + length1 = roles.length, + length2 = rs.length; + L1: + for (i = 0; i < length1; i++) { + //Array.indexOf() fails due to Java String vs JS String difference + role = roles[i]; + for (j = 0; j < length2; j++) { + if (role == rs[j]) { + continue L1; + } + } + return false; + } + return true; + }; + + User.prototype.addRoles = function (roles) { + return this.um.manager.updateRoleListOfUser(this.username, [], roles); + }; + + User.prototype.removeRoles = function (roles) { + return this.um.manager.updateRoleListOfUser(this.username, roles, []); + }; + + User.prototype.updateRoles = function (remove, add) { + return this.um.manager.updateRoleListOfUser(this.username, remove, add); + }; + + User.prototype.isAuthorized = function (permission, action) { + var i, + roles = this.getRoles(), + length = roles.length; + for (i = 0; i < length; i++) { + if (this.um.authorizer.isRoleAuthorized(roles[i], permission, action)) { + return true; + } + } + return false; + }; + +}(user)); diff --git a/modules/distribution/src/repository/jaggeryapps/ues/modules/process/module.xml b/modules/distribution/src/repository/jaggeryapps/ues/modules/process/module.xml new file mode 100644 index 00000000..c66d7457 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/modules/process/module.xml @@ -0,0 +1,23 @@ + + + + org.jaggeryjs.modules.process.ProcessHostObject + getEnv + + + org.jaggeryjs.modules.process.ProcessHostObject + getEnvs + + + org.jaggeryjs.modules.process.ProcessHostObject + getProperty + + + org.jaggeryjs.modules.process.ProcessHostObject + getProperties + + + org.jaggeryjs.modules.process.ProcessHostObject + setProperty + + \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/css/dashboard.css b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/css/dashboard.css new file mode 100644 index 00000000..aedbb972 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/css/dashboard.css @@ -0,0 +1,239 @@ +body.dashboard { + background: #fff; +} + +.dropdown-menu { + border: 1px solid #ccc; +} + +.dashboard .btn-default.active, +.dashboard .btn-default.active:focus { + background-color: #29313E; + color: #fff; +} + +.dashboard .btn-default.active:hover { + background-color: #53627B; + color: #fff; +} + +.dashboard .page-header { + background: #29313e; + min-height: 50px; + padding: 0; + color: #ebeced; +} + +.dashboard .page-header .page-title > h1 { + padding: 15px 15px 0 15px; + font-weight: 100; + text-transform: uppercase; + font-size: 18px; +} + +.dashboard .page-header .page-title > h1 > .icon { + font-size: 24px; + margin-top: -5px; + margin-right: 5px; +} + +.dashboard .page-header .navbar-header { + margin-right: 15px; + margin-left: 15px; + float: none; +} + +@media (min-width: 768px) { + .dashboard .page-header .navbar-collapse.collapse { + display: none !important; + } + .page-header .container-fluid { + padding: 0 15px; + } + .navbar-nav > li > a { + padding: 10px 0; + } +} + +.nav > li > a > .icon { + margin-right: 8px; +} + +.nav > li > a > .badge { + position: absolute; + top: 5px; + right: 5px; + background: #ff124a; +} + +.dashboard .page-header .auth { + margin-bottom: 0; + padding: 6px 0; +} + +.dashboard .page-content { + overflow: inherit; +} + +.dashboard .footer { + background: #0d1219; +} + +.dashboard .gadget-wrapper { + border: 1px dashed #e4e4e4; +} + +.dashboard .gadget .gadget-heading { + background: transparent; + border-bottom: none; + color: #29313e; +} + +.gadget .gadget-heading > .gadget-title { + font-size: 20px; +} + +.gadget .gadget-heading > .gadget-actions button { + border: none; +} + +.sidebar-wrapper hr { + border-top-color: #ebeced; +} + +.sidebar-toggle-button { + float: left; + height: 50px; + line-height: 50px; + font-size: 18px; + background: #438cad; + color: #ffffff; + margin-left: -15px; +} + +.sidebar-toggle-button > .icon { + line-height: 48px; +} + +.sidebar-nav { + background: #29313e; + color: #e3e5e6; +} + +.nav.pages { + text-transform: uppercase; +} + +.nav.pages > li { + line-height: 20px; +} + +.nav > li { + text-indent: 0; + line-height: 10px; +} + +.nav > li > a { + border-radius: 0; + color: #e3e5e6; + background: transparent; +} + +.collapse-nav-sub > li > a { + padding: 4px 10px; + font-size: 21px; +} + +.collapse-nav-sub > li > a > .icon { + margin: 0; +} + +.page-header .fw-inverse { + color: #29313e; +} + +.nav li:hover > a, +.nav li.open > a, +.nav li.open > a:focus, +.nav li.open > a:hover { + background: #1a2332; +} + +.nav > li > a:focus { + background: transparent; +} + +.nav.pages > li.active a { + background: #121822; + border-left: 5px solid #438cad; +} + +.navbar-collapse { + padding: 15px; + background: #1A2331; +} + +.navbar-collapse li:hover > a { + background: #29313E; +} + +.sidebar-nav .user { + text-align: center; + margin: 20px auto; +} + +.sidebar-nav .user > .user-image { + margin-bottom: 10px; +} + +.sidebar-nav .user > .user-image > .default .icon { + font-size: 25px; +} + +.sidebar-nav .user > .user-image > .default .icon .fw-inverse, +.sidebar-nav .user > .user-image > .default .icon .fa-inverse { + color: #29313e; +} + +.widget .gadget-wrapper { + border: none; +} + +.widget .ues-component-heading { + display: none !important; + height: 0; +} + +.widget .ues-component { + height: auto; +} + +.widget.form-control-widget { + height: 35px !important; +} + +.dropdown-menu.arrow.arrow-top-right:before { + right: 20px; +} + +.dropdown-menu.arrow:before, +.dropdown-menu.arrow.arrow-top-left:before { + top: -10px; + border-right: 10px solid transparent; + border-bottom: 10px solid #e4e4e4; + border-left: 10px solid transparent; +} + +.dropdown-menu.alerts { + min-width: 400px; + max-width: 100%; + line-height: 1.2; +} + +ul.sidebar-messages > li:first-child { + margin-top: 0; +} + +ul.sidebar-messages > li:last-child { + margin-bottom: 0; +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/js/VizGrammarSettings.js b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/js/VizGrammarSettings.js new file mode 100644 index 00000000..e1b44c83 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/js/VizGrammarSettings.js @@ -0,0 +1,12 @@ +var vizgSettings = { + colorScale: colorbrewer.RdYlBu[4].reverse(), + colors: { + green:"#5FCE9B", + blue:"#438CAD", + red:"#E87352", + yellow:"#EECA5A", + purple:"#B6688F", + grey:"434343", + brown:"#C59787" + } +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/js/colorbrewer.js b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/js/colorbrewer.js new file mode 100644 index 00000000..5266d212 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/js/colorbrewer.js @@ -0,0 +1,303 @@ +// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/). +// JavaScript specs as packaged in the D3 library (d3js.org). Please see license at http://colorbrewer.org/export/LICENSE.txt +var colorbrewer = {YlGn: { +3: ["#f7fcb9","#addd8e","#31a354"], +4: ["#ffffcc","#c2e699","#78c679","#238443"], +5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"], +6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"], +7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"], +8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"], +9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"] +},YlGnBu: { +3: ["#edf8b1","#7fcdbb","#2c7fb8"], +4: ["#ffffcc","#a1dab4","#41b6c4","#225ea8"], +5: ["#ffffcc","#a1dab4","#41b6c4","#2c7fb8","#253494"], +6: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#2c7fb8","#253494"], +7: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"], +8: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"], +9: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"] +},GnBu: { +3: ["#e0f3db","#a8ddb5","#43a2ca"], +4: ["#f0f9e8","#bae4bc","#7bccc4","#2b8cbe"], +5: ["#f0f9e8","#bae4bc","#7bccc4","#43a2ca","#0868ac"], +6: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#43a2ca","#0868ac"], +7: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"], +8: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"], +9: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"] +},BuGn: { +3: ["#e5f5f9","#99d8c9","#2ca25f"], +4: ["#edf8fb","#b2e2e2","#66c2a4","#238b45"], +5: ["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"], +6: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#2ca25f","#006d2c"], +7: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"], +8: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"], +9: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"] +},PuBuGn: { +3: ["#ece2f0","#a6bddb","#1c9099"], +4: ["#f6eff7","#bdc9e1","#67a9cf","#02818a"], +5: ["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"], +6: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#1c9099","#016c59"], +7: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"], +8: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"], +9: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"] +},PuBu: { +3: ["#ece7f2","#a6bddb","#2b8cbe"], +4: ["#f1eef6","#bdc9e1","#74a9cf","#0570b0"], +5: ["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"], +6: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#2b8cbe","#045a8d"], +7: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"], +8: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"], +9: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"] +},BuPu: { +3: ["#e0ecf4","#9ebcda","#8856a7"], +4: ["#edf8fb","#b3cde3","#8c96c6","#88419d"], +5: ["#edf8fb","#b3cde3","#8c96c6","#8856a7","#810f7c"], +6: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8856a7","#810f7c"], +7: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"], +8: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"], +9: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"] +},RdPu: { +3: ["#fde0dd","#fa9fb5","#c51b8a"], +4: ["#feebe2","#fbb4b9","#f768a1","#ae017e"], +5: ["#feebe2","#fbb4b9","#f768a1","#c51b8a","#7a0177"], +6: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#c51b8a","#7a0177"], +7: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"], +8: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"], +9: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"] +},PuRd: { +3: ["#e7e1ef","#c994c7","#dd1c77"], +4: ["#f1eef6","#d7b5d8","#df65b0","#ce1256"], +5: ["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"], +6: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#dd1c77","#980043"], +7: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"], +8: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"], +9: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"] +},OrRd: { +3: ["#fee8c8","#fdbb84","#e34a33"], +4: ["#fef0d9","#fdcc8a","#fc8d59","#d7301f"], +5: ["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"], +6: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#e34a33","#b30000"], +7: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"], +8: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"], +9: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"] +},YlOrRd: { +3: ["#ffeda0","#feb24c","#f03b20"], +4: ["#ffffb2","#fecc5c","#fd8d3c","#e31a1c"], +5: ["#ffffb2","#fecc5c","#fd8d3c","#f03b20","#bd0026"], +6: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#f03b20","#bd0026"], +7: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"], +8: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"], +9: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"] +},YlOrBr: { +3: ["#fff7bc","#fec44f","#d95f0e"], +4: ["#ffffd4","#fed98e","#fe9929","#cc4c02"], +5: ["#ffffd4","#fed98e","#fe9929","#d95f0e","#993404"], +6: ["#ffffd4","#fee391","#fec44f","#fe9929","#d95f0e","#993404"], +7: ["#ffffd4","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"], +8: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"], +9: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"] +},Purples: { +3: ["#efedf5","#bcbddc","#756bb1"], +4: ["#f2f0f7","#cbc9e2","#9e9ac8","#6a51a3"], +5: ["#f2f0f7","#cbc9e2","#9e9ac8","#756bb1","#54278f"], +6: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#756bb1","#54278f"], +7: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"], +8: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"], +9: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"] +},Blues: { +3: ["#deebf7","#9ecae1","#3182bd"], +4: ["#eff3ff","#bdd7e7","#6baed6","#2171b5"], +5: ["#eff3ff","#bdd7e7","#6baed6","#3182bd","#08519c"], +6: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#3182bd","#08519c"], +7: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"], +8: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"], +9: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"] +},Greens: { +3: ["#e5f5e0","#a1d99b","#31a354"], +4: ["#edf8e9","#bae4b3","#74c476","#238b45"], +5: ["#edf8e9","#bae4b3","#74c476","#31a354","#006d2c"], +6: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#31a354","#006d2c"], +7: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"], +8: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"], +9: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"] +},Oranges: { +3: ["#fee6ce","#fdae6b","#e6550d"], +4: ["#feedde","#fdbe85","#fd8d3c","#d94701"], +5: ["#feedde","#fdbe85","#fd8d3c","#e6550d","#a63603"], +6: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#e6550d","#a63603"], +7: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"], +8: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"], +9: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"] +},Reds: { +3: ["#fee0d2","#fc9272","#de2d26"], +4: ["#fee5d9","#fcae91","#fb6a4a","#cb181d"], +5: ["#fee5d9","#fcae91","#fb6a4a","#de2d26","#a50f15"], +6: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#de2d26","#a50f15"], +7: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"], +8: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"], +9: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"] +},Greys: { +3: ["#f0f0f0","#bdbdbd","#636363"], +4: ["#f7f7f7","#cccccc","#969696","#525252"], +5: ["#f7f7f7","#cccccc","#969696","#636363","#252525"], +6: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#636363","#252525"], +7: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"], +8: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"], +9: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"] +},PuOr: { +3: ["#f1a340","#f7f7f7","#998ec3"], +4: ["#e66101","#fdb863","#b2abd2","#5e3c99"], +5: ["#e66101","#fdb863","#f7f7f7","#b2abd2","#5e3c99"], +6: ["#b35806","#f1a340","#fee0b6","#d8daeb","#998ec3","#542788"], +7: ["#b35806","#f1a340","#fee0b6","#f7f7f7","#d8daeb","#998ec3","#542788"], +8: ["#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788"], +9: ["#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788"], +10: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"], +11: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"] +},BrBG: { +3: ["#d8b365","#f5f5f5","#5ab4ac"], +4: ["#a6611a","#dfc27d","#80cdc1","#018571"], +5: ["#a6611a","#dfc27d","#f5f5f5","#80cdc1","#018571"], +6: ["#8c510a","#d8b365","#f6e8c3","#c7eae5","#5ab4ac","#01665e"], +7: ["#8c510a","#d8b365","#f6e8c3","#f5f5f5","#c7eae5","#5ab4ac","#01665e"], +8: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e"], +9: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e"], +10: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"], +11: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"] +},PRGn: { +3: ["#af8dc3","#f7f7f7","#7fbf7b"], +4: ["#7b3294","#c2a5cf","#a6dba0","#008837"], +5: ["#7b3294","#c2a5cf","#f7f7f7","#a6dba0","#008837"], +6: ["#762a83","#af8dc3","#e7d4e8","#d9f0d3","#7fbf7b","#1b7837"], +7: ["#762a83","#af8dc3","#e7d4e8","#f7f7f7","#d9f0d3","#7fbf7b","#1b7837"], +8: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837"], +9: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837"], +10: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"], +11: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"] +},PiYG: { +3: ["#e9a3c9","#f7f7f7","#a1d76a"], +4: ["#d01c8b","#f1b6da","#b8e186","#4dac26"], +5: ["#d01c8b","#f1b6da","#f7f7f7","#b8e186","#4dac26"], +6: ["#c51b7d","#e9a3c9","#fde0ef","#e6f5d0","#a1d76a","#4d9221"], +7: ["#c51b7d","#e9a3c9","#fde0ef","#f7f7f7","#e6f5d0","#a1d76a","#4d9221"], +8: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221"], +9: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221"], +10: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"], +11: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"] +},RdBu: { +3: ["#ef8a62","#f7f7f7","#67a9cf"], +4: ["#ca0020","#f4a582","#92c5de","#0571b0"], +5: ["#ca0020","#f4a582","#f7f7f7","#92c5de","#0571b0"], +6: ["#b2182b","#ef8a62","#fddbc7","#d1e5f0","#67a9cf","#2166ac"], +7: ["#b2182b","#ef8a62","#fddbc7","#f7f7f7","#d1e5f0","#67a9cf","#2166ac"], +8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac"], +9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac"], +10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"], +11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"] +},RdGy: { +3: ["#ef8a62","#ffffff","#999999"], +4: ["#ca0020","#f4a582","#bababa","#404040"], +5: ["#ca0020","#f4a582","#ffffff","#bababa","#404040"], +6: ["#b2182b","#ef8a62","#fddbc7","#e0e0e0","#999999","#4d4d4d"], +7: ["#b2182b","#ef8a62","#fddbc7","#ffffff","#e0e0e0","#999999","#4d4d4d"], +8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d"], +9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d"], +10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"], +11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"] +},RdYlBu: { +3: ["#fc8d59","#ffffbf","#91bfdb"], +4: ["#d7191c","#fdae61","#abd9e9","#2c7bb6"], +5: ["#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6"], +6: ["#d73027","#fc8d59","#fee090","#e0f3f8","#91bfdb","#4575b4"], +7: ["#d73027","#fc8d59","#fee090","#ffffbf","#e0f3f8","#91bfdb","#4575b4"], +8: ["#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4"], +9: ["#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4"], +10: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"], +11: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"] +},Spectral: { +3: ["#fc8d59","#ffffbf","#99d594"], +4: ["#d7191c","#fdae61","#abdda4","#2b83ba"], +5: ["#d7191c","#fdae61","#ffffbf","#abdda4","#2b83ba"], +6: ["#d53e4f","#fc8d59","#fee08b","#e6f598","#99d594","#3288bd"], +7: ["#d53e4f","#fc8d59","#fee08b","#ffffbf","#e6f598","#99d594","#3288bd"], +8: ["#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd"], +9: ["#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd"], +10: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"], +11: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"] +},RdYlGn: { +3: ["#fc8d59","#ffffbf","#91cf60"], +4: ["#d7191c","#fdae61","#a6d96a","#1a9641"], +5: ["#d7191c","#fdae61","#ffffbf","#a6d96a","#1a9641"], +6: ["#d73027","#fc8d59","#fee08b","#d9ef8b","#91cf60","#1a9850"], +7: ["#d73027","#fc8d59","#fee08b","#ffffbf","#d9ef8b","#91cf60","#1a9850"], +8: ["#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850"], +9: ["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"], +10: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"], +11: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"] +},Accent: { +3: ["#7fc97f","#beaed4","#fdc086"], +4: ["#7fc97f","#beaed4","#fdc086","#ffff99"], +5: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0"], +6: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f"], +7: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17"], +8: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"] +},Dark2: { +3: ["#1b9e77","#d95f02","#7570b3"], +4: ["#1b9e77","#d95f02","#7570b3","#e7298a"], +5: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e"], +6: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02"], +7: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d"], +8: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"] +},Paired: { +3: ["#a6cee3","#1f78b4","#b2df8a"], +4: ["#a6cee3","#1f78b4","#b2df8a","#33a02c"], +5: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99"], +6: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c"], +7: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f"], +8: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00"], +9: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6"], +10: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a"], +11: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99"], +12: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"] +},Pastel1: { +3: ["#fbb4ae","#b3cde3","#ccebc5"], +4: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4"], +5: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6"], +6: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc"], +7: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd"], +8: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec"], +9: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"] +},Pastel2: { +3: ["#b3e2cd","#fdcdac","#cbd5e8"], +4: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4"], +5: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9"], +6: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae"], +7: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc"], +8: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"] +},Set1: { +3: ["#e41a1c","#377eb8","#4daf4a"], +4: ["#e41a1c","#377eb8","#4daf4a","#984ea3"], +5: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00"], +6: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33"], +7: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628"], +8: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf"], +9: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"] +},Set2: { +3: ["#66c2a5","#fc8d62","#8da0cb"], +4: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3"], +5: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854"], +6: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f"], +7: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494"], +8: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"] +},Set3: { +3: ["#8dd3c7","#ffffb3","#bebada"], +4: ["#8dd3c7","#ffffb3","#bebada","#fb8072"], +5: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3"], +6: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462"], +7: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69"], +8: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5"], +9: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9"], +10: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd"], +11: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5"], +12: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"] +}}; \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/templates/dashboard.jag b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/templates/dashboard.jag new file mode 100644 index 00000000..be15e2cb --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/ues/themes/analytics/templates/dashboard.jag @@ -0,0 +1,447 @@ + +<% + // i18n + var i18n = require("i18n"); + i18n.init(request, utils.getLocaleResourcePath()); + + // If the pageId is null, render the landing page + pageId = pageId || dashboard.landing; + + var usr = require('/modules/user.js'), + user = usr.current(), + isAnonView = request.getParameter('isAnonView'); + + // Get the anon view + if (!user) { + if (isAnonView) { + response.sendRedirect(request.getRequestURL()); + } + isAnonView = true; + } else { + isAnonView = JSON.parse(isAnonView); + + if((user.domain != urlDomain && urlDomain) || + (dashboard.isanon && !utils.allowed(user.roles, dashboard.permissions.editors) && !utils.allowed(user.roles, dashboard.permissions.viewers))) { + isAnonView = true; + } + } + + // Get the current page + var pages = dashboard.pages, + page; + pages.forEach(function(p) { + if (p.id == pageId) { + page = p; + } + }); +%> + + + + + + + <%= i18n.localize("dashboard.server.label")%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + +
+ +
+ +
+ <%=renderEngine.getDashboardContent(pageId || dashboard.landing, isAnonView)%> +
+
+
+ +
+
+
+ + +
+
+

WSO2 Dashboard Server 2.0.0 | © Inc.

+
+
+ + + + + + + + + + + + + + + + + + + + + <% include('/controllers/includes/common-scripts.jag'); %> + <% include('/controllers/includes/dashboard-scripts.jag'); %> + + + + + + + + + + + <% include('/controllers/includes/theme-dashboard-scripts.jag'); %> + + + + + + + + + + + + + + +