Skip to content

Commit

Permalink
file_selector notify property (default True) (#946)
Browse files Browse the repository at this point in the history
* file_selector notify property (default True)
support TimleDelta
resolves #573
resolves #455

* dependency

---------

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Mar 8, 2024
1 parent 01b16d5 commit 1903c9b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
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

0 comments on commit 1903c9b

Please sign in to comment.