Skip to content

Commit

Permalink
Merge pull request #1921 from klopfdreh/feature/taskFilter
Browse files Browse the repository at this point in the history
feat: filter for task description and dslText
  • Loading branch information
claudiahub authored May 26, 2023
2 parents 8746456 + 56d2ebe commit 37f74d5
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/manage/tools/task/export.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class TaskExportComponent {
open(): void {
this.isRunning = false;
this.isOpen = true;
this.taskService.getTasks(0, 100000, '', 'taskName', 'ASC').subscribe(
this.taskService.getTasks(0, 100000, '', null, null, 'taskName', 'ASC').subscribe(
(page: TaskPage) => {
this.tasks = page;
this.selected = [...page.items];
Expand Down
6 changes: 4 additions & 2 deletions ui/src/app/shared/api/task.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ describe('shared/api/task.service.ts', () => {

it('getTasks', () => {
mockHttp.get.and.returnValue(of(jsonData));
taskService.getTasks(0, 20, 'bar', 'name', 'DESC');
taskService.getTasks(0, 20, 'bar', 'test', 'dslText', 'name', 'DESC');
const httpUri = mockHttp.get.calls.mostRecent().args[0];
const httpParams = mockHttp.get.calls.mostRecent().args[1].params;
expect(httpParams.get('sort')).toEqual('name,DESC');
expect(httpParams.get('search')).toEqual('bar');
expect(httpParams.get('taskName')).toEqual('bar');
expect(httpParams.get('description')).toEqual('test');
expect(httpParams.get('dslText')).toEqual('dslText');
expect(httpParams.get('page')).toEqual('0');
expect(httpParams.get('size')).toEqual('20');
expect(httpUri).toEqual('/tasks/definitions');
Expand Down
20 changes: 17 additions & 3 deletions ui/src/app/shared/api/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,25 @@ import {UrlUtilities} from '../../url-utilities.service';
export class TaskService {
constructor(protected httpClient: HttpClient) {}

getTasks(page: number, size: number, search?: string, sort?: string, order?: string): Observable<TaskPage | unknown> {
getTasks(
page: number,
size: number,
taskName?: string,
description?: string,
dslText?: string,
sort?: string,
order?: string
): Observable<TaskPage | unknown> {
const headers = HttpUtils.getDefaultHttpHeaders();
let params = HttpUtils.getPaginationParams(page, size);
if (search) {
params = params.append('search', search);
if (taskName) {
params = params.append('taskName', taskName);
}
if (description) {
params = params.append('description', description);
}
if (dslText) {
params = params.append('dslText', dslText);
}
if (sort && order) {
params = params.append('sort', `${sort},${order}`);
Expand Down
22 changes: 12 additions & 10 deletions ui/src/app/shared/component/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,18 @@ export class SearchComponent implements OnInit {
this.results.streams = new StreamPage();
}
if (this.enabled.tasks) {
this.subscriptions.tasks = this.taskService.getTasks(0, 5, `${value}`, 'taskName', 'ASC').subscribe(
(page: TaskPage) => {
this.results.tasks = page;
this.searching.tasks = false;
},
error => {
this.notificationService.error(this.translate.instant('commons.message.error'), error);
this.searching.tasks = false;
}
);
this.subscriptions.tasks = this.taskService
.getTasks(0, 5, `${value}`, null, null, 'taskName', 'ASC')
.subscribe(
(page: TaskPage) => {
this.results.tasks = page;
this.searching.tasks = false;
},
error => {
this.notificationService.error(this.translate.instant('commons.message.error'), error);
this.searching.tasks = false;
}
);
} else {
this.results.tasks = new TaskPage();
}
Expand Down
6 changes: 4 additions & 2 deletions ui/src/app/tasks-jobs/tasks/tasks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,22 @@ <h1 class="page-title-actions">
<ng-container>{{ 'commons.name' | translate }}</ng-container>
</clr-dg-column>
<clr-dg-column
[clrDgField]="'description'"
[clrDgSortOrder]="context.by === 'description' ? (context.reverse ? -1 : 1) : 0"
(clrDgColumnResize)="updateContext('sizeDescription', $event)"
[style.width.px]="context.sizeDescription | datagridcolumn: datagrid:contextName:15 | async"
[clrFilterValue]="context.description"
>
<ng-container>{{ 'commons.description' | translate }}</ng-container>
<clr-dg-filter style="display: none"></clr-dg-filter>
</clr-dg-column>
<clr-dg-column
[clrDgField]="'dslText'"
[clrDgSortOrder]="context.by === 'dslText' ? (context.reverse ? -1 : 1) : 0"
(clrDgColumnResize)="updateContext('sizeDsl', $event)"
[style.width.px]="context.sizeDsl | datagridcolumn: datagrid:contextName:15 | async"
[clrFilterValue]="context.dslText"
>
<ng-container>{{ 'commons.definition' | translate }}</ng-container>
<clr-dg-filter style="display: none"></clr-dg-filter>
</clr-dg-column>
<clr-dg-column
(clrDgColumnResize)="updateContext('sizeStatus', $event)"
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/tasks-jobs/tasks/tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export class TasksComponent extends DatagridComponent {
params.current - 1,
params.size,
params?.taskName || '',
params?.description || '',
params?.dslText || '',
`${params.by || ''}`,
`${params.reverse ? 'DESC' : 'ASC'}`
)
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/tests/api/task.service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {delay, map} from 'rxjs/operators';
export class TaskServiceMock {
static mock: TaskServiceMock = null;

getTasks(page: number, size: number, search?: string, sort?: string, order?: string): Observable<TaskPage> {
getTasks(page: number, size: number, taskName?: string, description?: string, dslText?: string, sort?: string, order?: string): Observable<TaskPage> {
return of(GET_TASKS).pipe(delay(1), map(TaskPage.parse));
}

Expand Down

0 comments on commit 37f74d5

Please sign in to comment.