revert-70aa11f8
dilanua 9 years ago
commit 3daa42ca5d

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

@ -33,8 +33,6 @@ deviceModule = function () {
var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; 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 CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
var deviceManagementService = utility.getDeviceManagementService();
var publicMethods = {}; var publicMethods = {};
var privateMethods = {}; 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 @Updated
*/ */
@ -348,36 +394,6 @@ deviceModule = function () {
return result; 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 () { publicMethods.getAllPermittedDevices = function () {
var groupModule = require("/app/modules/group.js").groupModule; var groupModule = require("/app/modules/group.js").groupModule;
@ -405,11 +421,6 @@ deviceModule = function () {
return result; return result;
}; };
publicMethods.getDeviceTypes = function () {
var deviceTypesEndPoint = deviceCloudService + "/device/type/all";
return get(deviceTypesEndPoint, {}, "json");
};
publicMethods.removeDevice = function (deviceType, deviceId) { publicMethods.removeDevice = function (deviceType, deviceId) {
var carbonUser = session.get(constants.USER_SESSION_KEY); var carbonUser = session.get(constants.USER_SESSION_KEY);
if (!carbonUser) { if (!carbonUser) {

@ -25,10 +25,9 @@ function onRequest(context) {
var viewModel = {}; var viewModel = {};
var deviceModule = require("/app/modules/device.js").deviceModule; var deviceModule = require("/app/modules/device.js").deviceModule;
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var data = deviceModule.getDeviceTypes(); var deviceTypes = deviceModule.getDeviceTypes();
if (data.data) { if (deviceTypes) {
var deviceTypes = data.data;
var deviceTypesList = [], virtualDeviceTypesList = []; var deviceTypesList = [], virtualDeviceTypesList = [];
for (var i = 0; i < deviceTypes.length; i++) { 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]; 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'){ if (deviceCategory == 'virtual'){
virtualDeviceTypesList.push({ virtualDeviceTypesList.push({
"hasCustTemplate": false, "hasCustTemplate": false,

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

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

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

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

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

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

@ -33,7 +33,7 @@
{{#unequal adminUser username }} {{#unequal adminUser username }}
{{#if canRemove}} {{#if canRemove}}
<a href="#" data-username="{{username}}" data-userid="{{userid}}" <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"> class="btn padding-reduce-on-grid-view remove-user-link">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
@ -47,16 +47,11 @@
{{#unequal adminUser username }} {{#unequal adminUser username }}
{{#if canResetPassword}} {{#if canResetPassword}}
<a href="#" data-username="{{username}}" data-userid="{{userid}}" <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"> class="btn padding-reduce-on-grid-view remove-user-link">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-key fw-stack-1x"></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>
<span class="hidden-xs hidden-on-grid-view">Reset</span> <span class="hidden-xs hidden-on-grid-view">Reset</span>
</a> </a>

Loading…
Cancel
Save