Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions demo/monitoring-all-process-instances/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
const timeUseCase = new MonitoringUseCase('time', getHardwareRetailerDiagram, new TimeExecutionData());
const frequencyUseCase = new MonitoringUseCase('frequency', getHardwareRetailerDiagram, new FrequencyExecutionData());

// Initialize state of radio buttons
/**
* @param {string} useCaseType
* @returns {MonitoringUseCase}
*/
const detectActualUseCase = useCaseType => useCaseType === 'frequency' ? frequencyUseCase : timeUseCase

// Initialize the state and the radio buttons
const parameters = new URLSearchParams(window.location.search);
const state = {
useCase: timeUseCase,
dataType: 'both'
useCase: detectActualUseCase(['frequency', 'time'].includes(parameters.get('useCase')) ? parameters.get('useCase') : 'time'),
dataType: ['both', 'overlays', 'paths'].includes(parameters.get('dataType')) ? parameters.get('dataType') : 'both'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought (non-blocking):
Maybe we can extract the pattern in a method with parameters like values, parameterValue, defaultValue.

Copy link
Member Author

@tbouffard tbouffard Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check this when implementing the same behavior for the Hacktoberfest demo (#456).

}
document.getElementById('btn-time').checked = true;
document.getElementById(`btn-${state.useCase.type}`).checked = true;
document.getElementById(`btn-${state.dataType}`).checked = true;

document.addEventListener('DOMContentLoaded', function () {
Expand All @@ -17,7 +24,7 @@ document.addEventListener('DOMContentLoaded', function () {

document.getElementById('choose-use-case-panel').onchange = () => {
const useCaseType = document.querySelector("input[type='radio'][name='use-case-type']:checked").value;
state.useCase = useCaseType === 'frequency' ? frequencyUseCase : timeUseCase;
state.useCase = detectActualUseCase(useCaseType);

state.useCase.display(state.dataType);
}
Expand Down
4 changes: 4 additions & 0 deletions demo/static/js/use-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class UseCase {
this.#loadOptions = {...defaultLoadOptions, ...loadOptions};
}

get type() {
return this.#type;
}

display(dataType) {
this._displayPanel();

Expand Down