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

small fixes

This commit is contained in:
Adolfo Gómez García 2023-01-18 14:18:39 +01:00
parent 070a183ba6
commit cdffc4b977
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
3 changed files with 47 additions and 22 deletions

View File

@ -1,18 +1,24 @@
import { Component, HostListener, OnInit } from '@angular/core';
import { UDSApiService } from './services/uds-api.service';
@Component({
selector: 'uds-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
title = 'UDS';
blackTheme = false;
constructor(private api: UDSApiService) {
constructor(private api: UDSApiService) {}
// blackTheme property, get value from Storage
get blackTheme(): boolean {
return this.api.getFromStorage('blackTheme') === 'true';
}
// blackTheme property, set value to Storage
set blackTheme(value: boolean) {
this.api.putOnStorage('blackTheme', value.toString());
}
@HostListener('document:keydown', ['$event'])
@ -24,22 +30,24 @@ export class AppComponent implements OnInit {
}
ngOnInit() {
// Swith theme if needed
this.api.switchTheme(this.blackTheme);
// Initialize cookie consent
cookieconsent.initialise({
palette: {
popup: {
background: '#343c66',
text: '#cfcfe8'
text: '#cfcfe8',
},
button: {
background: '#f71559'
}
background: '#f71559',
},
},
content: {
message: django.gettext('We use cookies to track usage and preferences'),
dismiss: django.gettext('I Understand'),
link: django.gettext('Learn more')
}
link: django.gettext('Learn more'),
},
});
}
}

View File

@ -5,7 +5,6 @@ import { User, UDSConfig, Downloadable, Info } from '../types/config';
import { toPromise } from '../helpers/tools';
import { timeout } from 'rxjs/operators';
import {
JSONServicesInformation,
JSONEnabledService,
@ -25,7 +24,6 @@ const DARK_THEME = 'dark-theme';
const LIGHT_THEME = 'light-theme';
const TIMEOUT = 10000;
@Injectable()
export class UDSApiService implements UDSApiServiceType {
readonly user: User;
@ -223,4 +221,19 @@ export class UDSApiService implements UDSApiServiceType {
});
body.classList.add(dark ? DARK_THEME : LIGHT_THEME);
}
// Storage related
putOnStorage(key: string, value: string): void {
if (typeof Storage !== undefined) {
sessionStorage.setItem(key, value);
}
}
getFromStorage(key: string): string | null {
if (typeof Storage !== undefined) {
return sessionStorage.getItem(key);
} else {
return null;
}
}
}

View File

@ -16,16 +16,10 @@ export interface UDSApiServiceType {
config: UDSConfig;
/* Client enabler */
enabler(
serviceId: string,
transportId: string
): Promise<JSONEnabledService>;
enabler(serviceId: string, transportId: string): Promise<JSONEnabledService>;
/* Service status */
status(
serviceId: string,
transportId: string
): Promise<JSONStatusService>;
status(serviceId: string, transportId: string): Promise<JSONStatusService>;
/* Services resetter */
action(action: string, serviceId: string): Promise<JSONService>;
@ -34,7 +28,13 @@ export interface UDSApiServiceType {
transportUrl(url: string): Promise<JSONTransportURLService>;
/* Transport ticket credentials updater */
updateTransportTicket(ticketId: string, scrambler: string, username: string, password: string, domain: string): Promise<any>;
updateTransportTicket(
ticketId: string,
scrambler: string,
username: string,
password: string,
domain: string
): Promise<any>;
/* Go to admin dashboard */
gotoAdmin(): void;
@ -56,4 +56,8 @@ export interface UDSApiServiceType {
* Executes custom javascript for service launch if it is available
*/
executeCustomJSForServiceLaunch(): void;
// Storage related
putOnStorage(key: string, value: string): void;
getFromStorage(key: string): string | null;
}