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

get localstorage support (#2190) #2234

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

dinhlongviolin1
Copy link
Member

@dinhlongviolin1 dinhlongviolin1 commented Nov 11, 2024

Resolve #2190

localStorage.setItem and localStorage.removeItem can be used directly on the browser console to test out the feature

from taipy.gui import Gui, get_local_storage


def button_click(state):
    print(get_local_storage(state, "TaipyClientId")) # would return str | None
    print(get_local_storage(state, "TaipyClientId", "hey")) # would return dict

def on_local_storage_change(state, key, value):
    print(f"key: {key}, value: {value}")


Gui("<|Click me|button|on_action=button_click|>").run()

Copy link
Contributor

github-actions bot commented Nov 11, 2024

Coverage report for ./frontend/taipy

Caution

Coverage does not meet threshold
Statements coverage not met for global: expected >=80%, but got 52.07920792079208%

St.
Category Percentage Covered / Total
🔴 Statements 52.08% 263/505
🔴 Branches 21.75% 67/308
🔴 Functions 14.66% 17/116
🔴 Lines 53.42% 242/453

Test suite run success

7 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from a960e78

Copy link
Contributor

Coverage report for ./frontend/taipy-gui

Caution

Coverage does not meet threshold
Branches coverage not met for global: expected >=80%, but got 69.25624811803674%

St.
Category Percentage Covered / Total
🟢 Statements
87.77% (-0.07% 🔻)
3408/3883
🟡 Branches
69.26% (-0.04% 🔻)
2300/3321
🟢 Functions
83.42% (-0.22% 🔻)
629/754
🟢 Lines
88.24% (-0.06% 🔻)
3152/3572
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / taipyReducers.ts
89.49% (-0.97% 🔻)
81.22% (-0.83% 🔻)
83.64% (-3.16% 🔻)
89.92% (-0.91% 🔻)

Test suite run success

681 tests passing in 47 suites.

Report generated by 🧪jest coverage report action from a98cddf

Copy link
Contributor

github-actions bot commented Nov 11, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
19320 16787 87% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
taipy/gui/init.py 100% 🟢
taipy/gui/data/data_scope.py 94% 🟢
taipy/gui/gui.py 79% 🟢
taipy/gui/gui_actions.py 66% 🟢
taipy/gui/types.py 96% 🟢
TOTAL 87% 🟢

updated for commit: a960e78 by action🐍

Copy link
Member

@FredLL-Avaiga FredLL-Avaiga left a comment

Choose a reason for hiding this comment

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

Not sure about this local storage API redéfinition in the browser
Way to invasive for my taste
And I'm not sure a security audit would appreciate

const _setItem = Storage.prototype.setItem;
const _removeItem = Storage.prototype.removeItem;

Storage.prototype.setItem = function (key, value) {
Copy link
Member

Choose a reason for hiding this comment

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

a bit invasive ...
Any other way ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have tried multiple ways but to be able to catch an event on the local tab, I still need to modify the original implementation

frontend/taipy-gui/src/hooks/index.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retrieve values from the front-end local storage
2 participants