diff --git a/src/app/gui/components/service/service.component.ts b/src/app/gui/components/service/service.component.ts
index 8352912..497a9b5 100644
--- a/src/app/gui/components/service/service.component.ts
+++ b/src/app/gui/components/service/service.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, Input } from '@angular/core';
import { JSONService } from '../../../types/services';
-import { UdsApiService } from '../../../uds-api.service';
+import { UDSApiService } from '../../../uds-api.service';
const MAX_NAME_LENGTH = 32;
@@ -11,7 +11,7 @@ const MAX_NAME_LENGTH = 32;
})
export class ServiceComponent implements OnInit {
- constructor(private api: UdsApiService) { }
+ constructor(private api: UDSApiService) { }
@Input() service: JSONService;
@@ -33,4 +33,8 @@ export class ServiceComponent implements OnInit {
get serviceTooltip() {
return this.service.name;
}
+
+ launch() {
+ this.api.launchURL(this.service.transports[0].link);
+ }
}
diff --git a/src/app/gui/components/services-group/services-group.component.ts b/src/app/gui/components/services-group/services-group.component.ts
index 2667140..1d7f129 100644
--- a/src/app/gui/components/services-group/services-group.component.ts
+++ b/src/app/gui/components/services-group/services-group.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit, Input } from '@angular/core';
import { JSONGroup, JSONService } from '../../../types/services';
-import { UdsApiService } from '../../../uds-api.service';
+import { UDSApiService } from '../../../uds-api.service';
@Component({
selector: 'uds-services-group',
@@ -13,7 +13,7 @@ export class ServicesGroupComponent implements OnInit {
@Input() group: JSONGroup;
@Input() expanded = false;
- constructor(private api: UdsApiService) { }
+ constructor(private api: UDSApiService) { }
ngOnInit() {
}
diff --git a/src/app/gui/gui.service.ts b/src/app/gui/gui.service.ts
deleted file mode 100644
index a8e6b38..0000000
--- a/src/app/gui/gui.service.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Injectable } from '@angular/core';
-import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
-
-import { ModalComponent } from './modal/modal.component';
-
-@Injectable()
-export class GuiService {
-
- constructor(private modalService: NgbModal) { }
-
- alert(title: string, message: string, autoclose = 0 ) {
- const mod = this.modalService.open(ModalComponent, { centered: true });
- mod.componentInstance.title = title;
- mod.componentInstance.body = message;
-
- if (autoclose > 0) {
- window.setTimeout(() => {
- mod.close();
- }, autoclose);
- }
- }
-}
diff --git a/src/app/gui/modal/modal.component.css b/src/app/gui/modal/modal.component.css
index e69de29..dec1ec8 100644
--- a/src/app/gui/modal/modal.component.css
+++ b/src/app/gui/modal/modal.component.css
@@ -0,0 +1,4 @@
+.uds-modal-footer {
+ display: flex;
+ justify-content: left;
+}
\ No newline at end of file
diff --git a/src/app/gui/modal/modal.component.html b/src/app/gui/modal/modal.component.html
index 10d1a48..c8c6386 100644
--- a/src/app/gui/modal/modal.component.html
+++ b/src/app/gui/modal/modal.component.html
@@ -1,11 +1,5 @@
-
-
-
-
+
+
+
+
+
diff --git a/src/app/gui/modal/modal.component.ts b/src/app/gui/modal/modal.component.ts
index 28e47c7..86a6f82 100644
--- a/src/app/gui/modal/modal.component.ts
+++ b/src/app/gui/modal/modal.component.ts
@@ -1,5 +1,12 @@
-import { Component, Input, OnInit } from '@angular/core';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { Component, Input, OnInit, Inject } from '@angular/core';
+import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
+import { interval, Observable, Subscription } from 'rxjs';
+
+export interface ModalData {
+ title: string;
+ body: string;
+ autoclose: number;
+}
@Component({
selector: 'uds-modal',
@@ -8,14 +15,53 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
})
export class ModalComponent implements OnInit {
+ extra: string;
+ subscription: Subscription;
- @Input() title = 'Information';
- @Input() body = '';
+ constructor(public dialogRef: MatDialogRef
, @Inject(MAT_DIALOG_DATA) public data: ModalData) {
+ this.subscription = null;
+ }
- constructor(public activeModal: NgbActiveModal) {
+
+ /**
+ * Invoked on closed modal component
+ * This ensures that we stop subscription to interval
+ */
+ closed(): void {
+ if (this.subscription !== null) {
+ this.subscription.unsubscribe();
+ }
+ }
+
+ close(): void {
+ this.dialogRef.close();
+ }
+
+ /**
+ * Sets extra information on close button
+ * @param miliseconds miliseconds to inform (will be converted to seconds)
+ */
+ setExtra(miliseconds: number) {
+ this.extra = ' (' + Math.floor(miliseconds / 1000) + ' ' + django.gettext('seconds') + ') ';
}
ngOnInit() {
+ if (this.data.autoclose > 0) {
+ this.dialogRef.afterClosed().subscribe(res => {
+ this.closed();
+ });
+ this.setExtra(this.data.autoclose);
+ this.subscription = interval(1000).subscribe(n => {
+ const rem = this.data.autoclose - (n + 1) * 1000;
+ this.setExtra(rem);
+ if (rem <= 0) {
+ this.close();
+ }
+ });
+ /*window.setTimeout(() => {
+ this.dialogRef.close();
+ }, this.data.autoclose);*/
+ }
}
}
diff --git a/src/app/gui/navbar/navbar.component.ts b/src/app/gui/navbar/navbar.component.ts
index 8f39e46..d5d759b 100644
--- a/src/app/gui/navbar/navbar.component.ts
+++ b/src/app/gui/navbar/navbar.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { UdsApiService } from '../../uds-api.service';
+import { UDSApiService } from '../../uds-api.service';
import { Lang } from '../../types/config';
@Component({
@@ -12,7 +12,7 @@ export class NavbarComponent implements OnInit {
langs: Lang[]; // Available languages
isNavbarCollapsed = true;
- constructor(public api: UdsApiService) {
+ constructor(public api: UDSApiService) {
const lang = api.config.language;
// Add "non current lang" to list
this.langs = [];
diff --git a/src/app/helpers/plugin.ts b/src/app/helpers/plugin.ts
index bfc9444..cea2694 100644
--- a/src/app/helpers/plugin.ts
+++ b/src/app/helpers/plugin.ts
@@ -1,5 +1,5 @@
import { Router } from '@angular/router';
-import { UdsApiService } from '../uds-api.service';
+import { UDSApiService } from '../uds-api.service';
/**
* Plugin manipulation class
@@ -14,10 +14,7 @@ enum BrowserType {
export class Plugin {
static transportsWindow: Window = null;
- constructor(private api: UdsApiService) {
- }
-
- private launchChrome(url: string) {
+ constructor(private api: UDSApiService) {
}
/**
@@ -28,6 +25,14 @@ export class Plugin {
* unless bypassPluginDetection is FALSE
*/
private doLaunch(url: string) {
+ this.api.gui.alert(
+ django.gettext('Launching service'),
+ '' + django.gettext('Please wait') + '
' +
+ django.gettext('Remember that UDS Plugin is required in order for this service to be launched') +
+ '
',
+ 5000
+ );
+
let elem = document.getElementById('hiddenUdsLauncherIFrame');
if (elem === null) {
const i = document.createElement('div');
@@ -36,27 +41,6 @@ export class Plugin {
document.body.appendChild(i);
elem = document.getElementById('hiddenUdsLauncherIFrame');
}
-
- elem.focus();
- this.api.gui.alert(
- django.gettext('Launching service'),
- 'UDS is trying to launch your service.
UDS Plugin is required
',
- 5000
- );
-
- /*let launched = false;
- launched = true;
- window.onblur = () => {
- console.log('Plugin seems to be installed');
- window.onblur = null;
- launched = true;
- };
- window.setTimeout(() => {
- window.onblur = null;
- if (launched === false && this.api.config.bypassPluginDetection === false) {
- this.api.router.navigate(['client-download']);
- }
- }, 2800);*/
(elem).contentWindow.location.href = url;
}
diff --git a/src/app/modules/app-material.module.ts b/src/app/modules/app-material.module.ts
index 185ff90..fcca084 100644
--- a/src/app/modules/app-material.module.ts
+++ b/src/app/modules/app-material.module.ts
@@ -1,5 +1,12 @@
import { NgModule } from '@angular/core';
-import {MatToolbarModule, MatButtonModule, MatMenuModule, MatTooltipModule, MatExpansionModule } from '@angular/material';
+import {
+ MatToolbarModule,
+ MatButtonModule,
+ MatMenuModule,
+ MatTooltipModule,
+ MatExpansionModule,
+ MatDialogModule,
+} from '@angular/material';
@NgModule({
imports: [
@@ -8,6 +15,7 @@ import {MatToolbarModule, MatButtonModule, MatMenuModule, MatTooltipModule, MatE
MatMenuModule,
MatTooltipModule,
MatExpansionModule,
+ MatDialogModule,
],
exports: [
MatToolbarModule,
@@ -15,6 +23,7 @@ import {MatToolbarModule, MatButtonModule, MatMenuModule, MatTooltipModule, MatE
MatMenuModule,
MatTooltipModule,
MatExpansionModule,
+ MatDialogModule,
]
})
export class AppMaterialModule { }
diff --git a/src/app/pages/client-download/client-download.component.ts b/src/app/pages/client-download/client-download.component.ts
index 918f98e..6022f67 100644
--- a/src/app/pages/client-download/client-download.component.ts
+++ b/src/app/pages/client-download/client-download.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { UdsApiService } from '../../uds-api.service';
+import { UDSApiService } from '../../uds-api.service';
import { Downloadable } from '../../types/config';
@Component({
@@ -11,7 +11,7 @@ export class ClientDownloadComponent implements OnInit {
plugins: Downloadable[];
- constructor(public api: UdsApiService) {
+ constructor(public api: UDSApiService) {
}
ngOnInit() {
diff --git a/src/app/pages/login/login.component.ts b/src/app/pages/login/login.component.ts
index dffef95..4a735b7 100644
--- a/src/app/pages/login/login.component.ts
+++ b/src/app/pages/login/login.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { UdsApiService } from '../../uds-api.service';
+import { UDSApiService } from '../../uds-api.service';
import { Authenticator } from '../../types/config';
@Component({
@@ -11,7 +11,7 @@ export class LoginComponent implements OnInit {
auths: Authenticator[];
visible: boolean;
- constructor(public api: UdsApiService) {
+ constructor(public api: UDSApiService) {
this.auths = api.config.authenticators.slice(0);
// Sort array, so we can display it correctly
this.auths.sort((a, b) => a.priority - b.priority);
diff --git a/src/app/pages/services/services.component.ts b/src/app/pages/services/services.component.ts
index 1950c76..43b3855 100644
--- a/src/app/pages/services/services.component.ts
+++ b/src/app/pages/services/services.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
-import { UdsApiService } from '../../uds-api.service';
+import { UDSApiService } from '../../uds-api.service';
import { JSONServicesInformation, JSONGroup, JSONService } from '../../types/services';
import { Plugin } from '../../helpers/plugin';
@@ -19,10 +19,8 @@ class GroupedServices {
export class ServicesComponent implements OnInit {
servicesInformation: JSONServicesInformation;
group: GroupedServices[];
- plugin: Plugin;
- constructor(private api: UdsApiService) {
- this.plugin = new Plugin(api);
+ constructor(private api: UDSApiService) {
}
/**
@@ -34,7 +32,7 @@ export class ServicesComponent implements OnInit {
if (!this.servicesInformation.services[0].maintenance) {
this.api.executeCustomJSForServiceLaunch();
// Launch url
- this.plugin.launchURL(this.servicesInformation.services[0].transports[0].link);
+ this.api.launchURL(this.servicesInformation.services[0].transports[0].link);
return true;
} else {
this.api.gui.alert(django.gettext('Warning'), django.gettext('Service is in maintenance and cannot be executed'));
diff --git a/src/app/uds-api.service.ts b/src/app/uds-api.service.ts
index d7b90aa..9f8b303 100644
--- a/src/app/uds-api.service.ts
+++ b/src/app/uds-api.service.ts
@@ -4,16 +4,19 @@ import { Router } from '@angular/router';
import { User, UDSConfig, Downloadable } from './types/config';
import { Observable } from 'rxjs';
import { JSONServicesInformation, JSONEnabledService } from './types/services';
-import { GuiService } from './gui/gui.service';
+import { UDSGuiService } from './gui/uds-gui.service';
+import { Plugin } from './helpers/plugin';
@Injectable()
-export class UdsApiService {
+export class UDSApiService {
readonly user: User;
transportsWindow: Window;
+ plugin: Plugin;
- constructor(private http: HttpClient, public gui: GuiService, public router: Router) {
+ constructor(private http: HttpClient, public gui: UDSGuiService, public router: Router) {
this.user = new User(udsData.profile);
this.transportsWindow = null;
+ this.plugin = new Plugin(this);
}
/**
@@ -58,6 +61,10 @@ export class UdsApiService {
}
}
+ launchURL(udsURL): void {
+ this.plugin.launchURL(udsURL);
+ }
+
/**
* Gets auth custom html code
* @param authId if of the authenticator