diff --git a/svelte/src/filesystem/Toolbar.svelte b/svelte/src/filesystem/Toolbar.svelte index 699fb2b..3402800 100644 --- a/svelte/src/filesystem/Toolbar.svelte +++ b/svelte/src/filesystem/Toolbar.svelte @@ -4,8 +4,9 @@ import { copy_text } from "util/Util.svelte"; import FileStats from "./FileStats.svelte"; import type { FSNavigator } from "./FSNavigator"; import EditWindow from "./edit_window/EditWindow.svelte"; -import { fs_share_url } from "lib/FilesystemAPI"; +import { fs_share_url, path_is_shared } from "lib/FilesystemAPI"; import ShareDialog from "./ShareDialog.svelte"; +import { bookmark_add, bookmark_del, bookmarks_store, is_bookmark } from "lib/Bookmarks"; let dispatch = createEventDispatcher() @@ -14,10 +15,9 @@ export let details_visible = false export let edit_window: EditWindow export let edit_visible = false let share_dialog: ShareDialog - -$: share_url = fs_share_url($nav.path) let link_copied = false export const copy_link = () => { + const share_url = fs_share_url($nav.path) if (share_url === "") { edit_window.edit(nav.base, true, "share") return @@ -50,7 +50,19 @@ export const copy_link = () => { Download - {#if share_url !== ""} + {#if is_bookmark($bookmarks_store, $nav.base.id)} + + {:else} + + {/if} + + {#if path_is_shared($nav.path)} diff --git a/svelte/src/user_home/dashboard/Dashboard.svelte b/svelte/src/user_home/dashboard/Dashboard.svelte index 419ec17..605cf52 100644 --- a/svelte/src/user_home/dashboard/Dashboard.svelte +++ b/svelte/src/user_home/dashboard/Dashboard.svelte @@ -7,7 +7,6 @@ import CardSubscription from "./CardSubscription.svelte"; import CardUsage from "./CardUsage.svelte"; import CardActivity from "./CardActivity.svelte"; import CardPrepaidTransactions from "./CardPrepaidTransactions.svelte"; -import CardFsHome from "./CardFSHome.svelte"; import AddressReputation from "home_page/AddressReputation.svelte"; import { flip } from "svelte/animate"; @@ -60,51 +59,37 @@ const swap_card = (idx1, idx2) => { } onMount(() => { - cards = [] - if (window.user.subscription.filesystem_access === true) { - cards.push({ - id: "filesystem_home", - elem: CardFsHome, - title: "Filesystem home", - link: "/d/me", - }) - } - cards.push({ - id: "account", - elem: CardAccount, - title: "Account", - link: "/user/settings", - }) - cards.push({ - id: "subscription", - elem: CardSubscription, - title: "Subscription", - link: "/user/subscription", - }) - if (window.user.subscription.type === "prepaid") { - cards.push({ + cards = [ + { + id: "account", + elem: CardAccount, + title: "Account", + link: "/user/settings", + },{ + id: "subscription", + elem: CardSubscription, + title: "Subscription", + link: "/user/subscription", + }, { id: "prepaid_transactions", elem: CardPrepaidTransactions, title: "Prepaid transactions", link: "/user/prepaid/transactions", - }) - } - cards.push({ - id: "usage", - elem: CardUsage, - title: "Usage", - }) - cards.push({ - id: "statistics", - elem: CardStatistics, - title: "Statistics", - }) - cards.push({ - id: "activity", - elem: CardActivity, - title: "Activity", - link: "/user/activity", - }) + }, { + id: "usage", + elem: CardUsage, + title: "Usage", + }, { + id: "statistics", + elem: CardStatistics, + title: "Statistics", + }, { + id: "activity", + elem: CardActivity, + title: "Activity", + link: "/user/activity", + } + ] // Apply the view settings from localstorage try { diff --git a/svelte/src/util/upload_widget/DropUpload.svelte b/svelte/src/util/upload_widget/DropUpload.svelte deleted file mode 100644 index b4efaba..0000000 --- a/svelte/src/util/upload_widget/DropUpload.svelte +++ /dev/null @@ -1,51 +0,0 @@ - - - { dragging = true }} - on:dragenter|preventDefault|stopPropagation={() => { dragging = true }} - on:dragleave|preventDefault|stopPropagation={() => { dragging = false }} - on:drop={drop} - on:paste={paste} -/> - -{#if dragging} -
- Drop files here to upload them -
-{/if} - - diff --git a/svelte/src/util/upload_widget/UploadFunc.js b/svelte/src/util/upload_widget/UploadFunc.js deleted file mode 100644 index ddd3b60..0000000 --- a/svelte/src/util/upload_widget/UploadFunc.js +++ /dev/null @@ -1,68 +0,0 @@ -// Uploads a file to the logged in user's pixeldrain account. If no user is -// logged in the file is uploaded anonymously. -// -// on_progress reports progress on the file upload, parameter 1 is the uploaded -// file size and parameter 2 is the total file size -// -// on_success is called when the upload is done, the only parameter is the file -// ID -// -// on_error is called when the upload has failed. The parameters are the error -// code and an error message -export const upload_file = (file, name, on_progress, on_success, on_error) => { - // Check the file size limit. For free accounts it's 20 GB - if (window.user.subscription.file_size_limit === 0) { - window.user.subscription.file_size_limit = 20e9 - } - - if (file.size > window.user.subscription.file_size_limit) { - on_failure( - "file_too_large", - "This file is too large. Check out the Pro subscription to increase the file size limit" - ) - return - } - - let xhr = new XMLHttpRequest(); - xhr.open("PUT", window.api_endpoint + "/file/" + encodeURIComponent(name), true); - xhr.timeout = 86400000; // 24 hours, to account for slow connections - - xhr.upload.addEventListener("progress", evt => { - if (on_progress && evt.lengthComputable) { - on_progress(evt.loaded, evt.total) - } - }); - - xhr.onreadystatechange = () => { - // readystate 4 means the upload is done - if (xhr.readyState !== 4) { - return - } - - if (xhr.status >= 100 && xhr.status < 400) { - // Request is a success - on_success(JSON.parse(xhr.response).id) - } else if (xhr.status >= 400) { - // Request failed - console.log("Upload error. status: " + xhr.status + " response: " + xhr.response); - - let resp; - if (xhr.status === 429) { - resp = { - value: "too_many_requests", - message: "Too many requests. Please wait a few seconds", - } - } else { - resp = JSON.parse(xhr.response) - } - - on_error(resp.value, resp.message) - } else if (xhr.status === 0) { - on_error("request_failed", "Your request did not arrive, check your network connection") - } else { - on_error(xhr.responseText, xhr.responseText) - } - }; - - xhr.send(file); -} diff --git a/svelte/src/util/upload_widget/UploadProgress.svelte b/svelte/src/util/upload_widget/UploadProgress.svelte deleted file mode 100644 index 07bb51b..0000000 --- a/svelte/src/util/upload_widget/UploadProgress.svelte +++ /dev/null @@ -1,66 +0,0 @@ - - -
- {job.name}
- {#if error_code !== ""} - {error_message}
- {error_code}
- {/if} - -
- - diff --git a/svelte/src/util/upload_widget/UploadWidget.svelte b/svelte/src/util/upload_widget/UploadWidget.svelte deleted file mode 100644 index aebc37d..0000000 --- a/svelte/src/util/upload_widget/UploadWidget.svelte +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - -{#if visible} -
-
- {#if state === "idle"} - Waiting for files - {:else if state === "uploading"} - Uploading files... - {:else if state === "finished"} - Done - {/if} -
-
- {#each upload_queue as job} - {#if job.status !== "finished"} - - {/if} - {/each} -
-
-{/if} - -{#if drop_upload} - upload_files(e.detail)}/> -{/if} - - diff --git a/svelte/src/wrap/Bookmarks.svelte b/svelte/src/wrap/Bookmarks.svelte index ce5871f..a1ad36e 100644 --- a/svelte/src/wrap/Bookmarks.svelte +++ b/svelte/src/wrap/Bookmarks.svelte @@ -1,11 +1,12 @@ {#each $bookmarks_store as bookmark}
- + {bookmark.icon} {bookmark.label} diff --git a/svelte/src/wrap/MainMenu.svelte b/svelte/src/wrap/MainMenu.svelte index cf65c71..fd3004d 100644 --- a/svelte/src/wrap/MainMenu.svelte +++ b/svelte/src/wrap/MainMenu.svelte @@ -10,9 +10,14 @@ import { fs_get_node } from "lib/FilesystemAPI"; import { css_from_path } from "filesystem/edit_window/Branding"; import { loading_run, loading_store } from "lib/Loading"; import Spinner from "util/Spinner.svelte"; +import { get_user, logout_user } from "lib/PixeldrainAPI"; onMount(async () => { await loading_run(async () => { + const user = await get_user() + if (user.username === undefined || user.username === "") { + return + } const root = await fs_get_node("/me") document.documentElement.style = css_from_path(root.path) }) @@ -21,10 +26,20 @@ onMount(async () => {