mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-23 23:02:22 +00:00
Code cleaned up
This commit is contained in:
parent
2d3a4798d9
commit
83ac53e0a1
@ -4,6 +4,7 @@ import { Context } from '../models/context';
|
||||
import { MovingEventSource } from '../events/moving-event-source';
|
||||
import { Component } from '@angular/core';
|
||||
import { ZoomingCanvasDirective } from './zooming-canvas.directive';
|
||||
import { MapScaleService } from '../../services/mapScale.service';
|
||||
|
||||
@Component({
|
||||
template: `<svg #svg class="map" preserveAspectRatio="none" zoomingCanvas><g class="canvas" transform="translate(0, 0) scale(1)"></g></svg>`
|
||||
@ -22,7 +23,8 @@ describe('ZoomingCanvasDirective', () => {
|
||||
imports: [NoopAnimationsModule],
|
||||
providers: [
|
||||
{ provide: MovingEventSource, useValue: movingEventSource },
|
||||
{ provide: Context, useClass: Context }
|
||||
{ provide: Context, useClass: Context },
|
||||
{ provide: MapScaleService, useClass: MapScaleService }
|
||||
],
|
||||
declarations: [DummyComponent, ZoomingCanvasDirective]
|
||||
}).compileComponents();
|
||||
|
@ -3,6 +3,7 @@ import { Subscription } from 'rxjs';
|
||||
import { MovingEventSource } from '../events/moving-event-source';
|
||||
import { Context } from '../models/context';
|
||||
import { select } from 'd3-selection';
|
||||
import { MapScaleService } from '../../services/mapScale.service';
|
||||
|
||||
@Directive({
|
||||
selector: '[zoomingCanvas]',
|
||||
@ -14,7 +15,8 @@ export class ZoomingCanvasDirective implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
private element: ElementRef,
|
||||
private movingEventSource: MovingEventSource,
|
||||
private context: Context
|
||||
private context: Context,
|
||||
private mapsScaleService: MapScaleService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -45,6 +47,7 @@ export class ZoomingCanvasDirective implements OnInit, OnDestroy {
|
||||
const xTrans = this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x;
|
||||
const yTrans = this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y;
|
||||
const kTrans = this.context.transformation.k;
|
||||
this.mapsScaleService.setScale(kTrans);
|
||||
|
||||
return `translate(${xTrans}, ${yTrans}) scale(${kTrans})`;
|
||||
});
|
||||
|
@ -11,7 +11,6 @@ import { MapLink } from '../models/map/map-link';
|
||||
import { SelectionManager } from '../managers/selection-manager';
|
||||
import { event } from 'd3-selection';
|
||||
import { LinkContextMenu } from '../events/event-source';
|
||||
import { MapScaleService } from '../../services/mapScale.service';
|
||||
|
||||
@Injectable()
|
||||
export class LinkWidget implements Widget {
|
||||
@ -21,8 +20,7 @@ export class LinkWidget implements Widget {
|
||||
private multiLinkCalculatorHelper: MultiLinkCalculatorHelper,
|
||||
private interfaceLabelWidget: InterfaceLabelWidget,
|
||||
private interfaceStatusWidget: InterfaceStatusWidget,
|
||||
private selectionManager: SelectionManager,
|
||||
private mapScaleService: MapScaleService
|
||||
private selectionManager: SelectionManager
|
||||
) {}
|
||||
|
||||
public draw(view: SVGSelection) {
|
||||
@ -31,8 +29,7 @@ export class LinkWidget implements Widget {
|
||||
const link_body_enter = link_body
|
||||
.enter()
|
||||
.append<SVGGElement>('g')
|
||||
.attr('class', 'link_body')
|
||||
.attr('transform', `scale(${this.mapScaleService.getScale()})`);;
|
||||
.attr('class', 'link_body');
|
||||
|
||||
const link_body_merge = link_body.merge(link_body_enter).attr('transform', link => {
|
||||
const translation = this.multiLinkCalculatorHelper.linkTranslation(link.distance, link.source, link.target);
|
||||
|
Loading…
Reference in New Issue
Block a user