adding old jaggery app

application-manager-new
Rasika Perera 9 years ago
parent 8d5451c589
commit bfab890abd

@ -33,85 +33,27 @@ var carbonHttpsServletTransport = carbon.server.address('https');
var result;
if (uriMatcher.match("/{context}/api/device/sketch/download/{downloadId}")) {
downloadId = uriMatcher.elements().downloadId;
//Just download the already created zip archive
var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils;
var sketchFolder = "repository/resources/sketches";
var archivesPath = "file://"+CarbonUtils.getCarbonHome() + "/" + sketchFolder + "/archives/" + downloadId + ".zip";
var zipFile = new File(archivesPath);
response.addHeader('Content-type', "application/zip, application/octet-stream");
response.addHeader('Cache-Control', 'public,max-age=12960000');
response.addHeader("Content-Disposition", "attachment; filename=\"" + downloadId + ".zip\"");
try {
zipFile.open('r');
var stream = zipFile.getStream();
print(stream);
}catch(err){
}finally{
if(zipFile!=null) {
zipFile.close();
}
}
} else if (uriMatcher.match("/{context}/api/device/sketch/download")) {
//Create a new zip archive and register user calling endpoint
/* This should match with $CARBON_HOME/repository/resources/sketches/{sketchType} */
sketchType = request.getParameter("sketchType");
/* This should be registered device type of the CDMF(Connected Device Management Framework) */
deviceType = request.getParameter("deviceType");
if (!sketchType) {
log.error("Sketch Type is empty!");
// http status code 400 refers to - Bad request.
result = 400;
} else {
var user = session.get(constants.USER_SESSION_KEY);
if (!user) {
response.sendRedirect(dcProps.appContext + "login?#login-required");
exit();
}
//URL: https://localhost:9443/{deviceType}/download?owner={username}
deviceManagerService = carbonHttpsServletTransport + "/" + deviceType + "/manager";
sketchDownloadEndPoint = deviceManagerService + "/device/" + sketchType + "/download";
response.sendRedirect(sketchDownloadEndPoint + "?owner=" + user.username);
exit();//stop execution
}
} else if (uriMatcher.match("/{context}/api/device/sketch/generate_link")) {
var contents = request.getContent();
sketchType = contents.sketchType;
deviceType = contents.deviceType;
generateLink = contents.generateLink;
if (uriMatcher.match("/{context}/api/device/sketch/download")) {
sketchType = request.getParameter("sketchType");
deviceType = request.getParameter("deviceType");
if (!sketchType) {
log.error("Sketch Type is empty!");
// http status code 400 refers to - Bad request.
result = 400;
} else {
var user = session.get(constants.USER_SESSION_KEY);
if (!user) {
result = 403;
}else {
//URL: https://localhost:9443/{deviceType}/download?owner={username}
deviceManagerService = carbonHttpsServletTransport + "/" + deviceType + "/manager";
sketchGenerateLinkEndPoint = deviceManagerService + "/device/" + sketchType + "/generate_link";
var fileId = get(sketchGenerateLinkEndPoint + "?owner=" + user.username, null, "text");
result = carbonHttpsServletTransport + constants.WEB_APP_CONTEXT + "/api/device/sketch/download/" + fileId.data;
}
log.error("Sketch Type is empty");
}
} else if (uriMatcher.match("/{context}/api/devices/all")) {
var user = session.get(constants.USER_SESSION_KEY);
if (!user) {
response.sendRedirect(dcProps.appContext + "login?#login-required");
exit();
}
//URL: https://localhost:9443/{deviceType}/download?owner={username}
deviceManagerService = carbonHttpsServletTransport + "/" + deviceType + "/manager";
sketchDownloadEndPoint = deviceManagerService + "/device/" + sketchType + "/download";
response.sendRedirect(sketchDownloadEndPoint + "?owner=" + user.username);
exit();//stop execution
} else if (uriMatcher.match("/{context}/api/devices/all")) {
var user = session.get(constants.USER_SESSION_KEY);
if (!user) {
response.sendRedirect(dcProps.appContext + "login?#login-required");
@ -124,12 +66,7 @@ if (uriMatcher.match("/{context}/api/device/sketch/download/{downloadId}")) {
var data = {};
//XMLHTTPRequest's GET
try {
result = get(listAllDevicesEndPoint, data, "json");
}catch(err){
log.error("Error occured while retrieveing all devices with username: "+user.username);
result=[];
}
result = get(listAllDevicesEndPoint, data, "json");
} else if (uriMatcher.match("/{context}/api/devices/types")) {

@ -1,31 +0,0 @@
<%
/*
* Copyright (c) 2015, 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 uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri));
var log = new Log("api/operation-api.jag");
var deviceModule = require("/modules/device.js").deviceModule;
if (uriMatcher.match("/{context}/api/operation")) {
payload = request.getContent();
result = deviceModule.performOperation(payload.devices, payload.operation);
}
%>

@ -1,49 +0,0 @@
<%
/*
* Copyright (c) 2015, 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 uri = request.getRequestURI();
var uriMatcher = new URIMatcher(String(uri));
var log = new Log("api/policy-api.jag");
var constants = require("/modules/constants.js");
var dcProps = require('/config/dc-props.js').config();
var policyModule = require("/modules/policy.js").policyModule;
var result;
if (uriMatcher.match("/{context}/api/policies/update")) {
payload = request.getContent();
policyModule.updatePolicyPriorities(payload);
} else if (uriMatcher.match("/{context}/api/policies/{id}/delete")) {
elements = uriMatcher.elements();
policyId = elements.id;
try {
result = policyModule.deletePolicy(policyId);
} catch (e) {
log.error("Exception occurred while trying to delete policy for id:" + policyId, e);
// http status code 500 refers to - Internal Server Error.
result = 500;
}
}
// returning the result.
if (result) {
response.content = result;
}
%>

@ -31,111 +31,118 @@ var statsClient = new Packages.org.wso2.carbon.device.mgt.iot.common.analytics.s
if (uriMatcher.match("/{context}/api/stats")) {
deviceId = request.getParameter("deviceId");
deviceType = request.getParameter("deviceType");
from = request.getParameter("from");
to = request.getParameter("to");
user = session.get(constants.USER_SESSION_KEY);
if (!user) {
response.sendRedirect(dcProps.appContext + "login?#login-required");
exit();
}
log.info("deviceId : " + deviceId + " from : " + from + " to : " + to);
switch (deviceType) {
case "firealarm":
result = getFireAlarmData(user.username, deviceId, from, to);
break;
case "sensebot":
result = getSensebotData(user.username, deviceId, from, to);
break;
case "arduino":
result = getArduinoData(user.username, deviceId, from, to);
break;
case "digital_display":
result = getDigitalDisplayData(user.username, deviceId, from, to);
break;
case "android_sense":
result = getAndroidSenseData(user.username, deviceId, from, to);
break;
case "raspberrypi":
result = getDigitalDisplayData(user.username, deviceId, from, to);
break;
default:
result = new Object();
}
deviceId = request.getParameter("deviceId");
deviceType = request.getParameter("deviceType");
from = request.getParameter("from");
to = request.getParameter("to");
user = session.get(constants.USER_SESSION_KEY);
if (!user) {
response.sendRedirect(dcProps.appContext + "login?#login-required");
exit();
}
log.info("deviceId : " + deviceId + " from : " + from + " to : " + to);
switch (deviceType){
case "firealarm":
result = getFireAlarmData(user.username, deviceId, from, to);
break;
case "sensebot":
result = getSensebotData(user.username, deviceId, from, to);
break;
case "arduino":
result = getArduinoData(user.username, deviceId, from, to);
break;
case "digital_display":
result = getDigitalDisplayData(user.username, deviceId, from, to);
break;
case "android_sense":
result = getAndroidSenseData(user.username, deviceId, from, to);
break;
case "raspberrypi":
result = getDigitalDisplayData(user.username, deviceId, from, to);
break;
default:
result = new Object();
}
}
// returning the result.
if (result) {
print(result);
print(result);
}
function getFireAlarmData(user, deviceId, from, to) {
result = new Object();
result['cpuTemperatureData'] = getSensorData("DEVICE_CPU_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
result['fanData'] = getSensorData("DEVICE_FAN_USAGE_SUMMARY", "status", user, deviceId, from, to);
result['bulbData'] = getSensorData("DEVICE_BULB_USAGE_SUMMARY", "status", user, deviceId, from, to);
return result;
function getFireAlarmData(user, deviceId, from, to){
result = new Object();
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to);
result['fanData'] = getSensorData("DEVICE_FAN_USAGE_SUMMARY","status",user, deviceId, from, to);
result['bulbData'] = getSensorData("DEVICE_BULB_USAGE_SUMMARY","status",user, deviceId, from, to);
return result;
}
function getSensebotData(user, deviceId, from, to) {
result = new Object();
result['sonarData'] = getSensorData("SONAR_SENSOR_SUMMARY", "sonar", user, deviceId, from, to);
result['motionData'] = getSensorData("PIR_MOTION_SENSOR_SUMMARY", "motion", user, deviceId, from, to);
result['lightData'] = getSensorData("LDR_LIGHT_SENSOR_SUMMARY", "light", user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
return result;
function getSensebotData(user, deviceId, from, to){
result = new Object();
result['sonarData'] = getSensorData("SONAR_SENSOR_SUMMARY","sonar",user, deviceId, from, to);
result['motionData'] = getSensorData("PIR_MOTION_SENSOR_SUMMARY","motion",user, deviceId, from, to);
result['lightData'] = getSensorData("LDR_LIGHT_SENSOR_SUMMARY","light",user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to);
return result;
}
function getArduinoData(user, deviceId, from, to) {
result = new Object();
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
return result;
function getArduinoData(user, deviceId, from, to){
result = new Object();
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to);
return result;
}
function getAndroidSenseData(user, deviceId, from, to) {
result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY", "motion", user, deviceId, from, to);
result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY", "light", user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
result['motionData'] = getSensorData("PIR_MOTION_SENSOR_SUMMARY", "motion", user, deviceId, from, to);
return result;
function getDigitalDisplayData(user, deviceId, from, to){
result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY","motion",user, deviceId, from, to);
result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY","light",user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to);
return result;
}
function getDigitalDisplayData(user, deviceId, from, to) {
result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY", "motion", user, deviceId, from, to);
result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY", "light", user, deviceId, from, to);
result['cpuTemperatureData'] = getSensorData("DEVICE_CPU_TEMPERATURE_SUMMARY", "TEMPERATURE", user, deviceId, from, to);
return result;
function getAndroidSenseData(user, deviceId, from, to){
result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY","motion",user, deviceId, from, to);
result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY","light",user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to);
result['motionData'] = getSensorData("PIR_MOTION_SENSOR_SUMMARY","motion",user, deviceId, from, to);
return result;
}
function getDigitalDisplayData(user, deviceId, from, to){
result = new Object();
result['ramData'] = getSensorData("RAM_USAGE_SUMMARY","motion",user, deviceId, from, to);
result['cpuData'] = getSensorData("CPU_LOAD_SUMMARY","light",user, deviceId, from, to);
result['temperatureData'] = getSensorData("DEVICE_TEMPERATURE_SUMMARY","TEMPERATURE",user, deviceId, from, to);
return result;
}
function getSensorData(table, column, user, deviceId, from, to) {
var fetchedData = null;
var fetchedData = null;
try {
fetchedData = statsClient.getDeviceStats(table, column, user, deviceId, from, to);
} catch (error) {
log.error(error);
}
try {
fetchedData = statsClient.getDeviceStats(table, column, user, deviceId, from, to);
}catch(error){
log.info(error);
}
var sensorData = [];
var sensorData = [];
if (fetchedData == null) return [];
if(fetchedData==null) return [];
for (var i = 0; i < fetchedData.size(); i++) {
sensorData.push({
time: fetchedData.get(i).getTime(),
value: fetchedData.get(i).getValue()
});
}
for (var i = 0; i < fetchedData.size(); i++) {
sensorData.push({
time: fetchedData.get(i).getTime(),
value: fetchedData.get(i).getValue()
});
}
return sensorData;
return sensorData;
}
%>

@ -25,9 +25,7 @@ var log = new Log("api/user-api.jag");
var constants = require("/modules/constants.js");
var dcProps = require('/config/dc-props.js').config();
var userModule = require("/modules/user.js").userModule;
var deviceModule = require("/modules/device.js").deviceModule;
var utility = require("/modules/utility.js").utility;
var deviceManagementService = utility.getDeviceManagementService();
var result;
@ -42,15 +40,7 @@ if (uriMatcher.match("/{context}/api/user/login/")) {
if (log.isDebugEnabled()) {
log.debug("User Logged In : " + user);
}
var hasDevcies = (deviceManagementService.getDevicesOfUser(username).size() >= 1);
if(hasDevcies){
response.sendRedirect(constants.WEB_APP_CONTEXT+"/devices");
}else{
response.sendRedirect(constants.WEB_APP_CONTEXT);
}
response.sendRedirect(constants.WEB_APP_CONTEXT);
}, function () {
response.sendRedirect(dcProps.appContext + "login?#auth-failed");
});
@ -79,7 +69,7 @@ if (uriMatcher.match("/{context}/api/user/login/")) {
} else {
userRoles = String(addUserFormData.userRoles).split(",");
}
userRoles="deviceRole, deviceUser"
try {
result = userModule.registerUser(username, firstname, lastname, emailAddress, password,
userRoles);

@ -25,4 +25,4 @@ var carbonServer = new carbonModule.server.Server({
application.put("carbonServer", carbonServer);
var userModule = require("/modules/user.js").userModule;
var utility = require("/modules/utility.js").utility;
utility.insertAppPermissions(userModule, "init");
utility.insertAppPermissions(userModule, "init");

@ -3,25 +3,17 @@
"logLevel": "info",
"initScripts": ["/config/init.js"],
"urlMappings": [
{
"url" : "/testb/*",
"path" : "test.jag"
},
{
"url" : "/test/*",
"path" : "test/testExecutor.jag"
},
{
"url": "/api/device/*",
"path": "/api/device-api.jag"
},
{
"url": "/api/devices/*",
"path": "/api/device-api.jag"
"url": "/api/device/*",
"path": "/api/device-api.jag"
},
{
"url": "/api/operation/*",
"path": "/api/operation-api.jag"
"url": "/api/devices/*",
"path": "/api/device-api.jag"
},
{
"url": "/api/user/*",
@ -35,10 +27,6 @@
"url": "/api/stats/*",
"path": "/api/stats-api.jag"
},
{
"url": "/api/policies/*",
"path": "/api/policy-api.jag"
},
{
"url": "/sso/login",
"path": "/lib/login.jag"
@ -56,4 +44,4 @@
"path": "/lib/fuse.jag"
}
]
}
}

@ -1,44 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ defineZone "title"}}</title>
{{ defineZone "topCss"}}
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-liquid">
<div class="navbar-header">
<a class="navbar-brand" href="#">{{defineZone "brand"}}</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="/login">Login</a></li>
{{ defineZone "upperRight"}}
</ul>
</div>
</div>
</div>
<div id="wrap">
<div class="container-fluid">
<div class="row">
{{ defineZone "content"}}
</div>
</div>
<!-- /container -->
</div>
<div class="footer">
<div class="container">
<div class="row">
<div class="col-md-12">
{{ defineZone "footer"}}
</div>
</div>
</div>
</div>
</body>
</html>

@ -1,15 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="favicon.png" type="image/x-icon" />
{{defineZone "favicon"}}
<title>
{{ defineZone "title"}}
</title>
{{ defineZone "topLibCss"}}
{{ defineZone "topCss"}}
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>{{ defineZone "title"}}</title>
{{ defineZone "topLibCss"}}
{{ defineZone "topCss"}}
{{ defineZone "topJs"}}
</head>
<body>
<div class="wr-modalpopup">
@ -33,7 +32,6 @@
{{ defineZone "body"}}
{{ defineZone "footer"}}
</div>
{{ defineZone "bottomjquery" }}
{{ defineZone "bottomLibJs" }}
{{ defineZone "bottomJs" }}
</body>

@ -22,8 +22,6 @@ var sso = require('/modules/sso.js').sso;
var constants = require('/modules/constants.js');
var carbonModule = require("carbon");
var log = new Log();
var apiWrapperUtil = require("/modules/api-wrapper-util.js").apiWrapperUtil;
var userModule = require("/modules/user.js").userModule;
var keyStoreParams = {
keyStoreName: dataConfig.ssoConfiguration.keyStoreName,
keyStorePassword: dataConfig.ssoConfiguration.keyStorePassword,
@ -33,18 +31,14 @@ sso.configure(dataConfig.ssoConfiguration.issuer,
dataConfig.ssoConfiguration.appName,
keyStoreParams, dataConfig.ssoConfiguration.identityProviderURL);
sso.acs(
function(loggedInUser, samlResponse) {
function(loggedInUser) {
var carbonUser = carbonModule.server.tenantUser(loggedInUser);
session.put(constants.USER_SESSION_KEY, carbonUser);
var username = carbonUser.username;
if(log.isDebugEnabled()){
log.debug("User logged in: "+username);
}
var permissions = userModule.getUIPermissions();
if (permissions.DASHBOARD_VIEW){
apiWrapperUtil.setupAccessTokenPair("saml", samlResponse);
response.sendRedirect(dataConfig.appContext + "/device-mgt");
}
response.sendRedirect(dataConfig.appContext);
}, function() {
if(log.isDebugEnabled()){
log.debug("User logged out");

@ -82,8 +82,41 @@ var route;
};
var renderStatic = function (unit, path) {
log.debug('[' + requestId + '] for unit "' + unit + '" a request received for a static file "' + path + '"');
var staticFile = fuse.getFile(unit, 'public' + path);
var unitModel = null;
var unitName = "";
var parts = (unit + path).split("/");
//'unitName' name can be "unitA" or "categoryA/unitA" or "categoryA/categoryAb/unitB"...etc
//incrementally trying to resolve a unit using url path parts.
for (var i = 0; i < parts.length; i++) {
if (unitName == "") {
unitName = parts[i];
} else {
unitName += "/" + parts[i];
}
try {
var model = fuse.getUnitDefinition(unitName);
if (model) {
unitModel = {
name: model.name,
path: parts.splice(i + 1).join("/")
};
break;
}
} catch (err) {
//unit not found, ignore error
}
}
if (unitModel == null) {
log.error("unit `"+unit+"` not found!");
return false;
}
var staticFile = fuse.getFile(unitModel.name, 'public' + "/" + unitModel.path);
if (staticFile.isExists() && !staticFile.isDirectory()) {
response.addHeader('Content-type', getMime(path));
response.addHeader('Cache-Control', 'public,max-age=12960000');
@ -106,7 +139,7 @@ var route;
if (jagFile.isExists()) {
include(jagFile.getPath());
return true;
}else{
} else {
return false;
}
};

@ -1,4 +1,5 @@
<%
var getPath = File.prototype.getPath;
File.prototype.getPath = function() {
var path = getPath.call(this);
@ -10,7 +11,7 @@ File.prototype.getPath = function() {
var fuseState = {
zones: {},
appName: '',
currentZone: [], //TODO: rename to zone Stack
zoneStack: [],
currentUnit: null
};

@ -15,6 +15,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
for (var i = 0; i < definitions.length; i++) {
var definition = definitions[i];
lookUpTable[definition.name] = i;
//log.info("initLookUp()"+definition.name+"<-"+i);
}
}
};
@ -45,6 +46,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
};
var getAncestorModels = function (unit) {
//log.info('[' + requestId + '] getAncestorModels()'+unit);
var unitModel = getUnitDefinition(unit);
var ancestors = [unitModel];
var parentName;
@ -148,11 +150,12 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
};
getUnitDefinition = function (unit) {
//log.info('[' + requestId + '] getUnitDefinition()'+unit);
var definitions = getUnitDefinitions();
initLookUp(definitions);
//log.info('[' + requestId + '] lookUpTable[unit]:'+unit);
var model = definitions[lookUpTable[unit]];
if (!model) {
log.warn('[' + requestId + '] unit "' + unit + '" does not exits');
throw '[' + requestId + '] unit "' + unit + '" does not exits';
}
return model;
@ -205,7 +208,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
var unitDir = unitDirs[i];
if (unitDir.isDirectory()) {
var unitName = unitDir.getName();
//log.info("reading: "+unitName + " basePath:"+basePath);
//log.info("reading: "+unitName + " basePath:'" + basePath + "'");
var definitionFile = new File(fuse.getUnitPath(basePath+unitName) + '/' + unitName + '.json');
if(definitionFile.isExists()) {
@ -381,6 +384,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
* @returns {File}
*/
getFile = function (unitName, path, opt_suffix) {
//log.info("getFile() unitName:"+unitName+", path:"+path+", opt_suffix:"+opt_suffix);
var slashPath = ((path[0] === '/') ? '' : '/') + path;
var selfFileName = '';
var fileName = '';
@ -399,8 +403,10 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
var unitDef = getUnitDefinition(unitName);
if (unitDef.path.indexOf('.hbs', unitDef.path.length - 4) !== -1) {
if (opt_suffix.indexOf('.hbs', opt_suffix.length - 4) !== -1) {
//log.info("1:"+unitDef.path);
return new File(unitDef.path);
} else {
//log.info("2:"+unitDef.path.replace(/.hbs$/, opt_suffix));
return new File(unitDef.path.replace(/.hbs$/, opt_suffix));
}
}
@ -411,7 +417,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
'[' + requestId + '] for unit "' + unitName + '" file resolved : "'
+ slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"'
);
//log.info("3:"+getUnitPath(unitName) + slashPath + selfFileName);
return selfFile;
}
@ -431,6 +437,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
'[' + requestId + '] for unit "' + unitName + '" file resolved : "'
+ slashPath + selfFileName + '" -> "' + file.getPath() + '"'
);
//log.info("4:"+getUnitPath(ancestorName) + slashPath + fileName);
return file;
}
}
@ -438,6 +445,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors,
'[' + requestId + '] for unit "' + unitName + '" (non-excising) file resolved : "'
+ slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"'
);
//log.info("5:"+getUnitPath(unitName) + slashPath + selfFileName);
return selfFile;
};

