Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cophilot committed Jan 22, 2024
1 parent 69870d8 commit 9d2b595
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const routes: Routes = [
{ path: 'help', component: GetHelpComponent },
{ path: 'info', component: WhatsNewComponent },
{ path: 'impressum', component: ImpressumComponent },
{ path: 'connect/:host/:port', component: ConnectViaUrlComponent },
{ path: 'connect/:protocol/:host/:port', component: ConnectViaUrlComponent },
];

@NgModule({
Expand Down
12 changes: 12 additions & 0 deletions src/app/connect-via-url/connect-via-url.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ export class ConnectViaUrlComponent {
) {}

ngOnInit(): void {
let protocol = this.route.snapshot.paramMap.get('protocol');
if (protocol == null) {
this.router.navigate(['/']);
return;
}

let host = this.route.snapshot.paramMap.get('host');
if (host == null) {
this.router.navigate(['/']);
return;
}

let portS = this.route.snapshot.paramMap.get('port');
if (portS == null || isNaN(Number(portS))) {
this.router.navigate(['/']);
Expand All @@ -29,8 +36,13 @@ export class ConnectViaUrlComponent {
let port = Number(portS);
this.localStorageService.setServerHost(host);
this.localStorageService.setServerPort(port);
this.localStorageService.setServerProtocol(protocol);
IrisinterfaceService.host = host;
IrisinterfaceService.port = port;
IrisinterfaceService.protocol = protocol;
setTimeout(() => {
window.location.reload();
}, 1000);
this.router.navigate(['/']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export class ServerSettingsComponent {
this.localStorageService.setServerHost(this.host);
this.localStorageService.setServerPort(this.port);
this.localStorageService.setServerProtocol(this.protocol);
setTimeout(() => {
window.location.reload();
}, 1000);
this.router.navigate(['/']);
}

Expand Down
9 changes: 7 additions & 2 deletions src/app/user-input/log-in/log-in.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export class LogInComponent {
let password = localStorageService.getPassword();
if (password != null) {
this.enteredPassword = password;
this.submit();
this.submit(true);
}
}

submit() {
submit(onInit = false) {
this.apiService
.checkUser(this.entereduserName, this.enteredPassword)
.subscribe({
Expand All @@ -55,6 +55,11 @@ export class LogInComponent {
}
},
error: (err: Error) => {
if (onInit) {
this.localStorageService.removePassword();
this.close();
return;
}
this.wrongMessage = err.message;
this.isWrong = true;
this.enteredPassword = '';
Expand Down

0 comments on commit 9d2b595

Please sign in to comment.