mirror of
https://github.com/dkmstr/openuds-gui.git
synced 2025-03-12 08:58:21 +03:00
Detected session termination and fixed Launchers to detect "close button" pressed
This commit is contained in:
parent
bf45826e89
commit
8eaa2b7f33
@ -16,6 +16,27 @@ export class Plugin {
|
||||
}
|
||||
|
||||
launchURL(url: string): void {
|
||||
// Internal helper for notify errors
|
||||
const notifyError = (error?: any) => {
|
||||
let msg: string = django.gettext(
|
||||
'Error communicating with your service. Please, retry again.'
|
||||
);
|
||||
if (typeof error === 'string') {
|
||||
msg = error;
|
||||
} else if (error.status === 403) {
|
||||
// Session timeout
|
||||
msg = django.gettext('Your session has expired. Please, login again');
|
||||
}
|
||||
window.setTimeout(() => {
|
||||
this.showAlert(django.gettext('Error'), msg, 5000);
|
||||
if (error.status === 403) {
|
||||
window.setTimeout(() => {
|
||||
this.api.logout();
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// If uds url...
|
||||
if (url.substring(0, 7) === 'udsa://') {
|
||||
const params = url.split('//')[1].split('/');
|
||||
@ -27,19 +48,10 @@ export class Plugin {
|
||||
0,
|
||||
// Now UDS tries to check status
|
||||
new Observable<boolean>((observer) => {
|
||||
const notifyError = () => {
|
||||
window.setTimeout(() => {
|
||||
this.showAlert(
|
||||
django.gettext('Error'),
|
||||
django.gettext(
|
||||
'Error communicating with your service. Please, retry again.'
|
||||
),
|
||||
5000
|
||||
);
|
||||
});
|
||||
};
|
||||
let readyTime = 0;
|
||||
const checker = () => {
|
||||
if (alert.componentInstance) {
|
||||
// Not closed dialog...
|
||||
this.api.status(params[0], params[1]).subscribe(
|
||||
(data) => {
|
||||
if (data.status === 'ready') {
|
||||
@ -65,7 +77,9 @@ export class Plugin {
|
||||
'It seems that you don\'t have UDS Client installed. Please, install it from here: '
|
||||
) +
|
||||
'</span>' +
|
||||
'<a href="' + this.api.config.urls.clientDownload + '">' +
|
||||
'<a href="' +
|
||||
this.api.config.urls.clientDownload +
|
||||
'">' +
|
||||
django.gettext('UDS Client Download') +
|
||||
'</a>';
|
||||
}
|
||||
@ -88,9 +102,10 @@ export class Plugin {
|
||||
(error) => {
|
||||
observer.next(true);
|
||||
observer.complete();
|
||||
notifyError();
|
||||
notifyError(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
window.setTimeout(checker);
|
||||
})
|
||||
@ -126,19 +141,9 @@ export class Plugin {
|
||||
0,
|
||||
// Now UDS tries to check status before closing dialog...
|
||||
new Observable<boolean>((observer) => {
|
||||
const notifyError = (error: string = null) => {
|
||||
window.setTimeout(() => {
|
||||
this.showAlert(
|
||||
django.gettext('Error'),
|
||||
error ||
|
||||
django.gettext(
|
||||
'Error communicating with your service. Please, retry again.'
|
||||
),
|
||||
5000
|
||||
);
|
||||
});
|
||||
};
|
||||
const checker = () => {
|
||||
if (alert.componentInstance) {
|
||||
// Not closed dialog...
|
||||
this.api.transportUrl(url).subscribe(
|
||||
(data) => {
|
||||
if (data.url) {
|
||||
@ -175,9 +180,10 @@ export class Plugin {
|
||||
(error) => {
|
||||
observer.next(true);
|
||||
observer.complete();
|
||||
notifyError();
|
||||
notifyError(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
window.setTimeout(checker);
|
||||
})
|
||||
|
@ -33,6 +33,12 @@ export interface UDSApiServiceType {
|
||||
/* transport url */
|
||||
transportUrl(url: string): Observable<JSONTransportURLService>;
|
||||
|
||||
/* Go to admin dashboard */
|
||||
gotoAdmin(): void;
|
||||
|
||||
/* Executes logout */
|
||||
logout(): void;
|
||||
|
||||
/**
|
||||
* Gets services information
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user