Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 5caf4a7

Browse files
klopfdrehjvalkeal
authored andcommitted
Fix dynamic base path resolving
- Essentially calculates needed asset and api paths from a window and uses those dynamically. - Fixes #747 Generic polish for a PR: - Removed change to compodoc dep as dep updates should not get done with generic PR's - Don't update lock file - Removed use of APP_BASE_HREF which then made LeadingBaseHrefLocationStrategy defunct - Restored path redirect from '' to 'apps' - Fixed most of linting errors and left indentation errors in place as there's a know default conflict with prettier/eslint which needs to be fixed later - We now get links like http://localhost:9393/scdf/dashboard/index.html#/apps - Hard reload now works - Generic polish
1 parent 63b624d commit 5caf4a7

23 files changed

+205
-96
lines changed

ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"e2e-browserstack-local": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng e2e --host dataflow.local --protractor-config ./e2e/protractor-browserstack.conf.js --configuration production",
1717
"doc": "./node_modules/.bin/compodoc -p tsconfig.json -n \"Spring Cloud Data Flow Dashboard Documentation\"",
1818
"mavenbuild-tests": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng test --code-coverage true --watch false --browsers ChromeCustom",
19-
"mavenbuild-without-tests": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --configuration production --output-path ./../target/classes/public/dashboard --base-href /dashboard/",
20-
"mavenbuild": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng test --code-coverage true --watch false --browsers ChromeHeadless && --max_old_space_size=4096 node ./node_modules/@angular/cli/bin/ng build --configuration production --output-path ./../target/classes/public/dashboard --base-href /dashboard/",
19+
"mavenbuild-without-tests": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --configuration production --output-path ./../target/classes/public/dashboard",
20+
"mavenbuild": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng test --code-coverage true --watch false --browsers ChromeHeadless && --max_old_space_size=4096 node ./node_modules/@angular/cli/bin/ng build --configuration production --output-path ./../target/classes/public/dashboard",
2121
"bundle-report": "ng build --stats-json && webpack-bundle-analyzer dist/stats.json"
2222
},
2323
"private": true,

ui/src/app/app-routing.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {NgModule} from '@angular/core';
22
import {Routes, RouterModule} from '@angular/router';
3-
import {DevGuard} from './shared/support/dev.guard';
43

