Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update SCDF-UI to use the latest APIs #2026

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions ui/src/app/about/info/info.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ <h3>{{ 'about.info.runtimeSkipperDeployer' | translate }}</h3>
<strong>{{ 'about.info.platformType' | translate }}: </strong>
{{ about.runtimeEnvironment.appDeployer.platformType || 'N/A' }}
</li>
<li>
<strong>{{ 'about.info.springBootVersion' | translate }}: </strong>
{{ about.runtimeEnvironment.appDeployer.springBootVersion || 'N/A' }}
</li>
<li>
<strong>{{ 'about.info.springVersion' | translate }}: </strong>
{{ about.runtimeEnvironment.appDeployer.springVersion || 'N/A' }}
Expand Down Expand Up @@ -203,9 +199,6 @@ <h3>{{ 'about.info.runtimeTaskLauncher' | translate }}</h3>
<li>
<strong>{{ 'about.info.platformType' | translate }}: </strong> {{ item.platformType }}
</li>
<li>
<strong>{{ 'about.info.springBootVersion' | translate }}: </strong> {{ item.springBootVersion }}
</li>
<li>
<strong>{{ 'about.info.springVersion' | translate }}: </strong> {{ item.springVersion }}
</li>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {AppsModule} from './apps/apps.module';
import {UrlUtilities} from './url-utilities.service';
import {TaskService} from './shared/api/task.service';
import {JobService} from './shared/api/job.service';
import {DevModule} from './dev/dev.module';

