Skip to content

Commit 27ef16a

Browse files
etewiahclaude
andcommitted
Add PWS integration UI: extraction badges, dynamic portals, and health banner
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e3f03e8 commit 27ef16a

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

app/controllers/site_admin/property_url_import_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class PropertyUrlImportController < SiteAdminController
1111
# Show the URL input form
1212
def new
1313
@scraped_property = nil
14+
@pws_enabled = Pwb::ExternalScraperClient.enabled?
15+
@supported_portals = Pwb::ExternalScraperClient.supported_portals if @pws_enabled
1416
end
1517

1618
# POST /site_admin/property_url_import
@@ -130,6 +132,9 @@ def history
130132
# Show batch import form (CSV or URL list)
131133
def batch
132134
@batch_result = nil
135+
if Pwb::ExternalScraperClient.enabled?
136+
@pws_status = Pwb::ExternalScraperClient.healthy? ? :healthy : :unhealthy
137+
end
133138
end
134139

135140
# POST /site_admin/property_url_import/batch_process

app/views/site_admin/property_url_import/batch.html.erb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@
88
</p>
99
</div>
1010

11+
<% if @pws_status == :healthy %>
12+
<div class="mb-6 p-3 rounded-lg bg-green-50 border border-green-200">
13+
<div class="flex items-center">
14+
<svg class="w-5 h-5 text-green-600 mr-2 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
15+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
16+
</svg>
17+
<p class="text-sm font-medium text-green-800">Enhanced extraction is active</p>
18+
</div>
19+
</div>
20+
<% elsif @pws_status == :unhealthy %>
21+
<div class="mb-6 p-3 rounded-lg bg-yellow-50 border border-yellow-200">
22+
<div class="flex items-center">
23+
<svg class="w-5 h-5 text-yellow-600 mr-2 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
24+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"></path>
25+
</svg>
26+
<p class="text-sm font-medium text-yellow-800">External extraction service is unreachable &mdash; will use local parsing</p>
27+
</div>
28+
</div>
29+
<% end %>
30+
1131
<% if @batch_result %>
1232
<div class="mb-6 p-4 rounded-lg <%= @batch_result.failed == 0 ? 'bg-green-50 border border-green-200' : 'bg-yellow-50 border border-yellow-200' %>">
1333
<h3 class="font-medium <%= @batch_result.failed == 0 ? 'text-green-800' : 'text-yellow-800' %>">

app/views/site_admin/property_url_import/history.html.erb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<tr>
2020
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Source</th>
2121
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
22+
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Extraction</th>
2223
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Date</th>
2324
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Actions</th>
2425
</tr>
@@ -50,6 +51,18 @@
5051
</span>
5152
<% end %>
5253
</td>
54+
<td class="px-6 py-4">
55+
<% case sp.extraction_source %>
56+
<% when "external" %>
57+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">PropertyWebScraper</span>
58+
<% when "local" %>
59+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">Local parser</span>
60+
<% when "manual" %>
61+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Manual HTML</span>
62+
<% else %>
63+
<span class="text-gray-400">&mdash;</span>
64+
<% end %>
65+
</td>
5366
<td class="px-6 py-4 text-sm text-gray-500">
5467
<%= sp.created_at.strftime("%b %d, %Y") %>
5568
</td>

app/views/site_admin/property_url_import/new.html.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
The system will attempt to extract property data from any website. Best results are achieved with these popular property portals:
4242
</p>
4343
<div class="grid grid-cols-2 md:grid-cols-4 gap-3 text-sm">
44+
<% if @pws_enabled && @supported_portals.present? %>
45+
<% @supported_portals.each do |portal| %>
46+
<div class="bg-white rounded px-3 py-2 text-center text-gray-700">
47+
<%= portal.to_s.titleize %>
48+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 ml-1">Enhanced extraction</span>
49+
</div>
50+
<% end %>
51+
<% end %>
4452
<div class="bg-white rounded px-3 py-2 text-center text-gray-700">Rightmove</div>
4553
<div class="bg-white rounded px-3 py-2 text-center text-gray-700">Zoopla</div>
4654
<div class="bg-white rounded px-3 py-2 text-center text-gray-700">Idealista</div>

app/views/site_admin/property_url_import/preview.html.erb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,21 @@
180180
<dt class="text-gray-500">Method:</dt>
181181
<dd class="text-gray-900"><%= @scraped_property.scrape_method == "auto" ? "Automatic" : "Manual HTML" %></dd>
182182
</div>
183+
<div class="flex justify-between">
184+
<dt class="text-gray-500">Extraction:</dt>
185+
<dd>
186+
<% case @scraped_property.extraction_source %>
187+
<% when "external" %>
188+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">PropertyWebScraper</span>
189+
<% when "local" %>
190+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">Local parser</span>
191+
<% when "manual" %>
192+
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Manual HTML</span>
193+
<% else %>
194+
<span class="text-gray-900">&mdash;</span>
195+
<% end %>
196+
</dd>
197+
</div>
183198
<div class="flex justify-between">
184199
<dt class="text-gray-500">Scraped:</dt>
185200
<dd class="text-gray-900"><%= time_ago_in_words(@scraped_property.created_at) %> ago</dd>

0 commit comments

Comments
 (0)