@@ -296,22 +296,53 @@ export default {
296296
297297 async getReportsData (page = 1 ) {
298298 this .$emit (' loaded' , false )
299- let queryURL = ` ${ getApiBaseURL ()} /pipeline/reports`
299+ const queryURL = ` ${ getApiBaseURL ()} /pipeline/reports/search `
300300
301- const params = new URLSearchParams ();
302- if ( this . filter ? . scmid != undefined && this .filter ? . scmid != ' ' && this . filter ? . scmid != null ) {
303- params . append ( ' scmid ' , this . filter . scmid );
301+ const requestBody = {
302+ limit : this .itemsPerPage ,
303+ page,
304304 }
305305
306- if (this .filter ? .startTime && this .filter .endTime ) {
307- params .append (' start_time' , this .filter .startTime );
308- params .append (' end_time' , this .filter .endTime );
306+ if (this .filter ? .scmid ) {
307+ requestBody .scmid = this .filter .scmid
309308 }
310309
311- params .append (' limit' , this .itemsPerPage );
312- params .append (' page' , this .currentPage );
310+ if (this .filter ? .sourceid ) {
311+ requestBody .sourceid = this .filter .sourceid
312+ }
313+
314+ if (this .filter ? .conditionid ) {
315+ requestBody .conditionid = this .filter .conditionid
316+ }
317+
318+ if (this .filter ? .targetid ) {
319+ requestBody .targetid = this .filter .targetid
320+ }
321+
322+ if (this .filter ? .startTime && this .filter ? .endTime ) {
323+ requestBody .start_time = this .filter .startTime
324+ requestBody .end_time = this .filter .endTime
325+ }
326+
327+ if (typeof this .filter ? .latest === ' boolean' ) {
328+ requestBody .latest = this .filter .latest
329+ }
313330
314- queryURL += ` ?${ params .toString ()} ` ;
331+ // The search API expects labels as a key/value map object.
332+ if (this .filter ? .labels ) {
333+ if (typeof this .filter .labels === ' object' && ! Array .isArray (this .filter .labels )) {
334+ const labels = {}
335+ Object .entries (this .filter .labels ).forEach (([key , value ]) => {
336+ if (typeof key === ' string' && value !== undefined && value !== null ) {
337+ labels[key] = String (value)
338+ }
339+ })
340+
341+ if (Object .keys (labels).length > 0 ) {
342+ requestBody .labels = labels
343+ }
344+ }
345+ }
315346
316347 const isAuthEnabled = process .env .VUE_APP_AUTH_ENABLED === ' true' ;
317348
@@ -320,12 +351,21 @@ export default {
320351 if (isAuthEnabled) {
321352 const token = await this .$auth0 .getAccessTokenSilently ();
322353 response = await fetch (queryURL, {
354+ method: ' POST' ,
323355 headers: {
324- Authorization: ` Bearer ${ token} `
325- }
356+ Authorization: ` Bearer ${ token} ` ,
357+ ' Content-Type' : ' application/json' ,
358+ },
359+ body: JSON .stringify (requestBody),
326360 });
327361 } else {
328- response = await fetch (queryURL);
362+ response = await fetch (queryURL, {
363+ method: ' POST' ,
364+ headers: {
365+ ' Content-Type' : ' application/json' ,
366+ },
367+ body: JSON .stringify (requestBody),
368+ });
329369 }
330370
331371 if (! response .ok ) {
0 commit comments