mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 19:14:18 +00:00
Support local servers on custom ports, Ref. #303
This commit is contained in:
parent
e0bae16093
commit
28c4c25d14
@ -56,6 +56,14 @@ exports.stopAllLocalServers = async () => {
|
||||
|
||||
function getServerArguments(server, overrides) {
|
||||
let serverArguments = [];
|
||||
if(server.host) {
|
||||
serverArguments.push('--host');
|
||||
serverArguments.push(server.host);
|
||||
}
|
||||
if(server.port) {
|
||||
serverArguments.push('--port');
|
||||
serverArguments.push(server.port);
|
||||
}
|
||||
return serverArguments;
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,11 @@
|
||||
<input matInput tabindex="1" formControlName="path" placeholder="Local server path" />
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="serverForm.get('location').value === 'remote'">
|
||||
<mat-form-field>
|
||||
<input matInput tabindex="1" formControlName="host" placeholder="Host" />
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field *ngIf="serverForm.get('location').value === 'remote'">
|
||||
<mat-form-field>
|
||||
<input matInput tabindex="1" formControlName="port" placeholder="Port" />
|
||||
</mat-form-field>
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
<mat-form-field *ngIf="serverForm.get('authorization').value === 'basic'">
|
||||
<input matInput tabindex="1" formControlName="password" placeholder="Password" />
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
</div>
|
||||
<div mat-dialog-actions>
|
||||
<button mat-button (click)="onNoClick()" tabindex="-1" color="accent">No Thanks</button>
|
||||
|
@ -17,8 +17,8 @@ export class AddServerDialogComponent implements OnInit {
|
||||
'name': new FormControl('', [ Validators.required ]),
|
||||
'location': new FormControl(''),
|
||||
'path': new FormControl(''),
|
||||
'host': new FormControl(''),
|
||||
'port': new FormControl(''),
|
||||
'host': new FormControl('', [ Validators.required ]),
|
||||
'port': new FormControl('', [ Validators.required, Validators.min(1) ]),
|
||||
'authorization': new FormControl('none'),
|
||||
'login': new FormControl(''),
|
||||
'password': new FormControl('')
|
||||
@ -46,6 +46,14 @@ export class AddServerDialogComponent implements OnInit {
|
||||
return 'remote';
|
||||
}
|
||||
|
||||
getDefaultHost() {
|
||||
return '127.0.0.1';
|
||||
}
|
||||
|
||||
getDefaultPort() {
|
||||
return 3080;
|
||||
}
|
||||
|
||||
async getDefaultLocalServerPath() {
|
||||
if(this.electronService.isElectronApp) {
|
||||
return await this.electronService.remote.require('./local-server.js').getLocalServerPath();
|
||||
@ -60,32 +68,23 @@ export class AddServerDialogComponent implements OnInit {
|
||||
|
||||
this.serverForm.get('location').valueChanges.subscribe((location: string) => {
|
||||
const pathControl = this.serverForm.get('path');
|
||||
const portControl = this.serverForm.get('port');
|
||||
const hostControl = this.serverForm.get('host');
|
||||
|
||||
if(location === 'local') {
|
||||
pathControl.setValue(defaultLocalServerPath);
|
||||
pathControl.setValidators([Validators.required]);
|
||||
|
||||
portControl.clearValidators();
|
||||
hostControl.clearValidators();
|
||||
}
|
||||
else {
|
||||
pathControl.setValue('');
|
||||
pathControl.clearValidators();
|
||||
|
||||
portControl.setValidators([Validators.required, Validators.min(0)]);
|
||||
hostControl.setValidators([Validators.required]);
|
||||
}
|
||||
|
||||
[pathControl, portControl, hostControl].forEach((control) => {
|
||||
[pathControl].forEach((control) => {
|
||||
control.updateValueAndValidity({
|
||||
onlySelf: true
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
this.serverForm.get('authorization').valueChanges.subscribe((authorization: string) => {
|
||||
const loginControl = this.serverForm.get('login');
|
||||
const passwordControl = this.serverForm.get('password');
|
||||
@ -107,6 +106,8 @@ export class AddServerDialogComponent implements OnInit {
|
||||
});
|
||||
|
||||
this.serverForm.get('location').setValue(this.getDefaultLocation());
|
||||
this.serverForm.get('host').setValue(this.getDefaultHost());
|
||||
this.serverForm.get('port').setValue(this.getDefaultPort());
|
||||
this.serverForm.get('authorization').setValue('none');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user