How to use the @angular/common/http.HttpEventType.Response function in @angular/common

To help you get started, we’ve selected a few @angular/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / incubator-streampipes / ui / src / app / data-explorer / explorer / datadownloadDialog / dataDownload.dialog.ts View on Github external
this.downloadHttpRequestSubscribtion = request.subscribe(event => {
            // progress
            if (event.type === HttpEventType.DownloadProgress) {
                this.downloadedMBs = event.loaded / 1024 / 1014
            }

            // finished
            if (event.type === HttpEventType.Response) {
                this.createFile(event.body, this.downloadFormat, this.data.index, startDate, endDate);
                this.downloadFinish = true
            }
        });
    }
github xmlking / ngx-starter-kit / libs / core / src / lib / services / profile.service.ts View on Github external
switch (event.type) {
      case HttpEventType.Sent:
        return `Uploading Files`;

      case HttpEventType.UploadProgress:
        status = Math.round((100 * event.loaded) / event.total);
        this.uploadProgress.next(status);
        return `Files are ${status}% uploaded`;

      case HttpEventType.DownloadProgress:
        status = Math.round((100 * event.loaded) / event.total);
        this.downloadProgress.next(status); // NOTE: The Content-Length header must be set on the server to calculate this
        return `Files are ${status}% downloaded`;

      case HttpEventType.Response:
        return (event as HttpResponse).body; // `Done`;

      default:
        return `Something went wrong`;
    }
  }
}
github dcaslin / d2-checklist / src / app / service / destiny-cache.service.ts View on Github external
private showProgress(evt: HttpEvent) {
    switch (evt.type) {
      case HttpEventType.Sent:
        this.percent.next(5);
        break;
      case HttpEventType.ResponseHeader:
        this.percent.next(10);
        break;
      case HttpEventType.DownloadProgress:
        const kbLoaded = Math.round(evt.loaded / 1024);
        console.log(`Download in progress! ${kbLoaded}Kb loaded`);
        this.percent.next(15 + 80 * evt.loaded / evt.total);
        break;
      case HttpEventType.Response: {
        this.percent.next(95);
      }
    }
  }
github MyCoRe-Org / MyVidCoRe / src / ui / src / app / converter / api.service.ts View on Github external
map(event => {
                if (event.type === HttpEventType.UploadProgress && progress && event.total) {
                    const percentDone = Math.round(100 * event.loaded / event.total);
                    progress.next(percentDone);
                } else if (event.type === HttpEventType.Response) {
                    if (progress) {
                        progress.next(100);
                        progress.complete();
                    }

                    return event;
                }
            }),
            last()
github autowp / autowp / ng2 / src / app / moder / items / item / logo / logo.component.ts View on Github external
switchMap(httpEvent => {
          if (httpEvent.type === HttpEventType.DownloadProgress) {
            this.progress.percentage = Math.round(
              50 + 25 * (httpEvent.loaded / httpEvent.total)
            );
            return empty();
          }

          if (httpEvent.type === HttpEventType.UploadProgress) {
            this.progress.percentage = Math.round(
              50 * (httpEvent.loaded / httpEvent.total)
            );
            return empty();
          }

          if (httpEvent.type === HttpEventType.Response) {
            this.progress.percentage = 75;
            this.progress.success = true;

            return this.http
              .get('/api/item/' + this.item.id + '/logo')
              .pipe(
                tap(subresponse => {
                  this.progress.percentage = 100;
                  this.item.logo = subresponse;
                }),
                catchError((response, caught) => {
                  Notify.response(response);

                  return empty();
                })
              );
github inspursoft / board / src / ui / src / app / image / image-create-old / image-create-old.component.ts View on Github external
this.imageService.uploadFile(formData).subscribe((res: HttpEvent) => {
          if (res.type === HttpEventType.UploadProgress) {
            this.uploadProgressValue = res;
          } else if (res.type === HttpEventType.Response) {
            (event.target as HTMLInputElement).value = '';
            this.uploadTarPackageName = file.name;
            this.isUploadFileWIP = false;
            this.updateFileListAndPreviewInfo();
            this.messageService.showAlert('IMAGE.CREATE_IMAGE_UPLOAD_SUCCESS', {view: this.alertView});
          }
        }, (error: HttpErrorResponse) => {
          this.isUploadFileWIP = false;
github BinaryStudioAcademy / bsa-2018-watcher / frontend / src / app / admin / data-collector / data-collector.component.ts View on Github external
event => {
        if (event.type === HttpEventType.UploadProgress) {
          this.collectorApp.tgzLink = Math.round(100 * event.loaded / event.total).toString();
        } else if (event.type === HttpEventType.Response) {
          this.collectorApp.tgzLink = event.body.toString();
        }
      });
  }
github Squidex / squidex / frontend / app / shared / services / assets.service.ts View on Github external
filter(event =>
                event.type === HttpEventType.UploadProgress ||
                event.type === HttpEventType.Response),
            map(event => {
github Lumeer / web-ui / src / app / shared / data-input / files / files-data-input.component.ts View on Github external
(event: HttpEvent) => {
        switch (event.type) {
          case HttpEventType.Response:
            this.uploadProgress$.next(null);
            this.onSuccess(fileAttachment);
            return;
          case HttpEventType.UploadProgress:
            this.uploadProgress$.next(Math.round((event.loaded / event.total) * 100));
            return;
        }
      },
      () => this.onUploadFailure(fileAttachment.id)
github intershop / intershop-pwa / src / app / core / interceptors / mock.interceptor.spec.ts View on Github external
.subscribe(event => {
          expect(event.type).toBe(HttpEventType.Response);

          const response = event as HttpResponse;
          expect(response.headers.get('authentication-token')).toBeTruthy();
          done();
        });
    });