Commit 955470eee189445d960b13c35755927f6c6c6050

Thomas de Grivel 2022-01-26T21:15:05

[admin] disk usage in org, repo, user show

diff --git a/lib/kmxgit_web/controllers/admin/organisation_controller.ex b/lib/kmxgit_web/controllers/admin/organisation_controller.ex
index 4482a60..15745e4 100644
--- a/lib/kmxgit_web/controllers/admin/organisation_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/organisation_controller.ex
@@ -41,6 +41,8 @@ defmodule KmxgitWeb.Admin.OrganisationController do
   def show(conn, params) do
     org = OrganisationManager.get_organisation(params["id"])
     if org do
+      org = org
+      |> OrganisationManager.put_disk_usage()
       conn
       |> assign(:org, org)
       |> render("show.html")
diff --git a/lib/kmxgit_web/controllers/admin/repository_controller.ex b/lib/kmxgit_web/controllers/admin/repository_controller.ex
index df419ea..aac1edf 100644
--- a/lib/kmxgit_web/controllers/admin/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/repository_controller.ex
@@ -81,6 +81,7 @@ defmodule KmxgitWeb.Admin.RepositoryController do
 
   def show(conn, params) do
     repo = RepositoryManager.get_repository!(params["id"])
+    |> RepositoryManager.put_disk_usage()
     conn
     |> assign(:members, Repository.members(repo))
     |> assign(:repo, repo)
diff --git a/lib/kmxgit_web/controllers/admin/user_controller.ex b/lib/kmxgit_web/controllers/admin/user_controller.ex
index 733126e..2f6b4af 100644
--- a/lib/kmxgit_web/controllers/admin/user_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/user_controller.ex
@@ -44,6 +44,8 @@ defmodule KmxgitWeb.Admin.UserController do
   def show(conn, params) do
     user = UserManager.get_user(params["id"])
     if user do
+      user = user
+      |> UserManager.put_disk_usage()
       owned_repos = User.owned_repositories(user)
       contributor_repos = RepositoryManager.list_contributor_repositories(user)
       repos = owned_repos ++ contributor_repos
diff --git a/lib/kmxgit_web/templates/admin/organisation/show.html.heex b/lib/kmxgit_web/templates/admin/organisation/show.html.heex
index b0cf547..c53a439 100644
--- a/lib/kmxgit_web/templates/admin/organisation/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/organisation/show.html.heex
@@ -48,6 +48,10 @@
         </ul>
       </td>
     </tr>
+    <tr>
+      <th><%= gettext "Disk usage" %></th>
+      <td><%= disk_usage(@org.disk_usage) %></td>
+    </tr>
   </table>
 
   <%= link gettext("Delete organisation"),
diff --git a/lib/kmxgit_web/templates/admin/repository/show.html.heex b/lib/kmxgit_web/templates/admin/repository/show.html.heex
index b687c44..3867ca4 100644
--- a/lib/kmxgit_web/templates/admin/repository/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/repository/show.html.heex
@@ -66,6 +66,10 @@
       </td>
     </tr>
     <tr>
+      <th><%= gettext "Disk usage" %></th>
+      <td><%= disk_usage(@repo.disk_usage) %></td>
+    </tr>
+    <tr>
       <th><%= gettext "Deploy keys (read-only)" %></th>
       <td><pre class="admin_ssh_keys"><%= @repo.deploy_keys %></pre></td>
     </tr>
diff --git a/lib/kmxgit_web/templates/admin/user/show.html.heex b/lib/kmxgit_web/templates/admin/user/show.html.heex
index 44ea24a..47c426c 100644
--- a/lib/kmxgit_web/templates/admin/user/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/user/show.html.heex
@@ -49,6 +49,10 @@
       </td>
     </tr>
     <tr>
+      <th><%= gettext "Disk usage" %></th>
+      <td><%= disk_usage(@user.disk_usage) %></td>
+    </tr>
+    <tr>
       <th><%= gettext "2FA" %></th>
       <td><%= if @user.totp_last != 0, do: "TOTP", else: "none" %></td>
     </tr>