Skip to content

Commit a486788

Browse files
committed
feat: Update SCDF-UI to use the latest APIs
Resolves #2021
1 parent 38714f4 commit a486788

29 files changed

+78
-266
lines changed

Diff for: ui/src/app/app.module.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {AppsModule} from './apps/apps.module';
3030
import {UrlUtilities} from './url-utilities.service';
3131
import {TaskService} from './shared/api/task.service';
3232
import {JobService} from './shared/api/job.service';
33+
import {DevModule} from './dev/dev.module';
3334

3435
@NgModule({
3536
declarations: [AppComponent],
@@ -44,7 +45,7 @@ import {JobService} from './shared/api/job.service';
4445
FormsModule,
4546
LayoutModule,
4647
// DashboardModule,
47-
// DevModule,
48+
DevModule,
4849
StreamsModule,
4950
TasksJobsModule,
5051
ManageModule,

Diff for: ui/src/app/apps/add/register/register.component.html

-26
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,6 @@
4848
</div>
4949
</div>
5050
</div>
51-
<div
52-
class="clr-form-control clr-row"
53-
[class.clr-error]="submitted && form.get('bootVersion').invalid && !isFormEmpty(form)"
54-
>
55-
<label class="clr-col-2 clr-control-label" for="type{{ i }}">{{
56-
'applications.main.bootVersion' | translate
57-
}}</label>
58-
<div class="clr-control-container clr-col-10" *ngIf="bootVersions">
59-
<div class="clr-select-wrapper">
60-
<select
61-
name="bootVersion{{ i }}"
62-
id="bootVersion{{ i }}"
63-
formControlName="bootVersion"
64-
class="clr-select"
65-
>
66-
<option *ngFor="let bootVersionKey of bootVersions" value="{{ bootVersionKey }}">
67-
Spring Boot&nbsp;
68-
{{ 'applications.main.bootVersions.' + bootVersionKey | translate }}
69-
</option>
70-
</select>
71-
</div>
72-
<div class="clr-subtext" *ngIf="submitted && form.get('type').invalid && !isFormEmpty(form)">
73-
{{ 'applications.add.register.invalidType' | translate }}
74-
</div>
75-
</div>
76-
</div>
7751
<div
7852
class="clr-form-control clr-row"
7953
[class.clr-error]="submitted && form.get('uri').invalid && !isFormEmpty(form)"

Diff for: ui/src/app/apps/add/register/register.component.spec.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,16 @@ describe('apps/register/register.component.ts', () => {
7070
const navigate = spyOn((<any>component).router, 'navigateByUrl');
7171
fixture.detectChanges();
7272
const tests = [
73-
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', bootVersion: '3', force: false},
74-
{name: '', type: '', uri: '', metaDataUri: '', bootVersion: '2', force: false},
75-
{name: '', type: '', uri: '', metaDataUri: '', bootVersion: '2', force: false}
73+
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', force: false},
74+
{name: '', type: '', uri: '', metaDataUri: '', force: false},
75+
{name: '', type: '', uri: '', metaDataUri: '', force: false}
7676
];
7777
component.newForm();
7878
component.newForm();
7979
tests.forEach((test, index) => {
8080
component.forms[index].get('name').setValue(test.name);
8181
component.forms[index].get('type').setValue(test.type);
8282
component.forms[index].get('uri').setValue(test.uri);
83-
component.forms[index].get('bootVersion').setValue(test.bootVersion);
8483
component.forms[index].get('metaDataUri').setValue(test.metaDataUri);
8584
component.forms[index].get('force').setValue(test.force);
8685
});
@@ -108,17 +107,16 @@ describe('apps/register/register.component.ts', () => {
108107
it('should display errors form', () => {
109108
fixture.detectChanges();
110109
const tests = [
111-
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', bootVersion: '3', force: false},
112-
{name: 'foobar2', type: 'sink', uri: 'https://foo.bar', metaDataUri: '', bootVersion: '2', force: false},
113-
{name: 'foobar3', type: 'processor', uri: '', metaDataUri: '', bootVersion: '3', force: false}
110+
{name: 'foobar1', type: 'source', uri: 'https://foo.bar', metaDataUri: '', force: false},
111+
{name: 'foobar2', type: 'sink', uri: 'https://foo.bar', metaDataUri: '', force: false},
112+
{name: 'foobar3', type: 'processor', uri: '', metaDataUri: '', force: false}
114113
];
115114
component.newForm();
116115
component.newForm();
117116
tests.forEach((test, index) => {
118117
component.forms[index].get('name').setValue(test.name);
119118
component.forms[index].get('type').setValue(test.type);
120119
component.forms[index].get('uri').setValue(test.uri);
121-
component.forms[index].get('bootVersion').setValue(test.bootVersion);
122120
component.forms[index].get('metaDataUri').setValue(test.metaDataUri);
123121
component.forms[index].get('force').setValue(test.force);
124122
});
@@ -137,13 +135,11 @@ describe('apps/register/register.component.ts', () => {
137135
type: 'source',
138136
uri: 'https://foo.bar',
139137
metaDataUri: '',
140-
bootVersion: '3',
141138
force: false
142139
};
143140
component.forms[0].get('name').setValue(test.name);
144141
component.forms[0].get('type').setValue(test.type);
145142
component.forms[0].get('uri').setValue(test.uri);
146-
component.forms[0].get('bootVersion').setValue(test.bootVersion);
147143
component.forms[0].get('metaDataUri').setValue(test.metaDataUri);
148144
component.forms[0].get('force').setValue(test.force);
149145
fixture.detectChanges();

Diff for: ui/src/app/apps/add/register/register.component.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export class RegisterComponent implements OnInit {
5959
type: form.get('type').value as ApplicationType,
6060
uri: form.get('uri').value,
6161
metaDataUri: form.get('metaDataUri').value,
62-
bootVersion: form.get('bootVersion').value,
6362
force: form.get('force').value
6463
};
6564
}
@@ -109,8 +108,7 @@ export class RegisterComponent implements OnInit {
109108
form.get('uri').hasError('required') &&
110109
form.get('name').hasError('required') &&
111110
form.get('metaDataUri').value === '' &&
112-
form.get('type').hasError('required') &&
113-
form.get('bootVersion').value === this.defaultBoot
111+
form.get('type').hasError('required')
114112
);
115113
}
116114

@@ -121,7 +119,6 @@ export class RegisterComponent implements OnInit {
121119
type: new UntypedFormControl('', Validators.required),
122120
uri: new UntypedFormControl('', [AppsAddValidator.appUri, Validators.required]),
123121
metaDataUri: new UntypedFormControl('', AppsAddValidator.appUri),
124-
bootVersion: new UntypedFormControl(this.defaultBoot, Validators.required),
125122
force: new UntypedFormControl(false)
126123
});
127124

Diff for: ui/src/app/apps/apps.component.html

-14
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,6 @@ <h1 class="page-title-actions">
8383
<clr-dg-filter style="display: none"></clr-dg-filter>
8484
</ng-container>
8585
</clr-dg-column>
86-
<clr-dg-column
87-
[clrDgField]="'bootVersion'"
88-
[clrDgSortOrder]="context.by === 'bootVersion' ? (context.reverse ? -1 : 1) : 0"
89-
(clrDgColumnResize)="updateContext('sizeBootVersion', $event)"
90-
[style.width.px]="context.sizeBootVersion | datagridcolumn: datagrid:contextName | async"
91-
>
92-
<ng-container>
93-
{{ 'applications.main.bootVersion' | translate }}
94-
<clr-dg-filter style="display: none"></clr-dg-filter>
95-
</ng-container>
96-
</clr-dg-column>
9786

9887
<clr-dg-column
9988
[clrDgField]="'uri'"
@@ -128,9 +117,6 @@ <h1 class="page-title-actions">
128117
<span *ngIf="app.versions?.length > 1" class="badge badge-light-blue">{{ app.versions?.length }}</span>
129118
</span>
130119
</clr-dg-cell>
131-
<clr-dg-cell>
132-
{{ 'applications.main.bootVersions.' + app.bootVersion | translate }}
133-
</clr-dg-cell>
134120
<clr-dg-cell
135121
><span class="text-truncate">{{ app.uri }}</span></clr-dg-cell
136122
>

Diff for: ui/src/app/apps/apps.component.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('apps/apps.component.ts', () => {
8080
expect(actionBar).toBeTruthy();
8181
expect(title.textContent).toContain('Applications');
8282
expect(rows.length === 20).toBeTruthy();
83-
expect(cols.length === 6).toBeTruthy();
83+
expect(cols.length === 5).toBeTruthy();
8484
done();
8585
});
8686

@@ -230,13 +230,13 @@ describe('apps/apps.component.ts', () => {
230230
sort: {by: 'version', reverse: true}
231231
});
232232
// URI
233-
cols[4].query(By.css('button')).nativeElement.click();
233+
cols[3].query(By.css('button')).nativeElement.click();
234234
fixture.detectChanges();
235235
expect(refresh).toHaveBeenCalledWith({
236236
page: {from: 0, to: 19, size: 20, current: 1},
237237
sort: {by: 'uri', reverse: false}
238238
});
239-
cols[4].query(By.css('button')).nativeElement.click();
239+
cols[3].query(By.css('button')).nativeElement.click();
240240
fixture.detectChanges();
241241
expect(refresh).toHaveBeenCalledWith({
242242
page: {from: 0, to: 19, size: 20, current: 1},

Diff for: ui/src/app/shared/api/app.service.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ describe('shared/api/app.service.ts', () => {
110110
uri: 'https://uri.foo.bar',
111111
metaDataUri: 'https://metaDataUri.foo.bar',
112112
type: ApplicationType.processor,
113-
bootVersion: '3',
114113
force: true
115114
});
116115
const httpUri = mockHttp.post.calls.mostRecent().args[0];
@@ -121,7 +120,6 @@ describe('shared/api/app.service.ts', () => {
121120
expect(headerArgs.get('Accept')).toEqual('application/json');
122121
expect(httpParams.get('uri')).toEqual('https://uri.foo.bar');
123122
expect(httpParams.get('metadata-uri')).toEqual('https://metaDataUri.foo.bar');
124-
expect(httpParams.get('bootVersion')).toEqual('3');
125123
expect(httpParams.get('force')).toEqual('true');
126124
});
127125

Diff for: ui/src/app/shared/api/app.service.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,7 @@ export class AppService {
108108
}
109109

110110
registerProp(prop: any): Observable<any> {
111-
let params = new HttpParams()
112-
.append('uri', prop.uri)
113-
.append('force', prop.force.toString())
114-
.append('bootVersion', prop.bootVersion);
111+
let params = new HttpParams().append('uri', prop.uri).append('force', prop.force.toString());
115112
if (prop.metaDataUri) {
116113
params = params.append('metadata-uri', prop.metaDataUri);
117114
}

Diff for: ui/src/app/shared/api/job.service.ts

+8-27
Original file line numberDiff line numberDiff line change
@@ -33,66 +33,47 @@ export class JobService {
3333
.pipe(map(JobExecutionPage.parse), catchError(ErrorUtils.catchError));
3434
}
3535

36-
getExecution(executionId: string, schemaTarget: string): Observable<JobExecution | unknown> {
36+
getExecution(executionId: string): Observable<JobExecution | unknown> {
3737
const headers = HttpUtils.getDefaultHttpHeaders();
38-
const params = new HttpParams({encoder: new DataflowEncoder()}).set('schemaTarget', schemaTarget);
3938
return this.httpClient
40-
.get<any>(UrlUtilities.calculateBaseApiUrl() + `jobs/executions/${executionId}`, {headers, params})
39+
.get<any>(UrlUtilities.calculateBaseApiUrl() + `jobs/executions/${executionId}`, {headers})
4140
.pipe(map(JobExecution.parse), catchError(ErrorUtils.catchError));
4241
}
4342

4443
restart(execution: JobExecution): Observable<any> {
4544
const headers = HttpUtils.getDefaultHttpHeaders();
4645
const initHttpParams = new HttpParams({encoder: new DataflowEncoder()});
47-
const params = initHttpParams.append('schemaTarget', execution.schemaTarget);
4846
return this.httpClient
4947
.put(
5048
UrlUtilities.calculateBaseApiUrl() + `jobs/executions/${execution.jobExecutionId}?restart=true`,
5149
{},
52-
{headers, params}
50+
{headers}
5351
)
5452
.pipe(catchError(ErrorUtils.catchError));
5553
}
5654

5755
stop(item: JobExecution): Observable<any> {
5856
const headers = HttpUtils.getDefaultHttpHeaders();
5957
const initHttpParams = new HttpParams({encoder: new DataflowEncoder()});
60-
const params = initHttpParams.append('schemaTarget', item.schemaTarget);
6158
return this.httpClient
62-
.put(
63-
UrlUtilities.calculateBaseApiUrl() + `jobs/executions/${item.jobExecutionId}?stop=true`,
64-
{},
65-
{headers, params}
66-
)
59+
.put(UrlUtilities.calculateBaseApiUrl() + `jobs/executions/${item.jobExecutionId}?stop=true`, {}, {headers})
6760
.pipe(catchError(ErrorUtils.catchError));
6861
}
6962

70-
getExecutionStep(
71-
jobExecutionId: string,
72-
stepId: string,
73-
schemaTarget: string
74-
): Observable<ExecutionStepResource | unknown> {
63+
getExecutionStep(jobExecutionId: string, stepId: string): Observable<ExecutionStepResource | unknown> {
7564
const headers = HttpUtils.getDefaultHttpHeaders();
76-
const params = new HttpParams({encoder: new DataflowEncoder()}).append('schemaTarget', schemaTarget);
7765
return this.httpClient
7866
.get<any>(UrlUtilities.calculateBaseApiUrl() + `jobs/executions/${jobExecutionId}/steps/${stepId}`, {
79-
headers,
80-
params
67+
headers
8168
})
8269
.pipe(map(ExecutionStepResource.parse), catchError(ErrorUtils.catchError));
8370
}
8471

85-
getExecutionStepProgress(
86-
jobExecutionId: string,
87-
stepId: string,
88-
schemaTarget: string
89-
): Observable<ExecutionStepProgress | unknown> {
72+
getExecutionStepProgress(jobExecutionId: string, stepId: string): Observable<ExecutionStepProgress | unknown> {
9073
const headers = HttpUtils.getDefaultHttpHeaders();
91-
const params = new HttpParams({encoder: new DataflowEncoder()}).append('schemaTarget', schemaTarget);
9274
return this.httpClient
9375
.get<any>(UrlUtilities.calculateBaseApiUrl() + `jobs/executions/${jobExecutionId}/steps/${stepId}/progress`, {
94-
headers,
95-
params
76+
headers
9677
})
9778
.pipe(map(ExecutionStepProgress.parse), catchError(ErrorUtils.catchError));
9879
}

Diff for: ui/src/app/shared/api/task.service.spec.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,21 @@ describe('shared/api/task.service.ts', () => {
104104
it('executionsClean', async () => {
105105
mockHttp.delete.and.returnValue(of(jsonData));
106106
const taskExecutions = [
107-
TaskExecution.parse({executionId: 'foo1', schemaTarget: 'boot2'}),
108-
TaskExecution.parse({executionId: 'foo2', parentExecutionId: 'foo1', schemaTarget: 'boot2'}),
109-
TaskExecution.parse({executionId: 'foo3', parentExecutionId: 'foo1', schemaTarget: 'boot3'}),
110-
TaskExecution.parse({executionId: 'bar1', schemaTarget: 'boot3'}),
111-
TaskExecution.parse({executionId: 'bar2', parentExecutionId: 'bar1', schemaTarget: 'boot2'}),
112-
TaskExecution.parse({executionId: 'bar3', parentExecutionId: 'bar1', schemaTarget: 'boot3'})
107+
TaskExecution.parse({executionId: 'foo1'}),
108+
TaskExecution.parse({executionId: 'foo2', parentExecutionId: 'foo1'}),
109+
TaskExecution.parse({executionId: 'foo3', parentExecutionId: 'foo1'}),
110+
TaskExecution.parse({executionId: 'bar1'}),
111+
TaskExecution.parse({executionId: 'bar2', parentExecutionId: 'bar1'}),
112+
TaskExecution.parse({executionId: 'bar3', parentExecutionId: 'bar1'})
113113
];
114114
await taskService.executionsClean(taskExecutions).toPromise();
115115
const httpUri = mockHttp.delete.calls.all();
116116
expect(httpUri).not.toEqual(undefined);
117117
expect(httpUri).not.toEqual(null);
118118
expect(httpUri.length).not.toEqual(0);
119119
expect(httpUri.map(url => url.args[0])).toEqual([
120-
'/tasks/executions/foo2,bar2?action=CLEANUP,REMOVE_DATA&schemaTarget=boot2',
121-
'/tasks/executions/foo3,bar3?action=CLEANUP,REMOVE_DATA&schemaTarget=boot3',
122-
'/tasks/executions/foo1?action=CLEANUP,REMOVE_DATA&schemaTarget=boot2',
123-
'/tasks/executions/bar1?action=CLEANUP,REMOVE_DATA&schemaTarget=boot3'
120+
'/tasks/executions/foo2,foo3,bar2,bar3?action=CLEANUP,REMOVE_DATA',
121+
'/tasks/executions/foo1,bar1?action=CLEANUP,REMOVE_DATA'
124122
]);
125123
});
126124

@@ -152,13 +150,12 @@ describe('shared/api/task.service.ts', () => {
152150
taskService.getExecutionLogs(
153151
TaskExecution.parse({
154152
externalExecutionId: 'foo',
155-
schemaTarget: 'boot3',
156153
arguments: ['--spring.cloud.data.flow.platformname=bar']
157154
})
158155
);
159156
const httpUri = mockHttp.get.calls.mostRecent().args[0];
160157
const headerArgs = mockHttp.get.calls.mostRecent().args[1].headers;
161-
expect(httpUri).toEqual('/tasks/logs/foo?platformName=bar&schemaTarget=boot3');
158+
expect(httpUri).toEqual('/tasks/logs/foo?platformName=bar');
162159
expect(headerArgs.get('Content-Type')).toEqual('application/json');
163160
expect(headerArgs.get('Accept')).toEqual('application/json');
164161
});

0 commit comments

Comments
 (0)