diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7a7f01be..2aa88f01 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -279,6 +279,7 @@ import { AddImageDialogComponent } from './components/image-manager/add-image-di import { DeleteAllImageFilesDialogComponent } from './components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component'; import { UploadingProcessbarComponent } from './common/uploading-processbar/uploading-processbar.component'; import { ExportPortableProjectComponent } from './components/export-portable-project/export-portable-project.component'; +import { NodesMenuConfirmationDialogComponent } from './components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component'; @NgModule({ declarations: [ @@ -474,6 +475,7 @@ import { ExportPortableProjectComponent } from './components/export-portable-pro DeleteAllImageFilesDialogComponent, UploadingProcessbarComponent, ExportPortableProjectComponent, + NodesMenuConfirmationDialogComponent, ], imports: [ BrowserModule, diff --git a/src/app/common/uploading-processbar/uploading-processbar.component.html b/src/app/common/uploading-processbar/uploading-processbar.component.html index 0c3d3742..4229bb76 100644 --- a/src/app/common/uploading-processbar/uploading-processbar.component.html +++ b/src/app/common/uploading-processbar/uploading-processbar.component.html @@ -1,4 +1,4 @@ -

Image Uploading please wait .... {{uploadProgress}}%

+

{{upload_file_type}} Uploading please wait .... {{uploadProgress}}%

diff --git a/src/app/common/uploading-processbar/uploading-processbar.component.ts b/src/app/common/uploading-processbar/uploading-processbar.component.ts index 061daa27..ef545a53 100644 --- a/src/app/common/uploading-processbar/uploading-processbar.component.ts +++ b/src/app/common/uploading-processbar/uploading-processbar.component.ts @@ -13,7 +13,7 @@ import { UploadServiceService } from './upload-service.service'; export class UploadingProcessbarComponent implements OnInit { uploadProgress: number = 0 subscription: Subscription; - + upload_file_type:string constructor( @Inject(MAT_SNACK_BAR_DATA) public data, private _snackRef: MatSnackBarRef, @@ -21,6 +21,8 @@ export class UploadingProcessbarComponent implements OnInit { ) { } ngOnInit() { + this.upload_file_type = this.data.upload_file_type + debugger this.subscription = this._US.currentCount.subscribe((count:number) => { this.uploadProgress = count; if (this.uploadProgress === 100 || this.uploadProgress == null ) { diff --git a/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts b/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts index 96f999d9..19318b04 100644 --- a/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts +++ b/src/app/components/preferences/dynamips/add-ios-template/add-ios-template.component.ts @@ -158,6 +158,7 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { this.uploader.uploadItem(itemToUpload); this.snackBar.openFromComponent(UploadingProcessbarComponent, { panelClass: 'uplaoding-file-snackabar', + data:{upload_file_type:'Image'} }); } @@ -275,7 +276,7 @@ export class AddIosTemplateComponent implements OnInit, OnDestroy { cancelUploading() { this.uploader.clearQueue(); this.uploadServiceService.processBarCount(null) - this.toasterService.warning('Image upload cancelled'); + this.toasterService.warning('File upload cancelled'); // this.uploadServiceService.cancelFileUploading(false) // window.location.reload() diff --git a/src/app/components/preferences/ios-on-unix/add-iou-template/add-iou-template.component.ts b/src/app/components/preferences/ios-on-unix/add-iou-template/add-iou-template.component.ts index 55cb18be..ac5fabd2 100644 --- a/src/app/components/preferences/ios-on-unix/add-iou-template/add-iou-template.component.ts +++ b/src/app/components/preferences/ios-on-unix/add-iou-template/add-iou-template.component.ts @@ -129,6 +129,7 @@ export class AddIouTemplateComponent implements OnInit, OnDestroy { this.uploader.uploadItem(itemToUpload); this.snackBar.openFromComponent(UploadingProcessbarComponent, { panelClass: 'uplaoding-file-snackabar', + data:{upload_file_type:'Image'} }); } @@ -136,7 +137,7 @@ export class AddIouTemplateComponent implements OnInit, OnDestroy { cancelUploading() { this.uploader.clearQueue(); this.uploadServiceService.processBarCount(100) - this.toasterService.warning('Image upload cancelled'); + this.toasterService.warning('File upload cancelled'); // this.uploadServiceService.cancelFileUploading(false) // window.location.reload() } diff --git a/src/app/components/preferences/qemu/add-qemu-vm-template/add-qemu-vm-template.component.ts b/src/app/components/preferences/qemu/add-qemu-vm-template/add-qemu-vm-template.component.ts index 11d1b010..105558c9 100644 --- a/src/app/components/preferences/qemu/add-qemu-vm-template/add-qemu-vm-template.component.ts +++ b/src/app/components/preferences/qemu/add-qemu-vm-template/add-qemu-vm-template.component.ts @@ -157,7 +157,7 @@ export class AddQemuVmTemplateComponent implements OnInit { if ((itemToUpload as any).options) (itemToUpload as any).options.disableMultipart = true; ((itemToUpload as any).options.headers =[{name:'Authorization',value:'Bearer ' + this.server.authToken}]) this.uploader.uploadItem(itemToUpload); - this.snackBar.openFromComponent(UploadingProcessbarComponent,{panelClass: 'uplaoding-file-snackabar',}); + this.snackBar.openFromComponent(UploadingProcessbarComponent,{panelClass: 'uplaoding-file-snackabar', data:{upload_file_type:'Image'}}); } cancelUploading() { diff --git a/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts b/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts index 59a77d54..e5405da1 100644 --- a/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts +++ b/src/app/components/project-map/new-template-dialog/new-template-dialog.component.ts @@ -429,7 +429,7 @@ export class NewTemplateDialogComponent implements OnInit { cancelUploading() { this.uploaderImage.clearQueue(); this.uploadServiceService.processBarCount(null) - this.toasterService.warning('Image upload cancelled'); + this.toasterService.warning('File upload cancelled'); this.uploadServiceService.cancelFileUploading(false) } @@ -728,6 +728,7 @@ export class NewTemplateDialogComponent implements OnInit { openSnackBar() { this.snackBar.openFromComponent(UploadingProcessbarComponent, { panelClass: 'uplaoding-file-snackabar', + data:{upload_file_type:'Image'} }); } diff --git a/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.html b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.html new file mode 100644 index 00000000..dae4f3f1 --- /dev/null +++ b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.html @@ -0,0 +1,13 @@ +
+
+
Confirm {{ confirmActionData.actionType}} All
+
+
+ + +

Are you sure you want to {{confirmActionData.actionType}} all devices?

+
+ + + + diff --git a/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.scss b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.scss new file mode 100644 index 00000000..c74494a9 --- /dev/null +++ b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.scss @@ -0,0 +1,19 @@ +.close-btn{ + height: 30px; + width: 30px; + margin-left: 10px; + margin-bottom:10px +} +.close-icon{ + font-size: 15px; +} +.text-padding{ + padding: 15px 0 0 0; + +} +.mat-dialog-actions { + min-height: 31px; +} +.heading-txt{ + text-transform: capitalize; +} \ No newline at end of file diff --git a/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.spec.ts b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.spec.ts new file mode 100644 index 00000000..ae514afe --- /dev/null +++ b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.spec.ts @@ -0,0 +1,44 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { MatIconModule } from '@angular/material/icon'; +import { MatMenuModule } from '@angular/material/menu'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { MatToolbarModule } from '@angular/material/toolbar'; + +import { NodesMenuConfirmationDialogComponent } from './nodes-menu-confirmation-dialog.component'; + +describe('NodesMenuConfirmationDialogComponent', () => { + let component: NodesMenuConfirmationDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports:[ + MatIconModule, + MatToolbarModule, + MatMenuModule, + MatCheckboxModule, + MatDialogModule, + MatSnackBarModule, + ], + providers: [ + + { provide: MAT_DIALOG_DATA, useValue: {} }, + { provide: MatDialogRef, useValue: {} }, + ], + declarations: [ NodesMenuConfirmationDialogComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(NodesMenuConfirmationDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.ts b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.ts new file mode 100644 index 00000000..3c912534 --- /dev/null +++ b/src/app/components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component.ts @@ -0,0 +1,27 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; + +@Component({ + selector: 'app-nodes-menu-confirmation-dialog', + templateUrl: './nodes-menu-confirmation-dialog.component.html', + styleUrls: ['./nodes-menu-confirmation-dialog.component.scss'], +}) +export class NodesMenuConfirmationDialogComponent implements OnInit { + confirmActionData = { + actionType: 'start', + isAction:false + }; + constructor( + @Inject(MAT_DIALOG_DATA) public data: any, + public dialogRef: MatDialogRef + ) {} + + ngOnInit(): void { + this.confirmActionData.actionType = this.data; + } + + confirmAction() { + this.confirmActionData.isAction = true + this.dialogRef.close(this.confirmActionData); + } +} diff --git a/src/app/components/project-map/nodes-menu/nodes-menu.component.html b/src/app/components/project-map/nodes-menu/nodes-menu.component.html index b495ad3c..7414dc46 100644 --- a/src/app/components/project-map/nodes-menu/nodes-menu.component.html +++ b/src/app/components/project-map/nodes-menu/nodes-menu.component.html @@ -12,7 +12,7 @@ matTooltip="Start/Resume all nodes" matTooltipClass="custom-tooltip" mat-icon-button - (click)="startNodes()" + (click)="confirmControlsActions('start')" class="menu-button" > play_arrow @@ -21,7 +21,7 @@ matTooltip="Suspend all nodes" matTooltipClass="custom-tooltip" mat-icon-button - (click)="suspendNodes()" + (click)="confirmControlsActions('suspend')" class="menu-button" > pause @@ -30,7 +30,7 @@ matTooltip="Stop all nodes" matTooltipClass="custom-tooltip" mat-icon-button - (click)="stopNodes()" + (click)="confirmControlsActions('stop')" class="menu-button" > stop @@ -39,9 +39,19 @@ matTooltip="Reload all nodes" matTooltipClass="custom-tooltip" mat-icon-button - (click)="reloadNodes()" + (click)="confirmControlsActions('reload')" class="menu-button" > replay + +
diff --git a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts index 839ccbbe..f19dda53 100644 --- a/src/app/components/project-map/nodes-menu/nodes-menu.component.ts +++ b/src/app/components/project-map/nodes-menu/nodes-menu.component.ts @@ -1,14 +1,16 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { MapSettingsService } from '../../../services/mapsettings.service'; +import { MatDialog } from '@angular/material/dialog'; import { ElectronService } from 'ngx-electron'; import { NodesDataSource } from '../../../cartography/datasources/nodes-datasource'; import { Project } from '../../../models/project'; import { Server } from '../../../models/server'; +import { MapSettingsService } from '../../../services/mapsettings.service'; import { NodeService } from '../../../services/node.service'; +import { NodeConsoleService } from '../../../services/nodeConsole.service'; import { ServerService } from '../../../services/server.service'; import { SettingsService } from '../../../services/settings.service'; import { ToasterService } from '../../../services/toaster.service'; -import { NodeConsoleService } from '../../../services/nodeConsole.service'; +import { NodesMenuConfirmationDialogComponent } from './nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component'; @Component({ selector: 'app-nodes-menu', @@ -28,7 +30,8 @@ export class NodesMenuComponent { private serverService: ServerService, private settingsService: SettingsService, private mapSettingsService: MapSettingsService, - private electronService: ElectronService + private electronService: ElectronService, + private dialog: MatDialog ) {} async startConsoleForAllNodes() { @@ -83,4 +86,34 @@ export class NodesMenuComponent { this.toasterService.success('All nodes successfully reloaded'); }); } + + resetNodes() { + this.nodeService.resetAllNodes(this.server, this.project).subscribe(() => { + this.toasterService.success('Successfully reset all console connections'); + }); + } + + public confirmControlsActions(type) { + const dialogRef = this.dialog.open(NodesMenuConfirmationDialogComponent, { + width: '500px', + maxHeight: '200px', + autoFocus: false, + disableClose: true, + data: type, + }); + + dialogRef.afterClosed().subscribe((confirmAction_result) => { + if (confirmAction_result.isAction && confirmAction_result.actionType == 'start') { + this.startNodes(); + } else if (confirmAction_result.isAction && confirmAction_result.actionType == 'stop') { + this.stopNodes(); + } else if (confirmAction_result.isAction && confirmAction_result.actionType == 'reload') { + this.reloadNodes(); + } else if (confirmAction_result.isAction && confirmAction_result.actionType == 'suspend') { + this.suspendNodes(); + } else { + this.resetNodes() + } + }); + } } diff --git a/src/app/components/project-map/project-map.component.html b/src/app/components/project-map/project-map.component.html index fa9a4852..7ece4e04 100644 --- a/src/app/components/project-map/project-map.component.html +++ b/src/app/components/project-map/project-map.component.html @@ -139,11 +139,11 @@ -
+
-
+ +
{{ resultMessage }}
-
+