Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/components/stat_block_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

class StatBlockComponent < ViewComponent::Base
def initialize(title:, value:)
@title = title
@value = value
end

def call
content_tag :div, class: "badge text-bg-info col me-2" do
safe_join([
content_tag(:div) { @title.respond_to?(:model_name) ? @title.model_name.human(count: 100) : @title.to_s },
content_tag(:div, class: "fs-4 mt-2 ") { @value.to_s }
])
end
end
end
8 changes: 0 additions & 8 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,6 @@ def server_indicator(object)
end
end

def model_count
policy_scope(Model).count
end

def model_file_count
policy_scope(ModelFile).without_special.count
end

def oembed_params
params.permit(:maxwidth, :maxheight)
end
Expand Down
34 changes: 34 additions & 0 deletions app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,38 @@ module SettingsHelper
def masked_email(email)
email.gsub(/(?<=^.)[^@]*|(?<=@.).*(?=\.[^.]+$)/, "****")
end

def model_count(library: nil)
scope = policy_scope(Model)
scope = scope.where(library: library) if library
scope.count
end

def model_file_count(library: nil)
scope = policy_scope(ModelFile)
scope = scope.includes(:model).where("models.library": library) if library
scope.count
end

def total_file_size(library: nil)
scope = policy_scope(ModelFile)
scope = scope.includes(:model).where("models.library": library) if library
scope.sum(:size)
end

def creator_count
policy_scope(Creator).count
end

def collection_count
policy_scope(Collection).count
end

def tag_count
policy_scope(ActsAsTaggableOn::Tag).count
end

def user_count
policy_scope(User).count
end
end
7 changes: 0 additions & 7 deletions app/views/application/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
</li>
</ul>
</div>
<div class="col-4 col-lg-2 mb-3">
<h5><%= t ".stats_heading" %></h5>
<ul class="list-unstyled">
<li class="mb-2"><%= model_count %> <%= Model.model_name.human(count: model_count) %></li>
<li class="mb-2"><%= model_file_count %> <%= ModelFile.model_name.human(count: model_file_count) %></li>
</ul>
</div>
<div class="col-4 col-lg-2 mb-3">
<h5><%= t ".development_heading" %></h5>
<ul class="list-unstyled">
Expand Down
5 changes: 5 additions & 0 deletions app/views/libraries/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
</td>
</tr>
</table>
<div class="row">
<%= render StatBlockComponent.new(title: Model, value: model_count(library: library)) %>
<%= render StatBlockComponent.new(title: ModelFile, value: model_file_count(library: library)) %>
<%= render StatBlockComponent.new(title: t("settings.show.total_file_size"), value: number_to_human_size(total_file_size(library: library), precision: 2)) %>
</div>
</div>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions app/views/settings/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<h3><%= t(".stats") %></h3>

<div class="row">
<%= render StatBlockComponent.new(title: Model, value: model_count) %>
<%= render StatBlockComponent.new(title: ModelFile, value: model_file_count) %>
<%= render StatBlockComponent.new(title: Creator, value: creator_count) %>
<%= render StatBlockComponent.new(title: Collection, value: collection_count) %>
<%= render StatBlockComponent.new(title: User, value: user_count) %>
<%= render StatBlockComponent.new(title: ActsAsTaggableOn::Tag, value: tag_count) %>
<%= render StatBlockComponent.new(title: t(".total_file_size"), value: number_to_human_size(total_file_size, precision: 2)) %>
</div>

<hr>

<%= form_with url: settings_path, method: :patch do |form| %>

<%= render "folder_settings", form: form %>
<hr>
<%= render "file_settings", form: form %>
Expand Down
1 change: 0 additions & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ de:
open_source_html: 'Open Source unter dieser Lizenz: <a href="https://github.com/manyfold3d/manyfold/blob/main/LICENSE.md" target="_blank" rel="license">MIT license</a>'
social: Social Media
sponsor: Sponsoren
stats_heading: Statistiken
version: Version
link_fields:
url:
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ en:
open_source_html: Open Source under the <a href="https://github.com/manyfold3d/manyfold/blob/main/LICENSE.md" target="_blank" rel="license">MIT license</a>.
social: Social
sponsor: Sponsor
stats_heading: Stats
version: Version
link_fields:
url:
Expand Down
1 change: 0 additions & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ es:
open_source_html: Open Source bajo <a href="https://github.com/manyfold3d/manyfold/blob/main/LICENSE.md" target="_blank" rel="license">licencia MIT</a>.
social: Social
sponsor: Colaborar
stats_heading: Estadísticas
version: Versión
link_fields:
url:
Expand Down
1 change: 0 additions & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ fr:
open_source_html: Open Source sous <a href="https://github.com/manyfold3d/manyfold/blob/main/LICENSE.md" target="_blank" rel="license">licence MIT.</a>
social: Social
sponsor: Sponsor
stats_heading: Statistiques
version: Version
link_fields:
url:
Expand Down
1 change: 0 additions & 1 deletion config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ nl:
open_source_html: Open Source onder de <a href="https://github.com/manyfold3d/manyfold/blob/main/LICENSE.md" target="_blank" rel="license">MIT-licentie</a>.
social: Sociaal
sponsor: Sponsor
stats_heading: Statistieken
version: Versie
link_fields:
url:
Expand Down
1 change: 0 additions & 1 deletion config/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ pl:
open_source_html: Projekt Open Source na <a href="https://github.com/manyfold3d/manyfold/blob/main/LICENSE.md" target="_blank" rel="license">licencji MIT</a>.
social: Sociale
sponsor: Sponsoruj
stats_heading: Statystyki
version: Wersja
link_fields:
url:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/settings/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ de:
update:
ignored: Die Meldung wurde ignoriert
resolved: Die Meldung wurde als Gelöst Markiert
show:
stats: Statistiken
tag_settings:
auto_tag_new:
label: Automatisch neue Modelle mit Tag(s) markieren
Expand Down
3 changes: 3 additions & 0 deletions config/locales/settings/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ en:
update:
ignored: The report has been ignored.
resolved: The report has been marked as resolved.
show:
stats: Statistics
total_file_size: Total file size
tag_settings:
auto_tag_new:
label: Automatically tag new models with
Expand Down
2 changes: 2 additions & 0 deletions config/locales/settings/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ es:
update:
ignored: El informe ha sido ignorado.
resolved: El informe se ha marcado como resuelto.
show:
stats: Estadísticas
tag_settings:
auto_tag_new:
label: Etiquetar automáticamente los nuevos modelos con
Expand Down
2 changes: 2 additions & 0 deletions config/locales/settings/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ fr:
update:
ignored: Le rapport a été ignoré.
resolved: Le rapport a été marqué comme résolu.
show:
stats: Statistiques
tag_settings:
auto_tag_new:
label: Etiqueter automatiquement les nouveaux modèles
Expand Down
2 changes: 2 additions & 0 deletions config/locales/settings/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ nl:
update:
ignored: De melding is genegeerd.
resolved: De melding is gemarkeerd als opgelost.
show:
stats: Statistieken
tag_settings:
auto_tag_new:
label: Tag nieuwe modellen automatisch met
Expand Down
2 changes: 2 additions & 0 deletions config/locales/settings/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pl:
update:
ignored: Zgłoszenie zostało zignorowane.
resolved: Zgłoszenie zostało oznaczone jako rozwiązane.
show:
stats: Statystyki
tag_settings:
auto_tag_new:
label: Automatycznie taguj nowe modele za pomocą
Expand Down
Loading