mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 02:54:16 +00:00
Option to choose protocol from AddServerDialog
This commit is contained in:
parent
5cb3aa051b
commit
288879ccb2
@ -28,6 +28,12 @@
|
||||
<input matInput tabindex="1" formControlName="port" placeholder="Port" />
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Protocol" formControlName="protocol" >
|
||||
<mat-option *ngFor="let protocol of protocols" [value]="protocol.key"> {{ protocol.name }} </mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="serverForm.get('location').value === 'remote'">
|
||||
<mat-select placeholder="Authorization" formControlName="authorization" >
|
||||
<mat-option *ngFor="let auth of authorizations" [value]="auth.key"> {{ auth.name }} </mat-option>
|
||||
|
@ -13,6 +13,7 @@ import { ToasterService } from '../../../services/toaster.service';
|
||||
})
|
||||
export class AddServerDialogComponent implements OnInit {
|
||||
authorizations = [{ key: 'none', name: 'No authorization' }, { key: 'basic', name: 'Basic authorization' }];
|
||||
protocols = [{ key: 'http:', name: 'HTTP' }, { key: 'https:', name: 'HTTPS' }];
|
||||
locations = [];
|
||||
|
||||
serverForm = new FormGroup({
|
||||
@ -22,6 +23,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:'),
|
||||
'authorization': new FormControl('none'),
|
||||
'login': new FormControl(''),
|
||||
'password': new FormControl('')
|
||||
|
@ -3,13 +3,14 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { map } from 'rxjs//operators';
|
||||
|
||||
import { Server } from '../../../models/server';
|
||||
import { Server, ServerProtocol } from '../../../models/server';
|
||||
import { VersionService } from '../../../services/version.service';
|
||||
import { Version } from '../../../models/version';
|
||||
import { forkJoin } from 'rxjs';
|
||||
import { ServerService } from '../../../services/server.service';
|
||||
import { ServerDatabase } from '../../../services/server.database';
|
||||
import { from } from 'rxjs';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-server-discovery',
|
||||
@ -29,7 +30,8 @@ export class ServerDiscoveryComponent implements OnInit {
|
||||
constructor(
|
||||
private versionService: VersionService,
|
||||
private serverService: ServerService,
|
||||
private serverDatabase: ServerDatabase
|
||||
private serverDatabase: ServerDatabase,
|
||||
private route : ActivatedRoute
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -94,6 +96,7 @@ export class ServerDiscoveryComponent implements OnInit {
|
||||
}
|
||||
|
||||
server.location = 'remote';
|
||||
server.protocol = location.protocol as ServerProtocol;
|
||||
|
||||
this.serverService.create(server).then((created: Server) => {
|
||||
this.serverDatabase.addServer(created);
|
||||
|
@ -4,8 +4,8 @@ import { MatBottomSheet } from '@angular/material/bottom-sheet';
|
||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { Observable, merge, Subscription } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Router } from '@angular/router';
|
||||
import { Server } from '../../models/server';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Server, ServerProtocol } from '../../models/server';
|
||||
import { ServerService } from '../../services/server.service';
|
||||
import { ServerDatabase } from '../../services/server.database';
|
||||
import { AddServerDialogComponent } from './add-server-dialog/add-server-dialog.component';
|
||||
@ -35,6 +35,7 @@ export class ServersComponent implements OnInit, OnDestroy {
|
||||
private electronService: ElectronService,
|
||||
private childProcessService: ChildProcessService,
|
||||
private bottomSheet: MatBottomSheet,
|
||||
private route : ActivatedRoute
|
||||
) {}
|
||||
|
||||
getServers() {
|
||||
|
@ -1,6 +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 class Server {
|
||||
id: number;
|
||||
@ -14,4 +15,5 @@ export class Server {
|
||||
login: string;
|
||||
password: string;
|
||||
status: ServerStatus;
|
||||
protocol: ServerProtocol;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { HttpHeaders, HttpClient, HttpParams, HttpErrorResponse } from '@angular
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { Server } from '../models/server';
|
||||
import { Server, ServerProtocol } from '../models/server';
|
||||
|
||||
/* tslint:disable:interface-over-type-literal */
|
||||
export type JsonOptions = {
|
||||
@ -176,12 +176,14 @@ 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.authorization === 'basic') {
|
||||
url = `https://${server.host}:${server.port}/v2${url}`;
|
||||
} else {
|
||||
url = `http://${server.host}:${server.port}/v2${url}`;
|
||||
if (!server.protocol) {
|
||||
server.protocol = location.protocol as ServerProtocol;
|
||||
}
|
||||
url = `${server.protocol}//${server.host}:${server.port}/v2${url}`;
|
||||
} else {
|
||||
url = `/v2${url}`;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Injectable, EventEmitter } from '@angular/core';
|
||||
import { IndexedDbService } from './indexed-db.service';
|
||||
import { Server } from '../models/server';
|
||||
import { Server, ServerProtocol } from '../models/server';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { HttpServer } from './http-server.service';
|
||||
|
||||
@ -138,7 +138,7 @@ export class ServerService {
|
||||
}
|
||||
|
||||
public getServerUrl(server: Server) {
|
||||
return `http://${server.host}:${server.port}/`;
|
||||
return `${server.protocol}//${server.host}:${server.port}/`;
|
||||
}
|
||||
|
||||
public checkServerVersion(server: Server): Observable<any> {
|
||||
@ -152,6 +152,7 @@ export class ServerService {
|
||||
if (local) {
|
||||
local.host = host;
|
||||
local.port = port;
|
||||
local.protocol = location.protocol as ServerProtocol;
|
||||
this.update(local).then(updated => {
|
||||
resolve(updated);
|
||||
}, reject);
|
||||
@ -161,6 +162,7 @@ export class ServerService {
|
||||
server.host = host;
|
||||
server.port = port;
|
||||
server.location = 'bundled';
|
||||
server.protocol = location.protocol as ServerProtocol;
|
||||
this.create(server).then(created => {
|
||||
resolve(created);
|
||||
}, reject);
|
||||
|
Loading…
x
Reference in New Issue
Block a user