mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-19 13:07:52 +00:00
Clean code from outdated http based methods
This commit is contained in:
parent
288879ccb2
commit
149b68e037
@ -154,6 +154,6 @@ export class ImportApplianceComponent implements OnInit {
|
||||
}
|
||||
|
||||
private getUploadPath(server: Server, emulator: string, filename: string) {
|
||||
return `http://${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
this.nodesDataSource.changes.subscribe((nodes: Node[]) => {
|
||||
if (!this.server) return;
|
||||
nodes.forEach((node: Node) => {
|
||||
node.symbol_url = `http://${this.server.host}:${this.server.port}/v2/symbols/${node.symbol}/raw`;
|
||||
node.symbol_url = `${this.server.protocol}//${this.server.host}:${this.server.port}/v2/symbols/${node.symbol}/raw`;
|
||||
});
|
||||
|
||||
this.nodes = nodes;
|
||||
|
@ -53,6 +53,7 @@ export class ServersComponent implements OnInit, OnDestroy {
|
||||
this.serverService.checkServerVersion(server).subscribe(
|
||||
(serverInfo) => {
|
||||
if ((serverInfo.version.split('.')[1]>=2) && (serverInfo.version.split('.')[0]>=2)) {
|
||||
if (!server.protocol) server.protocol = location.protocol as ServerProtocol;
|
||||
if (!this.serverDatabase.find(server.name)) this.serverDatabase.addServer(server);
|
||||
}
|
||||
},
|
||||
|
@ -116,7 +116,7 @@ export class TemplateComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
getImageSourceForTemplate(template: Template) {
|
||||
return `http://${this.server.host}:${this.server.port}/v2/symbols/${template.symbol}/raw`;
|
||||
return `${this.server.protocol}//${this.server.host}:${this.server.port}/v2/symbols/${template.symbol}/raw`;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
export type ServerAuthorization = 'basic' | 'none';
|
||||
export type ServerLocation = 'local' | 'remote' | 'bundled';
|
||||
export type ServerStatus = 'stopped' | 'starting' | 'running';
|
||||
export type ServerProtocol = 'http' | 'https'
|
||||
export type ServerProtocol = 'http:' | 'https:'
|
||||
|
||||
export class Server {
|
||||
id: number;
|
||||
|
@ -19,7 +19,7 @@ export class ApplianceService {
|
||||
}
|
||||
|
||||
getUploadPath(server: Server, emulator: string, filename: string) {
|
||||
return `http://${server.host}:${server.port}/v2/compute/${emulator}/images/${filename}`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/compute/${emulator}/images/${filename}`;
|
||||
}
|
||||
|
||||
updateAppliances(server: Server): Observable<Appliance[]> {
|
||||
|
@ -14,7 +14,7 @@ export class ComputeService {
|
||||
}
|
||||
|
||||
getUploadPath(server: Server, emulator: string, filename: string) {
|
||||
return `http://${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
|
||||
}
|
||||
|
||||
getStatistics(server: Server): Observable<ComputeStatistics[]> {
|
||||
|
@ -176,9 +176,6 @@ export class HttpServer {
|
||||
}
|
||||
|
||||
private getOptionsForServer<T extends HeadersOptions>(server: Server, url: string, options: T) {
|
||||
console.log('Server ', server.protocol);
|
||||
console.log('Location ', location.protocol);
|
||||
|
||||
if (server.host && server.port) {
|
||||
if (!server.protocol) {
|
||||
server.protocol = location.protocol as ServerProtocol;
|
||||
|
@ -14,7 +14,7 @@ export class IosService {
|
||||
}
|
||||
|
||||
getImagePath(server: Server, filename: string): string {
|
||||
return `http://${server.host}:${server.port}/v2/compute/dynamips/images/${filename}`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/compute/dynamips/images/${filename}`;
|
||||
}
|
||||
|
||||
getTemplates(server: Server): Observable<IosTemplate[]> {
|
||||
|
@ -22,7 +22,7 @@ export class IouService {
|
||||
}
|
||||
|
||||
getImagePath(server: Server, filename: string): string {
|
||||
return `http://${server.host}:${server.port}/v2/compute/iou/images/${filename}`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/compute/iou/images/${filename}`;
|
||||
}
|
||||
|
||||
addTemplate(server: Server, iouTemplate: any): Observable<any> {
|
||||
|
@ -69,11 +69,11 @@ export class ProjectService {
|
||||
}
|
||||
|
||||
getUploadPath(server: Server, uuid: string, project_name: string) {
|
||||
return `http://${server.host}:${server.port}/v2/projects/${uuid}/import?name=${project_name}`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/projects/${uuid}/import?name=${project_name}`;
|
||||
}
|
||||
|
||||
getExportPath(server: Server, project: Project) {
|
||||
return `http://${server.host}:${server.port}/v2/projects/${project.project_id}/export`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/projects/${project.project_id}/export`;
|
||||
}
|
||||
|
||||
export(server: Server, project_id: string): Observable<any> {
|
||||
|
@ -20,7 +20,7 @@ export class QemuService {
|
||||
}
|
||||
|
||||
getImagePath(server: Server, filename: string): string {
|
||||
return `http://${server.host}:${server.port}/v2/compute/qemu/images/${filename}`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/v2/compute/qemu/images/${filename}`;
|
||||
}
|
||||
|
||||
getBinaries(server: Server): Observable<QemuBinary[]> {
|
||||
|
@ -5,5 +5,6 @@ export function getTestServer(): Server {
|
||||
server.host = '127.0.0.1';
|
||||
server.port = 3080;
|
||||
server.authorization = 'none';
|
||||
server.protocol = 'http:';
|
||||
return server;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user