Skip to content

Commit

Permalink
feat: runtype based scenario report
Browse files Browse the repository at this point in the history
  • Loading branch information
esasova committed Jun 15, 2022
1 parent 8a65342 commit b2e3bc9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
71 changes: 60 additions & 11 deletions src/config/Dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,86 @@ import {
// https://github.com/microsoft/PowerBI-JavaScript
// using
// https://github.com/microsoft/powerbi-models
export const SCENARIO_DASHBOARD_CONFIG = [
{

const defaultScenarioViewReport = {
title: {
en: 'Scenario dashboard',
fr: 'Rapport du scenario',
},
reportId: '608b7bef-f5e3-4aae-b8db-19bbb38325d5',
settings: {
navContentPaneEnabled: false,
panes: {
filters: {
expanded: false,
visible: false,
},
},
},
staticFilters: [new PowerBIReportEmbedMultipleFilter('Bar', 'Bar', ['MyBar'])],
dynamicFilters: [
new PowerBIReportEmbedSimpleFilter('StockProbe', 'SimulationRun', POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN),
new PowerBIReportEmbedSimpleFilter('Bar', 'simulationrun', POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN),
new PowerBIReportEmbedSimpleFilter(
'contains_Customer',
'simulationrun',
POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN
),
new PowerBIReportEmbedSimpleFilter(
'arc_to_Customer',
'simulationrun',
POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN
),
new PowerBIReportEmbedSimpleFilter('parameters', 'simulationrun', POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN),
new PowerBIReportEmbedSimpleFilter(
'CustomerSatisfactionProbe',
'SimulationRun',
POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN
),
],
pageName: {
en: 'ReportSection',
fr: 'ReportSection',
},
};
export const SCENARIO_VIEW_REPORTS_BY_RUNTEMPLATE = {
1: {
title: {
en: 'Scenario dashboard',
fr: 'Rapport du scenario',
en: 'Scenario dashboard for run type 1',
fr: 'Rapport du scenario du run type 1',
},
reportId: '608b7bef-f5e3-4aae-b8db-19bbb38325d5',
reportId: '70ff6a53-04f9-4076-93c0-328426b78c8f',
settings: {
navContentPaneEnabled: false,
navContentPaneEnabled: true,
filterPaneEnabled: true,
panes: {
filters: {
expanded: false,
visible: false,
expanded: true,
visible: true,
},
},
},
staticFilters: [new PowerBIReportEmbedMultipleFilter('Bar', 'id', ['MyBar', 'MyBar2'])],
staticFilters: [new PowerBIReportEmbedMultipleFilter('Bar', 'Bar', ['MyBar'])],
dynamicFilters: [
new PowerBIReportEmbedSimpleFilter(
'StockProbe',
'SimulationRun',
POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN
),
new PowerBIReportEmbedSimpleFilter(
'contains_Customer',
'simulationrun',
POWER_BI_FIELD_ENUM.SCENARIO_CSM_SIMULATION_RUN
),
],
pageName: {
en: 'ReportSection',
fr: 'ReportSection',
},
},
];

2: defaultScenarioViewReport,
3: defaultScenarioViewReport,
};
// For further information about settings or filters see:
// https://github.com/microsoft/powerbi-client-react
// based on
Expand Down
10 changes: 8 additions & 2 deletions src/views/Scenario/Scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
USE_POWER_BI_WITH_USER_CREDENTIALS,
SCENARIO_VIEW_IFRAME_DISPLAY_RATIO,
} from '../../config/AppConfiguration';
import { SCENARIO_DASHBOARD_CONFIG } from '../../config/Dashboards';
import { SCENARIO_VIEW_REPORTS_BY_RUNTEMPLATE } from '../../config/Dashboards';
import ScenarioService from '../../services/scenario/ScenarioService';
import ScenarioRunService from '../../services/scenarioRun/ScenarioRunService';
import { STATUSES } from '../../state/commons/Constants';
Expand Down Expand Up @@ -61,6 +61,11 @@ const Scenario = (props) => {
const createScenarioDialogLabels = getCreateScenarioDialogLabels(t, editMode);
const reportLabels = getReportLabels(t);

// Get the right report for given run template
const defaultPowerBIREport = Object.keys(SCENARIO_VIEW_REPORTS_BY_RUNTEMPLATE)[0];
const currentScenarioRunTemplateReport = Array.isArray(SCENARIO_VIEW_REPORTS_BY_RUNTEMPLATE)
? SCENARIO_VIEW_REPORTS_BY_RUNTEMPLATE
: [SCENARIO_VIEW_REPORTS_BY_RUNTEMPLATE[currentScenario?.data?.runTemplateId ?? defaultPowerBIREport]];
// Add accordion expand status in state
const [accordionSummaryExpanded, setAccordionSummaryExpanded] = useState(
localStorage.getItem('scenarioParametersAccordionExpanded') === 'true'
Expand Down Expand Up @@ -323,8 +328,9 @@ const Scenario = (props) => {
</Grid>
<Card>
<SimplePowerBIReportEmbed
key={currentScenario.data.id}
reports={reports}
reportConfiguration={SCENARIO_DASHBOARD_CONFIG}
reportConfiguration={currentScenarioRunTemplateReport}
scenario={currentScenario.data}
lang={i18n.language}
downloadLogsFile={currentScenario.data?.lastRun ? downloadLogsFile : null}
Expand Down

0 comments on commit b2e3bc9

Please sign in to comment.