Skip to content

Commit ec36f76

Browse files
committed
one more
1 parent 380f875 commit ec36f76

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

Chapters/Tricks.pillar

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Think of an application that does more time taking tasks (like generating a PDF that make take a while). What are current approaches with Seaside to show wait dialogs or other to the user until processing is ready?
2+
3+
I have a situation like that, with a process that might take up to a minute.
4+
What I do is to handle that, is to display a "running" indication with setTimeout() that polls for updates, and if nothing happens schedules another setTimeout(). Once there is an update (either if the process ended successfully or failed) I update the "running" indicator with the result or a failure sign, and cancel the setTimeout().
5+
6+
7+
| theIntervalString |
8+
theIntervalString := anId , 'Interval'
9+
, Time now asMilliSeconds printString.
10+
html div
11+
id: anId , self imageSmallID;
12+
onClick:
13+
(html jQuery ajax
14+
script: [ ...]);
15+
script:
16+
(((html jQuery id: anId) load
17+
onComplete:
18+
( (self clearIntervalJsString format: {theIntervalString}) js);
19+
html: [ :h | self renderPlaceholderId: anId on: h ];
20+
interval: 1 seconds) assignTo: theIntervalString);
21+
22+
23+
24+
25+
26+
27+
renderOngoingAnalysisOn: html
28+
29+
html div
30+
class: 'center status';
31+
with:
32+
[ html div
33+
class: 'status-icon';
34+
with: [html faIcon iconHourglassOutlined spin].
35+
(html heading)
36+
level: 3;
37+
with: 'Foo baz is running' _LD.
38+
html paragraph: 'Please wait until it finishes.' _LD.
39+
html
40+
script: (((html jQuery ajax script: [:s | self scriptUpdaterOn: s])
41+
interval: 5 seconds) assignTo: self progressHandlerId)]
42+
43+
scriptUpdaterOn: script
44+
45+
self hasOngoingAnalysis
46+
ifTrue: ["do nothing"]
47+
ifFalse:
48+
[self scriptValidatedReloadOn: script.
49+
self scriptClearUpdaterOn: script]
50+
51+
scriptClearUpdaterOn: script
52+
53+
script << (JSStream on: ('clearInterval(<1s>);<1s>=null;' expandMacrosWith: self progressHandlerId))
54+
scriptValidatedReloadOn: script
55+
56+
"do some other stuff and then"
57+
script << ( ( script jQuery id: self ajaxId ) replaceWith: [ :h | self renderContentOn: h ] )

0 commit comments

Comments
 (0)