Refactor server protocol field

This commit is contained in:
grossmj 2023-11-03 11:17:47 +10:00
parent 8253f8da38
commit 3300794aac
18 changed files with 31 additions and 31 deletions

View File

@ -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' },
@ -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(''),

View File

@ -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`;
}
}

View File

@ -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}`;
}
}

View File

@ -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
) {}
@ -229,7 +229,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.instance.instance.ngOnDestroy();
this.instance.destroy();
}
}
}
}
addSubscriptions() {
@ -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();
@ -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)

View File

@ -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 = [];
@ -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(''),

View File

@ -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();
}
}
}

View File

@ -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;

View File

@ -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[]> {

View File

@ -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[]> {

View File

@ -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}`;
}

View File

@ -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[]> {

View File

@ -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> {

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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> {

View File

@ -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[]> {

View File

@ -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> {

View File

@ -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;
}