1
0
mirror of https://github.com/dkmstr/openuds-gui.git synced 2024-10-26 08:55:23 +03:00

Removed error decoding and added error get by ID from UDS

This commit is contained in:
Adolfo Gómez García 2022-05-26 14:59:14 +02:00
parent 408335e9bd
commit 92fdc53dd8
5 changed files with 24 additions and 18 deletions

View File

@ -14,7 +14,7 @@
</h1>
<p class="description">
<span *ngFor="let error of this.error" [innerHTML]="error"></span>
{{ error }}
</p>
<a mat-raised-button color="warn" routerLink="/"><uds-translate>Return</uds-translate></a>

View File

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UDSApiService } from '../../uds-api.service';
declare const django: any;
declare const udsData: any;
@ -10,9 +11,9 @@ declare const udsData: any;
styleUrls: ['./error.component.css'],
})
export class ErrorComponent implements OnInit {
error: string[] = [''];
error: string;
constructor(private route: ActivatedRoute) {}
constructor(public api: UDSApiService, private route: ActivatedRoute) {}
ngOnInit() {
this.getError();
@ -20,20 +21,11 @@ export class ErrorComponent implements OnInit {
getError(): void {
const id = this.route.snapshot.paramMap.get('id');
try {
const errText = new TextDecoder()
.decode(
Uint8Array.from(window.atob(id), (c) => (c as any).charCodeAt(c))
)
.replace('<', '&lt;')
.replace('>', '&gt;');
// Split error text in lines
this.error = errText.split('\n');
console.log(this.error);
udsData.error = this.error;
} catch (e) {
console.log(e);
this.error = [django.gettext('Invalid error string')];
}
this.error = '';
// Request error string from UDS
this.api.getErrorInformation(id).subscribe((errInfo) => {
// Set error to errInfo.error + Hex code
this.error = errInfo.error;
});
}
}

View File

@ -29,6 +29,7 @@ export interface UDSUrls {
readonly galleryImage: string;
readonly transportIcon: string;
readonly clientDownload: string;
readonly error: string;
readonly launch: string;
}

View File

@ -45,6 +45,11 @@ export interface JSONServicesInformation {
transports: string;
}
export interface JSONErrorInformation {
error: string;
code: string;
}
export interface JSONEnabledService {
url: string;
error: string;

View File

@ -9,6 +9,7 @@ import {
JSONStatusService,
JSONService,
JSONTransportURLService,
JSONErrorInformation,
} from './types/services';
import { UDSGuiService } from './gui/uds-gui.service';
import { Plugin } from './helpers/plugin';
@ -137,6 +138,13 @@ export class UDSApiService implements UDSApiServiceType {
return this.http.get<JSONServicesInformation>(this.config.urls.services);
}
/**
* Gets error string from a code
*/
getErrorInformation(errorCode: string): Observable<JSONErrorInformation> {
return this.http.get<JSONErrorInformation>(this.config.urls.error.replace('9999', errorCode));
}
/**
* Executes custom javascript for service launch if it is available
*/