mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-30 17:56:55 +00:00
Code cleaned up
This commit is contained in:
parent
92b9163bf3
commit
0c788b9898
@ -33,6 +33,7 @@ import { ToolsService } from '../../../services/tools.service';
|
|||||||
import { TextEditorComponent } from '../text-editor/text-editor.component';
|
import { TextEditorComponent } from '../text-editor/text-editor.component';
|
||||||
import { MapScaleService } from '../../../services/mapScale.service';
|
import { MapScaleService } from '../../../services/mapScale.service';
|
||||||
import { Project } from '../../../models/project';
|
import { Project } from '../../../models/project';
|
||||||
|
import { MapSettingsService } from '../../../services/mapsettings.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-d3-map',
|
selector: 'app-d3-map',
|
||||||
@ -75,7 +76,8 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
protected movingToolWidget: MovingTool,
|
protected movingToolWidget: MovingTool,
|
||||||
public graphLayout: GraphLayout,
|
public graphLayout: GraphLayout,
|
||||||
private toolsService: ToolsService,
|
private toolsService: ToolsService,
|
||||||
private mapScaleService: MapScaleService
|
private mapScaleService: MapScaleService,
|
||||||
|
private mapSettingsService: MapSettingsService
|
||||||
) {
|
) {
|
||||||
this.parentNativeElement = element.nativeElement;
|
this.parentNativeElement = element.nativeElement;
|
||||||
}
|
}
|
||||||
@ -193,8 +195,7 @@ export class D3MapComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
this.graphLayout.draw(this.svg, this.context);
|
this.graphLayout.draw(this.svg, this.context);
|
||||||
this.textEditor.activateTextEditingForDrawings();
|
this.textEditor.activateTextEditingForDrawings();
|
||||||
this.textEditor.activateTextEditingForNodeLabels();
|
this.textEditor.activateTextEditingForNodeLabels();
|
||||||
|
this.mapSettingsService.mapRenderedEmitter.emit(true);
|
||||||
console.log("DONE!!!")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:resize', ['$event'])
|
@HostListener('window:resize', ['$event'])
|
||||||
|
@ -95,6 +95,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
protected settings: Settings;
|
protected settings: Settings;
|
||||||
private inReadOnlyMode = false;
|
private inReadOnlyMode = false;
|
||||||
|
private scrollX: number = 0;
|
||||||
|
private scrollY: number = 0;
|
||||||
|
private scrollEnabled: boolean = false;
|
||||||
|
|
||||||
@ViewChild(ContextMenuComponent, {static: false}) contextMenu: ContextMenuComponent;
|
@ViewChild(ContextMenuComponent, {static: false}) contextMenu: ContextMenuComponent;
|
||||||
@ViewChild(D3MapComponent, {static: false}) mapChild: D3MapComponent;
|
@ViewChild(D3MapComponent, {static: false}) mapChild: D3MapComponent;
|
||||||
@ -200,6 +203,12 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.subscriptions.push(routeSub);
|
this.subscriptions.push(routeSub);
|
||||||
|
|
||||||
|
this.subscriptions.push(
|
||||||
|
this.mapSettingsService.mapRenderedEmitter.subscribe((value: boolean) => {
|
||||||
|
if (this.scrollEnabled) this.centerCanvas();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
this.subscriptions.push(
|
this.subscriptions.push(
|
||||||
this.drawingsDataSource.changes.subscribe((drawings: Drawing[]) => {
|
this.drawingsDataSource.changes.subscribe((drawings: Drawing[]) => {
|
||||||
this.drawings = drawings;
|
this.drawings = drawings;
|
||||||
@ -522,21 +531,23 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.mapScaleService.setScale(scale);
|
this.mapScaleService.setScale(scale);
|
||||||
this.project.scene_width = this.project.scene_width * scale;
|
this.project.scene_width = this.project.scene_width * scale;
|
||||||
this.project.scene_height = this.project.scene_height * scale;
|
this.project.scene_height = this.project.scene_height * scale;
|
||||||
let scrollX: number = 0;
|
|
||||||
let scrollY: number = 0;
|
|
||||||
if (heightToSceneHeightRatio < widthOfAreaToShow) {
|
if (heightToSceneHeightRatio < widthOfAreaToShow) {
|
||||||
scrollX = (minX * scale) - ((windowWidth - widthOfAreaToShow*scale)/2) + this.project.scene_width/2;
|
this.scrollX = (minX * scale) - ((windowWidth - widthOfAreaToShow*scale)/2) + this.project.scene_width/2;
|
||||||
scrollY = (minY * scale) + this.project.scene_height/2;
|
this.scrollY = (minY * scale) + this.project.scene_height/2;
|
||||||
} else {
|
} else {
|
||||||
scrollX = (minX * scale) + this.project.scene_width/2;
|
this.scrollX = (minX * scale) + this.project.scene_width/2;
|
||||||
scrollY = (minY * scale) - ((windowHeight - heightOfAreaToShow*scale)/2) + this.project.scene_height/2;
|
this.scrollY = (minY * scale) - ((windowHeight - heightOfAreaToShow*scale)/2) + this.project.scene_height/2;
|
||||||
}
|
}
|
||||||
setTimeout(function(){window.scrollTo(scrollX, scrollY)}, 100);
|
|
||||||
} else {
|
} else {
|
||||||
let scrollX: number = (minX * scale) + this.project.scene_width/2;
|
this.scrollX = (minX * scale) + this.project.scene_width/2;
|
||||||
let scrollY: number = (minY * scale) + this.project.scene_height/2;
|
this.scrollY = (minY * scale) + this.project.scene_height/2;
|
||||||
window.scrollTo(scrollX, scrollY);
|
|
||||||
}
|
}
|
||||||
|
this.scrollEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public centerCanvas() {
|
||||||
|
window.scrollTo(this.scrollX, this.scrollY);
|
||||||
|
this.scrollEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public centerView() {
|
public centerView() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable, EventEmitter } from "@angular/core";
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -8,6 +8,7 @@ export class MapSettingsService {
|
|||||||
public isLogConsoleVisible: boolean = false;
|
public isLogConsoleVisible: boolean = false;
|
||||||
public isLayerNumberVisible: boolean = false;
|
public isLayerNumberVisible: boolean = false;
|
||||||
public interfaceLabels: Map<string, boolean> = new Map<string, boolean>();
|
public interfaceLabels: Map<string, boolean> = new Map<string, boolean>();
|
||||||
|
public mapRenderedEmitter = new EventEmitter<boolean>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.isLayerNumberVisible = localStorage.getItem('layersVisibility') === 'true' ? true : false;
|
this.isLayerNumberVisible = localStorage.getItem('layersVisibility') === 'true' ? true : false;
|
||||||
|
Loading…
Reference in New Issue
Block a user