From a3418653d04093d3a5eb7df3bb19a50bb1aa2041 Mon Sep 17 00:00:00 2001 From: bduran Date: Mon, 2 Oct 2023 10:54:18 -0700 Subject: [PATCH] add filter button to simulation list and plan snapshot list add snapshot control bar to plan page --- .../modals/CreatePlanSnapshotModal.svelte | 2 +- .../modals/RestorePlanSnapshotModal.svelte | 1 + src/components/plan/PlanForm.svelte | 54 ++++++++++++-- src/components/plan/PlanSnapshotBar.svelte | 51 +++++++++++++ .../simulation/SimulationPanel.svelte | 27 +++++++ src/components/ui/FilterToggleButton.svelte | 73 +++++++++++++++++++ src/routes/plans/[id]/+page.svelte | 28 ++++++- src/utilities/generic.ts | 8 +- 8 files changed, 235 insertions(+), 9 deletions(-) create mode 100644 src/components/plan/PlanSnapshotBar.svelte create mode 100644 src/components/ui/FilterToggleButton.svelte diff --git a/src/components/modals/CreatePlanSnapshotModal.svelte b/src/components/modals/CreatePlanSnapshotModal.svelte index b5332b49eb..04fd650776 100644 --- a/src/components/modals/CreatePlanSnapshotModal.svelte +++ b/src/components/modals/CreatePlanSnapshotModal.svelte @@ -101,6 +101,6 @@ diff --git a/src/components/modals/RestorePlanSnapshotModal.svelte b/src/components/modals/RestorePlanSnapshotModal.svelte index 834a17a106..df0c319b1c 100644 --- a/src/components/modals/RestorePlanSnapshotModal.svelte +++ b/src/components/modals/RestorePlanSnapshotModal.svelte @@ -74,6 +74,7 @@ diff --git a/src/components/plan/PlanSnapshotBar.svelte b/src/components/plan/PlanSnapshotBar.svelte new file mode 100644 index 0000000000..faa3079cd7 --- /dev/null +++ b/src/components/plan/PlanSnapshotBar.svelte @@ -0,0 +1,51 @@ + + + + +
+
+
Preview of plan snapshot
+
{snapshot.snapshot_name}
+
{numOfDirectives} directive{numOfDirectives !== 1 ? 's' : ''}
+
+ +
+ + +
+
+ + diff --git a/src/components/simulation/SimulationPanel.svelte b/src/components/simulation/SimulationPanel.svelte index d80938e6b6..f07168dd78 100644 --- a/src/components/simulation/SimulationPanel.svelte +++ b/src/components/simulation/SimulationPanel.svelte @@ -39,6 +39,7 @@ import GridMenu from '../menus/GridMenu.svelte'; import Parameters from '../parameters/Parameters.svelte'; import DatePickerActionButton from '../ui/DatePicker/DatePickerActionButton.svelte'; + import FilterToggleButton from '../ui/FilterToggleButton.svelte'; import Panel from '../ui/Panel.svelte'; import PanelHeaderActionButton from '../ui/PanelHeaderActionButton.svelte'; import PanelHeaderActions from '../ui/PanelHeaderActions.svelte'; @@ -55,6 +56,7 @@ let formParameters: FormParameter[] = []; let hasRunPermission: boolean = false; let hasUpdatePermission: boolean = false; + let isFilteredBySnapshot: boolean = false; let numOfUserChanges: number = 0; let startTimeDoy: string; let startTimeDoyField: FieldStore; @@ -107,6 +109,16 @@ }); } + $: isFilteredBySnapshot = $planSnapshot !== null; + + $: if (isFilteredBySnapshot) { + filteredSimulationDatasets = $simulationDatasetsPlan.filter( + simulationDataset => simulationDataset.plan_revision === $planSnapshot?.revision, + ); + } else { + filteredSimulationDatasets = $simulationDatasetsPlan; + } + $: if ($simulationDatasetsPlan?.length) { if ($planSnapshot) { filteredSimulationDatasets = $simulationDatasetsPlan.filter( @@ -213,6 +225,10 @@ } } + function onToggleFilter() { + isFilteredBySnapshot = !isFilteredBySnapshot; + } + function updateStartTime(doyString: string) { if ($simulation !== null) { const newSimulation: Simulation = { ...$simulation, simulation_start_time: doyString }; @@ -369,6 +385,17 @@
+ + {#if $planSnapshot} + + {/if} +
{#if !filteredSimulationDatasets || !filteredSimulationDatasets.length}
No Simulation Datasets
diff --git a/src/components/ui/FilterToggleButton.svelte b/src/components/ui/FilterToggleButton.svelte new file mode 100644 index 0000000000..344a6c1b82 --- /dev/null +++ b/src/components/ui/FilterToggleButton.svelte @@ -0,0 +1,73 @@ + + + + + + + diff --git a/src/routes/plans/[id]/+page.svelte b/src/routes/plans/[id]/+page.svelte index 05472b4d16..b8666fd43b 100644 --- a/src/routes/plans/[id]/+page.svelte +++ b/src/routes/plans/[id]/+page.svelte @@ -19,12 +19,14 @@ import ViewMenu from '../../../components/menus/ViewMenu.svelte'; import PlanMergeRequestsStatusButton from '../../../components/plan/PlanMergeRequestsStatusButton.svelte'; import PlanNavButton from '../../../components/plan/PlanNavButton.svelte'; + import PlanSnapshotBar from '../../../components/plan/PlanSnapshotBar.svelte'; import CssGrid from '../../../components/ui/CssGrid.svelte'; import PlanGrid from '../../../components/ui/PlanGrid.svelte'; import ProgressLinear from '../../../components/ui/ProgressLinear.svelte'; import { SearchParameters } from '../../../enums/searchParameters'; import { activityDirectives, + activityDirectivesList, activityDirectivesMap, resetActivityStores, selectActivity, @@ -253,6 +255,18 @@ clearSchedulingErrors(); } + function onCloseSnapshotPreview() { + $planSnapshotId = null; + $simulationDatasetId = -1; + removeQueryParam(SearchParameters.SNAPSHOT_ID); + removeQueryParam(SearchParameters.SIMULATION_DATASET_ID, 'PUSH'); + } + + function onConsoleResize(event: CustomEvent) { + const { detail } = event; + consoleHeightString = detail; + } + function onKeydown(event: KeyboardEvent): void { if (isSaveEvent(event)) { event.preventDefault(); @@ -282,6 +296,11 @@ } } + function onRestoreSnapshot(event: CustomEvent) { + const { detail: planSnapshot } = event; + effects.restorePlanSnapshot(planSnapshot, data.user); + } + async function onSaveView(event: CustomEvent) { const { detail } = event; const { definition, id, name } = detail; @@ -460,7 +479,14 @@ /> - + {#if $planSnapshot} + + {/if}