mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-05 00:40:44 +00:00
Resolve loader error
This commit is contained in:
parent
ea1e280e66
commit
0ae25095a8
@ -1,14 +1,14 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject, Subject } from 'rxjs';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class UploadServiceService {
|
export class UploadServiceService {
|
||||||
|
|
||||||
private countSource = new BehaviorSubject(0);
|
private countSource = new Subject();
|
||||||
currentCount = this.countSource.asObservable();
|
currentCount = this.countSource.asObservable();
|
||||||
private cancelItem = new BehaviorSubject(false);
|
private cancelItem = new Subject();
|
||||||
currentCancelItemDetails = this.cancelItem.asObservable();
|
currentCancelItemDetails = this.cancelItem.asObservable();
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
@ -21,7 +21,7 @@ export class UploadingProcessbarComponent implements OnInit {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.subscription = this._US.currentCount.subscribe((count) => {
|
this.subscription = this._US.currentCount.subscribe((count:number) => {
|
||||||
this.uploadProgress = count;
|
this.uploadProgress = count;
|
||||||
if (this.uploadProgress === 100) {
|
if (this.uploadProgress === 100) {
|
||||||
this.dismiss()
|
this.dismiss()
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Location } from '@angular/common';
|
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 { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { UploadServiceService } from 'app/common/uploading-processbar/upload-service.service';
|
import { UploadServiceService } from 'app/common/uploading-processbar/upload-service.service';
|
||||||
import { UploadingProcessbarComponent } from 'app/common/uploading-processbar/uploading-processbar.component';
|
import { UploadingProcessbarComponent } from 'app/common/uploading-processbar/uploading-processbar.component';
|
||||||
import { FileItem, FileUploader, ParsedResponseHeaders } from 'ng2-file-upload';
|
import { FileItem, FileUploader, ParsedResponseHeaders } from 'ng2-file-upload';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { Compute } from '../../../../models/compute';
|
import { Compute } from '../../../../models/compute';
|
||||||
import { IosImage } from '../../../../models/images/ios-image';
|
import { IosImage } from '../../../../models/images/ios-image';
|
||||||
@ -23,7 +24,7 @@ import { ToasterService } from '../../../../services/toaster.service';
|
|||||||
templateUrl: './add-ios-template.component.html',
|
templateUrl: './add-ios-template.component.html',
|
||||||
styleUrls: ['./add-ios-template.component.scss', '../../preferences.component.scss'],
|
styleUrls: ['./add-ios-template.component.scss', '../../preferences.component.scss'],
|
||||||
})
|
})
|
||||||
export class AddIosTemplateComponent implements OnInit {
|
export class AddIosTemplateComponent implements OnInit, OnDestroy {
|
||||||
server: Server;
|
server: Server;
|
||||||
iosTemplate: IosTemplate;
|
iosTemplate: IosTemplate;
|
||||||
isEtherSwitchRouter: boolean = false;
|
isEtherSwitchRouter: boolean = false;
|
||||||
@ -51,6 +52,7 @@ export class AddIosTemplateComponent implements OnInit {
|
|||||||
uploader: FileUploader;
|
uploader: FileUploader;
|
||||||
isLocalComputerChosen: boolean = true;
|
isLocalComputerChosen: boolean = true;
|
||||||
uploadProgress:number = 0;
|
uploadProgress:number = 0;
|
||||||
|
subscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -103,7 +105,7 @@ export class AddIosTemplateComponent implements OnInit {
|
|||||||
this.uploadProgress = progress['progress'];
|
this.uploadProgress = progress['progress'];
|
||||||
this.uploadServiceService.processBarCount(this.uploadProgress)
|
this.uploadServiceService.processBarCount(this.uploadProgress)
|
||||||
};
|
};
|
||||||
this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
|
this.subscription = this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
|
||||||
if (isCancel) {
|
if (isCancel) {
|
||||||
this.cancelUploading()
|
this.cancelUploading()
|
||||||
}
|
}
|
||||||
@ -274,8 +276,11 @@ export class AddIosTemplateComponent implements OnInit {
|
|||||||
this.uploader.clearQueue();
|
this.uploader.clearQueue();
|
||||||
this.uploadServiceService.processBarCount(100)
|
this.uploadServiceService.processBarCount(100)
|
||||||
this.toasterService.warning('Image upload cancelled');
|
this.toasterService.warning('Image upload cancelled');
|
||||||
this.uploadServiceService.cancelFileUploading(false)
|
// this.uploadServiceService.cancelFileUploading(false)
|
||||||
window.location.reload()
|
// window.location.reload()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.subscription.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
@ -22,7 +22,7 @@ import { ToasterService } from '../../../../services/toaster.service';
|
|||||||
templateUrl: './add-iou-template.component.html',
|
templateUrl: './add-iou-template.component.html',
|
||||||
styleUrls: ['./add-iou-template.component.scss', '../../preferences.component.scss'],
|
styleUrls: ['./add-iou-template.component.scss', '../../preferences.component.scss'],
|
||||||
})
|
})
|
||||||
export class AddIouTemplateComponent implements OnInit {
|
export class AddIouTemplateComponent implements OnInit, OnDestroy {
|
||||||
server: Server;
|
server: Server;
|
||||||
iouTemplate: IouTemplate;
|
iouTemplate: IouTemplate;
|
||||||
isRemoteComputerChosen: boolean = false;
|
isRemoteComputerChosen: boolean = false;
|
||||||
@ -68,7 +68,6 @@ export class AddIouTemplateComponent implements OnInit {
|
|||||||
};
|
};
|
||||||
this.uploader.onErrorItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
|
this.uploader.onErrorItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
|
||||||
this.toasterService.error('An error occured: ' + response);
|
this.toasterService.error('An error occured: ' + response);
|
||||||
this.setDiskImage('existingImage')
|
|
||||||
};
|
};
|
||||||
this.uploader.onProgressItem = (progress: any) => {
|
this.uploader.onProgressItem = (progress: any) => {
|
||||||
this.uploadProgress = progress['progress'];
|
this.uploadProgress = progress['progress'];
|
||||||
@ -93,7 +92,7 @@ export class AddIouTemplateComponent implements OnInit {
|
|||||||
this.iouTemplate = iouTemplate;
|
this.iouTemplate = iouTemplate;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
|
this.subscription = this.uploadServiceService.currentCancelItemDetails.subscribe((isCancel) => {
|
||||||
if (isCancel) {
|
if (isCancel) {
|
||||||
this.cancelUploading()
|
this.cancelUploading()
|
||||||
}
|
}
|
||||||
@ -138,9 +137,8 @@ export class AddIouTemplateComponent implements OnInit {
|
|||||||
this.uploader.clearQueue();
|
this.uploader.clearQueue();
|
||||||
this.uploadServiceService.processBarCount(100)
|
this.uploadServiceService.processBarCount(100)
|
||||||
this.toasterService.warning('Image upload cancelled');
|
this.toasterService.warning('Image upload cancelled');
|
||||||
this.uploadServiceService.cancelFileUploading(false)
|
// this.uploadServiceService.cancelFileUploading(false)
|
||||||
window.location.reload()
|
// window.location.reload()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,4 +172,8 @@ export class AddIouTemplateComponent implements OnInit {
|
|||||||
this.toasterService.error(`Fill all required fields`);
|
this.toasterService.error(`Fill all required fields`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.subscription.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user