@ -56,7 +56,7 @@ Handlebars.innerZonesFromUnit = null;
Handlebars.registerHelper('defineZone', function (zoneName, zoneContent) {
var result = '';
var zone = Handlebars.Utils.escapeExpression(zoneName);
fuseState.currentZone.push(zone);
fuseState.zoneStack.push(zone);
var unitsToRender = fuseState.zones[zone] || [];
if (Handlebars.innerZones.length > 0) {
@ -92,12 +92,12 @@ Handlebars.registerHelper('defineZone', function (zoneName, zoneContent) {
return result;
}
fuseState.currentZone.pop();
fuseState.zoneStack.pop();
return new Handlebars.SafeString(result);
});
Handlebars.registerHelper('zone', function (zoneName, zoneContent) {
var currentZone = fuseState.currentZone[fuseState.currentZone.length - 1];
var currentZone = fuseState.zoneStack[fuseState.zoneStack.length - 1];
if (currentZone == null) {
return 'zone_' + zoneName + ' ';
}
@ -113,7 +113,7 @@ Handlebars.registerHelper('zone', function (zoneName, zoneContent) {
});
Handlebars.registerHelper('layout', function (layoutName) {
var currentZone = fuseState.currentZone[fuseState.currentZone.length - 1];
var currentZone = fuseState.zoneStack[fuseState.zoneStack.length - 1];
if (currentZone == null) {
return 'layout_' + layoutName;
} else {
@ -122,7 +122,7 @@ Handlebars.registerHelper('layout', function (layoutName) {
});
Handlebars.registerHelper('authorized', function () {
var currentZone = fuseState.currentZone[fuseState.currentZone.length - 1];
var currentZone = fuseState.zoneStack[fuseState.zoneStack.length - 1];
if (currentZone == null) {
return '';
} else {
@ -155,11 +155,11 @@ Handlebars.registerHelper('unit', function (unitName,options) {
log.error('unit does not have a main zone');
}
//TODO warn when unspecified decencies are included.
fuseState.currentZone.push('main');
fuseState.zoneStack.push('main');
var template = fuse.getFile(baseUnit, '', '.hbs');
log.debug('[' + requestId + '] including "' + baseUnit + '"'+" with configs "+stringify(templateConfigs));
var result = new Handlebars.SafeString(Handlebars.compileFile(template)(getScope(baseUnit,templateConfigs)));
fuseState.currentZone.pop();
fuseState.zoneStack.pop();
return result;
});
@ -192,6 +192,7 @@ Handlebars.registerHelper('equal', function(lvalue, rvalue, options) {
return options.fn(this);
}
});
Handlebars.registerHelper('unequal', function(lvalue, rvalue, options) {
if (arguments.length < 3)
throw new Error("Handlebars Helper equal needs 2 parameters");

@ -10190,7 +10190,7 @@ var compile = function (args) {
var parser = new less.Parser(options);
parser.parse(input, function (e, root) {
if (e) {
log.error(e);
log.info(e);
writeError(e, options);
quit(1);
} else {

@ -1,41 +0,0 @@
/*
* Copyright (c) 2015, 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 apiWrapperUtil = function () {
var module = {};
var tokenUtil = require("/modules/util.js").util;
module.refreshToken = function () {
var tokenPair = session.get("accessTokenPair");
tokenPair = tokenUtil.refreshToken(tokenPair);
session.put("accessTokenPair", tokenPair);
response.addCookie({'name': 'accessToken', 'value': tokenPair.accessToken});
};
module.setupAccessTokenPair = function (type, properties) {
var tokenPair;
var clientId = "pY0FbBUC_GI7mfHVS1FvhWAifEwa";
var clientSecret = "Tu5Za1R3fHtGc5yH4KK8TNiLVSca";
if (type == "password") {
//tokenPair = tokenUtil.getTokenWithPasswordGrantType(properties.username, properties.password, clientId, clientSecret);
} else if (type == "saml") {
}
//session.put("accessTokenPair", tokenPair);
//response.addCookie({'name': 'accessToken', 'value': tokenPair.accessToken});
};
return module;
}();

@ -20,7 +20,7 @@ var WEB_APP_TITLE = "WSO2 DC - Device Cloud";
var WEB_APP_CONTEXT = "/iotserver";
var USER_SESSION_KEY = "USER";
var UNSPECIFIED = "Unspecified";
var DEVICES_UNIT_PATH="/units/";
var DEVICES_UNIT_PATH="/units/devices/";
var DEVICE_IDENTIFIER = "deviceIdentifier";
var DEVICE_NAME = "name";
@ -38,7 +38,7 @@ var FEATURE_DESCRIPTION = "featureDescription";
var PLATFORM_ANDROID = "android";
var PLATFORM_IOS = "ios";
var DEVICE_ENROLLMENT = "dateOfEnrolment";
var DEVICE_ENROLLMENT = "enrollment";
var VENDOR_APPLE = "Apple";
var ERRORS = {

@ -36,7 +36,7 @@ deviceModule = function () {
var deviceManagementDAOFactory = Packages.org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
var deviceManagementService = utility.getDeviceManagementService();
var publicMethods = {};
var privateMethods = {};
@ -167,7 +167,7 @@ deviceModule = function () {
var data = {};
//XMLHTTPRequest's GET
//log.info(removeDeviceEndpoint);
log.info(removeDeviceEndpoint);
return del(removeDeviceEndpoint, data, "text");
};
@ -178,8 +178,8 @@ deviceModule = function () {
var data = {};
//XMLHTTPRequest's POST
//log.info(updateDeviceEndpoint+ "?name="+device.name);
return post(updateDeviceEndpoint + "?name=" + encodeURIComponent(device.name), data, "text");
log.info(updateDeviceEndpoint+ "?name="+device.name);
return post(updateDeviceEndpoint+ "?name="+device.name, data, "text");
};
/*
@ -257,8 +257,8 @@ deviceModule = function () {
var deviceObject = {};
deviceObject[constants.DEVICE_IDENTIFIER] = device.getDeviceIdentifier();
deviceObject[constants.DEVICE_NAME] = privateMethods.validateAndReturn(device.getName());
deviceObject[constants.DEVICE_OWNERSHIP] = privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwnership());
deviceObject[constants.DEVICE_OWNER] = device.getEnrolmentInfo().getOwner();
deviceObject[constants.DEVICE_OWNERSHIP] = privateMethods.validateAndReturn(device.getOwnership());
deviceObject[constants.DEVICE_OWNER] = device.getOwner();
deviceObject[constants.DEVICE_TYPE] = device.getType();
if (device.getType() == constants.PLATFORM_IOS) {
properties[constants.DEVICE_MODEL] = properties[constants.DEVICE_PRODUCT];
@ -266,13 +266,11 @@ deviceModule = function () {
properties[constants.DEVICE_VENDOR] = constants.VENDOR_APPLE;
}
deviceObject[constants.DEVICE_PROPERTIES] = properties;
log.info("-------------------------");
log.info(device.getEnrolmentInfo().getDateOfEnrolment());
deviceObject[constants.DEVICE_ENROLLMENT] = device.getEnrolmentInfo().getDateOfEnrolment();
deviceObject[constants.DEVICE_ENROLLMENT] = device.getDateOfEnrolment();
return deviceObject;
}
};
return publicMethods;
}();
}();

@ -1,85 +0,0 @@
/*
* Copyright (c) 2015, 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 policyModule;
policyModule = function () {
var log = new Log("modules/policy.js");
var constants = require("/modules/constants.js");
var utility = require("/modules/utility.js").utility;
var userManagementService = utility.getUserManagementService();
var publicMethods = {};
var privateMethods = {};
publicMethods.getPolicies = function () {
//TODO-This method returns includes dummy policy data
var policies = [];
var policyObj = {
"id":1, // Identifier of the policy.
"priorityId":1, // Priority of the policies. This will be used only for simple evaluation.
"profile":{}, // Profile
"policyName":"Turn off light", // Name of the policy.
"generic":true, // If true, this should be applied to all related device.
"roles":{}, // Roles which this policy should be applied.
"ownershipType":{}, // Ownership type (COPE, BYOD, CPE)
"devices":{}, // Individual devices this policy should be applied
"users":{}, // Individual users this policy should be applied
"Compliance":{},
"policyCriterias":{},
"startTime":283468236, // Start time to apply the policy.
"endTime":283468236, // After this time policy will not be applied
"startDate":"", // Start date to apply the policy
"endDate":"", // After this date policy will not be applied.
"tenantId":-1234,
"profileId":1
};
policies.push(policyObj);
policyObj = {
"id":2, // Identifier of the policy.
"priorityId":1, // Priority of the policies. This will be used only for simple evaluation.
"profile":{}, // Profile
"policyName":"Turn on Buzzer", // Name of the policy.
"generic":false, // If true, this should be applied to all related device.
"roles":{}, // Roles which this policy should be applied.
"ownershipType":{}, // Ownership type (COPE, BYOD, CPE)
"devices":{}, // Individual devices this policy should be applied
"users":{}, // Individual users this policy should be applied
"Compliance":{},
"policyCriterias":{},
"startTime":283468236, // Start time to apply the policy.
"endTime":283468236, // After this time policy will not be applied
"startDate":"", // Start date to apply the policy
"endDate":"", // After this date policy will not be applied.
"tenantId":-1234,
"profileId":2
};
policies.push(policyObj);
return policies;
};
return publicMethods;
}();

@ -252,9 +252,7 @@ userModule = function () {
log.error("User object was not found in the session");
throw constants.ERRORS.USER_NOT_FOUND;
}
var userList = userManagementService.getUsersForTenant(carbonUser.tenantId);
var i, userObject;
for (i = 0; i < userList.size(); i++) {
userObject = userList.get(i);
@ -310,34 +308,6 @@ userModule = function () {
return permissions;
};
/**
* Get User Roles from user store.
* If "Internal/Everyone" role is required - true param needs to be passed.
* @param enableInternalEveryone boolean value true/false to enable Internal/Everyone role
*/
publicMethods.getRoles = function (enableInternalEveryone) {
var carbonModule = require("carbon");
var carbonServer = application.get("carbonServer");
var carbonUser = session.get(constants.USER_SESSION_KEY);
if (!carbonUser) {
log.error("User object was not found in the session");
throw constants.ERRORS.USER_NOT_FOUND;
}
var userManager = new carbonModule.user.UserManager(carbonServer, carbonUser.tenantId);
var allRoles = userManager.allRoles();
var filteredRoles = [];
var i;
for (i = 0; i < allRoles.length; i++) {
if (enableInternalEveryone && allRoles[i] == "Internal/everyone") {
filteredRoles.push(allRoles[i]);
}
if (allRoles[i].indexOf("Internal/") != 0) {
filteredRoles.push(allRoles[i]);
}
}
return filteredRoles;
};
publicMethods.logout = function (successCallback) {
session.invalidate();
successCallback();

@ -1,89 +0,0 @@
/*
* Copyright (c) 2015, 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 util = function () {
var module = {};
var Base64 = Packages.org.apache.commons.codec.binary.Base64;
var String = Packages.java.lang.String;
var log = new Log();
/**
* Encode the payload in Base64
* @param payload
* @returns {Packages.java.lang.String}
*/
function encode(payload){
return new String(Base64.encodeBase64(new String(payload).getBytes()));
}
/**
* Get an AccessToken pair based on username and password
* @param username
* @param password
* @param clientId
* @param clientSecret
* @param scope
* @returns {{accessToken: "", refreshToken: ""}}
*/
module.getTokenWithPasswordGrantType = function (username, password, clientId, clientSecret, scope) {
var xhr = new XMLHttpRequest();
var tokenEndpoint = "https://localhost:9443/oauth2/token";
var encodedClientKeys = encode(clientId + ":" + clientSecret);
xhr.open("POST", tokenEndpoint, false);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Authorization", "Basic " + encodedClientKeys);
xhr.send("grant_type=password&username=" + username + "&password=" + password + "&scope=" + scope);
delete password, delete clientSecret, delete encodedClientKeys;
var tokenPair = {};
if (xhr.status == 200) {
var data = parse(xhr.responseText);
tokenPair.refreshToken = data.refresh_token;
tokenPair.accessToken = data.access_token;
} else if (xhr.status == 403) {
throw "Error in obtaining token with Password Grant Type";
} else {
throw "Error in obtaining token with Password Grant Type";
}
return tokenPair;
};
module.getTokenWithSAMLGrantType = function () {
};
module.refreshToken = function(tokenPair){
var xhr = new XMLHttpRequest();
var tokenEndpoint = "https://localhost:9443/oauth2/token";
var encodedClientKeys = encode(clientId + ":" + clientSecret);
xhr.open("POST", tokenEndpoint, false);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Authorization", "Basic " + encodedClientKeys);
xhr.send("grant_type=refresh_token&refresh_token=" + tokenPair.refreshToken + "&scope=" + scope);
delete password, delete clientSecret, delete encodedClientKeys;
var tokenPair = {};
if (xhr.status == 200) {
var data = parse(xhr.responseText);
tokenPair.refreshToken = data.refresh_token;
tokenPair.accessToken = data.access_token;
} else if (xhr.status == 403) {
throw "Error in obtaining token with Password Grant Type";
} else {
throw "Error in obtaining token with Password Grant Type";
}
return tokenPair;
};
return module;
}();

@ -20,7 +20,6 @@ var utility;
utility = function () {
var JavaClass = Packages.java.lang.Class;
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext;
var userManagement = Packages.org.wso2.carbon.device.mgt.iot.common.UserManagement();
var getOsgiService = function (className) {
return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(JavaClass.forName(className));
@ -33,7 +32,7 @@ utility = function () {
};
publicMethods.getUserManagementService = function () {
return userManagement;
return getOsgiService('org.wso2.carbon.device.mgt.user.core.UserManager');
};
publicMethods.getPolicyManagementService = function () {
@ -42,52 +41,22 @@ utility = function () {
publicMethods.insertAppPermissions = function (userModule, type) {
userModule.addPermissions([{key: "device-mgt", name: "Device Management"}], "", type);
userModule.addPermissions([{
key: "admin",
name: "Device Management Admin"
}], "device-mgt", type);
userModule.addPermissions([{
key: "user",
name: "Device Management User"
}], "device-mgt", type);
userModule.addPermissions([{key: "admin", name: "Device Management Admin"}], "device-mgt", type);
userModule.addPermissions([{key: "user", name: "Device Management User"}], "device-mgt", type);
userModule.addPermissions([{key: "devices", name: "Devices"}], "device-mgt/admin", type);
userModule.addPermissions([{
key: "devices/list",
name: "List Devices"
}], "device-mgt/admin", type);
userModule.addPermissions([{
key: "devices/operation",
name: "Perform Operation"
}], "device-mgt/admin", type);
userModule.addPermissions([{key: "devices/list", name: "List Devices"}], "device-mgt/admin", type);
userModule.addPermissions([{key: "devices/operation", name: "Perform Operation"}], "device-mgt/admin", type);
userModule.addPermissions([{key: "users", name: "Users"}], "device-mgt/admin", type);
userModule.addPermissions([{
key: "users/add",
name: "Add New Users"
}], "device-mgt/admin", type);
userModule.addPermissions([{
key: "users/invite",
name: "Invite Users"
}], "device-mgt/admin", type);
userModule.addPermissions([{
key: "users/list",
name: "List Users"
}], "device-mgt/admin", type);
userModule.addPermissions([{
key: "users/remove",
name: "Remove Users"
}], "device-mgt/admin", type);
userModule.addPermissions([{key: "users/add", name: "Add New Users"}], "device-mgt/admin", type);
userModule.addPermissions([{key: "users/invite", name: "Invite Users"}], "device-mgt/admin", type);
userModule.addPermissions([{key: "users/list", name: "List Users"}], "device-mgt/admin", type);
userModule.addPermissions([{key: "users/remove", name: "Remove Users"}], "device-mgt/admin", type);
userModule.addPermissions([{key: "devices", name: "Devices"}], "device-mgt/user", type);
userModule.addPermissions([{
key: "devices/list",
name: "List Devices"
}], "device-mgt/user", type);
userModule.addPermissions([{
key: "devices/operation",
name: "Perform Operation"
}], "device-mgt/user", "init");
userModule.addPermissions([{key: "devices/list", name: "List Devices"}], "device-mgt/user", type);
userModule.addPermissions([{key: "devices/operation", name: "Perform Operation"}], "device-mgt/user", "init");
};
return publicMethods;

@ -1,4 +1,3 @@
{{authorized}}
{{layout "fluid"}}
{{#zone "title"}}
WSO2 DC | Device Cloud

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "android"}}
{{unit "devices/android"}}
{{/zone}}

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "android_sense"}}
{{unit "devices/android_sense"}}
{{/zone}}

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "arduino"}}
{{unit "devices/arduino"}}
{{/zone}}

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "digital_display"}}
{{unit "devices/digital_display"}}
{{/zone}}

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "firealarm"}}
{{unit "devices/firealarm"}}
{{/zone}}

@ -4,7 +4,7 @@
Devices
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="device-mgt" title="My Devices"}}
{{unit "appbar" link="device-mgt" title="Device Management"}}
{{unit "extended-search-box"}}
{{unit "operation-mod"}}
<div class="wr-device-list row">

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "raspberrypi"}}
{{unit "devices/raspberrypi"}}
{{/zone}}

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "sensebot"}}
{{unit "devices/sensebot"}}
{{/zone}}

@ -4,5 +4,5 @@
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="store" title="STORE"}}
{{unit "windows"}}
{{unit "devices/windows"}}
{{/zone}}

@ -1,9 +0,0 @@
{{authorized}}
{{layout "fluid"}}
{{#zone "title"}}
WSO2 DC | Add New Policy
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="policies" title="My Policies"}}
{{unit "policy-create"}}
{{/zone}}

@ -1,21 +0,0 @@
{{authorized}}
{{layout "fluid"}}
{{#zone "title"}}
Policies
{{/zone}}
{{#zone "body"}}
{{unit "appbar" link="policies" title="My Policies"}}
{{unit "extended-search-box"}}
<div class="wr-device-list row">
<div class="wr-hidden-operations wr-advance-operations">
</div>
<div class="col-md-12 wr-page-content">
<!-- content -->
<div>
{{unit "policy-listing"}}
</div>
<!-- /content -->
</div>
</div>
{{/zone}}

@ -1,100 +0,0 @@
/*
* Copyright (c) 2015, 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.
*/
describe('Device Module', function () {
var log = new Log();
var mobileDB;
var cdmDB;
var deviceModule = require("/modules/device.js").deviceModule;
function tearUp() {
mobileDB = new Database("MobileDM_DS");
cdmDB = new Database("DM_DS");
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
" 1,'4892813d-0b18-4a02-b7b1-61775257488e', 'admin@wso2.com', '-1234');");
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
" 1,'4892813d-0b18-4a02-b7b1-61775257488F', 'mdm@wso2.com', '-1234');");
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
"values ('4892813d-0b18-4a02-b7b1-61775257488e', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
"'ksdfjlskfjwer', '234234');");
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
"values ('4892813d-0b18-4a02-b7b1-61775257488F', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
"'ksdfjlskfjwer', '234234');");
}
function tearDown() {
deleteData();
mobileDB.close();
cdmDB.close();
}
function deleteData(){
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488e'");
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488F'");
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488e'");
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488F'");
}
it('List all Devices - Device Module', function () {
try {
tearUp();
var results = deviceModule.listDevices();
expect(results.length).not.toBe(0);
} catch (e) {
log.error(e);
throw e;
} finally {
tearDown();
}
});
it('List Devices for User - Device Module', function () {
try {
tearUp();
var results = deviceModule.listDevicesForUser("mdm@wso2.com");
expect(results.length).toBe(1);
} catch (e) {
log.error(e);
throw e;
} finally {
tearDown();
}
});
it('Perform operation on the device', function(){
try {
tearUp();
var devices = [{"id": "4892813d-0b18-4a02-b7b1-61775257488e", "type": "android"}];
var operation = {"featureName": "DEVICE_LOCK", "type": "COMMAND", "properties": {"enabled": true}}
var results = deviceModule.performOperation(devices, operation);
expect(results.length).toBe(1);
} catch (e) {
log.error(e);
throw e;
} finally {
tearDown();
}
});
});

@ -1,88 +0,0 @@
/*
* Copyright (c) 2015, 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.
*/
describe('Device Module', function () {
var log = new Log();
var mobileDB;
var cdmDB;
var deviceModule = require("/modules/device.js").deviceModule;
var userModule = require("/modules/user.js").userModule;
var constants = require("/modules/constants.js");
function tearUp() {
mobileDB = new Database("MobileDM_DS");
cdmDB = new Database("DM_DS");
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
" 1,'4892813d-0b18-4a02-b7b1-61775257488e', 'admin@wso2.com', '-1234');");
cdmDB.query("insert into dm_device(description, name, date_of_enrollment, date_of_last_update, " +
"ownership,status, device_type_id, device_identification, owner, tenant_id ) " +
"values ('Galaxy Tab','Admin Samsung', 1425467382, 1425467382, 'BYOD', 'ACTIVE'," +
" 1,'4892813d-0b18-4a02-b7b1-61775257488F', 'mdm@wso2.com', '-1234');");
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
"values ('4892813d-0b18-4a02-b7b1-61775257488e', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
"'ksdfjlskfjwer', '234234');");
mobileDB.query("insert into mbl_device (mobile_device_id, push_token, imei ,imsi, os_version, " +
"device_model , vendor ,latitude ,longitude , challenge ,token, unlock_token ,serial ) " +
"values ('4892813d-0b18-4a02-b7b1-61775257488F', 'sdfsdf', 'cxv', 'vbcb', '4.1', " +
"'Galaxy Tab', 'Samsung', '234234234', '4345345234234', 'dfjsdlfk', 'wuweir234', " +
"'ksdfjlskfjwer', '234234');");
session.put(constants.USER_SESSION_KEY, {"username" : "admin", "domain": "carbon.super", "tenantId": "-1234"});
}
function tearDown() {
deleteData();
mobileDB.close();
cdmDB.close();
session.put(constants.USER_SESSION_KEY, null);
}
function deleteData(){
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488e'");
cdmDB.query("delete from dm_device where device_identification='4892813d-0b18-4a02-b7b1-61775257488F'");
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488e'");
mobileDB.query("delete from mbl_device where mobile_device_id='4892813d-0b18-4a02-b7b1-61775257488F'");
}
it('List all users', function () {
try {
tearUp();
var results = userModule.getUsers();
expect(results.length).not.toBe(0);
} catch (e) {
log.error(e);
throw e;
} finally {
tearDown();
}
});
it('Check permission for user', function () {
try {
tearUp();
expect(userModule.isAuthorized("/permission/device-mgt/user/devices/list")).toBe(true);
} catch (e) {
log.error(e);
throw e;
} finally {
tearDown();
}
});
});

