Skip to content

Commit a5e4fd0

Browse files
committed
display network status
1 parent 00c78cc commit a5e4fd0

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/app/core/components/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class AppComponent implements OnInit, OnDestroy {
5151
this.subscriptions.push(
5252
this.offlineEvent.subscribe(() => {
5353
this.connectionStatus = 'offline';
54-
this.connectionStatusMessage = $localize`Connexion perdue ! Vous n'êtes pas connecté à l'Internet`;
54+
this.connectionStatusMessage = $localize`Vous n'êtes pas connecté à l'Internet`;
5555
})
5656
);
5757
}

src/app/core/components/network-status/network-status.component.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Component, Input, OnInit } from '@angular/core';
55
selector: 'network-status',
66
template: `
77
<div
8-
*ngIf="showNetworkStatus"
8+
*ngIf="networkStatus"
99
@showHideNotification
1010
aria-live="assertive"
1111
class="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:p-6">
@@ -14,52 +14,51 @@ import { Component, Input, OnInit } from '@angular/core';
1414
class="pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-white dark:bg-gray-800 shadow-lg ring-1 ring-black ring-opacity-5">
1515
<div class="p-4">
1616
<div class="flex items-start">
17-
<div class="flex-shrink-0">
18-
<!-- Heroicon name: outline/check-circle -->
17+
<div class="shrink-0">
1918
<svg
20-
class="h-6 w-6 text-green-400"
21-
xmlns="http://www.w3.org/2000/svg"
19+
class="h-6 w-6"
20+
[class.text-red-400]="networkStatus === 'offline'"
21+
[class.text-green-400]="networkStatus === 'online'"
2222
fill="none"
2323
viewBox="0 0 24 24"
2424
stroke-width="1.5"
2525
stroke="currentColor"
26+
xmlns="http://www.w3.org/2000/svg"
27+
viewBox="0 0 24 24"
2628
aria-hidden="true">
2729
<path
30+
*ngIf="networkStatus === 'online'"
2831
stroke-linecap="round"
2932
stroke-linejoin="round"
3033
d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
34+
<path
35+
*ngIf="networkStatus === 'offline'"
36+
d="M15.312 10c1.368.426 2.65 1.12 3.768 2.05m3.5-3.55a16 16 0 0 0-12.383-3.896M8.53 15.61a6 6 0 0 1 6.95 0M12 19.5h.01M1.193 8.7A16.014 16.014 0 0 1 5.76 5.764m-1.027 6.48a10.966 10.966 0 0 1 5-2.51m5.966 6.042A5.974 5.974 0 0 0 12 14.5c-1.416 0-2.718.49-3.745 1.312M3 3l18 18"
37+
stroke-linecap="round"
38+
stroke-linejoin="round" />
3139
</svg>
3240
</div>
3341
<div class="ml-3 w-0 flex-1 pt-0.5">
3442
<p class="text-sm font-medium text-slate-900 capitalize">
35-
Online
43+
{{ networkStatus }}
3644
</p>
3745
<p class="mt-1 text-sm text-slate-500">
38-
Anyone with a link can now view this file.
46+
{{ networkStatusMessage }}
3947
</p>
4048
</div>
4149
</div>
4250
</div>
4351
</div>
4452
</div>
4553
</div>
46-
<div *ngIf="networkStatus === 'online'" class="online">
47-
<span>{{ networkStatusMessage }}</span>
48-
</div>
49-
50-
<div *ngIf="networkStatus === 'offline'" class="offline">
51-
<span>{{ networkStatusMessage }}</span>
52-
</div>
5354
`,
5455
animations: [
5556
trigger('showHideNotification', [
5657
transition('void => *', [
57-
style({ transform: "translateX(0.5rem)", opacity: 0 }),
58-
animate(300, style({ transform: "translateX(0)", opacity: 1 }))
58+
style({ transform: 'translateX(0.5rem)', opacity: 0 }),
59+
animate(300, style({ transform: 'translateX(0)', opacity: 1 })),
5960
]),
60-
transition('* => void', [
61-
animate(100, style({ opacity: 0 }))
62-
])
61+
transition('* => void', [animate(100, style({ opacity: 0 }))]),
6362
]),
6463
],
6564
})
@@ -72,6 +71,6 @@ export class NetworkStatusComponent implements OnInit {
7271
ngOnInit() {
7372
setTimeout(() => {
7473
this.showNetworkStatus = false;
75-
}, 3000);
74+
}, 100);
7675
}
7776
}

0 commit comments

Comments
 (0)