mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-17 06:18:09 +00:00
Apply code style
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<button mat-menu-item (click)="editStyle()">
|
||||
<mat-icon>style</mat-icon>
|
||||
<span>Edit style</span>
|
||||
<mat-icon>style</mat-icon>
|
||||
<span>Edit style</span>
|
||||
</button>
|
||||
|
@ -1,33 +1,30 @@
|
||||
import { Component, OnInit, Input } from "@angular/core";
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Drawing } from '../../../../../cartography/models/drawing';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { Project } from '../../../../../models/project';
|
||||
import { StyleEditorDialogComponent } from '../../../drawings-editors/style-editor/style-editor.component';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-style-action',
|
||||
templateUrl: './edit-style-action.component.html'
|
||||
selector: 'app-edit-style-action',
|
||||
templateUrl: './edit-style-action.component.html'
|
||||
})
|
||||
export class EditStyleActionComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
@Input() project: Project;
|
||||
@Input() drawing: Drawing;
|
||||
@Input() server: Server;
|
||||
@Input() project: Project;
|
||||
@Input() drawing: Drawing;
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog
|
||||
) {}
|
||||
constructor(private dialog: MatDialog) {}
|
||||
|
||||
ngOnInit() {}
|
||||
ngOnInit() {}
|
||||
|
||||
editStyle() {
|
||||
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
||||
width: '450px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
editStyle() {
|
||||
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
||||
width: '450px'
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<button mat-menu-item (click)="editText()">
|
||||
<mat-icon>text_format</mat-icon>
|
||||
<span>Edit text</span>
|
||||
<mat-icon>text_format</mat-icon>
|
||||
<span>Edit text</span>
|
||||
</button>
|
||||
|
@ -5,29 +5,26 @@ import { Drawing } from '../../../../../cartography/models/drawing';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { TextEditorDialogComponent } from '../../../drawings-editors/text-editor/text-editor.component';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-text-action',
|
||||
templateUrl: './edit-text-action.component.html'
|
||||
selector: 'app-edit-text-action',
|
||||
templateUrl: './edit-text-action.component.html'
|
||||
})
|
||||
export class EditTextActionComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
@Input() project: Project;
|
||||
@Input() drawing: Drawing;
|
||||
@Input() server: Server;
|
||||
@Input() project: Project;
|
||||
@Input() drawing: Drawing;
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog
|
||||
) {}
|
||||
constructor(private dialog: MatDialog) {}
|
||||
|
||||
ngOnInit() {}
|
||||
ngOnInit() {}
|
||||
|
||||
editText() {
|
||||
const dialogRef = this.dialog.open(TextEditorDialogComponent, {
|
||||
width: '450px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
editText() {
|
||||
const dialogRef = this.dialog.open(TextEditorDialogComponent, {
|
||||
width: '450px'
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,8 @@ describe('MoveLayerDownActionComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MoveLayerDownActionComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [MoveLayerDownActionComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
// beforeEach(() => {
|
||||
|
@ -29,17 +29,13 @@ export class MoveLayerDownActionComponent implements OnInit {
|
||||
if (this.node) {
|
||||
this.node.z--;
|
||||
this.nodesDataSource.update(this.node);
|
||||
|
||||
this.nodeService
|
||||
.update(this.server, this.node)
|
||||
.subscribe((node: Node) => {});
|
||||
} else if(this.drawing) {
|
||||
|
||||
this.nodeService.update(this.server, this.node).subscribe((node: Node) => {});
|
||||
} else if (this.drawing) {
|
||||
this.drawing.z--;
|
||||
this.drawingsDataSource.update(this.drawing);
|
||||
|
||||
this.drawingService
|
||||
.update(this.server, this.drawing)
|
||||
.subscribe((drawing: Drawing) => {});
|
||||
this.drawingService.update(this.server, this.drawing).subscribe((drawing: Drawing) => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,8 @@ describe('MoveLayerUpActionComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MoveLayerUpActionComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [MoveLayerUpActionComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
// beforeEach(() => {
|
||||
|
@ -21,7 +21,7 @@ export class MoveLayerUpActionComponent implements OnInit {
|
||||
private drawingsDataSource: DrawingsDataSource,
|
||||
private nodeService: NodeService,
|
||||
private drawingService: DrawingService
|
||||
) { }
|
||||
) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
@ -29,17 +29,13 @@ export class MoveLayerUpActionComponent implements OnInit {
|
||||
if (this.node) {
|
||||
this.node.z++;
|
||||
this.nodesDataSource.update(this.node);
|
||||
|
||||
this.nodeService
|
||||
.update(this.server, this.node)
|
||||
.subscribe((node: Node) => {});
|
||||
} else if(this.drawing) {
|
||||
|
||||
this.nodeService.update(this.server, this.node).subscribe((node: Node) => {});
|
||||
} else if (this.drawing) {
|
||||
this.drawing.z++;
|
||||
this.drawingsDataSource.update(this.drawing);
|
||||
|
||||
this.drawingService
|
||||
.update(this.server, this.drawing)
|
||||
.subscribe((drawing: Drawing) => {});
|
||||
this.drawingService.update(this.server, this.drawing).subscribe((drawing: Drawing) => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,8 @@ describe('StartNodeActionComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ StartNodeActionComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [StartNodeActionComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -1,27 +1,21 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Server} from "../../../../../models/server";
|
||||
import {NodeService} from "../../../../../services/node.service";
|
||||
import {Node} from "../../../../../cartography/models/node";
|
||||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
|
||||
@Component({
|
||||
selector: 'app-start-node-action',
|
||||
templateUrl: './start-node-action.component.html',
|
||||
templateUrl: './start-node-action.component.html'
|
||||
})
|
||||
export class StartNodeActionComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
@Input() node: Node;
|
||||
|
||||
constructor(private nodeService: NodeService) { }
|
||||
constructor(private nodeService: NodeService) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
startNode() {
|
||||
this.nodeService
|
||||
.start(this.server, this.node)
|
||||
.subscribe((n: Node) => {
|
||||
|
||||
});
|
||||
this.nodeService.start(this.server, this.node).subscribe((n: Node) => {});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,9 +8,8 @@ describe('StopNodeActionComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ StopNodeActionComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [StopNodeActionComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -1,8 +1,7 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Server} from "../../../../../models/server";
|
||||
import {NodeService} from "../../../../../services/node.service";
|
||||
import {Node} from "../../../../../cartography/models/node";
|
||||
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
|
||||
@Component({
|
||||
selector: 'app-stop-node-action',
|
||||
@ -12,16 +11,11 @@ export class StopNodeActionComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
@Input() node: Node;
|
||||
|
||||
constructor(private nodeService: NodeService) { }
|
||||
constructor(private nodeService: NodeService) {}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
ngOnInit() {}
|
||||
|
||||
stopNode() {
|
||||
this.nodeService
|
||||
.stop(this.server, this.node)
|
||||
.subscribe((n: Node) => {
|
||||
|
||||
});
|
||||
this.nodeService.stop(this.server, this.node).subscribe((n: Node) => {});
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,29 @@
|
||||
<mat-menu #contextMenu="matMenu" class="context-menu-items">
|
||||
<app-start-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-start-node-action>
|
||||
<app-stop-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-stop-node-action>
|
||||
<app-edit-style-action *ngIf="hasDrawingCapabilities && !isTextElement" [server]="server" [project]="project" [drawing]="drawing"></app-edit-style-action>
|
||||
<app-edit-text-action *ngIf="hasDrawingCapabilities && isTextElement" [server]="server" [project]="project" [drawing]="drawing"></app-edit-text-action>
|
||||
<app-move-layer-up-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-up-action>
|
||||
<app-move-layer-down-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-down-action>
|
||||
<app-edit-style-action
|
||||
*ngIf="hasDrawingCapabilities && !isTextElement"
|
||||
[server]="server"
|
||||
[project]="project"
|
||||
[drawing]="drawing"
|
||||
></app-edit-style-action>
|
||||
<app-edit-text-action
|
||||
*ngIf="hasDrawingCapabilities && isTextElement"
|
||||
[server]="server"
|
||||
[project]="project"
|
||||
[drawing]="drawing"
|
||||
></app-edit-text-action>
|
||||
<app-move-layer-up-action
|
||||
*ngIf="!projectService.isReadOnly(project)"
|
||||
[server]="server"
|
||||
[node]="node"
|
||||
[drawing]="drawing"
|
||||
></app-move-layer-up-action>
|
||||
<app-move-layer-down-action
|
||||
*ngIf="!projectService.isReadOnly(project)"
|
||||
[server]="server"
|
||||
[node]="node"
|
||||
[drawing]="drawing"
|
||||
></app-move-layer-down-action>
|
||||
</mat-menu>
|
||||
</div>
|
||||
|
@ -15,18 +15,11 @@ describe('ContextMenuComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
MatMenuModule,
|
||||
BrowserModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: ChangeDetectorRef },
|
||||
{ provide: ProjectService, useClass: MockedProjectService }
|
||||
],
|
||||
declarations: [ ContextMenuComponent ],
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
})
|
||||
.compileComponents();
|
||||
imports: [MatMenuModule, BrowserModule],
|
||||
providers: [{ provide: ChangeDetectorRef }, { provide: ProjectService, useClass: MockedProjectService }],
|
||||
declarations: [ContextMenuComponent],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@ -40,8 +33,8 @@ describe('ContextMenuComponent', () => {
|
||||
});
|
||||
|
||||
it('should reset capabilities while opening menu for node', () => {
|
||||
component.contextMenu = { openMenu(){} } as MatMenuTrigger;
|
||||
var spy = spyOn<any>(component, "resetCapabilities");
|
||||
component.contextMenu = { openMenu() {} } as MatMenuTrigger;
|
||||
var spy = spyOn<any>(component, 'resetCapabilities');
|
||||
|
||||
component.openMenuForNode(null, 0, 0);
|
||||
|
||||
@ -49,10 +42,10 @@ describe('ContextMenuComponent', () => {
|
||||
});
|
||||
|
||||
it('should reset capabilities while opening menu for drawing', () => {
|
||||
component.contextMenu = { openMenu(){} } as MatMenuTrigger;
|
||||
component.contextMenu = { openMenu() {} } as MatMenuTrigger;
|
||||
let drawing = {} as Drawing;
|
||||
drawing.element = new RectElement();
|
||||
var spy = spyOn<any>(component, "resetCapabilities");
|
||||
var spy = spyOn<any>(component, 'resetCapabilities');
|
||||
spyOn(component, 'setPosition').and.callFake(() => {});
|
||||
component.openMenuForDrawing(drawing, 0, 0);
|
||||
|
||||
@ -60,10 +53,10 @@ describe('ContextMenuComponent', () => {
|
||||
});
|
||||
|
||||
it('should set correct flag while drawing is text element', () => {
|
||||
component.contextMenu = { openMenu(){} } as MatMenuTrigger;
|
||||
component.contextMenu = { openMenu() {} } as MatMenuTrigger;
|
||||
let drawing = {} as Drawing;
|
||||
drawing.element = new TextElement();
|
||||
var spy = spyOn<any>(component, "resetCapabilities");
|
||||
var spy = spyOn<any>(component, 'resetCapabilities');
|
||||
spyOn(component, 'setPosition').and.callFake(() => {});
|
||||
component.openMenuForDrawing(drawing, 0, 0);
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
import { ChangeDetectorRef, Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatMenuTrigger } from "@angular/material";
|
||||
import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { Node } from "../../../cartography/models/node";
|
||||
import { Server } from "../../../models/server";
|
||||
import { Project } from "../../../models/project";
|
||||
import { ProjectService } from "../../../services/project.service";
|
||||
import { MatMenuTrigger } from '@angular/material';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { Node } from '../../../cartography/models/node';
|
||||
import { Server } from '../../../models/server';
|
||||
import { Project } from '../../../models/project';
|
||||
import { ProjectService } from '../../../services/project.service';
|
||||
import { Drawing } from '../../../cartography/models/drawing';
|
||||
import { TextElement } from '../../../cartography/models/drawings/text-element';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-context-menu',
|
||||
templateUrl: './context-menu.component.html',
|
||||
@ -31,15 +30,16 @@ export class ContextMenuComponent implements OnInit {
|
||||
constructor(
|
||||
private sanitizer: DomSanitizer,
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
protected projectService: ProjectService) {}
|
||||
protected projectService: ProjectService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.setPosition(0, 0);
|
||||
}
|
||||
|
||||
public setPosition(top: number, left: number) {
|
||||
this.topPosition = this.sanitizer.bypassSecurityTrustStyle(top + "px");
|
||||
this.leftPosition = this.sanitizer.bypassSecurityTrustStyle(left + "px");
|
||||
this.topPosition = this.sanitizer.bypassSecurityTrustStyle(top + 'px');
|
||||
this.leftPosition = this.sanitizer.bypassSecurityTrustStyle(left + 'px');
|
||||
this.changeDetector.detectChanges();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user