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