server-stats.svelte 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <script lang="ts">
  2. import { ServerStatsResponseDto, UserResponseDto } from '@api';
  3. export let stats: ServerStatsResponseDto;
  4. export let allUsers: Array<UserResponseDto>;
  5. const getFullName = (userId: string) => {
  6. let name = 'Admin'; // since we do not have admin user in allUsers
  7. allUsers.forEach((user) => {
  8. if (user.id === userId) name = `${user.firstName} ${user.lastName}`;
  9. });
  10. return name;
  11. };
  12. </script>
  13. <div class="flex flex-col gap-6">
  14. <div class="border p-6 rounded-2xl bg-white text-center">
  15. <h1 class="font-medium text-immich-primary">Server Usage</h1>
  16. <div class="flex flex-row gap-6 mt-4 font-medium">
  17. <p class="grow">Photos: {stats.photos}</p>
  18. <p class="grow">Videos: {stats.videos}</p>
  19. <p class="grow">Objects: {stats.objects}</p>
  20. <p class="grow">Size: {stats.usage}</p>
  21. </div>
  22. </div>
  23. <div class="border p-6 rounded-2xl bg-white">
  24. <h1 class="font-medium text-immich-primary">Usage by User</h1>
  25. <table class="text-left w-full mt-4">
  26. <!-- table header -->
  27. <thead class="border rounded-md mb-2 bg-gray-50 flex text-immich-primary w-full h-12">
  28. <tr class="flex w-full place-items-center">
  29. <th class="text-center w-1/5 font-medium text-sm">User</th>
  30. <th class="text-center w-1/5 font-medium text-sm">Photos</th>
  31. <th class="text-center w-1/5 font-medium text-sm">Videos</th>
  32. <th class="text-center w-1/5 font-medium text-sm">Objects</th>
  33. <th class="text-center w-1/5 font-medium text-sm">Size</th>
  34. </tr>
  35. </thead>
  36. <tbody class="overflow-y-auto rounded-md w-full max-h-[320px] block border">
  37. {#each stats.usageByUser as user}
  38. <tr class="text-center flex place-items-center w-full h-[40px]">
  39. <td class="text-sm px-2 w-1/5 text-ellipsis">{getFullName(user.userId)}</td>
  40. <td class="text-sm px-2 w-1/5 text-ellipsis">{user.photos}</td>
  41. <td class="text-sm px-2 w-1/5 text-ellipsis">{user.videos}</td>
  42. <td class="text-sm px-2 w-1/5 text-ellipsis">{user.objects}</td>
  43. <td class="text-sm px-2 w-1/5 text-ellipsis">{user.usage}</td>
  44. </tr>
  45. {/each}
  46. </tbody>
  47. </table>
  48. </div>
  49. </div>