mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Added browser notification support to MeshMessenger
This commit is contained in:
		
							parent
							
								
									465d5345cb
								
							
						
					
					
						commit
						d511e431ea
					
				
					 7 changed files with 53 additions and 3 deletions
				
			
		| 
						 | 
					@ -263,6 +263,7 @@
 | 
				
			||||||
    <Content Include="public\styles\font-awesome\scss\_screen-reader.scss" />
 | 
					    <Content Include="public\styles\font-awesome\scss\_screen-reader.scss" />
 | 
				
			||||||
    <Content Include="public\styles\font-awesome\scss\_stacked.scss" />
 | 
					    <Content Include="public\styles\font-awesome\scss\_stacked.scss" />
 | 
				
			||||||
    <Content Include="public\styles\font-awesome\scss\_variables.scss" />
 | 
					    <Content Include="public\styles\font-awesome\scss\_variables.scss" />
 | 
				
			||||||
 | 
					    <Content Include="public\styles\messenger.css" />
 | 
				
			||||||
    <Content Include="public\styles\style.css" />
 | 
					    <Content Include="public\styles\style.css" />
 | 
				
			||||||
    <Content Include="readme.md" />
 | 
					    <Content Include="readme.md" />
 | 
				
			||||||
    <Content Include="sample-config.json" />
 | 
					    <Content Include="sample-config.json" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2847,7 +2847,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
 | 
				
			||||||
                var smesh = command.meshid.split('/');
 | 
					                var smesh = command.meshid.split('/');
 | 
				
			||||||
                if ((smesh.length != 3) || (smesh[0] != 'mesh') || (smesh[1] != domain.id)) { err = 'Invalid group id'; }
 | 
					                if ((smesh.length != 3) || (smesh[0] != 'mesh') || (smesh[1] != domain.id)) { err = 'Invalid group id'; }
 | 
				
			||||||
                var serverName = parent.getWebServerName(domain);
 | 
					                var serverName = parent.getWebServerName(domain);
 | 
				
			||||||
                if (parent.args.lanonly == true) { err = 'Server has not fixed IP or DNS name.'; }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Handle any errors
 | 
					                // Handle any errors
 | 
				
			||||||
                if (err != null) {
 | 
					                if (err != null) {
 | 
				
			||||||
| 
						 | 
					@ -2865,6 +2864,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
 | 
				
			||||||
                var xdomain = (domain.dns == null) ? domain.id : '';
 | 
					                var xdomain = (domain.dns == null) ? domain.id : '';
 | 
				
			||||||
                if (xdomain != '') xdomain += "/";
 | 
					                if (xdomain != '') xdomain += "/";
 | 
				
			||||||
                var url = "http" + (args.notls ? '' : 's') + "://" + serverName + ":" + httpsPort + "/" + xdomain + "agentinvite?c=" + inviteCookie;
 | 
					                var url = "http" + (args.notls ? '' : 's') + "://" + serverName + ":" + httpsPort + "/" + xdomain + "agentinvite?c=" + inviteCookie;
 | 
				
			||||||
 | 
					                if (serverName.split('.') == 1) { url = "/" + xdomain + "agentinvite?c=" + inviteCookie; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                ws.send(JSON.stringify({ action: 'createInviteLink', meshid: command.meshid, url: url, expire: command.expire, cookie: inviteCookie, responseid: command.responseid, tag: command.tag }));
 | 
					                ws.send(JSON.stringify({ action: 'createInviteLink', meshid: command.meshid, url: url, expire: command.expire, cookie: inviteCookie, responseid: command.responseid, tag: command.tag }));
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name": "meshcentral",
 | 
					  "name": "meshcentral",
 | 
				
			||||||
  "version": "0.4.1-i",
 | 
					  "version": "0.4.1-j",
 | 
				
			||||||
  "keywords": [
 | 
					  "keywords": [
 | 
				
			||||||
    "Remote Management",
 | 
					    "Remote Management",
 | 
				
			||||||
    "Intel AMT",
 | 
					    "Intel AMT",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB  | 
| 
						 | 
					@ -104,6 +104,21 @@
 | 
				
			||||||
    background-color: orange;
 | 
					    background-color: orange;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.icon12 {
 | 
				
			||||||
 | 
					    background: url(../images/messenger32.png) -352px 0px;
 | 
				
			||||||
 | 
					    background-color: gray;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.icon13 {
 | 
				
			||||||
 | 
					    background: url(../images/messenger32.png) -384px 0px;
 | 
				
			||||||
 | 
					    background-color: gray;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.icon14 {
 | 
				
			||||||
 | 
					    background: url(../images/messenger32.png) -416px 0px;
 | 
				
			||||||
 | 
					    background-color: gray;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.fileicon {
 | 
					.fileicon {
 | 
				
			||||||
    background: url(../images/messenger32.png) -96px 0px;
 | 
					    background: url(../images/messenger32.png) -96px 0px;
 | 
				
			||||||
    height: 32px;
 | 
					    height: 32px;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
					@ -12,6 +12,7 @@
 | 
				
			||||||
    </head>
 | 
					    </head>
 | 
				
			||||||
    <body style="font-family:Arial,Helvetica,sans-serif">
 | 
					    <body style="font-family:Arial,Helvetica,sans-serif">
 | 
				
			||||||
        <div id="xtop" style="position:absolute;left:0;right:0;top:0;height:38px;background-color:#036;color:#c8c8c8;box-shadow:3px 3px 10px gray">
 | 
					        <div id="xtop" style="position:absolute;left:0;right:0;top:0;height:38px;background-color:#036;color:#c8c8c8;box-shadow:3px 3px 10px gray">
 | 
				
			||||||
 | 
					            <div id="notifyButton" class="icon13 topButton" style="margin-right:4px" title="Enable browser notification" onclick="enableNotificationsButtonClick()"></div>
 | 
				
			||||||
            <div id="fileButton" class="icon4 topButton" title="Share a file" style="display:none" onclick="fileButtonClick()"></div>
 | 
					            <div id="fileButton" class="icon4 topButton" title="Share a file" style="display:none" onclick="fileButtonClick()"></div>
 | 
				
			||||||
            <div id="camButton" class="icon2 topButton" title="Activate camera & microphone" style="display:none" onclick="camButtonClick()"></div>
 | 
					            <div id="camButton" class="icon2 topButton" title="Activate camera & microphone" style="display:none" onclick="camButtonClick()"></div>
 | 
				
			||||||
            <div id="micButton" class="icon6 topButton" title="Activate microphone" style="display:none" onclick="micButtonClick()"></div>
 | 
					            <div id="micButton" class="icon6 topButton" title="Activate microphone" style="display:none" onclick="micButtonClick()"></div>
 | 
				
			||||||
| 
						 | 
					@ -52,6 +53,7 @@
 | 
				
			||||||
            var remoteStream = null;
 | 
					            var remoteStream = null;
 | 
				
			||||||
            var multiWebRtc = true;             // if set to true, multiple WebRTC sessions will be setup. If false, everything uses one session.
 | 
					            var multiWebRtc = true;             // if set to true, multiple WebRTC sessions will be setup. If false, everything uses one session.
 | 
				
			||||||
            var userMediaSupport = 0;
 | 
					            var userMediaSupport = 0;
 | 
				
			||||||
 | 
					            var notification = null;
 | 
				
			||||||
            getUserMediaSupport(function (x) { userMediaSupport = x; })
 | 
					            getUserMediaSupport(function (x) { userMediaSupport = x; })
 | 
				
			||||||
            var webrtcconfiguration = "{{{webrtconfig}}}";
 | 
					            var webrtcconfiguration = "{{{webrtconfig}}}";
 | 
				
			||||||
            if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: \"' + webrtcconfiguration + '\".'); webrtcconfiguration = null; } }
 | 
					            if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: \"' + webrtcconfiguration + '\".'); webrtcconfiguration = null; } }
 | 
				
			||||||
| 
						 | 
					@ -65,13 +67,23 @@
 | 
				
			||||||
            // Set the title
 | 
					            // Set the title
 | 
				
			||||||
            if (args.title) { QH('xtitle', ' - ' + args.title); document.title = document.title + ' - ' + args.title; }
 | 
					            if (args.title) { QH('xtitle', ' - ' + args.title); document.title = document.title + ' - ' + args.title; }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
 | 
					            // Setup web notifications
 | 
				
			||||||
 | 
					            if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Listen to drag & drop events
 | 
					            // Listen to drag & drop events
 | 
				
			||||||
            document.addEventListener('dragover', haltEvent, false);
 | 
					            document.addEventListener('dragover', haltEvent, false);
 | 
				
			||||||
            document.addEventListener('dragleave', haltEvent, false);
 | 
					            document.addEventListener('dragleave', haltEvent, false);
 | 
				
			||||||
            document.addEventListener('drop', fileDrop, false);
 | 
					            document.addEventListener('drop', fileDrop, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            document.onclick = function (e) {
 | 
				
			||||||
 | 
					                if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
 | 
				
			||||||
 | 
					                if (notification != null) { notification.close(); notification = null; }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Trap document key up events
 | 
					            // Trap document key up events
 | 
				
			||||||
            document.onkeyup = function ondockeypress(e) {
 | 
					            document.onkeyup = function ondockeypress(e) {
 | 
				
			||||||
 | 
					                if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
 | 
				
			||||||
 | 
					                if (notification != null) { notification.close(); notification = null; }
 | 
				
			||||||
                if (state == 2) {
 | 
					                if (state == 2) {
 | 
				
			||||||
                    if ((e.keyCode == 8) && (userInputFocus == 0)) {
 | 
					                    if ((e.keyCode == 8) && (userInputFocus == 0)) {
 | 
				
			||||||
                        // Backspace
 | 
					                        // Backspace
 | 
				
			||||||
| 
						 | 
					@ -84,6 +96,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Trap document key presses
 | 
					            // Trap document key presses
 | 
				
			||||||
            document.onkeypress = function ondockeypress(e) {
 | 
					            document.onkeypress = function ondockeypress(e) {
 | 
				
			||||||
 | 
					                if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
 | 
				
			||||||
 | 
					                if (notification != null) { notification.close(); notification = null; }
 | 
				
			||||||
                if (state == 2) {
 | 
					                if (state == 2) {
 | 
				
			||||||
                    if (e.keyCode == 13) {
 | 
					                    if (e.keyCode == 13) {
 | 
				
			||||||
                        // Return
 | 
					                        // Return
 | 
				
			||||||
| 
						 | 
					@ -148,10 +162,23 @@
 | 
				
			||||||
            function displayRemote(msg) {
 | 
					            function displayRemote(msg) {
 | 
				
			||||||
                QA('xmsg', '<div style="clear:both"><div class="remoteBubble">' + msg + '</div><div></div></div>');
 | 
					                QA('xmsg', '<div style="clear:both"><div class="remoteBubble">' + msg + '</div><div></div></div>');
 | 
				
			||||||
                Q('xmsg').scrollTop = Q('xmsg').scrollHeight;
 | 
					                Q('xmsg').scrollTop = Q('xmsg').scrollHeight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // If web notifications are granted, use it.
 | 
				
			||||||
 | 
					                if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
 | 
				
			||||||
 | 
					                if (Notification && (Notification.permission == "granted")) {
 | 
				
			||||||
 | 
					                    if (notification != null) { notification.close(); notification = null; }
 | 
				
			||||||
 | 
					                    if (args.title) {
 | 
				
			||||||
 | 
					                        notification = new Notification("MeshMessenger - " + args.title, { body: msg });
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        notification = new Notification("MeshMessenger", { body: msg });
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Display and send a message from the local user
 | 
					            // Display and send a message from the local user
 | 
				
			||||||
            function xsend(event) {
 | 
					            function xsend(event) {
 | 
				
			||||||
 | 
					                if (notification != null) { notification.close(); notification = null; }
 | 
				
			||||||
 | 
					                if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
 | 
				
			||||||
                var outtext = Q('xouttext').value;
 | 
					                var outtext = Q('xouttext').value;
 | 
				
			||||||
                if (outtext.length > 0) {
 | 
					                if (outtext.length > 0) {
 | 
				
			||||||
                    Q('xouttext').value = '';
 | 
					                    Q('xouttext').value = '';
 | 
				
			||||||
| 
						 | 
					@ -486,6 +513,12 @@
 | 
				
			||||||
                send({ action: 'fileUploadAck', id: msg.id });
 | 
					                send({ action: 'fileUploadAck', id: msg.id });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Toggle notification
 | 
				
			||||||
 | 
					            function enableNotificationsButtonClick() {
 | 
				
			||||||
 | 
					                if (Notification) { Notification.requestPermission().then(function (permission) { QV('notifyButton', permission != "granted"); }); }
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Camera button
 | 
					            // Camera button
 | 
				
			||||||
            function camButtonClick() {
 | 
					            function camButtonClick() {
 | 
				
			||||||
                if (localStream == null) { startLocalStream({ video: true, audio: true }); }
 | 
					                if (localStream == null) { startLocalStream({ video: true, audio: true }); }
 | 
				
			||||||
| 
						 | 
					@ -603,6 +636,7 @@
 | 
				
			||||||
                if (webchannel != null) { try { webchannel.close(); } catch (e) { } webchannel = null; }
 | 
					                if (webchannel != null) { try { webchannel.close(); } catch (e) { } webchannel = null; }
 | 
				
			||||||
                if (socket != null) { try { socket.close(); } catch (e) { } socket = null; }
 | 
					                if (socket != null) { try { socket.close(); } catch (e) { } socket = null; }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        </script>
 | 
					        </script>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue