@ -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,85 @@
|
||||
/*
|
||||
* 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;
|
||||
}();
|
||||
|
||||
|
@ -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,9 @@
|
||||
{{authorized}}
|
||||
{{layout "fluid"}}
|
||||
{{#zone "title"}}
|
||||
WSO2 DC | Add New Policy
|
||||
{{/zone}}
|
||||
{{#zone "body"}}
|
||||
{{unit "appbar" link="policies" title="My Policies"}}
|
||||
{{unit "policy-create"}}
|
||||
{{/zone}}
|
@ -0,0 +1,21 @@
|
||||
{{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}}
|
@ -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,4 @@
|
||||
<%
|
||||
var apiWrapperUtil = require("/modules/api-wrapper-util.js").apiWrapperUtil;
|
||||
apiWrapperUtil.refreshToken();
|
||||
%>
|
@ -0,0 +1,70 @@
|
||||
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)
|
||||
});
|
||||
}
|
@ -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 |
@ -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();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
@ -0,0 +1,243 @@
|
||||
{{#zone "main"}}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="hidden wr-steps">
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz itm-wiz-current" data-step="policy-platform"><div class="wiz-no">1</div><div class="wiz-lbl hidden-xs"><span>Select Platform</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz" data-step="policy-profile"><div class="wiz-no">2</div><div class="wiz-lbl hidden-xs"><span>Configure Profile</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz" data-step="policy-criteria"><div class="wiz-no">3</div><div class="wiz-lbl hidden-xs"><span>Assign to a group</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz" data-step="policy-content"><div class="wiz-no">4</div><div class="wiz-lbl hidden-xs"><span>Publish</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="container col-centered wr-content policy-message hidden">
|
||||
|
||||
<div class="wr-form">
|
||||
|
||||
<h1 class="wr-title">Policy creation is successful</h1>
|
||||
Please click <b>"Finish"</b> to complete the process and go back to the policy list
|
||||
<hr />
|
||||
<button class="wr-btn wizard-stepper" data-current="policy-message" data-direct="/mdm/policies/" onclick="window.location.href=''">
|
||||
Finish
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="container col-centered wr-content policy-content hidden">
|
||||
|
||||
<div class="wr-form">
|
||||
|
||||
<h1 class="page-sub-title">Add Policy</h1>
|
||||
|
||||
<div class="row wr-wizard"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div>
|
||||
<label class="wr-input-label" title="">
|
||||
Set a Name to Your Policy
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-50">
|
||||
<input id="policy-name-input" type="text" value="" placeholder="input text"/>
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="">
|
||||
Set Description
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-50">
|
||||
<textarea id="policy-description-input" placeholder="description"></textarea>
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="wr-input-control wr-btn-grp">
|
||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-content" data-back="true" data-next="policy-criteria">Back</a>
|
||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-content" data-next="policy-message">Save</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="container col-centered wr-content policy-criteria hidden">
|
||||
|
||||
<div class="wr-form">
|
||||
|
||||
<h1 class="page-sub-title">Add Policy</h1>
|
||||
|
||||
<div class="row wr-wizard"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div>
|
||||
<label class="wr-input-label" title="">
|
||||
Set Device Ownership Type
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-50">
|
||||
<select id="ownership-input" class="form-control">
|
||||
<option>COPE</option>
|
||||
<option>BYOD</option>
|
||||
</select>
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<div class="wr-input-control">
|
||||
<label class="wr-input-control radio light" rel="assetfilter">
|
||||
<input id="userRadio" type="radio" name="user-select" value="userSelectField" class="user-select-radio" />
|
||||
<span class="helper">User</span>
|
||||
</label>
|
||||
<label class="wr-input-control radio light">
|
||||
<input id="userRoleRadio" type="radio" name="user-select" value="userRoleSelectField" class="user-select-radio" />
|
||||
<span class="helper">User Role</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="userSelectField" class="user-select">
|
||||
<label class="wr-input-label" title="">
|
||||
Set User(s)
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-50">
|
||||
<select id="users-input" class="form-control select2" multiple="multiple">
|
||||
{{#each users}}
|
||||
<option>{{username}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="userRoleSelectField" class="user-select" style="display:none">
|
||||
<label class="wr-input-label" title="">
|
||||
Set User Role(s)
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-50">
|
||||
<select id="user-roles-input" class="form-control select2" multiple="multiple">
|
||||
{{#each roles}}
|
||||
<option>{{this}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="wr-input-label" title="">
|
||||
Set Action upon Non-compliance
|
||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
||||
</label>
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-50">
|
||||
<select id="action-input" class="form-control">
|
||||
<option data-action="enforce">Enforce</option>
|
||||
<option data-action="warn">Warn</option>
|
||||
<option data-action="monitor">Monitor</option>
|
||||
</select>
|
||||
</div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="wr-input-control wr-btn-grp">
|
||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-criteria" data-back="true" data-next="policy-profile">Back</a>
|
||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-criteria" data-next="policy-content">Continue</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container col-centered wr-content policy-profile hidden">
|
||||
|
||||
<div class="wr-form">
|
||||
|
||||
<h1 class="page-sub-title">Add Policy</h1>
|
||||
|
||||
<div class="row wr-wizard"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="wr-advance-operations">
|
||||
<label class="wr-input-label col-sm-4" for="maxFailedAttempts">Policy</label>
|
||||
<div class="wr-input-control">
|
||||
<input type="text" class="form-control" id="policyDefinition" data-key="policyDefinition" placeholder="Enter the policy">
|
||||
</div>
|
||||
</div>
|
||||
<div class="wr-input-control wr-btn-grp">
|
||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile" data-back="true" data-next="policy-platform">Back</a>
|
||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile" data-next="policy-criteria">Continue</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container col-centered wr-content policy-platform">
|
||||
|
||||
<div class="wr-form">
|
||||
|
||||
<h1 class="page-sub-title">Add Policy</h1>
|
||||
|
||||
<div class="row wr-wizard">
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz itm-wiz-current" data-step="policy-platform"><div class="wiz-no">1</div><div class="wiz-lbl hidden-xs"><span>Select Platform</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz" data-step="policy-profile"><div class="wiz-no">2</div><div class="wiz-lbl hidden-xs"><span>Configure Profile</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz" data-step="policy-criteria"><div class="wiz-no">3</div><div class="wiz-lbl hidden-xs"><span>Assign to a group</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-3">
|
||||
<div class="itm-wiz" data-step="policy-content"><div class="wiz-no">4</div><div class="wiz-lbl hidden-xs"><span>Publish</span></div></div>
|
||||
<br class="c-both" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row wr-tile-buttons-list">
|
||||
<div class="wr-input-control">
|
||||
<ul class="tile-buttons row">
|
||||
<li class="col-lg-4"><a href="#" class="wizard-stepper" data-current="policy-platform" data-next="policy-profile" data-platform="android" data-platform-id="1"><i class="fw fw-android"></i>Android</a></li>
|
||||
<li class="col-lg-4"><a href="#" class="wizard-stepper" data-current="policy-platform" data-next="policy-profile" data-platform="ios" data-platform-id="2"><i class="fw fw-apple"></i>iOS</a></li>
|
||||
<li class="col-lg-4"><a href="#" class="wizard-stepper" data-current="policy-platform" data-next="policy-profile" data-platform="windows" data-platform-id="3"><i class="fw fw-windows"></i>Windows</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- content -->
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
<script id="hidden-operations-bar-ios" src="{{self.publicURL}}/templates/hidden-operations-ios.hbs" type="text/x-handlebars-template" ></script>
|
||||
<script id="hidden-operations-bar-android" src="{{self.publicURL}}/templates/hidden-operations-android.hbs" type="text/x-handlebars-template" ></script>
|
||||
<script src="{{self.publicURL}}/js/policy-create.js"></script>
|
||||
{{/zone}}
|
@ -0,0 +1,10 @@
|
||||
function onRequest(context){
|
||||
var userModule = require("/modules/user.js").userModule;
|
||||
var roles = userModule.getRoles(true);
|
||||
var users = userModule.getUsers();
|
||||
var actions = ["Enforce"];
|
||||
context.roles = roles;
|
||||
context.users = users;
|
||||
context.actions = actions;
|
||||
return context;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"predicate": "false"
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
$('select.select2').select2({
|
||||
placeholder: 'Select..'
|
||||
});
|
||||
|
||||
$('select.select2[multiple=multiple]').select2({
|
||||
placeholder: 'Select..',
|
||||
tags: true
|
||||
});
|
||||
var stepperRegistry = {},
|
||||
hiddenOperation = '.wr-hidden-operations-content > div',
|
||||
advanceOperation = '.wr-advance-operations';
|
||||
function initStepper(selector){
|
||||
$(selector).click(function(){
|
||||
var nextStep = $(this).data("next");
|
||||
var currentStep = $(this).data("current");
|
||||
var isBack = $(this).data("back");
|
||||
if (!isBack){
|
||||
var action = stepperRegistry[currentStep];
|
||||
if (action){
|
||||
action(this);
|
||||
}
|
||||
}
|
||||
if (!nextStep) {
|
||||
var direct = $(this).data("direct");
|
||||
window.location.href = direct;
|
||||
}
|
||||
$(".itm-wiz").each(function(){
|
||||
var step = $(this).data("step");
|
||||
if (step == nextStep){
|
||||
$(this).addClass("itm-wiz-current");
|
||||
}else{
|
||||
$(this).removeClass("itm-wiz-current");
|
||||
}
|
||||
});
|
||||
$(".wr-wizard").html($(".wr-steps").html());
|
||||
$("." + nextStep).removeClass("hidden");
|
||||
$("." + currentStep).addClass("hidden");
|
||||
|
||||
});
|
||||
}
|
||||
function showAdvanceOperation(operation, button){
|
||||
$(button).addClass('selected');
|
||||
$(button).siblings().removeClass('selected');
|
||||
$(hiddenOperation + '[data-operation="' + operation + '"]').show();
|
||||
$(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
|
||||
}
|
||||
|
||||
var policy = {};
|
||||
var configuredProfiles = [];
|
||||
|
||||
function savePolicy(){
|
||||
var profilePayloads = [];
|
||||
for (var key in policy.profile) {
|
||||
if (policy.profile.hasOwnProperty(key)) {
|
||||
profilePayloads.push({
|
||||
featureCode: key,
|
||||
deviceTypeId: policy.platformId,
|
||||
content: policy.profile[key]
|
||||
});
|
||||
}
|
||||
}
|
||||
var payload = {
|
||||
policyName: policy.policyName,
|
||||
compliance: policy.selectedAction,
|
||||
ownershipType: policy.selectedOwnership,
|
||||
profile: {
|
||||
profileName: policy.policyName,
|
||||
deviceType: {
|
||||
id: policy.platformId
|
||||
},
|
||||
profileFeaturesList: profilePayloads
|
||||
}
|
||||
};
|
||||
payload.users = [];
|
||||
payload.roles = [];
|
||||
if (policy.selectedUsers){
|
||||
payload.users = policy.selectedUsers;
|
||||
}else if (policy.selectedUserRoles){
|
||||
payload.roles = policy.selectedUserRoles;
|
||||
}
|
||||
invokerUtil.post("/mdm-admin/policies", payload, function(){
|
||||
$(".policy-message").removeClass("hidden");
|
||||
$(".add-policy").addClass("hidden");
|
||||
}, function(){
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
alert("hiiiii");
|
||||
initStepper(".wizard-stepper");
|
||||
$( "input[type='radio'].user-select-radio" ).change(function() {
|
||||
$('.user-select').hide();
|
||||
$('#'+$(this).val()).show();
|
||||
});
|
||||
//Adds an event listener to swithc
|
||||
$(advanceOperation).on("click", ".wr-input-control.switch", function(evt){
|
||||
var operation = $(this).parents(".operation-data").data("operation");
|
||||
//prevents event bubbling by figuring out what element it's being called from
|
||||
if (evt.target.tagName == "INPUT") {
|
||||
if(!$(this).hasClass('collapsed')){
|
||||
configuredProfiles.push(operation);
|
||||
}else {
|
||||
//splicing the array if operation is present
|
||||
var index = jQuery.inArray( operation, configuredProfiles );
|
||||
if (index!= -1){
|
||||
configuredProfiles.splice( index, 1 );
|
||||
}
|
||||
}
|
||||
console.log(configuredProfiles);
|
||||
}
|
||||
|
||||
});
|
||||
stepperRegistry['policy-content'] = function (actionButton){
|
||||
policy.policyName = $("#policy-name-input").val();
|
||||
policy.policyDescription = $("#policy-description-input").val();
|
||||
//All data is collected. Policy can now be created.
|
||||
savePolicy();
|
||||
};
|
||||
stepperRegistry['policy-criteria'] = function (actionButton){
|
||||
$( "input[type='radio'].user-select-radio").each(function(){
|
||||
if ( $(this).is(':radio')){
|
||||
if ($(this).is(":checked")){
|
||||
if($(this).val() == "userSelectField"){
|
||||
policy.selectedUsers = $("#users-input").val();
|
||||
}else if($(this).val() == "userRoleSelectField"){
|
||||
policy.selectedUserRoles = $("#user-roles-input").val();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
policy.selectedAction = $("#action-input").find(":selected").data("action");
|
||||
policy.selectedOwnership = $("#ownership-input").val();
|
||||
|
||||
};
|
||||
stepperRegistry['policy-profile'] = function (actionButton){
|
||||
var deviceType = policy.platform;
|
||||
var generatedProfile = operationModule.generateProfile(deviceType, configuredProfiles);
|
||||
policy.profile = generatedProfile;
|
||||
};
|
||||
stepperRegistry['policy-platform'] = function (actionButton){
|
||||
policy.platform = $(actionButton).data("platform");
|
||||
policy.platformId = $(actionButton).data("platform-id");
|
||||
|
||||
};
|
||||
$(".uu").click(function(){
|
||||
var policyName = $("#policy-name-input").val();
|
||||
var selectedProfiles = $("#profile-input").find(":selected");
|
||||
var selectedProfileId = selectedProfiles.data("id");
|
||||
var selectedUserRoles = $("#user-roles-input").val();
|
||||
var selectedUsers = $("#users-input").val();
|
||||
var selectedAction = $("#action-input").val();
|
||||
|
||||
|
||||
});
|
||||
});
|
@ -0,0 +1,201 @@
|
||||
{{#zone "main"}}
|
||||
<div class="row wr-device-board">
|
||||
<div class="col-lg-12 wr-secondary-bar">
|
||||
<label class="device-id device-select" data-deviceid="{{device.deviceIdentifier}}" data-type="{{device.type}}">
|
||||
Device {{device.name}}
|
||||
<span class="lbl-device">
|
||||
{{#if device.viewModel.vendor}}
|
||||
({{device.viewModel.vendor}} {{device.viewModel.model}})
|
||||
{{/if}}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wr-device-list row">
|
||||
<div class="wr-hidden-operations wr-advance-operations">
|
||||
|
||||
</div>
|
||||
<div class="col-md-12 wr-page-content">
|
||||
{{unit "operation-bar" deviceType=device.type}}
|
||||
<div class="row">
|
||||
<div class="col-md-12 wr-stats-board">
|
||||
|
||||
<!-- content -->
|
||||
|
||||
<div class="col-lg-2 ast-desc-image">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-sm-4">
|
||||
<img src="{{self.publicURL}}/img/device_icons/{{device.type}}.png" style="width:200px" />
|
||||
</div>
|
||||
<div class="col-lg-12 col-sm-4 ast-desc">
|
||||
<div class="ast-device-desc"><b>Owner:</b> {{device.owner}}</div>
|
||||
<div class="ast-device-desc"><b>Date of Enrollment:</b><br/> <span class="formatDate">{{device.enrollment}}</span></div>
|
||||
<!--<div class="ast-device-desc"><b>Device:</b> {{device.viewModel.vendor}} {{device.properties.model}}</div>-->
|
||||
<!--<div class="ast-device-desc"><b>Model:</b> {{device.viewModel.model}}</div>-->
|
||||
<!--<div class="ast-device-desc"><b>IMEI:</b> {{device.viewModel.imei}}</div>-->
|
||||
<!--{{#if device.viewModel.udid}}<div class="ast-device-desc"><b>UDID:</b> {{device.viewModel.udid}}</div>{{/if}}-->
|
||||
<!--{{#if device.viewModel.phoneNumber}}<div class="ast-device-desc"><b>Phone Number:</b> {{device.viewModel.phoneNumber}}</div>{{/if}}-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-10 tiles">
|
||||
|
||||
<!-- device summary -->
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-6 col-md-6">
|
||||
{{#if device.viewModel.BatteryLevel}}
|
||||
<div class="col-lg-4">
|
||||
<div class="wr-stats-board-tile">
|
||||
<div class="tile-name">BATTERY</div>
|
||||
<div>
|
||||
<div class="tile-icon"><i class="fw fw-battery"></i></div>
|
||||
<div class="tile-stats">{{device.viewModel.BatteryLevel}}%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if device.viewModel.DeviceCapacity}}
|
||||
<div class="col-lg-4">
|
||||
<div class="wr-stats-board-tile">
|
||||
<div class="tile-name">STORAGE</div>
|
||||
<div>
|
||||
<div class="tile-icon"><i class="fw fw-hdd"></i></div>
|
||||
<div class="tile-stats">{{device.viewModel.DeviceCapacityPercentage}}%<span class="tile-stats-free">{{device.viewModel.DeviceCapacityUsed}} GB Free</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if device.viewModel.internal_memory.FreeCapacity}}
|
||||
<div class="col-lg-4">
|
||||
<div class="wr-stats-board-tile">
|
||||
<div class="tile-name">LOCAL STORAGE</div>
|
||||
<div>
|
||||
<div class="tile-icon"><i class="fw fw-hdd"></i></div>
|
||||
<div class="tile-stats">{{device.viewModel.internal_memory.DeviceCapacityPercentage}}%<span class="tile-stats-free">{{device.viewModel.internal_memory.FreeCapacity}} GB Free</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if device.viewModel.external_memory.FreeCapacity}}
|
||||
<div class="col-lg-4">
|
||||
<div class="wr-stats-board-tile">
|
||||
<div class="tile-name">EXTERNAL STORAGE</div>
|
||||
<div>
|
||||
<div class="tile-icon"><i class="fw fw-hdd"></i></div>
|
||||
<div class="tile-stats">{{device.viewModel.external_memory.DeviceCapacityPercentage}}%<span class="tile-stats-free">{{device.viewModel.external_memory.FreeCapacity}} GB Free</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /device summary -->
|
||||
|
||||
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
|
||||
|
||||
<!-- statistics -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="headingFour">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseFour" aria-expanded="false" aria-controls="collapseFour">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Device Statistics
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
|
||||
<div class="panel-body">
|
||||
<a href="../../devices/analytics?deviceId={{deviceId}}&deviceType={{deviceType}}" ><i class="fw fw-charts"></i> Show Statistics</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /statistics -->
|
||||
|
||||
<!-- device location -->
|
||||
<!--<div class="panel panel-default">-->
|
||||
<!--<div class="panel-heading" role="tab" id="headingOne">-->
|
||||
<!--<h2 class="sub-title panel-title">-->
|
||||
<!--<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">-->
|
||||
<!--<span class="fw-stack">-->
|
||||
<!--<i class="fw fw-ring fw-stack-2x"></i>-->
|
||||
<!--<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>-->
|
||||
<!--</span>-->
|
||||
<!--Device Location-->
|
||||
<!--</a>-->
|
||||
<!--</h2>-->
|
||||
<!--</div>-->
|
||||
<!--<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">-->
|
||||
<!--<div id="device-location" style="height:400px" class="panel-body">-->
|
||||
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!-- /device location -->
|
||||
|
||||
<!-- policies -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="headingTwo">
|
||||
<h2 class="sub-title panel-title">
|
||||
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
Policies
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
|
||||
<div class="panel-body">
|
||||
Not available yet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /policies -->
|
||||
|
||||
<!-- installed applications -->
|
||||
<!--<div class="panel panel-default">-->
|
||||
<!--<div class="panel-heading" role="tab" id="headingThree">-->
|
||||
<!--<h2 class="sub-title panel-title">-->
|
||||
<!--<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">-->
|
||||
<!--<span class="fw-stack">-->
|
||||
<!--<i class="fw fw-ring fw-stack-2x"></i>-->
|
||||
<!--<i class="fw fw-arrow fw-down-arrow fw-stack-1x"></i>-->
|
||||
<!--</span>-->
|
||||
<!--Installed Applications-->
|
||||
<!--</a>-->
|
||||
<!--</h2>-->
|
||||
<!--</div>-->
|
||||
<!--<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">-->
|
||||
<!--<div class="panel-body">-->
|
||||
<!--Not available yet-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!-- /installed applications -->
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- /content -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
|
||||
<script src="{{self.publicURL}}/js/device-detail.js"></script>
|
||||
{{/zone}}
|
@ -0,0 +1,58 @@
|
||||
function onRequest(context) {
|
||||
var uri = request.getRequestURI();
|
||||
var uriMatcher = new URIMatcher(String(uri));
|
||||
var isMatched = uriMatcher.match("/{context}/device/{deviceType}/{+deviceId}");
|
||||
if (isMatched) {
|
||||
var matchedElements = uriMatcher.elements();
|
||||
var deviceType = matchedElements.deviceType;
|
||||
var deviceId = matchedElements.deviceId;
|
||||
context.deviceType = deviceType;
|
||||
context.deviceId = deviceId;
|
||||
var deviceModule = require("/modules/device.js").deviceModule;
|
||||
var device = deviceModule.viewDevice(deviceType, deviceId);
|
||||
if (device){
|
||||
var viewModel = {};
|
||||
var deviceInfo = device.properties.DEVICE_INFO;
|
||||
if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0){
|
||||
deviceInfo = JSON.parse(deviceInfo);
|
||||
if (device.type == "ios"){
|
||||
viewModel.imei = device.properties.IMEI;
|
||||
viewModel.phoneNumber = deviceInfo.PhoneNumber;
|
||||
viewModel.udid = deviceInfo.UDID;
|
||||
viewModel.BatteryLevel = Math.round(deviceInfo.BatteryLevel * 100);
|
||||
viewModel.DeviceCapacity = Math.round(deviceInfo.DeviceCapacity * 100) / 100;
|
||||
viewModel.AvailableDeviceCapacity = Math.round(deviceInfo.AvailableDeviceCapacity * 100) / 100;
|
||||
viewModel.DeviceCapacityUsed = Math.round((viewModel.DeviceCapacity
|
||||
- viewModel.AvailableDeviceCapacity) * 100) / 100;
|
||||
viewModel.DeviceCapacityPercentage = Math.round(viewModel.DeviceCapacityUsed
|
||||
/ viewModel.DeviceCapacity * 10000) /100;
|
||||
}else if(device.type == "android"){
|
||||
viewModel.imei = device.properties.IMEI;
|
||||
viewModel.model = device.properties.DEVICE_MODEL;
|
||||
viewModel.vendor = device.properties.VENDOR;
|
||||
viewModel.internal_memory = {};
|
||||
viewModel.external_memory = {};
|
||||
viewModel.location = {
|
||||
latitude: device.properties.LATITUDE,
|
||||
longitude: device.properties.LONGITUDE
|
||||
};
|
||||
viewModel.BatteryLevel = deviceInfo.BATTERY_LEVEL;
|
||||
viewModel.internal_memory.FreeCapacity = Math.round((deviceInfo.INTERNAL_TOTAL_MEMORY -
|
||||
deviceInfo.INTERNAL_AVAILABLE_MEMORY) * 100) / 100;
|
||||
viewModel.internal_memory.DeviceCapacityPercentage = Math.round(deviceInfo.INTERNAL_AVAILABLE_MEMORY
|
||||
/ deviceInfo.INTERNAL_TOTAL_MEMORY * 10000) / 100;
|
||||
viewModel.external_memory.FreeCapacity = Math.round((deviceInfo.EXTERNAL_TOTAL_MEMORY -
|
||||
deviceInfo.EXTERNAL_AVAILABLE_MEMORY) * 100) / 100;
|
||||
viewModel.external_memory.DeviceCapacityPercentage = Math.round(deviceInfo.EXTERNAL_AVAILABLE_MEMORY
|
||||
/deviceInfo.EXTERNAL_TOTAL_MEMORY * 10000) /100;
|
||||
}
|
||||
viewModel.enrollment = device.enrollment;
|
||||
device.viewModel = viewModel;
|
||||
}
|
||||
}
|
||||
context.device = device;
|
||||
} else {
|
||||
response.sendError(404);
|
||||
}
|
||||
return context;
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
{{#zone "main"}}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- content -->
|
||||
<div class="wr-content">
|
||||
<p class="page-sub-title">Policies</p>
|
||||
<p>{{listPolicyStatus}}</p>
|
||||
<div class="wr-list-group wr-sortable">
|
||||
{{#if policies}}
|
||||
{{#each policies}}
|
||||
<span id="{{id}}" class="list-group-item">
|
||||
<i class="wr-sortable-icon fw fw-sort hide"></i>
|
||||
<i class="wr-list-icon fw fw-user"></i>
|
||||
<div class="wr-list-desc">
|
||||
<h3 class="wr-list-name">{{policyName}}</h3>
|
||||
<span class="wr-list-username">{{policyName}}</span>
|
||||
</div>
|
||||
<span class="list-group-item-actions">
|
||||
<!--a href="#" class="invite-user-link cu-btn-inner" data-policyname="{{policyName}}">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-invitation fw-stack-1x"></i>
|
||||
</span>
|
||||
Invite
|
||||
</a-->
|
||||
<a href="#" class="remove-user-link cu-btn-inner" data-policyname="{{policyName}}">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-delete fw-stack-1x"></i>
|
||||
</span>
|
||||
Remove
|
||||
</a>
|
||||
</span>
|
||||
<div class="clearfix"></div>
|
||||
</span>
|
||||
{{/each}}
|
||||
{{else}}
|
||||
<!-- no policies found -->
|
||||
<div class="container-fluid wr-content-alt">
|
||||
<div class="ctrl-info-panel col-md-6 col-centered">
|
||||
<h2>You don't have any Policies added at the moment.</h2>
|
||||
<p>
|
||||
</a><a href="/iotserver/policies/add-policy" class="cu-btn">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-add fw-stack-1x"></i>
|
||||
</span>
|
||||
Add New Policy
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /no policies found -->
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{{/zone}}
|
||||
{{#zone "common-navigation"}}
|
||||
<!--Later add the navigation menu from here-->
|
||||
{{/zone}}
|
||||
{{#zone "action-bar"}}
|
||||
{{#if permissions.ADD_POLICY}}
|
||||
<a href="/iotserver/policies/add-policy" class="cu-btn">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-add-user fw-stack-1x"></i>
|
||||
</span>
|
||||
Add Policy
|
||||
</a>
|
||||
{{/if}}
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
<script src="{{self.publicURL}}/js/policy-listing.js"></script>
|
||||
{{/zone}}
|
@ -0,0 +1,18 @@
|
||||
function onRequest(context) {
|
||||
// var log = new Log("policy-listing");
|
||||
var policyModule = require("/modules/policy.js").policyModule;
|
||||
var allPolicies = policyModule.getPolicies();
|
||||
if (!allPolicies || allPolicies.length == 0) {
|
||||
context.policies = [];
|
||||
context.listPolicyStatus = "Oops, Sorry, No other Policies found.";
|
||||
} else {
|
||||
var i, filteredPoliciesList = [];
|
||||
for (i = 0; i < allPolicies.length; i++) {
|
||||
filteredPoliciesList.push(allPolicies[i]);
|
||||
}
|
||||
context.policies = filteredPoliciesList;
|
||||
context.listPolicyStatus = "Total number of Policies found : " + filteredPoliciesList.length;
|
||||
}
|
||||
//context.permissions = policyModule.getUIPermissions();
|
||||
return context;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
/**
|
||||
* 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 click function would execute
|
||||
* when a user clicks on "Invite" link
|
||||
* on User Management page in WSO2 MDM Console.
|
||||
*/
|
||||
$("a.invite-user-link").click(function () {
|
||||
var username = $(this).data("username");
|
||||
var inviteUserAPI = "/iotserver/api/users/" + username + "/invite";
|
||||
|
||||
$(modalPopupContent).html($('#invite-user-modal-content').html());
|
||||
showPopup();
|
||||
|
||||
$("a#invite-user-yes-link").click(function () {
|
||||
invokerUtil.get(
|
||||
inviteUserAPI,
|
||||
function () {
|
||||
$(modalPopupContent).html($('#invite-user-success-content').html());
|
||||
$("a#invite-user-success-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
},
|
||||
function () {
|
||||
$(modalPopupContent).html($('#invite-user-error-content').html());
|
||||
$("a#invite-user-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("a#invite-user-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Remove" link
|
||||
* on User Management page in WSO2 MDM Console.
|
||||
*/
|
||||
$("a.remove-user-link").click(function () {
|
||||
var username = $(this).data("username");
|
||||
var removeUserAPI = "/iotserver/api/users/" + username + "/remove";
|
||||
|
||||
$(modalPopupContent).html($('#remove-user-modal-content').html());
|
||||
showPopup();
|
||||
|
||||
$("a#remove-user-yes-link").click(function () {
|
||||
invokerUtil.get(
|
||||
removeUserAPI,
|
||||
function (data) {
|
||||
if (data == 200) {
|
||||
$("#" + username).addClass("hide");
|
||||
$(modalPopupContent).html($('#remove-user-200-content').html());
|
||||
$("a#remove-user-200-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (data == 400) {
|
||||
$(modalPopupContent).html($('#remove-user-400-content').html());
|
||||
$("a#remove-user-400-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (data == 403) {
|
||||
$(modalPopupContent).html($('#remove-user-403-content').html());
|
||||
$("a#remove-user-403-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
} else if (data == 409) {
|
||||
$(modalPopupContent).html($('#remove-user-409-content').html());
|
||||
$("a#remove-user-409-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
},
|
||||
function () {
|
||||
$(modalPopupContent).html($('#remove-user-unexpected-error-content').html());
|
||||
$("a#remove-user-unexpected-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("a#remove-user-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 |