From e29f929a3619a45d11d8d91e412d4674227f9226 Mon Sep 17 00:00:00 2001 From: Sahiba Mittal Date: Fri, 4 Oct 2024 14:38:28 +0100 Subject: [PATCH] functionality to download component table data as CSV Co-Authored-By: Nick Castelli <3475905+nvcastelli@users.noreply.github.com> --- src/i18n/locales/de.json | 2 + src/i18n/locales/en.json | 2 + src/i18n/locales/es.json | 2 + src/i18n/locales/fr.json | 2 + src/i18n/locales/hi.json | 2 + src/i18n/locales/it.json | 2 + src/i18n/locales/ja.json | 2 + src/i18n/locales/pl.json | 2 + src/i18n/locales/pt-BR.json | 2 + src/i18n/locales/pt.json | 2 + src/i18n/locales/ru.json | 2 + src/i18n/locales/uk-UA.json | 2 + src/i18n/locales/zh.json | 2 + .../portfolio/projects/ProjectComponents.vue | 54 +++++++++++++++++++ 14 files changed, 80 insertions(+) diff --git a/src/i18n/locales/de.json b/src/i18n/locales/de.json index 2f7794f6..28ef94cb 100644 --- a/src/i18n/locales/de.json +++ b/src/i18n/locales/de.json @@ -442,6 +442,7 @@ "create_vulnerability": "Schwachstelle schaffen", "created": "Erstellt", "credits": "Credits", + "csv_filetype": "CSV", "custom_license": "Benutzerdefinierte Lizenz", "custom_license_deleted": "Benutzerdefinierte Lizenz gelöscht", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Nur Direkt", "direction": "Richtung", "download_bom": "BOM herunterladen", + "download_component": "Komponenten herunterladen", "email": "E-Mail", "empty_selection": "Keine Elemente ausgewählt", "endpoints": "Endpunkte", diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 94327b2d..f7b276d4 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -442,6 +442,7 @@ "create_vulnerability": "Create Vulnerability", "created": "Created", "credits": "Credits", + "csv_filetype": "CSV ", "custom_license": "Custom License", "custom_license_deleted": "Custom License Deleted", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Direct only", "direction": "Direction", "download_bom": "Download BOM", + "download_component": "Download Components", "email": "Email", "empty_selection": "No items selected", "endpoints": "Endpoints", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index afc2816f..cafb20ab 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -442,6 +442,7 @@ "create_vulnerability": "Crear vulnerabilidad", "created": "Creado", "credits": "Créditos", + "csv_filetype": "CSV", "custom_license": "Licencia personalizada", "custom_license_deleted": "Licencia personalizada eliminada", "cvss": "cvss", @@ -498,6 +499,7 @@ "direct_only": "Solo directo", "direction": "Dirección", "download_bom": "Descargar lista de materiales", + "download_component": "Descargar componentes", "email": "Correo electrónico", "empty_selection": "No hay elementos seleccionados", "endpoints": "Puntos finales", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index 4aadda1e..6ddfd47a 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -442,6 +442,7 @@ "create_vulnerability": "Créer une vulnérabilité", "created": "Créé(e)", "credits": "Crédits", + "csv_filetype": "CSV", "custom_license": "Licence personnalisée", "custom_license_deleted": "Licence personnalisée supprimée", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Direct uniquement", "direction": "Direction", "download_bom": "Télécharger la nomenclature", + "download_component": "Télécharger les composants", "email": "Courriel", "empty_selection": "Aucun élément sélectionné", "endpoints": "Points de terminaison", diff --git a/src/i18n/locales/hi.json b/src/i18n/locales/hi.json index e2a32aab..cdc82e32 100644 --- a/src/i18n/locales/hi.json +++ b/src/i18n/locales/hi.json @@ -442,6 +442,7 @@ "create_vulnerability": "भेद्यता बनाएँ", "created": "बनाया था", "credits": "क्रेडिट", + "csv_filetype": "CSV", "custom_license": "कस्टम लाइसेंस", "custom_license_deleted": "कस्टम लाइसेंस हटाया गया", "cvss": "सीवीएसएस", @@ -498,6 +499,7 @@ "direct_only": "केवल प्रत्यक्ष", "direction": "दिशा", "download_bom": "BOM डाउनलोड करें", + "download_component": "घटक डाउनलोड करें", "email": "ईमेल", "empty_selection": "कोई आइटम चयनित नहीं", "endpoints": "अंतिमबिंदुओं", diff --git a/src/i18n/locales/it.json b/src/i18n/locales/it.json index eab9d425..1b400ed4 100644 --- a/src/i18n/locales/it.json +++ b/src/i18n/locales/it.json @@ -442,6 +442,7 @@ "create_vulnerability": "Crea vulnerabilità", "created": "Creato", "credits": "Crediti", + "csv_filetype": "CSV", "custom_license": "Licenza personalizzata", "custom_license_deleted": "Licenza personalizzata eliminata", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Solo diretto", "direction": "Direzione", "download_bom": "Scarica distinta base", + "download_component": "Scarica Componenti", "email": "E-mail", "empty_selection": "Nessun elemento selezionato", "endpoints": "Endpoint", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 4e461207..15d607cd 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -442,6 +442,7 @@ "create_vulnerability": "脆弱性の追加", "created": "作成日", "credits": "クレジット", + "csv_filetype": "CSV", "custom_license": "カスタムライセンス", "custom_license_deleted": "カスタムライセンスが削除されました", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "直接のみ", "direction": "方向", "download_bom": "BOMをダウンロード", + "download_component": "コンポーネントをダウンロードする", "email": "Eメール", "empty_selection": "項目が選択されていません", "endpoints": "エンドポイント", diff --git a/src/i18n/locales/pl.json b/src/i18n/locales/pl.json index 90085fbf..5dde5c1a 100644 --- a/src/i18n/locales/pl.json +++ b/src/i18n/locales/pl.json @@ -442,6 +442,7 @@ "create_vulnerability": "Utwórz lukę", "created": "Utworzony", "credits": "Kredyty", + "csv_filetype": "CSV", "custom_license": "Licencja niestandardowa", "custom_license_deleted": "Usunięto licencję niestandardową", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Tylko bezpośrednie", "direction": "Kierunek", "download_bom": "Pobierz BOM", + "download_component": "Pobierz komponenty", "email": "E-mail", "empty_selection": "Nie wybrano żadnych elementów", "endpoints": "Punkty końcowe", diff --git a/src/i18n/locales/pt-BR.json b/src/i18n/locales/pt-BR.json index fce3cbc9..7f1edb1c 100644 --- a/src/i18n/locales/pt-BR.json +++ b/src/i18n/locales/pt-BR.json @@ -442,6 +442,7 @@ "create_vulnerability": "Criar vulnerabilidade", "created": "Criada", "credits": "Créditos", + "csv_filetype": "CSV", "custom_license": "Licença personalizada", "custom_license_deleted": "Licença personalizada excluída", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Somente direto", "direction": "Direção", "download_bom": "Baixe a lista técnica", + "download_component": "Baixar componentes", "email": "E-mail", "empty_selection": "Nenhum item selecionado", "endpoints": "Pontos finais", diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index e8e8c4f5..6e0747e4 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -442,6 +442,7 @@ "create_vulnerability": "Criar vulnerabilidade", "created": "Criada", "credits": "Créditos", + "csv_filetype": "CSV", "custom_license": "Licença personalizada", "custom_license_deleted": "Licença personalizada excluída", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Somente direto", "direction": "Direção", "download_bom": "Baixe a lista técnica", + "download_component": "Baixar componentes", "email": "E-mail", "empty_selection": "Nenhum item selecionado", "endpoints": "Pontos finais", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index 8653cdcd..749e9e56 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -442,6 +442,7 @@ "create_vulnerability": "Создать уязвимость", "created": "Созданный", "credits": "Кредиты", + "csv_filetype": "CSV", "custom_license": "Пользовательская лицензия", "custom_license_deleted": "Пользовательская лицензия удалена", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Только прямой", "direction": "Направление", "download_bom": "Скачать спецификацию", + "download_component": "Загрузить компоненты", "email": "Электронная почта", "empty_selection": "Элементы не выбраны", "endpoints": "Конечные точки", diff --git a/src/i18n/locales/uk-UA.json b/src/i18n/locales/uk-UA.json index b33ecb0c..f3c4e525 100644 --- a/src/i18n/locales/uk-UA.json +++ b/src/i18n/locales/uk-UA.json @@ -442,6 +442,7 @@ "create_vulnerability": "Створити вразливість", "created": "Створено", "credits": "Кредити", + "csv_filetype": "CSV", "custom_license": "Спеціальна ліцензія", "custom_license_deleted": "Спеціальну ліцензію видалено", "cvss": "CVSS", @@ -498,6 +499,7 @@ "direct_only": "Тільки прямий", "direction": "Напрямок", "download_bom": "Завантажити BOM", + "download_component": "Завантажити компоненти", "email": "Електронна пошта", "empty_selection": "Елементи не вибрано", "endpoints": "Кінцеві точки", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index a1eea37f..30800ee2 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -442,6 +442,7 @@ "create_vulnerability": "创建漏洞", "created": "创建", "credits": "Credits", + "csv_filetype": "CSV", "custom_license": "自定义许可证", "custom_license_deleted": "自定义许可证已删除", "cvss": "计算机视觉安全标准", @@ -498,6 +499,7 @@ "direct_only": "仅限直接", "direction": "方向", "download_bom": "下载 BOM", + "download_component": "下载组件", "email": "电子邮件", "empty_selection": "没有选择任何项目", "endpoints": "终结点", diff --git a/src/views/portfolio/projects/ProjectComponents.vue b/src/views/portfolio/projects/ProjectComponents.vue index 2d807aeb..b3b0d377 100644 --- a/src/views/portfolio/projects/ProjectComponents.vue +++ b/src/views/portfolio/projects/ProjectComponents.vue @@ -53,6 +53,18 @@ >{{ $t('message.inventory_with_vulnerabilities') }} + + + {{ + $t('message.csv_filetype') + }} + + header.map((header) => get(row, header)).join(','), + ), + ].join('\r\n'); + const url = window.URL.createObjectURL(new Blob([csv])); + const link = document.createElement('a'); + link.href = url; + let filename = 'componentTable.csv'; + link.setAttribute('download', filename); + document.body.appendChild(link); + link.click(); + } + }, + downloadTable: async function (fileType) { + const result = await this.downloadTableJson(); + this.buildTableFile(result, fileType); + }, + downloadTableJson: async function () { + let url = `${this.$api.BASE_URL}/${this.$api.URL_COMPONENT}/project/${this.uuid}?limit=1000000&offset=0`; + try { + let response = await this.axios.get(url); + return response; + } catch (e) { + console.log(e); + return e; + } + }, tableLoaded: function (data) { loadUserPreferencesForBootstrapTable( this,