mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-13 07:53:20 -05:00
Improved tagging dialog.
This commit is contained in:
parent
7bd7ba0c92
commit
a9f95f0da7
@ -5152,6 +5152,14 @@
|
||||
var x = "Perform batch device tag operation" + '<br /><br />';
|
||||
x += addHtmlValue("Operation", '<select id=d2deviceop style=float:right;width:250px><option value=1>' + "Add tags" + '</option><option value=2>' + "Set tags" + '</option><option value=3>' + "Remove tags" + '</option></select>');
|
||||
x += addHtmlValue("Tags", '<input id=dp10devicevalue maxlength=4096 placeholder="' + "Tag1, Tag2, Tag3" + '" />');
|
||||
// Get a list of all possible device tags
|
||||
var allTags = [], y = '';
|
||||
for (var i in nodes) { if (nodes[i].tags) { for (var j in nodes[i].tags) { if (allTags.indexOf(nodes[i].tags[j]) == -1) { allTags.push(nodes[i].tags[j]); } } } }
|
||||
if (allTags.length > 0) {
|
||||
allTags.sort();
|
||||
for (var i in allTags) { y += '<span style=padding:4px;background-color:#BBB;border-radius:3px;margin:3px;cursor:pointer onclick=showEditNodeValueDialogAddTag("' + encodeURIComponentEx(allTags[i]) + '")>' + EscapeHtml(allTags[i]) + '</span>'; }
|
||||
x += '<div style=height:4px></div>' + addHtmlValue("Existing Tags", y);
|
||||
}
|
||||
setDialogMode(2, "Edit Device Tags", 3, d2groupActionFunctionTagsExec, x);
|
||||
} else if (op == 108) {
|
||||
// Device notification
|
||||
@ -7675,6 +7683,16 @@
|
||||
function showEditNodeValueDialog(mode) {
|
||||
if (xxdialogMode) return;
|
||||
var x = addHtmlValue(showEditNodeValueDialog_modes[mode], '<input id=dp10devicevalue maxlength=' + showEditNodeValueDialog_modes4[mode] + ' placeholder="' + showEditNodeValueDialog_modes3[mode] + '" onchange=p10editdevicevalueValidate(' + mode + ',event) onkeyup=p10editdevicevalueValidate(' + mode + ',event) />');
|
||||
if (mode == 3) {
|
||||
// Get a list of all possible device tags
|
||||
var allTags = [], y = '';
|
||||
for (var i in nodes) { if (nodes[i].tags) { for (var j in nodes[i].tags) { if (allTags.indexOf(nodes[i].tags[j]) == -1) { allTags.push(nodes[i].tags[j]); } } } }
|
||||
if (allTags.length > 0) {
|
||||
allTags.sort();
|
||||
for (var i in allTags) { y += '<span style=padding:4px;background-color:#BBB;border-radius:3px;margin:3px;cursor:pointer onclick=showEditNodeValueDialogAddTag("' + encodeURIComponentEx(allTags[i]) + '")>' + EscapeHtml(allTags[i]) + '</span>'; }
|
||||
x += '<div style=height:4px></div>' + addHtmlValue("Existing Tags", y);
|
||||
}
|
||||
}
|
||||
setDialogMode(2, "Edit Device", 3, showEditNodeValueDialogEx, x, mode);
|
||||
var v = currentNode[showEditNodeValueDialog_modes2[mode]];
|
||||
if (v == null) v = '';
|
||||
@ -7684,6 +7702,14 @@
|
||||
Q('dp10devicevalue').focus();
|
||||
}
|
||||
|
||||
function showEditNodeValueDialogAddTag(t) {
|
||||
var tt = Q('dp10devicevalue').value.split(','), t2 = [];
|
||||
for (var i in tt) { t2.push(tt[i].trim()); }
|
||||
if (t2.indexOf(t) >= 0) return;
|
||||
Q('dp10devicevalue').value += ((Q('dp10devicevalue').value.length == 0)?'':', ') + decodeURIComponent(t);
|
||||
p10editdevicevalueValidate();
|
||||
}
|
||||
|
||||
function showEditNodeValueDialogEx(button, mode) {
|
||||
var x = { action: 'changedevice', nodeid: currentNode._id };
|
||||
x[showEditNodeValueDialog_modes2[mode]] = Q('dp10devicevalue').value;
|
||||
|
Loading…
Reference in New Issue
Block a user