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