Merge branch 'master' of https://github.com/wso2/carbon-device-mgt into apim
commit
5ccc480ddb
@ -1,62 +0,0 @@
|
||||
<%
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var uri = request.getRequestURI();
|
||||
var uriMatcher = new URIMatcher(String(uri));
|
||||
|
||||
var log = new Log("/api/operation-api.jag");
|
||||
|
||||
var utility = require('/app/modules/utility.js').utility;
|
||||
var constants = require('/app/modules/constants.js');
|
||||
var operationModule = require("/app/modules/operation.js").operationModule;
|
||||
|
||||
response.contentType = 'application/json';
|
||||
|
||||
var user = session.get(constants.USER_SESSION_KEY);
|
||||
|
||||
var result;
|
||||
|
||||
if (!user) {
|
||||
response.sendRedirect("/devicemgt/login?#login-required");
|
||||
exit();
|
||||
} else {
|
||||
if (uriMatcher.match("/{context}/api/operations/{deviceType}/stats")) {
|
||||
var deviceType = uriMatcher.elements().deviceType;
|
||||
var deviceId = request.getParameter("deviceId");
|
||||
var monitorOperations = operationModule.getMonitorOperations(deviceType);
|
||||
var stats = [];
|
||||
result = {};
|
||||
for (var op in monitorOperations) {
|
||||
result = operationModule.handleGETOperation(deviceType, monitorOperations[op].operation, monitorOperations[op].name, deviceId);
|
||||
stats.push(result.data);
|
||||
}
|
||||
result.data = stats;
|
||||
} else if (uriMatcher.match("/{context}/api/operations/{deviceType}/{operation}")) {
|
||||
var deviceType = uriMatcher.elements().deviceType;
|
||||
var operation = uriMatcher.elements().operation;
|
||||
var deviceId = request.getParameter("deviceId");
|
||||
var params = request.getAllParameters();
|
||||
result = operationModule.handlePOSTOperation(deviceType, operation, deviceId, params);
|
||||
}
|
||||
}
|
||||
|
||||
// returning the result.
|
||||
if (result) {
|
||||
print(result);
|
||||
}
|
||||
%>
|
@ -1,55 +0,0 @@
|
||||
<%
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* 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("/app/modules/constants.js");
|
||||
var policyModule = require("/app/modules/policy.js").policyModule;
|
||||
|
||||
var deviceType, deviceId;
|
||||
|
||||
var user = session.get(constants.USER_SESSION_KEY);
|
||||
|
||||
var responseProcessor = require('utils').response;
|
||||
response.contentType = 'application/json';
|
||||
|
||||
if (!user) {
|
||||
response = responseProcessor.buildErrorResponse(response, 401, "Unauthorized");
|
||||
} else {
|
||||
if (uriMatcher.match("/{context}/api/policies/add")) {
|
||||
var content = request.getContent();
|
||||
var policyName = content.policyName;
|
||||
var policyDefinition = content.profile.policyDefinition;
|
||||
var policyDescription = content.profile.policyDescription;
|
||||
deviceType = content.profile.deviceType.name;
|
||||
deviceId = content.deviceId;
|
||||
try {
|
||||
response.content = policyModule.addPolicy(policyName, deviceType, policyDefinition,
|
||||
policyDescription, deviceId);
|
||||
} catch (e) {
|
||||
log.error("Exception occurred while trying to add new policy under name:" + policyName, e);
|
||||
// http status code 500 refers to - Internal Server Error.
|
||||
responseProcessor.buildErrorResponse(response, 500, "Internal server error");
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var configParams = {
|
||||
"NOTIFIER_TYPE": "notifierType",
|
||||
"NOTIFIER_FREQUENCY": "notifierFrequency"
|
||||
};
|
||||
|
||||
var responseCodes = {
|
||||
"CREATED": "Created",
|
||||
"SUCCESS": "201",
|
||||
"INTERNAL_SERVER_ERROR": "Internal Server Error"
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if provided input is valid against RegEx input.
|
||||
*
|
||||
* @param regExp Regular expression
|
||||
* @param inputString Input string to check
|
||||
* @returns {boolean} Returns true if input matches RegEx
|
||||
*/
|
||||
function isPositiveInteger(str) {
|
||||
return /^\+?(0|[1-9]\d*)$/.test(str);
|
||||
}
|
||||
|
||||
invokerUtil.get(
|
||||
"/devicemgt_admin/configuration",
|
||||
function (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data && data.configuration) {
|
||||
for (var i = 0; i < data.configuration.length; i++) {
|
||||
var config = data.configuration[i];
|
||||
if (config.name == configParams["NOTIFIER_FREQUENCY"]) {
|
||||
$("input#monitoring-config-frequency").val(config.value / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, function (data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Save" button
|
||||
* on General platform configuration page in WSO2 EMM Console.
|
||||
*/
|
||||
$("button#save-general-btn").click(function () {
|
||||
var notifierFrequency = $("input#monitoring-config-frequency").val();
|
||||
var errorMsgWrapper = "#email-config-error-msg";
|
||||
var errorMsg = "#email-config-error-msg span";
|
||||
|
||||
if (!notifierFrequency) {
|
||||
$(errorMsg).text("Monitoring frequency is a required field. It cannot be empty.");
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else if (!isPositiveInteger(notifierFrequency)) {
|
||||
$(errorMsg).text("Provided monitoring frequency is invalid. ");
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
} else {
|
||||
var addConfigFormData = {};
|
||||
var configList = new Array();
|
||||
|
||||
var monitorFrequency = {
|
||||
"name": configParams["NOTIFIER_FREQUENCY"],
|
||||
"value": String((notifierFrequency * 1000)),
|
||||
"contentType": "text"
|
||||
};
|
||||
|
||||
configList.push(monitorFrequency);
|
||||
addConfigFormData.configuration = configList;
|
||||
|
||||
var addConfigAPI = "/devicemgt_admin/configuration";
|
||||
invokerUtil.post(
|
||||
addConfigAPI,
|
||||
addConfigFormData,
|
||||
function (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.statusCode == responseCodes["SUCCESS"]) {
|
||||
$("#config-save-form").addClass("hidden");
|
||||
$("#record-created-msg").removeClass("hidden");
|
||||
} else if (data == 500) {
|
||||
$(errorMsg).text("Exception occurred at backend.");
|
||||
} else if (data == 403) {
|
||||
$(errorMsg).text("Action was not permitted.");
|
||||
} else {
|
||||
$(errorMsg).text("An unexpected error occurred.");
|
||||
}
|
||||
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
}, function (data) {
|
||||
data = data.status;
|
||||
if (data == 500) {
|
||||
$(errorMsg).text("Exception occurred at backend.");
|
||||
} else if (data == 403) {
|
||||
$(errorMsg).text("Action was not permitted.");
|
||||
} else {
|
||||
$(errorMsg).text("An unexpected error occurred.");
|
||||
}
|
||||
$(errorMsgWrapper).removeClass("hidden");
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
@ -1,72 +0,0 @@
|
||||
#*
|
||||
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
|
||||
WSO2 Inc. licenses this file to you under the Apache License,
|
||||
Version 2.0 (the "License"); you may not use this file except
|
||||
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.
|
||||
*#
|
||||
<EmailConfig>
|
||||
<Subject>You have been invited to enroll your device in WSO2 EMM</Subject>
|
||||
<Body>
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>WSO2 Enterprise Mobility Manager</title>
|
||||
</head>
|
||||
<body style="color: #666666; background-color:#cdcdcd; padding: 0px; margin: 0px;">
|
||||
<div style="background-color:#cdcdcd; font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; padding: 20px 0px; margin: 0px;">
|
||||
<div style="width: 86%; max-width: 650px; padding: 2%; background-color: #ffffff; margin: auto; border-radius: 14px;">
|
||||
<div style="background-color: #49c8f5; line-height: 0px; border-top-left-radius: 10px; border-top-right-radius: 10px; padding: 0px 10px 0px 0px;">
|
||||
<div style="display: inline-block; line-height: 0px;">
|
||||
<img src="http://b.content.wso2.com/sites/all/2015-june-theme/navigation/wso2-nav-logo.png"
|
||||
alt="WSO2" style="margin: 0px 20px 0px 25px; width: 100%; max-width: 251px;"/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #ffffff; line-height: 170%; color: #666666; padding: 20px 25px;">
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px 20px;">
|
||||
Hi $first-name,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
You have been invited to enrol your device in WSO2 Enterprise Mobility Manager.
|
||||
Click <a href="$base-url-https/emm-web-agent/enrollment">here</a> to download the WSO2 EMM client application to begin device
|
||||
enrolment.</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
Should you need assistance, please contact your administrator.
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 20px 0px 5px;">
|
||||
Regards,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
WSO2 EMM Administrator
|
||||
</p>
|
||||
</div>
|
||||
<div style="background-color: #333333; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding: 0px 20px 0px 0px;"><img
|
||||
src="http://b.content.wso2.com/newsletter/images/wso2-logo-cloud-footer.png" alt="WSO2"
|
||||
style="margin: 15px 0px 15px 25px; width: 100%; max-width: 258px;"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</Body>
|
||||
</EmailConfig>
|
@ -1,82 +0,0 @@
|
||||
#*
|
||||
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
|
||||
WSO2 Inc. licenses this file to you under the Apache License,
|
||||
Version 2.0 (the "License"); you may not use this file except
|
||||
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.
|
||||
*#
|
||||
<EmailConfig>
|
||||
<Subject>You have successfully been registered in WSO2 EMM</Subject>
|
||||
<Body>
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>WSO2 Enterprise Mobility Manager</title>
|
||||
</head>
|
||||
<body style="color: #666666; background-color:#cdcdcd; padding: 0px; margin: 0px;">
|
||||
<div style="background-color:#cdcdcd; font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; padding: 20px 0px; margin: 0px;">
|
||||
<div style="width: 86%; max-width: 650px; padding: 2%; background-color: #ffffff; margin: auto; border-radius: 14px;">
|
||||
<div style="background-color: #49c8f5; line-height: 0px; border-top-left-radius: 10px; border-top-right-radius: 10px; padding: 0px 10px 0px 0px;">
|
||||
<div style="display: inline-block; line-height: 0px;">
|
||||
<img src="http://b.content.wso2.com/sites/all/2015-june-theme/navigation/wso2-nav-logo.png"
|
||||
alt="WSO2" style="margin: 0px 20px 0px 25px; width: 100%; max-width: 251px;"/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #ffffff; line-height: 170%; color: #666666; padding: 20px 25px;">
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px 20px;">
|
||||
Hi $first-name,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
You have been registered in WSO2 Enterprise Mobility Manager and invited to enrol your device.
|
||||
Click <a href="$base-url-https/emm-web-agent/enrollment">here</a> to download the WSO2 EMM client application to begin device
|
||||
enrolment.</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
Use following credentials to log in to WSO2 EMM client application.
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
<b>Username:</b> $username
|
||||
<br/>
|
||||
<b>Password:</b> $password
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
Should you need assistance, please contact your administrator.
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 20px 0px 5px;">
|
||||
Regards,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
WSO2 EMM Administrator
|
||||
</p>
|
||||
</div>
|
||||
<div style="background-color: #333333; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding: 0px 20px 0px 0px;"><img
|
||||
src="http://b.content.wso2.com/newsletter/images/wso2-logo-cloud-footer.png" alt="WSO2"
|
||||
style="margin: 15px 0px 15px 25px; width: 100%; max-width: 258px;"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</Body>
|
||||
</EmailConfig>
|
Loading…
Reference in new issue