Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
oodamien committed Jul 3, 2023
1 parent c4e41f9 commit 1b9c043
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 102 deletions.
175 changes: 90 additions & 85 deletions ui/proxy.conf.json
Original file line number Diff line number Diff line change
@@ -1,87 +1,92 @@
{
"/about" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/audit-records" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/authenticate" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/apps" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/dashboard/logout" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/jobs" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/oauth2" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/login" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/logout" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/metrics" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/security/info" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/streams" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/tasks" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/tools" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/runtime" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/completions" : {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/websocket": {
"target": "http://localhost:9393",
"ws": true,
"logLevel": "debug"
}
"/about": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/audit-records": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/authenticate": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/apps": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/dashboard/logout": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/jobs": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/oauth2": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/login": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/logout": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/metrics": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/security/info": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/streams": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/tasks": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/tools": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/runtime": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/completions": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
},
"/websocket": {
"target": "http://localhost:9393",
"ws": true,
"logLevel": "debug"
},
"/schema": {
"target": "http://localhost:9393/",
"secure": false,
"logLevel": "debug"
}
}
3 changes: 1 addition & 2 deletions ui/src/app/apps/add/register/register.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@
<label class="clr-col-2 clr-control-label" for="type{{ i }}">{{
'applications.main.bootVersion' | translate
}}</label>
<div class="clr-control-container clr-col-10">
<div class="clr-control-container clr-col-10" *ngIf="bootVersions">
<div class="clr-select-wrapper">
<select
name="bootVersion{{ i }}"
id="bootVersion{{ i }}"
formControlName="bootVersion"
class="clr-select"
>
<option value="">{{ 'applications.main.bootVersionPlaceholder' | translate }}</option>
<option *ngFor="let bootVersionKey of bootVersions" value="{{ bootVersionKey }}">
Spring Boot {{ bootVersionKey }}
</option>
Expand Down
25 changes: 18 additions & 7 deletions ui/src/app/apps/add/register/register.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,24 @@ describe('apps/register/register.component.ts', () => {
const navigate = spyOn((<any>component).router, 'navigateByUrl');
fixture.detectChanges();
const tests = [
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', force: false},
{name: '', type: '', uri: '', metaDataUri: '', force: false},
{name: '', type: '', uri: '', metaDataUri: '', force: false}
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', bootVersion: '3', force: false},
{name: '', type: '', uri: '', metaDataUri: '', bootVersion: '2', force: false},
{name: '', type: '', uri: '', metaDataUri: '', bootVersion: '2', force: false}
];
component.newForm();
component.newForm();
tests.forEach((test, index) => {
component.forms[index].get('name').setValue(test.name);
component.forms[index].get('type').setValue(test.type);
component.forms[index].get('uri').setValue(test.uri);
component.forms[index].get('bootVersion').setValue(test.bootVersion);
component.forms[index].get('metaDataUri').setValue(test.metaDataUri);
component.forms[index].get('force').setValue(test.force);
});
fixture.detectChanges();
fixture.debugElement.query(By.css('button[name=register]')).nativeElement.click();
fixture.detectChanges();

expect(component.isValid()).toBeTruthy();
expect(component.noValue()).toBeFalsy();
expect(NotificationServiceMock.mock.successNotifications[0].title).toContain('Register application(s).');
Expand All @@ -106,16 +108,17 @@ describe('apps/register/register.component.ts', () => {
it('should display errors form', () => {
fixture.detectChanges();
const tests = [
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', force: false},
{name: 'foobar2', type: 'sink', uri: 'https://foo.bar', metaDataUri: '', force: false},
{name: 'foobar3', type: 'processor', uri: '', metaDataUri: '', force: false}
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', bootVersion: '3', force: false},
{name: 'foobar2', type: 'sink', uri: 'https://foo.bar', metaDataUri: '', bootVersion: '2', force: false},
{name: 'foobar3', type: 'processor', uri: '', metaDataUri: '', bootVersion: '3', force: false}
];
component.newForm();
component.newForm();
tests.forEach((test, index) => {
component.forms[index].get('name').setValue(test.name);
component.forms[index].get('type').setValue(test.type);
component.forms[index].get('uri').setValue(test.uri);
component.forms[index].get('bootVersion').setValue(test.bootVersion);
component.forms[index].get('metaDataUri').setValue(test.metaDataUri);
component.forms[index].get('force').setValue(test.force);
});
Expand All @@ -129,10 +132,18 @@ describe('apps/register/register.component.ts', () => {
it('should handle error on run', () => {
spyOn(AppServiceMock.mock, 'registerProps').and.callFake(() => throwError(new Error('Fake error')));
fixture.detectChanges();
const test = {name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', force: false};
const test = {
name: 'foobar1',
type: 'source',
uri: 'https://foo.bar',
metaDataUri: '',
bootVersion: '3',
force: false
};
component.forms[0].get('name').setValue(test.name);
component.forms[0].get('type').setValue(test.type);
component.forms[0].get('uri').setValue(test.uri);
component.forms[0].get('bootVersion').setValue(test.bootVersion);
component.forms[0].get('metaDataUri').setValue(test.metaDataUri);
component.forms[0].get('force').setValue(test.force);
fixture.detectChanges();
Expand Down
13 changes: 9 additions & 4 deletions ui/src/app/apps/add/register/register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {TranslateService} from '@ngx-translate/core';
export class RegisterComponent implements OnInit {
forms: UntypedFormGroup[] = [];
applicationTypes = ApplicationType;
bootVersions = ['2', '3'];
bootVersions: Array<string>;
defaultBoot: string;
submitted = false;
isImporting = false;

Expand All @@ -27,7 +28,11 @@ export class RegisterComponent implements OnInit {
) {}

ngOnInit(): void {
this.newForm();
this.appService.getBootVersions().subscribe((data: any) => {
this.bootVersions = data.versions;
this.defaultBoot = data.defaultSchemaVersion;
this.newForm();
});
}

register(): void {
Expand Down Expand Up @@ -105,7 +110,7 @@ export class RegisterComponent implements OnInit {
form.get('name').hasError('required') &&
form.get('metaDataUri').value === '' &&
form.get('type').hasError('required') &&
form.get('bootVersion').hasError('required')
form.get('bootVersion').value === this.defaultBoot
);
}

Expand All @@ -116,7 +121,7 @@ export class RegisterComponent implements OnInit {
type: new UntypedFormControl('', Validators.required),
uri: new UntypedFormControl('', [AppsAddValidator.appUri, Validators.required]),
metaDataUri: new UntypedFormControl('', AppsAddValidator.appUri),
bootVersion: new UntypedFormControl('', Validators.required),
bootVersion: new UntypedFormControl(this.defaultBoot, Validators.required),
force: new UntypedFormControl(false)
});

Expand Down
12 changes: 12 additions & 0 deletions ui/src/app/shared/api/app.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ describe('shared/api/app.service.ts', () => {
expect(headerArgs.get('Accept')).toEqual('application/json');
});

it('getApp with spring boot version in parameter', () => {
mockHttp.get.and.returnValue(of(jsonData));
appService.getApp('foo', 'processor' as any as ApplicationType, '', '3');
const httpUri = mockHttp.get.calls.mostRecent().args[0];
const headerArgs = mockHttp.get.calls.mostRecent().args[1].headers;
expect(httpUri).toEqual('/apps/processor/foo?bootVersion=3');
expect(headerArgs.get('Content-Type')).toEqual('application/json');
expect(headerArgs.get('Accept')).toEqual('application/json');
});

it('getApp with version', () => {
mockHttp.get.and.returnValue(of(jsonData));
appService.getApp('foo', 'processor' as any as ApplicationType, '1.0.0');
Expand Down Expand Up @@ -100,6 +110,7 @@ describe('shared/api/app.service.ts', () => {
uri: 'https://uri.foo.bar',
metaDataUri: 'https://metaDataUri.foo.bar',
type: ApplicationType.processor,
bootVersion: '3',
force: true
});
const httpUri = mockHttp.post.calls.mostRecent().args[0];
Expand All @@ -110,6 +121,7 @@ describe('shared/api/app.service.ts', () => {
expect(headerArgs.get('Accept')).toEqual('application/json');
expect(httpParams.get('uri')).toEqual('https://uri.foo.bar');
expect(httpParams.get('metadata-uri')).toEqual('https://metaDataUri.foo.bar');
expect(httpParams.get('bootVersion')).toEqual('3');
expect(httpParams.get('force')).toEqual('true');
});

Expand Down
22 changes: 18 additions & 4 deletions ui/src/app/shared/api/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ export class AppService {
.pipe(map(AppPage.parse), catchError(ErrorUtils.catchError));
}

getApp(name: string, type: ApplicationType, appVersion?: string, bootVersion?: string): Observable<DetailedApp | unknown> {
getApp(
name: string,
type: ApplicationType,
appVersion?: string,
bootVersion?: string
): Observable<DetailedApp | unknown> {
const headers = HttpUtils.getDefaultHttpHeaders();
const bootVersionConfig = bootVersion ? `?bootVersion=${bootVersion}` : ``;
let url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}${bootVersion && bootVersionConfig}`;
let url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}${bootVersionConfig}`;
if (appVersion) {
url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}/${appVersion}${bootVersion && bootVersionConfig}`;
url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}/${appVersion}${bootVersionConfig}`;
}
return this.httpClient.get(url, {headers}).pipe(map(DetailedApp.parse), catchError(ErrorUtils.catchError));
}
Expand All @@ -60,6 +65,12 @@ export class AppService {
);
}

getBootVersions(): Observable<any> {
const headers = HttpUtils.getDefaultHttpHeaders();
const url = UrlUtilities.calculateBaseApiUrl() + `schema/versions`;
return this.httpClient.get(url, {headers}).pipe(catchError(ErrorUtils.catchError));
}

unregisterApp(app: App): Observable<any> {
const headers = HttpUtils.getDefaultHttpHeaders();
let url = UrlUtilities.calculateBaseApiUrl() + `apps/${app.type}/${app.name}`;
Expand Down Expand Up @@ -97,7 +108,10 @@ export class AppService {
}

registerProp(prop: any): Observable<any> {
let params = new HttpParams().append('uri', prop.uri).append('force', prop.force.toString());
let params = new HttpParams()
.append('uri', prop.uri)
.append('force', prop.force.toString())
.append('bootVersion', prop.bootVersion);
if (prop.metaDataUri) {
params = params.append('metadata-uri', prop.metaDataUri);
}
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/tests/api/app.service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ export class AppServiceMock {
return of(GET_APP).pipe(delay(1), map(DetailedApp.parse), catchError(ErrorUtils.catchError));
}

getBootVersions(): Observable<any> {
return of({
defaultSchemaVersion: '2',
versions: ['2', '3']
});
}

getAppVersions(name: string, type: ApplicationType): Observable<App[]> {
return of(GET_APP_VERSIONS).pipe(
map(AppPage.parse),
Expand Down

0 comments on commit 1b9c043

Please sign in to comment.