@NgModule({
declarations: [AppComponent],
Expand All @@ -44,7 +45,7 @@ import {JobService} from './shared/api/job.service';
FormsModule,
LayoutModule,
// DashboardModule,
// DevModule,
DevModule,
StreamsModule,
TasksJobsModule,
ManageModule,
Expand Down
26 changes: 0 additions & 26 deletions ui/src/app/apps/add/register/register.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,6 @@
</div>
</div>
</div>
<div
class="clr-form-control clr-row"
[class.clr-error]="submitted && form.get('bootVersion').invalid && !isFormEmpty(form)"
>
<label class="clr-col-2 clr-control-label" for="type{{ i }}">{{
'applications.main.bootVersion' | translate
}}</label>
<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 *ngFor="let bootVersionKey of bootVersions" value="{{ bootVersionKey }}">
Spring Boot&nbsp;
{{ 'applications.main.bootVersions.' + bootVersionKey | translate }}
</option>
</select>
</div>
<div class="clr-subtext" *ngIf="submitted && form.get('type').invalid && !isFormEmpty(form)">
{{ 'applications.add.register.invalidType' | translate }}
</div>
</div>
</div>
<div
class="clr-form-control clr-row"
[class.clr-error]="submitted && form.get('uri').invalid && !isFormEmpty(form)"
Expand Down
16 changes: 6 additions & 10 deletions ui/src/app/apps/add/register/register.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,16 @@ 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: '', bootVersion: '3', force: false},
{name: '', type: '', uri: '', metaDataUri: '', bootVersion: '2', force: false},
{name: '', type: '', uri: '', metaDataUri: '', bootVersion: '2', force: false}
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', force: false},
{name: '', type: '', uri: '', metaDataUri: '', force: false},
{name: '', type: '', uri: '', metaDataUri: '', 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 Down Expand Up @@ -108,17 +107,16 @@ describe('apps/register/register.component.ts', () => {
it('should display errors form', () => {
fixture.detectChanges();
const tests = [
{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}
{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}
];
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 @@ -137,13 +135,11 @@ describe('apps/register/register.component.ts', () => {
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
12 changes: 2 additions & 10 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,6 @@ import {TranslateService} from '@ngx-translate/core';
export class RegisterComponent implements OnInit {
forms: UntypedFormGroup[] = [];
applicationTypes = ApplicationType;
bootVersions: Array<string>;
defaultBoot: string;
submitted = false;
isImporting = false;
Expand All @@ -28,11 +27,7 @@ export class RegisterComponent implements OnInit {
) {}

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

register(): void {
Expand All @@ -59,7 +54,6 @@ export class RegisterComponent implements OnInit {
type: form.get('type').value as ApplicationType,
uri: form.get('uri').value,
metaDataUri: form.get('metaDataUri').value,
bootVersion: form.get('bootVersion').value,
oodamien marked this conversation as resolved.
Show resolved Hide resolved
force: form.get('force').value
};
}
Expand Down Expand Up @@ -109,8 +103,7 @@ export class RegisterComponent implements OnInit {
form.get('uri').hasError('required') &&
form.get('name').hasError('required') &&
form.get('metaDataUri').value === '' &&
form.get('type').hasError('required') &&
form.get('bootVersion').value === this.defaultBoot
form.get('type').hasError('required')
);
}

Expand All @@ -121,7 +114,6 @@ 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(this.defaultBoot, Validators.required),
force: new UntypedFormControl(false)
});

Expand Down
8 changes: 0 additions & 8 deletions ui/src/app/apps/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ <h1 class="page-title">
<span *ngIf="defaultApp" class="label">{{ detailedApp.version }}</span>
</div>
</div>
<div class="row">
<div class="key">{{ 'applications.main.bootVersion' | translate }}</div>
<div class="value">
<span *ngIf="defaultApp" class="label">{{
'applications.main.bootVersions.' + detailedApp.bootVersion | translate
}}</span>
</div>
</div>
<div *ngIf="detailedApp.uri" class="row">
<div class="key">{{ 'applications.main.uri' | translate }}</div>
<div class="value">{{ detailedApp.uri }}</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/apps/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class AppComponent implements OnInit {
this.detailedApp.version = app.version;
this.detailedApp.defaultVersion = app.defaultVersion;
}
this.appsService.getApp(app.name, app.type, app.version, app.version).subscribe(
this.appsService.getApp(app.name, app.type, app.version).subscribe(
(detailedApp: DetailedApp) => {
this.tooManyProperties = detailedApp.options.length > 50;
this.showAllProperties = !this.tooManyProperties;
Expand Down
14 changes: 0 additions & 14 deletions ui/src/app/apps/apps.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ <h1 class="page-title-actions">
<clr-dg-filter style="display: none"></clr-dg-filter>
</ng-container>
</clr-dg-column>
<clr-dg-column
[clrDgField]="'bootVersion'"
[clrDgSortOrder]="context.by === 'bootVersion' ? (context.reverse ? -1 : 1) : 0"
(clrDgColumnResize)="updateContext('sizeBootVersion', $event)"
[style.width.px]="context.sizeBootVersion | datagridcolumn: datagrid:contextName | async"
>
<ng-container>
{{ 'applications.main.bootVersion' | translate }}
<clr-dg-filter style="display: none"></clr-dg-filter>
</ng-container>
</clr-dg-column>

<clr-dg-column
[clrDgField]="'uri'"
Expand Down Expand Up @@ -128,9 +117,6 @@ <h1 class="page-title-actions">
<span *ngIf="app.versions?.length > 1" class="badge badge-light-blue">{{ app.versions?.length }}</span>
</span>
</clr-dg-cell>
<clr-dg-cell>
{{ 'applications.main.bootVersions.' + app.bootVersion | translate }}
</clr-dg-cell>
<clr-dg-cell
><span class="text-truncate">{{ app.uri }}</span></clr-dg-cell
>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/apps/apps.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('apps/apps.component.ts', () => {
expect(actionBar).toBeTruthy();
expect(title.textContent).toContain('Applications');
expect(rows.length === 20).toBeTruthy();
expect(cols.length === 6).toBeTruthy();
expect(cols.length === 5).toBeTruthy();
done();
});

Expand Down Expand Up @@ -230,13 +230,13 @@ describe('apps/apps.component.ts', () => {
sort: {by: 'version', reverse: true}
});
// URI
cols[4].query(By.css('button')).nativeElement.click();
cols[3].query(By.css('button')).nativeElement.click();
fixture.detectChanges();
expect(refresh).toHaveBeenCalledWith({
page: {from: 0, to: 19, size: 20, current: 1},
sort: {by: 'uri', reverse: false}
});
cols[4].query(By.css('button')).nativeElement.click();
cols[3].query(By.css('button')).nativeElement.click();
fixture.detectChanges();
expect(refresh).toHaveBeenCalledWith({
page: {from: 0, to: 19, size: 20, current: 1},
Expand Down
6 changes: 2 additions & 4 deletions ui/src/app/shared/api/app.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ describe('shared/api/app.service.ts', () => {

it('getApp with spring boot version in parameter', () => {
mockHttp.get.and.returnValue(of(jsonData));
appService.getApp('foo', 'processor' as any as ApplicationType, '', '3');
appService.getApp('foo', 'processor' as any as ApplicationType, '');
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(httpUri).toEqual('/apps/processor/foo');
expect(headerArgs.get('Content-Type')).toEqual('application/json');
expect(headerArgs.get('Accept')).toEqual('application/json');
});
Expand Down Expand Up @@ -110,7 +110,6 @@ describe('shared/api/app.service.ts', () => {
uri: 'https://uri.foo.bar',
metaDataUri: 'https://metaDataUri.foo.bar',
type: ApplicationType.processor,
bootVersion: '3',
oodamien marked this conversation as resolved.
Show resolved Hide resolved
force: true
});
const httpUri = mockHttp.post.calls.mostRecent().args[0];
Expand All @@ -121,7 +120,6 @@ 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
23 changes: 4 additions & 19 deletions ui/src/app/shared/api/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,11 @@ 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): Observable<DetailedApp | unknown> {
const headers = HttpUtils.getDefaultHttpHeaders();
const bootVersionConfig = bootVersion ? `?bootVersion=${bootVersion}` : ``;
let url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}${bootVersionConfig}`;
let url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}`;
if (appVersion) {
url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}/${appVersion}${bootVersionConfig}`;
url = UrlUtilities.calculateBaseApiUrl() + `apps/${type}/${name}/${appVersion}`;
}
return this.httpClient.get(url, {headers}).pipe(map(DetailedApp.parse), catchError(ErrorUtils.catchError));
}
Expand All @@ -65,12 +59,6 @@ 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 @@ -108,10 +96,7 @@ export class AppService {
}

registerProp(prop: any): Observable<any> {
let params = new HttpParams()
.append('uri', prop.uri)
.append('force', prop.force.toString())
.append('bootVersion', prop.bootVersion);
let params = new HttpParams().append('uri', prop.uri).append('force', prop.force.toString());
if (prop.metaDataUri) {
params = params.append('metadata-uri', prop.metaDataUri);
}
Expand Down
Loading
Loading