Add support for provider selection (#346)

This commit is contained in:
soky srm
2025-11-17 18:13:20 +01:00
committed by GitHub
parent 0290ed636f
commit 0d798c522a
8 changed files with 109 additions and 15 deletions

View File

@@ -0,0 +1,51 @@
<div class="space-y-4">
<div>
<h2 class="font-medium mb-1"><%= t(".title") %></h2>
<p class="text-secondary text-sm mb-4"><%= t(".description") %></p>
</div>
<%= styled_form_with model: Setting.new,
url: settings_hosting_path,
method: :patch,
data: {
controller: "auto-submit-form",
"auto-submit-form-trigger-event-value": "change"
} do |form| %>
<div class="space-y-4">
<%= form.select :exchange_rate_provider,
[
[t(".providers.twelve_data"), "twelve_data"],
[t(".providers.yahoo_finance"), "yahoo_finance"]
],
{ label: t(".exchange_rate_provider_label") },
{
value: ENV.fetch("EXCHANGE_RATE_PROVIDER", Setting.exchange_rate_provider),
disabled: ENV["EXCHANGE_RATE_PROVIDER"].present?,
data: { "auto-submit-form-target": "auto" }
} %>
<%= form.select :securities_provider,
[
[t(".providers.twelve_data"), "twelve_data"],
[t(".providers.yahoo_finance"), "yahoo_finance"]
],
{ label: t(".securities_provider_label") },
{
value: ENV.fetch("SECURITIES_PROVIDER", Setting.securities_provider),
disabled: ENV["SECURITIES_PROVIDER"].present?,
data: { "auto-submit-form-target": "auto" }
} %>
</div>
<% if ENV["EXCHANGE_RATE_PROVIDER"].present? || ENV["SECURITIES_PROVIDER"].present? %>
<div class="mt-4 bg-warning-50 border border-warning-200 rounded-lg p-3">
<div class="flex items-start gap-2">
<%= icon("alert-circle", class: "w-5 h-5 text-warning-600 mt-0.5 shrink-0") %>
<p class="text-sm text-warning-800">
<%= t(".env_configured_message") %>
</p>
</div>
</div>
<% end %>
<% end %>
</div>

View File

@@ -6,7 +6,7 @@
<% if @yahoo_finance_provider&.healthy? %>
<div class="space-y-4">
<div class="flex items-center space-x-3">
<div class="w-3 h-3 bg-green-500 rounded-full"></div>
<div class="w-3 h-3 bg-success rounded-full"></div>
<p class="text-sm text-secondary">
<%= t(".status_active") %>
</p>
@@ -15,18 +15,19 @@
<% else %>
<div class="space-y-4">
<div class="flex items-center space-x-3">
<div class="w-3 h-3 bg-red-500 rounded-full"></div>
<div class="w-3 h-3 bg-destructive rounded-full"></div>
<p class="text-sm text-secondary">
<%= t(".status_inactive") %>
</p>
</div>
<div class="bg-red-50 border border-red-200 rounded-lg p-3">
<div class="flex">
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">
<div class="bg-destructive-50 border border-destructive-200 rounded-lg p-3">
<div class="flex items-start gap-2">
<%= icon("alert-circle", class: "w-5 h-5 text-destructive-600 mt-0.5 shrink-0") %>
<div>
<h3 class="text-sm font-medium text-destructive-800">
<%= t(".connection_failed") %>
</h3>
<div class="mt-2 text-sm text-red-700">
<div class="mt-2 text-sm text-destructive-700">
<p><%= t(".troubleshooting") %></p>
</div>
</div>

View File

@@ -7,8 +7,13 @@
<% end %>
<%= settings_section title: t(".financial_data_providers") do %>
<div class="space-y-6">
<%= render "settings/hostings/yahoo_finance_settings" %>
<%= render "settings/hostings/twelve_data_settings" %>
<%= render "settings/hostings/provider_selection" %>
<% if @show_yahoo_finance_settings %>
<%= render "settings/hostings/yahoo_finance_settings" %>
<% end %>
<% if @show_twelve_data_settings %>
<%= render "settings/hostings/twelve_data_settings" %>
<% end %>
</div>
<% end %>
<%= settings_section title: t(".invites") do %>