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

file_selector notify property (default True) #946

Merged
merged 2 commits into from
Mar 8, 2024
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
8 changes: 5 additions & 3 deletions frontend/taipy-gui/src/components/Taipy/FileSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface FileSelectorProps extends TaipyActiveProps {
multiple?: boolean;
extensions?: string;
dropMessage?: string;
notify?: boolean;
}

const handleDragOver = (evt: DragEvent) => {
Expand All @@ -50,6 +51,7 @@ const FileSelector = (props: FileSelectorProps) => {
extensions = ".csv,.xlsx",
dropMessage = "Drop here to Upload",
label,
notify = true,
} = props;
const [dropLabel, setDropLabel] = useState("");
const [dropSx, setDropSx] = useState(defaultSx);
Expand All @@ -74,20 +76,20 @@ const FileSelector = (props: FileSelectorProps) => {
(value) => {
setUpload(false);
onAction && dispatch(createSendActionNameAction(id, module, onAction));
dispatch(
notify && dispatch(
createAlertAction({ atype: "success", message: value, system: false, duration: 3000 })
);
},
(reason) => {
setUpload(false);
dispatch(
notify && dispatch(
createAlertAction({ atype: "error", message: reason, system: false, duration: 3000 })
);
}
);
}
},
[state.id, id, onAction, updateVarName, dispatch, module]
[state.id, id, onAction, notify, updateVarName, dispatch, module]
);

const handleChange = useCallback(
Expand Down
1 change: 1 addition & 0 deletions taipy/gui/_renderers/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class _Factory:
("extensions",),
("drop_message",),
("hover_text", PropertyType.dynamic_string),
("notify", PropertyType.boolean, True),
]
),
"image": lambda gui, control_type, attrs: _Builder(
Expand Down
5 changes: 4 additions & 1 deletion taipy/gui/_renderers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

import typing as t
from abc import ABC, abstractmethod
from datetime import date, datetime, time
from datetime import date, datetime, time, timedelta
from json import JSONEncoder
from pathlib import Path

import pandas
from flask.json.provider import DefaultJSONProvider

from .._warnings import _warn
Expand Down Expand Up @@ -45,6 +46,8 @@ def parse(self, o):
return _date_to_string(o)
if isinstance(o, Path):
return str(o)
if isinstance(o, (timedelta, pandas.Timedelta)):
return str(o)


class _TaipyJsonAdapter(object, metaclass=_Singleton):
Expand Down
8 changes: 7 additions & 1 deletion taipy/gui/viselements.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,12 @@
"type": "str",
"default_value": "\"Drop here to Upload\"",
"doc": "The message that is displayed when the user drags a file above the button."
},
{
"name": "notify",
"type": "bool",
"default_value": "True",
"doc": "If set to False, the user won't be notified of upload finish."
}
]
}
Expand Down Expand Up @@ -1128,7 +1134,7 @@
{
"name": "downloadable",
"type": "boolean",
"doc": "The indicator that would show the icon to allow the user to download the data as a csv file if True."
"doc": "If True, a clickable icon is shown so the user can download the data as CSV."
}
]
}
Expand Down
Loading