|
|
|
@ -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) {
|
|
|
|
|