mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-18 18:56:26 +00:00
Use DOCUMENT from angular/common, Ref: #347
This commit is contained in:
parent
038f3682eb
commit
ddf2db7df6
@ -6,7 +6,8 @@ import { ServerService } from '../../services/server.service';
|
|||||||
import { MockedServerService } from '../../services/server.service.spec';
|
import { MockedServerService } from '../../services/server.service.spec';
|
||||||
import { Server } from '../../models/server';
|
import { Server } from '../../models/server';
|
||||||
|
|
||||||
describe('LocalServerComponent', () => {
|
|
||||||
|
fdescribe('LocalServerComponent', () => {
|
||||||
let component: LocalServerComponent;
|
let component: LocalServerComponent;
|
||||||
let fixture: ComponentFixture<LocalServerComponent>;
|
let fixture: ComponentFixture<LocalServerComponent>;
|
||||||
let router: any;
|
let router: any;
|
||||||
@ -24,7 +25,8 @@ describe('LocalServerComponent', () => {
|
|||||||
spyOn(serverService, 'getLocalServer').and.returnValue(Promise.resolve(server));
|
spyOn(serverService, 'getLocalServer').and.returnValue(Promise.resolve(server));
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [{ provide: Router, useValue: router }, { provide: ServerService, useValue: serverService }],
|
providers: [{ provide: Router, useValue: router },
|
||||||
|
{ provide: ServerService, useValue: serverService }],
|
||||||
declarations: [LocalServerComponent]
|
declarations: [LocalServerComponent]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, Inject } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { ServerService } from '../../services/server.service';
|
import { ServerService } from '../../services/server.service';
|
||||||
import { Server } from '../../models/server';
|
import { Server } from '../../models/server';
|
||||||
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-local-server',
|
selector: 'app-local-server',
|
||||||
@ -10,10 +11,16 @@ import { Server } from '../../models/server';
|
|||||||
styleUrls: ['./local-server.component.scss']
|
styleUrls: ['./local-server.component.scss']
|
||||||
})
|
})
|
||||||
export class LocalServerComponent implements OnInit {
|
export class LocalServerComponent implements OnInit {
|
||||||
constructor(private router: Router, private serverService: ServerService) {}
|
constructor(
|
||||||
|
private router: Router,
|
||||||
|
private serverService: ServerService,
|
||||||
|
@Inject(DOCUMENT) private document) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.serverService.getLocalServer(location.hostname, parseInt(location.port, 10)).then((server: Server) => {
|
this.serverService.getLocalServer(
|
||||||
|
this.document.location.hostname,
|
||||||
|
parseInt(this.document.location.port, 10))
|
||||||
|
.then((server: Server) => {
|
||||||
this.router.navigate(['/server', server.id, 'projects']);
|
this.router.navigate(['/server', server.id, 'projects']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user