Merge branch 'release-2.0.x' of https://github.com/wso2/carbon-device-mgt into release-2.0.x

revert-70aa11f8
charitha 8 years ago
commit d9b670ef19

@ -20,6 +20,7 @@
var deviceId = $(".device-id"); var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid"); var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type"); var deviceType = deviceId.data("type");
var deviceOwner = deviceId.data("owner");
$(document).ready(function () { $(document).ready(function () {
$(".panel-body").removeClass("hidden"); $(".panel-body").removeClass("hidden");
@ -61,8 +62,9 @@
pageLength : 10, pageLength : 10,
order: [], order: [],
ajax: { ajax: {
url: context + "/api/operation/paginate",
data: {deviceId : deviceIdentifier, deviceType: deviceType}, url: "/devicemgt/api/operation/paginate",
data: {deviceId : deviceIdentifier, deviceType: deviceType, owner: deviceOwner},
dataSrc: function (json) { dataSrc: function (json) {
$("#operations-spinner").addClass("hidden"); $("#operations-spinner").addClass("hidden");
$("#operations-log-container").empty(); $("#operations-log-container").empty();
@ -102,6 +104,7 @@
} }
], ],
"createdRow": function(row, data) { "createdRow": function(row, data) {
$(row).attr("data-type", "selectable"); $(row).attr("data-type", "selectable");
$(row).attr("data-id", data["id"]); $(row).attr("data-id", data["id"]);
$.each($("td", row), $.each($("td", row),

@ -1,24 +0,0 @@
<table class="table table-striped table-hover table-bordered display data-table" id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
{{#each operations}}
<tr data-type="selectable" data-id="{{id}}">
<td data-display="{{code}}" data-grid-label="Code">{{code}}</td>
<td data-display="{{status}}" data-grid-label="Status">
{{#equal status "COMPLETED"}}<span><i class="fw fw-ok icon-success"></i> Completed</span>{{/equal}}
{{#equal status "PENDING"}}<span><i class="fw fw-warning icon-warning"></i> Pending</span>{{/equal}}
{{#equal status "ERROR"}}<span><i class="fw fw-error icon-danger"></i> Error</span>{{/equal}}
{{#equal status "IN_PROGRESS"}}<span><i class="fw fw-ok icon-warning"></i> In Progress</span>{{/equal}}
</td>
<td data-display="{{createdTimeStamp}}" data-grid-label="Created Timestamp">{{createdTimeStamp}}</td>
</tr>
{{/each}}
<br class="c-both" />
</tbody>
</table>

@ -59,142 +59,109 @@
</div> </div>
</div> </div>
{{#defineZone "device-detail-properties"}} <div class="media tab-responsive">
<div class="media"> <div class="media-left col-xs-1 col-sm-1 col-md-2 col-lg-2 hidden-xs">
<ul class="list-group nav nav-pills nav-stacked" role="tablist">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2"> {{#defineZone "device-view-tabs"}}
<ul class="list-group" role="tablist"> {{#defineZone "device-details-tab"}}
<li class="active"><a class="list-group-item" <li role="presentation" class="list-group-item active">
href="#device_details" <a href="#device_details_tab" role="tab" data-toggle="tab"
role="tab" data-toggle="tab" aria-controls="device_details_tab">
aria-controls="device_details">Device <i class="icon fw fw-mobile"></i><span class="hidden-sm">Device Details</span>
Details</a> </a>
</li>
<li><a class="list-group-item" href="#policies"
role="tab"
data-toggle="tab" aria-controls="policies">Policies</a>
</li>
<li><a class="list-group-item" href="#policy_compliance"
role="tab"
data-toggle="tab" aria-controls="policy_compliance">Policy
Compliance</a>
</li> </li>
<li><a class="list-group-item" href="#device_location" {{/defineZone}}
role="tab" {{#defineZone "device-details-tab-injected"}}
data-toggle="tab" aria-controls="device_location">Device {{/defineZone}}
Location</a> {{#defineZone "device-details-tab-operations"}}
<li role="presentation" class="list-group-item">
<a href="#event_log_tab" role="tab" data-toggle="tab" aria-controls="event_log_tab">
<i class="icon fw fw-text"></i><span class="hidden-sm">Operations Log</span>
</a>
</li> </li>
<li><a class="list-group-item" href="#event_log" role="tab" {{/defineZone}}
data-toggle="tab" aria-controls="event_log">Operations {{/defineZone}}
Log</a></li>
</ul> </ul>
</div> </div>
<div class="media-body add-padding-left-5x remove-padding-xs">
<div class="panel-group tab-content remove-padding" id="tabs" role="tablist"
data-status="{{device.isNotRemoved}}" aria-multiselectable="true">
<div class="arrow-left hidden-xs"></div>
<div class="media-body add-padding-left-5x remove-padding-xs tab-content"> {{#defineZone "device-view-tab-contents"}}
<div class="panel-group tab-content"> {{#defineZone "device-details-tab-contents"}}
<div class="message message-info">
<div class="panel panel-default tab-pane active" <h4 class="remove-margin">
id="device_details" role="tabpanel" <i class="icon fw fw-info"></i>
aria-labelledby="device_details"> No Device details avaialbe yet.
{{unit "cdmf.unit.device.details" device=device}} </h4>
</div>
<div class="panel panel-default tab-pane" id="policies" role="tabpanel"
aria-labelledby="policies">
<div class="panel-heading">Policies</div>
<div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden">
<br>
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading Policies . . .
<br>
<br>
</div>
<div id="policy-list-container">
<div class="panel-body">
No policies found
</div>
<br class="c-both" />
</div>
</div>
<a class="padding-left"
href="{{@app.context}}/policy/add/{{device.type}}?deviceId={{device.deviceIdentifier}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-policy fw-stack-1x"></i>
</span> Add device specific policy</a>
</div> </div>
{{/defineZone}}
<div class="panel panel-default tab-pane" id="policy_compliance" {{#defineZone "device-view-tab-injected-conents"}}
role="tabpanel" aria-labelledby="policy_compliance"> {{/defineZone}}
<div class="panel-heading">Policy Compliance <span><a
href="#" id="refresh-policy"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body">
<div id="policy-spinner"
class="wr-advance-operations-init hidden">
<br>
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading Policy Compliance . . . {{#defineZone "device-view-tab-operations-log-conents"}}
<br> <div class="panel panel-default visible-xs-block" role="tabpanel" id="event_log_tab">
<br> <div class="panel-heading visible-xs collapsed" id="event_log">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#tabs"
href="#collapseFive" aria-expanded="true" aria-controls="collapseFive">
<i class="fw fw-text fw-2x"></i>
Operations Log
<i class="caret-updown fw fw-down"></i>
</a>
</h4>
</div>
<div class="panel-heading display-none-xs">
Operations Log
<span>
<a href="javascript:void(0);" id="refresh-operations">
<i class="fw fw-refresh"></i>
</a>
</span>
</div> </div>
<div id="policy-list-container"> <div id="collapseFive" class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="event_log">
<div class="panel-body"> <div class="panel-body">
Not available yet <span class="visible-xs add-padding-2x text-right">
</div> <a href="javascript:void(0);" id="refresh-operations">
<br class="c-both" /> <i class="fw fw-refresh"></i>
</div> </a>
</span>
<div id="operations-spinner" class="wr-advance-operations-init hidden">
<i class="fw fw-settings fw-spin fw-2x"></i> Loading Operations Log...
</div> </div>
<div id="operations-log-container">
<div class="message message-info">
<h4 class="remove-margin">
<i class="icon fw fw-info"></i>
There are no operations, performed yet on this device.
</h4>
</div> </div>
<div class="panel panel-default tab-pane" id="device_location"
role="tabpanel" aria-labelledby="device_location">
<div class="panel-heading">Device Location</div>
<div class="panel-body">
<div id="device-location"
data-lat="{{device.viewModel.location.latitude}}"
data-long="{{device.viewModel.location.longitude}}"
style="height:450px" class="panel-body">
</div> </div>
<div id="map-error" class="panel-body"> <table class="table table-striped table-hover table-bordered display data-table"
Not available yet id="operations-log-table">
<thead>
<tr class="sort-row">
<th>Operation Code</th>
<th>Status</th>
<th>Request created at</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div> </div>
<br class="c-both" />
</div> </div>
</div> </div>
<div class="panel panel-default tab-pane" id="event_log" {{/defineZone}}
role="tabpanel" aria-labelledby="event_log"> {{/defineZone}}
<div class="panel-heading">Operations Log <span><a href="#"
id="refresh-operations"><i
class="fw fw-refresh"></i></a></span></div>
<div class="panel-body">
<div id="operations-spinner"
class="wr-advance-operations-init hidden">
<br>
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading Operations Log . . .
<br>
<br>
</div>
<div id="operations-log-container">
<div class="panel-body">
Not available yet
</div>
<br class="c-both" />
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{/defineZone}}
</div>
{{else}} {{else}}
<h1 class="page-sub-title"> <h1 class="page-sub-title">
Permission Denied Permission Denied
@ -206,6 +173,7 @@
<h1 class="page-sub-title"> <h1 class="page-sub-title">
Device not found Device not found
</h1> </h1>
</h1>
<br> <br>
You have tried to access either a removed or non-existing device. You have tried to access either a removed or non-existing device.
{{/if}} {{/if}}
@ -221,7 +189,4 @@
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs" <script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.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>
<script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs"
data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}"
type="text/x-handlebars-template"></script>
{{/zone}} {{/zone}}

@ -196,7 +196,7 @@ function onRequest(context) {
viewModel["deviceInfoAvailable"] = false; viewModel["deviceInfoAvailable"] = false;
} }
deviceViewData["deviceView"] = viewModel; deviceViewData["device"] = viewModel;
} else if (response["status"] == "unauthorized") { } else if (response["status"] == "unauthorized") {
deviceViewData["deviceFound"] = true; deviceViewData["deviceFound"] = true;
deviceViewData["isAuthorized"] = false; deviceViewData["isAuthorized"] = false;

@ -59,6 +59,11 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
} }
}; };
/**
* Load all device groups.
*
* @param callback function to call on loading completion.
*/
function loadGroups(callback) { function loadGroups(callback) {
invokerUtil.get( invokerUtil.get(
"/api/device-mgt/v1.0/groups", "/api/device-mgt/v1.0/groups",
@ -68,6 +73,12 @@ function loadGroups(callback) {
}); });
} }
/**
* Creates DeviceGroupWrapper object from selected groups.
*
* @param selectedGroups
* @returns {Array} DeviceGroupWrapper list.
*/
var createDeviceGroupWrapper = function (selectedGroups) { var createDeviceGroupWrapper = function (selectedGroups) {
var groupObjects = []; var groupObjects = [];
loadGroups(function (deviceGroups) { loadGroups(function (deviceGroups) {
@ -136,7 +147,6 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
$.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) { $.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
var content = template(); var content = template();
$("#device-type-policy-operations").html(content).removeClass("hidden"); $("#device-type-policy-operations").html(content).removeClass("hidden");
// $("#device-type-policy-operations").removeClass("hidden");
$(".policy-platform").addClass("hidden"); $(".policy-platform").addClass("hidden");
}); });

@ -63,7 +63,7 @@
<div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert"> <div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
<div> <div class="clearfix">
<label class="wr-input-label"> <label class="wr-input-label">
Set a name * to your policy<br> Set a name * to your policy<br>
( should be 1-to-30 characters long ) ( should be 1-to-30 characters long )

@ -63,6 +63,11 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
} }
}; };
/**
* Load all device groups.
*
* @param callback function to call on loading completion.
*/
function loadGroups(callback) { function loadGroups(callback) {
invokerUtil.get( invokerUtil.get(
"/api/device-mgt/v1.0/groups", "/api/device-mgt/v1.0/groups",
@ -72,12 +77,18 @@ function loadGroups(callback) {
}); });
} }
/**
* Creates DeviceGroupWrapper object from selected groups.
*
* @param selectedGroups
* @returns {Array} DeviceGroupWrapper list.
*/
var createDeviceGroupWrapper = function (selectedGroups) { var createDeviceGroupWrapper = function (selectedGroups) {
var groupObjects = []; var groupObjects = [];
loadGroups(function (deviceGroups) { loadGroups(function (deviceGroups) {
var tenantId = $("#logged-in-user").data("tenant-id"); var tenantId = $("#logged-in-user").data("tenant-id");
for (var index in deviceGroups) { for (var index in deviceGroups) {
if(deviceGroups.hasOwnProperty(index)) { if (deviceGroups.hasOwnProperty(index)) {
var deviceGroupWrapper = {}; var deviceGroupWrapper = {};
if (selectedGroups.indexOf(deviceGroups[index].name) > -1) { if (selectedGroups.indexOf(deviceGroups[index].name) > -1) {
deviceGroupWrapper.id = deviceGroups[index].id; deviceGroupWrapper.id = deviceGroups[index].id;
@ -132,7 +143,18 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
currentlyEffected["roles"] = policyPayloadObj.roles; currentlyEffected["roles"] = policyPayloadObj.roles;
currentlyEffected["users"] = policyPayloadObj.users; currentlyEffected["users"] = policyPayloadObj.users;
currentlyEffected["groups"] = policyPayloadObj.deviceGroups; currentlyEffected["groups"] = [];
if (policyPayloadObj.deviceGroups) {
var deviceGroups = policyPayloadObj.deviceGroups;
for (var index in deviceGroups) {
if (deviceGroups.hasOwnProperty(index)) {
currentlyEffected["groups"].push(deviceGroups[index].name);
}
}
} else {
currentlyEffected["groups"].push("NONE");
}
if (currentlyEffected["roles"].length > 0) { if (currentlyEffected["roles"].length > 0) {
$("#user-roles-radio-btn").prop("checked", true); $("#user-roles-radio-btn").prop("checked", true);
@ -146,7 +168,7 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
userInput.val(currentlyEffected["users"]).trigger("change"); userInput.val(currentlyEffected["users"]).trigger("change");
} }
if(currentlyEffected["groups"].length > 0) { if (currentlyEffected["groups"].length > 0) {
groupsInput.val(currentlyEffected["groups"]).trigger("change"); groupsInput.val(currentlyEffected["groups"]).trigger("change");
} }
@ -178,8 +200,8 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
script.type = 'text/javascript'; script.type = 'text/javascript';
script.src = policyOperationsScriptSrc; script.src = policyOperationsScriptSrc;
$(".wr-advance-operations").prepend(script); $(".wr-advance-operations").prepend(script);
var configuredOperations = operationModule. var configuredOperations = operationModule.populateProfile(policy["platform"],
populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]); policyPayloadObj["profile"]["profileFeaturesList"]);
polulateProfileOperations(configuredOperations); polulateProfileOperations(configuredOperations);
} }
}); });
@ -222,7 +244,7 @@ stepForwardFrom["policy-criteria"] = function () {
} }
}); });
policy["selectedGroups"] = $("#groups-input").val(); policy["selectedGroups"] = $("#groups-input").val();
if (policy["selectedGroups"].length > 1 || policy["selectedGroups"][0] !== "NONE") { if (policy["selectedGroups"] && (policy["selectedGroups"].length > 1 || policy["selectedGroups"][0] !== "NONE")) {
policy["selectedGroups"] = createDeviceGroupWrapper(policy["selectedGroups"]); policy["selectedGroups"] = createDeviceGroupWrapper(policy["selectedGroups"]);
} }
@ -422,7 +444,7 @@ var updatePolicy = function (policy, state) {
payload["roles"] = []; payload["roles"] = [];
} }
if(policy["selectedGroups"]) { if (policy["selectedGroups"]) {
payload["deviceGroups"] = policy["selectedGroups"]; payload["deviceGroups"] = policy["selectedGroups"];
} }

Loading…
Cancel
Save