|
83 | 83 | :key="status" |
84 | 84 | :color="getStatusColor(status)" |
85 | 85 | size="x-small" |
86 | | - class="mr-1 mb-1" |
| 86 | + class="status-chip" |
87 | 87 | > |
88 | | - {{ status }} {{ count }} |
| 88 | + <span class="status-chip-status">{{ status }}</span> |
| 89 | + <span class="status-chip-value">{{ getStatusPercentage(count, branchData.total_result) }}</span> |
89 | 90 | </v-chip> |
90 | 91 | </div> |
91 | 92 | </v-col> |
|
133 | 134 | :key="status" |
134 | 135 | :color="getStatusColor(status)" |
135 | 136 | size="x-small" |
136 | | - class="mr-1 mb-1" |
| 137 | + class="status-chip" |
137 | 138 | > |
138 | | - {{ status }} {{ count }} |
| 139 | + <span class="status-chip-status">{{ status }}</span> |
| 140 | + <span class="status-chip-value">{{ getStatusPercentage(count, branchData.total_result) }}</span> |
139 | 141 | </v-chip> |
140 | 142 | </div> |
141 | 143 | </div> |
@@ -266,17 +268,16 @@ export default { |
266 | 268 | loadedPages: new Set(), |
267 | 269 | }), |
268 | 270 |
|
269 | | - watch: { |
270 | | - filter: async function(newFilter, oldFilter) { |
271 | | - const newScmId = newFilter.scmid || ""; |
272 | | - const oldScmId = oldFilter.scmid || ""; |
273 | | - if (newScmId !== oldScmId) { |
274 | | - this.stopSequentialLoad(); // cancel any in-flight sequential loads |
275 | | - this.resetPagination(); |
276 | | - await this.loadSequentialPages(9); // or desired number |
277 | | - } |
278 | | - } |
279 | | - }, |
| 271 | + watch: { |
| 272 | + filter: { |
| 273 | + deep: true, |
| 274 | + async handler() { |
| 275 | + this.stopSequentialLoad(); |
| 276 | + this.resetPagination(); |
| 277 | + await this.loadSequentialPages(9); |
| 278 | + }, |
| 279 | + }, |
| 280 | + }, |
280 | 281 |
|
281 | 282 | methods: { |
282 | 283 | isNoData() { |
@@ -343,41 +344,63 @@ export default { |
343 | 344 | this.isLoading= true; |
344 | 345 | this.$emit('loaded', false) |
345 | 346 |
|
346 | | - try { |
| 347 | + try { |
347 | 348 | const auth_enabled = process.env.VUE_APP_AUTH_ENABLED === 'true'; |
348 | 349 | const restrictedSCM = router.currentRoute.value.query.filter?.scmid; |
349 | 350 |
|
350 | | - // Build query with pagination parameters |
351 | | - const params = new URLSearchParams(); |
352 | | - params.append('summary', 'true'); |
353 | | - params.append('limit', this.itemsPerPage); |
354 | | - params.append('page', page); |
| 351 | + const requestBody = { |
| 352 | + summary: true, |
| 353 | + limit: this.itemsPerPage, |
| 354 | + page, |
| 355 | + }; |
355 | 356 |
|
356 | 357 | // Add SCM ID filter if provided |
357 | 358 | if (restrictedSCM) { |
358 | | - params.append('scmid', restrictedSCM); |
| 359 | + requestBody.scmid = restrictedSCM; |
359 | 360 | } else if (this.filter?.scmid && this.filter?.scmid !== '') { |
360 | | - params.append('scmid', this.filter.scmid); |
| 361 | + requestBody.scmid = this.filter.scmid; |
361 | 362 | } |
362 | 363 |
|
363 | 364 | // Add starttime and endtime filters if provided |
364 | 365 | if (this.filter?.startTime && this.filter.endTime ) { |
365 | | - params.append('start_time', this.filter.startTime); |
366 | | - params.append('end_time', this.filter.endTime); |
| 366 | + requestBody.start_time = this.filter.startTime; |
| 367 | + requestBody.end_time = this.filter.endTime; |
| 368 | + } |
| 369 | +
|
| 370 | + if (this.filter?.labels && typeof this.filter.labels === 'object' && !Array.isArray(this.filter.labels)) { |
| 371 | + const labels = {}; |
| 372 | + Object.entries(this.filter.labels).forEach(([key, value]) => { |
| 373 | + if (typeof key === 'string' && value !== undefined && value !== null) { |
| 374 | + labels[key] = String(value); |
| 375 | + } |
| 376 | + }); |
| 377 | +
|
| 378 | + if (Object.keys(labels).length > 0) { |
| 379 | + requestBody.labels = labels; |
| 380 | + } |
367 | 381 | } |
368 | 382 |
|
369 | | - let query = `${getApiBaseURL()}/pipeline/scms?${params.toString()}`; |
| 383 | + const query = `${getApiBaseURL()}/pipeline/scms/search`; |
370 | 384 |
|
371 | 385 | let response; |
372 | 386 | if (auth_enabled) { |
373 | 387 | const token = await this.$auth0.getAccessTokenSilently(); |
374 | 388 | response = await fetch(query, { |
| 389 | + method: 'POST', |
375 | 390 | headers: { |
376 | | - Authorization: `Bearer ${token}` |
377 | | - } |
| 391 | + Authorization: `Bearer ${token}`, |
| 392 | + 'Content-Type': 'application/json', |
| 393 | + }, |
| 394 | + body: JSON.stringify(requestBody), |
378 | 395 | }); |
379 | 396 | } else { |
380 | | - response = await fetch(query); |
| 397 | + response = await fetch(query, { |
| 398 | + method: 'POST', |
| 399 | + headers: { |
| 400 | + 'Content-Type': 'application/json', |
| 401 | + }, |
| 402 | + body: JSON.stringify(requestBody), |
| 403 | + }); |
381 | 404 | } |
382 | 405 |
|
383 | 406 | if (!response.ok) { |
@@ -560,6 +583,17 @@ export default { |
560 | 583 | default: return 'purple'; |
561 | 584 | } |
562 | 585 | }, |
| 586 | +
|
| 587 | + getStatusPercentage(count, total) { |
| 588 | + const safeCount = Number(count) || 0; |
| 589 | + const safeTotal = Number(total) || 0; |
| 590 | +
|
| 591 | + if (safeTotal <= 0) { |
| 592 | + return '0%'; |
| 593 | + } |
| 594 | +
|
| 595 | + return `${Math.round((safeCount / safeTotal) * 100)}%`; |
| 596 | + }, |
563 | 597 | }, |
564 | 598 | async created() { |
565 | 599 | try { |
@@ -613,7 +647,34 @@ export default { |
613 | 647 | } |
614 | 648 |
|
615 | 649 | .status-summary { |
616 | | - max-width: 200px; |
| 650 | + max-width: 220px; |
| 651 | + display: flex; |
| 652 | + flex-direction: column; |
| 653 | + align-items: flex-start; |
| 654 | + gap: 6px; |
| 655 | +} |
| 656 | +
|
| 657 | +.status-chip { |
| 658 | + margin: 0; |
| 659 | + width: 100%; |
| 660 | + justify-content: stretch; |
| 661 | +} |
| 662 | +
|
| 663 | +.status-chip :deep(.v-chip__content) { |
| 664 | + width: 100%; |
| 665 | + display: flex; |
| 666 | + align-items: center; |
| 667 | +} |
| 668 | +
|
| 669 | +.status-chip-status { |
| 670 | + font-weight: 600; |
| 671 | +} |
| 672 | +
|
| 673 | +.status-chip-value { |
| 674 | + margin-left: auto; |
| 675 | + min-width: 48px; |
| 676 | + text-align: right; |
| 677 | + font-variant-numeric: tabular-nums; |
617 | 678 | } |
618 | 679 |
|
619 | 680 | .branch-info { |
|
0 commit comments