toast changes

This commit is contained in:
Jonas Winkler
2020-10-29 14:35:36 +01:00
parent 2c318b87a0
commit 635a02c611
6 changed files with 35 additions and 17 deletions

View File

@@ -66,7 +66,7 @@ export abstract class EditDialogComponent<T extends ObjectWithId> implements OnI
this.activeModal.close()
this.success.emit(result)
}, error => {
this.toastService.showToast(Toast.make("Error", `Could not save ${this.entityName}: ${error.error.name}`))
this.toastService.showToast(Toast.makeError(`Could not save ${this.entityName}: ${error.error.name}`))
})
}

View File

@@ -1,6 +1,7 @@
<ngb-toast
*ngFor="let toast of toasts"
[header]="toast.title" [autohide]="true" [delay]="toast.delay"
[class]="toast.classname"
(hide)="toastService.closeToast(toast)">
{{toast.content}}
</ngb-toast>

View File

@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { FileSystemDirectoryEntry, FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop';
import { DocumentService } from 'src/app/services/rest/document.service';
import { Toast, ToastService } from 'src/app/services/toast.service';
@Component({
selector: 'app-dashboard',
@@ -9,7 +10,7 @@ import { DocumentService } from 'src/app/services/rest/document.service';
})
export class DashboardComponent implements OnInit {
constructor(private documentService: DocumentService) { }
constructor(private documentService: DocumentService, private toastService: ToastService) { }
ngOnInit(): void {
}
@@ -24,8 +25,6 @@ export class DashboardComponent implements OnInit {
public dropped(files: NgxFileDropEntry[]) {
for (const droppedFile of files) {
// Is it a file?
if (droppedFile.fileEntry.isFile) {
const fileEntry = droppedFile.fileEntry as FileSystemFileEntry;
console.log(fileEntry)
@@ -34,9 +33,9 @@ export class DashboardComponent implements OnInit {
const formData = new FormData()
formData.append('document', file, file.name)
this.documentService.uploadDocument(formData).subscribe(result => {
console.log(result)
this.toastService.showToast(Toast.make("Information", "The document has been uploaded and will be processed by the consumer shortly."))
}, error => {
console.error(error)
this.toastService.showToast(Toast.makeError("An error has occured while uploading the document. Sorry!"))
})
});
}

View File

@@ -26,7 +26,7 @@ export class LoginComponent implements OnInit {
this.auth.login(this.loginForm.value.username, this.loginForm.value.password, this.loginForm.value.rememberMe).subscribe(result => {
this.router.navigate([''])
}, (error) => {
this.toastService.showToast(Toast.make("Error", "result: " + JSON.stringify(error.error)))
this.toastService.showToast(Toast.makeError("Unable to log in with provided credentials."))
}
)
}