diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml index fc34cf54..79d21050 100644 --- a/modules/distribution/src/assembly/bin.xml +++ b/modules/distribution/src/assembly/bin.xml @@ -313,7 +313,7 @@ ${pom.artifactId}-${pom.version}/repository/deployment/server/jaggeryapps/ - store/extensions/app/store-device/* + store/extensions/app/store-device-type/* publisher/config/publisher-tenant.json diff --git a/modules/distribution/src/repository/jaggeryapps/publisher/extensions/apps/publisher-device-type/app.js b/modules/distribution/src/repository/jaggeryapps/publisher/extensions/apps/publisher-device-type/app.js new file mode 100644 index 00000000..04a227db --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/publisher/extensions/apps/publisher-device-type/app.js @@ -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'] + } + } +}; diff --git a/modules/distribution/src/repository/jaggeryapps/publisher/extensions/assets/deviceType/asset.js b/modules/distribution/src/repository/jaggeryapps/publisher/extensions/assets/deviceType/asset.js new file mode 100644 index 00000000..8b94530b --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/publisher/extensions/assets/deviceType/asset.js @@ -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' + } + }; +}; \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/publisher/extensions/assets/deviceType/workflows/asset_create.js b/modules/distribution/src/repository/jaggeryapps/publisher/extensions/assets/deviceType/workflows/asset_create.js new file mode 100644 index 00000000..813f5dd3 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/publisher/extensions/assets/deviceType/workflows/asset_create.js @@ -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'); +}; \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/apis/stats-api.jag b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/apis/stats-api.jag similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/apis/stats-api.jag rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/apis/stats-api.jag diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/app.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/app.js similarity index 89% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/app.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/app.js index b4c96882..88762df3 100644 --- a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/app.js +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/app.js @@ -21,18 +21,16 @@ app.server = function(ctx) { return { endpoints: { pages: [{ - title: 'Store | Device Page', - url: 'device_global', - path: 'device_global.jag' - }, { - title: 'Store | Device Splash page', - url: 'devices', - path: 'device_top_assets.jag' - }, { title: 'Store | Analytics', url: 'analytics', path: 'device-analytics.jag', secured:true + },{ + title: 'Store | My Devices Page', + url: 'my-items', + path: 'my_items.jag', + secured:true, + permission:'APP_MYITEMS' }], apis: [{ url: 'stats', @@ -41,7 +39,7 @@ app.server = function(ctx) { }] }, configs: { - disabledAssets: ['ebook', 'api', 'wsdl', 'servicex','policy','proxy','schema','sequence','uri','wadl','endpoint', 'swagger','restservice','comments','soapservice', 'service', 'license', 'gadget', 'site'] + disabledAssets: ['ebook', 'api', 'wsdl', 'servicex','policy','proxy','schema','sequence','uri','wadl','endpoint', 'swagger','restservice','comments','soapservice', 'service', 'license', 'gadget', 'site','server'] } } }; diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device-analytics.jag b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/pages/device-analytics.jag similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device-analytics.jag rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/pages/device-analytics.jag diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/pages/my_items.jag b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/pages/my_items.jag new file mode 100644 index 00000000..a469fb4d --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/pages/my_items.jag @@ -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); %> \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/custom-desktop.css b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/custom-desktop.css similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/custom-desktop.css rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/custom-desktop.css diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/daterangepicker.css b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/daterangepicker.css similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/daterangepicker.css rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/daterangepicker.css diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/detail.css b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/detail.css similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/detail.css rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/detail.css diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/graph.css b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/graph.css similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/graph.css rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/graph.css diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/legend.css b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/legend.css similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/legend.css rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/legend.css diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/lines.css b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/lines.css similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/css/lines.css rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/css/lines.css diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/helpers/analytics.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/helpers/analytics.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/helpers/analytics.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/helpers/analytics.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/helpers/navigation.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/helpers/navigation.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/helpers/navigation.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/helpers/navigation.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/graph_util.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/graph_util.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/graph_util.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/graph_util.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/d3.min.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/d3.min.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/d3.min.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/d3.min.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/jquery-ui.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/jquery-ui.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/jquery-ui.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/jquery-ui.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/jquery.daterangepicker.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/jquery.daterangepicker.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/jquery.daterangepicker.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/jquery.daterangepicker.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/moment.min.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/moment.min.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/moment.min.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/moment.min.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/rickshaw.min.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/rickshaw.min.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/js/libs/rickshaw.min.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/js/libs/rickshaw.min.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/pages/2-column-right.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/pages/2-column-right.hbs similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/pages/2-column-right.hbs rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/pages/2-column-right.hbs diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/partials/analytics.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/analytics.hbs similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/partials/analytics.hbs rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/analytics.hbs diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/my_items.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/my_items.hbs new file mode 100644 index 00000000..79855e5d --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/my_items.hbs @@ -0,0 +1,49 @@ +
+

My Devices

+ {{#if assets.device}} + {{#itr assets}} +
+ +
+ {{#each value.assets}} + {{#attributes}} +
+
+ + {{> asset-thumbnail ..}} + +
+
+ {{overview_name}} + {{overview_provider}} +
+
+ +
+
+
+
+
+
+
+ {{/attributes}} + {{/each}} + {{/itr}} + {{else}} +
+ +

+ {{t "You still haven't any devices from the Store."}} +

+

+ {{t "Add a Device"}} +

+
+ {{/if}} +
+ diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/partials/navigation.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/navigation.hbs similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/partials/navigation.hbs rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/navigation.hbs diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/product-title.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/product-title.hbs new file mode 100644 index 00000000..19c58981 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/partials/product-title.hbs @@ -0,0 +1,2 @@ +

{{t "IoT Server"}}

+

{{t "IoTS"}}

\ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/details.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/details.js new file mode 100644 index 00000000..b0dcf089 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/details.js @@ -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 + } + ] + }); +}; \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/renderers/pages/device-analytics.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/device-analytics.js similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/themes/store/renderers/pages/device-analytics.js rename to modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/device-analytics.js diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/my_items.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/my_items.js new file mode 100644 index 00000000..c7583d12 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device-type/themes/store/renderers/pages/my_items.js @@ -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 + // } + ] + }); +}; diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device_global.jag b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device_global.jag deleted file mode 100644 index 26542378..00000000 --- a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device_global.jag +++ /dev/null @@ -1,6 +0,0 @@ - - - -

New Global Page

- - \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device_top_assets.jag b/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device_top_assets.jag deleted file mode 100644 index 2aae6102..00000000 --- a/modules/distribution/src/repository/jaggeryapps/store/extensions/app/store-device/pages/device_top_assets.jag +++ /dev/null @@ -1,6 +0,0 @@ - - - -

Overriden Top Assets Page

- - \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/asset.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/asset.js new file mode 100644 index 00000000..8b94530b --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/asset.js @@ -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' + } + }; +}; \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/assert-action-link.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/assert-action-link.hbs new file mode 100644 index 00000000..53c9f77c --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/assert-action-link.hbs @@ -0,0 +1,6 @@ +{{#if overview_actionURL}} + {{#if overview_actionName}} +

+ {{overview_actionName}} + {{/if}} +{{/if}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/asset.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/asset.hbs new file mode 100644 index 00000000..c6cacc5c --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/asset.hbs @@ -0,0 +1,112 @@ + +
+ + {{#with assets}} + + + {{#with attributes}} +
+
+

{{../../rxt.singularLabel}} Details

+
+
+
+
+ +
+ +
+
+ {{> asset-thumbnail ..}} +
+
+
+

{{overview_name}}

+

{{t "Version"}} {{overview_version}}

+

{{t "by"}} {{overview_provider}}

+
+
+ ( {{../count}} ) + +
+
+
+ {{!#hasAssetPermission . key="ASSET_BOOKMARK" type=../../rxt.shortName username=../../cuser.username tenantId=../../cuser.tenantId}} + {{!>asset-utilization ../../..}} + {{!/hasAssetPermission}} + {{>assert-action-link}} + {{> asset-version-info ../..}} +
+
+
+ +
+
+
+

Summary

+

{{>overview .}}

+
+ {{>tags ../../.}} +
+
+
+
+ +
+
+ +
+
+
+ {{>overview .}} + {{>quick-startup-steps}} + {{>assert-action-link}} +
+
+
+
+ {{>hardware-setup}} +
+
+
+
+ {{>share ../..}} +
+
+ {{#hasAssetPermission . key="ASSET_REVIEWS" type=../../rxt.shortName username=../../cuser.username tenantId=../../cuser.tenantId}} +
+ {{#if ../../../features.social.enabled}} + + {{/if}} + {{#if ../../../inDashboard}} +
+ {{else}} +
+ {{/if}} +
+ {{/hasAssetPermission}} +
+
+ {{/with}} + {{/with}} +
\ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/hardware-setup.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/hardware-setup.hbs new file mode 100644 index 00000000..7776946b --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/hardware-setup.hbs @@ -0,0 +1,26 @@ + +{{dump .}} +{{#if ingredients_ingredients}} +

Hardware Requirements

+
+ {{#itr ingredients_ingredients}} + + + + {{value}}
+ {{/itr}} +
+{{/if}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/overview.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/overview.hbs new file mode 100644 index 00000000..4839c7d9 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/overview.hbs @@ -0,0 +1,18 @@ + + + +{{overview_description}} + diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/process-asset-text.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/process-asset-text.hbs new file mode 100644 index 00000000..5a3ea6cc --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/process-asset-text.hbs @@ -0,0 +1,4 @@ + +{{t "Add Device"}} + + diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/processed-asset-text.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/processed-asset-text.hbs new file mode 100644 index 00000000..d3bf1f14 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/processed-asset-text.hbs @@ -0,0 +1,4 @@ + +{{t "Added"}} + + \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/product-title.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/product-title.hbs new file mode 100644 index 00000000..d3a64673 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/product-title.hbs @@ -0,0 +1,2 @@ +

{{t "IoT Server"}}

+

{{t "IoT"}}

\ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/quick-startup-steps.hbs b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/quick-startup-steps.hbs new file mode 100644 index 00000000..e6b68dcd --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/partials/quick-startup-steps.hbs @@ -0,0 +1,23 @@ + +{{#if quickStartupSteps_stepDescription}} +

+

Quick Startup Steps

+
+ {{#itr quickStartupSteps_stepDescription}} +

0{{key}} {{value}}

+ {{/itr}} +
+{{/if}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/theme.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/theme.js new file mode 100644 index 00000000..e88eaea0 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/themes/store/theme.js @@ -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 = ''; + break; + case 'options': + output = ''; + 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 = '{{>process-asset-text}}'; + 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 = '{{>process-asset-text}}'; + break; + default: + output = '{{>process-asset-text}}'; + 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; +}; \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/workflows/asset_create.js b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/workflows/asset_create.js new file mode 100644 index 00000000..813f5dd3 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/store/extensions/assets/deviceType/workflows/asset_create.js @@ -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'); +}; \ No newline at end of file diff --git a/modules/samples/arduino/artifact/device.json b/modules/samples/arduino/artifact/device.json deleted file mode 100644 index 4bfd2298..00000000 --- a/modules/samples/arduino/artifact/device.json +++ /dev/null @@ -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" - } -} \ No newline at end of file diff --git a/modules/samples/arduino/artifact/deviceType.json b/modules/samples/arduino/artifact/deviceType.json new file mode 100644 index 00000000..92222a3b --- /dev/null +++ b/modules/samples/arduino/artifact/deviceType.json @@ -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" + } +} \ No newline at end of file diff --git a/modules/samples/common.xml b/modules/samples/common.xml index 597dc07b..d47f03f5 100644 --- a/modules/samples/common.xml +++ b/modules/samples/common.xml @@ -6,7 +6,7 @@ - + diff --git a/modules/samples/raspberrypi/artifact/device.json b/modules/samples/raspberrypi/artifact/device.json deleted file mode 100644 index fbe22d8c..00000000 --- a/modules/samples/raspberrypi/artifact/device.json +++ /dev/null @@ -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" - } -} \ No newline at end of file diff --git a/modules/samples/raspberrypi/artifact/deviceType.json b/modules/samples/raspberrypi/artifact/deviceType.json new file mode 100644 index 00000000..4a341c77 --- /dev/null +++ b/modules/samples/raspberrypi/artifact/deviceType.json @@ -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" + } +} \ No newline at end of file