@ -0,0 +1,31 @@
|
||||
<%
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
%>
|
@ -0,0 +1,49 @@
|
||||
<%
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
%>
|
@ -0,0 +1,44 @@
|
||||
<!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>
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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;
|
||||
}();
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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;
|
||||
}();
|
@ -0,0 +1,12 @@
|
||||
<%
|
||||
var userModule = require("/modules/user.js").userModule;
|
||||
userModule.addPermissions([{key: "device-mgt/", name: "Device Management"}], "");
|
||||
userModule.addPermissions([{key: "device-mgt/admin", name: "Device Management Admin"}], "");
|
||||
userModule.addPermissions([{key: "device-mgt/user", name: "Device Management User"}], "");
|
||||
|
||||
userModule.addPermissions([{key: "devices", name: "Device"}], "device-mgt/admin");
|
||||
userModule.addPermissions([{key: "devices", name: "Device"}], "device-mgt/user");
|
||||
userModule.addPermissions([{key: "devices/list", name: "List all Devices"}], "device-mgt/admin");
|
||||
userModule.addPermissions([{key: "devices/list", name: "List own Devices"}], "device-mgt/user");
|
||||
new Log().info(userModule.isAuthorized("/permission/device-mgt/admin/devices/list"));
|
||||
%>
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
});
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
# Ignore everything in this directory.
|
||||
# they are auto generated, should not be committed.
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
@ -0,0 +1,4 @@
|
||||
<%
|
||||
var apiWrapperUtil = require("/modules/api-wrapper-util.js").apiWrapperUtil;
|
||||
apiWrapperUtil.refreshToken();
|
||||
%>
|
@ -0,0 +1,4 @@
|
||||
function onRequest(context){
|
||||
context.sketchPath = "api/device/sketch/download";
|
||||
return context;
|
||||
}
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
@ -0,0 +1,4 @@
|
||||
function onRequest(context){
|
||||
context.sketchPath = "api/device/sketch/download";
|
||||
return context;
|
||||
}
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
@ -0,0 +1,4 @@
|
||||
function onRequest(context){
|
||||
context.sketchPath = "api/device/sketch/download";
|
||||
return context;
|
||||
}
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@ -0,0 +1,353 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var cache = {};
|
||||
var permissionSet = {};
|
||||
var validateAndReturn = function (value) {
|
||||
return (value == undefined || value == null) ? "Unspecified" : value;
|
||||
};
|
||||
Handlebars.registerHelper("deviceMap", function (device) {
|
||||
device.owner = validateAndReturn(device.owner);
|
||||
device.ownership = validateAndReturn(device.ownership);
|
||||
var arr = device.properties;
|
||||
if (arr) {
|
||||
device.properties = arr.reduce(function (total, current) {
|
||||
total[current.name] = validateAndReturn(current.value);
|
||||
return total;
|
||||
}, {});
|
||||
}
|
||||
});
|
||||
|
||||
//This method is used to setup permission for device listing
|
||||
$.setPermission = function (permission) {
|
||||
permissionSet[permission] = true;
|
||||
};
|
||||
|
||||
$.hasPermission = function (permission) {
|
||||
return permissionSet[permission];
|
||||
};
|
||||
})();
|
||||
|
||||
/*
|
||||
* Setting-up global variables.
|
||||
*/
|
||||
var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
|
||||
var assetContainer = "#ast-container";
|
||||
|
||||
/*
|
||||
* DOM ready functions.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
/* Adding selected class for selected devices */
|
||||
$(deviceCheckbox).each(function () {
|
||||
addDeviceSelectedClass(this);
|
||||
});
|
||||
|
||||
var i;
|
||||
var permissionList = $("#permission").data("permission");
|
||||
for (i = 0; i < permissionList.length; i++) {
|
||||
$.setPermission(permissionList[i]);
|
||||
}
|
||||
|
||||
/* for device list sorting drop down */
|
||||
$(".ctrl-filter-type-switcher").popover({
|
||||
html: true,
|
||||
content: function () {
|
||||
return $("#content-filter-types").html();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
* On Select All Device button click function.
|
||||
*
|
||||
* @param button: Select All Device button
|
||||
*/
|
||||
function selectAllDevices(button) {
|
||||
if (!$(button).data('select')) {
|
||||
$(deviceCheckbox).each(function (index) {
|
||||
$(this).prop('checked', true);
|
||||
addDeviceSelectedClass(this);
|
||||
});
|
||||
$(button).data('select', true);
|
||||
$(button).html('Deselect All Devices');
|
||||
} else {
|
||||
$(deviceCheckbox).each(function (index) {
|
||||
$(this).prop('checked', false);
|
||||
addDeviceSelectedClass(this);
|
||||
});
|
||||
$(button).data('select', false);
|
||||
$(button).html('Select All Devices');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* On listing layout toggle buttons click function.
|
||||
*
|
||||
* @param view: Selected view type
|
||||
* @param selection: Selection button
|
||||
*/
|
||||
function changeDeviceView(view, selection) {
|
||||
$(".view-toggle").each(function () {
|
||||
$(this).removeClass("selected");
|
||||
});
|
||||
$(selection).addClass("selected");
|
||||
if (view == "list") {
|
||||
$(assetContainer).addClass("list-view");
|
||||
} else {
|
||||
$(assetContainer).removeClass("list-view");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add selected style class to the parent element function.
|
||||
*
|
||||
* @param checkbox: Selected checkbox
|
||||
*/
|
||||
function addDeviceSelectedClass(checkbox) {
|
||||
if ($(checkbox).is(":checked")) {
|
||||
$(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select");
|
||||
} else {
|
||||
$(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select");
|
||||
}
|
||||
}
|
||||
function loadDevices(searchType, searchParam) {
|
||||
var deviceListing = $("#device-listing");
|
||||
var deviceListingSrc = deviceListing.attr("src");
|
||||
var imageResource = deviceListing.data("image-resource");
|
||||
$.template("device-listing", deviceListingSrc, function (template) {
|
||||
var serviceURL;
|
||||
if ($.hasPermission("LIST_DEVICES")) {
|
||||
serviceURL = "/iotserver/api/devices/all";
|
||||
} else if ($.hasPermission("LIST_OWN_DEVICES")) {
|
||||
//Get authenticated users devices
|
||||
serviceURL = "/iotserver/api/devices/all";
|
||||
} else {
|
||||
$("#ast-container").html("Permission denied");
|
||||
return;
|
||||
}
|
||||
if (searchParam) {
|
||||
if (searchType == "users") {
|
||||
serviceURL = serviceURL + "?user=" + searchParam;
|
||||
} else if (searchType == "user-roles") {
|
||||
serviceURL = serviceURL + "?role=" + searchParam;
|
||||
} else {
|
||||
serviceURL = serviceURL + "?type=" + searchParam;
|
||||
}
|
||||
}
|
||||
var successCallback = function (data) {
|
||||
data = JSON.parse(data);
|
||||
var viewModel = {};
|
||||
viewModel.devices = data.data;
|
||||
viewModel.imageLocation = imageResource;
|
||||
if(!data.data || data.data.length <= 0){
|
||||
$("#ast-container").html($("#no-devices-div-content").html());
|
||||
} else {
|
||||
var content = template(viewModel);
|
||||
$("#ast-container").html(content);
|
||||
/*
|
||||
* On device checkbox select add parent selected style class
|
||||
*/
|
||||
$(deviceCheckbox).click(function () {
|
||||
addDeviceSelectedClass(this);
|
||||
});
|
||||
attachEvents();
|
||||
formatDates();
|
||||
}
|
||||
};
|
||||
invokerUtil.get(serviceURL,
|
||||
successCallback, function (message) {
|
||||
console.log(message);
|
||||
});
|
||||
});
|
||||
}
|
||||
$(document).ready(function () {
|
||||
loadDevices();
|
||||
});
|
||||
|
||||
function formatDates(){
|
||||
$(".formatDate").each(function(){
|
||||
var timeStamp = $(this).html();
|
||||
$(this).html(new Date(parseInt(timeStamp)).toUTCString());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorting function of users
|
||||
* listed on User Management page in WSO2 MDM Console.
|
||||
*/
|
||||
$(function () {
|
||||
var sortableElem = '.wr-sortable';
|
||||
$(sortableElem).sortable({
|
||||
beforeStop: function () {
|
||||
var sortedIDs = $(this).sortable('toArray');
|
||||
console.log(sortedIDs);
|
||||
}
|
||||
});
|
||||
$(sortableElem).disableSelection();
|
||||
});
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
* set popup maximum height function.
|
||||
*/
|
||||
function setPopupMaxHeight() {
|
||||
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
|
||||
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
|
||||
}
|
||||
|
||||
/*
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
}
|
||||
|
||||
/*
|
||||
* hide popup function.
|
||||
*/
|
||||
function hidePopup() {
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Following functions should be triggered after AJAX request is made.
|
||||
*/
|
||||
function attachEvents() {
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Remove" link
|
||||
* on Device Management page in WSO2 MDM Console.
|
||||
*/
|
||||
$("a.remove-device-link").click(function () {
|
||||
var deviceId = $(this).data("deviceid");
|
||||
var deviceType = $(this).data("devicetype");
|
||||
var removeDeviceAPI = "/iotserver/api/device/" + deviceType + "/" + deviceId + "/remove";
|
||||
|
||||
$(modalPopupContent).html($('#remove-device-modal-content').html());
|
||||
showPopup();
|
||||
|
||||
$("a#remove-device-yes-link").click(function () {
|
||||
invokerUtil.get(
|
||||
removeDeviceAPI,
|
||||
function (data,txtStatus,jqxhr) {
|
||||
var status = jqxhr.status;
|
||||
if (status == 200) {
|
||||
$(modalPopupContent).html($('#remove-device-200-content').html());
|
||||
$("a#remove-device-200-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
$("")
|
||||
} else if (status == 400) {
|
||||
$(modalPopupContent).html($('#remove-device-400-content').html());
|
||||
$("a#remove-device-400-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (status == 403) {
|
||||
$(modalPopupContent).html($('#remove-device-403-content').html());
|
||||
$("a#remove-device-403-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (status == 409) {
|
||||
$(modalPopupContent).html($('#remove-device-409-content').html());
|
||||
$("a#remove-device-409-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
},
|
||||
function () {
|
||||
$(modalPopupContent).html($('#remove-device-unexpected-error-content').html());
|
||||
$("a#remove-device-unexpected-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("a#remove-device-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Edit" link
|
||||
* on Device Management page in WSO2 MDM Console.
|
||||
*/
|
||||
$("a.edit-device-link").click(function () {
|
||||
var deviceId = $(this).data("deviceid");
|
||||
var deviceType = $(this).data("devicetype");
|
||||
var deviceName = $(this).data("devicename");
|
||||
var editDeviceAPI = "/iotserver/api/device/" + deviceType + "/" + deviceId + "/update";
|
||||
|
||||
$(modalPopupContent).html($('#edit-device-modal-content').html());
|
||||
$('#edit-device-name').val(deviceName);
|
||||
showPopup();
|
||||
|
||||
$("a#edit-device-yes-link").click(function () {
|
||||
var device={"device":{"name" : $('#edit-device-name').val()}};
|
||||
invokerUtil.post(
|
||||
editDeviceAPI,
|
||||
device,
|
||||
function (data,txtStatus,jqxhr) {
|
||||
var status = jqxhr.status;
|
||||
if (status == 200) {
|
||||
$(modalPopupContent).html($('#edit-device-200-content').html());
|
||||
$("a#edit-device-200-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (status == 400) {
|
||||
$(modalPopupContent).html($('#edit-device-400-content').html());
|
||||
$("a#edit-device-400-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (status == 403) {
|
||||
$(modalPopupContent).html($('#edit-device-403-content').html());
|
||||
$("a#edit-device-403-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (status == 409) {
|
||||
$(modalPopupContent).html($('#edit-device-409-content').html());
|
||||
$("a#edit-device-409-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
},
|
||||
function () {
|
||||
$(modalPopupContent).html($('#edit-device-unexpected-error-content').html());
|
||||
$("a#edit-device-unexpected-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("a#edit-device-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
});
|
||||
}
|
@ -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;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
function onRequest(context){
|
||||
context.sketchPath = "../api/device/sketch/download";
|
||||
return context;
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
{{#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}}
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
@ -0,0 +1,215 @@
|
||||
{{#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>
|
||||
<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>Raspberry Pi (Internet Enabled)
|
||||
 
|
||||
<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>DHT11 Temperature Sensor<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>LED
|
||||
       
|
||||
       
|
||||
|
||||
<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>Buzzer(3v)<br><br>
|
||||
<a href="#" class="download-link btn-operations" data-devicetype="firealarm" data-sketchtype="firealarm">Download</a>
|
||||
<!--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"><b>Get your device ready</b></p>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">01 </span> <span class="padding-left"><b>Set up your RaspberryPi device as shown in the schematic below and get the FireAlarm setup.</b></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"><b>Connect a monitor to your RaspberryPi via the HDMI cable to get a UI view of the device.</b></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"><b>Get the RaspberryPi to connect to the internet (via Ethernet or Wifi) and note its IP_ADDRESS</b></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class ="col-xs-12 col-sm-6 col-md-3 col-lg-12 padding-double grey-bg ">
|
||||
<h2 class="uppercase">Schematic Diagram</h2><hr>
|
||||
<p class="grey margin-top">Click on the image to zoom</p>
|
||||
<center>
|
||||
<a href="{{self.publicURL}}/images/schematicsGuide.png" target="_blank">
|
||||
<img src="{{self.publicURL}}/images/schematicsGuide.png" class="img-responsive" style="max-width: 500px; max-height: 500px" />
|
||||
</a>
|
||||
</center>
|
||||
</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"><b>Click on the <i>"Create DEB"</i> button above to get the download link for the FireAlarm setup files</b></span><br>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<span class="padding-left"><i>(The following commands can be issued by directly typing into the terminal of the device or by an <b>"ssh"</b> login from a remote PC)</i></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"><b>Download the FireAlarm setup files using the following command: "curl -k <url_link_received_from_the_above_step> > Agent.zip"</b></span><br>
|
||||
<i> This will download a zip file named "Agent.zip"</i>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
|
||||
<span class="circle">03 </span> <span class="padding-left"><b>Run the following commands to successfuly install the package and get the service running:</b></span><br>
|
||||
<b> cd <PATH_WHERE_THE_DOWNLOADED_"Agent.zip"_FILE_IS> </b> <br>
|
||||
<b>unzip Agent.zip -d Agent</b> <br>
|
||||
<b>cd Agent</b> <br>
|
||||
<b>sudo chmod 755 startservice.sh</b> <br>
|
||||
<b>sudo ./startservice.sh</b> <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">Follow the installation instructions and complete installation. Upon completion the Agent would have started automatically</span><br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="download-device-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Please download the file from following link.</h3>
|
||||
<br/>
|
||||
<div class="buttons">
|
||||
<form method="POST" action="{{sketchPath}}">
|
||||
<input type="hidden" name="deviceType" value="firealarm" />
|
||||
<input type="hidden" name="sketchType" value="firealarm" />
|
||||
<button class="btn-operations" type="submit" style="font-size: 13px;border:none; padding: 10px 10px; display: inline-block; margin-right: 2px; text-decoration: none;">Download Now</button>
|
||||
|
||||
<a href="#" id="download-device-download-link" class="btn-operations">
|
||||
Copy Link
|
||||
</a>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="download-device-modal-content-links" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Please download the file from following link(Press CTRL+C).</h3>
|
||||
<br/>
|
||||
<div>
|
||||
<input id="download-device-url" style="color:#3f3f3f;padding:5px" type="text" value="" placeholder="Type here" size="60">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-400-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Exception at backend. Try Later.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-400-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-403-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Action not permitted.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-403-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-409-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Device Sketch does not exist.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-409-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-unexpected-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Unexpected error.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-unexpected-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</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}}
|
||||
{{#zone "bottomJs"}}
|
||||
<script src="{{self.publicURL}}/js/firealarm.js"></script>
|
||||
{{/zone}}
|
@ -0,0 +1,213 @@
|
||||
{{#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>
|
||||
<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>Raspberry Pi (Internet Enabled)
|
||||
 
|
||||
<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>DHT11 Temperature Sensor<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>LED
|
||||
       
|
||||
       
|
||||
|
||||
<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>Buzzer(3v)<br><br>
|
||||
<a href="#" class="download-link btn-operations" data-devicetype="firealarm" data-sketchtype="firealarm">Download</a>
|
||||
<!--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"><b>Get your device ready</b></p>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">01 </span> <span class="padding-left"><b>Set up your RaspberryPi device as shown in the schematic below and get the FireAlarm setup.</b></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"><b>Connect a monitor to your RaspberryPi via the HDMI cable to get a UI view of the device.</b></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"><b>Get the RaspberryPi to connect to the internet (via Ethernet or Wifi) and note its IP_ADDRESS</b></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class ="col-xs-12 col-sm-6 col-md-3 col-lg-12 padding-double grey-bg ">
|
||||
<h2 class="uppercase">Schematic Diagram</h2><hr>
|
||||
<p class="grey margin-top">Click on the image to zoom</p>
|
||||
<center>
|
||||
<a href="{{self.publicURL}}/images/schematicsGuide.png" target="_blank">
|
||||
<img src="{{self.publicURL}}/images/schematicsGuide.png" class="img-responsive" style="max-width: 500px; max-height: 500px" />
|
||||
</a>
|
||||
</center>
|
||||
</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"><b>Click on the <i>"Create DEB"</i> button above to get the download link for the FireAlarm setup files</b></span><br>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<span class="padding-left"><i>(The following commands can be issued by directly typing into the terminal of the device or by an <b>"ssh"</b> login from a remote PC)</i></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"><b>Download the FireAlarm setup files using the following command: "wget <url_link_received_from_the_above_step>"</b></span><br>
|
||||
<i> This will download a zip file named "FireAlarmAgent.zip"</i>
|
||||
</div>
|
||||
<div class="margin-doubles padding-top-double light-grey margin-left-double margin-bottom ">
|
||||
<span class="circle">03 </span> <span class="padding-left"><b>Run the following commands to successfuly install the package and get the service running:</b></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>
|
||||
|
||||
<div id="download-device-modal-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Please download the file from following link.</h3>
|
||||
<br/>
|
||||
<div class="buttons">
|
||||
<form method="POST" action="{{sketchPath}}">
|
||||
<input type="hidden" name="deviceType" value="firealarm" />
|
||||
<input type="hidden" name="sketchType" value="firealarm" />
|
||||
<button class="btn-operations" type="submit" style="font-size: 13px;border:none; padding: 10px 10px; display: inline-block; margin-right: 2px; text-decoration: none;">Download Now</button>
|
||||
|
||||
<a href="#" id="download-device-download-link" class="btn-operations">
|
||||
Copy Link
|
||||
</a>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="download-device-modal-content-links" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Please download the file from following link(Press CTRL+C).</h3>
|
||||
<br/>
|
||||
<div>
|
||||
<input id="download-device-url" style="color:#3f3f3f;padding:5px" type="text" value="" placeholder="Type here" size="60">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-400-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Exception at backend. Try Later.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-400-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-403-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Action not permitted.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-403-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-409-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Device Sketch does not exist.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-409-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="device-unexpected-error-content" class="hide">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>Unexpected error.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-unexpected-error-link" class="btn-operations">
|
||||
Ok
|
||||
</a>
|
||||
</div>
|
||||
</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}}
|
||||
{{#zone "bottomJs"}}
|
||||
<script src="{{self.publicURL}}/js/firealarm.js"></script>
|
||||
{{/zone}}
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 151 KiB |
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
* set popup maximum height function.
|
||||
*/
|
||||
function setPopupMaxHeight() {
|
||||
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
|
||||
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
|
||||
}
|
||||
|
||||
/*
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
}
|
||||
|
||||
/*
|
||||
* hide popup function.
|
||||
*/
|
||||
function hidePopup() {
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
}
|
||||
|
||||
/*
|
||||
* DOM ready functions.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
attachEvents();
|
||||
});
|
||||
|
||||
function attachEvents() {
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Download" link
|
||||
* on Device Management page in WSO2 DC Console.
|
||||
*/
|
||||
$("a.download-link").click(function () {
|
||||
var sketchType = $(this).data("sketchtype");
|
||||
var deviceType = $(this).data("devicetype");
|
||||
var downloadDeviceAPI = "/iotserver/api/device/sketch/generate_link";
|
||||
var payload = {"sketchType":sketchType, "deviceType":deviceType};
|
||||
console.log(payload);
|
||||
$(modalPopupContent).html($('#download-device-modal-content').html());
|
||||
showPopup();
|
||||
|
||||
$("a#download-device-download-link").click(function () {
|
||||
invokerUtil.post(
|
||||
downloadDeviceAPI,
|
||||
payload,
|
||||
function (data, textStatus, jqxhr) {
|
||||
if(jqxhr.status == 200) {
|
||||
$(modalPopupContent).html($('#download-device-modal-content-links').html());
|
||||
$("#download-device-url").val(data);
|
||||
$("#download-device-url").focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
showPopup();
|
||||
}else{
|
||||
$(modalPopupContent).html($('#device-403-content').html());
|
||||
$("#device-403-link").click(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
showPopup();
|
||||
}
|
||||
},
|
||||
function () {
|
||||
$(modalPopupContent).html($('#device-unexpected-error-content').html());
|
||||
$("a#device-unexpected-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("a#download-device-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 478 KiB After Width: | Height: | Size: 478 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |