Fix default map size

This commit is contained in:
ziajka 2018-07-23 17:57:09 +02:00
parent 88f6134092
commit c7d079ed0d
3 changed files with 18 additions and 21 deletions

View File

@ -2,7 +2,7 @@ import {
Component, ElementRef, HostListener, Input, OnChanges, OnDestroy, OnInit, SimpleChange
} from '@angular/core';
import { D3, D3Service } from 'd3-ng2-service';
import {select, Selection} from 'd3-selection';
import { select, Selection } from 'd3-selection';
import { Node } from "../../models/node";
import { Link } from "../../models/link";
@ -10,7 +10,7 @@ import { GraphLayout } from "../../widgets/graph-layout";
import { Context } from "../../models/context";
import { Size } from "../../models/size";
import { Drawing } from "../../models/drawing";
import {Symbol} from "../../models/symbol";
import { Symbol } from "../../models/symbol";
@Component({
@ -30,10 +30,9 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
private d3: D3;
private parentNativeElement: any;
private svg: Selection<SVGSVGElement, any, null, undefined>;
public graphLayout: GraphLayout;
private graphContext: Context;
public graphLayout: GraphLayout;
constructor(protected element: ElementRef,
protected d3Service: D3Service
@ -118,12 +117,6 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
this.graphContext.size = this.getSize();
}
if (this.graphContext != null) {
this.svg
.attr('width', this.graphContext.size.width)
.attr('height', this.graphContext.size.height);
}
this.graphLayout.setNodes(this.nodes);
this.graphLayout.setLinks(this.links);
this.graphLayout.setDrawings(this.drawings);

View File

@ -82,6 +82,10 @@ export class GraphLayout implements Widget {
}
draw(view: SVGSelection, context: Context) {
view
.attr('width', context.size.width)
.attr('height', context.size.height);
const canvas = view
.selectAll<SVGGElement, Context>('g.canvas')
.data([context]);

View File

@ -4,21 +4,21 @@
<meta charset="utf-8">
<title>GNS3 Web UI</title>
<!-- It's important to have base here because of the script below //-->
<base href="./">
<base href="/">
<script>
var userAgent = navigator.userAgent.toLowerCase();
// in case we're running in electron because we need it for resources
// if (userAgent.indexOf(' electron/') > -1) {
// var base = document.getElementsByTagName('base');
// if(base.length > 0) {
// base.href = document.location;
// }
// else {
// document.write('<base href="' + document.location + '" />');
// }
// }
//in case we're running in electron because we need it for resources
if (userAgent.indexOf(' electron/') > -1) {
var base = document.getElementsByTagName('base');
if(base.length > 0) {
base.href ='./';
}
else {
document.write('<base href="./" />');
}
}
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">