mirror of https://github.com/abpframework/abp.git
committed by
GitHub
8 changed files with 73 additions and 1 deletions
@ -0,0 +1,18 @@ |
|||
import { DOCUMENT } from '@angular/common'; |
|||
import { Injectable, inject } from '@angular/core'; |
|||
import { fromEvent, merge, of } from 'rxjs'; |
|||
import { map } from 'rxjs/operators'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
export class InternetConnectionService{ |
|||
protected readonly window = inject(DOCUMENT).defaultView; |
|||
protected readonly navigator = this.window.navigator; |
|||
|
|||
networkStatus$ = merge( |
|||
of(navigator.onLine), |
|||
fromEvent(window, 'offline'), |
|||
fromEvent(window, 'online') |
|||
).pipe(map(() => navigator.onLine)) |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
import { Component, inject } from '@angular/core'; |
|||
import { CommonModule } from '@angular/common' |
|||
import { map } from 'rxjs'; |
|||
import { InternetConnectionService, LocalizationModule } from '@abp/ng.core'; |
|||
|
|||
@Component({ |
|||
selector: 'abp-internet-status', |
|||
standalone: true, |
|||
imports:[CommonModule,LocalizationModule], |
|||
template: ` |
|||
<div class="status-icon" *ngIf="isOffline$ | async"> |
|||
<i data-toggle="tooltip" title="{{ 'AbpUi::InternetConnectionInfo' | abpLocalization }}" data-placement="left" class="fa fa-circle text-blinking blink"> |
|||
</i> |
|||
</div> |
|||
`,
|
|||
styles: [` |
|||
.blink { |
|||
animation: blinker 0.9s cubic-bezier(.5, 0, 1, 1) infinite alternate; |
|||
} |
|||
@keyframes blinker { |
|||
0% { color:#c1c1c1 } |
|||
70% { color: #DC3545 } |
|||
100% { color: #DC3545 } |
|||
} |
|||
|
|||
.text-blinking{ |
|||
font-size:1.2rem; |
|||
} |
|||
|
|||
.status-icon{ |
|||
position: fixed; |
|||
z-index: 999999; |
|||
top: 10px; |
|||
right: 10px; |
|||
} |
|||
|
|||
@media (width < 768px){ |
|||
.status-icon{ |
|||
top: 26px; |
|||
right: 134px; |
|||
} |
|||
} |
|||
`]
|
|||
}) |
|||
export class InternetConnectionStatusComponent{ |
|||
internetConnectionService = inject(InternetConnectionService) |
|||
isOffline$ = this.internetConnectionService.networkStatus$.pipe(map((val) => !val)); |
|||
} |
|||
Loading…
Reference in new issue