Skip to content

Commit

Permalink
Merge pull request #320 from catenax-ng/main
Browse files Browse the repository at this point in the history
added filtering on notifications, redesigned filter api
  • Loading branch information
ds-mwesener authored Oct 25, 2023
2 parents 692bf1b + b2d4ee7 commit 088970e
Show file tree
Hide file tree
Showing 81 changed files with 8,303 additions and 1,686 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Added
- Added Table columns settings in part tables to show/hide/reorder table columns
- new endpoints supporting filtering feature for investigations and alers api/investigations api/alerts
- Added missing translations
- support for date ranges BEFORE_LOCAL_DATE and AFTER_LOCAL_DATE providing both will cause filter result to return only relevant date ranges
- added supported searchCriteriaFieldsMappers for investigations, alerts, assetsAsBuilt and assetAsPlanned related endpoints

### Changed
- Updated user manual to reflect the table column settings feature
- Fixed a bug which removed all parts asBuilt selection at once when creating notifications
- Changed Filter to support Logical operator (AND,OR) on searchCriteria
- Adapt frontend to use the changed filter logic with the correct operator per use case
- Reworked business logic of /registry/reload to always sync all assets
- Bump @babel/traverse from 7.20.13 to 7.23.2 in frontend
- distinctFilterValues endpoints now support startWith parameter that will cause result to contain only suggestions starting with given string
- changed qualityNotification filtering changed from side to channel as response field name
- changed assetAsBuilt filtering manufacturerId to businessPartner

### Removed

- Removed &filterOperator=AND from filtering requests
- Removed no longer needed endpoints api/investigations/created, api/investigations/received, api/alerts/created, api/alerts/received

## [8.0.0 - 16.10.2023]

Expand Down Expand Up @@ -57,7 +69,6 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Changed date formats of assets to have offsetDateTime instead of Date or LocalDateTime
- Aligned date formats in the rest api for assets
- Increased version of jetty-http from 11.0.15 to 11.0.17 and excluded from edc package
- Reworked business logic of /registry/reload to always sync all assets

### Removed

