merge-requests/7/head
dilanua 9 years ago
commit 3daa42ca5d

@ -82,20 +82,17 @@ if (!user) {
{deviceName} - from request
**/
var deviceManagerService = devicemgtProps["httpsURL"] + "/" + deviceType + "_mgt" + "/manager";
var sketchDownloadEndPoint = deviceManagerService + "/device/" + sketchType + "/download";
var sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceType + "/devices/download";
deviceTypeConfig = utility.getDeviceTypeConfig(deviceType);
if (deviceTypeConfig && deviceTypeConfig.deviceType.downloadAgentUri) {
sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceType + "_mgt" +
"/" + deviceTypeConfig.deviceType.downloadAgentUri;
sketchDownloadEndPoint = deviceTypeConfig.deviceType.downloadAgentUri;
}
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
if (tokenPair) {
response.addHeader(constants.AUTHORIZATION_HEADER, constants.BEARER_PREFIX +
tokenPair.accessToken);
response.sendRedirect(sketchDownloadEndPoint + "?owner=" + user.username + "&deviceName=" +
deviceName);
response.addHeader(constants.AUTHORIZATION_HEADER, constants.BEARER_PREFIX + tokenPair.accessToken);
response.sendRedirect(sketchDownloadEndPoint + "?sketchType=" + sketchType + "&deviceName="
+ deviceName);
} else {
response.sendRedirect(devicemgtProps["httpsURL"] + "/devicemgt/login");
exit();

@ -33,8 +33,6 @@ deviceModule = function () {
var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation;
var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
var deviceManagementService = utility.getDeviceManagementService();
var publicMethods = {};
var privateMethods = {};
@ -314,6 +312,54 @@ deviceModule = function () {
}
};
// Refactored methods
publicMethods.getOwnDevicesCount = function () {
var carbonUser = session.get(constants.USER_SESSION_KEY);
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username
+ "/count";
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
}
,
function (responsePayload) {
log.error(responsePayload);
return -1;
}
);
};
publicMethods.getAllDevicesCount = function () {
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count";
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
}
,
function (responsePayload) {
log.error(responsePayload);
return -1;
}
);
};
publicMethods.getDeviceTypes = function () {
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/types";
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
}
,
function (responsePayload) {
log.error(responsePayload);
return -1;
}
);
};
//Old methods
//TODO: make sure these methods are updated
/*
@Updated
*/
@ -348,36 +394,6 @@ deviceModule = function () {
return result;
};
publicMethods.getOwnDevicesCount = function () {
var carbonUser = session.get(constants.USER_SESSION_KEY);
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username
+ "/count";
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
}
,
function (responsePayload) {
log.error(responsePayload);
return -1;
}
);
};
publicMethods.getAllDevicesCount = function () {
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count";
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
}
,
function (responsePayload) {
log.error(responsePayload);
return -1;
}
);
};
publicMethods.getAllPermittedDevices = function () {
var groupModule = require("/app/modules/group.js").groupModule;
@ -405,11 +421,6 @@ deviceModule = function () {
return result;
};
publicMethods.getDeviceTypes = function () {
var deviceTypesEndPoint = deviceCloudService + "/device/type/all";
return get(deviceTypesEndPoint, {}, "json");
};
publicMethods.removeDevice = function (deviceType, deviceId) {
var carbonUser = session.get(constants.USER_SESSION_KEY);
if (!carbonUser) {

@ -25,10 +25,9 @@ function onRequest(context) {
var viewModel = {};
var deviceModule = require("/app/modules/device.js").deviceModule;
var utility = require("/app/modules/utility.js").utility;
var data = deviceModule.getDeviceTypes();
var deviceTypes = deviceModule.getDeviceTypes();
if (data.data) {
var deviceTypes = data.data;
if (deviceTypes) {
var deviceTypesList = [], virtualDeviceTypesList = [];
for (var i = 0; i < deviceTypes.length; i++) {
@ -43,13 +42,6 @@ function onRequest(context) {
deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
}
}
//deviceTypesList.push({
// "hasCustTemplate": false,
// "deviceTypeLabel": deviceTypeLabel,
// "deviceTypeName": deviceTypes[i].name,
// "deviceCategory": deviceCategory,
// "deviceTypeId": deviceTypes[i].id
//});
if (deviceCategory == 'virtual'){
virtualDeviceTypesList.push({
"hasCustTemplate": false,

@ -54,7 +54,7 @@ $(document).ready(function () {
null,
function (data) {
data = JSON.parse(data);
if (data.statusCode == responseCodes["ACCEPTED"]) {
if (data.status == responseCodes["ACCEPTED"]) {
$("#config-save-form").addClass("hidden");
location.href = redirectUrl;
} else if (data == 500) {

@ -150,7 +150,7 @@ $(document).ready(function () {
updateRolePermissionAPI,
updateRolePermissionData,
function (jqXHR) {
if (JSON.parse(jqXHR).statusCode == 200 || jqXHR.status == 200) {
if (JSON.parse(jqXHR).status == 200 || jqXHR.status == 200) {
// Refreshing with success message
$("#role-create-form").addClass("hidden");
$("#role-created-msg").removeClass("hidden");

@ -109,7 +109,7 @@ function formatRepo (user) {
}
function formatRepoSelection (user) {
return user.username || user.text;;
return user.username || user.text;
}
$(document).ready(function () {
@ -188,7 +188,7 @@ $(document).ready(function () {
addRoleAPI,
addRoleFormData,
function (jqXHR) {
if (JSON.parse(jqXHR).statusCode == 200 || jqXHR.status == 200) {
if (JSON.parse(jqXHR).status == 200 || jqXHR.status == 200) {
// Clearing user input fields.
$("input#rolename").val("");
$("#domain").val("");

@ -175,9 +175,9 @@ $( "#userStore" )
if (data.errorMessage) {
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
$(errorMsgWrapper).removeClass("hidden");
} else if (data["statusCode"] == 200) {
} else if (data["status"] == 200) {
$("#roles").empty();
for(i=0;i<data.responseContent.length;i++){
for (var i = 0; i < data.responseContent.length; i++) {
var newOption = $('<option value="'+data.responseContent[i]+'">'+data.responseContent[i]+'</option>');
$('#roles').append(newOption);
}
@ -254,7 +254,7 @@ $(document).ready(function () {
if (data.errorMessage) {
$(errorMsg).text("Selected user store prompted an error : " + data.errorMessage);
$(errorMsgWrapper).removeClass("hidden");
} else if (data["statusCode"] == 201) {
} else if (data["status"] == 201) {
// Clearing user input fields.
$("input#username").val("");
$("input#firstname").val("");

@ -232,7 +232,7 @@ $(document).ready(function () {
addUserFormData,
function (data) {
data = JSON.parse(data);
if (data["statusCode"] == 201) {
if (data["status"] == 201) {
// Clearing user input fields.
$("input#username").val("");
$("input#firstname").val("");

@ -198,14 +198,14 @@ function resetPassword(uname) {
resetPasswordFormData,
function (data) { // The success callback
data = JSON.parse(data);
if (data.statusCode == 201) {
if (data.status == 201) {
$(modalPopupContent).html($('#reset-password-success-content').html());
$("a#reset-password-success-link").click(function () {
hidePopup();
});
}
}, function (data) { // The error callback
if (data.statusCode == 400) {
if (data.status == 400) {
$(errorMsg).text("Old password does not match with the provided value.");
$(errorMsgWrapper).removeClass("hidden");
} else {

@ -33,7 +33,7 @@
{{#unequal adminUser username }}
{{#if canRemove}}
<a href="#" data-username="{{username}}" data-userid="{{userid}}"
data-click-event="remove-form" onclick="javascript:removeUser('{{username}}', '{{userid}}')"
data-click-event="remove-form" onclick="removeUser('{{username}}', '{{userid}}')"
class="btn padding-reduce-on-grid-view remove-user-link">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
@ -47,16 +47,11 @@
{{#unequal adminUser username }}
{{#if canResetPassword}}
<a href="#" data-username="{{username}}" data-userid="{{userid}}"
data-click-event="edit-form" onclick="javascript:resetPassword('{{username}}')"
data-click-event="edit-form" onclick="resetPassword('{{username}}')"
class="btn padding-reduce-on-grid-view remove-user-link">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-key fw-stack-1x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>
<i class="fw fw-circle fw-stack-2x"></i>
<i class="fw fw-refresh fw-stack-1x fw-inverse"></i>
</span>
</span>
<span class="hidden-xs hidden-on-grid-view">Reset</span>
</a>

Loading…
Cancel
Save