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 { Server } from '../../models/server';
|
||||
|
||||
describe('LocalServerComponent', () => {
|
||||
|
||||
fdescribe('LocalServerComponent', () => {
|
||||
let component: LocalServerComponent;
|
||||
let fixture: ComponentFixture<LocalServerComponent>;
|
||||
let router: any;
|
||||
@ -24,7 +25,8 @@ describe('LocalServerComponent', () => {
|
||||
spyOn(serverService, 'getLocalServer').and.returnValue(Promise.resolve(server));
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [{ provide: Router, useValue: router }, { provide: ServerService, useValue: serverService }],
|
||||
providers: [{ provide: Router, useValue: router },
|
||||
{ provide: ServerService, useValue: serverService }],
|
||||
declarations: [LocalServerComponent]
|
||||
}).compileComponents();
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { ServerService } from '../../services/server.service';
|
||||
import { Server } from '../../models/server';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-local-server',
|
||||
@ -10,10 +11,16 @@ import { Server } from '../../models/server';
|
||||
styleUrls: ['./local-server.component.scss']
|
||||
})
|
||||
export class LocalServerComponent implements OnInit {
|
||||
constructor(private router: Router, private serverService: ServerService) {}
|
||||
constructor(
|
||||
private router: Router,
|
||||
private serverService: ServerService,
|
||||
@Inject(DOCUMENT) private document) {}
|
||||
|
||||
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']);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user