Guest User

Untitled

a guest
Jun 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <div class="progress progressbar" style="height:10px;">
  2. <div class="progress-bar" role="progressbar" [ngStyle]="{ 'width': uploader.progress + '%' }"></div>
  3. </div>
  4. <button type="button" class="btn btn-warning btn-s button_gray" (click)="uploader.cancelAll()" [disabled]="!uploader.isUploading">
  5. <span class="glyphicon glyphicon-ban-circle"></span> Cancel
  6. </button>
  7. <button type="button" class="btn btn-danger btn-s button_gray" (click)="uploader.clearQueue()" [disabled]="!uploader.queue.length">
  8. <span class="glyphicon glyphicon-trash"></span> Remove
  9. </button>
  10. <button type="button" class="btn btn-primary btn-s" (click)="uploader.authToken=authToken ;uploader.uploadAll()" [disabled]="!uploader.getNotUploadedItems().length">
  11. <span class="glyphicon glyphicon-upload"></span> Upload
  12. </button>
  13.  
  14. ngOnInit() {
  15. this.uploader.onAfterAddingFile = (file) => {
  16. file.withCredentials = false;
  17. if (this.target) this.target.value = '';
  18. };
  19. this.uploader.onErrorItem = (item, response, status, headers) => this.onErrorItem(item, response, status, headers);
  20. this.uploader.onSuccessItem = (item, response, status, headers) => this.onSuccessItem(item, response, status, headers);
  21. }
  22.  
  23. let data = JSON.parse(response); //success server response
  24. console.log(data)
  25. this.showSnackBar('Successfully Uploaded file.');
  26. this.router.navigate(['/result'])
  27. }
  28.  
  29. onErrorItem(item: FileItem, response: string, status: number, headers: ParsedResponseHeaders): any {
  30. let error;
  31. if (response != undefined && response.length > 0)
  32. JSON.parse(response); //error server response
  33. else
  34. error = response;
  35.  
  36. console.log(error)
  37. this.showSnackBar('Error on Upload the file.');
  38. }
Add Comment
Please, Sign In to add comment