diff --git a/src/app/config.jl b/src/app/config.jl index ff8d496..be6af42 100644 --- a/src/app/config.jl +++ b/src/app/config.jl @@ -16,4 +16,5 @@ struct DashConfig include_assets_files ::Bool show_undo_redo ::Bool compress ::Bool + update_title ::String end diff --git a/src/app/dashapp.jl b/src/app/dashapp.jl index 976cc37..64d02b3 100644 --- a/src/app/dashapp.jl +++ b/src/app/dashapp.jl @@ -185,7 +185,8 @@ get_assets_path(app::DashApp) = joinpath(app.root_path, get_setting(app, :assets assets_external_path, include_assets_files, show_undo_redo, - compress + compress, + update_title ) Dash is a framework for building analytical web applications. No JavaScript required. @@ -280,6 +281,12 @@ If a parameter can be set by an environment variable, that is listed as: - `compress::Bool`: Default ``true``, controls whether gzip is used to compress files and data served by HTTP.jl when supported by the client. Set to ``false`` to disable compression completely. + +- `update_title::String`: Default ``Updating...``. Configures the document.title + (the text that appears in a browser tab) text when a callback is being run. + Set to '' if you don't want the document.title to change or if you + want to control the document.title through a separate component or + clientside callback. """ function dash(; external_stylesheets = ExternalSrcType[], @@ -299,7 +306,8 @@ function dash(; assets_external_path = dash_env("assets_external_path"), include_assets_files = dash_env(Bool, "include_assets_files", true), show_undo_redo = false, - compress = true + compress = true, + update_title = "Updating..." ) @@ -323,7 +331,8 @@ function dash(; assets_external_path, include_assets_files, show_undo_redo, - compress + compress, + update_title ) result = DashApp(app_root_path(), isinteractive(), config, index_string) return result diff --git a/src/handler/index_page.jl b/src/handler/index_page.jl index aedac11..5a0e84c 100644 --- a/src/handler/index_page.jl +++ b/src/handler/index_page.jl @@ -84,7 +84,8 @@ function config_html(app::DashApp) :ui => get_devsetting(app, :ui), :props_check => get_devsetting(app, :props_check), :show_undo_redo => get_setting(app, :show_undo_redo), - :suppress_callback_exceptions => get_setting(app, :suppress_callback_exceptions) + :suppress_callback_exceptions => get_setting(app, :suppress_callback_exceptions), + :update_title => get_setting(app, :update_title) ) if get_devsetting(app, :hot_reload) config[:hot_reload] = ( diff --git a/test/integration/base/jl_update_title/jltut001_update_title.jl b/test/integration/base/jl_update_title/jltut001_update_title.jl new file mode 100644 index 0000000..829ac23 --- /dev/null +++ b/test/integration/base/jl_update_title/jltut001_update_title.jl @@ -0,0 +1,6 @@ +using Dash +using DashHtmlComponents + +app = dash() +app.layout = html_div(children = "Hello world!", id = "hello-div") +run_server(app) diff --git a/test/integration/base/jl_update_title/jltut002_update_title.jl b/test/integration/base/jl_update_title/jltut002_update_title.jl new file mode 100644 index 0000000..e910df6 --- /dev/null +++ b/test/integration/base/jl_update_title/jltut002_update_title.jl @@ -0,0 +1,6 @@ +using Dash +using DashHtmlComponents + +app = dash(;update_title = "... computing !") +app.layout = html_div(children = "Hello world!", id = "hello-div") +run_server(app) diff --git a/test/integration/base/jl_update_title/jltut003_update_title.jl b/test/integration/base/jl_update_title/jltut003_update_title.jl new file mode 100644 index 0000000..798e7a3 --- /dev/null +++ b/test/integration/base/jl_update_title/jltut003_update_title.jl @@ -0,0 +1,6 @@ +using Dash +using DashHtmlComponents + +app = dash(;update_title = "") +app.layout = html_div(children = "Hello world!", id = "hello-div") +run_server(app) diff --git a/test/integration/base/test_update_title.py b/test/integration/base/test_update_title.py new file mode 100644 index 0000000..b39aad1 --- /dev/null +++ b/test/integration/base/test_update_title.py @@ -0,0 +1,34 @@ +import os +import pathlib + +curr_path = pathlib.Path(__file__).parent.absolute() + + +def boot(dashjl, filename): + fp = os.path.join(curr_path, "jl_update_title", filename) + dashjl.start_server(fp) + dashjl.wait_for_text_to_equal( + "#hello-div", + "Hello world!" + ) + + +def get_update_title_state(dashjl): + return dashjl.driver.execute_script( + "return store.getState().config.update_title" + ) + + +def test_jltut001_update_title(dashjl): + boot(dashjl, "jltut001_update_title.jl") + assert get_update_title_state(dashjl) == "Updating..." + + +def test_jltut002_update_title(dashjl): + boot(dashjl, "jltut002_update_title.jl") + assert get_update_title_state(dashjl) == "... computing !" + + +def test_jltut003_update_title(dashjl): + boot(dashjl, "jltut003_update_title.jl") + assert get_update_title_state(dashjl) == ""