Database.svelte 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script lang="ts">
  2. import { downloadDatabase } from '$lib/apis/utils';
  3. import { onMount, getContext } from 'svelte';
  4. import { config } from '$lib/stores';
  5. const i18n = getContext('i18n');
  6. export let saveHandler: Function;
  7. onMount(async () => {
  8. // permissions = await getUserPermissions(localStorage.token);
  9. });
  10. </script>
  11. <form
  12. class="flex flex-col h-full justify-between space-y-3 text-sm"
  13. on:submit|preventDefault={async () => {
  14. saveHandler();
  15. }}
  16. >
  17. <div class=" space-y-3 pr-1.5 overflow-y-scroll max-h-80">
  18. <div>
  19. <div class=" mb-2 text-sm font-medium">{$i18n.t('Database')}</div>
  20. <div class=" flex w-full justify-between">
  21. <!-- <div class=" self-center text-xs font-medium">{$i18n.t('Allow Chat Deletion')}</div> -->
  22. {#if $config?.admin_export_enabled ?? true}
  23. <button
  24. class=" flex rounded-md py-1.5 px-3 w-full hover:bg-gray-200 dark:hover:bg-gray-800 transition"
  25. type="button"
  26. on:click={() => {
  27. // exportAllUserChats();
  28. downloadDatabase(localStorage.token);
  29. }}
  30. >
  31. <div class=" self-center mr-3">
  32. <svg
  33. xmlns="http://www.w3.org/2000/svg"
  34. viewBox="0 0 16 16"
  35. fill="currentColor"
  36. class="w-4 h-4"
  37. >
  38. <path d="M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3Z" />
  39. <path
  40. fill-rule="evenodd"
  41. d="M13 6H3v6a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V6ZM8.75 7.75a.75.75 0 0 0-1.5 0v2.69L6.03 9.22a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l2.5-2.5a.75.75 0 1 0-1.06-1.06l-1.22 1.22V7.75Z"
  42. clip-rule="evenodd"
  43. />
  44. </svg>
  45. </div>
  46. <div class=" self-center text-sm font-medium">{$i18n.t('Download Database')}</div>
  47. </button>
  48. {/if}
  49. </div>
  50. </div>
  51. </div>
  52. <!-- <div class="flex justify-end pt-3 text-sm font-medium">
  53. <button
  54. class=" px-4 py-2 bg-emerald-600 hover:bg-emerald-700 text-gray-100 transition rounded"
  55. type="submit"
  56. >
  57. Save
  58. </button>
  59. </div> -->
  60. </form>