Small fixed to MeshPlayer

Ylian Saint-Hilaire committed Aug 13, 2019 at 17:06 UTC b9116203f95dde2a05ab22b7159bc6c7a5feb3e2
3 files changed +42 -35
db.js
+35 -31
@@ -234,41 +234,45 @@ module.exports.CreateDB = function (parent, func) {
234
235 // Setup the changeStream on the MongoDB main collection if possible
236 if (parent.args.mongodbchangestream == true) {
237 - obj.fileChangeStream = obj.file.watch( [ { $match: { $or: [{ 'fullDocument.type': { $in: ['node', 'mesh', 'user'] } }, { 'operationType': 'delete' }] } } ], { fullDocument: 'updateLookup' });
238 - obj.fileChangeStream.on('change', function (change) {
239 - if (change.operationType == 'update') {
240 - switch (change.fullDocument.type) {
241 - case 'node': { dbNodeChange(change, false); break; } // A node has changed
242 - case 'mesh': { dbMeshChange(change, false); break; } // A device group has changed
243 - case 'user': { dbUserChange(change, false); break; } // A user account has changed
244 - }
245 - } else if (change.operationType == 'insert') {
246 - switch (change.fullDocument.type) {
247 - case 'node': { dbNodeChange(change, true); break; } // A node has added
248 - case 'mesh': { dbMeshChange(change, true); break; } // A device group has created
249 - case 'user': { dbUserChange(change, true); break; } // A user account has created
250 - }
251 - } else if (change.operationType == 'delete') {
252 - var splitId = change.documentKey._id.split('/');
253 - switch (splitId[0]) {
254 - case 'node': {
255 - //Not Good: Problem here is that we don't know what meshid the node belonged to before the delete.
256 - //parent.DispatchEvent(['*', node.meshid], obj, { etype: 'node', action: 'removenode', nodeid: change.documentKey._id, domain: splitId[1] });
257 - break;
237 + if (typeof obj.file.watch != 'function') {
238 + console.log('WARNING: watch() is not a function, MongoDB ChangeStream not supported.');
239 + } else {
240 + obj.fileChangeStream = obj.file.watch([{ $match: { $or: [{ 'fullDocument.type': { $in: ['node', 'mesh', 'user'] } }, { 'operationType': 'delete' }] } }], { fullDocument: 'updateLookup' });
241 + obj.fileChangeStream.on('change', function (change) {
242 + if (change.operationType == 'update') {
243 + switch (change.fullDocument.type) {
244 + case 'node': { dbNodeChange(change, false); break; } // A node has changed
245 + case 'mesh': { dbMeshChange(change, false); break; } // A device group has changed
246 + case 'user': { dbUserChange(change, false); break; } // A user account has changed
247 }
259 - case 'mesh': {
260 - parent.DispatchEvent(['*', node.meshid], obj, { etype: 'mesh', action: 'deletemesh', meshid: change.documentKey._id, domain: splitId[1] });
261 - break;
248 + } else if (change.operationType == 'insert') {
249 + switch (change.fullDocument.type) {
250 + case 'node': { dbNodeChange(change, true); break; } // A node has added
251 + case 'mesh': { dbMeshChange(change, true); break; } // A device group has created
252 + case 'user': { dbUserChange(change, true); break; } // A user account has created
253 }
263 - case 'user': {
264 - //Not Good: This is not a perfect user removal because we don't know what groups the user was in.
265 - //parent.DispatchEvent(['*', 'server-users'], obj, { etype: 'user', action: 'accountremove', userid: change.documentKey._id, domain: splitId[1], username: splitId[2] });
266 - break;
254 + } else if (change.operationType == 'delete') {
255 + var splitId = change.documentKey._id.split('/');
256 + switch (splitId[0]) {
257 + case 'node': {
258 + //Not Good: Problem here is that we don't know what meshid the node belonged to before the delete.
259 + //parent.DispatchEvent(['*', node.meshid], obj, { etype: 'node', action: 'removenode', nodeid: change.documentKey._id, domain: splitId[1] });
260 + break;
261 + }
262 + case 'mesh': {
263 + parent.DispatchEvent(['*', node.meshid], obj, { etype: 'mesh', action: 'deletemesh', meshid: change.documentKey._id, domain: splitId[1] });
264 + break;
265 + }
266 + case 'user': {
267 + //Not Good: This is not a perfect user removal because we don't know what groups the user was in.
268 + //parent.DispatchEvent(['*', 'server-users'], obj, { etype: 'user', action: 'accountremove', userid: change.documentKey._id, domain: splitId[1], username: splitId[2] });
269 + break;
270 + }
271 }
272 }
269 - }
270 - });
271 - obj.changeStream = true;
273 + });
274 + obj.changeStream = true;
275 + }
276 }
277
278 // Setup MongoDB events collection and indexes
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.3.9-s",
3 + "version": "0.3.9-t",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
public/player.htm
+6 -3
@@ -35,10 +35,10 @@
35 <div id="bigok" style="display:none;left:calc((100vh / 2))"><b>&checkmark;</b></div>
36 <div id="bigfail" style="display:none;left:calc((100vh / 2))"><b>&#10007;</b></div>
37 <div id="metadatadiv" style="padding:20px;color:lightgrey;text-align:left;display:none"></div>
38 - <div id=DeskParent onclick="togglePause()">
38 + <div id=DeskParent>
39 <canvas id=Desk width=640 height=480></canvas>
40 </div>
41 - <div id=TermParent onclick="togglePause()" style="display:none">
41 + <div id=TermParent style="display:none">
42 <pre id=Term></pre>
43 </div>
44 <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 @@
279 recFile = null;
280 recFilePtr = 0;
281 recFileMetadata = null;
282 + playing = false;
283 if (agentDesktop != null) { agentDesktop.Canvas.clearRect(0, 0, agentDesktop.CanvasId.width, agentDesktop.CanvasId.height); agentDesktop = null; }
284 if (amtDesktop != null) { amtDesktop.canvas.clearRect(0, 0, amtDesktop.CanvasId.width, amtDesktop.CanvasId.height); amtDesktop = null; }
285 readState = 0;
@@ -370,7 +371,9 @@
371 QE('idx_dlgOkButton', files.length == 1);
372 }
373
373 - function togglePause() { if (recFile == null) return; if (playing == true) { pause(); } else { if (recFilePtr != recFile.size) { play(); } } }
374 + function togglePause() {
375 + if (recFile != null) { if (playing == true) { pause(); } else { if (recFilePtr != recFile.size) { play(); } } } return false;
376 + }
377
378 function play() {
379 Q('PlayButton').blur();