Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor server protocol field #1477

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export class BundledServerFinderComponent implements OnInit {
this.progressService.activate();
setTimeout(() => {
let port;

if (parseInt(this.document.location.port, 10)) {
port = parseInt(this.document.location.port, 10);
} else if (this.document.location.protocol == "https:") {
} else if (this.document.location.protocol == "https") {
port = 443;
} else {
port = 80;
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/direct-link/direct-link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class DirectLinkComponent implements OnInit {
{ key: 'basic', name: 'Basic authorization' },
];
protocols = [
{ key: 'http:', name: 'HTTP' },
{ key: 'https:', name: 'HTTPS' },
{ key: 'http', name: 'HTTP' },
{ key: 'https', name: 'HTTPS' },
];
locations = [
{ key: 'local', name: 'Local' },
Expand All @@ -34,7 +34,7 @@ export class DirectLinkComponent implements OnInit {
serverForm = new FormGroup({
name: new FormControl('', [Validators.required]),
location: new FormControl(''),
protocol: new FormControl('http:'),
protocol: new FormControl('http'),
authorization: new FormControl('none'),
login: new FormControl(''),
password: new FormControl(''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export class SymbolsComponent implements OnInit {
}

private createSvgFileForImage(image: string | ArrayBuffer, imageToUpload: HTMLImageElement) {
return `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" height=\"${imageToUpload.height}\"
return `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" height=\"${imageToUpload.height}\"
width=\"${imageToUpload.width}\">\n<image height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\" xlink:href=\"${image}\"/>\n</svg>`;
}

getImageSourceForTemplate(symbol: string) {
return `${this.server.protocol}//${this.server.host}:${this.server.port}/v2/symbols/${symbol}/raw`;
return `${this.server.protocol}://${this.server.host}:${this.server.port}/v2/symbols/${symbol}/raw`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@ export class ImportApplianceComponent implements OnInit {
}

private getUploadPath(server: Server, emulator: string, filename: string) {
return `${server.protocol}//${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
return `${server.protocol}://${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
}
}
10 changes: 5 additions & 5 deletions src/app/components/project-map/project-map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
private nodeConsoleService: NodeConsoleService,
private symbolService: SymbolService,
private cd: ChangeDetectorRef,
private cfr: ComponentFactoryResolver,
private cfr: ComponentFactoryResolver,
private injector: Injector
) {}

Expand Down Expand Up @@ -229,7 +229,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.instance.instance.ngOnDestroy();
this.instance.destroy();
}
}
}
}

addSubscriptions() {
Expand All @@ -250,7 +250,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.nodesDataSource.changes.subscribe((nodes: Node[]) => {
if (!this.server) return;
nodes.forEach(async (node: Node) => {
node.symbol_url = `${this.server.protocol}//${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`;

// if (node.width == 0 && node.height == 0) {
// let symbolDimensions = await this.symbolService.getDimensions(this.server, node.symbol).toPromise();
Expand Down Expand Up @@ -990,8 +990,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy {

fileReader.onloadend = () => {
let image = fileReader.result;
let svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"
height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\">\n<image height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\"
let svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"
height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\">\n<image height=\"${imageToUpload.height}\" width=\"${imageToUpload.width}\"
xlink:href=\"${image}\"/>\n</svg>`;
this.drawingService
.add(this.server, this.project.project_id, -(imageToUpload.width / 2), -(imageToUpload.height / 2), svg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class AddServerDialogComponent implements OnInit {
{ key: 'basic', name: 'Basic authorization' },
];
protocols = [
{ key: 'http:', name: 'HTTP' },
{ key: 'https:', name: 'HTTPS' },
{ key: 'http', name: 'HTTP' },
{ key: 'https', name: 'HTTPS' },
];
locations = [];

Expand All @@ -28,7 +28,7 @@ export class AddServerDialogComponent implements OnInit {
ubridge_path: new FormControl(''),
host: new FormControl('', [Validators.required]),
port: new FormControl('', [Validators.required, Validators.min(1)]),
protocol: new FormControl('http:'),
protocol: new FormControl('http'),
authorization: new FormControl('none'),
login: new FormControl(''),
password: new FormControl(''),
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/template/template.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ export class TemplateComponent implements OnInit, OnDestroy {
}

getImageSourceForTemplate(template: Template) {
return `${this.server.protocol}//${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() {
this.subscription.unsubscribe();
}
}
}
2 changes: 1 addition & 1 deletion src/app/models/server.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/appliances.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ApplianceService {
}

getUploadPath(server: Server, emulator: string, filename: string) {
return `${server.protocol}//${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[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/compute.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ComputeService {
}

getUploadPath(server: Server, emulator: string, filename: string) {
return `${server.protocol}//${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
return `${server.protocol}://${server.host}:${server.port}/v2/${emulator}/images/${filename}`;
}

getStatistics(server: Server): Observable<ComputeStatistics[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/http-server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class HttpServer {
if (!server.protocol) {
server.protocol = location.protocol as ServerProtocol;
}
url = `${server.protocol}//${server.host}:${server.port}/v2${url}`;
url = `${server.protocol}://${server.host}:${server.port}/v2${url}`;
} else {
url = `/v2${url}`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/ios.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class IosService {
}

getImagePath(server: Server, filename: string): string {
return `${server.protocol}//${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[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/iou.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class IouService {
}

getImagePath(server: Server, filename: string): string {
return `${server.protocol}//${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> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/nodeConsole.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class NodeConsoleService {

getUrl(server: Server, node: Node) {
let protocol:string = "ws"
if (server.protocol === "https:") {
if (server.protocol === "https") {
protocol = "wss"
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { Server } from '../models/server';
export class NotificationService {
notificationsPath(server: Server): string {
let protocol:string = "ws"
if (server.protocol === "https:") {
if (server.protocol === "https") {
protocol = "wss"
}

return `${protocol}://${server.host}:${server.port}/v2/notifications/ws`;
}


projectNotificationsPath(server: Server, project_id: string): string {
let protocol:string = "ws"
if (server.protocol === "https:") {
if (server.protocol === "https") {
protocol = "wss"
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ export class ProjectService {
}

getUploadPath(server: Server, uuid: string, project_name: string) {
return `${server.protocol}//${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 `${server.protocol}//${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> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/qemu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class QemuService {
}

getImagePath(server: Server, filename: string): string {
return `${server.protocol}//${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[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ServerService {
}

public getServerUrl(server: Server) {
return `${server.protocol}//${server.host}:${server.port}/`;
return `${server.protocol}://${server.host}:${server.port}/`;
}

public checkServerVersion(server: Server): Observable<any> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export function getTestServer(): Server {
server.host = '127.0.0.1';
server.port = 3080;
server.authorization = 'none';
server.protocol = 'http:';
server.protocol = 'http';
return server;
}
Loading