mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-22 06:17:47 +00:00
Basic support of local server
This commit is contained in:
parent
d929cd4187
commit
f1493800cd
@ -176,4 +176,17 @@ describe('HttpServer', () => {
|
||||
expect(req.request.headers.get('Authorization')).toEqual('Basic bG9naW46cGFzc3dvcmQ=');
|
||||
expect(req.request.headers.get('CustomHeader')).toEqual('value');
|
||||
});
|
||||
|
||||
it('should make local call when ip and port is not defined', () => {
|
||||
server.ip = null;
|
||||
server.port = null;
|
||||
|
||||
service.get(server, '/test', {
|
||||
headers: {
|
||||
'CustomHeader': 'value'
|
||||
}
|
||||
}).subscribe();
|
||||
|
||||
const req = httpTestingController.expectOne('/v2/test');
|
||||
});
|
||||
});
|
||||
|
@ -112,7 +112,11 @@ export class HttpServer {
|
||||
}
|
||||
|
||||
private getOptionsForServer<T extends HeadersOptions>(server: Server, url: string, options: T) {
|
||||
url = `http://${server.ip}:${server.port}/v2${url}`;
|
||||
if (server.ip && server.port) {
|
||||
url = `http://${server.ip}:${server.port}/v2${url}`;
|
||||
} else {
|
||||
url = `/v2${url}`;
|
||||
}
|
||||
|
||||
if (!options.headers) {
|
||||
options.headers = {};
|
||||
|
@ -115,4 +115,5 @@ describe('ProjectService', () => {
|
||||
const path = service.notificationsPath(server, "myproject");
|
||||
expect(path).toEqual('ws://127.0.0.1:3080/v2/projects/myproject/notifications/ws')
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
|
||||
import {IndexedDbService} from "./indexed-db.service";
|
||||
import {Server} from "../models/server";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -23,7 +24,9 @@ export class ServerService {
|
||||
|
||||
public getLocalOrRemote(id: string) {
|
||||
if (id === 'local') {
|
||||
|
||||
const server = new Server();
|
||||
server.name = 'local';
|
||||
return Observable.of(server);
|
||||
}
|
||||
return this.get(parseInt(id, 10));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user