Expand Down
8 changes: 4 additions & 4 deletions DEPENDENCIES_BACKEND
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ maven/mavencentral/dev.failsafe/failsafe/3.3.2, Apache-2.0, approved, #9268
maven/mavencentral/io.cucumber/ci-environment/9.2.0, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-core/7.12.1, MIT AND (Apache-2.0 AND MIT), approved, #11050
maven/mavencentral/io.cucumber/cucumber-expressions/16.1.2, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-gherkin-messages/7.12.1, None, restricted, #11045
maven/mavencentral/io.cucumber/cucumber-gherkin-messages/7.12.1, MIT, approved, #11045
maven/mavencentral/io.cucumber/cucumber-gherkin/7.12.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-java/7.12.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-junit-platform-engine/7.12.1, None, restricted, #11046
maven/mavencentral/io.cucumber/cucumber-junit-platform-engine/7.12.1, MIT, approved, #11046
maven/mavencentral/io.cucumber/cucumber-plugin/7.12.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/datatable/7.12.1, None, restricted, #11047
maven/mavencentral/io.cucumber/datatable/7.12.1, MIT, approved, #11047
maven/mavencentral/io.cucumber/docstring/7.12.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/gherkin/26.2.0, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/html-formatter/20.3.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/junit-xml-formatter/0.2.0, None, restricted, #11043
maven/mavencentral/io.cucumber/junit-xml-formatter/0.2.0, MIT, approved, #11043
maven/mavencentral/io.cucumber/messages/22.0.0, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/tag-expressions/5.0.1, MIT, approved, clearlydefined
maven/mavencentral/io.github.classgraph/classgraph/4.8.149, MIT, approved, CQ22530
Expand Down
15 changes: 13 additions & 2 deletions DEPENDENCIES_FRONTEND
Original file line number Diff line number Diff line change
Expand Up @@ -1152,12 +1152,14 @@ npm/npmjs/@angular/router/15.2.8, MIT, approved, #8070
npm/npmjs/@assemblyscript/loader/0.10.1, Apache-2.0, approved, clearlydefined
npm/npmjs/@babel/code-frame/7.16.7, MIT, approved, clearlydefined
npm/npmjs/@babel/code-frame/7.21.4, MIT, approved, clearlydefined
npm/npmjs/@babel/code-frame/7.22.13, MIT, approved, #8946
npm/npmjs/@babel/compat-data/7.21.7, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8211
npm/npmjs/@babel/core/7.19.3, MIT, approved, clearlydefined
npm/npmjs/@babel/core/7.20.12, MIT, approved, #4666
npm/npmjs/@babel/core/7.21.8, MIT AND (BSD-2-Clause AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #7466
npm/npmjs/@babel/generator/7.20.14, MIT, approved, #4572
npm/npmjs/@babel/generator/7.21.5, MIT AND (BSD-2-Clause AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #7470
npm/npmjs/@babel/generator/7.23.0, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-annotate-as-pure/7.18.6, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-builder-binary-assignment-operator-visitor/7.21.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8255
npm/npmjs/@babel/helper-compilation-targets/7.20.7, MIT AND BSD-2-Clause AND BSD-3-Clause, approved, #5989
Expand All @@ -1166,8 +1168,11 @@ npm/npmjs/@babel/helper-create-class-features-plugin/7.21.8, MIT AND (BSD-2-Clau
npm/npmjs/@babel/helper-create-regexp-features-plugin/7.21.8, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8261
npm/npmjs/@babel/helper-define-polyfill-provider/0.3.3, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-environment-visitor/7.21.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8223
npm/npmjs/@babel/helper-environment-visitor/7.22.20, MIT, approved, #8934
npm/npmjs/@babel/helper-function-name/7.21.0, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-function-name/7.23.0, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-hoist-variables/7.18.6, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-hoist-variables/7.22.5, MIT, approved, #8957
npm/npmjs/@babel/helper-member-expression-to-functions/7.21.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8251
npm/npmjs/@babel/helper-module-imports/7.21.4, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-module-transforms/7.20.11, MIT, approved, #4659
Expand All @@ -1179,16 +1184,21 @@ npm/npmjs/@babel/helper-replace-supers/7.21.5, MIT AND (BSD-2-Clause AND ISC AND
npm/npmjs/@babel/helper-simple-access/7.21.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8220
npm/npmjs/@babel/helper-skip-transparent-expression-wrappers/7.20.0, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-split-export-declaration/7.18.6, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-split-export-declaration/7.22.6, MIT, approved, #8938
npm/npmjs/@babel/helper-string-parser/7.21.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8226
npm/npmjs/@babel/helper-string-parser/7.22.5, MIT, approved, #8962
npm/npmjs/@babel/helper-validator-identifier/7.19.1, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-validator-identifier/7.22.20, MIT, approved, #8955
npm/npmjs/@babel/helper-validator-option/7.21.0, MIT, approved, clearlydefined
npm/npmjs/@babel/helper-wrap-function/7.20.5, MIT, approved, clearlydefined
npm/npmjs/@babel/helpers/7.20.13, MIT, approved, #4646
npm/npmjs/@babel/helpers/7.21.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8250
npm/npmjs/@babel/highlight/7.18.6, MIT, approved, clearlydefined
npm/npmjs/@babel/highlight/7.22.20, MIT, approved, #9073
npm/npmjs/@babel/parser/7.20.15, MIT, approved, #4604
npm/npmjs/@babel/parser/7.20.5, MIT, approved, #4604
npm/npmjs/@babel/parser/7.21.8, MIT AND (BSD-2-Clause AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #7455
npm/npmjs/@babel/parser/7.23.0, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #10663
npm/npmjs/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/7.18.6, MIT, approved, clearlydefined
npm/npmjs/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/7.20.7, MIT AND BSD-2-Clause AND BSD-3-Clause, approved, #5987
npm/npmjs/@babel/plugin-proposal-async-generator-functions/7.20.7, MIT, approved, #4607
Expand Down Expand Up @@ -1262,10 +1272,11 @@ npm/npmjs/@babel/runtime/7.20.6, MIT AND BSD-3-Clause AND BSD-2-Clause, approved
npm/npmjs/@babel/runtime/7.21.0, MIT AND (BSD-2-Clause AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #7349
npm/npmjs/@babel/runtime/7.21.5, MIT AND (BSD-2-Clause AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #7349
npm/npmjs/@babel/template/7.20.7, MIT AND BSD-2-Clause AND BSD-3-Clause, approved, #5988
npm/npmjs/@babel/traverse/7.20.13, MIT, approved, #4570
npm/npmjs/@babel/traverse/7.21.5, MIT AND (BSD-2-Clause AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #7472
npm/npmjs/@babel/template/7.22.15, MIT, approved, #9017
npm/npmjs/@babel/traverse/7.23.2, MIT, approved, clearlydefined
npm/npmjs/@babel/types/7.20.7, MIT, approved, #4626
npm/npmjs/@babel/types/7.21.5, MIT AND (BSD-2-Clause AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #7473
npm/npmjs/@babel/types/7.23.0, MIT, approved, clearlydefined
npm/npmjs/@badeball/cypress-configuration/5.0.0, MIT, approved, #8021
npm/npmjs/@badeball/cypress-cucumber-preprocessor/16.0.3, MIT, approved, #8041
npm/npmjs/@bahmutov/cypress-esbuild-preprocessor/2.2.0, MIT, approved, clearlydefined
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/mocks/services/alerts-mock/alerts.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const commonHandler = [
];

export const alertsHandlers = [
rest.get(`*${environment.apiUrl}/alerts/created`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/alerts`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [
Expand All @@ -65,7 +65,7 @@ export const alertsHandlers = [
return res(ctx.status(200), ctx.json(applyPagination(buildMockAlerts(currentStatus, 'SENDER'), pagination)));
}),

rest.get(`*${environment.apiUrl}/alerts/received`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/alerts`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [
Expand Down Expand Up @@ -120,7 +120,7 @@ export const alertsHandlers = [
];

export const alertsTestHandlers = [
rest.get(`*${environment.apiUrl}/alerts/created`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/alerts`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [
Expand All @@ -134,7 +134,7 @@ export const alertsTestHandlers = [
return res(ctx.status(200), ctx.json(applyPagination(testBuildMockAlerts(currentStatus, 'SENDER'), pagination)));
}),

rest.get(`*${environment.apiUrl}/alerts/received`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/alerts`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [NotificationStatus.RECEIVED, NotificationStatus.ACKNOWLEDGED];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const commonHandler = [
];

export const investigationsHandlers = [
rest.get(`*${environment.apiUrl}/investigations/created`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/investigations`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [
Expand All @@ -68,7 +68,7 @@ export const investigationsHandlers = [
);
}),

rest.get(`*${environment.apiUrl}/investigations/received`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/investigations`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [
Expand Down Expand Up @@ -126,7 +126,7 @@ export const investigationsHandlers = [
];

export const investigationsTestHandlers = [
rest.get(`*${environment.apiUrl}/investigations/created`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/investigations`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [
Expand All @@ -143,7 +143,7 @@ export const investigationsTestHandlers = [
);
}),

rest.get(`*${environment.apiUrl}/investigations/received`, (req, res, ctx) => {
rest.get(`*${environment.apiUrl}/investigations`, (req, res, ctx) => {
const pagination = extractPagination(req);

const currentStatus = [NotificationStatus.RECEIVED, NotificationStatus.ACKNOWLEDGED];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ export const otherPartsAsBuiltHandlers = [
rest.get(`*${environment.apiUrl}/assets/as-built`, (req, res, ctx) => {
const pagination = extractPagination(req);
const ownerSearchQuery = req.url.searchParams.get('filter').replace("owner,EQUAL,", "");

switch (ownerSearchQuery) {
case 'SUPPLIER':
case 'SUPPLIER,AND':
return res(ctx.status(200), ctx.json(mockSupplierAssets));

case 'CUSTOMER':
case 'CUSTOMER,AND':
return res(ctx.status(200), ctx.json(mockCustomerAssets));
}

Expand All @@ -47,10 +46,10 @@ export const otherPartsAsBuiltHandlersTest = [
const owner = req.url.searchParams.get('filter').replace("owner,EQUAL,", "");

switch (owner) {
case 'SUPPLIER':
case 'SUPPLIER,AND':
return res(ctx.status(200), ctx.json(mockSupplierAssets));

case 'CUSTOMER':
case 'CUSTOMER,AND':
return res(ctx.status(200), ctx.json(mockCustomerAssets));
}

Expand All @@ -63,10 +62,10 @@ export const otherPartsAsPlannedHandlers = [
const owner = req.url.searchParams.get('filter').replace("owner,EQUAL,", "");

switch (owner) {
case 'SUPPLIER':
case 'SUPPLIER,AND':
return res(ctx.status(200), ctx.json(applyPagination(supplierPartsAsPlannedAssets, pagination)));

case 'CUSTOMER':
case 'CUSTOMER,AND':
return res(ctx.status(200), ctx.json(applyPagination(customerPartsAsPlannedModel, pagination)));
}

Expand All @@ -79,10 +78,10 @@ export const otherPartsAsPlannedHandlersTest = [
const owner = req.url.searchParams.get('filter').replace("owner,EQUAL,", "");

switch (owner) {
case 'SUPPLIER':
case 'SUPPLIER,AND':
return res(ctx.status(200), ctx.json(supplierPartsAsPlannedAssets));

case 'CUSTOMER':
case 'CUSTOMER,AND':
return res(ctx.status(200), ctx.json(applyPagination(customerPartsAsPlannedModel, pagination)));
}

Expand Down
5 changes: 3 additions & 2 deletions frontend/src/app/modules/core/api/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import { AuthService } from '../auth/auth.service';
providedIn: 'root',
})
export class ApiService {
constructor(private readonly httpClient: HttpClient, private readonly authService: AuthService) {}
constructor(private readonly httpClient: HttpClient, private readonly authService: AuthService) {
}

private static stringifyBody<T>(body: T | null): string {
return JSON.stringify(body === null ? {} : body);
Expand Down Expand Up @@ -57,7 +58,7 @@ export class ApiService {
headers?: HttpHeaders,
params?: HttpParams,
): Observable<T> {
const urlWithParams = params ? `${url}${params}` : url;
const urlWithParams = params ? `${ url }${ params }` : url;
return this.httpClient.post<T>(urlWithParams, ApiService.stringifyBody(body), {
headers: headers ? headers : this.buildHeaders(),
responseType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ export class OtherPartsService {

public getOtherPartsAsBuilt(page: number, pageSize: number, sorting: TableHeaderSort[], owner: Owner, filter?: AssetAsBuiltFilter, isOrSearch?: boolean): Observable<Pagination<Part>> {
let sort = sorting.map(sortingItem => PartsAssembler.mapSortToApiSort(sortingItem));
let params = this.buildHttpParams(page, pageSize, isOrSearch, owner);
let params = this.buildHttpParams(page, pageSize, owner);
let filterOperator = isOrSearch? "OR":"AND";

sort.forEach(sortingItem => {
params = params.append('sort', sortingItem);
});

if (filter) {
params = enrichFilterAndGetUpdatedParams(filter, params);
params = enrichFilterAndGetUpdatedParams(filter, params, filterOperator);
}
return this.apiService
.getBy<PartsResponse>(`${ this.url }/assets/as-built`, params)
Expand All @@ -61,27 +62,27 @@ export class OtherPartsService {
let sort = sorting.map(sortingItem => PartsAssembler.mapSortToApiSort(sortingItem));


let params = this.buildHttpParams(page, pageSize, isOrSearch, owner);
let params = this.buildHttpParams(page, pageSize, owner);
let filterOperator = isOrSearch? "OR":"AND";


sort.forEach(sortingItem => {
params = params.append('sort', sortingItem);
});
if (filter) {
params = enrichFilterAndGetUpdatedParams(filter, params);
params = enrichFilterAndGetUpdatedParams(filter, params, filterOperator);
}

return this.apiService
.getBy<PartsResponse>(`${ this.url }/assets/as-planned`, params)
.pipe(map(parts => PartsAssembler.assembleOtherParts(parts, MainAspectType.AS_PLANNED)));
}

private buildHttpParams(page: number, pageSize: number, isOrSearch: boolean, owner: Owner): HttpParams{
let filterOperator = isOrSearch ? 'OR' : 'AND';
private buildHttpParams(page: number, pageSize: number, owner: Owner): HttpParams{
return new HttpParams()
.set('page', page)
.set('size', pageSize)
.set('filterOperator', filterOperator)
.set('filter', 'owner,EQUAL,' + owner);
.set('filter', 'owner,EQUAL,' + owner + ',AND');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<input [disabled]="!textSearch" #searchInput [(ngModel)]="theSearchElement" type="text"
[ngClass]="{'pl-1': !multiple}"
(input)="filterItem(searchInput.value)"
[placeholder]="textSearch ? 'Search..': 'Choose..'">
[placeholder]="textSearch ? ('multiSelect.searchPlaceholder' | i18n): ('multiSelect.choosePlaceholder'| i18n)">
<div class="box-search-icon" (click)="filterItem(''); clickClear()">
<button mat-icon-button class="search-button">
<mat-icon class="mat-24" aria-label="Search icon">clear</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<ng-container matColumnDef="{{ filter.headerKey }}" *ngFor="let filter of filterConfiguration">
<th class="multi-select-header-cell" mat-header-cell *matHeaderCellDef>
<app-multiselect *ngIf="filter.headerKey!==filterKey"
[placeholder]="'All'"
[placeholder]="'multiSelect.placeholder' | i18n"
[options]="filter.option"
[multiple]='isMultipleSearch(filter)'
[textSearch]='filter.isTextSearch'
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/modules/shared/helper/filter-helper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
********************************************************************************/

import { HttpParams } from '@angular/common/http';
import { enrichFilterAndGetUpdatedParams } from './filter-helper'
import { enrichFilterAndGetUpdatedParams } from './filter-helper';

describe('enrichFilterAndGetUpdatedParams', () => {
it('should append filter parameters for non-date filters', () => {
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('enrichFilterAndGetUpdatedParams', () => {
semanticDataModel: ['value1', 'value2'],
};
const params = new HttpParams();
const result = enrichFilterAndGetUpdatedParams(filter, params);
const result = enrichFilterAndGetUpdatedParams(filter, params, "OR");
expect(result.toString()).toContain('filter=semanticDataModel,EQUAL,value1');
expect(result.toString()).toContain('filter=semanticDataModel,EQUAL,value2');
});
Expand Down
Loading

0 comments on commit 088970e

Please sign in to comment.