Merge pull request #578 from lakshani/devicestatus

Added "change device status" feature to mobile plugings
revert-dabc3590
Hasunie 8 years ago committed by GitHub
commit f8471abff2

@ -27,29 +27,6 @@
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - App Manager WSO2 MDM REST Connector Component</name> <name>WSO2 Carbon - App Manager WSO2 MDM REST Connector Component</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<repositories>
<repository>
<id>wso2-maven2-repository</id>
<name>WSO2 Maven2 Repository</name>
<url>http://dist.wso2.org/maven2/</url>
</repository>
<repository>
<id>wso2-maven2-snapshot-repository</id>
<name>WSO2 Maven2 Snapshot Repository</name>
<url>http://dist.wso2.org/snapshots/maven2/</url>
</repository>
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

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

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

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

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

@ -69,8 +69,7 @@ var InitiateViewOption = null;
activeTabPaneCaret.removeClass("fw-up").addClass("fw-down"); activeTabPaneCaret.removeClass("fw-up").addClass("fw-down");
activeTabPaneCaretSiblings.removeClass("fw-down").addClass("fw-up"); activeTabPaneCaretSiblings.removeClass("fw-down").addClass("fw-up");
}); });
$('.media.tab-responsive a[data-toggle="collapse"]').on('click',function(){ $('.media.tab-responsive a[data-toggle="collapse"]').on('click',function(){
var clickedPanel = $(this).attr('href'); 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) { function positionArrow(selectedTab) {
var selectedTabHeight = $(selectedTab).innerHeight(); var selectedTabHeight = $(selectedTab).innerHeight();

@ -1244,7 +1244,7 @@
<javax.ws.rs.version>1.1.1</javax.ws.rs.version> <javax.ws.rs.version>1.1.1</javax.ws.rs.version>
<!-- Carbon Device Management --> <!-- Carbon Device Management -->
<carbon.devicemgt.version>2.0.13</carbon.devicemgt.version> <carbon.devicemgt.version>2.0.17</carbon.devicemgt.version>
<carbon.devicemgt.version.range>[2.0.0, 3.0.0)</carbon.devicemgt.version.range> <carbon.devicemgt.version.range>[2.0.0, 3.0.0)</carbon.devicemgt.version.range>
<!-- Carbon App Management --> <!-- Carbon App Management -->

Loading…
Cancel
Save