mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 22:17:31 +03:00
Now need agent uninstall permission to delete a device, mesh edit permission to move a device between groups.
This commit is contained in:
parent
43c5c7f2df
commit
9342720a40
@ -251,17 +251,18 @@ function createMeshCore(agent) {
|
||||
return (svc);
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO: Monitor the file 'batterystate.txt' in the agent's folder and sends battery update when this file is changed.
|
||||
if (require('fs').existsSync('batterystate.txt')) {
|
||||
/*
|
||||
if (require('fs').existsSync(process.cwd() + 'batterystate.txt')) {
|
||||
// Setup manual battery monitoring
|
||||
require('MeshAgent')._batteryFileWatcher = require('fs').watch('.', function (a) {
|
||||
sendConsoleText('Manual Battery State Monitor');
|
||||
require('MeshAgent')._batteryFileWatcher = require('fs').watch(process.cwd(), function (a) {
|
||||
if (require('MeshAgent')._batteryFileTimer != null) return;
|
||||
require('MeshAgent')._batteryFileTimer = setTimeout(function () {
|
||||
sendConsoleText('Battery State Changed');
|
||||
try {
|
||||
require('MeshAgent')._batteryFileTimer = null;
|
||||
var data = require('fs').readFileSync('batterystate.txt').toString();
|
||||
var data = require('fs').readFileSync(process.cwd() + 'batterystate.txt').toString();
|
||||
if (data.length < 10) {
|
||||
data = data.split(',');
|
||||
if ((data.length == 2) && ((data[0] == 'ac') || (data[0] == 'dc'))) { require('MeshAgent').SendCommand({ action: 'battery', state: data[0], level: parseInt(data[1]) }); }
|
||||
|
@ -3333,7 +3333,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// Make sure that we have rights on both source and destination mesh
|
||||
const targetMeshRights = parent.GetMeshRights(user, command.meshid);
|
||||
if (((rights & MESHRIGHT_MANAGECOMPUTERS) == 0) || ((targetMeshRights & MESHRIGHT_MANAGECOMPUTERS) == 0)) {
|
||||
if (((rights & MESHRIGHT_EDITMESH) == 0) || ((targetMeshRights & MESHRIGHT_EDITMESH) == 0)) {
|
||||
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'changeDeviceMesh', responseid: command.responseid, result: 'Permission denied' })); } catch (ex) { } }
|
||||
return;
|
||||
}
|
||||
@ -3385,7 +3385,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
// Get the node and the rights for this node
|
||||
parent.GetNodeWithRights(domain, user, command.nodeids[i], function (node, rights, visible) {
|
||||
// Check we have the rights to delete this device
|
||||
if ((rights & MESHRIGHT_MANAGECOMPUTERS) == 0) return;
|
||||
if ((rights & MESHRIGHT_UNINSTALL) == 0) return;
|
||||
|
||||
// Delete this node including network interface information, events and timeline
|
||||
db.Remove(node._id); // Remove node with that id
|
||||
|
2
public/scripts/amt-wsman-0.2.0-min.js
vendored
2
public/scripts/amt-wsman-0.2.0-min.js
vendored
File diff suppressed because one or more lines are too long
@ -13139,7 +13139,7 @@
|
||||
"zh-chs": "導出設備信息",
|
||||
"zh-cht": "導出設備信息",
|
||||
"xloc": [
|
||||
"default.handlebars->27->456"
|
||||
"default.handlebars->27->457"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -21114,7 +21114,7 @@
|
||||
"zh-chs": "移至設備組",
|
||||
"zh-cht": "移至設備組",
|
||||
"xloc": [
|
||||
"default.handlebars->27->457"
|
||||
"default.handlebars->27->448"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -23584,7 +23584,7 @@
|
||||
"default-mobile.handlebars->9->264",
|
||||
"default.handlebars->27->1605",
|
||||
"default.handlebars->27->1686",
|
||||
"default.handlebars->27->450",
|
||||
"default.handlebars->27->451",
|
||||
"default.handlebars->27->471",
|
||||
"default.handlebars->27->731"
|
||||
]
|
||||
@ -24936,7 +24936,7 @@
|
||||
"zh-chs": "關閉設備電源",
|
||||
"zh-cht": "關閉設備電源",
|
||||
"xloc": [
|
||||
"default.handlebars->27->455"
|
||||
"default.handlebars->27->456"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -26834,7 +26834,7 @@
|
||||
"zh-chs": "重置設備",
|
||||
"zh-cht": "重置設備",
|
||||
"xloc": [
|
||||
"default.handlebars->27->454"
|
||||
"default.handlebars->27->455"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -27195,7 +27195,7 @@
|
||||
"zh-chs": "运行命令",
|
||||
"zh-cht": "運行命令",
|
||||
"xloc": [
|
||||
"default.handlebars->27->452"
|
||||
"default.handlebars->27->453"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -27973,7 +27973,7 @@
|
||||
"zh-chs": "選擇要在所有選定設備上執行的操作。僅在擁有適當權限的情況下才能執行操作。",
|
||||
"zh-cht": "選擇要在所有選定設備上執行的操作。僅在擁有適當權限的情況下才能執行操作。",
|
||||
"xloc": [
|
||||
"default.handlebars->27->449"
|
||||
"default.handlebars->27->450"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -29734,7 +29734,7 @@
|
||||
"zh-chs": "睡眠裝置",
|
||||
"zh-cht": "睡眠裝置",
|
||||
"xloc": [
|
||||
"default.handlebars->27->453"
|
||||
"default.handlebars->27->454"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -32947,11 +32947,16 @@
|
||||
"zh-cht": "卸載代理",
|
||||
"xloc": [
|
||||
"default-mobile.handlebars->9->426",
|
||||
"default.handlebars->27->1426",
|
||||
"default.handlebars->27->448",
|
||||
"default.handlebars->27->449",
|
||||
"default.handlebars->27->730"
|
||||
]
|
||||
},
|
||||
{
|
||||
"en": "Uninstall Agent / Delete Device",
|
||||
"xloc": [
|
||||
"default.handlebars->27->1426"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cs": "Odinstalovat agenta",
|
||||
"de": "Agenten deinstallieren",
|
||||
@ -34703,7 +34708,7 @@
|
||||
"zh-chs": "喚醒設備",
|
||||
"zh-cht": "喚醒設備",
|
||||
"xloc": [
|
||||
"default.handlebars->27->451"
|
||||
"default.handlebars->27->452"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -2630,7 +2630,7 @@
|
||||
|
||||
// Show bottom buttons
|
||||
x = '<div style=float:right;font-size:x-small;margin-right:10px>';
|
||||
if ((meshrights & 4) != 0) x += '<a style=cursor:pointer onclick=p10showDeleteNodeDialog("' + node._id + '")>' + "Delete Device" + '</a>';
|
||||
if ((meshrights & 0x8000) != 0) { x += '<a style=cursor:pointer onclick=p10showDeleteNodeDialog("' + node._id + '")>' + "Delete Device" + '</a>'; }
|
||||
x += '</div><div style=font-size:x-small>';
|
||||
//if (mesh.mtype == 2) x += '<a style=cursor:pointer onclick=p10showNodeNetInfoDialog("' + node._id + '")>Interfaces</a> ';
|
||||
//if (xxmap != null) x += '<a style=cursor:pointer onclick=p10showNodeLocationDialog("' + node._id + '")>Location</a> ';
|
||||
|
@ -4375,13 +4375,13 @@
|
||||
|
||||
// Display the "Uninstall Agent" option if allowed and we selected connected devices.
|
||||
for (var i in nodeids) {
|
||||
var node = getNodeFromId(nodeids[i]);
|
||||
var rights = GetNodeRights(node);
|
||||
if (((node.conn & 1) != 0) && ((rights & 32768) != 0)) { addedOptions += '<option value=104>' + "Uninstall Agent" + '</option>'; break; }
|
||||
var node = getNodeFromId(nodeids[i]), rights = GetNodeRights(node), added = 0;
|
||||
if ((rights & 1) && ((added & 2) == 0)) { added += 2; addedOptions += '<option value=102>' + "Move to device group" + '</option>'; }
|
||||
if (((node.conn & 1) != 0) && ((rights & 0x8000) != 0) && ((added & 1) == 0)) { added += 1; addedOptions += '<option value=104>' + "Uninstall Agent" + '</option>'; }
|
||||
}
|
||||
|
||||
var x = "Select an operation to perform on all selected devices. Actions will be performed only with proper rights." + '<br /><br />';
|
||||
x += addHtmlValue("Operation", '<select id=d2groupop><option value=100>' + "Wake-up devices" + '</option><option value=106>' + "Run commands" + '</option><option value=4>' + "Sleep devices" + '</option><option value=3>' + "Reset devices" + '</option><option value=2>' + "Power off devices" + '</option><option value=105>' + "Export device information" + '</option><option value=102>' + "Move to device group" + '</option>' + '</option><option value=107>' + "Edit tags" + '</option><option value=108>' + "Device notification" + '</option>' + addedOptions + '<option value=101>' + "Delete devices" + '</option></select>');
|
||||
x += addHtmlValue("Operation", '<select id=d2groupop><option value=100>' + "Wake-up devices" + '</option><option value=106>' + "Run commands" + '</option><option value=4>' + "Sleep devices" + '</option><option value=3>' + "Reset devices" + '</option><option value=2>' + "Power off devices" + '</option><option value=105>' + "Export device information" + '</option>' + '</option><option value=107>' + "Edit tags" + '</option><option value=108>' + "Device notification" + '</option>' + addedOptions + '<option value=101>' + "Delete devices" + '</option></select>');
|
||||
setDialogMode(2, "Group Action", 3, groupActionFunctionEx, x);
|
||||
}
|
||||
|
||||
@ -5689,9 +5689,11 @@
|
||||
|
||||
// Show bottom buttons
|
||||
x = '<div class="p10html3right">';
|
||||
if ((meshrights & 4) != 0) {
|
||||
if ((meshrights & 1) != 0) { // MESHRIGHT_EDITMESH
|
||||
// TODO: Show change group only if there is another mesh of the same type.
|
||||
x += ' <a href=# onclick=p10showChangeGroupDialog(["' + node._id + '"]) title="' + "Move this device to a different device group" + '">' + "Change Group" + '</a>';
|
||||
}
|
||||
if ((meshrights & 0x8000) != 0) { // MESHRIGHT_UNINSTALL
|
||||
x += ' <a href=# onclick=p10showDeleteNodeDialog("' + node._id + '") title="' + "Remove this device" + '">' + "Delete Device" + '</a>';
|
||||
}
|
||||
x += '</div><div class="p10html3left">';
|
||||
@ -9689,7 +9691,7 @@
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20editnotes>' + "Edit Device Notes" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20limitevents>' + "Show Only Own Events" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20chatnotify>' + "Chat & Notify" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20uninstall>' + "Uninstall Agent" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20uninstall>' + "Uninstall Agent / Delete Device" + '</label><br>';
|
||||
x += '<label><input type=checkbox onchange=p20validateAddMeshUserDialog() id=p20settingslock>' + "Lock Account Settings" + '</label><br>';
|
||||
x += '</div>';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user