Skip to content

Commit 94c2bc3

Browse files
committed
chg: [interactive crawler] improve template
1 parent a1c2426 commit 94c2bc3

2 files changed

Lines changed: 124 additions & 11 deletions

File tree

var/www/templates/crawler/crawler_splash/interactive_capture.html

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

145152
function is_capture_done(captureStatus){
146153
const normalizedCaptureStatus = String(captureStatus || '').toUpperCase();
147-
return ['DONE', '1', 'COMPLETED', 'COMPLETE'].includes(normalizedCaptureStatus);
154+
return normalizedCaptureStatus === 'DONE';
148155
}
149156

150157
function 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+
154179
function 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+
158195
function 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();
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>AIL-Framework</title>
5+
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png')}}">
6+
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
7+
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
8+
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
9+
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
10+
</head>
11+
<body>
12+
{% include 'nav_bar.html' %}
13+
<div class="container-fluid"><div class="row">
14+
{% include 'crawler/menu_sidebar.html' %}
15+
<div class="col-12 col-lg-10" id="core_content">
16+
<div class="jumbotron bg-dark text-white mt-3 shadow-sm">
17+
<div class="row align-items-center">
18+
<div class="col-lg-8">
19+
<p class="text-uppercase text-info font-weight-bold mb-2"><i class="fas fa-desktop"></i> Interactive capture</p>
20+
<h1 class="display-4">No active browser session</h1>
21+
<p class="lead mb-0">Start an interactive browser capture when you need to log in, solve prompts, or manually navigate before AIL saves the page state.</p>
22+
</div>
23+
<div class="col-lg-4 mt-4 mt-lg-0">
24+
<div class="card text-dark border-0 shadow">
25+
<div class="card-body text-center">
26+
<div class="h2 mb-0">{{ usage.active }} / {{ usage.max }}</div>
27+
<div class="text-muted">interactive slots in use</div>
28+
{% if usage.active < usage.max %}
29+
<span class="badge badge-success mt-3">Slot available</span>
30+
{% else %}
31+
<span class="badge badge-danger mt-3">All slots busy</span>
32+
{% endif %}
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
</div>
38+
39+
<div class="row">
40+
<div class="col-xl-8">
41+
<div class="card shadow-sm mb-3">
42+
<div class="card-header bg-white">
43+
<h4 class="mb-0"><i class="fas fa-play-circle text-primary"></i> Start a new interactive capture</h4>
44+
</div>
45+
<div class="card-body">
46+
<p class="mb-4">Interactive captures are launched from the crawler form. Paste a URL, enable <b>Interactive browser capture</b>, then AIL will open a remote browser that you can control.</p>
47+
<a class="btn btn-primary btn-lg" href="{{ url_for('crawler_splash.manual') }}">
48+
<i class="fas fa-plus"></i> Open crawler form
49+
</a>
50+
{% if current_user.get_role() == 'admin' %}
51+
<a class="btn btn-outline-secondary btn-lg ml-2" href="{{ url_for('crawler_splash.interactive_capture_admin') }}">
52+
<i class="fas fa-tools"></i> Manage sessions
53+
</a>
54+
{% endif %}
55+
</div>
56+
</div>
57+
</div>
58+
<div class="col-xl-4">
59+
<div class="card border-info shadow-sm mb-3">
60+
<div class="card-header bg-info text-white"><i class="fas fa-info-circle"></i> Workflow</div>
61+
<div class="card-body">
62+
<ol class="pl-3 mb-0">
63+
<li>Launch the interactive capture from the crawler form.</li>
64+
<li>Open the remote browser link and navigate as needed.</li>
65+
<li>Click <b>Finish capture</b> to let AIL import and process the result.</li>
66+
</ol>
67+
</div>
68+
</div>
69+
</div>
70+
</div>
71+
</div>
72+
</div></div>
73+
</body>
74+
<script>$(document).ready(function(){ $('#page-Crawler').addClass('active'); });</script>
75+
</html>

0 commit comments

Comments
 (0)