|
40 | 40 | v-permission="PERMISSIONS.PORTFOLIO_MANAGEMENT"
|
41 | 41 | style="margin-left: 0px"
|
42 | 42 | >
|
43 |
| - <span class="fa fa-minus"></span> {{ $t('message.remove_bom') }} |
| 43 | + <span class="fa fa-minus"></span> {{ $t('message.remove_bom') }} |
44 | 44 | </b-button>
|
45 | 45 | <b-dropdown
|
46 | 46 | variant="outline-primary"
|
|
124 | 124 | :uuid="this.uuid"
|
125 | 125 | v-on:refreshTable="refreshTable"
|
126 | 126 | />
|
127 |
| - <b-modal |
128 |
| - ref="confirmModal" |
129 |
| - title="Confirm Removal" |
130 |
| - > |
| 127 | + <b-modal ref="confirmModal" title="Confirm Removal"> |
131 | 128 | <p>Are you sure you want to remove the BOM and all its components?</p>
|
132 | 129 | <div slot="modal-footer">
|
133 |
| - <b-button variant="outline-primary" @click="$refs.confirmModal.hide()">Cancel</b-button> |
134 |
| - <b-button variant="outline-danger" @click="handleRemoveBom">Remove</b-button> |
| 130 | + <b-button variant="outline-primary" @click="$refs.confirmModal.hide()" |
| 131 | + >Cancel</b-button |
| 132 | + > |
| 133 | + <b-button variant="outline-danger" @click="handleRemoveBom" |
| 134 | + >Remove</b-button |
| 135 | + > |
135 | 136 | </div>
|
136 | 137 | </b-modal>
|
137 | 138 | </div>
|
@@ -429,42 +430,44 @@ export default {
|
429 | 430 | try {
|
430 | 431 | let allDependencies = [];
|
431 | 432 | let page = 1;
|
432 |
| - let pageSize = 100; // Adjust based on API limits |
433 |
| - //Step 1: Fetch all dependencies and handling pagination |
| 433 | + let pageSize = 100; |
434 | 434 | while (true) {
|
435 |
| - let response = await this.axios.get(`${getDependenciesUrl}?page=${page}&size=${pageSize}`); |
| 435 | + let response = await this.axios.get( |
| 436 | + `${getDependenciesUrl}?page=${page}&size=${pageSize}`, |
| 437 | + ); |
436 | 438 | let dependencies = response.data;
|
437 | 439 | if (!dependencies || dependencies.length === 0) break;
|
438 | 440 | allDependencies = allDependencies.concat(dependencies);
|
439 | 441 | page++;
|
440 | 442 | }
|
441 |
| - //Step 2: Delete dependencies in batches |
442 | 443 | let batchSize = 50;
|
443 | 444 | let lengthAllDependencies = allDependencies.length;
|
444 | 445 | if (lengthAllDependencies !== 0) {
|
445 |
| - for (let i = 0; i < allDependencies.length; i += batchSize) { |
446 |
| - let batch = allDependencies.slice(i, i + batchSize); |
447 |
| - this.$toastr.s(this.$t("message.removing_dependencies", { n: lengthAllDependencies })); |
448 |
| - lengthAllDependencies -= batch.length; |
449 |
| - let deletePromises = batch.map(dep => |
450 |
| - this.axios.delete(`${this.$api.BASE_URL}/${this.$api.URL_COMPONENT}/${dep.uuid}`) |
451 |
| - ); |
452 |
| - await Promise.all(deletePromises); |
453 |
| - this.$refs.table.refresh({ silent: true }); |
| 446 | + for (let i = 0; i < allDependencies.length; i += batchSize) { |
| 447 | + let batch = allDependencies.slice(i, i + batchSize); |
| 448 | + this.$toastr.s( |
| 449 | + this.$t('message.removing_dependencies', { |
| 450 | + n: lengthAllDependencies, |
| 451 | + }), |
| 452 | + ); |
| 453 | + lengthAllDependencies -= batch.length; |
| 454 | + let deletePromises = batch.map((dep) => |
| 455 | + this.axios.delete( |
| 456 | + `${this.$api.BASE_URL}/${this.$api.URL_COMPONENT}/${dep.uuid}`, |
| 457 | + ), |
| 458 | + ); |
| 459 | + await Promise.all(deletePromises); |
| 460 | + this.$refs.table.refresh({ silent: true }); |
| 461 | + } |
| 462 | + await this.axios.delete(deleteBomUrl); |
| 463 | + this.$toastr.s(this.$t('message.bom_deleted')); |
| 464 | + this.$refs.table.removeAll(); |
| 465 | + await this.axios.get(`/api/v1/metrics/project/${this.uuid}/refresh`); |
| 466 | + } else { |
| 467 | + this.$toastr.w(this.$t('message.no_bom_available')); |
454 | 468 | }
|
455 |
| - //Step 3: Delete the BOM after all its components are removed |
456 |
| - await this.axios.delete(deleteBomUrl); |
457 |
| - this.$toastr.s(this.$t("message.bom_deleted")); |
458 |
| - //Step 4: Refresh the table |
459 |
| - this.$refs.table.removeAll(); |
460 |
| - //Step 5: Refresh the metrics |
461 |
| - await this.axios.get(`/api/v1/metrics/project/${this.uuid}/refresh`); |
462 |
| - } |
463 |
| - else { |
464 |
| - this.$toastr.w(this.$t("message.no_bom_available")); |
465 |
| - } |
466 | 469 | } catch (error) {
|
467 |
| - this.$toastr.w(this.$t("condition.unsuccessful_action")); |
| 470 | + this.$toastr.w(this.$t('condition.unsuccessful_action')); |
468 | 471 | }
|
469 | 472 | },
|
470 | 473 | downloadBom: function (data) {
|
|
0 commit comments