diff --git a/src/app/components/project-map/import-appliance/import-appliance.component.ts b/src/app/components/project-map/import-appliance/import-appliance.component.ts index b7c50a08..2d2e4c67 100644 --- a/src/app/components/project-map/import-appliance/import-appliance.component.ts +++ b/src/app/components/project-map/import-appliance/import-appliance.component.ts @@ -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}`; } } diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index 72ed6f97..01069e2d 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -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; diff --git a/src/app/components/servers/servers.component.ts b/src/app/components/servers/servers.component.ts index 8c613066..e72f8774 100644 --- a/src/app/components/servers/servers.component.ts +++ b/src/app/components/servers/servers.component.ts @@ -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); } }, diff --git a/src/app/components/template/template.component.ts b/src/app/components/template/template.component.ts index 5323a42a..a6f0f09b 100644 --- a/src/app/components/template/template.component.ts +++ b/src/app/components/template/template.component.ts @@ -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() { diff --git a/src/app/models/server.ts b/src/app/models/server.ts index d8a546d3..1275d7fd 100644 --- a/src/app/models/server.ts +++ b/src/app/models/server.ts @@ -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; diff --git a/src/app/services/appliances.service.ts b/src/app/services/appliances.service.ts index eb492d64..e21a2533 100644 --- a/src/app/services/appliances.service.ts +++ b/src/app/services/appliances.service.ts @@ -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 { diff --git a/src/app/services/compute.service.ts b/src/app/services/compute.service.ts index 1799e4e2..9cc76014 100644 --- a/src/app/services/compute.service.ts +++ b/src/app/services/compute.service.ts @@ -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 { diff --git a/src/app/services/http-server.service.ts b/src/app/services/http-server.service.ts index 56611156..e3742a78 100644 --- a/src/app/services/http-server.service.ts +++ b/src/app/services/http-server.service.ts @@ -176,9 +176,6 @@ export class HttpServer { } private getOptionsForServer(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; diff --git a/src/app/services/ios.service.ts b/src/app/services/ios.service.ts index 5ab1c7b1..ae1f0704 100644 --- a/src/app/services/ios.service.ts +++ b/src/app/services/ios.service.ts @@ -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 { diff --git a/src/app/services/iou.service.ts b/src/app/services/iou.service.ts index 588aab21..9dd95bed 100644 --- a/src/app/services/iou.service.ts +++ b/src/app/services/iou.service.ts @@ -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 { diff --git a/src/app/services/project.service.ts b/src/app/services/project.service.ts index f4a1057c..06133cb0 100644 --- a/src/app/services/project.service.ts +++ b/src/app/services/project.service.ts @@ -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 { diff --git a/src/app/services/qemu.service.ts b/src/app/services/qemu.service.ts index f8a8c6ac..f9f94afc 100644 --- a/src/app/services/qemu.service.ts +++ b/src/app/services/qemu.service.ts @@ -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 { diff --git a/src/app/services/testing.ts b/src/app/services/testing.ts index 8fb0792c..04e76f4e 100644 --- a/src/app/services/testing.ts +++ b/src/app/services/testing.ts @@ -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; }