-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EMBCESSMOD-5590: Improve Toast integration, add better UI to file upl…
…oader
- Loading branch information
1 parent
5671476
commit 229fcba
Showing
11 changed files
with
97 additions
and
56 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
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
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
13 changes: 13 additions & 0 deletions
13
...liers/src/UI/embc-supplier/src/app/core/components/toasts/toasts-container.component.html
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,13 @@ | ||
<div class="toast-container"> | ||
@for (toast of toastService.toasts; track toast) { | ||
<ngb-toast | ||
[class]="toast.classname" | ||
[autohide]="true" | ||
[delay]="toast.delay || 5000" | ||
(hidden)="toastService.remove(toast)" | ||
> | ||
{{ toast.text }} | ||
<fa-icon class="close-icon" [icon]="closeIcon" (click)="toastService.remove(toast)"></fa-icon> | ||
</ngb-toast> | ||
} | ||
</div> |
13 changes: 13 additions & 0 deletions
13
...liers/src/UI/embc-supplier/src/app/core/components/toasts/toasts-container.component.scss
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,13 @@ | ||
.toast-container { | ||
z-index: 1200; | ||
top: 0 !important; | ||
right: 0 !important; | ||
position: fixed; | ||
padding: 10px; | ||
|
||
.close-icon { | ||
cursor: pointer; | ||
margin-left: 5px; | ||
} | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
suppliers/src/UI/embc-supplier/src/app/core/components/toasts/toasts-container.component.ts
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,20 @@ | ||
import { Component, inject } from '@angular/core'; | ||
|
||
import { ToastService } from "../../services/toast.service"; | ||
import { NgTemplateOutlet } from '@angular/common'; | ||
import { NgbToastModule } from '@ng-bootstrap/ng-bootstrap'; | ||
import { faXmark } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; | ||
|
||
@Component({ | ||
selector: 'app-toasts', | ||
standalone: true, | ||
imports: [NgbToastModule, NgTemplateOutlet, FontAwesomeModule], | ||
templateUrl: "./toasts-container.component.html", | ||
styleUrls: ["./toasts-container.component.scss"] | ||
}) | ||
|
||
export class ToastsContainer { | ||
closeIcon = faXmark; | ||
toastService = inject(ToastService); | ||
} |
17 changes: 0 additions & 17 deletions
17
suppliers/src/UI/embc-supplier/src/app/core/components/toasts/toasts.component.html
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
suppliers/src/UI/embc-supplier/src/app/core/components/toasts/toasts.component.ts
This file was deleted.
Oops, something went wrong.
20 changes: 15 additions & 5 deletions
20
suppliers/src/UI/embc-supplier/src/app/core/services/toast.service.ts
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,14 +1,24 @@ | ||
import { Injectable, TemplateRef } from '@angular/core'; | ||
import { Injectable } from '@angular/core'; | ||
|
||
export interface Toast { | ||
text: string; | ||
classname?: string; | ||
delay?: number; | ||
} | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class ToastService { | ||
toasts: any[] = []; | ||
toasts: Toast[] = []; | ||
|
||
show(textOrTpl: string | TemplateRef<any>, options: any = {}) { | ||
this.toasts.push({ textOrTpl, ...options }); | ||
show(text: string, options: Partial<Toast> = {}) { | ||
this.toasts.push({ text, ...options }); | ||
} | ||
|
||
remove(toast) { | ||
remove(toast: Toast) { | ||
this.toasts = this.toasts.filter((t) => t !== toast); | ||
} | ||
|
||
clear() { | ||
this.toasts.splice(0, this.toasts.length); | ||
} | ||
} |