mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #222 from charithag/master
Add tenant aware dynamic units routing
This commit is contained in:
commit
7add57e9c2
@ -241,6 +241,13 @@
|
|||||||
<url>/devices/name/*/*</url>
|
<url>/devices/name/*/*</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
|
<Permission>
|
||||||
|
<name>List All Own Devices</name>
|
||||||
|
<path>/device-mgt/user/devices/list</path>
|
||||||
|
<url>/devices/user/*</url>
|
||||||
|
<method>GET</method>
|
||||||
|
</Permission>
|
||||||
<!-- End of Device related APIs -->
|
<!-- End of Device related APIs -->
|
||||||
|
|
||||||
<!-- Notification related APIs -->
|
<!-- Notification related APIs -->
|
||||||
|
|||||||
@ -97,61 +97,6 @@ deviceModule = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
@Deprecated
|
|
||||||
*/
|
|
||||||
publicMethods.listDevicesForUser = function (username) {
|
|
||||||
var carbonUser = session.get(constants.USER_SESSION_KEY);
|
|
||||||
var utility = require('/app/modules/utility.js').utility;
|
|
||||||
if (!carbonUser) {
|
|
||||||
log.error("User object was not found in the session");
|
|
||||||
throw constants.ERRORS.USER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
utility.startTenantFlow(carbonUser);
|
|
||||||
var deviceManagementService = utility.getDeviceManagementService();
|
|
||||||
var devices = deviceManagementService.getDevicesOfUser(username);
|
|
||||||
var deviceList = [];
|
|
||||||
var i, device, propertiesList, deviceObject;
|
|
||||||
for (i = 0; i < devices.size(); i++) {
|
|
||||||
device = devices.get(i);
|
|
||||||
propertiesList = DeviceManagerUtil.convertDevicePropertiesToMap(device.getProperties());
|
|
||||||
|
|
||||||
deviceObject = {};
|
|
||||||
deviceObject[constants.DEVICE_IDENTIFIER] =
|
|
||||||
privateMethods.validateAndReturn(device.getDeviceIdentifier());
|
|
||||||
deviceObject[constants.DEVICE_NAME] =
|
|
||||||
privateMethods.validateAndReturn(device.getName());
|
|
||||||
deviceObject[constants.DEVICE_OWNERSHIP] =
|
|
||||||
privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwnership());
|
|
||||||
deviceObject[constants.DEVICE_OWNER] =
|
|
||||||
privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwner());
|
|
||||||
deviceObject[constants.DEVICE_TYPE] =
|
|
||||||
privateMethods.validateAndReturn(device.getType());
|
|
||||||
deviceObject[constants.DEVICE_PROPERTIES] = {};
|
|
||||||
if (device.getType() == constants.PLATFORM_IOS) {
|
|
||||||
deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] =
|
|
||||||
privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_PRODUCT));
|
|
||||||
deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] = constants.VENDOR_APPLE;
|
|
||||||
} else {
|
|
||||||
deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] =
|
|
||||||
privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_MODEL));
|
|
||||||
deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] =
|
|
||||||
privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_VENDOR));
|
|
||||||
}
|
|
||||||
deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_OS_VERSION] =
|
|
||||||
privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_OS_VERSION));
|
|
||||||
|
|
||||||
deviceList.push(deviceObject);
|
|
||||||
}
|
|
||||||
return deviceList;
|
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
utility.endTenantFlow();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Deprecated
|
@Deprecated
|
||||||
*/
|
*/
|
||||||
@ -383,86 +328,21 @@ deviceModule = function () {
|
|||||||
return license;
|
return license;
|
||||||
};
|
};
|
||||||
|
|
||||||
publicMethods.getOwnDevices = function () {
|
publicMethods.getDevices = function (userName) {
|
||||||
var listAllDevicesEndPoint = deviceCloudService + "/device/user/" + user.username + "/all";
|
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + userName;
|
||||||
var result = get(listAllDevicesEndPoint, {}, "json");
|
return serviceInvokers.XMLHttp.get(
|
||||||
var devices = result.data;
|
url, function (responsePayload) {
|
||||||
var device;
|
for (var i = 0; i < responsePayload.length; i++) {
|
||||||
for (var d in devices){
|
responsePayload[i].thumb = utility.getDeviceThumb(responsePayload[i].type);
|
||||||
device = devices[d];
|
}
|
||||||
device.assetId = publicMethods.getAssetId(device.deviceType);
|
return responsePayload;
|
||||||
}
|
}
|
||||||
return result;
|
,
|
||||||
|
function (responsePayload) {
|
||||||
|
log.error(responsePayload);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
publicMethods.getAllPermittedDevices = function () {
|
|
||||||
var groupModule = require("/app/modules/group.js").groupModule;
|
|
||||||
|
|
||||||
var result = publicMethods.getUnGroupedDevices();
|
|
||||||
var unGroupedDevices = result.data;
|
|
||||||
var user_groups = groupModule.getGroups().data;
|
|
||||||
var allDevices = [];
|
|
||||||
var deviceCount = unGroupedDevices.length;
|
|
||||||
for (var g in user_groups) {
|
|
||||||
var deviceInGroup = user_groups[g].devices;
|
|
||||||
deviceCount += deviceInGroup.length;
|
|
||||||
if (deviceInGroup && deviceInGroup.length == 0) {
|
|
||||||
delete user_groups[g]["devices"];
|
|
||||||
}
|
|
||||||
var device;
|
|
||||||
for (var d in deviceInGroup){
|
|
||||||
device = deviceInGroup[d];
|
|
||||||
device.assetId = publicMethods.getAssetId(device.type);
|
|
||||||
}
|
|
||||||
allDevices.push(user_groups[g]);
|
|
||||||
}
|
|
||||||
allDevices.push({id: 0, devices: unGroupedDevices});
|
|
||||||
result.data = allDevices;
|
|
||||||
result.device_count = deviceCount;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
publicMethods.removeDevice = function (deviceType, deviceId) {
|
|
||||||
var carbonUser = session.get(constants.USER_SESSION_KEY);
|
|
||||||
if (!carbonUser) {
|
|
||||||
log.error("User object was not found in the session");
|
|
||||||
throw constants.ERRORS.USER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
utility.startTenantFlow(carbonUser);
|
|
||||||
var deviceManagementService = utility.getDeviceManagementService();
|
|
||||||
var deviceIdentifier = new DeviceIdentifier();
|
|
||||||
deviceIdentifier.setType(deviceType);
|
|
||||||
deviceIdentifier.setId(deviceId);
|
|
||||||
return deviceManagementService.disenrollDevice(deviceIdentifier);
|
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
utility.endTenantFlow();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
publicMethods.updateDevice = function (deviceType, deviceId, deviceName) {
|
|
||||||
var carbonUser = session.get(constants.USER_SESSION_KEY);
|
|
||||||
if (!carbonUser) {
|
|
||||||
log.error("User object was not found in the session");
|
|
||||||
throw constants.ERRORS.USER_NOT_FOUND;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
utility.startTenantFlow(carbonUser);
|
|
||||||
var deviceManagementService = utility.getDeviceManagementService();
|
|
||||||
var deviceIdentifier = new DeviceIdentifier();
|
|
||||||
deviceIdentifier.setType(deviceType);
|
|
||||||
deviceIdentifier.setId(deviceId);
|
|
||||||
var device = deviceManagementService.getDevice(deviceIdentifier);
|
|
||||||
device.setName(deviceName);
|
|
||||||
return deviceManagementService.modifyEnrollment(device);
|
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
utility.endTenantFlow();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return publicMethods;
|
return publicMethods;
|
||||||
}();
|
}();
|
||||||
|
|||||||
@ -67,8 +67,7 @@ policyModule = function () {
|
|||||||
policyObjectToView["priorityId"] = policyObjectFromRestEndpoint["priorityId"];
|
policyObjectToView["priorityId"] = policyObjectFromRestEndpoint["priorityId"];
|
||||||
policyObjectToView["name"] = policyObjectFromRestEndpoint["policyName"];
|
policyObjectToView["name"] = policyObjectFromRestEndpoint["policyName"];
|
||||||
policyObjectToView["platform"] = policyObjectFromRestEndpoint["profile"]["deviceType"]["name"];
|
policyObjectToView["platform"] = policyObjectFromRestEndpoint["profile"]["deviceType"]["name"];
|
||||||
policyObjectToView["icon"] = devicemgtProps["httpsURL"] + devicemgtProps["appContext"] +
|
policyObjectToView["icon"] = utility.getDeviceThumb(policyObjectToView["platform"]);
|
||||||
"public/cdmf.unit.device.type." + policyObjectToView["platform"] + ".type-view/images/thumb.png";
|
|
||||||
policyObjectToView["ownershipType"] = policyObjectFromRestEndpoint["ownershipType"];
|
policyObjectToView["ownershipType"] = policyObjectFromRestEndpoint["ownershipType"];
|
||||||
policyObjectToView["roles"] = privateMethods.
|
policyObjectToView["roles"] = privateMethods.
|
||||||
getElementsInAString(policyObjectFromRestEndpoint["roles"]);
|
getElementsInAString(policyObjectFromRestEndpoint["roles"]);
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
var utility;
|
var utility;
|
||||||
utility = function () {
|
utility = function () {
|
||||||
|
|
||||||
|
var constants = require('/app/modules/constants.js');
|
||||||
|
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
|
||||||
var log = new Log("/app/modules/utility.js");
|
var log = new Log("/app/modules/utility.js");
|
||||||
var JavaClass = Packages.java.lang.Class;
|
var JavaClass = Packages.java.lang.Class;
|
||||||
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext;
|
var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
@ -104,26 +107,43 @@ utility = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
publicMethods.getOperationIcon = function (deviceType, operation) {
|
publicMethods.getOperationIcon = function (deviceType, operation) {
|
||||||
var iconPath = "/app/units/cdmf.unit.device.type."
|
var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view");
|
||||||
+ deviceType + ".type-view/public/images/operations/" + operation + ".png";
|
var iconPath = "/app/units/" + unitName + "/public/images/operations/" + operation + ".png";
|
||||||
var icon = new File(iconPath);
|
var icon = new File(iconPath);
|
||||||
if (icon.isExists()) {
|
if (icon.isExists()) {
|
||||||
return "public/cdmf.unit.device.type." + deviceType + ".type-view/images/operations/" + operation + ".png";
|
return devicemgtProps["appContext"] + "public/" + unitName + "/images/operations/" + operation + ".png";
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
publicMethods.getDeviceThumb = function (deviceType) {
|
publicMethods.getDeviceThumb = function (deviceType) {
|
||||||
var iconPath = "/app/units/cdmf.unit.device.type."
|
var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view");
|
||||||
+ deviceType + ".type-view/public/images/thumb.png";
|
var iconPath = "/app/units/" + unitName + "/public/images/thumb.png";
|
||||||
var icon = new File(iconPath);
|
var icon = new File(iconPath);
|
||||||
if (icon.isExists()) {
|
if (icon.isExists()) {
|
||||||
return "/devicemgt/public/cdmf.unit.device.type." + deviceType + ".type-view/images/thumb.png";
|
return devicemgtProps["appContext"] + "public/" + unitName + "/images/thumb.png";
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
publicMethods.getTenantedDeviceUnitName = function (deviceType, unitPostfix) {
|
||||||
|
var user = session.get(constants.USER_SESSION_KEY);
|
||||||
|
if (!user) {
|
||||||
|
log.error("User object was not found in the session");
|
||||||
|
throw constants.ERRORS.USER_NOT_FOUND;
|
||||||
|
}
|
||||||
|
var unitName = user.domain + "cdmf.unit.device.type." + deviceType + "." + unitPostfix;
|
||||||
|
if (new File("/app/units/" + unitName).isExists()) {
|
||||||
|
return unitName;
|
||||||
|
}
|
||||||
|
unitName = "cdmf.unit.device.type." + deviceType + "." + unitPostfix;
|
||||||
|
if (new File("/app/units/" + unitName).isExists()) {
|
||||||
|
return unitName;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
return publicMethods;
|
return publicMethods;
|
||||||
}();
|
}();
|
||||||
|
|||||||
@ -39,9 +39,8 @@ function onRequest(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"deviceTypeViewUnitName": "cdmf.unit.device.type." + deviceType + ".type-view",
|
"deviceTypeViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "type-view"),
|
||||||
"deviceType": deviceType,
|
"deviceType": deviceType,
|
||||||
"label" : configs["deviceType"]["label"]
|
"label" : configs["deviceType"]["label"]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onRequest(context){
|
function onRequest(context){
|
||||||
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
|
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
|
||||||
if (arguments.length < 3)
|
if (arguments.length < 3)
|
||||||
throw new Error("Handlebars Helper equal needs 2 parameters");
|
throw new Error("Handlebars Helper equal needs 2 parameters");
|
||||||
@ -28,6 +29,5 @@ function onRequest(context){
|
|||||||
});
|
});
|
||||||
|
|
||||||
var deviceType = context.uriParams.deviceType;
|
var deviceType = context.uriParams.deviceType;
|
||||||
|
return {"deviceViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "device-view")};
|
||||||
return {"deviceViewUnitName" : "cdmf.unit.device.type." + deviceType + ".device-view"};
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -326,7 +326,6 @@
|
|||||||
|
|
||||||
{{#zone "bottomJs"}}
|
{{#zone "bottomJs"}}
|
||||||
<script id="device-listing" data-current-user="{{currentUser.username}}" data-device-types="{{deviceTypes}}"
|
<script id="device-listing" data-current-user="{{currentUser.username}}" data-device-types="{{deviceTypes}}"
|
||||||
data-image-resource="{{@app.context}}/public/cdmf.unit.device.type."
|
|
||||||
type="text/x-handlebars-template"></script>
|
type="text/x-handlebars-template"></script>
|
||||||
{{js "js/listing.js"}}
|
{{js "js/listing.js"}}
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|||||||
@ -35,8 +35,8 @@ function onRequest(context) {
|
|||||||
if (currentUser) {
|
if (currentUser) {
|
||||||
page.permissions = {};
|
page.permissions = {};
|
||||||
page.permissions.list = stringify(userModule.getUIPermissions());
|
page.permissions.list = stringify(userModule.getUIPermissions());
|
||||||
if (userModule.isAuthorized("/permission/admin/device-mgt/admin/devices/add")) {
|
if (userModule.isAuthorized("/permission/admin/device-mgt/user/devices/add")) {
|
||||||
permissions.enroll = true;
|
page.permissions.enroll = true;
|
||||||
}
|
}
|
||||||
page.currentUser = currentUser;
|
page.currentUser = currentUser;
|
||||||
var deviceCount = 0;
|
var deviceCount = 0;
|
||||||
@ -58,7 +58,8 @@ function onRequest(context) {
|
|||||||
deviceTypes.push({
|
deviceTypes.push({
|
||||||
"type": data[i].name,
|
"type": data[i].name,
|
||||||
"category": deviceType.category,
|
"category": deviceType.category,
|
||||||
"label": deviceType.label
|
"label": deviceType.label,
|
||||||
|
"thumb": utility.getDeviceThumb(data[i].name)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,4 +67,4 @@ function onRequest(context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -213,6 +213,16 @@ function loadDevices(searchType, searchParam){
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDeviceTypeThumb(type) {
|
||||||
|
var deviceTypes = deviceListing.data("deviceTypes");
|
||||||
|
for (var i = 0; i < deviceTypes.length; i++) {
|
||||||
|
if (deviceTypes[i].type == type) {
|
||||||
|
return deviceTypes[i].thumb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
$('#device-grid').datatables_extended ({
|
$('#device-grid').datatables_extended ({
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
processing: false,
|
processing: false,
|
||||||
@ -233,7 +243,7 @@ function loadDevices(searchType, searchParam){
|
|||||||
},
|
},
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{ targets: 0, data: 'name', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
|
{ targets: 0, data: 'name', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
|
||||||
return '<div class="thumbnail icon"><img class="square-element text fw " src="' + imageResource + row.type + '.type-view/images/thumb.png"/></div>';
|
return '<div class="thumbnail icon"><img class="square-element text fw " src="' + getDeviceTypeThumb(row.type) + '"/></div>';
|
||||||
}},
|
}},
|
||||||
{ targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) {
|
{ targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) {
|
||||||
var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
|
var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
|
||||||
|
|||||||
@ -16,11 +16,13 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function onRequest(context){
|
function onRequest(context) {
|
||||||
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
|
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
|
||||||
if (arguments.length < 3)
|
if (arguments.length < 3) {
|
||||||
throw new Error("Handlebars Helper equal needs 2 parameters");
|
throw new Error("Handlebars Helper equal needs 2 parameters");
|
||||||
if( lvalue!=rvalue ) {
|
}
|
||||||
|
if (lvalue != rvalue) {
|
||||||
return options.inverse(this);
|
return options.inverse(this);
|
||||||
} else {
|
} else {
|
||||||
return options.fn(this);
|
return options.fn(this);
|
||||||
@ -28,5 +30,5 @@ function onRequest(context){
|
|||||||
});
|
});
|
||||||
var deviceType = context.uriParams.deviceType;
|
var deviceType = context.uriParams.deviceType;
|
||||||
|
|
||||||
return {"policyWizardUnitName" : "cdmf.unit.device.type." + deviceType + ".policy-wizard"};
|
return {"policyWizardUnitName": utility.getTenantedDeviceUnitName(deviceType, "policy-wizard")};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onRequest(context) {
|
function onRequest(context) {
|
||||||
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var deviceType = request.getParameter("type");
|
var deviceType = request.getParameter("type");
|
||||||
return {"deviceTypePolicyEdit" : "cdmf.unit.device.type." + deviceType + ".policy-edit"};
|
return {"deviceTypePolicyEdit": utility.getTenantedDeviceUnitName(deviceType, "policy-edit")};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onRequest(context) {
|
function onRequest(context) {
|
||||||
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var deviceType = request.getParameter("type");
|
var deviceType = request.getParameter("type");
|
||||||
return {"deviceTypePolicyView" : "cdmf.unit.device.type." + deviceType + ".policy-view"};
|
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, "policy-view")};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,8 +43,7 @@
|
|||||||
</button>
|
</button>
|
||||||
our {{deviceTypeLabel}} device
|
our {{deviceTypeLabel}} device
|
||||||
</p>
|
</p>
|
||||||
<img class="try-device-image"
|
<img class="try-device-image" src="{{thumb}}">
|
||||||
src="{{@app.context}}/public/cdmf.unit.device.type.{{deviceTypeName}}.type-view/images/thumb.png">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
@ -55,8 +54,6 @@
|
|||||||
{{/zone}}
|
{{/zone}}
|
||||||
{{#zone "bottomJs"}}
|
{{#zone "bottomJs"}}
|
||||||
<script id="device-listing" data-current-user="{{currentUser.username}}"
|
<script id="device-listing" data-current-user="{{currentUser.username}}"
|
||||||
{{! /devicemgt/public/cdmf.unit.device.type.android}}
|
|
||||||
data-image-resource="{{@app.context}}/public/cdmf.unit.device.type."
|
|
||||||
src="{{@unit.publicUri}}/templates/listing.hbs"
|
src="{{@unit.publicUri}}/templates/listing.hbs"
|
||||||
type="text/x-handlebars-template"></script>
|
type="text/x-handlebars-template"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -65,4 +62,4 @@
|
|||||||
var deviceTypesList = {{{deviceTypesList}}};
|
var deviceTypesList = {{{deviceTypesList}}};
|
||||||
</script>
|
</script>
|
||||||
{{js "js/listing.js"}}
|
{{js "js/listing.js"}}
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|||||||
@ -42,21 +42,23 @@ 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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deviceCategory == 'virtual'){
|
if (deviceCategory == 'virtual') {
|
||||||
virtualDeviceTypesList.push({
|
virtualDeviceTypesList.push({
|
||||||
"hasCustTemplate": false,
|
"hasCustTemplate": false,
|
||||||
"deviceTypeLabel": deviceTypeLabel,
|
"deviceTypeLabel": deviceTypeLabel,
|
||||||
"deviceTypeName": deviceTypes[i].name,
|
"deviceTypeName": deviceTypes[i].name,
|
||||||
"deviceCategory": deviceCategory,
|
"deviceCategory": deviceCategory,
|
||||||
"deviceTypeId": deviceTypes[i].id
|
"deviceTypeId": deviceTypes[i].id,
|
||||||
|
"thumb": utility.getDeviceThumb(deviceTypes[i].name)
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
deviceTypesList.push({
|
deviceTypesList.push({
|
||||||
"hasCustTemplate": false,
|
"hasCustTemplate": false,
|
||||||
"deviceTypeLabel": deviceTypeLabel,
|
"deviceTypeLabel": deviceTypeLabel,
|
||||||
"deviceTypeName": deviceTypes[i].name,
|
"deviceTypeName": deviceTypes[i].name,
|
||||||
"deviceCategory": deviceCategory,
|
"deviceCategory": deviceCategory,
|
||||||
"deviceTypeId": deviceTypes[i].id
|
"deviceTypeId": deviceTypes[i].id,
|
||||||
|
"thumb": utility.getDeviceThumb(deviceTypes[i].name)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,4 +71,4 @@ function onRequest(context) {
|
|||||||
throw new Error("Unable to fetch device types!");
|
throw new Error("Unable to fetch device types!");
|
||||||
}
|
}
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,7 +125,6 @@ var deviceTypeCount, compiledDeviceTypesCount = 0;
|
|||||||
function loadDevices(searchType, searchParam){
|
function loadDevices(searchType, searchParam){
|
||||||
var deviceListing = $("#device-listing");
|
var deviceListing = $("#device-listing");
|
||||||
var deviceListingSrc = deviceListing.attr("src");
|
var deviceListingSrc = deviceListing.attr("src");
|
||||||
var imageResource = deviceListing.data("image-resource");
|
|
||||||
var currentUser = deviceListing.data("currentUser");
|
var currentUser = deviceListing.data("currentUser");
|
||||||
|
|
||||||
$('#ast-container').html("");
|
$('#ast-container').html("");
|
||||||
@ -133,7 +132,7 @@ function loadDevices(searchType, searchParam){
|
|||||||
if(deviceTypesList.length > 0){
|
if(deviceTypesList.length > 0){
|
||||||
for (var i = 0; i < deviceTypesList.length; i++) {
|
for (var i = 0; i < deviceTypesList.length; i++) {
|
||||||
var viewModel = {};
|
var viewModel = {};
|
||||||
viewModel.imageLocation = imageResource;
|
viewModel.thumb = deviceTypesList[i].thumb;
|
||||||
viewModel.appContext = clientJsAppContext;
|
viewModel.appContext = clientJsAppContext;
|
||||||
viewModel.deviceTypeName = deviceTypesList[i].deviceTypeName;
|
viewModel.deviceTypeName = deviceTypesList[i].deviceTypeName;
|
||||||
viewModel.deviceTypeId = deviceTypesList[i].deviceTypeId;
|
viewModel.deviceTypeId = deviceTypesList[i].deviceTypeId;
|
||||||
@ -240,4 +239,4 @@ $(document).ready(function () {
|
|||||||
window.document.location = $(this).data('href');
|
window.document.location = $(this).data('href');
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<td class="remove-padding icon-only content-fill" data-search="{{deviceCategory}}" data-display="{{deviceCategory}}">
|
<td class="remove-padding icon-only content-fill" data-search="{{deviceCategory}}" data-display="{{deviceCategory}}">
|
||||||
<div class="thumbnail icon">
|
<div class="thumbnail icon">
|
||||||
<!--<i class="square-element text fw fw-mobile"></i>-->
|
<!--<i class="square-element text fw fw-mobile"></i>-->
|
||||||
<img class="square-element text fw " src="{{imageLocation}}{{deviceTypeName}}.type-view/images/thumb.png" />
|
<img class="square-element text fw" src="{{thumb}}"/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="remove-padding-top" data-search="{{deviceTypeLabel}}" data-display="{{deviceTypeLabel}}">
|
<td class="remove-padding-top" data-search="{{deviceTypeLabel}}" data-display="{{deviceTypeLabel}}">
|
||||||
@ -18,4 +18,4 @@
|
|||||||
<span>Select</span>
|
<span>Select</span>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -17,19 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onRequest(context) {
|
function onRequest(context) {
|
||||||
var log = new Log("create.js");
|
|
||||||
var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType";
|
var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType";
|
||||||
var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label";
|
var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label";
|
||||||
|
|
||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var userModule = require("/app/modules/user.js")["userModule"];
|
var userModule = require("/app/modules/user.js")["userModule"];
|
||||||
|
|
||||||
var JFile = Packages.java.io.File;
|
|
||||||
var sep = JFile.separator;
|
|
||||||
|
|
||||||
var systemProcess = require('process');
|
|
||||||
var parent = 'file:///' + (systemProcess.getProperty('jaggery.home') ||
|
|
||||||
systemProcess.getProperty('carbon.home')).replace(/[\\]/g, '/').replace(/^[\/]/g, '');
|
|
||||||
var types = {};
|
var types = {};
|
||||||
types["types"] = [];
|
types["types"] = [];
|
||||||
var typesListResponse = userModule.getPlatforms();
|
var typesListResponse = userModule.getPlatforms();
|
||||||
@ -41,9 +34,7 @@ function onRequest(context) {
|
|||||||
if (configs && configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) {
|
if (configs && 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];
|
deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
|
||||||
}
|
}
|
||||||
var policyWizard = new File(parent + sep + "repository" + sep + "deployment" + sep + "server" + sep +
|
var policyWizard = new File("/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-wizard"));
|
||||||
"jaggeryapps" + sep + "devicemgt" + sep + "app" + sep + "units" + sep +
|
|
||||||
"cdmf.unit.device.type." + deviceType + ".policy-wizard");
|
|
||||||
if(policyWizard.isExists()){
|
if(policyWizard.isExists()){
|
||||||
typesListResponse["content"][type]["icon"] = utility.getDeviceThumb(deviceType);
|
typesListResponse["content"][type]["icon"] = utility.getDeviceThumb(deviceType);
|
||||||
typesListResponse["content"][type]["label"] = deviceTypeLabel;
|
typesListResponse["content"][type]["label"] = deviceTypeLabel;
|
||||||
@ -52,4 +43,4 @@ function onRequest(context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
<a href="{{@app.context}}"><i class="fw fw-dashboard"></i>Admin Dashboard</a>
|
<a href="{{@app.context}}"><i class="fw fw-dashboard"></i>Admin Dashboard</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if permissions.LIST_DEVICES}}
|
{{#if permissions.LIST_OWN_DEVICES}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{@app.context}}/devices"><i class="fw fw-mobile"></i>Device Management</a>
|
<a href="{{@app.context}}/devices"><i class="fw fw-mobile"></i>Device Management</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -91,7 +91,7 @@
|
|||||||
<span class="wr-list-icon">
|
<span class="wr-list-icon">
|
||||||
<div class="thumbnail icon">
|
<div class="thumbnail icon">
|
||||||
<img class="square-element text fw "
|
<img class="square-element text fw "
|
||||||
src="{{@app.context}}/public/cdmf.unit.device.type.{{type}}.type-view/images/thumb.png"/>
|
src="{{thumb}}"/>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<span class="wr-list-desc">
|
<span class="wr-list-desc">
|
||||||
|
|||||||
@ -41,9 +41,8 @@ function onRequest(context) {
|
|||||||
if (response["status"] == "success") {
|
if (response["status"] == "success") {
|
||||||
userRoles = response["content"];
|
userRoles = response["content"];
|
||||||
}
|
}
|
||||||
|
|
||||||
var deviceModule = require("/app/modules/device.js").deviceModule;
|
var deviceModule = require("/app/modules/device.js").deviceModule;
|
||||||
devices = deviceModule.listDevicesForUser(userName);
|
devices = deviceModule.getDevices(userName);
|
||||||
}
|
}
|
||||||
return {"user": user, "userRoles": userRoles, "devices": devices};
|
return {"user": user, "userRoles": userRoles, "devices": devices};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user