Skip to content

Commit

Permalink
Merge pull request #141 from charithag/IoTS-1.0.0-M1
Browse files Browse the repository at this point in the history
Update device type listing
  • Loading branch information
ruwany committed Jan 8, 2016
2 parents 9a04356 + 650db0c commit a0a0bc9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<br class="c-both"/>
</tbody>
</table>

</div>
<br class="c-both"/>
<div id="content-filter-types" style="display: none">
Expand All @@ -29,8 +28,56 @@
<a href="#">By Device Type<span class="ico-sort-asc"></span></a>
</div>
</div>

{{#if virtualDeviceTypesList}}
<div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar">
<span class="page-sub-title">Virtual Devices</span>
</div>
</div>
{{#each virtualDeviceTypesList}}
<div class="try-device-container">
<div class="message message-info try-device-message">
<p class="try-device-text">Don't have a device?
<button
href="{{appContext}}/device/{{deviceTypeName}}/enroll"
class="btn btn-default btn-primary">Try
</button>
our {{deviceTypeLabel}} device
</p>
<img class="try-device-image"
src="{{@app.context}}/public/cdmf.unit.device.type.{{deviceTypeName}}.type-view/images/thumb.png">
</div>
</div>
{{/each}}
{{/if}}

{{#zone "topCss"}}
{{css "css/listing-grid.css"}}
<style>
.try-device-container {
position: relative;
}
.try-device-image {
position: absolute;
top: 20px;
left: 10px;
width: 192px;
background: #11375b;
}
.try-device-text {
font-size: 22px;
margin: 80px 190px;
font-weight: 300;
}
.try-device-message {
border-color: transparent;
margin: 20px 10px;
}
</style>
{{/zone}}
{{#zone "bottomJs"}}
<script id="device-listing" data-current-user="{{currentUser.username}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2016, 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
Expand All @@ -21,9 +21,6 @@ function onRequest(context) {
var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType";
var DTYPE_CONF_DEVICE_CATEGORY = "category";
var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label";
var DTYPE_UNIT_NAME_PREFIX = "cdmf.unit.device.type.";
var DTYPE_UNIT_NAME_SUFFIX = ".type-view";
var DTYPE_UNIT_LISTING_TEMPLATE_PATH = "/public/templates/listing.hbs";

var viewModel = {};
var deviceModule = require("/app/modules/device.js").deviceModule;
Expand All @@ -32,30 +29,52 @@ function onRequest(context) {

if (data.data) {
var deviceTypes = data.data;
var deviceTypesList = [];
var deviceTypesList = [], virtualDeviceTypesList = [];
for (var i = 0; i < deviceTypes.length; i++) {

var deviceTypeLabel = deviceTypes[i].name;
var configs = utility.getDeviceTypeConfig(deviceTypeLabel);

if (configs && configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) {
deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
var deviceCategory = "device";
if (configs) {
if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY]) {
deviceCategory = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY];
}
if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) {
deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
}
}
deviceTypesList.push({
"hasCustTemplate": false,
"deviceTypeLabel": deviceTypeLabel,
"deviceTypeName": deviceTypes[i].name,
"deviceCategory": configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY],
"deviceCategory": deviceCategory,
"deviceTypeId": deviceTypes[i].id
});

//if (deviceCategory == 'virtual'){
// virtualDeviceTypesList.push({
// "hasCustTemplate": false,
// "deviceTypeLabel": deviceTypeLabel,
// "deviceTypeName": deviceTypes[i].name,
// "deviceCategory": deviceCategory,
// "deviceTypeId": deviceTypes[i].id
// });
//}else{
// deviceTypesList.push({
// "hasCustTemplate": false,
// "deviceTypeLabel": deviceTypeLabel,
// "deviceTypeName": deviceTypes[i].name,
// "deviceCategory": deviceCategory,
// "deviceTypeId": deviceTypes[i].id
// });
//}
}
if (virtualDeviceTypesList.length > 0) {
viewModel.virtualDeviceTypesList = virtualDeviceTypesList;
}

viewModel.deviceTypesList = stringify(deviceTypesList);
} else {
log.error("Unable to fetch device types data");
throw new Error("Unable to fetch device types!");
}

return viewModel;
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</div>
</span>
<span class="wr-list-desc">
<h3 class="wr-list-name">Device {{name}}</h3>
<h3 class="wr-list-name">{{name}}</h3>
</span>
</div>
<div class="col-lg-6">
Expand Down

0 comments on commit a0a0bc9

Please sign in to comment.