mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-06 09:11:36 +00:00
Merge pull request #1345 from GNS3/enhancement/1342
I have added node menu controls confirmation action dialog in
This commit is contained in:
commit
cb11e8b1a2
@ -278,6 +278,7 @@ import { ImageManagerComponent } from './components/image-manager/image-manager.
|
|||||||
import { AddImageDialogComponent } from './components/image-manager/add-image-dialog/add-image-dialog.component';
|
import { AddImageDialogComponent } from './components/image-manager/add-image-dialog/add-image-dialog.component';
|
||||||
import { DeleteAllImageFilesDialogComponent } from './components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component';
|
import { DeleteAllImageFilesDialogComponent } from './components/image-manager/deleteallfiles-dialog/deleteallfiles-dialog.component';
|
||||||
import { UploadingProcessbarComponent } from './common/uploading-processbar/uploading-processbar.component';
|
import { UploadingProcessbarComponent } from './common/uploading-processbar/uploading-processbar.component';
|
||||||
|
import { NodesMenuConfirmationDialogComponent } from './components/project-map/nodes-menu/nodes-menu-confirmation-dialog/nodes-menu-confirmation-dialog.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -472,6 +473,7 @@ import { UploadingProcessbarComponent } from './common/uploading-processbar/uplo
|
|||||||
AddImageDialogComponent,
|
AddImageDialogComponent,
|
||||||
DeleteAllImageFilesDialogComponent,
|
DeleteAllImageFilesDialogComponent,
|
||||||
UploadingProcessbarComponent,
|
UploadingProcessbarComponent,
|
||||||
|
NodesMenuConfirmationDialogComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h5 class="heading-txt">Confirm {{ confirmActionData.actionType}} All</h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<mat-divider></mat-divider>
|
||||||
|
<mat-dialog-content>
|
||||||
|
<p class="text-padding">Are you sure you want to {{confirmActionData.actionType}} all devices?</p>
|
||||||
|
</mat-dialog-content>
|
||||||
|
<mat-dialog-actions align="end">
|
||||||
|
<button mat-button mat-dialog-close>No</button>
|
||||||
|
<button mat-button (click)="confirmAction()" cdkFocusInitial>Yes</button>
|
||||||
|
</mat-dialog-actions>
|
@ -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;
|
||||||
|
}
|
@ -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<NodesMenuConfirmationDialogComponent>;
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
@ -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<NodesMenuConfirmationDialogComponent>
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.confirmActionData.actionType = this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmAction() {
|
||||||
|
this.confirmActionData.isAction = true
|
||||||
|
this.dialogRef.close(this.confirmActionData);
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@
|
|||||||
matTooltip="Start/Resume all nodes"
|
matTooltip="Start/Resume all nodes"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(click)="startNodes()"
|
(click)="confirmControlsActions('start')"
|
||||||
class="menu-button"
|
class="menu-button"
|
||||||
>
|
>
|
||||||
<mat-icon>play_arrow</mat-icon>
|
<mat-icon>play_arrow</mat-icon>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
matTooltip="Suspend all nodes"
|
matTooltip="Suspend all nodes"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(click)="suspendNodes()"
|
(click)="confirmControlsActions('suspend')"
|
||||||
class="menu-button"
|
class="menu-button"
|
||||||
>
|
>
|
||||||
<mat-icon>pause</mat-icon>
|
<mat-icon>pause</mat-icon>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
matTooltip="Stop all nodes"
|
matTooltip="Stop all nodes"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(click)="stopNodes()"
|
(click)="confirmControlsActions('stop')"
|
||||||
class="menu-button"
|
class="menu-button"
|
||||||
>
|
>
|
||||||
<mat-icon>stop</mat-icon>
|
<mat-icon>stop</mat-icon>
|
||||||
@ -39,9 +39,19 @@
|
|||||||
matTooltip="Reload all nodes"
|
matTooltip="Reload all nodes"
|
||||||
matTooltipClass="custom-tooltip"
|
matTooltipClass="custom-tooltip"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(click)="reloadNodes()"
|
(click)="confirmControlsActions('reload')"
|
||||||
class="menu-button"
|
class="menu-button"
|
||||||
>
|
>
|
||||||
<mat-icon>replay</mat-icon>
|
<mat-icon>replay</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
matTooltip="Reset all console connections"
|
||||||
|
matTooltipClass="custom-tooltip"
|
||||||
|
mat-icon-button
|
||||||
|
(click)="confirmControlsActions('reset')"
|
||||||
|
class="menu-button"
|
||||||
|
>
|
||||||
|
<mat-icon>compare_arrows</mat-icon>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
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 { ElectronService } from 'ngx-electron';
|
||||||
import { NodesDataSource } from '../../../cartography/datasources/nodes-datasource';
|
import { NodesDataSource } from '../../../cartography/datasources/nodes-datasource';
|
||||||
import { Project } from '../../../models/project';
|
import { Project } from '../../../models/project';
|
||||||
import { Server } from '../../../models/server';
|
import { Server } from '../../../models/server';
|
||||||
|
import { MapSettingsService } from '../../../services/mapsettings.service';
|
||||||
import { NodeService } from '../../../services/node.service';
|
import { NodeService } from '../../../services/node.service';
|
||||||
|
import { NodeConsoleService } from '../../../services/nodeConsole.service';
|
||||||
import { ServerService } from '../../../services/server.service';
|
import { ServerService } from '../../../services/server.service';
|
||||||
import { SettingsService } from '../../../services/settings.service';
|
import { SettingsService } from '../../../services/settings.service';
|
||||||
import { ToasterService } from '../../../services/toaster.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({
|
@Component({
|
||||||
selector: 'app-nodes-menu',
|
selector: 'app-nodes-menu',
|
||||||
@ -28,7 +30,8 @@ export class NodesMenuComponent {
|
|||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService,
|
||||||
private mapSettingsService: MapSettingsService,
|
private mapSettingsService: MapSettingsService,
|
||||||
private electronService: ElectronService
|
private electronService: ElectronService,
|
||||||
|
private dialog: MatDialog
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async startConsoleForAllNodes() {
|
async startConsoleForAllNodes() {
|
||||||
@ -83,4 +86,34 @@ export class NodesMenuComponent {
|
|||||||
this.toasterService.success('All nodes successfully reloaded');
|
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()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,9 @@ export class NodeService {
|
|||||||
reloadAll(server: Server, project: Project) {
|
reloadAll(server: Server, project: Project) {
|
||||||
return this.httpServer.post(server, `/projects/${project.project_id}/nodes/reload`, {});
|
return this.httpServer.post(server, `/projects/${project.project_id}/nodes/reload`, {});
|
||||||
}
|
}
|
||||||
|
resetAllNodes(server: Server, project: Project) {
|
||||||
|
return this.httpServer.post(server, `/projects/${project.project_id}/nodes/console/reset`, {});
|
||||||
|
}
|
||||||
|
|
||||||
createFromTemplate(
|
createFromTemplate(
|
||||||
server: Server,
|
server: Server,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user