Fixed FELIX-3432 UPnP plugin should provide better device property representation
https://issues.apache.org/jira/browse/FELIX-3432
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1309402 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/upnp/src/main/resources/res/upnp.js b/webconsole-plugins/upnp/src/main/resources/res/upnp.js
index c77a3e2..be7e260 100644
--- a/webconsole-plugins/upnp/src/main/resources/res/upnp.js
+++ b/webconsole-plugins/upnp/src/main/resources/res/upnp.js
@@ -121,8 +121,11 @@
return node;
}
/* fills in the list of state variables */
+function sortVarNm(a) { return typeof a != 'undefined' && typeof a.name != undefined ? a.name.toLowerCase() : '' }
+function namedObjectSorter(a,b) { return sortVarNm(a) > sortVarNm(b) ? 1 : -1 }
function renderVars(data) {
serviceDataVars.empty();
+ data.variables.sort(namedObjectSorter);
for(i in data.variables) {
var _var = data.variables[i];
var _tr = tr(null, null, [
@@ -141,8 +144,17 @@
function renderDevice(device) {
// generate content
var table = '';
- for(var key in device.props) {
- table += '<tr><td class="ui-priority-primary">' + key + '</td><td>' + _val(device.props[key]) + '</td></tr>';
+ var sortedKeys = [];
+ for(var key in device.props) sortedKeys.push(key);
+ sortedKeys.sort();
+ for(var x in sortedKeys) {
+ var key = sortedKeys[x];
+ var xvalue = _val(device.props[key]);
+ if ('objectClass' == key) continue;
+ if ('service.id' == key) {
+ xvalue = '<a href="' + appRoot + '/services/' + key + '">' + xvalue + '</a>';
+ }
+ table += '<tr><td class="ui-priority-primary">' + key + '</td><td>' + xvalue + '</td></tr>';
}
// update the UI
@@ -175,6 +187,7 @@
if (data.actions) {
var html = '';
var x = data.actions;
+ x.sort(namedObjectSorter);
for (var a in x) html += '<option value="' + a + '">' + x[a].name + '</option>';
actionsSelect.html(html).unbind('change').change(function() {
var index = $(this).val();