Small fixed to MeshPlayer

This commit is contained in:
Ylian Saint-Hilaire 2019-08-13 17:06:45 -07:00
parent 673e00f51a
commit 98ffdcf220
3 changed files with 42 additions and 35 deletions

66
db.js
View File

@ -234,41 +234,45 @@ module.exports.CreateDB = function (parent, func) {
// Setup the changeStream on the MongoDB main collection if possible
if (parent.args.mongodbchangestream == true) {
obj.fileChangeStream = obj.file.watch( [ { $match: { $or: [{ 'fullDocument.type': { $in: ['node', 'mesh', 'user'] } }, { 'operationType': 'delete' }] } } ], { fullDocument: 'updateLookup' });
obj.fileChangeStream.on('change', function (change) {
if (change.operationType == 'update') {
switch (change.fullDocument.type) {
case 'node': { dbNodeChange(change, false); break; } // A node has changed
case 'mesh': { dbMeshChange(change, false); break; } // A device group has changed
case 'user': { dbUserChange(change, false); break; } // A user account has changed
}
} else if (change.operationType == 'insert') {
switch (change.fullDocument.type) {
case 'node': { dbNodeChange(change, true); break; } // A node has added
case 'mesh': { dbMeshChange(change, true); break; } // A device group has created
case 'user': { dbUserChange(change, true); break; } // A user account has created
}
} else if (change.operationType == 'delete') {
var splitId = change.documentKey._id.split('/');
switch (splitId[0]) {
case 'node': {
//Not Good: Problem here is that we don't know what meshid the node belonged to before the delete.
//parent.DispatchEvent(['*', node.meshid], obj, { etype: 'node', action: 'removenode', nodeid: change.documentKey._id, domain: splitId[1] });
break;
if (typeof obj.file.watch != 'function') {
console.log('WARNING: watch() is not a function, MongoDB ChangeStream not supported.');
} else {
obj.fileChangeStream = obj.file.watch([{ $match: { $or: [{ 'fullDocument.type': { $in: ['node', 'mesh', 'user'] } }, { 'operationType': 'delete' }] } }], { fullDocument: 'updateLookup' });
obj.fileChangeStream.on('change', function (change) {
if (change.operationType == 'update') {
switch (change.fullDocument.type) {
case 'node': { dbNodeChange(change, false); break; } // A node has changed
case 'mesh': { dbMeshChange(change, false); break; } // A device group has changed
case 'user': { dbUserChange(change, false); break; } // A user account has changed
}
case 'mesh': {
parent.DispatchEvent(['*', node.meshid], obj, { etype: 'mesh', action: 'deletemesh', meshid: change.documentKey._id, domain: splitId[1] });
break;
} else if (change.operationType == 'insert') {
switch (change.fullDocument.type) {
case 'node': { dbNodeChange(change, true); break; } // A node has added
case 'mesh': { dbMeshChange(change, true); break; } // A device group has created
case 'user': { dbUserChange(change, true); break; } // A user account has created
}
case 'user': {
//Not Good: This is not a perfect user removal because we don't know what groups the user was in.
//parent.DispatchEvent(['*', 'server-users'], obj, { etype: 'user', action: 'accountremove', userid: change.documentKey._id, domain: splitId[1], username: splitId[2] });
break;
} else if (change.operationType == 'delete') {
var splitId = change.documentKey._id.split('/');
switch (splitId[0]) {
case 'node': {
//Not Good: Problem here is that we don't know what meshid the node belonged to before the delete.
//parent.DispatchEvent(['*', node.meshid], obj, { etype: 'node', action: 'removenode', nodeid: change.documentKey._id, domain: splitId[1] });
break;
}
case 'mesh': {
parent.DispatchEvent(['*', node.meshid], obj, { etype: 'mesh', action: 'deletemesh', meshid: change.documentKey._id, domain: splitId[1] });
break;
}
case 'user': {
//Not Good: This is not a perfect user removal because we don't know what groups the user was in.
//parent.DispatchEvent(['*', 'server-users'], obj, { etype: 'user', action: 'accountremove', userid: change.documentKey._id, domain: splitId[1], username: splitId[2] });
break;
}
}
}
}
});
obj.changeStream = true;
});
obj.changeStream = true;
}
}
// Setup MongoDB events collection and indexes

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.3.9-s",
"version": "0.3.9-t",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -35,10 +35,10 @@
<div id="bigok" style="display:none;left:calc((100vh / 2))"><b>&checkmark;</b></div>
<div id="bigfail" style="display:none;left:calc((100vh / 2))"><b>&#10007;</b></div>
<div id="metadatadiv" style="padding:20px;color:lightgrey;text-align:left;display:none"></div>
<div id=DeskParent onclick="togglePause()">
<div id=DeskParent>
<canvas id=Desk width=640 height=480></canvas>
</div>
<div id=TermParent onclick="togglePause()" style="display:none">
<div id=TermParent style="display:none">
<pre id=Term></pre>
</div>
<div id=p11DeskConsoleMsg style="display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=clearConsoleMsg()></div>
@ -279,6 +279,7 @@
recFile = null;
recFilePtr = 0;
recFileMetadata = null;
playing = false;
if (agentDesktop != null) { agentDesktop.Canvas.clearRect(0, 0, agentDesktop.CanvasId.width, agentDesktop.CanvasId.height); agentDesktop = null; }
if (amtDesktop != null) { amtDesktop.canvas.clearRect(0, 0, amtDesktop.CanvasId.width, amtDesktop.CanvasId.height); amtDesktop = null; }
readState = 0;
@ -370,7 +371,9 @@
QE('idx_dlgOkButton', files.length == 1);
}
function togglePause() { if (recFile == null) return; if (playing == true) { pause(); } else { if (recFilePtr != recFile.size) { play(); } } }
function togglePause() {
if (recFile != null) { if (playing == true) { pause(); } else { if (recFilePtr != recFile.size) { play(); } } } return false;
}
function play() {
Q('PlayButton').blur();