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

Fixed custom message

This commit is contained in:
Adolfo Gómez García 2024-07-19 17:30:19 +02:00
parent c3e7fc56c5
commit 8a757ba60c
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
6 changed files with 25 additions and 21 deletions

View File

@ -60,6 +60,7 @@
"eslint-plugin-prettier": "^4.0.0",
"jasmine-core": "^4.0.1",
"jasmine-spec-reporter": "^7.0.0",
"jsonc-parser": "^3.3.1",
"karma": "^6.3.17",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-reporter": "^3.0.3",

View File

@ -93,7 +93,7 @@ export class ServiceComponent implements OnInit {
this.api.gui.alert('<p align="center"><b>' + django.gettext('Launcher') + '</b></p>', message);
}
async launch(transport: JSONTransport|null) {
async launch(transport: JSONTransport | null) {
if (this.service.maintenance) {
this.notifyNotLaunching(django.gettext('Service is in maintenance and cannot be launched'));
} else if (this.service.not_accesible) {
@ -112,28 +112,29 @@ export class ServiceComponent implements OnInit {
transport = this.service.transports[0];
}
if (this.service.custom_message_text !== null && this.service.custom_message_text !== undefined) {
const tr = transport;
if ((await this.api.gui.yesno(django.gettext('Service message'), this.service.custom_message_text)) === false) {
return;
}
console.debug('Launching service with transport', tr);
}
this.api.executeCustomJSForServiceLaunch();
this.api.launchURL(transport.link);
}
}
action(type: string) {
async action(type: string) {
const title =
(type === 'release' ? django.gettext('Release service: ') : django.gettext('Reset service: ')) +
' ' +
this.serviceName;
const action = type === 'release' ? django.gettext('Service released') : django.gettext('Service reseted');
this.api.gui.yesno(title, django.gettext('Are you sure?')).then((val) => {
if (val) {
this.api.action(type, this.service.id).then((service) => {
if (service) {
this.api.gui.alert(title, action);
}
});
if ((await this.api.gui.yesno(title, django.gettext('Are you sure?'))) === false) {
return;
}
this.api.action(type, this.service.id).then((service) => {
if (service) {
this.api.gui.alert(title, action);
}
});
}

View File

@ -1,7 +1,8 @@
/* eslint-disable no-shadow */
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { interval, Subscription, Observable } from 'rxjs';
import { interval } from 'rxjs';
import { Future } from '../../helpers/tools';
export enum DialogType {
alert = 0,
@ -25,19 +26,17 @@ export interface ModalData {
})
export class ModalComponent implements OnInit {
extra = '';
subscription: Subscription | null = null;
yesno: Promise<boolean> = new Promise<boolean>((resolve) => (this.resolver = resolve));
yesno: Future<boolean> = new Future<boolean>();
constructor(public dialogRef: MatDialogRef<ModalComponent>, @Inject(MAT_DIALOG_DATA) public data: ModalData) {
// Notifies on case of yes or not to subscriber
}
resolveAndClose(value: boolean): void {
this.resolver(value);
this.yesno.resolve(value);
this.close();
}
resolver: (value: boolean) => void = () => {};
close() {
this.dialogRef.close();
}

View File

@ -51,7 +51,7 @@ export class LoginComponent implements OnInit {
// Ejecuted when custom auth selected
const doCustomAuth = (data: string) => {
// eslint-disable-next-line no-eval
eval(data);
this.api.eval(data);
};
for (const l of this.auths) {

View File

@ -24,6 +24,8 @@ const DARK_THEME = 'dark-theme';
const LIGHT_THEME = 'light-theme';
const TIMEOUT = 10000;
const EVAL_FNC = eval;
@Injectable()
export class UDSApiService implements UDSApiServiceType {
readonly user: User;
@ -158,8 +160,7 @@ export class UDSApiService implements UDSApiServiceType {
// Executes a defined JS on launch servic event if defined
// this is in fact a hook
if (udsData.custom_js_for_service_launch !== undefined) {
// eslint-disable-next-line no-eval
eval(udsData.custom_js_for_service_launch);
this.eval(udsData.custom_js_for_service_launch);
}
}
@ -236,4 +237,9 @@ export class UDSApiService implements UDSApiServiceType {
return null;
}
}
eval(data: string): void {
// eslint-disable-next-line no-eval
EVAL_FNC(data);
}
}

View File

@ -5,9 +5,6 @@
/* Default, light theme */
@include mat.all-component-themes($angular-default-theme);
/* Cookie consent */
@import 'cookieconsent/build/cookieconsent.min.css';
// variables
$font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif;
//$font-family: Verdana, Geneva, Tahoma, sans-serif;