-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ root = true | |
[Makefile] | ||
indent_style = tab | ||
|
||
[*.js] | ||
[*.js,*.ts] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as client from './client/src'; | ||
|
||
|
||
declare global { | ||
interface Window { | ||
enduro: any; | ||
fgt_sslvpn: any; | ||
} | ||
} | ||
|
||
function apiPath(): string { | ||
const location = window.location; | ||
const path = location.protocol | ||
+ '//' | ||
+ location.hostname | ||
+ (location.port ? ':' + location.port : '') | ||
+ location.pathname | ||
+ (location.search ? location.search : ''); | ||
|
||
return path.replace(/\/$/, ''); | ||
} | ||
|
||
export let EnduroCollectionClient: client.CollectionApi; | ||
|
||
export function setUpEnduroClient() { | ||
let path = apiPath(); | ||
|
||
// path seems to be wrong when Enduro is deployed behind FortiNet SSLVPN. | ||
// There is some URL rewriting going on that is beyond my understanding. | ||
// This is an attempt to rewrite the URL using their url_rewrite function. | ||
if (typeof window.fgt_sslvpn !== 'undefined') { | ||
path = window.fgt_sslvpn.url_rewrite(path); | ||
} | ||
|
||
const config: client.Configuration = new client.Configuration({basePath: path}); | ||
EnduroCollectionClient = new client.CollectionApi(config); | ||
|
||
// tslint:disable-next-line:no-console | ||
console.log('Enduro client created', path); | ||
} | ||
|
||
window.enduro = { | ||
// As a last resort, user could run window.enduro.reload() from console? | ||
reload: () => { | ||
setUpEnduroClient(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters