Database.svelte 1.8 KB

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