diff --git a/api/net/Areas/Subscriber/Controllers/ReportController.cs b/api/net/Areas/Subscriber/Controllers/ReportController.cs index ec6a8ceeb..ae48f68bb 100644 --- a/api/net/Areas/Subscriber/Controllers/ReportController.cs +++ b/api/net/Areas/Subscriber/Controllers/ReportController.cs @@ -1,6 +1,7 @@ using System.Net; using System.Net.Mime; +using System.Text; using System.Text.Json; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Mvc; @@ -11,15 +12,14 @@ using TNO.API.Helpers; using TNO.API.Models; using TNO.API.Models.SignalR; +using TNO.Ches.Configuration; using TNO.Core.Exceptions; using TNO.DAL.Services; +using TNO.Entities; using TNO.Kafka; using TNO.Kafka.SignalR; using TNO.Keycloak; using TNO.Models.Filters; -using System.Text; -using TNO.Entities; -using TNO.Ches.Configuration; namespace TNO.API.Areas.Subscriber.Controllers; using TNO.Ches; using TNO.Core.Extensions; @@ -356,7 +356,7 @@ public async Task Generate(int id, [FromQuery] bool regenerate = else if (regenerate && currentInstance.SentOn.HasValue) { // Generate a new instance because the prior was sent to CHES. - currentInstance = await _reportService.GenerateReportInstanceAsync(id, user.Id); + currentInstance = await _reportService.GenerateReportInstanceAsync(id, user.Id, null, regenerate); _reportInstanceService.ClearChangeTracker(); currentInstance = _reportInstanceService.AddAndSave(currentInstance); instances = _reportService.GetLatestInstances(id, user.Id); @@ -368,7 +368,7 @@ public async Task Generate(int id, [FromQuery] bool regenerate = else if (regenerate && currentInstance.SentOn.HasValue == false) { // Regenerate the current instance, but do not create a new instance. - var regeneratedInstance = await _reportService.GenerateReportInstanceAsync(id, user.Id, currentInstance.Id); + var regeneratedInstance = await _reportService.GenerateReportInstanceAsync(id, user.Id, currentInstance.Id, regenerate); _reportInstanceService.ClearChangeTracker(); currentInstance.ContentManyToMany.Clear(); var count = 0; diff --git a/app/subscriber/src/components/modal/Modal.tsx b/app/subscriber/src/components/modal/Modal.tsx index 08b28a0a5..1825c0f40 100644 --- a/app/subscriber/src/components/modal/Modal.tsx +++ b/app/subscriber/src/components/modal/Modal.tsx @@ -90,7 +90,7 @@ export const Modal: React.FC = ({ diff --git a/app/subscriber/src/features/my-reports/edit/content/ReportEditContentForm.tsx b/app/subscriber/src/features/my-reports/edit/content/ReportEditContentForm.tsx index 2f609bff0..65f95cb45 100644 --- a/app/subscriber/src/features/my-reports/edit/content/ReportEditContentForm.tsx +++ b/app/subscriber/src/features/my-reports/edit/content/ReportEditContentForm.tsx @@ -10,7 +10,7 @@ import { FaAngleDown, FaMinus } from 'react-icons/fa6'; import { useParams } from 'react-router-dom'; import { useReports, useUsers } from 'store/hooks'; import { useProfileStore } from 'store/slices'; -import { Checkbox, Show, ToggleButton, useModal } from 'tno-core'; +import { Checkbox, Loading, Show, ToggleButton, useModal } from 'tno-core'; import { useReportEditContext } from '../ReportEditContext'; import { ReportSections } from './stories'; @@ -156,6 +156,9 @@ export const ReportEditContentForm = React.forwardRef< }} /> + + +

Do you want to proceed?

} diff --git a/app/subscriber/src/features/my-reports/edit/settings/template/ReportSectionMediaAnalyticsChart.tsx b/app/subscriber/src/features/my-reports/edit/settings/template/ReportSectionMediaAnalyticsChart.tsx index b00547d85..020f299f4 100644 --- a/app/subscriber/src/features/my-reports/edit/settings/template/ReportSectionMediaAnalyticsChart.tsx +++ b/app/subscriber/src/features/my-reports/edit/settings/template/ReportSectionMediaAnalyticsChart.tsx @@ -55,8 +55,14 @@ export const ReportSectionMediaAnalyticsChart = React.forwardRef< }, [values.instances]); React.useEffect(() => { - setData(convertToChart(chart, showReportData ? reportContent : testData, values.sections)); - }, [chart, reportContent, showReportData, testData, values.sections]); + const sectionContent = + section.filterId || section.folderId || section.linkedReportId + ? reportContent.filter((rc) => rc.sectionName === section.name) + : reportContent; + setData( + convertToChart(section, chart, showReportData ? sectionContent : testData, values.sections), + ); + }, [section, chart, reportContent, showReportData, testData, values.sections]); React.useEffect(() => { setReportContent(values.instances ? values.instances[0].content : []); diff --git a/app/subscriber/src/features/my-reports/edit/settings/template/utils/convertToChart.ts b/app/subscriber/src/features/my-reports/edit/settings/template/utils/convertToChart.ts index de99e487f..eb80dad60 100644 --- a/app/subscriber/src/features/my-reports/edit/settings/template/utils/convertToChart.ts +++ b/app/subscriber/src/features/my-reports/edit/settings/template/utils/convertToChart.ts @@ -14,6 +14,7 @@ export interface IConvertToChartOptions { /** * Convert specified data into chart data for chart.js. + * @param section The section the chart belongs in. * @param chart The chart to populate. * @param content An array of report instance content. * @param sections An array of sections in the report. @@ -21,6 +22,7 @@ export interface IConvertToChartOptions { * @returns Chart data. */ export const convertToChart = ( + section: IReportSectionModel, chart: IReportSectionChartTemplateModel, content: IReportInstanceContentModel[], sections: IReportSectionModel[], diff --git a/libs/net/dal/Services/Interfaces/IReportService.cs b/libs/net/dal/Services/Interfaces/IReportService.cs index 293d8a085..9f4941f41 100644 --- a/libs/net/dal/Services/Interfaces/IReportService.cs +++ b/libs/net/dal/Services/Interfaces/IReportService.cs @@ -54,11 +54,13 @@ public interface IReportService : IBaseService /// /// /// + /// /// public Task GenerateReportInstanceAsync( int id, int? requestorId = null, - long? instanceId = null); + long? instanceId = null, + bool regenerate = false); /// /// Regenerate the content for the current report instance for the specified report 'id' and 'sectionId'. diff --git a/libs/net/dal/Services/ReportService.cs b/libs/net/dal/Services/ReportService.cs index ee45d6bd9..b17e083a2 100644 --- a/libs/net/dal/Services/ReportService.cs +++ b/libs/net/dal/Services/ReportService.cs @@ -483,17 +483,19 @@ public override void Delete(Report entity) /// /// /// + /// /// public async Task GenerateReportInstanceAsync( int id, int? requestorId = null, - long? instanceId = null) + long? instanceId = null, + bool regenerate = false) { // Fetch content for every section within the report. This will include folders and filters. var report = FindById(id) ?? throw new NoContentException("Report does not exist"); var reportSettings = JsonSerializer.Deserialize(report.Settings, _serializerOptions) ?? new ReportSettingsModel(); List instanceContent; - if (reportSettings.Content.CopyPriorInstance) + if (reportSettings.Content.CopyPriorInstance && !regenerate) { var currentInstance = GetCurrentReportInstance(report.Id, requestorId) ?? new ReportInstance(report.Id); instanceContent = currentInstance.ContentManyToMany.Select(c => new ReportInstanceContent(0, c.ContentId, c.SectionName, c.SortOrder)).ToList();