Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
5.1 KB
Raw Blame
<% env_configured = ENV["SIMPLEFIN_INCLUDE_PENDING"].present? || ENV["PLAID_INCLUDE_PENDING"].present? %>
<div class="space-y-4">
  <div class="flex items-center justify-between">
    <div class="space-y-1">
      <p class="text-sm"><%= t(".include_pending_label") %></p>
      <p class="text-secondary text-sm"><%= t(".include_pending_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| %>
      <%= form.toggle :syncs_include_pending,
                      checked: Setting.syncs_include_pending,
                      disabled: env_configured,
                      data: { auto_submit_form_target: "auto" } %>
    <% end %>
  </div>

  <div class="flex items-center justify-between">
    <div class="space-y-1">
      <p class="text-sm"><%= t(".auto_sync_label") %></p>
      <p class="text-secondary text-sm"><%= t(".auto_sync_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| %>
      <%= form.toggle :auto_sync_enabled,
                      checked: Setting.auto_sync_enabled,
                      data: { auto_submit_form_target: "auto" } %>
    <% end %>
  </div>

  <div class="flex items-center justify-between">
    <div class="space-y-1">
      <p class="text-sm"><%= t(".auto_sync_time_label") %></p>
      <p class="text-secondary text-sm"><%= t(".auto_sync_time_description") %></p>
    </div>

    <%= 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| %>
      <%= form.time_field :auto_sync_time,
                          value: Setting.auto_sync_time,
                          disabled: !Setting.auto_sync_enabled,
                          class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container text-primary w-full",
                          data: { auto_submit_form_target: "auto" } %>
    <% end %>
  </div>

  <div class="flex items-center justify-between">
    <div class="space-y-1">
      <p class="text-sm"><%= t(".market_data_sync_label") %></p>
      <p class="text-secondary text-sm"><%= t(".market_data_sync_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| %>
      <%= form.toggle :market_data_sync_enabled,
                      checked: Setting.market_data_sync_enabled,
                      data: { auto_submit_form_target: "auto" } %>
    <% end %>
  </div>

  <div class="flex items-center justify-between">
    <div class="space-y-1">
      <p class="text-sm"><%= t(".market_data_sync_time_label") %></p>
      <p class="text-secondary text-sm"><%= t(".market_data_sync_time_description") %></p>
    </div>

    <%= 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| %>
      <%= form.label :market_data_sync_time, t(".market_data_sync_time_label"), class: "sr-only" %>
      <%= form.time_field :market_data_sync_time,
                          value: Setting.market_data_sync_time,
                          disabled: !Setting.market_data_sync_enabled,
                          class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container text-primary w-full",
                          data: { auto_submit_form_target: "auto" } %>
    <% end %>
  </div>

  <%# The page cache's three numbers: each from its env variable when set (the
      field is then disabled and shows the value in effect), else this form. %>
  <% {
       page_cache_days: t(".page_cache_days_description", default_days: Setting::PAGE_CACHE_DAYS_DEFAULT),
       page_cache_cooldown_minutes: t(".page_cache_cooldown_minutes_description", default_minutes: Setting::PAGE_CACHE_COOLDOWN_MINUTES_DEFAULT),
       page_cache_max_mb: t(".page_cache_max_mb_description",
                            default_mb: Setting::PAGE_CACHE_MAX_MB_DEFAULT,
                            used: number_to_human_size(PageCache.total_bytes),
                            limit: number_to_human_size(PageCache.max_bytes))
     }.each do |name, description| %>
    <%= render "settings/hostings/page_cache_setting", name: name, label: t(".#{name}_label"), description: description %>
  <% end %>

  <% if env_configured %>
    <%= render DS::Alert.new(message: t(".env_configured_message"), variant: :warning) %>
  <% end %>
</div>