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

Keep customized time partitions after logout #41

Open
thomasssino opened this issue Feb 23, 2022 · 1 comment
Open

Keep customized time partitions after logout #41

thomasssino opened this issue Feb 23, 2022 · 1 comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code python Pull requests that update Python code

Comments

@thomasssino
Copy link

Customization of daily time periods seems now to work until logout. When logging back in, previous customizations are forgotten.

@JPHutchins JPHutchins added enhancement New feature or request javascript Pull requests that update Javascript code python Pull requests that update Python code labels Feb 25, 2022
@JPHutchins
Copy link
Owner

JPHutchins commented Feb 25, 2022

Hey @thomasssino ! Unfortunately that's expected. TLDR the "daily partitions config" needs to be saved to the server's database and recalled on next login.

For future reference:

  • The database already has a "partition_options" field that is intended to be the save location for this, see https://github.dev/JPHutchins/open-energy-view/blob/master/open_energy_view/models.py
  • partion_options, in the database, python, or javascript should be this shape:
    [
      { name: "Night", start: 0, color: "hsl(240, 40%, 37%)" },
      { name: "Day", start: 7, color: "hsl(173, 40%, 57%)" },
      { name: "Evening", start: 18, color: "hsl(296, 40%, 57%)" },
    ];
    where the list can be any length (including 0?)
    see: open_energy_view/frontend/js/data-structures/helpers/defaultPartitions.js
  • Add API POST endpoint to open_energy_view/resources.py that handles saving partition options - register it in __init__.py under the #User interactions section
  • Add "save" button to this file that makes the POST above:https://github.com/JPHutchins/open-energy-view/blob/master/open_energy_view/frontend/js/components/Settings/SetPartitions.jsx
  • Currently, the frontend handles updating partitions by checking for partitionUpdate at line 101 of open_energy_view/frontend/js/App.jsx. Honestly, it needs to be redone but can still work for now.
  • Use the API endpoint api/web/partition-options, resources.py/GetPartitionOptions to retrieve partition options. See line 22 of DatabaseService.js, it looks like this was just never hooked up.
  • Request from the partition options endpoint before calling getData so that the partition options saved server side can be passed into getData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code python Pull requests that update Python code
Projects
None yet
Development

No branches or pull requests

2 participants