Request #2410
This commit is contained in:
parent
eaa561f3d6
commit
2ca49d49d8
|
@ -303,7 +303,7 @@
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter": {
|
||||||
"description": "Array of node/domain/id or mesh/domain/id strings. When set, the link will only show up for the specified devices or device groups.",
|
"description": "Array of node/<domain>/<id> or mesh/<domain>/<id> or tag:<tag> strings. When set, the link will only show up for the specified devices, device groups or device tag.",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": { "type": "string" }
|
"items": { "type": "string" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4118,7 +4118,7 @@
|
||||||
if ((serverinfo.devicemeshrouterlinks != null) && (Array.isArray(serverinfo.devicemeshrouterlinks.extralinks))) {
|
if ((serverinfo.devicemeshrouterlinks != null) && (Array.isArray(serverinfo.devicemeshrouterlinks.extralinks))) {
|
||||||
for (var i in serverinfo.devicemeshrouterlinks.extralinks) {
|
for (var i in serverinfo.devicemeshrouterlinks.extralinks) {
|
||||||
var r = serverinfo.devicemeshrouterlinks.extralinks[i], p = 0;
|
var r = serverinfo.devicemeshrouterlinks.extralinks[i], p = 0;
|
||||||
if ((r.filter == null) || (Array.isArray(r.filter) && ((r.filter.indexOf(node.meshid) >= 0) || (r.filter.indexOf(node._id) >= 0)))) {
|
if (doesDeviceMatchFilterTags(node, r.filter)) {
|
||||||
if (typeof r.protocol == 'number') { p = r.protocol; } else if (r.protocol == 'http') { p = 1; } else if (r.protocol == 'https') { p = 2; } else if (r.protocol == 'rdp') { p = 3; } else if (r.protocol == 'ssh') { p = 4; } else if (r.protocol == 'scp') { p = 5; }
|
if (typeof r.protocol == 'number') { p = r.protocol; } else if (r.protocol == 'http') { p = 1; } else if (r.protocol == 'https') { p = 2; } else if (r.protocol == 'rdp') { p = 3; } else if (r.protocol == 'ssh') { p = 4; } else if (r.protocol == 'scp') { p = 5; }
|
||||||
x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + (r.ip?(',\"' + r.ip + '\"'):'') + ')>' + r.name + '</a> ';
|
x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + (r.ip?(',\"' + r.ip + '\"'):'') + ')>' + r.name + '</a> ';
|
||||||
}
|
}
|
||||||
|
@ -4130,6 +4130,16 @@
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if this device matches any of the given filters
|
||||||
|
function doesDeviceMatchFilterTags(node, filter) {
|
||||||
|
if (filter == null) return true; // No filters, every device matches.
|
||||||
|
if (!Array.isArray(filter)) return false; // Bad filter
|
||||||
|
if (filter.indexOf(node.meshid) >= 0) return true; // Device group match
|
||||||
|
if (filter.indexOf(node._id) >= 0) return true; // Nodeid match
|
||||||
|
if (Array.isArray(node.tags)) { for (var i in node.tags) { if (filter.indexOf('tag:' + node.tags[i]) >= 0) return true; } } // Tag match
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Show device help requests
|
// Show device help requests
|
||||||
function showDeviceHelpRequests(nodeid, force, e) {
|
function showDeviceHelpRequests(nodeid, force, e) {
|
||||||
if (e) haltEvent(e);
|
if (e) haltEvent(e);
|
||||||
|
@ -6316,7 +6326,7 @@
|
||||||
if ((serverinfo.devicemeshrouterlinks != null) && (Array.isArray(serverinfo.devicemeshrouterlinks.extralinks))) {
|
if ((serverinfo.devicemeshrouterlinks != null) && (Array.isArray(serverinfo.devicemeshrouterlinks.extralinks))) {
|
||||||
for (var i in serverinfo.devicemeshrouterlinks.extralinks) {
|
for (var i in serverinfo.devicemeshrouterlinks.extralinks) {
|
||||||
var r = serverinfo.devicemeshrouterlinks.extralinks[i], p = 0;
|
var r = serverinfo.devicemeshrouterlinks.extralinks[i], p = 0;
|
||||||
if ((r.filter == null) || (Array.isArray(r.filter) && ((r.filter.indexOf(mesh._id) >= 0) || (r.filter.indexOf(node._id) >= 0)))) {
|
if (doesDeviceMatchFilterTags(node, r.filter)) {
|
||||||
if (typeof r.protocol == 'number') { p = r.protocol; } else if (r.protocol == 'http') { p = 1; } else if (r.protocol == 'https') { p = 2; } else if (r.protocol == 'rdp') { p = 3; } else if (r.protocol == 'ssh') { p = 4; } else if (r.protocol == 'scp') { p = 5; }
|
if (typeof r.protocol == 'number') { p = r.protocol; } else if (r.protocol == 'http') { p = 1; } else if (r.protocol == 'https') { p = 2; } else if (r.protocol == 'rdp') { p = 3; } else if (r.protocol == 'ssh') { p = 4; } else if (r.protocol == 'scp') { p = 5; }
|
||||||
x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + (r.ip?(',\"' + r.ip + '\"'):'') + ') title="' + "Requires installation of MeshCentral Router." + '">' + r.name + '</a> ';
|
x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + (r.ip?(',\"' + r.ip + '\"'):'') + ') title="' + "Requires installation of MeshCentral Router." + '">' + r.name + '</a> ';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue