Resolve loader error

This commit is contained in:
Rajnikant 2022-05-24 19:54:26 +05:30
parent ea1e280e66
commit 0ae25095a8
4 changed files with 23 additions and 16 deletions

View File

@ -1,14 +1,14 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class UploadServiceService {
private countSource = new BehaviorSubject(0);
private countSource = new Subject();
currentCount = this.countSource.asObservable();
private cancelItem = new BehaviorSubject(false);
private cancelItem = new Subject();
currentCancelItemDetails = this.cancelItem.asObservable();
constructor() { }

View File

@ -21,7 +21,7 @@ export class UploadingProcessbarComponent implements OnInit {
) { }
ngOnInit() {
this.subscription = this._US.currentCount.subscribe((count) => {
this.subscription = this._US.currentCount.subscribe((count:number) => {
this.uploadProgress = count;
if (this.uploadProgress === 100) {
this.dismiss()

View File

@ -1,11 +1,12 @@
import { Location } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router';
import { UploadServiceService } from 'app/common/uploading-processbar/upload-service.service';
import { UploadingProcessbarComponent } from 'app/common/uploading-processbar/uploading-processbar.component';
import { FileItem, FileUploader, ParsedResponseHeaders } from 'ng2-file-upload';
import { Subscription } from 'rxjs';
import { v4 as uuid } from 'uuid';
import { Compute } from '../../../../models/compute';
import { IosImage } from '../../../../models/images/ios-image';
@ -23,7 +24,7 @@ import { ToasterService } from '../../../../services/toaster.service';
templateUrl: './add-ios-template.component.html',
styleUrls: ['./add-ios-template.component.scss', '../../preferences.component.scss'],
})
export class AddIosTemplateComponent implements OnInit {
export class AddIosTemplateComponent implements OnInit, OnDestroy {
server: Server;
iosTemplate: IosTemplate;
isEtherSwitchRouter: boolean = false;
@ -51,6 +52,7 @@ export class AddIosTemplateComponent implements OnInit {
uploader: FileUploader;
isLocalComputerChosen: boolean = true;
uploadProgress:number = 0;
subscription: Subscription;
constructor(
private route: ActivatedRoute,
@ -103,7 +105,7 @@ export class AddIosTemplateComponent implements OnInit {
this.uploadProgress = progress['progress'];
this.uploadServiceService.processBarCount(this.uploadProgress)
};
this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
this.subscription = this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
if (isCancel) {
this.cancelUploading()
}
@ -274,8 +276,11 @@ export class AddIosTemplateComponent implements OnInit {
this.uploader.clearQueue();
this.uploadServiceService.processBarCount(100)
this.toasterService.warning('Image upload cancelled');
this.uploadServiceService.cancelFileUploading(false)
window.location.reload()
// this.uploadServiceService.cancelFileUploading(false)
// window.location.reload()
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
}

View File

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router';
@ -22,7 +22,7 @@ import { ToasterService } from '../../../../services/toaster.service';
templateUrl: './add-iou-template.component.html',
styleUrls: ['./add-iou-template.component.scss', '../../preferences.component.scss'],
})
export class AddIouTemplateComponent implements OnInit {
export class AddIouTemplateComponent implements OnInit, OnDestroy {
server: Server;
iouTemplate: IouTemplate;
isRemoteComputerChosen: boolean = false;
@ -68,7 +68,6 @@ export class AddIouTemplateComponent implements OnInit {
};
this.uploader.onErrorItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
this.toasterService.error('An error occured: ' + response);
this.setDiskImage('existingImage')
};
this.uploader.onProgressItem = (progress: any) => {
this.uploadProgress = progress['progress'];
@ -93,7 +92,7 @@ export class AddIouTemplateComponent implements OnInit {
this.iouTemplate = iouTemplate;
});
});
this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
this.subscription = this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
if (isCancel) {
this.cancelUploading()
}
@ -138,9 +137,8 @@ export class AddIouTemplateComponent implements OnInit {
this.uploader.clearQueue();
this.uploadServiceService.processBarCount(100)
this.toasterService.warning('Image upload cancelled');
this.uploadServiceService.cancelFileUploading(false)
window.location.reload()
// this.uploadServiceService.cancelFileUploading(false)
// window.location.reload()
}
@ -174,4 +172,8 @@ export class AddIouTemplateComponent implements OnInit {
this.toasterService.error(`Fill all required fields`);
}
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
}