+ Are you sure you want to remove the BOM and all its components?
+
+ Cancel
+ Remove
+
+
@@ -400,6 +420,56 @@ export default {
}
this.$refs.table.uncheckAll();
},
+ handleRemoveBom() {
+ this.$refs.confirmModal.hide();
+ this.removeBom();
+ },
+ removeBom: async function () {
+ let getDependenciesUrl = `${this.$api.BASE_URL}/${this.$api.URL_COMPONENT}/project/${this.uuid}`;
+ let deleteBomUrl = `${this.$api.BASE_URL}/${this.$api.URL_BOM}/project/${this.uuid}`;
+ try {
+ let allDependencies = [];
+ let page = 1;
+ let pageSize = 100;
+ while (true) {
+ let response = await this.axios.get(
+ `${getDependenciesUrl}?page=${page}&size=${pageSize}`,
+ );
+ let dependencies = response.data;
+ if (!dependencies || dependencies.length === 0) break;
+ allDependencies = allDependencies.concat(dependencies);
+ page++;
+ }
+ let batchSize = 50;
+ let lengthAllDependencies = allDependencies.length;
+ if (lengthAllDependencies !== 0) {
+ for (let i = 0; i < allDependencies.length; i += batchSize) {
+ let batch = allDependencies.slice(i, i + batchSize);
+ this.$toastr.s(
+ this.$t('message.removing_dependencies', {
+ n: lengthAllDependencies,
+ }),
+ );
+ lengthAllDependencies -= batch.length;
+ let deletePromises = batch.map((dep) =>
+ this.axios.delete(
+ `${this.$api.BASE_URL}/${this.$api.URL_COMPONENT}/${dep.uuid}`,
+ ),
+ );
+ await Promise.all(deletePromises);
+ this.$refs.table.refresh({ silent: true });
+ }
+ await this.axios.delete(deleteBomUrl);
+ this.$toastr.s(this.$t('message.bom_deleted'));
+ this.$refs.table.removeAll();
+ await this.axios.get(`/api/v1/metrics/project/${this.uuid}/refresh`);
+ } else {
+ this.$toastr.w(this.$t('message.no_bom_available'));
+ }
+ } catch (error) {
+ this.$toastr.w(this.$t('condition.unsuccessful_action'));
+ }
+ },
downloadBom: function (data) {
let url = `${this.$api.BASE_URL}/${this.$api.URL_BOM}/cyclonedx/project/${this.uuid}`;
this.axios