Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary data source options in DashboardVisulisation #141

Closed
2 tasks
FredrikAugust opened this issue Apr 16, 2021 · 1 comment · Fixed by #146
Closed
2 tasks

Allow arbitrary data source options in DashboardVisulisation #141

FredrikAugust opened this issue Apr 16, 2021 · 1 comment · Fixed by #146
Assignees
Labels
enhancement New feature or request
Projects

Comments

@FredrikAugust
Copy link
Contributor

FredrikAugust commented Apr 16, 2021

Description

Bear with me, this might get a bit confusing. If so don't hesitate to ask here, send me a DM, or call me.

In the current drafted implementation of population parameters, i.e.

https://github.com/IT2901-SINTEF01/frontend/pull/116/files#diff-b01a6c1c95562d08ab752970c643e4069e70de83e390189d9bbd8f224a18fe21R100

There's essentially a switch statement that generates a set of controls for the data source in-place. This data is then added to a global store.

https://github.com/IT2901-SINTEF01/frontend/pull/116/files#diff-7eeb8bab2802ad9120bb9d23ca0003af1c535416e48e97f300fa83fea064da9aR11-R12

https://github.com/IT2901-SINTEF01/frontend/pull/116/files#diff-7cd1314945ef5b0ae105c7554edbd674636614af44d9ba11b8e6f01b1e906909R26-R28

Firstly, we will address the state management. It is beneficial to the complexity of the application if state is stored at the Lowest Common Ancestor (apologies if you suffer from Post-AlgDat Traumas). This is because this isolates the state and ensures only the relevant parts of the application get access to the state.

This LCA will probably be the VisualisationEditor, and thus state should be kept there.


The second part revolves around the creation of the components to control the inputs --- and the subsequent state modifications.

What if, we add a field to the DashboardVisualisation interface called DataSourceOptions which has the following form (using type aliases);

type GraphQLParameterName = string;
type ControlType = "municipality_editor" | "lat_lon_editor";
type ControlValue = string | number | string[]; // e.g.

type DataSourceOption = { controlType: ControlType, value: ControlValue };

type DataSourceOptions = Record<GraphQLParameterName, DataSourceOption>;

The code is meant as inspiration and should be taken with a pinch of salt.

Then we could add a section in the visualisation editor which essentially iterates through the entries in the datasourceoptions and generates the relevant components. The results from these components should be injected into the GraphQL queries as parameters, and stored in the Redux store (as they should be persisted so the variables are the same on the next load).

Subtasks

  • Move state to LCA
  • Implement generic control component "generator" and associated types

Related sources

@FredrikAugust
Copy link
Contributor Author

I'll take a look at this now, @fredrikbw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

2 participants