Updating emm device view with permissions

revert-dabc3590
dilanua 8 years ago
parent acc3875b51
commit a9d00964d2

@ -26,6 +26,7 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices"> <a href="{{@app.context}}/devices">
Devices Devices
</a> </a>
@ -38,7 +39,15 @@
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{#if isAuthorized}}
{{unit "cdmf.unit.lib.data-table"}} {{unit "cdmf.unit.lib.data-table"}}
{{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.device.operation-mod"}}
{{unit "cdmf.unit.device.view"}} {{unit "cdmf.unit.device.view"}}
{{else}}
<h1 class="page-sub-title">
Permission Denied
</h1>
<br>
You are not authorized to view any enrolled device in the system.
{{/if}}
{{/zone}} {{/zone}}

@ -17,7 +17,14 @@
*/ */
function onRequest(context){ function onRequest(context){
var utility = require("/app/modules/utility.js").utility; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var viewModel = {};
// permission checks
// [1] checking viewing devices permission
viewModel["isAuthorized"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/view");
if (viewModel["isAuthorized"]) {
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");
@ -27,7 +34,7 @@ function onRequest(context){
return options.fn(this); return options.fn(this);
} }
}); });
}
var deviceType = context.uriParams.deviceType; return viewModel;
return {"deviceViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "device-view")};
} }

@ -156,6 +156,12 @@
</p> </p>
</div> </div>
</div> </div>
{{else}}
<h1 class="page-sub-title">
Permission Denied
</h1>
<br>
You are not authorized to view any enrolled device in the system.
{{/if}} {{/if}}
{{/zone}} {{/zone}}

@ -3,6 +3,7 @@
{{unit "mdm.unit.device.qr-modal"}} {{unit "mdm.unit.device.qr-modal"}}
{{#zone "contentTitle"}} {{#zone "contentTitle"}}
{{#if isAuthorized}}
<div class="row wr-device-board"> <div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar"> <div class="col-lg-12 wr-secondary-bar">
<label class="device-id device-select" data-deviceid="{{device.deviceIdentifier}}" <label class="device-id device-select" data-deviceid="{{device.deviceIdentifier}}"
@ -16,9 +17,11 @@
</label> </label>
</div> </div>
</div> </div>
{{/if}}
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}
{{#if isAuthorized}}
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;"> <div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
<div class="media"> <div class="media">
<div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2"> <div class="media-left media-middle asset-image col-xs-2 col-sm-2 col-md-2 col-lg-2">
@ -366,8 +369,16 @@
{{/defineZone}} {{/defineZone}}
</div> </div>
</div> </div>
{{else}}
<h1 class="page-sub-title">
Permission Denied
</h1>
<br>
You are not authorized to view specified device in the system.
{{/if}}
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
{{#if isAuthorized}}
<script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs" <script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script> type="text/x-handlebars-template"></script>
@ -380,4 +391,5 @@
{{js "js/device-detail.js"}} {{js "js/device-detail.js"}}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
{{js "js/load-map.js"}} {{js "js/load-map.js"}}
{{/if}}
{{/zone}} {{/zone}}

@ -17,7 +17,7 @@
*/ */
function onRequest(context) { function onRequest(context) {
var log = new Log("view.js"); // var log = new Log("view.js");
var deviceType = context.uriParams.deviceType; var deviceType = context.uriParams.deviceType;
var deviceId = request.getParameter("id"); var deviceId = request.getParameter("id");
var deviceData = {}; var deviceData = {};
@ -26,6 +26,8 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var response = deviceModule.viewDevice(deviceType, deviceId); var response = deviceModule.viewDevice(deviceType, deviceId);
if (response["status"] == "success") { if (response["status"] == "success") {
deviceData["isAuthorized"] = true;
var device = response["content"]; var device = response["content"];
var viewModel = {}; var viewModel = {};
var deviceInfo = device["properties"]["DEVICE_INFO"]; var deviceInfo = device["properties"]["DEVICE_INFO"];
@ -54,8 +56,7 @@ function onRequest(context) {
viewModel["vendor"] = device["properties"]["VENDOR"]; viewModel["vendor"] = device["properties"]["VENDOR"];
var osBuildDate = device["properties"]["OS_BUILD_DATE"]; var osBuildDate = device["properties"]["OS_BUILD_DATE"];
if (osBuildDate != null && osBuildDate != "0") { if (osBuildDate != null && osBuildDate != "0") {
var formattedDate = new Date(osBuildDate * 1000); viewModel["os_build_date"] = new Date(osBuildDate * 1000);
viewModel["os_build_date"] = formattedDate;
} }
viewModel["internal_memory"] = {}; viewModel["internal_memory"] = {};
viewModel["external_memory"] = {}; viewModel["external_memory"] = {};
@ -96,6 +97,8 @@ function onRequest(context) {
device["viewModel"] = viewModel; device["viewModel"] = viewModel;
} }
deviceData["device"] = device; deviceData["device"] = device;
} else if (response["status"] == "unauthorized") {
deviceData["isAuthorized"] = false;
} }
return deviceData; return deviceData;
} }

Loading…
Cancel
Save