mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	Merge pull request #184 from geeeeeeeeek/issue/network-error-page
Improve network error display.
This commit is contained in:
		
							
								
								
									
										42
									
								
								app/renderer/css/network.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								app/renderer/css/network.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					html, body {
 | 
				
			||||||
 | 
					    margin: 0;
 | 
				
			||||||
 | 
					    cursor: default;
 | 
				
			||||||
 | 
					    font-size: 14px;
 | 
				
			||||||
 | 
					    color: #333;
 | 
				
			||||||
 | 
					    background: #fff;
 | 
				
			||||||
 | 
					    user-select:none;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#content {
 | 
				
			||||||
 | 
					    display: flex;
 | 
				
			||||||
 | 
					    flex-direction: column;
 | 
				
			||||||
 | 
					    font-family: "Trebuchet MS", Helvetica, sans-serif;
 | 
				
			||||||
 | 
					    margin: 100px 200px;
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#title {
 | 
				
			||||||
 | 
					    font-size: 24px;
 | 
				
			||||||
 | 
					    font-weight: bold;
 | 
				
			||||||
 | 
					    margin: 20px 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#description {
 | 
				
			||||||
 | 
					    font-size: 16px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#reconnect {
 | 
				
			||||||
 | 
					    font-size: 16px;
 | 
				
			||||||
 | 
					    background: #009688;
 | 
				
			||||||
 | 
					    color: #fff;
 | 
				
			||||||
 | 
					    width: 84px;
 | 
				
			||||||
 | 
					    height: 32px;
 | 
				
			||||||
 | 
					    border-radius: 5px;
 | 
				
			||||||
 | 
					    line-height: 32px;
 | 
				
			||||||
 | 
					    margin: 20px auto 0;
 | 
				
			||||||
 | 
					    cursor: pointer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#reconnect:hover {
 | 
				
			||||||
 | 
					    opacity: 0.8;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								app/renderer/img/zulip_network.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/renderer/img/zulip_network.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 27 KiB  | 
@@ -64,7 +64,7 @@ class WebView extends BaseComponent {
 | 
				
			|||||||
			const hasConnectivityErr = (SystemUtil.connectivityERR.indexOf(errorDescription) >= 0);
 | 
								const hasConnectivityErr = (SystemUtil.connectivityERR.indexOf(errorDescription) >= 0);
 | 
				
			||||||
			if (hasConnectivityErr) {
 | 
								if (hasConnectivityErr) {
 | 
				
			||||||
				console.error('error', errorDescription);
 | 
									console.error('error', errorDescription);
 | 
				
			||||||
				this.checkConnectivity();
 | 
									this.props.onNetworkError();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,6 +54,7 @@ class ServerManagerView {
 | 
				
			|||||||
				isActive: () => {
 | 
									isActive: () => {
 | 
				
			||||||
					return index === this.activeTabIndex;
 | 
										return index === this.activeTabIndex;
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
 | 
									onNetworkError: this.openNetworkTroubleshooting.bind(this),
 | 
				
			||||||
				onTitleChange: this.updateBadge.bind(this),
 | 
									onTitleChange: this.updateBadge.bind(this),
 | 
				
			||||||
				nodeIntegration: false
 | 
									nodeIntegration: false
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
@@ -89,6 +90,7 @@ class ServerManagerView {
 | 
				
			|||||||
				isActive: () => {
 | 
									isActive: () => {
 | 
				
			||||||
					return this.functionalTabs[tabProps.name] === this.activeTabIndex;
 | 
										return this.functionalTabs[tabProps.name] === this.activeTabIndex;
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
 | 
									onNetworkError: this.openNetworkTroubleshooting.bind(this),
 | 
				
			||||||
				onTitleChange: this.updateBadge.bind(this),
 | 
									onTitleChange: this.updateBadge.bind(this),
 | 
				
			||||||
				nodeIntegration: true
 | 
									nodeIntegration: true
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
@@ -113,6 +115,14 @@ class ServerManagerView {
 | 
				
			|||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						openNetworkTroubleshooting() {
 | 
				
			||||||
 | 
							this.openFunctionalTab({
 | 
				
			||||||
 | 
								name: 'Network Troubleshooting',
 | 
				
			||||||
 | 
								materialIcon: 'network_check',
 | 
				
			||||||
 | 
								url: `file://${__dirname}/network.html`
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	activateTab(index, hideOldTab = true) {
 | 
						activateTab(index, hideOldTab = true) {
 | 
				
			||||||
		if (this.tabs[index].loading) {
 | 
							if (this.tabs[index].loading) {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
@@ -188,3 +198,7 @@ window.onload = () => {
 | 
				
			|||||||
	const serverManagerView = new ServerManagerView();
 | 
						const serverManagerView = new ServerManagerView();
 | 
				
			||||||
	serverManagerView.init();
 | 
						serverManagerView.init();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					window.addEventListener('online', () => {
 | 
				
			||||||
 | 
						ipcRenderer.send('reload-main');
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								app/renderer/js/pages/network.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								app/renderer/js/pages/network.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const {ipcRenderer} = require('electron');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class NetworkTroubleshootingView {
 | 
				
			||||||
 | 
						constructor() {
 | 
				
			||||||
 | 
							this.$reconnectButton = document.getElementById('reconnect');
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						init() {
 | 
				
			||||||
 | 
							this.$reconnectButton.addEventListener('click', () => {
 | 
				
			||||||
 | 
								ipcRenderer.send('reload-main');
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					window.onload = () => {
 | 
				
			||||||
 | 
						const networkTroubleshootingView = new NetworkTroubleshootingView();
 | 
				
			||||||
 | 
						networkTroubleshootingView.init();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					const {ipcRenderer} = require('electron');
 | 
				
			||||||
const {spellChecker} = require('./spellchecker');
 | 
					const {spellChecker} = require('./spellchecker');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const logout = () => {
 | 
					const logout = () => {
 | 
				
			||||||
@@ -30,4 +31,9 @@ process.once('loaded', () => {
 | 
				
			|||||||
document.addEventListener('DOMContentLoaded', () => {
 | 
					document.addEventListener('DOMContentLoaded', () => {
 | 
				
			||||||
	// Init spellchecker
 | 
						// Init spellchecker
 | 
				
			||||||
	spellChecker();
 | 
						spellChecker();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// redirect users to network troubleshooting page
 | 
				
			||||||
 | 
						document.querySelector('.restart_get_events_button').addEventListener('click', () => {
 | 
				
			||||||
 | 
							ipcRenderer.send('reload-main');
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,7 +118,7 @@ const createTray = function () {
 | 
				
			|||||||
		label: 'About',
 | 
							label: 'About',
 | 
				
			||||||
		click() {
 | 
							click() {
 | 
				
			||||||
			// We need to focus the main window first
 | 
								// We need to focus the main window first
 | 
				
			||||||
		    ipcRenderer.send('focus-app');
 | 
								ipcRenderer.send('focus-app');
 | 
				
			||||||
			sendAction('open-about');
 | 
								sendAction('open-about');
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
@@ -137,7 +137,7 @@ const createTray = function () {
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		label: 'Manage Zulip servers',
 | 
							label: 'Manage Zulip servers',
 | 
				
			||||||
		click() {
 | 
							click() {
 | 
				
			||||||
		    ipcRenderer.send('focus-app');
 | 
								ipcRenderer.send('focus-app');
 | 
				
			||||||
			sendAction('open-settings');
 | 
								sendAction('open-settings');
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										21
									
								
								app/renderer/network.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								app/renderer/network.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<!DOCTYPE html>
 | 
				
			||||||
 | 
					<html lang="en" class="responsive desktop">
 | 
				
			||||||
 | 
					  <head>
 | 
				
			||||||
 | 
					    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 | 
				
			||||||
 | 
					    <meta name="viewport" content="width=device-width">
 | 
				
			||||||
 | 
					    <title>Zulip - Network Troubleshooting</title>
 | 
				
			||||||
 | 
					    <link rel="stylesheet" href="css/network.css" type="text/css" media="screen">
 | 
				
			||||||
 | 
					  </head>
 | 
				
			||||||
 | 
					  <body>
 | 
				
			||||||
 | 
					    <div id="content">
 | 
				
			||||||
 | 
					      <div id="picture"><img src="img/zulip_network.png"></div>
 | 
				
			||||||
 | 
					      <div id="title">Zulip can't connect</div>
 | 
				
			||||||
 | 
					      <div id="description">
 | 
				
			||||||
 | 
					        <div>Your computer seems to be offline.</div>
 | 
				
			||||||
 | 
					        <div>We will keep trying to reconnect, or you can try now.</div>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					      <div id="reconnect">Try now</div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </body>
 | 
				
			||||||
 | 
					  <script src="js/pages/network.js"></script>  
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user