@@ -41,16 +41,23 @@ <h4 class="mb-0"><i class="fas fa-route text-primary"></i> Session controls</h4>
4141 < div id ="capture_processing " class ="alert alert-success " {% if session.status not in [ 'finishing', 'completed'] %}style="display:none; "{% endif %} >
4242 < i class ="fas fa-check-circle "> </ i > The interactive session is completed. AIL is saving and processing the browser state; results URL will appear in AIL when processing is finished.
4343 </ div >
44+ < div id ="capture_stopped_pending_import " class ="alert alert-info " {% if session.remote_status|lower ! = 'stopped ' or session.status in [ 'completed', 'expired', 'error', 'closed'] %}style="display:none; "{% endif %} >
45+ < i class ="fas fa-hourglass-half "> </ i > The interactive browser capture is stopped. The crawler will import the capture, then the crawled domain will be available when processing is finished.
46+ </ div >
47+ < div id ="open_browser_help " class ="alert alert-primary " {% if not session.remote_url or session.status not in [ 'starting', 'ready'] or session.remote_status|lower == 'stopped ' %}style ="display:none; "{% endif %} >
48+ < i class ="fas fa-external-link-alt "> </ i > Click < strong > Open interactive browser</ strong > to open the interactive session. When you are done browsing, come back to this page and click < strong > Finish capture</ strong > .
49+ </ div >
4450 < div id ="interactive_error " class ="alert alert-danger " {% if not session.error %}style ="display:none; "{% endif %} > {{ session.error }}</ div >
45- < div id ="crawled_domain_card " class ="alert alert-primary d-flex flex-column flex-md-row justify-content-between align-items-md-center " {% if not session.crawled_domain %}style ="display:none; "{% endif %} >
51+ {% set show_crawled_domain = session.crawled_domain and session.crawled_url and session.capture_status == 'DONE' %}
52+ < div id ="crawled_domain_card " class ="alert alert-primary flex-column flex-md-row justify-content-between align-items-md-center {% if show_crawled_domain %}d-flex{% else %}d-none{% endif %} " {% if not show_crawled_domain %}style ="display:none !important; "{% endif %} >
4653 < div >
4754 < div class ="font-weight-bold "> < i class ="fas fa-globe "> </ i > Crawled domain ready</ div >
4855 < div >
4956 < span id ="crawled_url " class ="text-muted " {% if not session.crawled_url %}style ="display:none; "{% endif %} > ({{ session.crawled_url }})</ span >
5057 < span id ="crawled_domain_text "> {{ session.crawled_domain }}</ span >
5158 </ div >
5259 </ div >
53- < a id ="crawled_domain_btn " class ="btn btn-primary mt-3 mt-md-0 " href ="{{ url_for('crawler_splash.showDomain') }}?domain={{ session.crawled_domain|urlencode }} " {% if not session.crawled_domain %}style ="display:none; "{% endif %} >
60+ < a id ="crawled_domain_btn " class ="btn btn-primary mt-3 mt-md-0 {% if not show_crawled_domain %}d-none{% endif %} " href ="{{ url_for('crawler_splash.showDomain') }}?domain={{ session.crawled_domain|urlencode }} " {% if not show_crawled_domain %}style ="display:none !important ; "{% endif %} >
5461 < i class ="fas fa-external-link-alt "> </ i > Open domain
5562 </ a >
5663 </ div >
@@ -92,7 +99,7 @@ <h4 class="mb-0"><i class="fas fa-route text-primary"></i> Session controls</h4>
9299 < a id ="cookiejar_link " href ="{{ url_for('crawler_splash.crawler_cookiejar_show') }}?uuid={{ session.cookiejar_uuid }} "> {{ session.cookiejar_uuid }}</ a >
93100 </ div >
94101 {% endif %}
95- < div class ="list-group-item " id ="crawled_domain_row " {% if not session.crawled_domain %}style ="display:none; "{% endif %} >
102+ < div class ="list-group-item {% if not show_crawled_domain %}d-none{% endif %} " id ="crawled_domain_row " {% if not show_crawled_domain %}style ="display:none !important ; "{% endif %} >
96103 < div class ="text-muted small "> Crawled domain</ div >
97104 < a id ="crawled_domain_link " class ="btn btn-sm btn-outline-primary mt-1 " href ="{{ url_for('crawler_splash.showDomain') }}?domain={{ session.crawled_domain|urlencode }} ">
98105 < i class ="fas fa-external-link-alt "> </ i > {{ session.crawled_domain }}
@@ -144,17 +151,47 @@ <h4 class="mb-0"><i class="fas fa-route text-primary"></i> Session controls</h4>
144151
145152function is_capture_done ( captureStatus ) {
146153 const normalizedCaptureStatus = String ( captureStatus || '' ) . toUpperCase ( ) ;
147- return [ 'DONE' , '1' , 'COMPLETED' , 'COMPLETE' ] . includes ( normalizedCaptureStatus ) ;
154+ return normalizedCaptureStatus === 'DONE' ;
148155}
149156
150157function is_remote_browser_stopped ( remoteStatus ) {
151158 return String ( remoteStatus || '' ) . toLowerCase ( ) === 'stopped' ;
152159}
153160
161+ function update_stopped_pending_import_message ( status , remoteStatus ) {
162+ const normalizedStatus = String ( status || '' ) . toLowerCase ( ) ;
163+ if ( is_remote_browser_stopped ( remoteStatus ) && ! interactiveFinalStates . includes ( normalizedStatus ) ) {
164+ $ ( '#capture_stopped_pending_import' ) . show ( ) ;
165+ } else {
166+ $ ( '#capture_stopped_pending_import' ) . hide ( ) ;
167+ }
168+ }
169+
170+ function update_open_browser_help ( status , remoteStatus ) {
171+ const normalizedStatus = String ( status || '' ) . toLowerCase ( ) ;
172+ if ( $ ( '#remote_url_btn' ) . is ( ':visible' ) && [ 'starting' , 'ready' ] . includes ( normalizedStatus ) && ! is_remote_browser_stopped ( remoteStatus ) ) {
173+ $ ( '#open_browser_help' ) . show ( ) ;
174+ } else {
175+ $ ( '#open_browser_help' ) . hide ( ) ;
176+ }
177+ }
178+
154179function hide_remote_browser_controls ( ) {
155180 $ ( '#remote_url_btn' ) . hide ( ) . addClass ( 'd-none' ) ;
156181}
157182
183+ function show_crawled_domain_controls ( ) {
184+ $ ( '#crawled_domain_card' ) . removeClass ( 'd-none' ) . addClass ( 'd-flex' ) . removeAttr ( 'style' ) ;
185+ $ ( '#crawled_domain_row' ) . removeClass ( 'd-none' ) . removeAttr ( 'style' ) ;
186+ $ ( '#crawled_domain_btn' ) . removeClass ( 'd-none' ) . removeAttr ( 'style' ) ;
187+ }
188+
189+ function hide_crawled_domain_controls ( ) {
190+ $ ( '#crawled_domain_card' ) . removeClass ( 'd-flex' ) . addClass ( 'd-none' ) . attr ( 'style' , 'display:none !important;' ) ;
191+ $ ( '#crawled_domain_row' ) . addClass ( 'd-none' ) . attr ( 'style' , 'display:none !important;' ) ;
192+ $ ( '#crawled_domain_btn' ) . addClass ( 'd-none' ) . attr ( 'style' , 'display:none !important;' ) ;
193+ }
194+
158195function update_interactive_controls ( status , captureStatus , remoteStatus ) {
159196 update_interactive_title ( status ) ;
160197 const normalizedStatus = String ( status || '' ) . toLowerCase ( ) ;
@@ -177,6 +214,8 @@ <h4 class="mb-0"><i class="fas fa-route text-primary"></i> Session controls</h4>
177214 if ( [ 'finishing' , 'completed' ] . includes ( normalizedStatus ) ) {
178215 $ ( '#capture_processing' ) . show ( ) ;
179216 }
217+ update_stopped_pending_import_message ( normalizedStatus , remoteStatus ) ;
218+ update_open_browser_help ( normalizedStatus , remoteStatus ) ;
180219 if ( interactiveFinalStates . includes ( normalizedStatus ) ) {
181220 stop_interactive_status_refresh ( ) ;
182221 }
@@ -209,23 +248,22 @@ <h4 class="mb-0"><i class="fas fa-route text-primary"></i> Session controls</h4>
209248 $ ( '#remote_url_btn' ) . attr ( 'href' , data . remote_url ) . show ( ) . removeClass ( 'd-none' ) ;
210249 $ ( '#remote_starting' ) . hide ( ) ;
211250 }
212- if ( data . status ) {
213- update_interactive_controls ( data . status , data . capture_status , currentRemoteStatus ) ;
214- }
251+ update_interactive_controls ( data . status || $ ( '#interactive_status' ) . text ( ) , data . capture_status || $ ( '#capture_status' ) . text ( ) , currentRemoteStatus ) ;
215252 if ( data . cookiejar_uuid ) {
216253 $ ( '#cookiejar_link' ) . attr ( 'href' , '{{ url_for(' crawler_splash . crawler_cookiejar_show ') }}?uuid=' + data . cookiejar_uuid ) . text ( data . cookiejar_uuid ) ;
217254 $ ( '#cookiejar_row' ) . show ( ) ;
218255 }
219- if ( data . crawled_domain ) {
256+ if ( data . crawled_domain && data . crawled_url && is_capture_done ( data . capture_status || $ ( '#capture_status' ) . text ( ) ) ) {
220257 const domainUrl = '{{ url_for(' crawler_splash . showDomain ') }}?domain=' + encodeURIComponent ( data . crawled_domain ) ;
221258 $ ( '#crawled_domain_link' ) . attr ( 'href' , domainUrl ) . html ( '<i class="fas fa-external-link-alt"></i> ' + data . crawled_domain ) ;
222- $ ( '#crawled_domain_btn' ) . attr ( 'href' , domainUrl ) . show ( ) ;
259+ $ ( '#crawled_domain_btn' ) . attr ( 'href' , domainUrl ) ;
223260 $ ( '#crawled_domain_text' ) . text ( data . crawled_domain ) ;
224261 if ( data . crawled_url ) {
225262 $ ( '#crawled_url' ) . text ( '(' + data . crawled_url + ')' ) . show ( ) ;
226263 }
227- $ ( '#crawled_domain_card' ) . show ( ) ;
228- $ ( '#crawled_domain_row' ) . show ( ) ;
264+ show_crawled_domain_controls ( ) ;
265+ } else if ( ! is_capture_done ( data . capture_status || $ ( '#capture_status' ) . text ( ) ) ) {
266+ hide_crawled_domain_controls ( ) ;
229267 }
230268 if ( data . error || data . last_status_error ) {
231269 $ ( '#interactive_error' ) . text ( data . error || data . last_status_error ) . show ( ) ;
0 commit comments