@ -48,8 +48,6 @@
</div>
<div id="div-bulbData">
</div>
<div id="div-cpuTemperatureData">
</div>
<div id="div-CPUData">
</div>
<div id="div-RAMData">
@ -72,5 +70,4 @@
<script src="{{self.publicURL}}/js/graphs/sonar_graph.js"></script>
<script src="{{self.publicURL}}/js/graphs/cpu_graph.js"></script>
<script src="{{self.publicURL}}/js/graphs/ram_graph.js"></script>
<script src="{{self.publicURL}}/js/graphs/cpu_temperature_graph.js"></script>
{{/zone}}

@ -1,10 +1,6 @@
var fromDate;
var toDate;
var currentDay = new Date();
var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
var endDate = new Date(currentDay.getTime());
// create a custom bar renderer that has no gaps
Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Bar, {
name: 'bar_no_gap',
@ -15,11 +11,10 @@ Rickshaw.Graph.Renderer.BarNoGap = Rickshaw.Class.create(Rickshaw.Graph.Renderer
}
});
function initDate(){
currentDay = new Date();
startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
endDate = new Date(currentDay.getTime());
}
var currentDay = new Date();
var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100));
var endDate = new Date(currentDay.getTime());
var configObject = {
startOfWeek: 'monday',
@ -43,7 +38,6 @@ var configObject = {
var DateRange = convertDate(startDate) + " " + configObject.separator + " " + convertDate(endDate);
$(document).ready(function () {
initDate();
$('#date-range').dateRangePicker(configObject)
.bind('datepicker-apply', function (event, dateRange) {
$(this).addClass('active');
@ -67,25 +61,21 @@ $(document).ready(function () {
//day picker
$('#today-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 86400000, currentDay.getTime());
});
//hour picker
$('#hour-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 3600000, currentDay.getTime());
});
})
//week picker
$('#week-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - 604800000, currentDay.getTime());
});
})
//month picker
$('#month-btn').on('click', function () {
initDate();
getDateTime(currentDay.getTime() - (604800000 * 4), currentDay.getTime());
});
@ -158,77 +148,69 @@ function updateGraphs(stats) {
console.log(stats);
var temperatureData = stats['temperatureData'];
if (typeof temperatureData != 'undefined') {
if (typeof temperatureData != 'undefined'){
$('#div-temperatureData').html("").html("<div class='row margin-double'><div><h2 class='grey'>Temperature</h2><hr><div id='canvas-wrapper1'></div></div><hr></div>");
updateTemperatureGraph(convertStatsToGraphData(temperatureData));
} else {
}else{
$('#div-temperatureData').html("");
}
var lightData = stats['lightData'];
if (typeof lightData != 'undefined') {
if (typeof lightData != 'undefined'){
$('#div-lightData').html("").html("<div class='row margin-double'><div><h2 class='grey'>Light</h2><hr><div id='canvas-wrapper2'></div></div><hr></div>");
updateLightGraph(convertStatsToGraphData(lightData));
} else {
}else{
$('#div-lightData').html("");
}
var motionData = stats['motionData'];
if (typeof motionData != 'undefined') {
if (typeof motionData != 'undefined'){
$('#div-motionData').html("").html("<div class='row margin-double'><div><h2 class='grey'>Motion</h2><hr><div id='canvas-wrapper3'></div></div><hr></div>");
updateMotionGraph(convertStatsToGraphData(motionData));
} else {
}else{
$('#div-motionData').html("");
}
var sonarData = stats['sonarData'];
if (typeof sonarData != 'undefined') {
if (typeof sonarData != 'undefined'){
$('#div-sonarData').html("").html("<div class='row margin-double'><div><h2 class='grey'>Sonar</h2><hr><div id='canvas-wrapper4'></div></div><hr></div>");
updateSonarGraph(convertStatsToGraphData(sonarData));
} else {
}else{
$('#div-sonarData').html("");
}
var fanData = stats['fanData'];
if (typeof fanData != 'undefined') {
if (typeof fanData != 'undefined'){
$('#div-fanData').html("").html("<div class='row margin-double'><div><h2 class='grey'>Fan Status</h2><hr><div id='canvas-wrapper5'></div></div><hr></div>");
updateFanGraph(convertStateStatsToGraphData(fanData));
} else {
}else{
$('#div-fanData').html("");
}
var bulbData = stats['bulbData'];
if (typeof bulbData != 'undefined') {
if (typeof bulbData != 'undefined'){
$('#div-bulbData').html("").html("<div class='row margin-double'><div><h2 class='grey'>Bulb Status</h2><hr><div id='canvas-wrapper6'></div></div><hr></div>");
updateBulbGraph(convertStateStatsToGraphData(bulbData));
} else {
}else{
$('#div-bulbData').html("");
}
var cpuData = stats['cpuData'];
if (typeof cpuData != 'undefined') {
if (typeof cpuData != 'undefined'){
$('#div-CPUData').html("").html("<div class='row margin-double'><div><h2 class='grey'>CPU Load</h2><hr><div id='canvas-wrapper7'></div></div><hr></div>");
updateCPUGraph(convertStateStatsToGraphData(cpuData));
} else {
}else{
$('#div-CPUData').html("");
}
var ramData = stats['ramData'];
if (typeof ramData != 'undefined') {
if (typeof ramData != 'undefined'){
$('#div-RAMData').html("").html("<div class='row margin-double'><div><h2 class='grey'>RAM Usage</h2><hr><div id='canvas-wrapper8'></div></div><hr></div>");
updateRAMGraph(convertStateStatsToGraphData(ramData));
} else {
}else{
$('#div-RAMData').html("");
}
var cpuTemperatureData = stats['cpuTemperatureData'];
if (typeof cpuTemperatureData != 'undefined') {
$('#div-cpuTemperatureData').html("").html("<div class='row margin-double'><div><h2 class='grey'>CPU Temperature</h2><hr><div id='canvas-wrapper9'></div></div><hr></div>");
updateCPUTemperatureGraph(convertStatsToGraphData(cpuTemperatureData));
} else {
$('#div-cpuTemperatureData').html("");
}
scaleGraphs();
}
@ -237,18 +219,8 @@ function scaleGraphs() {
if (sliders.length == 0) {
return;
}
var graphWidth = 0;
for (var i = 1; i < 10; i++){
if ($('#canvas-wrapper' + i).length){
graphWidth = $('#canvas-wrapper' + i).width() - 50;
break;
}
}
if (graphWidth <= 0){
return;
}
var graphWidth = $('#canvas-wrapper1').width() - 50;
//Scale graphs
var sliderX = graphWidth * 60 * 60 / (toDate - fromDate);
if (sliderX < graphWidth) {
@ -311,9 +283,9 @@ function convertStateStatsToGraphData(stats) {
function convertDate(date) {
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var hour=date.getHours();
var minute=date.getMinutes();
return date.getFullYear() + '-' + (('' + month).length < 2 ? '0' : '')
+ month + '-' + (('' + day).length < 2 ? '0' : '') + day + " " + (('' + hour).length < 2 ? '0' : '')
+ hour + ":" + (('' + minute).length < 2 ? '0' : '') + minute;
+ month + '-' + (('' + day).length < 2 ? '0' : '') + day +" "+ (('' + hour).length < 2 ? '0' : '')
+ hour +":"+(('' + minute).length < 2 ? '0' : '')+ minute;
}

@ -1,70 +0,0 @@
function updateCPUTemperatureGraph(temperatureData) {
console.log("cpuTemperatureData");
renderCPUTemperatureChart(temperatureData);
}
function renderCPUTemperatureChart(chartDataRaw) {
var chartWrapperElmId = "#canvas-wrapper9";
var graphWidth = $(chartWrapperElmId).width() - 50;
if (chartDataRaw.length == 0) {
$(chartWrapperElmId).html("No data available...");
return;
}
var chartData = [];
for (var i = 0; i < chartDataRaw.length; i++) {
chartData.push({x: parseInt(chartDataRaw[i].x), y: parseInt(chartDataRaw[i].y)});
}
//var i = parseInt(fromDate);
//while (i < parseInt(toDate)){
// var rnd = Math.random() * (30 - 20) + 20;
// chartData.push({x:i * 1000, y:rnd});
// i += 60 * 5;
//}
var chartDiv = "chart9";
var sliderDiv = "slider9";
var x_axis = "x_axis9";
var y_axis = "y_axis9";
$(chartWrapperElmId).html("").html('<div id="' + y_axis + '" class="custom_y_axis"></div><div id="' + chartDiv + '" class="custom_rickshaw_graph"></div><div id="' + x_axis + '" class="custom_x_axis"></div><div id="' + sliderDiv + '" class="custom_slider"></div>');
var graph = new Rickshaw.Graph({
element: document.getElementById(chartDiv),
width: graphWidth,
height: 400,
strokeWidth: 1,
renderer: 'line',
xScale: d3.time.scale(),
padding: {top: 0.2, left: 0.02, right: 0.02, bottom: 0},
series: [
{color: '#FF4000', data: chartData}
]
});
graph.render();
var xAxis = new Rickshaw.Graph.Axis.X({
graph: graph,
orientation: 'bottom',
element: document.getElementById(x_axis),
tickFormat: graph.x.tickFormat()
});
xAxis.render();
var yAxis = new Rickshaw.Graph.Axis.Y({
graph: graph,
orientation: 'left',
element: document.getElementById(y_axis),
width: 40,
height: 410
});
yAxis.render();
var slider = new Rickshaw.Graph.RangeSlider.Preview({
graph: graph,
element: document.getElementById(sliderDiv)
});
}

@ -1,4 +0,0 @@
function onRequest(context){
context.sketchPath = "api/device/sketch/download";
return context;
}

@ -1,4 +0,0 @@
function onRequest(context){
context.sketchPath = "api/device/sketch/download";
return context;
}

@ -41,11 +41,11 @@
<!-- common navigation -->
<div id="hiddenNav" class="wr-hidden-nav">
<ul>
<li><a href="/iotserver/devices"><i class="fw fw-mobile"></i>My Devices</a></li>
<li><a href="/iotserver/devices"><i class="fw fw-mobile"></i>Device Management</a></li>
{{#if permissions.ADD_USER}}
<li><a href="/iotserver/users"><i class="fw fw-user"></i>User Management</a></li>
{{/if}}
<li><a href="/iotserver/policies"><i class="fw fw-policy"></i>Policy Management</a></li>
<li><a href="#"><i class="fw fw-policy"></i>Policy Management</a></li>
<li><a href="/iotserver/dashboard"><i class="fw fw-settings"></i>Dashboard</a></li>
</ul>
</div>

@ -1,6 +1,6 @@
function onRequest(context) {
var constants = require("/modules/constants.js");
var carbonUser = session.get(constants.USER_SESSION_KEY);
var user = session.get(constants.USER_SESSION_KEY);
var links = {
"users": [],
@ -18,7 +18,7 @@ function onRequest(context) {
};
var deviceMgtLink = {
title: "Go back to My Devices",
title: "Go back to Device Management",
icon: "fw-left-arrow",
url: "/iotserver/devices"
};
@ -38,12 +38,9 @@ function onRequest(context) {
links.analytics.push(deviceMgtLink);
links['device-mgt'].push(dashboardLink);
if (!carbonUser) {
//user is not logged in
}else{
if (user) {
var userModule = require("/modules/user.js").userModule;
var permissions = userModule.getUIPermissions();
context.permissions = permissions;
//if (permissions.ADD_USER) {

@ -1,4 +0,0 @@
function onRequest(context){
context.sketchPath = "api/device/sketch/download";
return context;
}

@ -93,7 +93,7 @@
<div class="col-lg-5 col-md-6 col-centered">
<h3>Device was successfully updated.</h3>
<div class="buttons">
<a href="#" id="edit-device-200-link" class="btn-operations">
<a href="#" id="remove-device-200-link" class="btn-operations">
&nbsp;&nbsp;&nbsp;&nbsp;Ok&nbsp;&nbsp;&nbsp;&nbsp;
</a>
</div>
@ -165,4 +165,4 @@
{{#zone "bottomJs"}}
<script id="device-listing" data-image-resource="{{self.publicURL}}/images/" src="{{self.publicURL}}/templates/device-listing.hbs" type="text/x-handlebars-template" ></script>
<script src="{{self.publicURL}}/js/device-listing.js"></script>
{{/zone}}
{{/zone}}

@ -168,7 +168,7 @@ function loadDevices(searchType, searchParam) {
addDeviceSelectedClass(this);
});
attachEvents();
//formatDates();
formatDates();
}
};
invokerUtil.get(serviceURL,
@ -253,25 +253,24 @@ function attachEvents() {
$("a#remove-device-yes-link").click(function () {
invokerUtil.get(
removeDeviceAPI,
function (data,txtStatus,jqxhr) {
var status = jqxhr.status;
if (status == 200) {
function (data) {
if (data == 200) {
$("#" + username).addClass("hide");
$(modalPopupContent).html($('#remove-device-200-content').html());
$('div[data-deviceid="' + deviceId + '"]').remove();
$("a#remove-device-200-link").click(function () {
$("a#remove-device-200-link").click(function () {
hidePopup();
});
} else if (status == 400) {
} else if (data == 400) {
$(modalPopupContent).html($('#remove-device-400-content').html());
$("a#remove-device-400-link").click(function () {
hidePopup();
});
} else if (status == 403) {
} else if (data == 403) {
$(modalPopupContent).html($('#remove-device-403-content').html());
$("a#remove-device-403-link").click(function () {
hidePopup();
});
} else if (status == 409) {
} else if (data == 409) {
$(modalPopupContent).html($('#remove-device-409-content').html());
$("a#remove-device-409-link").click(function () {
hidePopup();
@ -309,30 +308,28 @@ function attachEvents() {
showPopup();
$("a#edit-device-yes-link").click(function () {
var newDeviceName = $('#edit-device-name').val();
var device={"device":{"name" : newDeviceName}};
var device={"device":{"name" : $('#edit-device-name').val()}};
invokerUtil.post(
editDeviceAPI,
device,
function (data,txtStatus,jqxhr) {
var status = jqxhr.status;
if (status == 200) {
function (data) {
if (data == 200) {
$("#" + username).addClass("hide");
$(modalPopupContent).html($('#edit-device-200-content').html());
$("div[data-deviceid='"+deviceId+"'] .ast-name").html(newDeviceName);
$("a#edit-device-200-link").click(function () {
hidePopup();
});
} else if (status == 400) {
} else if (data == 400) {
$(modalPopupContent).html($('#edit-device-400-content').html());
$("a#edit-device-400-link").click(function () {
hidePopup();
});
} else if (status == 403) {
} else if (data == 403) {
$(modalPopupContent).html($('#edit-device-403-content').html());
$("a#edit-device-403-link").click(function () {
hidePopup();
});
} else if (status == 409) {
} else if (data == 409) {
$(modalPopupContent).html($('#edit-device-409-content').html());
$("a#edit-device-409-link").click(function () {
hidePopup();

@ -1,6 +1,6 @@
{{#each devices}}
{{deviceMap this}}
<div class="ctrl-wr-asset" data-deviceid="{{deviceIdentifier}}" data-type="{{type}}">
<div class="ctrl-wr-asset" data-deviceid="{{id}}" data-type="{{type}}">
<div class="itm-select">
<label class="wr-input-control checkbox">
<input type="checkbox"/>
@ -12,7 +12,7 @@
<div class="ast-img"><img src="{{../imageLocation}}{{type}}.png"/></div>
<div class="ast-desc">
<div class="ast-title">
<h3 class="ast-name">{{name}}</h3>
<h3 class="ast-name">Device {{name}}</h3>
<span class="ast-auth">Device Type: {{type}}</span>
<span class="ast-auth">Date of Enrollment: <span class="formatDate">{{dateOfEnrolment}}</span></span>
</div>
@ -52,4 +52,4 @@
{{/each}}
<br class="c-both"/>
<br class="c-both"/>

@ -0,0 +1,90 @@
{{#zone "main"}}
<div class="container container-bg white-bg">
<div class=" margin-top-double">
<div class="row row padding-top-double padding-bottom-double margin-bottom-double">
<div class="col-lg-12 margin-top-double">
<h1 class="grey ">Fire Alarm</h1>
<hr>
<p class="margin-bottom-double light-grey ">Connect your Fire Alarm device
to the WSO2 device cloud. </p>
</div>
</div>
<div class="row margin-bottom-double">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 padding-top">
<img src="{{self.publicURL}}/images/firealarm.png" class="img-responsive">
</div>
<div class="col-xs-12 col-sm-6 col-md-8 col-lg-8 padding-top">
<h2 class="uppercase">Ingredients</h2>
<hr>
<p class="grey margin-top">Hardware Requirements </p>
<br><br>
<span class="fw-stack fw-lg margin-right">
<i class="fw fw-ring fw-stack-2x"> </i>
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
</span>Arduino Uno<br><br>
<span class="fw-stack fw-lg margin-right">
<i class="fw fw-ring fw-stack-2x"> </i>
<i class="fw fw-right-arrow-2 fw-stack-1x"></i>
</span>Arduino Ethernet / WiFi Shield
<br /><br />
<form method="POST" class="float-left margin-right"
action="{{sketchPath}}">
<input type="hidden" name="deviceType" value="firealarm" />
<input type="hidden" name="sketchType" value="firealarm_wifi" />
<button class="wr-btn" type="submit">Create Sketch for
Wifi
</button>
</form>
<form method="POST" class="form-login-box float-left"
action="{{sketchPath}}">
<input type="hidden" name="deviceType" value="firealarm" />
<input type="hidden" name="sketchType" value="firealarm" />
<button class="wr-btn margin-right" type="submit">Create
Sketch
for Ethernet</button>
</form>
<br/>
</div>
<div class ="col-xs-12 col-sm-6 col-md-3 col-lg-12 padding-double grey-bg ">
<h2 class="uppercase">Prepare</h2><hr>
<p class="grey margin-top">Get your device ready </p>
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
<span class="circle">01 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
</div>
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom">
<span class="circle">02 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
</div>
<div class="margin-doubles padding-top-double margin-bottom-double light-grey margin-left-double margin-bottom">
<span class="circle">03 </span> <span class="padding-left"> Mount the Ethernet / Wifi shield on the Arduino Uno device.</span>
</div>
</div>
</div>
<div class="row row padding-top-double padding-bottom-double margin-bottom-double ">
<div class="col-lg-12 margin-top-double">
<h2 class="uppercase ">Connect (Quickstart)</h2>
<hr>
<p class="margin-bottom-double light-grey ">Internet of Things Foundation Quickstart connection </p>
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
<span class="circle">01 </span> <span class="padding-left">Use the following command to download the installer from GitHub:</span><br>
</div>
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
<span class="circle">02 </span> <span class="padding-left">Download the Sketch installer from the Arduino website http://arduino.cc/en/Main/Software</span><br>
</div>
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
<span class="circle">03 </span> <span class="padding-left"> Install the Sketch program</span><br>
</div>
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
<span class="circle">04 </span> <span class="padding-left">Use the Sketch program to open the samples code samples/quickstart/quickstart.ino</span><br>
</div>
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
<span class="circle">05 </span> <span class="padding-left">View the lower part of the Sketch pad window to check that the COM connection is shown as active</span><br>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "topCss"}}
<link href="{{self.publicURL}}/css/fontwso2.css" rel="stylesheet">
<link href="{{self.publicURL}}/css/fontwso2-extend.css" rel="stylesheet">
{{/zone}}

@ -0,0 +1,4 @@
function onRequest(context){
context.sketchPath = "../api/device/sketch/download";
return context;
}

@ -0,0 +1,4 @@
function onRequest(context){
context.sketchPath = "../api/device/sketch/download";
return context;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save