From 7cfe9c312dab0f3700bf92f82a5a1da74cf6b670 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 9 Oct 2024 20:51:44 +0200 Subject: [PATCH 1/7] Add create report definition --- plugins/main/public/plugin.ts | 5 + .../reporting/dashboards-generate-reports.ts | 13 + .../reporting/html_template.html | 447 ++++++++++++++++++ .../reporting/reporting-definitions.ts | 112 +++++ 4 files changed, 577 insertions(+) create mode 100644 plugins/main/public/react-services/reporting/dashboards-generate-reports.ts create mode 100644 plugins/main/public/react-services/reporting/html_template.html create mode 100644 plugins/main/public/react-services/reporting/reporting-definitions.ts diff --git a/plugins/main/public/plugin.ts b/plugins/main/public/plugin.ts index 1e58ec444b..6e62f4753a 100644 --- a/plugins/main/public/plugin.ts +++ b/plugins/main/public/plugin.ts @@ -49,6 +49,7 @@ import { Applications, Categories } from './utils/applications'; import { euiPaletteColorBlind } from '@elastic/eui'; import NavigationService from './react-services/navigation-service'; import { createHashHistory } from 'history'; +import { reportingDefinitions } from './react-services/reporting/reporting-definitions'; export class WazuhPlugin implements @@ -214,6 +215,10 @@ export class WazuhPlugin setWazuhCorePlugin(plugins.wazuhCore); setWazuhEnginePlugin(plugins.wazuhEngine); setWazuhFleetPlugin(plugins.wazuhFleet); + + // Create the reporting definitions + reportingDefinitions.validateIfReportDefinitionExist(); + return {}; } } diff --git a/plugins/main/public/react-services/reporting/dashboards-generate-reports.ts b/plugins/main/public/react-services/reporting/dashboards-generate-reports.ts new file mode 100644 index 0000000000..aebb7e248c --- /dev/null +++ b/plugins/main/public/react-services/reporting/dashboards-generate-reports.ts @@ -0,0 +1,13 @@ +export interface DashboardGenerateReport { + idDashboardByReference: string; + titleReport: string; +} + +const vulnerabilityDetectionDashboardReport: DashboardGenerateReport = { + idDashboardByReference: '94febc80-55a2-11ef-a580-5b5ba88681be', + titleReport: 'Vulnerability Detection Dashboard Report' +}; + +export const DASHBOARDS_GENERATE_REPORTS: Array = [ + vulnerabilityDetectionDashboardReport +]; diff --git a/plugins/main/public/react-services/reporting/html_template.html b/plugins/main/public/react-services/reporting/html_template.html new file mode 100644 index 0000000000..3ab854c262 --- /dev/null +++ b/plugins/main/public/react-services/reporting/html_template.html @@ -0,0 +1,447 @@ + + + + + Wazuh dashboard email template + + + + + A new Wazuh Dashboards report is available         +                     +                     +                     +                     +                     +                     +               + + + + + + + + diff --git a/plugins/main/public/react-services/reporting/reporting-definitions.ts b/plugins/main/public/react-services/reporting/reporting-definitions.ts new file mode 100644 index 0000000000..3bc4ff4271 --- /dev/null +++ b/plugins/main/public/react-services/reporting/reporting-definitions.ts @@ -0,0 +1,112 @@ +import { SavedObject } from '../saved-objects'; +import { WzRequest } from '../wz-request'; +import { + DashboardGenerateReport, + DASHBOARDS_GENERATE_REPORTS +} from './dashboards-generate-reports'; + +export class reportingDefinitions { + /** + * Create report */ + static async createReportDefinition(dashboard: DashboardGenerateReport) { + try { + const postReport = await WzRequest.genericReq( + 'POST', + '/api/reporting/reportDefinition', + { + report_params: { + report_name: dashboard.titleReport, + report_source: 'Dashboard', + description: '', + core_params: { + base_url: `/app/dashboards#/view/${dashboard.idDashboardByReference}`, + report_format: 'pdf', + time_duration: 'PT30M' + } + }, + delivery: { + configIds: [], + title: '', + textDescription: '', + htmlDescription: '' + }, + trigger: { + trigger_type: 'Schedule', + trigger_params: { + enabled_time: 1728473660771, + schedule: { + interval: { + period: 1, + unit: 'DAYS', + start_time: 1728473700000 + } + }, + schedule_type: 'Recurring', + enabled: false + } + } + } + ); + return postReport; + } catch (error) { + throw error?.data?.message || false + ? new Error(error.data.message) + : error; + } + } + + /** + * Get report */ + static async getReportDefinitions() { + try { + const getReport = await WzRequest.genericReq( + 'GET', + '/api/reporting/reportDefinitions' + ); + return getReport; + } catch (error) { + throw error?.data?.message || false + ? new Error(error.data.message) + : error; + } + } + + /** + * Validate if the report exists + * If the report does not exist, it is created */ + static async validateIfReportDefinitionExist() { + try { + const reportsDefinitionsRes = await this.getReportDefinitions(); + const reportsDefinitionsList = reportsDefinitionsRes?.data?.data; + const dashboardsByReferenceRes = await SavedObject.getAllDashboards(); + const dashboardsByReferenceList = + dashboardsByReferenceRes?.data?.saved_objects; + DASHBOARDS_GENERATE_REPORTS.forEach(async dashboard => { + const reportDefinitionNoExist = reportsDefinitionsList?.every( + report => + report?._source?.report_definition?.report_params?.report_name !== + dashboard.titleReport + ); + console.log(reportDefinitionNoExist); + if (!reportDefinitionNoExist) { + return; + } + + const dashboardByRenferenceNoExist = dashboardsByReferenceList.every( + dashboardByReference => + dashboardByReference.id !== dashboard.idDashboardByReference + ); + + if (dashboardByRenferenceNoExist) { + return; + } + + await this.createReportDefinition(dashboard); + }); + } catch (error) { + throw error?.data?.message || false + ? new Error(error.data.message) + : error; + } + } +} From 6fbe151baaac7172820ad6ef85c8b1b814e831a3 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 9 Oct 2024 21:00:02 +0200 Subject: [PATCH 2/7] rename file and remove console.log --- .../reporting/{html_template.html => html-template.html} | 0 .../public/react-services/reporting/reporting-definitions.ts | 1 - 2 files changed, 1 deletion(-) rename plugins/main/public/react-services/reporting/{html_template.html => html-template.html} (100%) diff --git a/plugins/main/public/react-services/reporting/html_template.html b/plugins/main/public/react-services/reporting/html-template.html similarity index 100% rename from plugins/main/public/react-services/reporting/html_template.html rename to plugins/main/public/react-services/reporting/html-template.html diff --git a/plugins/main/public/react-services/reporting/reporting-definitions.ts b/plugins/main/public/react-services/reporting/reporting-definitions.ts index 3bc4ff4271..c00821def6 100644 --- a/plugins/main/public/react-services/reporting/reporting-definitions.ts +++ b/plugins/main/public/react-services/reporting/reporting-definitions.ts @@ -87,7 +87,6 @@ export class reportingDefinitions { report?._source?.report_definition?.report_params?.report_name !== dashboard.titleReport ); - console.log(reportDefinitionNoExist); if (!reportDefinitionNoExist) { return; } From b7828f256ef142f923e0a08d620f847ade7493d3 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Thu, 10 Oct 2024 14:56:58 +0200 Subject: [PATCH 3/7] Add template body --- .vscode/settings.json | 17 + .../react-services/reporting/html-template.ts | 448 ++++++++++++++++++ .../reporting/reporting-definitions.ts | 31 +- 3 files changed, 481 insertions(+), 15 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 plugins/main/public/react-services/reporting/html-template.ts diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..b96fcd2154 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,17 @@ +{ + "diffEditor.ignoreTrimWhitespace": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnPaste": true, + "editor.formatOnSave": true, + "editor.inlineSuggest.enabled": true, + "editor.insertSpaces": true, + "editor.minimap.enabled": true, + "editor.rulers": [80, 100], + "editor.tabSize": 2, + "editor.trimAutoWhitespace": true, + "editor.wordWrap": "on", + "explorer.confirmDelete": true, + "files.autoSave": "off", + "javascript.updateImportsOnFileMove.enabled": "always", + "typescript.updateImportsOnFileMove.enabled": "always" +} diff --git a/plugins/main/public/react-services/reporting/html-template.ts b/plugins/main/public/react-services/reporting/html-template.ts new file mode 100644 index 0000000000..ea0a5c3c1a --- /dev/null +++ b/plugins/main/public/react-services/reporting/html-template.ts @@ -0,0 +1,448 @@ +export const htmlTemplate = ` + + + + Wazuh dashboard email template + + + + + A new Wazuh Dashboards report is available         +                     +                     +                     +                     +                     +                     +               + + + + + + + + +`; diff --git a/plugins/main/public/react-services/reporting/reporting-definitions.ts b/plugins/main/public/react-services/reporting/reporting-definitions.ts index c00821def6..f0c8976ae8 100644 --- a/plugins/main/public/react-services/reporting/reporting-definitions.ts +++ b/plugins/main/public/react-services/reporting/reporting-definitions.ts @@ -2,8 +2,9 @@ import { SavedObject } from '../saved-objects'; import { WzRequest } from '../wz-request'; import { DashboardGenerateReport, - DASHBOARDS_GENERATE_REPORTS + DASHBOARDS_GENERATE_REPORTS, } from './dashboards-generate-reports'; +import { htmlTemplate } from './html-template'; export class reportingDefinitions { /** @@ -21,14 +22,14 @@ export class reportingDefinitions { core_params: { base_url: `/app/dashboards#/view/${dashboard.idDashboardByReference}`, report_format: 'pdf', - time_duration: 'PT30M' - } + time_duration: 'PT30M', + }, }, delivery: { configIds: [], - title: '', - textDescription: '', - htmlDescription: '' + title: dashboard.titleReport, + textDescription: htmlTemplate, + htmlDescription: htmlTemplate, }, trigger: { trigger_type: 'Schedule', @@ -38,14 +39,14 @@ export class reportingDefinitions { interval: { period: 1, unit: 'DAYS', - start_time: 1728473700000 - } + start_time: 1728473700000, + }, }, schedule_type: 'Recurring', - enabled: false - } - } - } + enabled: false, + }, + }, + }, ); return postReport; } catch (error) { @@ -61,7 +62,7 @@ export class reportingDefinitions { try { const getReport = await WzRequest.genericReq( 'GET', - '/api/reporting/reportDefinitions' + '/api/reporting/reportDefinitions', ); return getReport; } catch (error) { @@ -85,7 +86,7 @@ export class reportingDefinitions { const reportDefinitionNoExist = reportsDefinitionsList?.every( report => report?._source?.report_definition?.report_params?.report_name !== - dashboard.titleReport + dashboard.titleReport, ); if (!reportDefinitionNoExist) { return; @@ -93,7 +94,7 @@ export class reportingDefinitions { const dashboardByRenferenceNoExist = dashboardsByReferenceList.every( dashboardByReference => - dashboardByReference.id !== dashboard.idDashboardByReference + dashboardByReference.id !== dashboard.idDashboardByReference, ); if (dashboardByRenferenceNoExist) { From fa10f444bd1b44cca8de7576b5ca4960b59fd88f Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Tue, 15 Oct 2024 20:30:29 +0200 Subject: [PATCH 4/7] Create report definition when creating dashboard by reference --- plugins/main/public/plugin.ts | 4 -- .../reporting/reporting-definitions.ts | 40 ++++++++----------- .../public/react-services/saved-objects.js | 10 +++++ 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/plugins/main/public/plugin.ts b/plugins/main/public/plugin.ts index 6e62f4753a..87271f0731 100644 --- a/plugins/main/public/plugin.ts +++ b/plugins/main/public/plugin.ts @@ -215,10 +215,6 @@ export class WazuhPlugin setWazuhCorePlugin(plugins.wazuhCore); setWazuhEnginePlugin(plugins.wazuhEngine); setWazuhFleetPlugin(plugins.wazuhFleet); - - // Create the reporting definitions - reportingDefinitions.validateIfReportDefinitionExist(); - return {}; } } diff --git a/plugins/main/public/react-services/reporting/reporting-definitions.ts b/plugins/main/public/react-services/reporting/reporting-definitions.ts index f0c8976ae8..7a0a7db58e 100644 --- a/plugins/main/public/react-services/reporting/reporting-definitions.ts +++ b/plugins/main/public/react-services/reporting/reporting-definitions.ts @@ -75,34 +75,26 @@ export class reportingDefinitions { /** * Validate if the report exists * If the report does not exist, it is created */ - static async validateIfReportDefinitionExist() { + static async validateIfReportDefinitionExist(dashboardId: string) { try { - const reportsDefinitionsRes = await this.getReportDefinitions(); - const reportsDefinitionsList = reportsDefinitionsRes?.data?.data; - const dashboardsByReferenceRes = await SavedObject.getAllDashboards(); - const dashboardsByReferenceList = - dashboardsByReferenceRes?.data?.saved_objects; - DASHBOARDS_GENERATE_REPORTS.forEach(async dashboard => { - const reportDefinitionNoExist = reportsDefinitionsList?.every( - report => - report?._source?.report_definition?.report_params?.report_name !== - dashboard.titleReport, - ); - if (!reportDefinitionNoExist) { - return; - } + const { + data: { data: reportsDefinitionsList }, + } = await this.getReportDefinitions(); - const dashboardByRenferenceNoExist = dashboardsByReferenceList.every( - dashboardByReference => - dashboardByReference.id !== dashboard.idDashboardByReference, - ); + const reportDefinitionNoExist = reportsDefinitionsList?.every( + report => + report?.report_definition?.report_params?.report_name !== dashboardId, + ); + + if (!reportDefinitionNoExist) { + return; + } - if (dashboardByRenferenceNoExist) { - return; - } + const dashboard = DASHBOARDS_GENERATE_REPORTS.filter( + ({ idDashboardByReference }) => idDashboardByReference === dashboardId, + )[0]; - await this.createReportDefinition(dashboard); - }); + await this.createReportDefinition(dashboard); } catch (error) { throw error?.data?.message || false ? new Error(error.data.message) diff --git a/plugins/main/public/react-services/saved-objects.js b/plugins/main/public/react-services/saved-objects.js index 809c028204..831cdac53c 100644 --- a/plugins/main/public/react-services/saved-objects.js +++ b/plugins/main/public/react-services/saved-objects.js @@ -27,6 +27,7 @@ import { webDocumentationLink } from '../../common/services/web_documentation'; import { ErrorFactory } from './error-management'; import { WarningError } from './error-management/error-factory/errors/WarningError'; import { WzRequest } from '../react-services/wz-request'; +import { reportingDefinitions } from './reporting/reporting-definitions'; export class SavedObject { /** @@ -400,6 +401,15 @@ Restart the ${PLUGIN_PLATFORM_NAME} service to initialize the index. More inform formdata, { overwriteHeaders: { 'content-type': 'multipart/form-data' } }, ); + + // Create Report definition + const detailsDashboard = postDashboard.data.successResults.filter( + result => result.type === 'dashboard', + ); + reportingDefinitions.validateIfReportDefinitionExist( + detailsDashboard[0].id, + ); + return postDashboard; } catch (error) { throw ((error || {}).data || {}).message || false From 45d3ed3e831212a92a4f3ec7a46e06b603fa0b45 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Tue, 15 Oct 2024 22:45:50 +0200 Subject: [PATCH 5/7] Add button to reset report definition --- .../poc/dashboards/overview/dashboard.tsx | 14 ++ .../reporting/dashboards-generate-reports.ts | 6 +- .../reporting/reporting-definitions.ts | 131 ++++++++++++------ 3 files changed, 105 insertions(+), 46 deletions(-) diff --git a/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx b/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx index 016eafc76e..a59a9b0ad0 100644 --- a/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx +++ b/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx @@ -9,6 +9,8 @@ import { } from '../../../../common/hocs/validate-states-index-pattern-and-dashboards'; import { SavedObject } from '../../../../../react-services'; import { EuiButton } from '@elastic/eui'; +import { reportingDefinitions } from '../../../../../react-services/reporting/reporting-definitions'; +import { vulnerabilityDetectionDashboardReport } from '../../../../../react-services/reporting/dashboards-generate-reports'; const DashboardByRenderer = getPlugins().dashboard.DashboardContainerByValueRenderer; @@ -139,11 +141,23 @@ const DashboardComponent = () => { } }; + const handleRestartReportDefinition = async () => { + await reportingDefinitions.overrideReportDefinition( + vulnerabilityDetectionDashboardReport.idDashboardByReference, + ); + }; + return ( <> {idDashboard ? ( <> Restart + + Restart report definition + ) : isLoading ? ( diff --git a/plugins/main/public/react-services/reporting/dashboards-generate-reports.ts b/plugins/main/public/react-services/reporting/dashboards-generate-reports.ts index aebb7e248c..5042dc7d5b 100644 --- a/plugins/main/public/react-services/reporting/dashboards-generate-reports.ts +++ b/plugins/main/public/react-services/reporting/dashboards-generate-reports.ts @@ -3,11 +3,11 @@ export interface DashboardGenerateReport { titleReport: string; } -const vulnerabilityDetectionDashboardReport: DashboardGenerateReport = { +export const vulnerabilityDetectionDashboardReport: DashboardGenerateReport = { idDashboardByReference: '94febc80-55a2-11ef-a580-5b5ba88681be', - titleReport: 'Vulnerability Detection Dashboard Report' + titleReport: 'Vulnerability Detection Dashboard Report', }; export const DASHBOARDS_GENERATE_REPORTS: Array = [ - vulnerabilityDetectionDashboardReport + vulnerabilityDetectionDashboardReport, ]; diff --git a/plugins/main/public/react-services/reporting/reporting-definitions.ts b/plugins/main/public/react-services/reporting/reporting-definitions.ts index 7a0a7db58e..ce0d36565a 100644 --- a/plugins/main/public/react-services/reporting/reporting-definitions.ts +++ b/plugins/main/public/react-services/reporting/reporting-definitions.ts @@ -1,4 +1,3 @@ -import { SavedObject } from '../saved-objects'; import { WzRequest } from '../wz-request'; import { DashboardGenerateReport, @@ -7,46 +6,56 @@ import { import { htmlTemplate } from './html-template'; export class reportingDefinitions { + /** + * Create report body */ + static createReportDefinitionBody(dashboardId: string) { + const dashboard: DashboardGenerateReport = + DASHBOARDS_GENERATE_REPORTS.filter( + ({ idDashboardByReference }) => idDashboardByReference === dashboardId, + )[0]; + return { + report_params: { + report_name: dashboard.titleReport, + report_source: 'Dashboard', + description: '', + core_params: { + base_url: `/app/dashboards#/view/${dashboard.idDashboardByReference}`, + report_format: 'pdf', + time_duration: 'PT30M', + }, + }, + delivery: { + configIds: [], + title: dashboard.titleReport, + textDescription: htmlTemplate, + htmlDescription: htmlTemplate, + }, + trigger: { + trigger_type: 'Schedule', + trigger_params: { + enabled_time: 1728473660771, + schedule: { + interval: { + period: 1, + unit: 'DAYS', + start_time: 1728473700000, + }, + }, + schedule_type: 'Recurring', + enabled: false, + }, + }, + }; + } + /** * Create report */ - static async createReportDefinition(dashboard: DashboardGenerateReport) { + static async createReportDefinition(dashboardId: string) { try { const postReport = await WzRequest.genericReq( 'POST', '/api/reporting/reportDefinition', - { - report_params: { - report_name: dashboard.titleReport, - report_source: 'Dashboard', - description: '', - core_params: { - base_url: `/app/dashboards#/view/${dashboard.idDashboardByReference}`, - report_format: 'pdf', - time_duration: 'PT30M', - }, - }, - delivery: { - configIds: [], - title: dashboard.titleReport, - textDescription: htmlTemplate, - htmlDescription: htmlTemplate, - }, - trigger: { - trigger_type: 'Schedule', - trigger_params: { - enabled_time: 1728473660771, - schedule: { - interval: { - period: 1, - unit: 'DAYS', - start_time: 1728473700000, - }, - }, - schedule_type: 'Recurring', - enabled: false, - }, - }, - }, + this.createReportDefinitionBody(dashboardId), ); return postReport; } catch (error) { @@ -81,20 +90,56 @@ export class reportingDefinitions { data: { data: reportsDefinitionsList }, } = await this.getReportDefinitions(); - const reportDefinitionNoExist = reportsDefinitionsList?.every( - report => - report?.report_definition?.report_params?.report_name !== dashboardId, - ); + const reportDefinitionNoExist = reportsDefinitionsList?.every(report => { + const splitUrl = + report?._source?.report_definition?.report_params?.core_params?.base_url.split( + '/', + ); + return splitUrl[splitUrl.length - 1] !== dashboardId; + }); if (!reportDefinitionNoExist) { return; } - const dashboard = DASHBOARDS_GENERATE_REPORTS.filter( - ({ idDashboardByReference }) => idDashboardByReference === dashboardId, - )[0]; + await this.createReportDefinition(dashboardId); + } catch (error) { + throw error?.data?.message || false + ? new Error(error.data.message) + : error; + } + } + + /** + * Override the report */ + static async overrideReportDefinition(dashboardId: string) { + try { + const { + data: { data: reportsDefinitionsList }, + } = await this.getReportDefinitions(); + + const reportDefinition = reportsDefinitionsList?.find(report => { + const splitUrl = + report?._source?.report_definition?.report_params?.core_params?.base_url.split( + '/', + ); + return splitUrl[splitUrl.length - 1] === dashboardId; + }); + + if (!reportDefinition) { + const reportDefinitionCreated = await this.createReportDefinition( + dashboardId, + ); + return reportDefinitionCreated; + } + + const reportDefinitionEdited = await WzRequest.genericReq( + 'PUT', + `/api/reporting/reportDefinitions/${reportDefinition._id}`, + this.createReportDefinitionBody(dashboardId), + ); - await this.createReportDefinition(dashboard); + return reportDefinitionEdited; } catch (error) { throw error?.data?.message || false ? new Error(error.data.message) From cc9bc3ecdac1b2ed57edc54d8ea1fe9ea2ad1874 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 16 Oct 2024 16:37:56 +0200 Subject: [PATCH 6/7] Add modal restart definition --- .../poc/dashboards/overview/dashboard.tsx | 53 ++++++++++++++++--- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx b/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx index a59a9b0ad0..1419f8ea02 100644 --- a/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx +++ b/plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx @@ -7,10 +7,11 @@ import { withVulnerabilitiesStateDataSource, createDashboard, } from '../../../../common/hocs/validate-states-index-pattern-and-dashboards'; -import { SavedObject } from '../../../../../react-services'; +import { SavedObject, ToastNotifications } from '../../../../../react-services'; import { EuiButton } from '@elastic/eui'; import { reportingDefinitions } from '../../../../../react-services/reporting/reporting-definitions'; import { vulnerabilityDetectionDashboardReport } from '../../../../../react-services/reporting/dashboards-generate-reports'; +import { WzButtonPermissionsModalConfirm } from '../../../../common/buttons'; const DashboardByRenderer = getPlugins().dashboard.DashboardContainerByValueRenderer; @@ -142,9 +143,24 @@ const DashboardComponent = () => { }; const handleRestartReportDefinition = async () => { - await reportingDefinitions.overrideReportDefinition( - vulnerabilityDetectionDashboardReport.idDashboardByReference, - ); + try { + ToastNotifications.add({ + title: 'Restarting report definition...', + color: 'primary', + }); + await reportingDefinitions.overrideReportDefinition( + vulnerabilityDetectionDashboardReport.idDashboardByReference, + ); + ToastNotifications.success({ + title: 'Report definition restarted successfully.', + }); + } catch (error) { + ToastNotifications.error( + 'plugins/main/public/components/overview/poc/dashboards/overview/dashboard.tsx', + error, + ); + } + ToastNotifications; }; return ( @@ -152,12 +168,33 @@ const DashboardComponent = () => { {idDashboard ? ( <> Restart - Restart report definition - + ) : isLoading ? ( From 115fbf3a9abdad2d439e4e5b8b8fff76174b1170 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 16 Oct 2024 17:16:23 +0200 Subject: [PATCH 7/7] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d938fa2ff2..9183bda873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to the Wazuh app project will be documented in this file. ### Added - Support for Wazuh 5.0.0 +- Added creation of report definition when creating dashboard by reference and the button to reset the report [#7091](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7091) ### Removed