Added change device status feature to mobile plugings

merge-requests/1/head
lakshani 8 years ago committed by susinda
parent facadb13b2
commit f5d71d917e

@ -1,4 +1,5 @@
{{unit "cdmf.unit.device.type.android.leaflet"}}
{{unit "cdmf.unit.lib.editable"}}
{{unit "cdmf.unit.lib.qrcode"}}
{{unit "cdmf.unit.device.type.qr-modal"}}
@ -51,14 +52,41 @@
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td>
<td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i>Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i>Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i>Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i>Removed</span>{{/equal}}
{{#if permissions.CHANGE_DEVICE_STATUS}}
{{#equal device.status "ACTIVE"}}<span><i id="statusIcon"
class="fw fw-success icon-success"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Active"></a>
</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i id="statusIcon"
class="fw fw-warning icon-warning"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Inactive"></a>
</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i id="statusIcon"
class="fw fw-remove icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Blocked"></a>
</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i id="statusIcon"
class="fw fw-delete icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Removed"></a>
</span>{{/equal}}
{{else}}
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i> Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
{{/if}}
</td>
</tr>
{{/if}}

@ -210,7 +210,10 @@ function onRequest(context) {
{"name" : "deviceId", "value" : deviceId}
];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var permissions = userModule.getUIPermissions();
deviceViewData["autoCompleteParams"] = autoCompleteParams;
deviceViewData["permissions"] = permissions;
deviceViewData["portalUrl"] = devicemgtProps['portalURL'];
deviceViewData["anchor"] = encodeURI(JSON.stringify({ "device" : { "id" : deviceId, "type" : deviceType}}));

@ -81,6 +81,62 @@ var InitiateViewOption = null;
}
});
$('#status').on('save', function (e, params) {
var deviceStatus = params.submitValue.toUpperCase();
var serviceUrl = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceIdentifier
+ "/changestatus?newStatus=" + deviceStatus;
var payload = null;
if (serviceUrl) {
var successCallback = function (jqXHR, status, resp) {
if (resp.status == 200) {
setTimeout(function () {
if (deviceStatus == "REMOVED") {
$('#statusIcon').removeClass().addClass('fw fw-delete icon-danger');
} else if (deviceStatus == "INACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-warning icon-warning');
} else if (deviceStatus == "ACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-success icon-success');
}
$("#statusIcon").show();
}, 1500);
} else {
console.log(resp.status);
}
};
invokerUtil.put(serviceUrl, payload,
successCallback, function (message) {
console.log(message);
});
}
});
$("#status").click(function () {
$("#statusIcon").hide();
});
$.fn.editable.defaults.mode = 'inline';
$('#status').editable({
value: $('#status').attr("selectedValue"),
source: [
{value: 'Active', text: 'Active'},
{value: "Inactive", text: 'Inactive'},
{value: "Removed", text: 'Removed'}
],
success: this.update_elements
});
$.fn.editableform.buttons =
'<button id="checkedBtn" type="submit" class="btn btn-primary btn-sm editable-submit">' +
'<i class="fw fw-check"></i>' +
'</button>' +
'<button type="button" class="btn btn-secondary btn-sm editable-cancel">' +
'<i class="fw fw-cancel"></i>' +
'</button>';
function positionArrow(selectedTab) {
var selectedTabHeight = $(selectedTab).innerHeight();

@ -1,4 +1,5 @@
{{unit "cdmf.unit.device.type.windows.leaflet"}}
{{unit "cdmf.unit.lib.editable"}}
{{unit "cdmf.unit.lib.qrcode"}}
{{unit "cdmf.unit.device.type.qr-modal"}}
@ -51,14 +52,41 @@
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td>
<td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i>Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i>Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i>Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i>Removed</span>{{/equal}}
{{#if permissions.CHANGE_DEVICE_STATUS}}
{{#equal device.status "ACTIVE"}}<span><i id="statusIcon"
class="fw fw-success icon-success"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Active"></a>
</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i id="statusIcon"
class="fw fw-warning icon-warning"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Inactive"></a>
</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i id="statusIcon"
class="fw fw-remove icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Blocked"></a>
</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i id="statusIcon"
class="fw fw-delete icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Removed"></a>
</span>{{/equal}}
{{else}}
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i> Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
{{/if}}
</td>
</tr>
{{/if}}

@ -112,6 +112,9 @@ function onRequest(context) {
{"name" : "deviceId", "value" : deviceId}
];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var permissions = userModule.getUIPermissions();
deviceViewData["autoCompleteParams"] = autoCompleteParams;
deviceViewData["permissions"] = permissions;
return deviceViewData;
}

@ -69,8 +69,7 @@ var InitiateViewOption = null;
activeTabPaneCaret.removeClass("fw-up").addClass("fw-down");
activeTabPaneCaretSiblings.removeClass("fw-down").addClass("fw-up");
});
$('.media.tab-responsive a[data-toggle="collapse"]').on('click',function(){
var clickedPanel = $(this).attr('href');
@ -81,6 +80,62 @@ var InitiateViewOption = null;
}
});
$('#status').on('save', function (e, params) {
var deviceStatus = params.submitValue.toUpperCase();
var serviceUrl = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceIdentifier
+ "/changestatus?newStatus=" + deviceStatus;
var payload = null;
if (serviceUrl) {
var successCallback = function (jqXHR, status, resp) {
if (resp.status == 200) {
setTimeout(function () {
if (deviceStatus == "REMOVED") {
$('#statusIcon').removeClass().addClass('fw fw-delete icon-danger');
} else if (deviceStatus == "INACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-warning icon-warning');
} else if (deviceStatus == "ACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-success icon-success');
}
$("#statusIcon").show();
}, 1500);
} else {
console.log(resp.status);
}
};
invokerUtil.put(serviceUrl, payload,
successCallback, function (message) {
console.log(message);
});
}
});
$("#status").click(function () {
$("#statusIcon").hide();
});
$.fn.editable.defaults.mode = 'inline';
$('#status').editable({
value: $('#status').attr("selectedValue"),
source: [
{value: 'Active', text: 'Active'},
{value: "Inactive", text: 'Inactive'},
{value: "Removed", text: 'Removed'}
],
success: this.update_elements
});
$.fn.editableform.buttons =
'<button id="checkedBtn" type="submit" class="btn btn-primary btn-sm editable-submit">' +
'<i class="fw fw-check"></i>' +
'</button>' +
'<button type="button" class="btn btn-secondary btn-sm editable-cancel">' +
'<i class="fw fw-cancel"></i>' +
'</button>';
function positionArrow(selectedTab) {
var selectedTabHeight = $(selectedTab).innerHeight();

Loading…
Cancel
Save