mirror of
https://github.com/dkmstr/openuds-gui.git
synced 2025-01-03 05:17:36 +03:00
lauhchenr seems to work
This commit is contained in:
parent
69eac69a55
commit
2d3dd65b8d
@ -1,3 +1,4 @@
|
|||||||
|
import { Router } from '@angular/router';
|
||||||
import { UdsApiService } from '../uds-api.service';
|
import { UdsApiService } from '../uds-api.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,27 +13,21 @@ enum BrowserType {
|
|||||||
|
|
||||||
export class Plugin {
|
export class Plugin {
|
||||||
static transportsWindow: Window = null;
|
static transportsWindow: Window = null;
|
||||||
browser: BrowserType;
|
|
||||||
|
|
||||||
constructor(private api: UdsApiService) {
|
constructor(private api: UdsApiService, private router: Router) {
|
||||||
const ua = navigator.userAgent.toLowerCase();
|
|
||||||
if (ua.indexOf('safari') !== -1) {
|
|
||||||
if (ua.indexOf('chrome') !== -1) {
|
|
||||||
this.browser = BrowserType.chrome;
|
|
||||||
} else {
|
|
||||||
this.browser = BrowserType.safari;
|
|
||||||
}
|
|
||||||
} else if (ua.indexOf('msie ') !== -1 || ua.indexOf('trident/') !== -1) {
|
|
||||||
this.browser = BrowserType.ie;
|
|
||||||
} else {
|
|
||||||
this.browser = BrowserType.firefox;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private launchChrome(url: string) {
|
private launchChrome(url: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private launchFirefox(url: string): boolean {
|
/**
|
||||||
|
* Launches an UDS related url
|
||||||
|
* @param url uds url to be lauhcned
|
||||||
|
*
|
||||||
|
* If the plugin cannon detect the correct launch of the UDS plugin, will redirect to plugin page
|
||||||
|
* unless bypassPluginDetection is FALSE
|
||||||
|
*/
|
||||||
|
private doLaunch(url: string) {
|
||||||
let elem = document.getElementById('hiddenUdsLauncherIFrame');
|
let elem = document.getElementById('hiddenUdsLauncherIFrame');
|
||||||
if (elem === null) {
|
if (elem === null) {
|
||||||
const i = document.createElement('div');
|
const i = document.createElement('div');
|
||||||
@ -41,43 +36,22 @@ export class Plugin {
|
|||||||
document.body.appendChild(i);
|
document.body.appendChild(i);
|
||||||
elem = document.getElementById('hiddenUdsLauncherIFrame');
|
elem = document.getElementById('hiddenUdsLauncherIFrame');
|
||||||
}
|
}
|
||||||
console.log('Launching ', url);
|
|
||||||
try {
|
elem.focus();
|
||||||
(<any>elem).contentWindow.location.href = url;
|
|
||||||
} catch (e) {
|
let launched = false;
|
||||||
if (e.name === 'NS_ERROR_UNKNOWN_PROTOCOL') {
|
window.onblur = () => {
|
||||||
return false;
|
console.log('Plugin seems to be installed');
|
||||||
|
window.onblur = null;
|
||||||
|
launched = true;
|
||||||
|
};
|
||||||
|
(<any>elem).contentWindow.location.href = url;
|
||||||
|
window.setTimeout(() => {
|
||||||
|
window.onblur = null;
|
||||||
|
if (launched === false && this.api.config.bypassPluginDetection === false) {
|
||||||
|
this.router.navigate(['client-download']);
|
||||||
}
|
}
|
||||||
}
|
}, 2800);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private launchSafari(url: string): boolean {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private launchIe(url: string): boolean {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private doLaunch(url: string) {
|
|
||||||
switch (this.browser) {
|
|
||||||
case BrowserType.chrome:
|
|
||||||
this.launchChrome(url);
|
|
||||||
break;
|
|
||||||
case BrowserType.firefox:
|
|
||||||
this.launchFirefox(url);
|
|
||||||
break;
|
|
||||||
case BrowserType.ie:
|
|
||||||
this.launchIe(url);
|
|
||||||
break;
|
|
||||||
case BrowserType.safari:
|
|
||||||
this.launchSafari(url);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
window.location.href = url;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
launchURL(url: string): void {
|
launchURL(url: string): void {
|
||||||
@ -92,11 +66,7 @@ export class Plugin {
|
|||||||
// Ensures that protocol is https also for plugin, fixing if needed UDS provided info
|
// Ensures that protocol is https also for plugin, fixing if needed UDS provided info
|
||||||
data.url = data.url.replace('uds://', 'udss://');
|
data.url = data.url.replace('uds://', 'udss://');
|
||||||
}
|
}
|
||||||
if (this.api.config.bypassPluginDetection === false) {
|
this.doLaunch(data.url);
|
||||||
this.doLaunch(data.url);
|
|
||||||
} else {
|
|
||||||
window.location.href = data.url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,7 +14,7 @@ export class ServicesComponent implements OnInit {
|
|||||||
plugin: Plugin;
|
plugin: Plugin;
|
||||||
|
|
||||||
constructor(private api: UdsApiService, private router: Router) {
|
constructor(private api: UdsApiService, private router: Router) {
|
||||||
this.plugin = new Plugin(api);
|
this.plugin = new Plugin(api, router);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -4,6 +4,7 @@ import { Router } from '@angular/router';
|
|||||||
import { User, UDSConfig, Downloadable } from './types/config';
|
import { User, UDSConfig, Downloadable } from './types/config';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { JSONServicesInformation, JSONEnabledService } from './types/services';
|
import { JSONServicesInformation, JSONEnabledService } from './types/services';
|
||||||
|
import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UdsApiService {
|
export class UdsApiService {
|
||||||
|
Loading…
Reference in New Issue
Block a user