Open BoJIbFbI4 opened 6 years ago
it's possible to dynamically change content. For example: catch the file size and show it in %. with existing code, i get a new notification for every kb.
toast(req: any, fileName: string) { this.form = this._fb.group({ type: 'success', timeOut: 1000, showProgressBar: true, pauseOnHover: true, clickToClose: true, animate: 'fromRight' }); this.http.request(req).subscribe((event: HttpEvent<any>) => { switch (event.type) { case HttpEventType.Sent: const toastStart = this.form.getRawValue(); this.notificationService.success(`Downloading ${fileName}`, `Download is started! `, toastStart); delete toastStart.type; break; case HttpEventType.ResponseHeader: break; case HttpEventType.DownloadProgress: this.size = (event.total / 1048576).toFixed(2); break; case HttpEventType.Response: const toastDone = this.form.getRawValue(); toastDone.showProgressBar = false; this.notificationService.success(`Downloading ${fileName}`, `Download is finished! ${this.size} Mb loaded`, toastDone); saveAs(event.body, fileName); } }); }
what's new?
it's possible to dynamically change content. For example: catch the file size and show it in %. with existing code, i get a new notification for every kb.