-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sockets): full-screen socket connection status if disconnected /…
… retrying to server
- Loading branch information
Showing
5 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
<router-outlet></router-outlet> | ||
|
||
<div class="disconnected" *ngIf="!connected"> | ||
<p *ngIf="state === 2">Connection closed. Please check your internet connection.</p> | ||
<p *ngIf="state === 3 || state === 0">Retrying to connect ...</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { SocketService } from './services/socket.service'; | ||
import { ConnectionStates } from './classes/rx-web-socket.class'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: 'app.component.html' | ||
}) | ||
export class AppComponent { } | ||
export class AppComponent { | ||
connected: boolean; | ||
state: ConnectionStates; | ||
|
||
constructor(private socketService: SocketService) { } | ||
|
||
ngOnInit() { | ||
this.socketService.connectionState | ||
.subscribe(state => { | ||
this.state = state; | ||
|
||
if (state === ConnectionStates.CONNECTED) { | ||
this.connected = true; | ||
} else { | ||
this.connected = false; | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.disconnected | ||
position: fixed | ||
top: 0 | ||
left: 0 | ||
right: 0 | ||
bottom: 0 | ||
width: 100% | ||
height: 100% | ||
display: flex | ||
align-items: center | ||
justify-content: center | ||
color: $white | ||
font-size: 18px | ||
font-weight: bold | ||
background: rgba($black, 0.7) | ||
z-index: 999 |