54
const routes: Routes = [
65
{

ui/src/app/flo/shared/support/shared-shapes.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {dia} from 'jointjs';
22
import * as _joint from 'jointjs';
3+
import {UrlUtilities} from '../../../url-utilities.service';
34

45
import {loadShapes} from 'spring-flo';
56

@@ -159,16 +160,30 @@ export function createPaletteGroupHeader(title: string, isOpen: boolean): any {
159160
'.group-label-bg/class',
160161
`${group.attr('.group-label-bg/class') || 'group-label-bg'} ${title.replace(' ', '-')}`
161162
);
162-
group.attr('.collapse-handle/xlink:href', isOpen ? 'assets/img/chevron-down.svg' : 'assets/img/chevron-left.svg');
163+
group.attr(
164+
'.collapse-handle/xlink:href',
165+
isOpen
166+
? UrlUtilities.calculateAssetUrl() + 'img/chevron-down.svg'
167+
: UrlUtilities.calculateAssetUrl() + 'img/chevron-left.svg'
168+
);
163169
group.attr(
164170
'.collapse-handle2/xlink:href',
165-
isOpen ? 'assets/img/chevron-down-white.svg' : 'assets/img/chevron-left-white.svg'
171+
isOpen
172+
? UrlUtilities.calculateAssetUrl() + 'img/chevron-down-white.svg'
173+
: UrlUtilities.calculateAssetUrl() + 'img/chevron-left-white.svg'
166174
);
167175
group.on('change:isOpen', (cell, newValue) => {
168-
group.attr('.collapse-handle/xlink:href', newValue ? 'assets/img/chevron-down.svg' : 'assets/img/chevron-left.svg');
176+
group.attr(
177+
'.collapse-handle/xlink:href',
178+
newValue
179+
? UrlUtilities.calculateAssetUrl() + 'img/chevron-down.svg'
180+
: UrlUtilities.calculateAssetUrl() + 'img/chevron-left.svg'
181+
);
169182
group.attr(
170183
'.collapse-handle2/xlink:href',
171-
newValue ? 'assets/img/chevron-down-white.svg' : 'assets/img/chevron-left-white.svg'
184+
newValue
185+
? UrlUtilities.calculateAssetUrl() + 'img/chevron-down-white.svg'
186+
: UrlUtilities.calculateAssetUrl() + 'img/chevron-left-white.svg'
172187
);
173188
});
174189
return group;

ui/src/app/flo/stream/content-assist.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {HttpClient, HttpParams} from '@angular/common/http';
33
import {Observable} from 'rxjs';
44
import {map} from 'rxjs/operators';
55
import {HttpUtils} from '../../shared/support/http.utils';
6+
import {UrlUtilities} from '../../url-utilities.service';
67

78
@Injectable()
89
export class ContentAssistService {
@@ -12,7 +13,7 @@ export class ContentAssistService {
1213
const headers = HttpUtils.getDefaultHttpHeaders();
1314
const params = new HttpParams().append('start', prefix).append('defaultLevel', '1');
1415
return this.httpClient
15-
.get<any>('/completions/stream', {headers, params})
16+
.get<any>(UrlUtilities.calculateBaseApiUrl() + 'completions/stream', {headers, params})
1617
.pipe(map(jsonResponse => jsonResponse.proposals));
1718
}
1819
}

ui/src/app/flo/stream/node-helper.service.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {dia} from 'jointjs';
1919
import {Flo} from 'spring-flo';
2020
import {Utils as SharedUtils} from '../shared/support/utils';
2121
import {ApplicationType} from '../../shared/model/app.model';
22+
import {UrlUtilities} from '../../url-utilities.service';
2223

2324
import * as _joint from 'jointjs';
2425
const joint: any = _joint;
@@ -30,13 +31,13 @@ const BETWEEN_HANDLE_SPACING = 5;
3031

3132
// Default icons (unicode chars) for each group member, unless they override
3233
const GROUP_ICONS = new Map<string, string>()
33-
.set('app', 'assets/img/app.svg') // U+2338 (Quad equal symbol)
34-
.set('source', 'assets/img/source.svg') // 21D2
35-
.set('processor', 'assets/img/processor.svg') // 3bb //flux capacitor? 1D21B
36-
.set('sink', 'assets/img/sink.svg') // 21D2
37-
.set('task', 'assets/img/unknown.svg') // 2609 ⚙=2699 gear (rubbish)
38-
.set('other', 'assets/img/tap.svg') // 2982
39-
.set('unresolved', 'assets/img/unknown.svg'); // 2982
34+
.set('app', UrlUtilities.calculateAssetUrl() + 'img/app.svg') // U+2338 (Quad equal symbol)
35+
.set('source', UrlUtilities.calculateAssetUrl() + 'img/source.svg') // 21D2
36+
.set('processor', UrlUtilities.calculateAssetUrl() + 'img/processor.svg') // 3bb //flux capacitor? 1D21B
37+
.set('sink', UrlUtilities.calculateAssetUrl() + 'img/sink.svg') // 21D2
38+
.set('task', UrlUtilities.calculateAssetUrl() + 'img/unknown.svg') // 2609 ⚙=2699 gear (rubbish)
39+
.set('other', UrlUtilities.calculateAssetUrl() + 'img/tap.svg') // 2982
40+
.set('unresolved', UrlUtilities.calculateAssetUrl() + 'img/unknown.svg'); // 2982
4041
/**
4142
* Node Helper for Flo based Stream Definition graph editor.
4243
* Static utility method for creating joint model objects.

ui/src/app/flo/stream/node/stream-node.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
</svg:g>
3939
<svg:image
4040
class="error-marker"
41-
xlink:href="assets/img/error.svg"
41+
xlink:href=""
42+
ng-href="{{ assetUrl }}img/error.svg"
4243
tippy
4344
[content]="markerTooltipElement ? markerTooltipElement.nativeElement : ''"
4445
[tippyOptions]="{appendTo: docBody(), placement: 'top', theme: 'error'}"

ui/src/app/flo/stream/node/stream-node.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {dia} from 'jointjs';
33
import {NodeComponent} from '../../shared/support/node-component';
44
import {DocService} from '../../shared/service/doc.service';
55
import {PropertiesEditor} from '../properties-editor.service';
6+
import {UrlUtilities} from '../../../url-utilities.service';
67

78
/**
89
* Component for displaying application properties and capturing their values.
@@ -26,6 +27,8 @@ export class StreamNodeComponent extends NodeComponent {
2627
@ViewChild('paletteNodeTooltip')
2728
paletteTooltipElement: ElementRef;
2829

30+
assetUrl = UrlUtilities.calculateAssetUrl();
31+
2932
constructor(docService: DocService, private propertiesEditor: PropertiesEditor) {
3033
super(docService);
3134
}

ui/src/app/flo/stream/support/shapes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as _joint from 'jointjs';
2+
import {UrlUtilities} from '../../../url-utilities.service';
23

34
const joint: any = _joint;
45

@@ -98,7 +99,7 @@ export function loadStreamShapes(): void {
9899
refX: 10,
99100
refY: 0.5,
100101
refY2: -TYPE_ICON_SIZE.height / 2,
101-
'xlink:href': 'assets/img/unknown.svg'
102+
'xlink:href': UrlUtilities.calculateAssetUrl() + 'img/unknown.svg'
102103
},
103104
'.error-marker': {
104105
width: ERROR_MARKER_SIZE.width,

ui/src/app/flo/task/content-assist.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {HttpClient, HttpParams} from '@angular/common/http';
33
import {Observable} from 'rxjs';
44
import {map} from 'rxjs/operators';
55
import {HttpUtils} from '../../shared/support/http.utils';
6+
import {UrlUtilities} from '../../url-utilities.service';
67

78
@Injectable()
89
export class ContentAssistService {
@@ -12,7 +13,7 @@ export class ContentAssistService {
1213
const headers = HttpUtils.getDefaultHttpHeaders();
1314
const params = new HttpParams().append('start', prefix).append('defaultLevel', '1');
1415
return this.httpClient
15-
.get<any>('/completions/task', {headers, params})
16+
.get<any>(UrlUtilities.calculateBaseApiUrl() + 'completions/task', {headers, params})
1617
.pipe(map(jsonResponse => jsonResponse.proposals));
1718
}
1819
}

ui/src/app/flo/task/node/task-node.component.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
<svg:text class="name-label" />
1515
<svg:image
1616
class="error-marker"
17-
xlink:href="assets/img/error.svg"
17+
xlink:href=""
18+
ng-href="{{ assetUrl }}img/error.svg"
1819
tippy
1920
[content]="markerTooltipElement ? markerTooltipElement.nativeElement : ''"
2021
[tippyOptions]="{appendTo: docBody(), placement: 'top', theme: 'error'}"
@@ -40,7 +41,8 @@
4041
<svg:text class="name-label" />
4142
<svg:image
4243
class="error-marker"
43-
xlink:href="assets/img/error.svg"
44+
xlink:href=""
45+
ng-href="{{ assetUrl }}img/error.svg"
4446
tippy
4547
[content]="markerTooltipElement ? markerTooltipElement.nativeElement : ''"
4648
[tippyOptions]="{appendTo: docBody(), placement: 'top', theme: 'error'}"
@@ -103,7 +105,8 @@
103105
</svg:g>
104106
<svg:image
105107
class="error-marker"
106-
xlink:href="assets/img/error.svg"
108+
xlink:href=""
109+
ng-href="{{ assetUrl }}img/error.svg"
107110
tippy
108111
[content]="markerTooltipElement ? markerTooltipElement.nativeElement : ''"
109112
[tippyOptions]="{appendTo: docBody(), placement: 'top', theme: 'error'}"
@@ -154,7 +157,8 @@
154157
</svg:g>
155158
<svg:image
156159
class="error-marker"
157-
xlink:href="assets/img/error.svg"
160+
xlink:href=""
161+
ng-href="{{ assetUrl }}img/error.svg"
158162
tippy
159163
[content]="markerTooltipElement ? markerTooltipElement.nativeElement : ''"
160164
[tippyOptions]="{appendTo: docBody(), placement: 'top', theme: 'error'}"

0 commit comments

Comments
 (0)