Skip to content

Commit d27478f

Browse files
authored
Merge pull request #102 from etpinard/add-update_title-config-option
Add `update_title` config option
2 parents 3fbfae4 + a3d077c commit d27478f

File tree

7 files changed

+67
-4
lines changed

7 files changed

+67
-4
lines changed

src/app/config.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ struct DashConfig
1616
include_assets_files ::Bool
1717
show_undo_redo ::Bool
1818
compress ::Bool
19+
update_title ::String
1920
end

src/app/dashapp.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ get_assets_path(app::DashApp) = joinpath(app.root_path, get_setting(app, :assets
185185
assets_external_path,
186186
include_assets_files,
187187
show_undo_redo,
188-
compress
188+
compress,
189+
update_title
189190
)
190191
191192
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:
280281
- `compress::Bool`: Default ``true``, controls whether gzip is used to compress
281282
files and data served by HTTP.jl when supported by the client. Set to
282283
``false`` to disable compression completely.
284+
285+
- `update_title::String`: Default ``Updating...``. Configures the document.title
286+
(the text that appears in a browser tab) text when a callback is being run.
287+
Set to '' if you don't want the document.title to change or if you
288+
want to control the document.title through a separate component or
289+
clientside callback.
283290
"""
284291
function dash(;
285292
external_stylesheets = ExternalSrcType[],
@@ -299,7 +306,8 @@ function dash(;
299306
assets_external_path = dash_env("assets_external_path"),
300307
include_assets_files = dash_env(Bool, "include_assets_files", true),
301308
show_undo_redo = false,
302-
compress = true
309+
compress = true,
310+
update_title = "Updating..."
303311

304312
)
305313

@@ -323,7 +331,8 @@ function dash(;
323331
assets_external_path,
324332
include_assets_files,
325333
show_undo_redo,
326-
compress
334+
compress,
335+
update_title
327336
)
328337
result = DashApp(app_root_path(), isinteractive(), config, index_string)
329338
return result

src/handler/index_page.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ function config_html(app::DashApp)
8484
:ui => get_devsetting(app, :ui),
8585
:props_check => get_devsetting(app, :props_check),
8686
:show_undo_redo => get_setting(app, :show_undo_redo),
87-
:suppress_callback_exceptions => get_setting(app, :suppress_callback_exceptions)
87+
:suppress_callback_exceptions => get_setting(app, :suppress_callback_exceptions),
88+
:update_title => get_setting(app, :update_title)
8889
)
8990
if get_devsetting(app, :hot_reload)
9091
config[:hot_reload] = (
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Dash
2+
using DashHtmlComponents
3+
4+
app = dash()
5+
app.layout = html_div(children = "Hello world!", id = "hello-div")
6+
run_server(app)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Dash
2+
using DashHtmlComponents
3+
4+
app = dash(;update_title = "... computing !")
5+
app.layout = html_div(children = "Hello world!", id = "hello-div")
6+
run_server(app)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Dash
2+
using DashHtmlComponents
3+
4+
app = dash(;update_title = "")
5+
app.layout = html_div(children = "Hello world!", id = "hello-div")
6+
run_server(app)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
import pathlib
3+
4+
curr_path = pathlib.Path(__file__).parent.absolute()
5+
6+
7+
def boot(dashjl, filename):
8+
fp = os.path.join(curr_path, "jl_update_title", filename)
9+
dashjl.start_server(fp)
10+
dashjl.wait_for_text_to_equal(
11+
"#hello-div",
12+
"Hello world!"
13+
)
14+
15+
16+
def get_update_title_state(dashjl):
17+
return dashjl.driver.execute_script(
18+
"return store.getState().config.update_title"
19+
)
20+
21+
22+
def test_jltut001_update_title(dashjl):
23+
boot(dashjl, "jltut001_update_title.jl")
24+
assert get_update_title_state(dashjl) == "Updating..."
25+
26+
27+
def test_jltut002_update_title(dashjl):
28+
boot(dashjl, "jltut002_update_title.jl")
29+
assert get_update_title_state(dashjl) == "... computing !"
30+
31+
32+
def test_jltut003_update_title(dashjl):
33+
boot(dashjl, "jltut003_update_title.jl")
34+
assert get_update_title_state(dashjl) == ""

0 commit comments

Comments
 (0)