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

View File

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

View File

@ -35,10 +35,10 @@
<div id="bigok" style="display:none;left:calc((100vh / 2))"><b>&checkmark;</b></div> <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="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="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> <canvas id=Desk width=640 height=480></canvas>
</div> </div>
<div id=TermParent onclick="togglePause()" style="display:none"> <div id=TermParent style="display:none">
<pre id=Term></pre> <pre id=Term></pre>
</div> </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> <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; recFile = null;
recFilePtr = 0; recFilePtr = 0;
recFileMetadata = null; recFileMetadata = null;
playing = false;
if (agentDesktop != null) { agentDesktop.Canvas.clearRect(0, 0, agentDesktop.CanvasId.width, agentDesktop.CanvasId.height); agentDesktop = null; } 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; } if (amtDesktop != null) { amtDesktop.canvas.clearRect(0, 0, amtDesktop.CanvasId.width, amtDesktop.CanvasId.height); amtDesktop = null; }
readState = 0; readState = 0;
@ -370,7 +371,9 @@
QE('idx_dlgOkButton', files.length == 1); 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() { function play() {
Q('PlayButton').blur(); Q('PlayButton').blur();