Skip to content

Commit 2366111

Browse files
committed
ui: attempt workaround for fortinet
1 parent d14768e commit 2366111

File tree

6 files changed

+55
-23
lines changed

6 files changed

+55
-23
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ root = true
55
[Makefile]
66
indent_style = tab
77

8-
[*.js]
8+
[*.js,*.ts]
99
indent_style = space
1010
indent_size = 2
1111

ui/src/client.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as client from './client/src';
2+
3+
4+
declare global {
5+
interface Window {
6+
enduro: any;
7+
fgt_sslvpn: any;
8+
}
9+
}
10+
11+
function apiPath(): string {
12+
const location = window.location;
13+
const path = location.protocol
14+
+ '//'
15+
+ location.hostname
16+
+ (location.port ? ':' + location.port : '')
17+
+ location.pathname
18+
+ (location.search ? location.search : '');
19+
20+
return path.replace(/\/$/, '');
21+
}
22+
23+
export let EnduroCollectionClient: client.CollectionApi;
24+
25+
export function setUpEnduroClient() {
26+
let path = apiPath();
27+
28+
// path seems to be wrong when Enduro is deployed behind FortiNet SSLVPN.
29+
// There is some URL rewriting going on that is beyond my understanding.
30+
// This is an attempt to rewrite the URL using their url_rewrite function.
31+
if (typeof window.fgt_sslvpn !== 'undefined') {
32+
path = window.fgt_sslvpn.url_rewrite(path);
33+
}
34+
35+
const config: client.Configuration = new client.Configuration({basePath: path});
36+
EnduroCollectionClient = new client.CollectionApi(config);
37+
38+
// tslint:disable-next-line:no-console
39+
console.log('Enduro client created', path);
40+
}
41+
42+
window.enduro = {
43+
// As a last resort, user could run window.enduro.reload() from console?
44+
reload: () => {
45+
setUpEnduroClient();
46+
},
47+
};

ui/src/components/CollectionDetail.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
<script lang="ts">
7575
import { CollectionShowResponseBody } from '../client/src';
76-
import { EnduroCollectionClient } from '../main';
76+
import { EnduroCollectionClient } from '../client';
7777
import { Component, Inject, Prop, Provide, Vue } from 'vue-property-decorator';
7878
import CollectionStatusBadge from '@/components/CollectionStatusBadge.vue';
7979

ui/src/components/CollectionList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
<script lang="ts">
3939
import { Component, Prop, Provide, Vue } from 'vue-property-decorator';
40-
import { EnduroCollectionClient } from '../main';
40+
import { EnduroCollectionClient } from '../client';
4141
import CollectionStatusBadge from '@/components/CollectionStatusBadge.vue';
4242
import { CollectionListRequest, CollectionListResponseBody, EnduroStoredCollectionResponseBodyCollection } from '../client/src';
4343

ui/src/main.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,7 @@ import App from './App.vue';
33
import router from './router';
44
import store from './store';
55
import BootstrapVue from 'bootstrap-vue';
6-
import * as client from './client/src';
7-
8-
function apiPath(): string {
9-
const location = window.location;
10-
const path = location.protocol
11-
+ '//'
12-
+ location.hostname
13-
+ (location.port ? ':' + location.port : '')
14-
+ location.pathname
15-
+ (location.search ? location.search : '');
16-
17-
return path.replace(/\/$/, '');
18-
}
19-
20-
console.log(apiPath());
21-
22-
export let EnduroCollectionClient = new client.CollectionApi(
23-
new client.Configuration({basePath: apiPath()},
24-
));
6+
import { EnduroCollectionClient, setUpEnduroClient } from './client';
257

268
Vue.use(BootstrapVue);
279

@@ -45,4 +27,7 @@ new Vue({
4527
router,
4628
store,
4729
render: (h) => h(App),
30+
beforeMount: () => {
31+
setUpEnduroClient();
32+
},
4833
}).$mount('#app');

ui/src/views/CollectionWorkflow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
<script lang="ts">
6161
import { Component, Prop, Provide, Vue } from 'vue-property-decorator';
62-
import { EnduroCollectionClient } from '../main';
62+
import { EnduroCollectionClient } from '../client';
6363
import CollectionStatusBadge from '@/components/CollectionStatusBadge.vue';
6464
import { CollectionShowResponseBody, CollectionWorkflowResponseBody, EnduroCollectionWorkflowHistoryResponseBody } from '../client/src';
6565

0 commit comments

Comments
 (0)