forked from community/product-iots
# Conflicts: # modules/distribution/src/assembly/bin.xmlapplication-manager-new
commit
3766bbec06
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
app.dependencies = ['publisher-common'];
|
||||
app.server = function(ctx) {
|
||||
return {
|
||||
endpoints: {
|
||||
//pages: [{
|
||||
// title: 'Publisher | Servicex Page',
|
||||
// url: 'devices_global',
|
||||
// path: 'device_global.jag'
|
||||
//}, {
|
||||
// title: 'Publisher | Servicex Splash page',
|
||||
// url: 'devices',
|
||||
// path: 'device_top_assets.jag'
|
||||
//}]
|
||||
},
|
||||
configs:{
|
||||
landingPage:'/assets/deviceType/list',
|
||||
disabledAssets:['ebook', 'api', 'wsdl', 'service','policy','proxy','schema','sequence','servicex','uri','wadl','endpoint','swagger','restservice','comments','soapservice', 'license', 'gadget', 'site', 'server']
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,28 @@
|
||||
asset.configure = function () {
|
||||
return {
|
||||
table: {
|
||||
overview: {
|
||||
fields: {
|
||||
thumbnail: {
|
||||
type: 'file'
|
||||
}
|
||||
}
|
||||
},
|
||||
setupGuide: {
|
||||
fields: {
|
||||
guideImage: {
|
||||
type: 'file'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
meta: {
|
||||
lifecycle: {
|
||||
name: 'DeviceLifeCycle',
|
||||
defaultLifecycleEnabled: true
|
||||
},
|
||||
thumbnail: 'overview_thumbnail',
|
||||
banner: 'overview_thumbnail'
|
||||
}
|
||||
};
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
var log = new Log();
|
||||
var execute = function(req,res,session){
|
||||
log.info('Executing the Device-Type asset create ');
|
||||
};
|
||||
|
||||
var process = function(req,res,session){
|
||||
log.info('Processing the Device-Type asset create');
|
||||
};
|
@ -0,0 +1,66 @@
|
||||
<%
|
||||
/*
|
||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
var caramel;
|
||||
require('/modules/store.js').exec(function(ctx) {
|
||||
caramel = require('caramel');
|
||||
var tenantApi = require('/modules/tenant-api.js').api;
|
||||
var ratingApi = require('/modules/rating-api.js').api;
|
||||
var app = require('rxt').app;
|
||||
var constants = require('rxt').constants;
|
||||
var asset = require('rxt').asset;
|
||||
var core = require('rxt').core;
|
||||
var constants = require('rxt').constants;
|
||||
var am;
|
||||
var server = require('store').server;
|
||||
var user = server.current(ctx.session);
|
||||
var ui = require('rxt').ui;
|
||||
var page = ui.buildPage(ctx.session, ctx.request);
|
||||
var appManager;
|
||||
var rxtManager;
|
||||
var appResources = tenantApi.createTenantAwareAppResources(ctx.session);
|
||||
appManager = appResources.appManager;
|
||||
//appManager = app.createUserAppManager(ctx.session);
|
||||
//tenanId = user.tenantId;
|
||||
tenantId = appResources.context.tenantId;
|
||||
rxtManager = core.rxtManager(tenantId);
|
||||
var type;
|
||||
var availableAssetTypes = rxtManager.listRxtTypes();
|
||||
var assets = {};
|
||||
var subs;
|
||||
//Subscriptions should not be retrieved if the user
|
||||
//is accessing a cross tenant view
|
||||
if (!appResources.context.isAnonContext) {
|
||||
for (var index in availableAssetTypes) {
|
||||
type = availableAssetTypes[index];
|
||||
am = asset.createUserAssetManager(ctx.session, type);
|
||||
//Get all of the subscriptions for the current asset type
|
||||
subs = am.subscriptions(ctx.session);
|
||||
//Only create an entry if there are any subscriptions
|
||||
if (subs.length > 0) {
|
||||
ratingApi.addRatings(subs, am, context.tenantId, context.username);
|
||||
assets[type] = {};
|
||||
assets[type].assets = subs;
|
||||
assets[type].meta = rxtManager.getRxtTypeDetails(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
var output = appManager.render(assets, page);
|
||||
caramel.render(output);
|
||||
}, request, response, session); %>
|
@ -0,0 +1,49 @@
|
||||
<div id="myasset-container">
|
||||
<h2 class="padding-top-lg">My Devices</h2>
|
||||
{{#if assets.device}}
|
||||
{{#itr assets}}
|
||||
<div class="ast-container">
|
||||
<div class="container-fluid ">
|
||||
<div class="title">
|
||||
<a class="asset-type-{{rxt.shortName}}" href="{{url "/assets"}}/{{key}}/list">{{value.meta.pluralLabel}}</a>
|
||||
</div><!--title-->
|
||||
<hr />
|
||||
</div>
|
||||
</div>
|
||||
{{#each value.assets}}
|
||||
{{#attributes}}
|
||||
<div class="ctrl-wr-asset margin-top-lg">
|
||||
<div class="itm-ast">
|
||||
<a class="ast-img " href="{{tenantedUrl "/assets"}}/{{../type}}/details/{{../id}}">
|
||||
{{> asset-thumbnail ..}}
|
||||
</a>
|
||||
<div class="ast-content">
|
||||
<div class="ast-title padding">
|
||||
<a class="ast-name truncate" href="{{tenantedUrl "/assets"}}/{{../type}}/details/{{../id}}" title="{{overview_name}}">{{overview_name}}</a>
|
||||
<span class="ast-auth" title="{{overview_provider}}">{{overview_provider}}</span>
|
||||
</div>
|
||||
<div class="pull-left asset-rating-container">
|
||||
<span class="asset-rating">
|
||||
<div style="width:{{../ratingPx}}px"></div>
|
||||
</span>
|
||||
</div>
|
||||
<div class="clearfix padding-bottom-sm"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/attributes}}
|
||||
{{/each}}
|
||||
{{/itr}}
|
||||
{{else}}
|
||||
<div id="no-data-my-items" class="no-data">
|
||||
<i class="icon-inbox"></i>
|
||||
<p>
|
||||
{{t "You still haven't any devices from the Store."}}
|
||||
</p>
|
||||
<p>
|
||||
<a href="{{url "/assets/device/list"}}" class="btn btn-primary">{{t "Add a Device"}}</a>
|
||||
</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,2 @@
|
||||
<h2 class="app-title hidden-xs-320">{{t "IoT Server"}}</h2>
|
||||
<h2 class="app-title visible-xs-320">{{t "IoTS"}}</h2>
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
var render = function(theme, data, meta, require) {
|
||||
var log = new Log();
|
||||
var navigation = 'navigation';
|
||||
var navigationContext = data;
|
||||
switch (data.assetTypeCount) {
|
||||
case 1:
|
||||
navigation = 'navigation-single';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
theme('2-column-right', {
|
||||
title: data.meta.title,
|
||||
header: [{
|
||||
partial: 'header',
|
||||
context: data
|
||||
}],
|
||||
navigation: [{
|
||||
partial: navigation,
|
||||
context: navigationContext
|
||||
}],
|
||||
body: [{
|
||||
partial: 'asset',
|
||||
context: data
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
var render = function(theme, data, meta, require) {
|
||||
var navigation = 'navigation';
|
||||
var navigationContext = data;
|
||||
switch (data.assetTypeCount) {
|
||||
case 1:
|
||||
navigation = 'navigation-single';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
theme('2-column-right', {
|
||||
title: data.meta.title,
|
||||
header: [{
|
||||
partial: 'header',
|
||||
context: data
|
||||
}],
|
||||
navigation: [{
|
||||
partial: navigation,
|
||||
context: navigationContext
|
||||
}],
|
||||
body: [{
|
||||
partial: 'my_items',
|
||||
context: data
|
||||
}],
|
||||
right: [{
|
||||
partial: 'my_items',
|
||||
context: data
|
||||
}
|
||||
// {
|
||||
// partial: 'tags',
|
||||
// context: data.tags
|
||||
// }
|
||||
]
|
||||
});
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h1 id="assetNewGlobalPage">New Global Page</h1>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h1 id="assetOverridenGlobalPage">Overriden Top Assets Page</h1>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,28 @@
|
||||
asset.configure = function () {
|
||||
return {
|
||||
table: {
|
||||
overview: {
|
||||
fields: {
|
||||
thumbnail: {
|
||||
type: 'file'
|
||||
}
|
||||
}
|
||||
},
|
||||
setupGuide: {
|
||||
fields: {
|
||||
guideImage: {
|
||||
type: 'file'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
meta: {
|
||||
lifecycle: {
|
||||
name: 'DeviceLifeCycle',
|
||||
defaultLifecycleEnabled: true
|
||||
},
|
||||
thumbnail: 'overview_thumbnail',
|
||||
banner: 'overview_thumbnail'
|
||||
}
|
||||
};
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
{{#if overview_actionURL}}
|
||||
{{#if overview_actionName}}
|
||||
<br /><br />
|
||||
<a href="{{overview_actionURL}}" class="blue-button">{{overview_actionName}}</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
@ -0,0 +1,112 @@
|
||||
<script>
|
||||
var isSocial = ('{{features.social.enabled}}' == 'true');
|
||||
var guestDomain = '{{guestDomain}}';
|
||||
</script>
|
||||
<div class="asset-description">
|
||||
|
||||
{{#with assets}}
|
||||
|
||||
|
||||
{{#with attributes}}
|
||||
<div class="asset-description-header">
|
||||
<div class="col-lg-12 white-bg left ">
|
||||
<h3 >{{../../rxt.singularLabel}} Details</h3>
|
||||
<div class="clear"></div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
<!-- asset details folder-->
|
||||
<div class="asset-details-header ">
|
||||
<!-- aset details -->
|
||||
<div class="col-xs-12 col-sm-5 col-md-5 col-lg-5 white-bg">
|
||||
<div class=" details-image white-bg">
|
||||
{{> asset-thumbnail ..}}
|
||||
</div>
|
||||
<div class="details-container">
|
||||
<div class="pull-left">
|
||||
<h4 class="margin-none ">{{overview_name}}</h4>
|
||||
<p class="grey padding-none margin-none">{{t "Version"}} {{overview_version}}</p>
|
||||
<p class="light-blue padding-none margin-none">{{t "by"}} {{overview_provider}}</p>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<span class = "pull-right rating-count"> ( <i class="fa fa-users"></i> {{../count}} )</span>
|
||||
<span class="asset-rating pull-right">
|
||||
<div style="width:{{../ratingPx}}px"></div>
|
||||
</span>
|
||||
<div class="clearfix"></div>
|
||||
{{!#hasAssetPermission . key="ASSET_BOOKMARK" type=../../rxt.shortName username=../../cuser.username tenantId=../../cuser.tenantId}}
|
||||
{{!>asset-utilization ../../..}}
|
||||
{{!/hasAssetPermission}}
|
||||
{{>assert-action-link}}
|
||||
{{> asset-version-info ../..}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end of asset details-->
|
||||
</div>
|
||||
<div class="white-bg asset-details-wrapper ">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<h4>Summary</h4>
|
||||
<p>{{>overview .}}</p>
|
||||
<hr>
|
||||
{{>tags ../../.}}
|
||||
</div><!-- description column-->
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<!-- asset description -->
|
||||
<div class="assetp-properties">
|
||||
<hr class="margin-bottom-double">
|
||||
<ul class="nav nav-tabs" id="assetp-tabs" data-aid="{{../path}}">
|
||||
<li class="active">
|
||||
<a href="#tab-properties" data-toggle="tab" data-type="basic">{{t "Description"}}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tab-setup" data-toggle="tab" data-type="basic">{{t "Hardware Setup"}}</a>
|
||||
</li>
|
||||
{{#hasAssetPermission . key="ASSET_REVIEWS" type=../../rxt.shortName username=../../cuser.username tenantId=../../cuser.tenantId}}
|
||||
<li>
|
||||
<a href="#tab-reviews" data-toggle="tab" data-type="comments">{{t "User Reviews"}}</a>
|
||||
</li>
|
||||
{{/hasAssetPermission}}
|
||||
<li>
|
||||
<a href="#tab-share" data-toggle="tab" data-type="basic">{{t "Share"}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab-properties">
|
||||
<div class="content">
|
||||
{{>overview .}}
|
||||
{{>quick-startup-steps}}
|
||||
{{>assert-action-link}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab-setup">
|
||||
<div class="content">
|
||||
{{>hardware-setup}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab-share">
|
||||
<div class="content">
|
||||
{{>share ../..}}
|
||||
</div>
|
||||
</div>
|
||||
{{#hasAssetPermission . key="ASSET_REVIEWS" type=../../rxt.shortName username=../../cuser.username tenantId=../../cuser.tenantId}}
|
||||
<div class="tab-pane" id="tab-reviews">
|
||||
{{#if ../../../features.social.enabled}}
|
||||
<iframe name="socialIfr" id="socialIfr"
|
||||
src="{{../../../../features.social.keys.socialAppUrl}}?target={{../../../../rxt.shortName}}:{{../../../id}}&user={{../../../../cuser.username}}&urlDomain={{../../../../features.social.keys.urlDomain}}"
|
||||
width="100%" height="100%" style="min-height: 500px;" data-script="{{../../../../features.social.keys.socialScriptSource}}" data-script-type="{{../../../../features.social.keys.socialScriptType}}"></iframe>
|
||||
{{/if}}
|
||||
{{#if ../../../inDashboard}}
|
||||
<div id="comment-content" class="content"></div>
|
||||
{{else}}
|
||||
<div id="comment-content" class="content user-review"></div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/hasAssetPermission}}
|
||||
</div>
|
||||
</div>
|
||||
{{/with}}
|
||||
{{/with}}
|
||||
</div>
|
@ -0,0 +1,26 @@
|
||||
<style>
|
||||
.circle {
|
||||
background: none repeat scroll 0 0 #191919;
|
||||
border-radius: 50px;
|
||||
height: 50px;
|
||||
padding: 10px;
|
||||
width: 50px;
|
||||
color: #fff;
|
||||
}
|
||||
.padding-top-double {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
{{dump .}}
|
||||
{{#if ingredients_ingredients}}
|
||||
<h3>Hardware Requirements</h3>
|
||||
<div>
|
||||
{{#itr ingredients_ingredients}}
|
||||
<span class="fw-stack fw-lg margin-right">
|
||||
<i class="fw fw-ring fw-stack-2x"> </i>
|
||||
<i class="fw fw-right-arrow fw-stack-1x"></i>
|
||||
</span>{{value}}<br/>
|
||||
{{/itr}}
|
||||
</div>
|
||||
{{/if}}
|
@ -0,0 +1,18 @@
|
||||
<!--{{.}}
|
||||
{{#itr .}}
|
||||
<ul>
|
||||
<li>
|
||||
<div class="row">
|
||||
<div class="span2 assetp-key">{{key}}</div>
|
||||
<div class="span7 assetp-value">{{value}}</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
{{/itr}}
|
||||
-->
|
||||
|
||||
|
||||
{{overview_description}}
|
||||
<!--<hr>
|
||||
<a id="btn-view-xml" href="{{overview_url}}" target="_blank"><i class="icon-link"></i> {{>asset-overview-text}}</a>-->
|
@ -0,0 +1,4 @@
|
||||
<span id="main-bookmark">
|
||||
{{t "Add Device"}}
|
||||
<span class="sub-bookmark"></span>
|
||||
</span>
|
@ -0,0 +1,4 @@
|
||||
<span id="main-bookmark">
|
||||
{{t "Added"}}
|
||||
<span class="sub-bookmark"></span>
|
||||
</span>
|
@ -0,0 +1,2 @@
|
||||
<h2 class="app-title hidden-xs-320">{{t "IoT Server"}}</h2>
|
||||
<h2 class="app-title visible-xs-320">{{t "IoT"}}</h2>
|
@ -0,0 +1,23 @@
|
||||
<style>
|
||||
.circle {
|
||||
background: none repeat scroll 0 0 #191919;
|
||||
border-radius: 50px;
|
||||
height: 50px;
|
||||
padding: 10px;
|
||||
width: 50px;
|
||||
color: #fff;
|
||||
}
|
||||
.padding-top-double {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
{{#if quickStartupSteps_stepDescription}}
|
||||
<br /><br />
|
||||
<h3>Quick Startup Steps</h3>
|
||||
<div>
|
||||
{{#itr quickStartupSteps_stepDescription}}
|
||||
<p class="padding-top-double"><span class="circle">0{{key}}</span> {{value}}</p>
|
||||
{{/itr}}
|
||||
</div>
|
||||
{{/if}}
|
@ -0,0 +1,283 @@
|
||||
/*
|
||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
var cache = false;
|
||||
var engine = caramel.engine('handlebars', (function() {
|
||||
return {
|
||||
partials: function(Handlebars) {
|
||||
var theme = caramel.theme();
|
||||
var partials = function(file) {
|
||||
(function register(prefix, file) {
|
||||
var i, length, name, files;
|
||||
if (file.isDirectory()) {
|
||||
files = file.listFiles();
|
||||
length = files.length;
|
||||
for (i = 0; i < length; i++) {
|
||||
file = files[i];
|
||||
register(prefix ? prefix + '.' + file.getName() : file.getName(), file);
|
||||
}
|
||||
} else {
|
||||
name = file.getName();
|
||||
if (name.substring(name.length - 4) !== '.hbs') {
|
||||
return;
|
||||
}
|
||||
file.open('r');
|
||||
Handlebars.registerPartial(prefix.substring(0, prefix.length - 4), file.readAll());
|
||||
file.close();
|
||||
}
|
||||
})('', file);
|
||||
};
|
||||
//TODO : we don't need to register all partials in the themes dir.
|
||||
//Rather register only not overridden partials
|
||||
partials(new File(theme.__proto__.resolve.call(theme, 'partials')));
|
||||
var rxtAPI = require('rxt');
|
||||
var appExtensionMediator = rxtAPI.core.defaultAppExtensionMediator();
|
||||
if(appExtensionMediator){
|
||||
var defaultExtensionPartialsPath = appExtensionMediator.resolveCaramelResources(theme.__proto__.resolve.call(theme,'partials'));
|
||||
log.debug('Registering new partials directory from: '+defaultExtensionPartialsPath);
|
||||
partials(new File(defaultExtensionPartialsPath));
|
||||
}
|
||||
partials(new File(theme.resolve('partials')));
|
||||
Handlebars.registerHelper('dyn', function(options) {
|
||||
var asset = options.hash.asset,
|
||||
resolve = function(path) {
|
||||
var p,
|
||||
store = require('/modules/store.js');
|
||||
if (asset) {
|
||||
p = store.ASSETS_EXT_PATH + asset + '/themes/' + theme.name + '/' + path;
|
||||
if (new File(p).isExists()) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return theme.__proto__.resolve.call(theme, path);
|
||||
};
|
||||
partials(new File(resolve('partials')));
|
||||
return options.fn(this);
|
||||
});
|
||||
Handlebars.registerHelper('renderSearchField', function(options) {
|
||||
var output = '';
|
||||
//log.info('options: '+stringify(options));
|
||||
switch (options.type) {
|
||||
case 'text':
|
||||
output = '<input type="text" class="search-input" name="' + options.name.fullName + '" />';
|
||||
break;
|
||||
case 'options':
|
||||
output = '<select id="' + options.name.fullName + '" class="selectpicker " name="' + options.name.fullName + '">';
|
||||
var valueObj = options.values ? options.values[0] : {};
|
||||
var values = valueObj.value ? valueObj.value : [];
|
||||
output += '<option value="ignore-value">-- Select ' + options.name.label + ' --</option>';
|
||||
for (var index in values) {
|
||||
output += '<option value="' + Handlebars.Utils.escapeExpression(values[index].value) + '">' + Handlebars.Utils.escapeExpression(values[index].value) + '</option>';
|
||||
}
|
||||
output += '</select>';
|
||||
break;
|
||||
default:
|
||||
log.warn('Unable to render search field: ' + options.name.name + ' as the type is not supported');
|
||||
break;
|
||||
}
|
||||
return new Handlebars.SafeString(output);
|
||||
});
|
||||
Handlebars.registerHelper('authentication', function(options) {
|
||||
var log = new Log();
|
||||
//Determine if security details are present
|
||||
var security = options.security;
|
||||
var output = "";
|
||||
var ptr;
|
||||
if (!security) {
|
||||
log.debug('Unable to locate security details in order to render authentication ui elements');
|
||||
return;
|
||||
}
|
||||
//Determine the authentication method
|
||||
switch (security.method) {
|
||||
case 'sso':
|
||||
output = "{{> sso-auth .}}";
|
||||
break;
|
||||
case 'basic':
|
||||
output = "{{> basic-auth .}}";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ptr = Handlebars.compile(output);
|
||||
return new Handlebars.SafeString(ptr(security));
|
||||
});
|
||||
Handlebars.registerHelper('signout',function(options){
|
||||
var log=new Log();
|
||||
var security=options.security;
|
||||
var output='';
|
||||
var ptr;
|
||||
if(!security){
|
||||
log.warn('Unable to locate security details in order to render sign out ui elements');
|
||||
return;
|
||||
}
|
||||
switch(security.method){
|
||||
case 'sso':
|
||||
output='{{> sso-signout .}}';
|
||||
break;
|
||||
case 'basic':
|
||||
output='{{> basic-signout .}}';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ptr=Handlebars.compile(output);
|
||||
return new Handlebars.SafeString(ptr(security));
|
||||
});
|
||||
Handlebars.registerHelper('assetUtilization', function(options) {
|
||||
var output = '';
|
||||
var ptr;
|
||||
var security = options.security;
|
||||
var cuser = options.cuser;
|
||||
//log.info(options);
|
||||
if (!cuser) {
|
||||
log.warn('Unable to locate user details');
|
||||
return output;
|
||||
}
|
||||
if (!cuser.isAnon) {
|
||||
output = '<a href="#" class="btn btn-primary asset-add-btn">{{>process-asset-text}}</a>';
|
||||
ptr = Handlebars.compile(output);
|
||||
return new Handlebars.SafeString(ptr());
|
||||
}
|
||||
if (!security) {
|
||||
log.warn('Unable to locate security block to render assset utilization');
|
||||
return output;
|
||||
}
|
||||
switch (security.method) {
|
||||
case 'basic':
|
||||
output = '<a href="#" class="btn btn-primary asset-add-btn">{{>process-asset-text}}</a>';
|
||||
break;
|
||||
default:
|
||||
output = '<a href="{{url "/login"}}" class="btn btn-primary asset-add-btn">{{>process-asset-text}}</a>';
|
||||
break;
|
||||
}
|
||||
ptr = Handlebars.compile(output);
|
||||
return new Handlebars.SafeString(ptr());
|
||||
});
|
||||
Handlebars.registerHelper('getLoginUrl',function(options){
|
||||
var security=options.security;
|
||||
var output='/login';
|
||||
if(!security){
|
||||
log.debug('Unable to determine login url as the security block was not pesent');
|
||||
return output;
|
||||
}
|
||||
switch(security.method){
|
||||
case 'sso':
|
||||
output='/login';
|
||||
break;
|
||||
case 'basic':
|
||||
output='#';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return output;
|
||||
});
|
||||
Handlebars.registerHelper('tenantedUrl', function (path) {
|
||||
var constants = require('rxt').constants;
|
||||
var uriPattern = '/{context}/{+suffix}';
|
||||
var tenantedUriPattern = constants.TENANT_URL_PATTERN;// '/{context}/t/{domain}/{+any}';
|
||||
|
||||
var uriOptions, output;
|
||||
var uriMatcher = new URIMatcher(request.getRequestURI());
|
||||
if (uriMatcher.match(tenantedUriPattern)) {
|
||||
uriOptions = uriMatcher.elements();
|
||||
output = '/' + uriOptions.context + '/t/' + uriOptions.domain;
|
||||
} else if (uriMatcher.match(uriPattern)) {
|
||||
uriOptions = uriMatcher.elements();
|
||||
output = '/' + uriOptions.context;
|
||||
}
|
||||
return output + path;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('hasAssetPermission',function(context,options){
|
||||
var rxtAPI = require('rxt');
|
||||
var key = options.hash.key;
|
||||
var type = options.hash.type;
|
||||
var tenantId = options.hash.tenantId;
|
||||
var username = options.hash.username||rxtAPI.permissions.wso2AnonUsername();
|
||||
var isAuthorized =options.hash.auth ? options.hash.auth : false;
|
||||
var missingParams = (!key) || (!type) || (!tenantId)||(!username);
|
||||
//If the user is forcing the view to render
|
||||
if(isAuthorized){
|
||||
return options.fn(context);
|
||||
}
|
||||
if(missingParams){
|
||||
log.error('[hasAssetPermission] Helper not executed since insufficient number of parameters were provided (required parameters: key,type,tenantId,username)');
|
||||
return ;
|
||||
}
|
||||
isAuthorized = rxtAPI.permissions.hasAssetPermission(key,type,tenantId,username);
|
||||
if(isAuthorized){
|
||||
return options.fn(context);
|
||||
}else{
|
||||
if(log.isDebugEnabled()){
|
||||
log.debug('[hasAssetPermission] User '+username+' does not have permission: '+key+' to see ui area');
|
||||
}
|
||||
return options.inverse(context);
|
||||
}
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('hasAppPermission',function(context,options){
|
||||
var rxtAPI = require('rxt');
|
||||
var key = options.hash.key;
|
||||
var type = options.hash.type;
|
||||
var tenantId = options.hash.tenantId;
|
||||
var username = options.hash.username||rxtAPI.permissions.wso2AnonUsername();
|
||||
var isAuthorized =options.hash.auth ? options.hash.auth : false;
|
||||
var missingParams = (!key) || (!tenantId)||(!username);
|
||||
//If the user is forcing the view to render
|
||||
if(isAuthorized){
|
||||
return options.fn(context);
|
||||
}
|
||||
if(missingParams){
|
||||
log.error('[hasAppPermission] Helper not executed since insufficient number of parameters were provided (required parameters: key,type,tenantId,username)');
|
||||
return ;
|
||||
}
|
||||
isAuthorized = rxtAPI.permissions.hasAppPermission(key,tenantId,username);
|
||||
if(isAuthorized){
|
||||
return options.fn(context);
|
||||
}
|
||||
if(log.isDebugEnabled()){
|
||||
log.debug('[hasAppPermission] User '+username+' does not have permission: '+key+' to see ui area');
|
||||
}
|
||||
return ;
|
||||
});
|
||||
},
|
||||
render: function(data, meta) {
|
||||
this.__proto__.render.call(this, data, meta);
|
||||
},
|
||||
globals: function(data, meta) {
|
||||
var store = require('/modules/store.js'),
|
||||
user = require('store').server.current(meta.session);
|
||||
return 'var store = ' + stringify({
|
||||
user: user ? user.username : null
|
||||
});
|
||||
}
|
||||
};
|
||||
}()));
|
||||
var resolve = function(path) {
|
||||
var themeResolver = this.__proto__.resolve;
|
||||
var asset = require('rxt').asset;
|
||||
var app = require('rxt').app;
|
||||
var appPath = app.resolve(request, path, this.name, this, themeResolver, session);
|
||||
if (!appPath) {
|
||||
path = asset.resolve(request, path, this.name, this, themeResolver);
|
||||
} else {
|
||||
path = appPath;
|
||||
}
|
||||
return path;
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
var log = new Log();
|
||||
var execute = function(req,res,session){
|
||||
log.info('Executing the Device-Type asset create ');
|
||||
};
|
||||
|
||||
var process = function(req,res,session){
|
||||
log.info('Processing the Device-Type asset create');
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "Arduino",
|
||||
"tags": "WSO2, IoT, Arduino, ArduinoUno",
|
||||
"rate": 3,
|
||||
"attributes": {
|
||||
"overview_status": "PUBLISHED",
|
||||
"overview_provider": "admin",
|
||||
"overview_name": "Arduino",
|
||||
"overview_version": "1.0.0",
|
||||
"overview_board": "Arduino",
|
||||
"overview_url": "https://204.232.188.214:9443/iotserver/devices/arduino",
|
||||
"overview_model": "Arduino Uno",
|
||||
"overview_defaultOs": "Cross-Platform",
|
||||
"overview_description": "This is a bare-board Arduino Device-Type. The board used here is Arduino Uno.",
|
||||
"images_thumbnail": "/arduino/arduino_thumbnail.png",
|
||||
"images_banner": "/arduino/arduino_banner.png"
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "Arduino",
|
||||
"tags": "WSO2, IoT, Arduino, ArduinoUno",
|
||||
"rate": 3,
|
||||
"attributes": {
|
||||
"overview_thumbnail":"/arduino/arduino_thumbnail.png",
|
||||
"overview_name":"Arduino",
|
||||
"setupGuide_guideImage":"undefined",
|
||||
"overview_actionName":"Download",
|
||||
"overview_actionUrl":"http://www.google.lk",
|
||||
"ingredients_ingredients":[
|
||||
"Arduino Uno",
|
||||
"Arduino Ethernet / WiFi Shield"
|
||||
],
|
||||
"overview_description":"Connect your Arduino Uno device to the WSO2 IoT Server.This is a bare-board Arduino Device-Type. The board used here is Arduino Uno.",
|
||||
"overview_actionUrl":"http://www.google.lk",
|
||||
"setupGuide_description":"sfd",
|
||||
"quickStartupSteps_stepDescription":["Install the Sketch program","Install the Sketch program","Install the Sketch program"],
|
||||
"quickStartupSteps_stepLabel":["1","2","3"],
|
||||
"overview_version":"1.0.0",
|
||||
"overview_provider":"admin"
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "Raspberry Pi",
|
||||
"tags": "WSO2, IoT, RaspberryPi, RaspberryPi-B Plus",
|
||||
"rate": 3,
|
||||
"attributes": {
|
||||
"overview_status": "PUBLISHED",
|
||||
"overview_provider": "admin",
|
||||
"overview_name": "Raspberry Pi",
|
||||
"overview_version": "1.0.0",
|
||||
"overview_board": "RaspberryPi",
|
||||
"overview_url": "https://204.232.188.214:9443/iotserver/devices/raspberrypi",
|
||||
"overview_model": "RaspberryPi B+",
|
||||
"overview_defaultOs": "Cross-Platform",
|
||||
"overview_description": "This is a bare-board Raspberry Pi Device-Type. The board used here is RPi B+.",
|
||||
"images_thumbnail": "/raspberrypi/raspberryPi_thumbnail.png",
|
||||
"images_banner": "/raspberrypi/raspberryPi_banner.png"
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "Raspberry Pi",
|
||||
"tags": "WSO2, IoT, RaspberryPi",
|
||||
"rate": 3,
|
||||
"attributes": {
|
||||
"overview_thumbnail":"/raspberrypi/raspberryPi_thumbnail.png",
|
||||
"overview_name":"Raspberry Pi",
|
||||
"setupGuide_guideImage":"undefined",
|
||||
"overview_actionName":"Download",
|
||||
"overview_actionUrl":"http://www.google.lk",
|
||||
"ingredients_ingredients":[
|
||||
"Raspberry Pi",
|
||||
"WiFi Adapter / Ethernet"
|
||||
],
|
||||
"overview_description":"Connect your Raspberry Pi device to the WSO2 IoT Server.This is a bare-board Raspberry Pi Device-Type. The board used here is RPi B+.",
|
||||
"overview_actionUrl":"http://www.google.lk",
|
||||
"setupGuide_description":"sfd",
|
||||
"quickStartupSteps_stepDescription":["Install the Sketch program","Install the Sketch program","Install the Sketch program"],
|
||||
"quickStartupSteps_stepLabel":["1","2","3"],
|
||||
"overview_version":"1.0.0",
|
||||
"overview_provider":"admin"
|
||||
}
|
||||
}
|
Loading…
Reference in new issue