Compare commits

...
22 Commits
Author SHA1 Message Date
Pixeldrain-Server ca5342d7fa Fix typo 2026-11-12 15:58:21 +01:00
Pixeldrain-Server ee06b91b92 Add remote sync feature to run rclone on the server side 2026-11-12 15:50:06 +01:00
Pixeldrain-Server b423446412 Add button titles for accessibility 2026-11-09 20:42:08 +01:00
Pixeldrain-Server 5788f5a8b4 Update to Material Symbols and switch to class names for icons
The switch to class names is for accessibility. Class names are not translated by browser translation plugins and not read by screen readers.
2026-11-09 20:26:23 +01:00
Pixeldrain-Server 672a19f8f6 Remove Svelte upgrade compatibility code 2026-11-09 19:18:18 +01:00
Pixeldrain-Server 1956790dde Add data sync form 2026-11-09 18:48:27 +01:00
Pixeldrain-Server ebb72c7f24 Redesign the home page 2026-11-05 15:53:24 +01:00
Pixeldrain-Server 5b32f3dca7 Update S3 connection information 2026-10-09 16:11:48 +02:00
Pixeldrain-Server 9f8a985c63 Add S3 metrics 2026-10-06 16:19:23 +02:00
Pixeldrain-Server 8a41307700 Only warn about limits when usage-based billing is disabled 2026-10-06 11:51:19 +02:00
Pixeldrain-Server e3e8a1db1a Move metered billing settings to the subscription tab 2026-10-06 01:00:53 +02:00
Pixeldrain-Server a50ac7310f Tweak subscriptions some more 2026-10-06 00:46:54 +02:00
Pixeldrain-Server 1f7238841a Update uploading widget 2026-10-05 21:47:04 +02:00
Pixeldrain-Server f3738cbc4d Allow password entry for shared directories 2026-10-05 17:39:39 +02:00
Pixeldrain-Server 6f0f58d2d9 Allow bulk downloading selection 2026-10-05 14:12:18 +02:00
Pixeldrain-Server 93d5583940 Add OAuth authorization page 2026-10-05 13:46:24 +02:00
Pixeldrain-Server a513e731c4 Redesign permissions page 2026-10-02 19:33:58 +02:00
Pixeldrain-Server d5772c24e5 Enable search on all pages 2026-10-02 18:19:42 +02:00
Pixeldrain-Server 09fa193e9a Fix issue where swiping a shared image without a directory made it disappear 2026-10-02 15:22:02 +02:00
Pixeldrain-Server f5b9f543c6 Add drag and drop to file manager 2026-10-02 15:10:34 +02:00
Pixeldrain-Server 9a7ed0a347 Rename entrypoint to main.ts. Tweak text contrast 2026-10-02 13:53:53 +02:00
Pixeldrain-Server 41c0481380 Add two random glows with dithering as background. 2026-10-02 13:31:16 +02:00
124 changed files with 3499 additions and 2201 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
module fornaxian.tech/nova_web module fornaxian.tech/nova_web
go 1.26 go 1.27
replace ( replace (
fornaxian.tech/nova_server => ../nova_server fornaxian.tech/nova_server => ../nova_server
Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.
+107
View File
@@ -0,0 +1,107 @@
/* Generated by svelte/icons.js */
.i_account_balance_wallet{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760H520q-71 0-115.5 44.5T360-600v240q0 71 44.5 115.5T520-200h320q0 33-23.5 56.5T760-120H200Zm320-160q-33 0-56.5-23.5T440-360v-240q0-33 23.5-56.5T520-680h280q33 0 56.5 23.5T880-600v240q0 33-23.5 56.5T800-280H520Zm163-157q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Z'/></svg>")}
.i_add{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z'/></svg>")}
.i_admin_panel_settings{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M680-80q-83 0-141.5-58.5T480-280q0-83 58.5-141.5T680-480q83 0 141.5 58.5T880-280q0 83-58.5 141.5T680-80Zm-200 0q-139-35-229.5-159.5T160-516v-244l320-120 320 120v227q-26-13-58.5-20t-61.5-7q-116 0-198 82t-82 198q0 62 23.5 112T483-81q-1 0-1.5.5t-1.5.5Zm242.5-217.5Q740-315 740-340t-17.5-42.5Q705-400 680-400t-42.5 17.5Q620-365 620-340t17.5 42.5Q655-280 680-280t42.5-17.5ZM680-160q31 0 57-14.5t42-38.5q-22-13-47-20t-52-7q-27 0-52 7t-47 20q16 24 42 38.5t57 14.5Z'/></svg>")}
.i_app_registration{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M183.5-183.5Q160-207 160-240t23.5-56.5Q207-320 240-320t56.5 23.5Q320-273 320-240t-23.5 56.5Q273-160 240-160t-56.5-23.5Zm0-240Q160-447 160-480t23.5-56.5Q207-560 240-560t56.5 23.5Q320-513 320-480t-23.5 56.5Q273-400 240-400t-56.5-23.5Zm0-240Q160-687 160-720t23.5-56.5Q207-800 240-800t56.5 23.5Q320-753 320-720t-23.5 56.5Q273-640 240-640t-56.5-23.5Zm240 0Q400-687 400-720t23.5-56.5Q447-800 480-800t56.5 23.5Q560-753 560-720t-23.5 56.5Q513-640 480-640t-56.5-23.5Zm240 0Q640-687 640-720t23.5-56.5Q687-800 720-800t56.5 23.5Q800-753 800-720t-23.5 56.5Q753-640 720-640t-56.5-23.5Zm-240 240Q400-447 400-480t23.5-56.5Q447-560 480-560t56.5 23.5Q560-513 560-480t-23.5 56.5Q513-400 480-400t-56.5-23.5ZM520-160v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T863-380L643-160H520Zm263-224 37-39-37-37-38 38 38 38Z'/></svg>")}
.i_apps{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M183.5-183.5Q160-207 160-240t23.5-56.5Q207-320 240-320t56.5 23.5Q320-273 320-240t-23.5 56.5Q273-160 240-160t-56.5-23.5Zm240 0Q400-207 400-240t23.5-56.5Q447-320 480-320t56.5 23.5Q560-273 560-240t-23.5 56.5Q513-160 480-160t-56.5-23.5Zm240 0Q640-207 640-240t23.5-56.5Q687-320 720-320t56.5 23.5Q800-273 800-240t-23.5 56.5Q753-160 720-160t-56.5-23.5Zm-480-240Q160-447 160-480t23.5-56.5Q207-560 240-560t56.5 23.5Q320-513 320-480t-23.5 56.5Q273-400 240-400t-56.5-23.5Zm240 0Q400-447 400-480t23.5-56.5Q447-560 480-560t56.5 23.5Q560-513 560-480t-23.5 56.5Q513-400 480-400t-56.5-23.5Zm240 0Q640-447 640-480t23.5-56.5Q687-560 720-560t56.5 23.5Q800-513 800-480t-23.5 56.5Q753-400 720-400t-56.5-23.5Zm-480-240Q160-687 160-720t23.5-56.5Q207-800 240-800t56.5 23.5Q320-753 320-720t-23.5 56.5Q273-640 240-640t-56.5-23.5Zm240 0Q400-687 400-720t23.5-56.5Q447-800 480-800t56.5 23.5Q560-753 560-720t-23.5 56.5Q513-640 480-640t-56.5-23.5Zm240 0Q640-687 640-720t23.5-56.5Q687-800 720-800t56.5 23.5Q800-753 800-720t-23.5 56.5Q753-640 720-640t-56.5-23.5Z'/></svg>")}
.i_area_chart{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M840-320 464-614 305-395 120-540v-140l160 120 200-280 200 160h160v360ZM120-160v-280l200 160 160-220 360 281v59H120Z'/></svg>")}
.i_arrow_back{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z'/></svg>")}
.i_arrow_drop_down{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-360 280-560h400L480-360Z'/></svg>")}
.i_arrow_forward{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M647-440H160v-80h487L423-744l57-56 320 320-320 320-57-56 224-224Z'/></svg>")}
.i_arrow_right{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M400-280v-400l200 200-200 200Z'/></svg>")}
.i_block{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M324-111.5Q251-143 197-197t-85.5-127Q80-397 80-480t31.5-156Q143-709 197-763t127-85.5Q397-880 480-880t156 31.5Q709-817 763-763t85.5 127Q880-563 880-480t-31.5 156Q817-251 763-197t-127 85.5Q563-80 480-80t-156-31.5ZM677-227q16-12 30-26t26-30L283-733q-16 12-30 26t-26 30l450 450Z'/></svg>")}
.i_bolt{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m320-80 40-280H160l360-520h80l-40 320h240L400-80h-80Z'/></svg>")}
.i_bookmark_add{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M200-120v-640q0-33 23.5-56.5T280-840h280q-20 30-30 57.5T520-720q0 72 45.5 127T680-524q23 3 40 3t40-3v404L480-240 200-120Zm480-480v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z'/></svg>")}
.i_bookmark_remove{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M840-680H600v-80h240v80ZM200-120v-640q0-33 23.5-56.5T280-840h280q-20 30-30 57.5T520-720q0 72 45.5 127T680-524q23 3 40 3t40-3v404L480-240 200-120Z'/></svg>")}
.i_cancel{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z'/></svg>")}
.i_check{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z'/></svg>")}
.i_chevron_left{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z'/></svg>")}
.i_chevron_right{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z'/></svg>")}
.i_close{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z'/></svg>")}
.i_cloud_upload{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M440-160H260q-91 0-155.5-63T40-377q0-78 47-139t123-78q25-92 100-149t170-57q117 0 198.5 81.5T760-520q69 8 114.5 59.5T920-340q0 75-52.5 127.5T740-160H520v-286l64 62 56-56-160-160-160 160 56 56 64-62v286Z'/></svg>")}
.i_collections{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M360-400h400L622-580l-92 120-62-80-108 140Zm-40 160q-33 0-56.5-23.5T240-320v-480q0-33 23.5-56.5T320-880h480q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H320ZM160-80q-33 0-56.5-23.5T80-160v-560h80v560h560v80H160Z'/></svg>")}
.i_content_copy{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Z'/></svg>")}
.i_create{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-120v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm584-528 56-56-56-56-56 56 56 56Z'/></svg>")}
.i_create_new_folder{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M560-320h80v-80h80v-80h-80v-80h-80v80h-80v80h80v80ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Z'/></svg>")}
.i_dashboard{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M520-600v-240h320v240H520ZM120-440v-400h320v400H120Zm400 320v-400h320v400H520Zm-400 0v-240h320v240H120Z'/></svg>")}
.i_data_usage{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-80q-83 0-156-31.5t-127-86Q143-252 111.5-325T80-480q0-157 104-270t256-128v120q-103 14-171.5 92.5T200-480q0 116 82 198t198 82q66 0 123.5-28t96.5-76l104 60q-54 75-139 119.5T480-80Zm366-238-104-60q9-24 13.5-49.5T760-480q0-107-68.5-185.5T520-758v-120q152 15 256 128t104 270q0 44-8 85t-26 77Z'/></svg>")}
.i_delete{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm80-160h80v-360h-80v360Zm160 0h80v-360h-80v360Z'/></svg>")}
.i_delete_forever{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m376-300 104-104 104 104 56-56-104-104 104-104-56-56-104 104-104-104-56 56 104 104-104 104 56 56Zm-96 180q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Z'/></svg>")}
.i_description{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M320-240h320v-80H320v80Zm0-160h320v-80H320v80ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520h200L520-800v200Z'/></svg>")}
.i_done{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z'/></svg>")}
.i_download{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z'/></svg>")}
.i_drag_indicator{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z'/></svg>")}
.i_drive_file_move{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm328-240-65 65 56 56 161-161-161-161-56 56 65 65H320v80h168Z'/></svg>")}
.i_east{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m600-200-57-56 184-184H80v-80h647L544-704l56-56 280 280-280 280Z'/></svg>")}
.i_edit{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-120v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm584-528 56-56-56-56-56 56 56 56Z'/></svg>")}
.i_email{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm320-280 320-200v-80L480-520 160-720v80l320 200Z'/></svg>")}
.i_expand_less{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z'/></svg>")}
.i_expand_more{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/></svg>")}
.i_flag{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M200-120v-680h360l16 80h224v400H520l-16-80H280v280h-80Z'/></svg>")}
.i_folder{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Z'/></svg>")}
.i_folder_open{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640H160v400l96-320h684L837-217q-8 26-29.5 41.5T760-160H160Z'/></svg>")}
.i_forward_10{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M360-320v-180h-60v-60h120v240h-60Zm140 0q-17 0-28.5-11.5T460-360v-160q0-17 11.5-28.5T500-560h80q17 0 28.5 11.5T620-520v160q0 17-11.5 28.5T580-320h-80Zm20-60h40v-120h-40v120ZM339.5-108.5q-65.5-28.5-114-77t-77-114Q120-365 120-440t28.5-140.5q28.5-65.5 77-114t114-77Q405-800 480-800h6l-62-62 56-58 160 160-160 160-56-58 62-62h-6q-117 0-198.5 81.5T200-440q0 117 81.5 198.5T480-160q117 0 198.5-81.5T760-440h80q0 75-28.5 140.5t-77 114q-48.5 48.5-114 77T480-80q-75 0-140.5-28.5Z'/></svg>")}
.i_fullscreen{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z'/></svg>")}
.i_help{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M513.5-254.5Q528-269 528-290t-14.5-35.5Q499-340 478-340t-35.5 14.5Q428-311 428-290t14.5 35.5Q457-240 478-240t35.5-14.5ZM442-394h74q0-33 7.5-52t42.5-52q26-26 41-49.5t15-56.5q0-56-41-86t-97-30q-57 0-92.5 30T342-618l66 26q5-18 22.5-39t53.5-21q32 0 48 17.5t16 38.5q0 20-12 37.5T506-526q-44 39-54 59t-10 73Zm38 314q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z'/></svg>")}
.i_home{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M160-120v-480l320-240 320 240v480H560v-280H400v280H160Z'/></svg>")}
.i_how_to_reg{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M622-144 484-282l56-56 82 82 202-202 56 56-258 258ZM287-527q-47-47-47-113t47-113q47-47 113-47t113 47q47 47 47 113t-47 113q-47 47-113 47t-113-47Zm227 99L368-282l122 122H80v-112q0-33 17-62t47-44q51-26 115-44t141-18q30 0 58.5 3t55.5 9Z'/></svg>")}
.i_hub{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M155-75q-35-35-35-85t35-85q35-35 85-35 14 0 26 3t23 8l57-71q-28-31-39-70t-5-78l-81-27q-17 25-43 40t-58 15q-50 0-85-35T0-580q0-50 35-85t85-35q50 0 85 35t35 85v8l81 28q20-36 53.5-61t75.5-32v-87q-39-11-64.5-42.5T360-840q0-50 35-85t85-35q50 0 85 35t35 85q0 42-26 73.5T510-724v87q42 7 75.5 32t53.5 61l81-28v-8q0-50 35-85t85-35q50 0 85 35t35 85q0 50-35 85t-85 35q-32 0-58.5-15T739-515l-81 27q6 39-5 77.5T614-340l57 70q11-5 23-7.5t26-2.5q50 0 85 35t35 85q0 50-35 85t-85 35q-50 0-85-35t-35-85q0-20 6.5-38.5T624-232l-57-71q-41 23-87.5 23T392-303l-56 71q11 15 17.5 33.5T360-160q0 50-35 85t-85 35q-50 0-85-35Z'/></svg>")}
.i_image{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm40-160h480L570-480 450-320l-90-120-120 160Z'/></svg>")}
.i_info{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M440-280h80v-240h-80v240Zm68.5-331.5Q520-623 520-640t-11.5-28.5Q497-680 480-680t-28.5 11.5Q440-657 440-640t11.5 28.5Q463-600 480-600t28.5-11.5ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z'/></svg>")}
.i_key{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M365-395q35-35 35-85t-35-85q-35-35-85-35t-85 35q-35 35-35 85t35 85q35 35 85 35t85-35Zm-85 155q-100 0-170-70T40-480q0-100 70-170t170-70q81 0 141.5 46T506-560h335l79 79-140 160-100-79-80 80-80-80h-14q-25 72-87 116t-139 44Z'/></svg>")}
.i_list{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M280-600v-80h560v80H280Zm0 160v-80h560v80H280Zm0 160v-80h560v80H280ZM160-600q-17 0-28.5-11.5T120-640q0-17 11.5-28.5T160-680q17 0 28.5 11.5T200-640q0 17-11.5 28.5T160-600Zm0 160q-17 0-28.5-11.5T120-480q0-17 11.5-28.5T160-520q17 0 28.5 11.5T200-480q0 17-11.5 28.5T160-440Zm0 160q-17 0-28.5-11.5T120-320q0-17 11.5-28.5T160-360q17 0 28.5 11.5T200-320q0 17-11.5 28.5T160-280Z'/></svg>")}
.i_lock_open{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M240-640h360v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85h-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640Zm296.5 336.5Q560-327 560-360t-23.5-56.5Q513-440 480-440t-56.5 23.5Q400-393 400-360t23.5 56.5Q447-280 480-280t56.5-23.5Z'/></svg>")}
.i_login{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-120v-80h280v-560H480v-80h280q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H480Zm-80-160-55-58 102-102H120v-80h327L345-622l55-58 200 200-200 200Z'/></svg>")}
.i_logout{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h280v80H200Zm440-160-55-58 102-102H360v-80h327L585-622l55-58 200 200-200 200Z'/></svg>")}
.i_menu{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z'/></svg>")}
.i_more_time{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M299.5-148Q234-176 185-225t-77-114.5Q80-405 80-480t28-140.5Q136-686 185-735t114.5-77Q365-840 440-840q21 0 40.5 2.5T520-830v82q-20-6-39.5-9t-40.5-3q-118 0-199 81t-81 199q0 118 81 199t199 81q118 0 199-81t81-199q0-11-1-20t-3-20h82q2 11 2 20v20q0 75-28 140.5T695-225q-49 49-114.5 77T440-120q-75 0-140.5-28ZM552-312 400-464v-216h80v184l128 128-56 56Zm168-288v-120H600v-80h120v-120h80v120h120v80H800v120h-80Z'/></svg>")}
.i_north{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M440-80v-647L256-544l-56-56 280-280 280 280-56 57-184-184v647h-80Z'/></svg>")}
.i_open_in_new{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z'/></svg>")}
.i_paid{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M444-200h70v-50q50-9 86-39t36-89q0-42-24-77t-96-61q-60-20-83-35t-23-41q0-26 18.5-41t53.5-15q32 0 50 15.5t26 38.5l64-26q-11-35-40.5-61T516-710v-50h-70v50q-50 11-78 44t-28 74q0 47 27.5 76t86.5 50q63 23 87.5 41t24.5 47q0 33-23.5 48.5T486-314q-33 0-58.5-20.5T390-396l-66 26q14 48 43.5 77.5T444-252v52Zm36 120q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z'/></svg>")}
.i_palette{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 32.5-156t88-127Q256-817 330-848.5T488-880q80 0 151 27.5t124.5 76q53.5 48.5 85 115T880-518q0 115-70 176.5T640-280h-74q-9 0-12.5 5t-3.5 11q0 12 15 34.5t15 51.5q0 50-27.5 74T480-80ZM303-457q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Zm120-160q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Zm200 0q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Zm120 160q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Z'/></svg>")}
.i_pause{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M560-200v-560h160v560H560Zm-320 0v-560h160v560H240Z'/></svg>")}
.i_payments{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-160q-33 0-56.5-23.5T40-240v-440h80v440h680v80H120Zm160-160q-33 0-56.5-23.5T200-400v-320q0-33 23.5-56.5T280-800h560q33 0 56.5 23.5T920-720v320q0 33-23.5 56.5T840-320H280Zm80-80q0-33-23.5-56.5T280-480v80h80Zm400 0h80v-80q-33 0-56.5 23.5T760-400Zm-200-40q50 0 85-35t35-85q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 50 35 85t85 35ZM280-640q33 0 56.5-23.5T360-720h-80v80Zm560 0v-80h-80q0 33 23.5 56.5T840-640Z'/></svg>")}
.i_person{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M367-527q-47-47-47-113t47-113q47-47 113-47t113 47q47 47 47 113t-47 113q-47 47-113 47t-113-47ZM160-160v-112q0-34 17.5-62.5T224-378q62-31 126-46.5T480-440q66 0 130 15.5T736-378q29 15 46.5 43.5T800-272v112H160Z'/></svg>")}
.i_person_remove{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M640-520v-80h240v80H640Zm-393-7q-47-47-47-113t47-113q47-47 113-47t113 47q47 47 47 113t-47 113q-47 47-113 47t-113-47ZM40-160v-112q0-34 17.5-62.5T104-378q62-31 126-46.5T360-440q66 0 130 15.5T616-378q29 15 46.5 43.5T680-272v112H40Z'/></svg>")}
.i_photo_library{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M360-400h400L622-580l-92 120-62-80-108 140Zm-40 160q-33 0-56.5-23.5T240-320v-480q0-33 23.5-56.5T320-880h480q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H320ZM160-80q-33 0-56.5-23.5T80-160v-560h80v560h560v80H160Z'/></svg>")}
.i_play_arrow{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M320-200v-560l440 280-440 280Z'/></svg>")}
.i_priority_high{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-120q-33 0-56.5-23.5T400-200q0-33 23.5-56.5T480-280q33 0 56.5 23.5T560-200q0 33-23.5 56.5T480-120Zm-80-240v-480h160v480H400Z'/></svg>")}
.i_public{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M324-111.5Q251-143 197-197t-85.5-127Q80-397 80-480t31.5-156Q143-709 197-763t127-85.5Q397-880 480-880t156 31.5Q709-817 763-763t85.5 127Q880-563 880-480t-31.5 156Q817-251 763-197t-127 85.5Q563-80 480-80t-156-31.5ZM440-162v-78q-33 0-56.5-23.5T360-320v-40L168-552q-3 18-5.5 36t-2.5 36q0 121 79.5 212T440-162Zm276-102q41-45 62.5-100.5T800-480q0-98-54.5-179T600-776v16q0 33-23.5 56.5T520-680h-80v80q0 17-11.5 28.5T400-560h-80v80h240q17 0 28.5 11.5T600-440v120h40q26 0 47 15.5t29 40.5Z'/></svg>")}
.i_receipt{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-80v-800l60 60 60-60 60 60 60-60 60 60 60-60 60 60 60-60 60 60 60-60 60 60 60-60v800l-60-60-60 60-60-60-60 60-60-60-60 60-60-60-60 60-60-60-60 60-60-60-60 60Zm120-200h480v-80H240v80Zm0-160h480v-80H240v80Zm0-160h480v-80H240v80Z'/></svg>")}
.i_refresh{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z'/></svg>")}
.i_replay_10{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M339.5-108.5q-65.5-28.5-114-77t-77-114Q120-365 120-440h80q0 117 81.5 198.5T480-160q117 0 198.5-81.5T760-440q0-117-81.5-198.5T480-720h-6l62 62-56 58-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-440q0 75-28.5 140.5t-77 114q-48.5 48.5-114 77T480-80q-75 0-140.5-28.5ZM360-320v-180h-60v-60h120v240h-60Zm140 0q-17 0-28.5-11.5T460-360v-160q0-17 11.5-28.5T500-560h80q17 0 28.5 11.5T620-520v160q0 17-11.5 28.5T580-320h-80Zm20-60h40v-120h-40v120Z'/></svg>")}
.i_restart_alt{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M440-122q-121-15-200.5-105.5T160-440q0-66 26-126.5T260-672l57 57q-38 34-57.5 79T240-440q0 88 56 155.5T440-202v80Zm80 0v-80q87-16 143.5-83T720-440q0-100-70-170t-170-70h-3l44 44-56 56-140-140 140-140 56 56-44 44h3q134 0 227 93t93 227q0 121-79.5 211.5T520-122Z'/></svg>")}
.i_restore_from_trash{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M440-320h80v-166l64 62 56-56-160-160-160 160 56 56 64-62v166ZM280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Z'/></svg>")}
.i_save{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M840-680v480q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h480l160 160ZM565-275q35-35 35-85t-35-85q-35-35-85-35t-85 35q-35 35-35 85t35 85q35 35 85 35t85-35ZM240-560h360v-160H240v160Z'/></svg>")}
.i_search{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z'/></svg>")}
.i_select_all{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z'/></svg>")}
.i_send{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-160v-240l320-80-320-80v-240l760 320-760 320Z'/></svg>")}
.i_settings{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm112-260q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Z'/></svg>")}
.i_share{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M680-80q-50 0-85-35t-35-85q0-6 3-28L282-392q-16 15-37 23.5t-45 8.5q-50 0-85-35t-35-85q0-50 35-85t85-35q24 0 45 8.5t37 23.5l281-164q-2-7-2.5-13.5T560-760q0-50 35-85t85-35q50 0 85 35t35 85q0 50-35 85t-85 35q-24 0-45-8.5T598-672L317-508q2 7 2.5 13.5t.5 14.5q0 8-.5 14.5T317-452l281 164q16-15 37-23.5t45-8.5q50 0 85 35t35 85q0 50-35 85t-85 35Z'/></svg>")}
.i_shopping_cart{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M223.5-103.5Q200-127 200-160t23.5-56.5Q247-240 280-240t56.5 23.5Q360-193 360-160t-23.5 56.5Q313-80 280-80t-56.5-23.5Zm400 0Q600-127 600-160t23.5-56.5Q647-240 680-240t56.5 23.5Q760-193 760-160t-23.5 56.5Q713-80 680-80t-56.5-23.5ZM208-800h590q23 0 35 20.5t1 41.5L692-482q-11 20-29.5 31T622-440H324l-44 80h480v80H280q-45 0-68-39.5t-2-78.5l54-98-144-304H40v-80h130l38 80Z'/></svg>")}
.i_shuffle{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M560-160v-80h104L537-367l57-57 126 126v-102h80v240H560Zm-344 0-56-56 504-504H560v-80h240v240h-80v-104L216-160Zm151-377L160-744l56-56 207 207-56 56Z'/></svg>")}
.i_skip_next{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M660-240v-480h80v480h-80Zm-440 0v-480l360 240-360 240Z'/></svg>")}
.i_skip_previous{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M220-240v-480h80v480h-80Zm520 0L380-480l360-240v480Z'/></svg>")}
.i_speed{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M418-340q25 25 63 23.5t55-27.5l224-336-336 224q-26 18-28.5 54.5T418-340ZM204-160q-22 0-40.5-9.5T134-198q-26-47-40-97.5T80-400q0-83 31.5-156T197-683q54-54 127-85.5T480-800q82 0 154 31t126 84.5q54 53.5 86 125T879-406q1 55-12.5 107.5T825-198q-11 19-29.5 28.5T755-160H204Z'/></svg>")}
.i_star{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m233-120 65-281L80-590l288-25 112-265 112 265 288 25-218 189 65 281-247-149-247 149Z'/></svg>")}
.i_stop{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M240-240v-480h480v480H240Z'/></svg>")}
.i_storage{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M120-160v-160h720v160H120Zm80-40h80v-80h-80v80Zm-80-440v-160h720v160H120Zm80-40h80v-80h-80v80Zm-80 280v-160h720v160H120Zm80-40h80v-80h-80v80Z'/></svg>")}
.i_swap_horiz{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M280-160 80-360l200-200 56 57-103 103h287v80H233l103 103-56 57Zm400-240-56-57 103-103H440v-80h287L624-743l56-57 200 200-200 200Z'/></svg>")}
.i_sync_alt{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M280-120 80-320l200-200 57 56-104 104h607v80H233l104 104-57 56Zm400-320-57-56 104-104H120v-80h607L623-784l57-56 200 200-200 200Z'/></svg>")}
.i_text_snippet{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h400l240 240v400q0 33-23.5 56.5T760-120H200Zm80-160h400v-80H280v80Zm0-160h400v-80H280v80Zm0-160h280v-80H280v80Z'/></svg>")}
.i_touch_app{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M419-80q-28 0-52.5-12T325-126L107-403l19-20q20-21 48-25t52 11l74 45v-328q0-17 11.5-28.5T340-760q17 0 29 11.5t12 28.5v200h299q50 0 85 35t35 85v160q0 66-47 113T640-80H419ZM167-620q-13-22-20-47.5t-7-52.5q0-83 58.5-141.5T340-920q83 0 141.5 58.5T540-720q0 27-7 52.5T513-620l-69-40q8-14 12-28.5t4-31.5q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 17 4 31.5t12 28.5l-69 40Z'/></svg>")}
.i_undo{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z'/></svg>")}
.i_unfold_less{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m356-160-56-56 180-180 180 180-56 56-124-124-124 124Zm124-404L300-744l56-56 124 124 124-124 56 56-180 180Z'/></svg>")}
.i_unfold_more{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z'/></svg>")}
.i_upload{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z'/></svg>")}
.i_verified_user{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m438-338 226-226-57-57-169 169-84-84-57 57 141 141Zm42 258q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Z'/></svg>")}
.i_view_compact{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M880-170v-620 620ZM80-610v-180h170v180H80Zm210 0v-180h170v180H290Zm210 0v-180h170v180H500Zm210 0v-180h170v180H710Zm0 220v-180h170v180H710Zm-210 0v-180h170v180H500Zm-210 0v-180h170v180H290Zm-210 0v-180h170v180H80Zm630 220v-180h170v180H710Zm-210 0v-180h170v180H500Zm-210 0v-180h170v180H290Zm-210 0v-180h170v180H80Z'/></svg>")}
.i_visibility{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5Z'/></svg>")}
.i_visibility_off{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M792-56 624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM480-320q11 0 20.5-1t20.5-4L305-541q-3 11-4 20.5t-1 20.5q0 75 52.5 127.5T480-320Zm292 18L645-428q7-17 11-34.5t4-37.5q0-75-52.5-127.5T480-680q-20 0-37.5 4T408-664L306-766q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302ZM587-486 467-606q28-5 51.5 4.5T559-574q17 18 24.5 41.5T587-486Z'/></svg>")}
.i_volume_off{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M792-56 671-177q-25 16-53 27.5T560-131v-82q14-5 27.5-10t25.5-12L480-368v208L280-360H120v-240h128L56-792l56-56 736 736-56 56Zm-8-232-58-58q17-31 25.5-65t8.5-70q0-94-55-168T560-749v-82q124 28 202 125.5T840-481q0 53-14.5 102T784-288ZM650-422l-90-90v-130q47 22 73.5 66t26.5 96q0 15-2.5 29.5T650-422ZM480-592 376-696l104-104v208Z'/></svg>")}
.i_volume_up{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M560-131v-82q90-26 145-100t55-168q0-94-55-168T560-749v-82q124 28 202 125.5T840-481q0 127-78 224.5T560-131ZM120-360v-240h160l200-200v640L280-360H120Zm440 40v-322q47 22 73.5 66t26.5 96q0 51-26.5 94.5T560-320Z'/></svg>")}
.i_vpn_key{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M280-240q-100 0-170-70T40-480q0-100 70-170t170-70q81 0 141.5 45.5T506-560h414v160h-80v160H680v-160H506q-24 69-84.5 114.5T280-240Zm0-160q33 0 56.5-23.5T360-480q0-33-23.5-56.5T280-560q-33 0-56.5 23.5T200-480q0 33 23.5 56.5T280-400Z'/></svg>")}
.i_warning{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='m40-120 440-760 440 760H40Zm468.5-131.5Q520-263 520-280t-11.5-28.5Q497-320 480-320t-28.5 11.5Q440-297 440-280t11.5 28.5Q463-240 480-240t28.5-11.5ZM440-360h80v-200h-80v200Z'/></svg>")}
.i_west{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M360-200 80-480l280-280 56 56-183 184h647v80H233l184 184-57 56Z'/></svg>")}
.i_zoom_in{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Zm-40-60v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z'/></svg>")}
.i_zoom_out{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400ZM280-540v-80h200v80H280Z'/></svg>")}
+13 -22
View File
@@ -94,31 +94,22 @@ body {
accent-color: var(--accent_color); accent-color: var(--accent_color);
} }
@font-face { /* Material Symbols, used like <i class="icon i_delete"></i>. The i_ classes
font-family: 'Material Icons'; are generated into icons.css by svelte/icons.js. The glyph is a mask on a
font-style: normal; pseudo element so backgrounds and padding on the icon itself still work */
font-weight: 400;
font-display: block;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(/res/misc/MaterialIcons.woff2) format('woff2');
}
.icon { .icon {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 1.5em; font-size: 1.5em;
display: inline-block; display: inline-block;
line-height: 1em;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
text-rendering: optimizeLegibility;
vertical-align: middle; vertical-align: middle;
font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.icon::before {
content: "";
display: block;
width: 1em;
height: 1em;
background-color: currentColor;
-webkit-mask: var(--icon) center / contain no-repeat;
mask: var(--icon) center / contain no-repeat;
} }
.icon_unicode { .icon_unicode {
@@ -500,7 +491,7 @@ input[type="color"]:active {
/* Selected buttons get the accent colour on a shade of it. The outline shows /* Selected buttons get the accent colour on a shade of it. The outline shows
hover and keyboard focus, so it would be confusing to use it for this too */ hover and keyboard focus, so it would be confusing to use it for this too */
.button_highlight { .button_highlight {
color: var(--accent_color) !important; color: var(--link_color) !important;
background: var(--accent_shade) !important; background: var(--accent_shade) !important;
} }
+2 -2
View File
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/res/style/layout.css?v{{.CacheID}}"/> <link rel="stylesheet" href="/res/style/layout.css?v{{.CacheID}}"/>
<link rel="preload" href="/res/misc/MaterialIcons.woff2" as="font" type="font/woff2" crossorigin/> <link rel="stylesheet" href="/res/style/icons.css?v{{.CacheID}}"/>
<link rel="icon" href="/favicon.ico" sizes="32x32"/> <link rel="icon" href="/favicon.ico" sizes="32x32"/>
<link rel="icon" href="/res/img/nova.svg" type="image/svg+xml"/> <link rel="icon" href="/res/img/nova.svg" type="image/svg+xml"/>
@@ -36,7 +36,7 @@
{{with .Node}}window.initial_node = {{.}};{{end}} {{with .Node}}window.initial_node = {{.}};{{end}}
</script> </script>
<script src="/res/svelte/wrap.js" type="module"></script> <script src="/res/svelte/main.js" type="module"></script>
</head> </head>
<body></body> <body></body>
</html> </html>
+44
View File
@@ -0,0 +1,44 @@
// Writes the Material Symbols used in the source to icons.css. Icons are found
// by their i_<name> classes and by the icon props of Button, ToggleButton and
// TabMenu: icon="name", icon: "name" and icon={a ? "name" : "other"}. Icons
// which are already in icons.css are not downloaded again
import { globSync, readFileSync, writeFileSync } from "node:fs"
const css_file = "../res/static/style/icons.css"
const names = new Set()
for (const file of globSync(["src/**/*.svelte", "../res/template/**/*.html"])) {
const src = readFileSync(file, "utf8")
for (const [, name] of src.matchAll(/\bi_([a-z0-9_]+)/g)) {
names.add(name)
}
for (const [, prop] of src.matchAll(/\bicon(?:_on|_off)?(?:=|:\s*)("[^"]*"|\{[^}]*\})/g)) {
for (const [, name] of prop.matchAll(/"([a-z0-9_]+)"/g)) {
names.add(name)
}
}
}
const cached = new Map(
readFileSync(css_file, "utf8").matchAll(/^\.i_([a-z0-9_]+)\{.*$/gm).map(m => [m[1], m[0]])
)
const rules = await Promise.all([...names].sort().map(async name => {
if (cached.has(name)) {
return cached.get(name)
}
const url = `https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/${name}/fill1/24px.svg`
const resp = await fetch(url)
if (!resp.ok) {
throw new Error(`Icon ${name} not found: ${resp.status} ${url}`)
}
const svg = await resp.text()
const path = svg.match(/^<svg [^>]*viewBox="0 -960 960 960"[^>]*><path d="([^"]+)"\/><\/svg>$/)
if (path === null) {
throw new Error(`Icon ${name} has an unexpected format: ${svg}`)
}
return `.i_${name}{--icon:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'><path d='${path[1]}'/></svg>")}`
}))
writeFileSync(css_file, "/* Generated by svelte/icons.js */\n" + rules.join("\n") + "\n")
+2 -2
View File
@@ -3,8 +3,8 @@
"version": "1.0.0", "version": "1.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "NODE_ENV=production vite build", "build": "node icons.js && NODE_ENV=production vite build",
"dev": "NODE_ENV=development vite build --watch" "dev": "node icons.js && NODE_ENV=development vite build --watch"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-node-resolve": "^15.3.1", "@rollup/plugin-node-resolve": "^15.3.1",
+15 -10
View File
@@ -1,12 +1,17 @@
<script lang="ts"> <script lang="ts">
import { formatDate, formatNumber } from "util/Formatting"; import { formatDate, formatNumber } from "util/Formatting";
import Expandable from "util/Expandable.svelte"; import Expandable from "util/Expandable.svelte";
import { createEventDispatcher } from "svelte";
let dispatch = createEventDispatcher()
let { let {
report, report,
ip_report_count ip_report_count,
on_resolve_report,
on_resolve_by_ip,
}: {
report: any
ip_report_count: {[key: string]: number}
on_resolve_report: (action: string, report_type: string) => void
on_resolve_by_ip: (ip: string, action: string) => void
} = $props(); } = $props();
let preview = $state(false) let preview = $state(false)
@@ -14,7 +19,7 @@ let can_grant = $derived(report.status !== "granted")
let can_reject = $derived(report.status !== "rejected") let can_reject = $derived(report.status !== "rejected")
let set_status = async (action: string, report_type: string) => { let set_status = async (action: string, report_type: string) => {
dispatch("resolve_report", {action: action, report_type: report_type}) on_resolve_report(action, report_type)
} }
</script> </script>
@@ -47,19 +52,19 @@ let set_status = async (action: string, report_type: string) => {
<div class="toolbar"> <div class="toolbar">
<div class="action_list"> <div class="action_list">
<a class="button" target="_blank" href={"/u/"+report.file.id} rel="noreferrer"> <a class="button" target="_blank" href={"/u/"+report.file.id} rel="noreferrer">
<i class="icon">open_in_new</i> Open file <i class="icon i_open_in_new"></i> Open file
</a> </a>
<button class:button_highlight={preview} onclick={() => {preview = !preview}}> <button class:button_highlight={preview} onclick={() => {preview = !preview}}>
<i class="icon">visibility</i> Preview <i class="icon i_visibility"></i> Preview
</button> </button>
{#if can_grant} {#if can_grant}
<button class="button_highlight" onclick={() => {set_status("grant", report.type)}}> <button class="button_highlight" onclick={() => {set_status("grant", report.type)}}>
<i class="icon">done</i> Block ({report.type}) <i class="icon i_done"></i> Block ({report.type})
</button> </button>
{/if} {/if}
{#if can_reject} {#if can_reject}
<button class="button_red" onclick={() => {set_status("reject", "")}}> <button class="button_red" onclick={() => {set_status("reject", "")}}>
<i class="icon">delete</i> Ignore <i class="icon i_delete"></i> Ignore
</button> </button>
{/if} {/if}
</div> </div>
@@ -105,12 +110,12 @@ let set_status = async (action: string, report_type: string) => {
<td>{ip_report_count[user_report.ip_address]}</td> <td>{ip_report_count[user_report.ip_address]}</td>
<td> <td>
{#if can_grant} {#if can_grant}
<button onclick={() => dispatch("resolve_by_ip", {ip: user_report.ip_address, action: "grant"})}> <button onclick={() => on_resolve_by_ip(user_report.ip_address, "grant")}>
Accept all Accept all
</button> </button>
{/if} {/if}
{#if can_reject} {#if can_reject}
<button onclick={() => dispatch("resolve_by_ip", {ip: user_report.ip_address, action: "reject"})}> <button onclick={() => on_resolve_by_ip(user_report.ip_address, "reject")}>
Ignore all Ignore all
</button> </button>
{/if} {/if}
+5 -5
View File
@@ -168,15 +168,15 @@ onMount(() => {
<div class="tab_bar"> <div class="tab_bar">
<button onclick={() => {tab = "pending"; get_reports()}} class:button_highlight={tab === "pending"}> <button onclick={() => {tab = "pending"; get_reports()}} class:button_highlight={tab === "pending"}>
<i class="icon">flag</i> <i class="icon i_flag"></i>
Pending Pending
</button> </button>
<button onclick={() => {tab = "granted"; get_reports()}} class:button_highlight={tab === "granted"}> <button onclick={() => {tab = "granted"; get_reports()}} class:button_highlight={tab === "granted"}>
<i class="icon">flag</i> <i class="icon i_flag"></i>
Granted Granted
</button> </button>
<button onclick={() => {tab = "rejected"; get_reports()}} class:button_highlight={tab === "rejected"}> <button onclick={() => {tab = "rejected"; get_reports()}} class:button_highlight={tab === "rejected"}>
<i class="icon">flag</i> <i class="icon i_flag"></i>
Rejected Rejected
</button> </button>
</div> </div>
@@ -185,8 +185,8 @@ onMount(() => {
<AbuseReport <AbuseReport
report={report} report={report}
ip_report_count={ip_report_count} ip_report_count={ip_report_count}
on:resolve_report={e => resolve_report(report.id, e.detail.action, e.detail.report_type)} on_resolve_report={(action, report_type) => resolve_report(report.id, action, report_type)}
on:resolve_by_ip={e => resolve_by_ip(e.detail.ip, e.detail.action)} on_resolve_by_ip={resolve_by_ip}
/> />
{/each} {/each}
</section> </section>
+1 -1
View File
@@ -31,7 +31,7 @@ let block_form = {
default_value: "Anonymous", default_value: "Anonymous",
}, },
], ],
submit_label: `<i class="icon">send</i> Submit`, submit_label: `<i class="icon i_send"></i> Submit`,
on_submit: async fields => { on_submit: async fields => {
const form = new FormData() const form = new FormData()
form.append("text", fields.text) form.append("text", fields.text)
+16 -17
View File
@@ -116,7 +116,6 @@ const delete_reporter = async (reporter: Reporter) => {
const index = reporters.indexOf(reporter) const index = reporters.indexOf(reporter)
if (index > -1) { if (index > -1) {
reporters.splice(index, 1) reporters.splice(index, 1)
reporters = reporters
} }
try { try {
@@ -140,11 +139,11 @@ onMount(get_reporters);
<section> <section>
<div class="toolbar" style="text-align: left;"> <div class="toolbar" style="text-align: left;">
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<button onclick={() => get_reporters()}> <button onclick={() => get_reporters()} title="Refresh">
<i class="icon">refresh</i> <i class="icon i_refresh"></i>
</button> </button>
<button bind:this={edit_button} class:button_highlight={creating} onclick={() => {creating = !creating}}> <button bind:this={edit_button} class:button_highlight={creating} onclick={() => {creating = !creating}}>
<i class="icon">create</i> Add abuse reporter <i class="icon i_create"></i> Add abuse reporter
</button> </button>
</div> </div>
{#if creating} {#if creating}
@@ -164,7 +163,7 @@ onMount(get_reporters);
<label for="reporter_status_2">Rejected</label> <label for="reporter_status_2">Rejected</label>
</div> </div>
<button class="button_highlight" type="submit"> <button class="button_highlight" type="submit">
<i class="icon">save</i> Save <i class="icon i_save"></i> Save
</button> </button>
</div> </div>
</form> </form>
@@ -175,29 +174,29 @@ onMount(get_reporters);
<h2>Pending reporters ({reporters_pending.length})</h2> <h2>Pending reporters ({reporters_pending.length})</h2>
<EmailReportersTable <EmailReportersTable
reporters={reporters_pending} reporters={reporters_pending}
on:edit={e => edit_reporter(e.detail)} on_edit={edit_reporter}
on:approve={e => approve_reporter(e.detail)} on_approve={approve_reporter}
on:spam={e => spam_reporter(e.detail)} on_spam={spam_reporter}
on:delete={e => delete_reporter(e.detail)}> on_delete={delete_reporter}>
</EmailReportersTable> </EmailReportersTable>
<h2>Trusted reporters ({reporters_trusted.length})</h2> <h2>Trusted reporters ({reporters_trusted.length})</h2>
<EmailReportersTable <EmailReportersTable
reporters={reporters_trusted} reporters={reporters_trusted}
on:edit={e => edit_reporter(e.detail)} on_edit={edit_reporter}
on:approve={e => approve_reporter(e.detail)} on_approve={approve_reporter}
on:spam={e => spam_reporter(e.detail)} on_spam={spam_reporter}
on:delete={e => delete_reporter(e.detail)}> on_delete={delete_reporter}>
</EmailReportersTable> </EmailReportersTable>
<h2>Rejected reporters ({reporters_rejected.length})</h2> <h2>Rejected reporters ({reporters_rejected.length})</h2>
<EmailReportersTable <EmailReportersTable
reporters={reporters_rejected} reporters={reporters_rejected}
on:edit={e => edit_reporter(e.detail)} on_edit={edit_reporter}
on:approve={e => approve_reporter(e.detail)} on_approve={approve_reporter}
on:spam={e => spam_reporter(e.detail)} on_spam={spam_reporter}
on:delete={e => delete_reporter(e.detail)}> on_delete={delete_reporter}>
</EmailReportersTable> </EmailReportersTable>
<br/> <br/>
@@ -1,44 +1,42 @@
<script lang="ts"> <script lang="ts">
import { run, preventDefault } from 'svelte/legacy';
import { createEventDispatcher } from "svelte";
import { formatDate } from "util/Formatting"; import { formatDate } from "util/Formatting";
import Modal from "util/Modal.svelte" import Modal from "util/Modal.svelte"
import SortButton from "layout/SortButton.svelte"; import SortButton from "layout/SortButton.svelte";
import { flip } from "svelte/animate"; import { flip } from "svelte/animate";
const dispatch = createEventDispatcher() let { reporters = [], on_edit, on_approve, on_spam, on_delete }: {
reporters?: any[];
let { reporters = $bindable([]) } = $props(); on_edit: (reporter: any) => void;
on_approve: (reporter: any) => void;
const update_table = (reporters) => sort("") on_spam: (reporter: any) => void;
on_delete: (reporter: any) => void;
} = $props();
let sort_field = $state("last_used") let sort_field = $state("last_used")
let asc = $state(false) let asc = $state(false)
const sort = (field) => { const sort = (field: string) => {
if (field !== "" && field === sort_field) asc = !asc if (field === sort_field) asc = !asc
if (field === "") field = sort_field
sort_field = field sort_field = field
console.log("sorting by", field, "asc", asc) console.log("sorting by", field, "asc", asc)
reporters.sort((a, b) => { }
if (typeof (a[field]) === "number") {
let sorted = $derived([...reporters].sort((a, b) => {
if (typeof (a[sort_field]) === "number") {
// Sort ints from high to low // Sort ints from high to low
if (asc) { if (asc) {
return a[field] - b[field] return a[sort_field] - b[sort_field]
} else { } else {
return b[field] - a[field] return b[sort_field] - a[sort_field]
} }
} else { } else {
// Sort strings alphabetically // Sort strings alphabetically
if (asc) { if (asc) {
return a[field].localeCompare(b[field]) return a[sort_field].localeCompare(b[sort_field])
} else { } else {
return b[field].localeCompare(a[field]) return b[sort_field].localeCompare(a[sort_field])
} }
} }
}) }))
reporters = reporters
}
let modal: Modal = $state() let modal: Modal = $state()
let preview_subject = $state("") let preview_subject = $state("")
@@ -50,9 +48,6 @@ const toggle_preview = (rep) => {
preview_html = rep.last_message_html preview_html = rep.last_message_html
modal.show() modal.show()
} }
run(() => {
update_table(reporters)
});
</script> </script>
<div class="table_scroll"> <div class="table_scroll">
@@ -69,7 +64,7 @@ run(() => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each reporters as rep (rep.from_address)} {#each sorted as rep (rep.from_address)}
<tr animate:flip={{duration: 500}}> <tr animate:flip={{duration: 500}}>
<td>{rep.from_address}</td> <td>{rep.from_address}</td>
<td>{rep.name}</td> <td>{rep.name}</td>
@@ -78,24 +73,24 @@ run(() => {
<td>{formatDate(rep.last_used, true, true, false)}</td> <td>{formatDate(rep.last_used, true, true, false)}</td>
<td>{formatDate(rep.created, false, false, false)}</td> <td>{formatDate(rep.created, false, false, false)}</td>
<td> <td>
<button onclick={preventDefault(() => toggle_preview(rep))} class="button round"> <button onclick={e => {e.preventDefault(); toggle_preview(rep)}} class="button round" title="Show last message">
<i class="icon">email</i> <i class="icon i_email"></i>
</button> </button>
<button onclick={preventDefault(() => {dispatch("edit", rep)})} class="button round"> <button onclick={e => {e.preventDefault(); on_edit(rep)}} class="button round" title="Edit">
<i class="icon">edit</i> <i class="icon i_edit"></i>
</button> </button>
{#if rep.status !== "trusted"} {#if rep.status !== "trusted"}
<button onclick={preventDefault(() => {dispatch("approve", rep)})} class="button button_highlight round"> <button onclick={e => {e.preventDefault(); on_approve(rep)}} class="button button_highlight round" title="Trust">
<i class="icon">check</i> <i class="icon i_check"></i>
</button> </button>
{/if} {/if}
{#if rep.status !== "rejected"} {#if rep.status !== "rejected"}
<button onclick={preventDefault(() => {dispatch("spam", rep)})} class="button button_red round"> <button onclick={e => {e.preventDefault(); on_spam(rep)}} class="button button_red round" title="Reject">
<i class="icon">block</i> <i class="icon i_block"></i>
</button> </button>
{/if} {/if}
<button onclick={preventDefault(() => {dispatch("delete", rep)})} class="button button_red round"> <button onclick={e => {e.preventDefault(); on_delete(rep)}} class="button button_red round" title="Delete">
<i class="icon">delete</i> <i class="icon i_delete"></i>
</button> </button>
</td> </td>
</tr> </tr>
+1 -1
View File
@@ -49,7 +49,7 @@ const date = (d: string) => (!d || d.startsWith("0001-")) ? "never" : formatDate
<label for="hash_input">File hash (hex sha256)</label> <label for="hash_input">File hash (hex sha256)</label>
<input id="hash_input" bind:value={hash} onclick={e => e.currentTarget.select()}/> <input id="hash_input" bind:value={hash} onclick={e => e.currentTarget.select()}/>
<button type="submit" disabled={loading}> <button type="submit" disabled={loading}>
<i class="icon">search</i> Look up <i class="icon i_search"></i> Look up
</button> </button>
</form> </form>
+2 -2
View File
@@ -285,11 +285,11 @@ onMount(() => {
<h3>Cache nodes</h3> <h3>Cache nodes</h3>
</section> </section>
<PeerTable peers={status.peers.reduce((acc, val) => {if (val.role === "cache") {acc.push(val)}; return acc}, [])}/> <PeerTable peers={status.peers.filter(peer => peer.services?.includes("cache"))}/>
<section> <section>
<h3>Storage nodes</h3> <h3>Storage nodes</h3>
</section> </section>
<PeerTable peers={status.peers.reduce((acc, val) => {if (val.role === "storage") {acc.push(val)}; return acc}, [])}/> <PeerTable peers={status.peers.filter(peer => peer.services?.includes("storage"))}/>
<section> <section>
<h3>Query statistics</h3> <h3>Query statistics</h3>
@@ -55,6 +55,8 @@ const groups: {
data_type: "duration", data_type: "duration",
}, },
{metric: "filesystem_index_walk_child", data_type: "number"}, {metric: "filesystem_index_walk_child", data_type: "number"},
{metric: "s3_request", data_type: "number"},
{metric: "s3_error_500", data_type: "number"},
] ]
}, { }, {
title: "Task scheduler", expanded: false, title: "Task scheduler", expanded: false,
+2 -2
View File
@@ -161,13 +161,13 @@ let invoices_filtered: Invoice[] = $state([])
<h3>{year + "-" + ("00"+(month)).slice(-2)}</h3> <h3>{year + "-" + ("00"+(month)).slice(-2)}</h3>
<div class="toolbar"> <div class="toolbar">
<button onclick={last_month}> <button onclick={last_month}>
<i class="icon">chevron_left</i> <i class="icon i_chevron_left"></i>
Previous month Previous month
</button> </button>
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<button onclick={next_month}> <button onclick={next_month}>
Next month Next month
<i class="icon">chevron_right</i> <i class="icon i_chevron_right"></i>
</button> </button>
</div> </div>
@@ -8,7 +8,7 @@ import { loading_finish, loading_start } from "lib/Loading";
let { settlement = {} } = $props(); let { settlement = {} } = $props();
let payments = $state([]) let payments = $state([])
let per_country = $state({}) let per_country: {[country: string]: any} = $state({})
let totals = $state({ let totals = $state({
count: 0, count: 0,
vat: 0, vat: 0,
@@ -79,7 +79,7 @@ const get_payments = async () => {
{} {}
) )
console.log(per_country) console.log($state.snapshot(per_country))
} catch (err) { } catch (err) {
alert(err); alert(err);
} finally { } finally {
+2 -2
View File
@@ -115,8 +115,8 @@ const decommission = (id: string) => {
<td>{formatDataVolume(peer.min_free_space, 3)}</td> <td>{formatDataVolume(peer.min_free_space, 3)}</td>
{#if !all_reachable} {#if !all_reachable}
<td> <td>
<button class="button flat delete" onclick={() => decommission(peer.id)}> <button class="button flat delete" onclick={() => decommission(peer.id)} title="Decommission">
<i class="icon small">delete</i> <i class="icon small i_delete"></i>
</button> </button>
</td> </td>
{/if} {/if}
+1 -1
View File
@@ -67,7 +67,7 @@ let pages = [
}, { }, {
path: "/admin/paypal_taxes", path: "/admin/paypal_taxes",
title: "Paypal Taxes", title: "Paypal Taxes",
icon: "paypal", icon: "payments",
component: PayPalTaxes, component: PayPalTaxes,
}, { }, {
path: "/admin/invoices", path: "/admin/invoices",
+2 -2
View File
@@ -26,7 +26,7 @@ let credit_form = {
default_value: 0, default_value: 0,
}, },
], ],
submit_label: `<i class="icon">send</i> Submit`, submit_label: `<i class="icon i_send"></i> Submit`,
on_submit: async fields => { on_submit: async fields => {
const form = new FormData() const form = new FormData()
form.append("id", fields.user_id) form.append("id", fields.user_id)
@@ -71,7 +71,7 @@ let impersonate_form = {
default_value: "", default_value: "",
}, },
], ],
submit_label: `<i class="icon">send</i> Submit`, submit_label: `<i class="icon i_send"></i> Submit`,
on_submit: async fields => { on_submit: async fields => {
const form = new FormData() const form = new FormData()
form.append("id", fields.user_id) form.append("id", fields.user_id)
@@ -1,5 +1,4 @@
<script> <script>
import { stopPropagation } from 'svelte/legacy';
import { onMount } from "svelte"; import { onMount } from "svelte";
import { formatDate } from "util/Formatting"; import { formatDate } from "util/Formatting";
import Expandable from "util/Expandable.svelte"; import Expandable from "util/Expandable.svelte";
@@ -116,9 +115,9 @@ onMount(get_bans);
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<button class:button_highlight={expanded} onclick={() => {expanded = !expanded}}> <button class:button_highlight={expanded} onclick={() => {expanded = !expanded}}>
{#if expanded} {#if expanded}
<i class="icon">unfold_less</i> Collapse all <i class="icon i_unfold_less"></i> Collapse all
{:else} {:else}
<i class="icon">unfold_more</i> Expand all <i class="icon i_unfold_more"></i> Expand all
{/if} {/if}
</button> </button>
</div> </div>
@@ -142,8 +141,8 @@ onMount(get_bans);
Date<br/> Date<br/>
{formatDate(row.offences[0].ban_time, false, false, false)} {formatDate(row.offences[0].ban_time, false, false, false)}
</div> </div>
<button onclick={stopPropagation(() => {delete_ban(row.user_id)})} class="button button_red" style="align-self: center;"> <button onclick={e => {e.stopPropagation(); delete_ban(row.user_id)}} class="button button_red" style="align-self: center;" title="Delete ban">
<i class="icon">delete</i> <i class="icon i_delete"></i>
</button> </button>
</div> </div>
{/snippet} {/snippet}
@@ -152,7 +151,7 @@ onMount(get_bans);
<Button click={() => impersonate(row.user_id)} icon="login" label="Impersonate user"/> <Button click={() => impersonate(row.user_id)} icon="login" label="Impersonate user"/>
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<div class="toolbar_label"> <div class="toolbar_label">
<i class="icon">block</i> Block all files <i class="icon i_block"></i> Block all files
<select bind:value={row.select_abuse_type}> <select bind:value={row.select_abuse_type}>
<option>copyright</option> <option>copyright</option>
<option>child_abuse</option> <option>child_abuse</option>
+5 -4
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { fs_encode_path } from "lib/FilesystemAPI.svelte"; import { fs_encode_path } from "lib/FilesystemAPI.svelte";
import { path_link, type FSNavigator } from "./FSNavigator"; import { move_target, path_link, type FSNavigator } from "./FSNavigator";
import FileMenu from "./filemanager/FileMenu.svelte"; import FileMenu from "./filemanager/FileMenu.svelte";
import EditWindow from "./edit_window/EditWindow.svelte"; import EditWindow from "./edit_window/EditWindow.svelte";
import { onMount } from "svelte"; import { onMount } from "svelte";
@@ -29,19 +29,20 @@ onMount(() => {
href={"/d"+fs_encode_path(node.path)} href={"/d"+fs_encode_path(node.path)}
class="breadcrumb button flat" class="breadcrumb button flat"
use:path_link={{nav: nav, node: node}} use:path_link={{nav: nav, node: node}}
use:move_target={{nav, node: () => node}}
oncontextmenu={e => file_menu.open(node, e.target, e)} oncontextmenu={e => file_menu.open(node, e.target, e)}
> >
{#if node.abuse_type !== undefined} {#if node.abuse_type !== undefined}
<i class="icon small">block</i> <i class="icon small i_block"></i>
{:else if node.is_shared()} {:else if node.is_shared()}
<i class="icon small">share</i> <i class="icon small i_share"></i>
{/if} {/if}
<div class="node_name" class:base={$nav.base_index === i} class:small={$nav.path.length > 10}> <div class="node_name" class:base={$nav.base_index === i} class:small={$nav.path.length > 10}>
{node.name} {node.name}
</div> </div>
</a> </a>
{#if $nav.base_index !== i} {#if $nav.base_index !== i}
<i class="icon">chevron_right</i> <i class="icon i_chevron_right"></i>
{/if} {/if}
{/each} {/each}
+7 -5
View File
@@ -6,6 +6,7 @@ import { fs_path_url, fs_share_hotlink_url, fs_share_url, fs_timeseries, type FS
import { color_by_name } from "util/Util"; import { color_by_name } from "util/Util";
import CopyButton from "layout/CopyButton.svelte"; import CopyButton from "layout/CopyButton.svelte";
import type { FSNavigator } from "./FSNavigator"; import type { FSNavigator } from "./FSNavigator";
import { untrack } from "svelte";
let { let {
nav, nav,
@@ -19,9 +20,12 @@ export const toggle = () => visible = !visible
$effect(() => { $effect(() => {
// Only update the chart if the details modal is open. Else the chart is // Only update the chart if the details modal is open. Else the chart is
// rendered for nothing // rendered for nothing. The chart is not there until it's downloaded,
if (visible) { // reading it here makes this run again when it's ready. The timespan is not
update_chart($nav.base, chart_timespan, chart_interval) // a dependency, update_chart sets it and that would fetch the data twice
if (visible && chart) {
const base = $nav.base
untrack(() => update_chart(base, chart_timespan, chart_interval))
} }
}) })
@@ -42,8 +46,6 @@ let total_downloads = $state(0)
let total_egress = $state(0) let total_egress = $state(0)
let update_chart = async (base: FSNode, timespan: number, interval: number) => { let update_chart = async (base: FSNode, timespan: number, interval: number) => {
// The chart is not there until it's downloaded. The $effect above reads it
// through this function, so it calls this function again when it's ready
if (!visible || base.type !== "file" || !chart) { if (!visible || base.type !== "file" || !chart) {
return return
} }
+28
View File
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import TextBlock from "layout/TextBlock.svelte"; import TextBlock from "layout/TextBlock.svelte";
import Button from "layout/Button.svelte";
import { type FSNavigator } from "./FSNavigator"; import { type FSNavigator } from "./FSNavigator";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { breadcrumbs_store } from "wrap/HeaderStore"; import { breadcrumbs_store } from "wrap/HeaderStore";
@@ -17,6 +18,16 @@ onMount(() => {
}) })
let password = $state("")
let wrong_password = $state(false)
const submit_password = async (e: SubmitEvent) => {
e.preventDefault()
await nav.navigate(nav.last_requested_path, false, password)
// This page is gone if the password was right
wrong_password = true
}
</script> </script>
{#snippet breadcrumbs()} {#snippet breadcrumbs()}
@@ -29,6 +40,23 @@ onMount(() => {
<p> <p>
This page could not be found. This page could not be found.
</p> </p>
{:else if $nav.navigation_error === "password_required"}
<h1>Password required</h1>
<p>
This directory is protected with a password.
</p>
<form onsubmit={submit_password}>
<!-- Password managers take the directory for the username. Without
this they fill in the password of the visitor's Nova account. The
hidden attribute does not work, the stylesheet overrides it -->
<input type="text" autocomplete="username" value={$nav.last_requested_path.split("/")[1]} style="display: none;">
<!-- svelte-ignore a11y_autofocus -->
<input type="password" bind:value={password} placeholder="Password" required autofocus>
<Button type="submit" icon="lock_open" label="Open"/>
</form>
{#if wrong_password}
<p>This password is not correct.</p>
{/if}
{:else if $nav.navigation_error === "permission_denied" || $nav.navigation_error === "forbidden"} {:else if $nav.navigation_error === "permission_denied" || $nav.navigation_error === "forbidden"}
<h1>Permission denied</h1> <h1>Permission denied</h1>
<p> <p>
+169 -6
View File
@@ -1,5 +1,5 @@
import { loading_finish, loading_start } from "lib/Loading"; import { loading_finish, loading_run, loading_start } from "lib/Loading";
import { fs_get_node, fs_encode_path, fs_split_path, fs_path_from_json } from "lib/FilesystemAPI.svelte"; import { fs_get_node, fs_encode_path, fs_split_path, fs_path_from_json, fs_path_url, fs_rename } from "lib/FilesystemAPI.svelte";
import type { FSNode, FSPath, FSPermissions, FSContext } from "lib/FilesystemAPI.svelte"; import type { FSNode, FSPath, FSPermissions, FSContext } from "lib/FilesystemAPI.svelte";
export class FSNavigator { export class FSNavigator {
@@ -16,6 +16,10 @@ export class FSNavigator {
// Initialized will be set to true when the first file or directory is loaded // Initialized will be set to true when the first file or directory is loaded
initialized = false initialized = false
shuffle = false shuffle = false
toggle_shuffle = () => {
this.shuffle = !this.shuffle
this.notify_subscribers()
}
// Whether navigation events should update the browser history // Whether navigation events should update the browser history
history_enabled = true history_enabled = true
@@ -45,8 +49,8 @@ export class FSNavigator {
last_requested_path: string = "" last_requested_path: string = ""
navigation_error: string = "" navigation_error: string = ""
navigate = async (path: string, push_history: boolean) => { navigate = async (path: string, push_history: boolean, password?: string) => {
if (path === this.last_requested_path) { if (path === this.last_requested_path && password === undefined) {
console.debug("FSNavigator: Requested path ", path, " is equal to current path. Debouncing") console.debug("FSNavigator: Requested path ", path, " is equal to current path. Debouncing")
return return
} }
@@ -56,6 +60,18 @@ export class FSNavigator {
path = "/" + path path = "/" + path
} }
// The password of a shared directory is entered by the visitor, or it's
// in the link they opened. It's sent in a cookie, which is the only way
// to get it into the requests for images, videos and downloads. The
// cookie's path is the directory, so each directory has its own password
if (password === undefined && this.history_enabled) {
password = new URLSearchParams(window.location.search).get("password")
}
if (password) {
document.cookie = "nova_fs_password=" + encodeURIComponent(password) +
"; path=" + fs_path_url(path.split("/")[1]) + "; samesite=lax"
}
console.debug("FSNavigator: Navigating to path", path, push_history) console.debug("FSNavigator: Navigating to path", path, push_history)
try { try {
@@ -70,9 +86,9 @@ export class FSNavigator {
this.open_node(resp, push_history) this.open_node(resp, push_history)
} catch (err: any) { } catch (err: any) {
if (err.value !== undefined && err.value === "path_not_found") { if (err.value !== undefined && err.value === "path_not_found") {
if (path !== this.path[0].path && path !== "/" && path !== "") { if (path !== this.path[0]?.path && path !== "/" && path !== "") {
console.debug("Path", path, "was not found, trying to navigate to parent") console.debug("Path", path, "was not found, trying to navigate to parent")
this.navigate(fs_split_path(path).parent, push_history) this.navigate(fs_split_path(path).parent, push_history, password)
} }
} else if (err.value !== undefined) { } else if (err.value !== undefined) {
this.navigation_error = err.value this.navigation_error = err.value
@@ -251,6 +267,105 @@ export class FSNavigator {
// the reactivity // the reactivity
this.notify_subscribers() this.notify_subscribers()
} }
// The selection is kept by path, so it survives reloads and navigating to
// other directories. The directory views look each entry up in it
selecting = false
selection = new Map<string, FSNode>()
last_selected = ""
// Leaving selection mode clears the selection
set_selecting = (on: boolean) => {
this.selecting = on
if (!on) {
this.selection.clear()
}
this.notify_subscribers()
}
// Toggles a node. With range, everything between it and the node which was
// toggled before it is selected. Hidden nodes are left out of the range when
// the view doesn't show them
select = (node: FSNode, range = false, hidden = true) => {
const from = range ? this.children.findIndex(c => c.path === this.last_selected) : -1
if (from !== -1) {
const to = this.children.indexOf(node)
for (let i = Math.min(from, to); i <= Math.max(from, to); i++) {
if (hidden || !this.children[i].is_hidden()) {
this.selection.set(this.children[i].path, this.children[i])
}
}
} else if (!this.selection.delete(node.path)) {
this.selection.set(node.path, node)
}
this.last_selected = node.path
this.set_selecting(true)
}
// Downloads the selection, or the open node if nothing is selected. More
// than one node is zipped by the closest directory which they are all in
download = () => {
const nodes = [...this.selection.values()]
if (nodes.length < 2) {
return (nodes[0] ?? this.base).download()
}
let dir = nodes[0].path
do {
dir = dir.slice(0, dir.lastIndexOf("/"))
} while (!nodes.every(n => n.path.startsWith(dir + "/")))
const a = document.createElement("a")
a.href = fs_path_url(dir) + "?bulk_download&" + new URLSearchParams(
nodes.map(n => ["include", n.path.slice(dir.length + 1)])
)
a.download = ""
a.dispatchEvent(new MouseEvent("click"))
}
// A directory can't be moved into itself, and there has to be at least one
// node which is not in dir already
can_move = (dir: string) => {
let moves = false
for (const node of this.selection.values()) {
if ((dir + "/").startsWith(node.path + "/")) {
return false
}
moves ||= node.path !== dir + "/" + node.name
}
return moves
}
move_selection = async (dir: string) => {
try {
await loading_run(() => Promise.all(
[...this.selection.values()]
.filter(node => node.path !== dir + "/" + node.name)
.map(node => fs_rename(node.path, dir + "/" + node.name))
))
} catch (err: any) {
console.error(err)
alert("Move failed: " + err.message + " (" + err.value + ")")
}
this.set_selecting(false)
await this.reload()
}
// Dragging a node drags the whole selection. The drag itself only carries a
// marker, as the selection outlives the element which is being dragged when
// the user navigates during the drag
drag_start = (e: DragEvent, node: FSNode) => {
e.dataTransfer.setData(drag_type, node.path)
e.dataTransfer.effectAllowed = "move"
if (!this.selecting) {
// The drag started the selection, so it ends it as well
e.target.addEventListener("dragend", () => this.set_selecting(false), { once: true })
}
if (!this.selection.has(node.path)) {
this.select(node)
}
}
} }
const sort_children = (children: FSNode[], field: string, asc: boolean) => { const sort_children = (children: FSNode[], field: string, asc: boolean) => {
@@ -287,7 +402,55 @@ const sort_children = (children: FSNode[], field: string, asc: boolean) => {
export let global_navigator = new FSNavigator(true) export let global_navigator = new FSNavigator(true)
const drag_type = "application/x-nova-selection"
const is_drag = (e: DragEvent) => e.dataTransfer.types.includes(drag_type)
// Moves the selection into a directory when it's dropped on the element. The
// node is a function because an action only gets its parameters once. Bookmarks
// have no type, the server refuses the move if one turns out to be a file
export const move_target = (
el: HTMLElement,
data: { nav: FSNavigator, node: () => { path: string, type?: string } },
) => {
const accepts = (e: DragEvent) => {
if (!is_drag(e) || data.node().type === "file" || !data.nav.can_move(data.node().path)) {
return false
}
e.preventDefault()
e.stopPropagation()
return true
}
el.addEventListener("dragover", e => {
if (accepts(e)) {
el.style.boxShadow = "var(--accent_color) 0 0 0 2px inset"
}
})
el.addEventListener("dragleave", () => el.style.boxShadow = "")
el.addEventListener("drop", e => {
el.style.boxShadow = ""
if (accepts(e)) {
data.nav.move_selection(data.node().path)
}
})
}
// Clicks the element when the selection is held over it, so the navigation
// buttons work during a drag
export const drag_click = (el: HTMLElement) => {
let timer: number
el.addEventListener("dragenter", e => {
if (is_drag(e)) {
clearTimeout(timer)
timer = window.setTimeout(() => el.click(), 500)
}
})
el.addEventListener("dragleave", e => {
// Moving onto a child of the element is not leaving it
if (!el.contains(e.relatedTarget as Node)) {
clearTimeout(timer)
}
})
}
export const path_link = (node: HTMLAnchorElement, data: { nav: FSNavigator, node: FSNode }) => { export const path_link = (node: HTMLAnchorElement, data: { nav: FSNavigator, node: FSNode }) => {
// Set url // Set url
+3 -3
View File
@@ -115,11 +115,11 @@ const toggle_expand_keyboard = (e: KeyboardEvent) => {
</script> </script>
<div class="container" onclick={toggle_expand} onkeypress={toggle_expand_keyboard} role="presentation"> <div class="container" onclick={toggle_expand} onkeypress={toggle_expand_keyboard} role="presentation">
<button class="button_expand hidden_vertical" onclick={toggle_expand}> <button class="button_expand hidden_vertical" onclick={toggle_expand} title={expanded ? "Collapse" : "Expand"}>
{#if expanded} {#if expanded}
<i class="icon">expand_more</i> <i class="icon i_expand_more"></i>
{:else} {:else}
<i class="icon">expand_less</i> <i class="icon i_expand_less"></i>
{/if} {/if}
</button> </button>
+7 -28
View File
@@ -5,23 +5,19 @@ import Toolbar from "./Toolbar.svelte";
import Breadcrumbs from "./Breadcrumbs.svelte"; import Breadcrumbs from "./Breadcrumbs.svelte";
import DetailsWindow from "./DetailsWindow.svelte"; import DetailsWindow from "./DetailsWindow.svelte";
import FilePreview from "./viewers/FilePreview.svelte"; import FilePreview from "./viewers/FilePreview.svelte";
import FSUploadWidget from "./upload_widget/FSUploadWidget.svelte";
import { global_navigator } from "./FSNavigator" import { global_navigator } from "./FSNavigator"
import { css_from_path } from "filesystem/edit_window/Branding"; import { css_from_path } from "filesystem/edit_window/Branding";
import { update_favicon } from "util/NovaLogo.svelte"; import { update_favicon } from "util/NovaLogo.svelte";
import AffiliatePrompt from "user_home/AffiliatePrompt.svelte"; import AffiliatePrompt from "user_home/AffiliatePrompt.svelte";
import { current_page_store } from "wrap/RouterStore"; import { current_page_store } from "wrap/RouterStore";
import SearchBar from "./SearchBar.svelte";
import ErrorPage from "./ErrorPage.svelte"; import ErrorPage from "./ErrorPage.svelte";
let file_preview: FilePreview = $state() let file_preview: FilePreview = $state()
let toolbar: Toolbar = $state() let toolbar: Toolbar = $state()
let upload_widget: FSUploadWidget = $state()
let details_visible = $state(false) let details_visible = $state(false)
let edit_window: EditWindow = $state() let edit_window: EditWindow = $state()
let edit_visible = $state(false) let edit_visible = $state(false)
let details_window: DetailsWindow = $state() let details_window: DetailsWindow = $state()
let search_bar: SearchBar = $state()
const nav = global_navigator const nav = global_navigator
@@ -42,10 +38,10 @@ onMount(() => {
return return
} }
// Custom CSS rules for the whole viewer. The MainMenu applies its // Custom CSS rules for the whole viewer. App.svelte applies its styles
// styles to the <html> element. So we apply to the <body> element, our // to the <html> element. So we apply to the <body> element, our styles
// styles take precedence since they're lower level, and we can clean it // take precedence since they're lower level, and we can clean it up
// up afterwards without overwriting global style // afterwards without overwriting global style
document.body.style = css_from_path(nav.path) document.body.style = css_from_path(nav.path)
update_favicon() update_favicon()
}) })
@@ -60,13 +56,7 @@ onMount(() => {
const keydown = (e: KeyboardEvent) => { const keydown = (e: KeyboardEvent) => {
if (e.ctrlKey || e.altKey || e.metaKey) { if (e.ctrlKey || e.altKey || e.metaKey) {
return // prevent custom shortcuts from interfering with system shortcuts return // prevent custom shortcuts from interfering with system shortcuts
} else if ( } else if (["text", "password", "textarea"].includes((document.activeElement as any).type)) {
(document.activeElement as any).type !== undefined &&
(
(document.activeElement as any).type === "text" ||
(document.activeElement as any).type === "textarea"
)
) {
return // Prevent shortcuts from interfering with input fields return // Prevent shortcuts from interfering with input fields
} }
@@ -86,13 +76,10 @@ const keydown = (e: KeyboardEvent) => {
} }
break; break;
case "s": case "s":
nav.base.download() nav.download()
break; break;
case "r": case "r":
nav.shuffle = !nav.shuffle nav.toggle_shuffle()
break;
case "/":
search_bar.open()
break; break;
case "a": case "a":
case "ArrowLeft": case "ArrowLeft":
@@ -153,10 +140,8 @@ const keydown = (e: KeyboardEvent) => {
<FilePreview <FilePreview
bind:this={file_preview} bind:this={file_preview}
nav={nav} nav={nav}
upload_widget={upload_widget}
edit_window={edit_window} edit_window={edit_window}
details_window={details_window} details_window={details_window}
search_bar={search_bar}
/> />
</div> </div>
@@ -173,16 +158,10 @@ const keydown = (e: KeyboardEvent) => {
<ErrorPage nav={nav} /> <ErrorPage nav={nav} />
{/if} {/if}
<SearchBar bind:this={search_bar} nav={nav}/>
<DetailsWindow nav={nav} bind:this={details_window} bind:visible={details_visible} /> <DetailsWindow nav={nav} bind:this={details_window} bind:visible={details_visible} />
<EditWindow nav={nav} bind:this={edit_window} bind:visible={edit_visible} /> <EditWindow nav={nav} bind:this={edit_window} bind:visible={edit_visible} />
<!-- This one is included at the highest level so uploads can keep running
even when the user navigates to a different directory -->
<FSUploadWidget nav={nav} bind:this={upload_widget} />
<AffiliatePrompt/> <AffiliatePrompt/>
<style> <style>
+35 -22
View File
@@ -1,13 +1,17 @@
<script lang="ts" module>
// The search bar is mounted once, in App.svelte. It sets this function when it
// mounts, so that other components can open it
export let open_search: () => void
</script>
<script lang="ts"> <script lang="ts">
import { onMount, tick } from "svelte"; import { onMount, tick } from "svelte";
import { fs_search, fs_encode_path, fs_thumbnail_url, FSNode } from "lib/FilesystemAPI.svelte"; import { fs_search, fs_encode_path, fs_thumbnail_url, FSNode } from "lib/FilesystemAPI.svelte";
import type { FSNavigator } from "filesystem/FSNavigator"; import { global_navigator as nav } from "filesystem/FSNavigator";
import { loading_finish, loading_start } from "lib/Loading"; import { loading_finish, loading_start } from "lib/Loading";
import { user } from "lib/UserStore";
import Modal from "util/Modal.svelte"; import Modal from "util/Modal.svelte";
import { navigate } from "wrap/Router.svelte";
let { nav }: {
nav: FSNavigator;
} = $props();
let modal: Modal let modal: Modal
let search_bar: HTMLInputElement = $state() let search_bar: HTMLInputElement = $state()
@@ -32,8 +36,23 @@ onMount(() => {
}) })
}) })
export const open = async () => { // The path of the directory to search. Outside of the filesystem page the
search_prefix_node = nav.base // navigator is stale or empty, there it's the home directory of the user.
// Visitors who are not logged in don't have one, then the path is empty
const search_path = (): FSNode[] => {
if (nav.initialized && window.location.pathname.startsWith("/d/")) {
// If the base is not a directory, we use the parent
return nav.base.type === "dir" ? nav.path : nav.path.slice(0, -1)
}
return $user === null ? [] : [{name: $user.username, path: "/me"} as FSNode]
}
open_search = async () => {
const path = search_path()
if (path.length === 0) {
return
}
search_prefix_node = path[path.length-1]
modal.show() modal.show()
await tick() await tick()
search_bar.focus() search_bar.focus()
@@ -62,18 +81,14 @@ const search = async (limit = 10) => {
try { try {
loading_start() loading_start()
let search_node = nav.base const path = search_path()
// If the base is not a directory, we use the parent let search_node = path[path.length-1]
if (search_node.type !== "dir") {
search_node = nav.path[nav.path.length-2]
}
let search_results_tmp = await fs_search(search_node.path, search_term, limit) let search_results_tmp = await fs_search(search_node.path, search_term, limit)
// If there are no results, and we are not searching the filesystem // If there are no results, and we are not searching the filesystem
// root, we will search the filesystem root // root, we will search the filesystem root
if (search_results_tmp.length === 0 && search_node.path != nav.path[0].path) { if (search_results_tmp.length === 0 && path.length > 1) {
search_node = nav.path[0] search_node = path[0]
search_results_tmp = await fs_search(search_node.path, search_term, limit) search_results_tmp = await fs_search(search_node.path, search_term, limit)
} }
@@ -158,14 +173,14 @@ const open_result = (index: number, e?: MouseEvent) => {
if (e !== undefined) { if (e !== undefined) {
e.preventDefault() e.preventDefault()
} }
nav.navigate(search_results[index], true) navigate("/d" + fs_encode_path(search_results[index]))
clear_search(false) clear_search(false)
} }
const window_keydown = (e: KeyboardEvent) => { const window_keydown = (e: KeyboardEvent) => {
if (e.ctrlKey || e.altKey || e.metaKey) { if (e.ctrlKey || e.altKey || e.metaKey) {
return // prevent custom shortcuts from interfering with system shortcuts return // prevent custom shortcuts from interfering with system shortcuts
} else if ((document.activeElement as any).type !== undefined && (document.activeElement as any).type === "text") { } else if (document.activeElement.matches("input, textarea, select")) {
return // Prevent shortcuts from interfering with input fields return // Prevent shortcuts from interfering with input fields
} }
@@ -175,9 +190,7 @@ const window_keydown = (e: KeyboardEvent) => {
} else if (e.key === "/" || e.key === "f") { } else if (e.key === "/" || e.key === "f") {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
// search_bar.focus() open_search()
open()
return
} }
} }
</script> </script>
@@ -200,7 +213,7 @@ const window_keydown = (e: KeyboardEvent) => {
{/if} {/if}
<div class="center"> <div class="center">
<form class="search_form" onsubmit={submit_search}> <form class="search_form" onsubmit={submit_search}>
<i class="icon">search</i> <i class="icon i_search"></i>
<input <input
bind:this={search_bar} bind:this={search_bar}
class="term" class="term"
@@ -237,7 +250,7 @@ const window_keydown = (e: KeyboardEvent) => {
<div class="node"> <div class="node">
<div class="node_name" style="text-align: center;"> <div class="node_name" style="text-align: center;">
<button onclick={() => {search(last_limit + 100)}}> <button onclick={() => {search(last_limit + 100)}}>
<i class="icon">expand_more</i> <i class="icon i_expand_more"></i>
More results More results
</button> </button>
</div> </div>
+14 -14
View File
@@ -41,37 +41,37 @@ export const copy_link = () => {
<div class="grid" class:hide={!toolbar_expanded}> <div class="grid" class:hide={!toolbar_expanded}>
<div class="button_row"> <div class="button_row">
<button onclick={() => {nav.open_sibling(-1)}}> <button onclick={() => {nav.open_sibling(-1)}} title="Previous file">
<i class="icon">skip_previous</i> <i class="icon i_skip_previous"></i>
</button> </button>
<button onclick={() => {nav.shuffle = !nav.shuffle}} class:button_highlight={nav.shuffle}> <button onclick={nav.toggle_shuffle} class:button_highlight={$nav.shuffle} title="Shuffle">
<i class="icon">shuffle</i> <i class="icon i_shuffle"></i>
</button> </button>
<button onclick={() => {nav.open_sibling(1)}}> <button onclick={() => {nav.open_sibling(1)}} title="Next file">
<i class="icon">skip_next</i> <i class="icon i_skip_next"></i>
</button> </button>
</div> </div>
<button onclick={() => $nav.base.download()}> <button onclick={() => nav.download()}>
<i class="icon">save</i> <i class="icon i_save"></i>
<span>Download</span> <span>Download</span>
</button> </button>
{#if is_bookmark($bookmarks_store, $nav.base.id)} {#if is_bookmark($bookmarks_store, $nav.base.id)}
<button onclick={() => bookmark_del($nav.base.id)}> <button onclick={() => bookmark_del($nav.base.id)}>
<i class="icon">bookmark_remove</i> <i class="icon i_bookmark_remove"></i>
<span>Bookmark</span> <span>Bookmark</span>
</button> </button>
{:else} {:else}
<button onclick={() => bookmark_add($nav.base)}> <button onclick={() => bookmark_add($nav.base)}>
<i class="icon">bookmark_add</i> <i class="icon i_bookmark_add"></i>
<span>Bookmark</span> <span>Bookmark</span>
</button> </button>
{/if} {/if}
{#if path_is_shared($nav.path)} {#if path_is_shared($nav.path)}
<button onclick={copy_link} class:button_highlight={link_copied}> <button onclick={copy_link} class:button_highlight={link_copied}>
<i class="icon">content_copy</i> <i class="icon i_content_copy"></i>
{#if link_copied} {#if link_copied}
<span>Link copied!</span> <span>Link copied!</span>
{:else} {:else}
@@ -83,19 +83,19 @@ export const copy_link = () => {
<!-- Share button is enabled when: The browser has a sharing API, or the user can edit the file (to enable sharing)--> <!-- Share button is enabled when: The browser has a sharing API, or the user can edit the file (to enable sharing)-->
{#if navigator.share !== undefined || $nav.permissions.write === true} {#if navigator.share !== undefined || $nav.permissions.write === true}
<button onclick={(e) => share_dialog.open(e, nav.path)}> <button onclick={(e) => share_dialog.open(e, nav.path)}>
<i class="icon">share</i> <i class="icon i_share"></i>
<span>Share</span> <span>Share</span>
</button> </button>
{/if} {/if}
<button onclick={() => details_visible = !details_visible} class:button_highlight={details_visible}> <button onclick={() => details_visible = !details_visible} class:button_highlight={details_visible}>
<i class="icon">help</i> <i class="icon i_help"></i>
<span>Deta<u>i</u>ls</span> <span>Deta<u>i</u>ls</span>
</button> </button>
{#if $nav.base.id !== "me" && $nav.permissions.write === true} {#if $nav.base.id !== "me" && $nav.permissions.write === true}
<button onclick={() => edit_window.edit(nav.base, true, "file")} class:button_highlight={edit_visible}> <button onclick={() => edit_window.edit(nav.base, true, "file")} class:button_highlight={edit_visible}>
<i class="icon">edit</i> <i class="icon i_edit"></i>
<span><u>E</u>dit</span> <span><u>E</u>dit</span>
</button> </button>
{/if} {/if}
@@ -22,7 +22,6 @@ const add_user = (e: SubmitEvent) => {
} }
const del_user = (id: string) => { const del_user = (id: string) => {
delete options.user_permissions[id] delete options.user_permissions[id]
options.user_permissions = options.user_permissions
} }
let new_password = $state("") let new_password = $state("")
@@ -49,7 +48,6 @@ const generate_password = () => {
let revealed: {[password: string]: boolean} = $state({}) let revealed: {[password: string]: boolean} = $state({})
const del_password = (pass: string) => { const del_password = (pass: string) => {
delete options.password_permissions[pass] delete options.password_permissions[pass]
options.password_permissions = options.password_permissions
} }
</script> </script>
@@ -95,7 +93,7 @@ const del_password = (pass: string) => {
{#if options.user_permissions !== undefined} {#if options.user_permissions !== undefined}
{#each Object.keys(options.user_permissions) as id (id)} {#each Object.keys(options.user_permissions) as id (id)}
<div class="row"> <div class="row">
<Button click={() => del_user(id)} icon="delete"/> <Button click={() => del_user(id)} icon="delete" title="Remove"/>
<div class="grow id"> <div class="grow id">
{id} {id}
</div> </div>
@@ -135,9 +133,9 @@ const del_password = (pass: string) => {
{#if options.password_permissions !== undefined} {#if options.password_permissions !== undefined}
{#each Object.keys(options.password_permissions) as password (password)} {#each Object.keys(options.password_permissions) as password (password)}
<div class="row"> <div class="row">
<Button click={() => del_password(password)} icon="delete"/> <Button click={() => del_password(password)} icon="delete" title="Remove"/>
<input type="text" bind:value={options.password_permissions[password].label} placeholder="Label" class="grow" maxlength="100" size="1"> <input type="text" bind:value={options.password_permissions[password].label} placeholder="Label" class="grow" maxlength="100" size="1">
<ToggleButton bind:on={revealed[password]} icon_on="visibility" icon_off="visibility_off"/> <ToggleButton bind:on={revealed[password]} icon_on="visibility" icon_off="visibility_off" title="Reveal password"/>
<div class="grow id"> <div class="grow id">
{revealed[password] ? password : "••••••••••••••••"} {revealed[password] ? password : "••••••••••••••••"}
</div> </div>
@@ -239,9 +239,9 @@ const generate_link_color = (link_color: string, body_color: string) => {
// If the body and link colours are both dark we lighten the link, and the // If the body and link colours are both dark we lighten the link, and the
// other way around too // other way around too
if (body[2] < 50 && link[2] < 50) { if (body[2] < 50 && link[2] < 50) {
link[2] = link[2] + 40 // Dark color, add lightness link[2] = link[2] + 30 // Dark color, add lightness
} else if (body[2] > 50 && link[2] > 50) { } else if (body[2] > 50 && link[2] > 50) {
link[2] = link[2] - 40 // Light color, remove lightness link[2] = link[2] - 30 // Light color, remove lightness
} }
return rgb2hex(hsl2rgb(link)) // Convert back to hex return rgb2hex(hsl2rgb(link)) // Convert back to hex
} }
@@ -151,7 +151,7 @@ let accent_info = $state(false)
</p> </p>
<div>Header image ID</div> <div>Header image ID</div>
<button onclick={() => pick_image("brand_header_image")}> <button onclick={() => pick_image("brand_header_image")}>
<i class="icon">folder_open</i> <i class="icon i_folder_open"></i>
Pick Pick
</button> </button>
<input type="text" bind:value={options.brand_header_image}/> <input type="text" bind:value={options.brand_header_image}/>
@@ -159,7 +159,7 @@ let accent_info = $state(false)
<input class="span2" type="text" bind:value={options.brand_header_link}/> <input class="span2" type="text" bind:value={options.brand_header_link}/>
<div>Background image ID</div> <div>Background image ID</div>
<button onclick={() => pick_image("brand_background_image")}> <button onclick={() => pick_image("brand_background_image")}>
<i class="icon">folder_open</i> <i class="icon i_folder_open"></i>
Pick Pick
</button> </button>
<input type="text" bind:value={options.brand_background_image}/> <input type="text" bind:value={options.brand_background_image}/>
@@ -182,9 +182,9 @@ let accent_info = $state(false)
<hr/> <hr/>
<div class="example_button_row"> <div class="example_button_row">
<button type="button"><i class="icon">touch_app</i>Normal</button> <button type="button"><i class="icon i_touch_app"></i>Normal</button>
<button type="button" class="button_highlight"><i class="icon">priority_high</i>Important</button> <button type="button" class="button_highlight"><i class="icon i_priority_high"></i>Important</button>
<button type="button" class="button_red"><i class="icon">warning</i>Dangerous</button> <button type="button" class="button_red"><i class="icon i_warning"></i>Dangerous</button>
</div> </div>
<div class="example_button_row"> <div class="example_button_row">
@@ -35,7 +35,7 @@ export const edit = (f: FSNode, oae = false, open_tab = "") => {
tab = open_tab tab = open_tab
} }
console.log("Editing file", file) console.log("Editing file", $state.snapshot(file))
// We save the name in a separate field because we need both the original // We save the name in a separate field because we need both the original
// name and the new name for the rename operation // name and the new name for the rename operation
@@ -111,15 +111,15 @@ const save = async (e: SubmitEvent) => {
<Modal bind:visible={visible} title="Edit {file.name}" width="800px" form="edit_form" style="color: var(--body_text_color); {custom_css}"> <Modal bind:visible={visible} title="Edit {file.name}" width="800px" form="edit_form" style="color: var(--body_text_color); {custom_css}">
<div class="tab_bar"> <div class="tab_bar">
<button class:button_highlight={tab === "file"} onclick={() => tab = "file"}> <button class:button_highlight={tab === "file"} onclick={() => tab = "file"}>
<i class="icon">edit</i> <i class="icon i_edit"></i>
Properties Properties
</button> </button>
<button class:button_highlight={tab === "share"} onclick={() => tab = "share"}> <button class:button_highlight={tab === "share"} onclick={() => tab = "share"}>
<i class="icon">share</i> <i class="icon i_share"></i>
Sharing Sharing
</button> </button>
<button class:button_highlight={tab === "branding"} onclick={() => tab = "branding"}> <button class:button_highlight={tab === "branding"} onclick={() => tab = "branding"}>
<i class="icon">palette</i> <i class="icon i_palette"></i>
Branding Branding
</button> </button>
</div> </div>
@@ -45,6 +45,16 @@ const toggle_example = () => {
let share_link = $derived(window.location.protocol+"//"+window.location.host+"/d/"+file.id) let share_link = $derived(window.location.protocol+"//"+window.location.host+"/d/"+file.id)
const s3_endpoint = window.location.protocol+"//s3."+window.location.host const s3_endpoint = window.location.protocol+"//s3."+window.location.host
// S3 clients know the directory by its UUID, which is what the ID is when it's
// decoded from base58. Clients like Proxmox Backup Server only accept lowercase
// bucket names
const base58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
let s3_bucket = $derived(
[...file.id].reduce((n, c) => n * 58n + BigInt(base58.indexOf(c)), 0n)
.toString(16).padStart(32, "0")
.replace(/^(.{8})(.{4})(.{4})(.{4})/, "$1-$2-$3-$4-")
)
</script> </script>
{#if $user.subscription.file_sharing === false} {#if $user.subscription.file_sharing === false}
@@ -79,15 +89,27 @@ const s3_endpoint = window.location.protocol+"//s3."+window.location.host
<legend>S3 access</legend> <legend>S3 access</legend>
<p> <p>
This directory can be used as a bucket by backup tools and other This directory can be used as a bucket by backup tools and other
software which supports Amazon S3. The directory ID is the access key, software which supports Amazon S3. The name of the bucket is also the
and the passwords above are the secret keys. Each password's permissions access key, and the passwords above are the secret keys. Each password's
decide what it can do. permissions decide what it can do.
</p> </p>
<table> <table>
<tbody> <tbody>
<tr><td>Endpoint</td><td>{s3_endpoint}</td><td><CopyButton text={s3_endpoint}>Copy</CopyButton></td></tr> <tr>
<tr><td>Bucket and access key</td><td>{file.id}</td><td><CopyButton text={file.id}>Copy</CopyButton></td></tr> <td>Endpoint</td>
<tr><td>Region</td><td>us-east-1 (any region works)</td><td></td></tr> <td>{s3_endpoint}</td>
<td><CopyButton text={s3_endpoint}>Copy</CopyButton></td>
</tr>
<tr>
<td>Bucket ID / Access key</td>
<td>{s3_bucket}</td>
<td><CopyButton text={s3_bucket}>Copy</CopyButton></td>
</tr>
<tr>
<td>Region</td>
<td>us-east-1 (any region works)</td>
<td></td>
</tr>
</tbody> </tbody>
</table> </table>
</fieldset> </fieldset>
@@ -110,7 +132,7 @@ const s3_endpoint = window.location.protocol+"//s3."+window.location.host
<br/> <br/>
<CopyButton text={embed_html} disabled={!is_shared}>Copy HTML</CopyButton> <CopyButton text={embed_html} disabled={!is_shared}>Copy HTML</CopyButton>
<button onclick={toggle_example} class:button_highlight={example} disabled={!is_shared}> <button onclick={toggle_example} class:button_highlight={example} disabled={!is_shared}>
<i class="icon">visibility</i> Show example <i class="icon i_visibility"></i> Show example
</button> </button>
</div> </div>
<hr/> <hr/>
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte" import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte"
import type { FSNavigator } from "filesystem/FSNavigator"; import { move_target, type FSNavigator } from "filesystem/FSNavigator";
import { FileAction, type FileActionHandler } from "./FileManagerLib"; import { FileAction, type FileActionHandler } from "./FileManagerLib";
let { let {
@@ -24,25 +24,28 @@ let {
href={"/d"+fs_encode_path(child.path)} href={"/d"+fs_encode_path(child.path)}
onclick={e => file_event(FileAction.Click, index, e)} onclick={e => file_event(FileAction.Click, index, e)}
oncontextmenu={e => file_event(FileAction.Context, index, e)} oncontextmenu={e => file_event(FileAction.Context, index, e)}
ondragstart={e => file_event(FileAction.Drag, index, e)}
use:move_target={{nav, node: () => child}}
class="node" class="node"
class:node_selected={child.fm_selected} class:node_selected={$nav.selection.has(child.path)}
class:hidden={child.name.startsWith(".") && !show_hidden} class:hidden={child.name.startsWith(".") && !show_hidden}
> >
<img src={fs_node_icon(child, 64, 64)} class="node_icon" class:large_icons loading="lazy" alt="icon"/> <img src={fs_node_icon(child, 64, 64)} class="node_icon" class:large_icons loading="lazy" alt="icon" draggable="false"/>
<div class="node_name"> <div class="node_name">
{child.name} {child.name}
</div> </div>
{#if child.is_shared()} {#if child.is_shared()}
<i class="icon" title="This file / directory is shared. Click to open public link">share</i> <i class="icon i_share" title="This file / directory is shared. Click to open public link"></i>
{/if} {/if}
{#if !hide_edit} {#if !hide_edit}
<button <button
class="action_button flat" class="action_button flat"
onclick={e => file_event(FileAction.Menu, index, e)} onclick={e => file_event(FileAction.Menu, index, e)}
title="Menu"
> >
<i class="icon">menu</i> <i class="icon i_menu"></i>
</button> </button>
{/if} {/if}
</a> </a>
@@ -5,7 +5,7 @@ const scroll_positions = new Map<string, number>()
</script> </script>
<script lang="ts"> <script lang="ts">
import { fs_rename, fs_trash, FSNode } from "lib/FilesystemAPI.svelte" import { fs_trash } from "lib/FilesystemAPI.svelte"
import CreateDirectory from "./CreateDirectory.svelte" import CreateDirectory from "./CreateDirectory.svelte"
import ListView from "./ListView.svelte" import ListView from "./ListView.svelte"
import GalleryView from "./GalleryView.svelte" import GalleryView from "./GalleryView.svelte"
@@ -13,36 +13,32 @@ import CompactView from "./CompactView.svelte"
import Button from "layout/Button.svelte"; import Button from "layout/Button.svelte";
import { formatDate } from "util/Formatting"; import { formatDate } from "util/Formatting";
import { drop_target } from "lib/DropTarget" import { drop_target } from "lib/DropTarget"
import type { FSNavigator } from "filesystem/FSNavigator"; import { drag_click, move_target, type FSNavigator } from "filesystem/FSNavigator";
import FsUploadWidget from "filesystem/upload_widget/FSUploadWidget.svelte"; import { pick_files, upload_files } from "filesystem/upload_widget/FSUploadWidget.svelte";
import EditWindow from "filesystem/edit_window/EditWindow.svelte"; import EditWindow from "filesystem/edit_window/EditWindow.svelte";
import { FileAction, type FileActionHandler } from "./FileManagerLib"; import { FileAction, type FileActionHandler } from "./FileManagerLib";
import FileMenu from "./FileMenu.svelte"; import FileMenu from "./FileMenu.svelte";
import { loading_finish, loading_start } from "lib/Loading"; import { loading_finish, loading_start } from "lib/Loading";
import SearchBar from "../SearchBar.svelte"; import { open_search } from "../SearchBar.svelte";
import type { GenericResponse } from "lib/NovaAPI";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { toolbar_store } from "wrap/HeaderStore"; import { toolbar_store } from "wrap/HeaderStore";
let { let {
nav = $bindable(), nav = $bindable(),
upload_widget,
edit_window = $bindable(), edit_window = $bindable(),
search_bar = $bindable(),
directory_view = $bindable(localStorage.getItem("directory_view") || "list"), directory_view = $bindable(localStorage.getItem("directory_view") || "list"),
children children
}: { }: {
nav: FSNavigator; nav: FSNavigator;
upload_widget: FsUploadWidget;
edit_window: EditWindow; edit_window: EditWindow;
search_bar: SearchBar;
directory_view?: string; directory_view?: string;
children?: import('svelte').Snippet; children?: import('svelte').Snippet;
} = $props(); } = $props();
let large_icons = $state(localStorage.getItem("large_icons") === "true") let large_icons = $state(localStorage.getItem("large_icons") === "true")
let uploader!: FsUploadWidget // In selection mode a click selects. Moving is the part of selection mode where
let mode = $state("viewing") // the user browses to the directory which the selection has to go to
let moving = $state(false)
let creating_dir = $state(false) let creating_dir = $state(false)
let show_hidden = $state(false) let show_hidden = $state(false)
let file_menu!: FileMenu let file_menu!: FileMenu
@@ -50,12 +46,17 @@ $effect(() => {
window.scrollTo(0, scroll_positions.get($nav.base.path) ?? 0) window.scrollTo(0, scroll_positions.get($nav.base.path) ?? 0)
}) })
export const upload = (files: File[]) => {
return uploader.upload_files(files)
}
// Navigation functions // Navigation functions
const file_event: FileActionHandler = (action: FileAction, index: number, orig: Event) => { const file_event: FileActionHandler = (action: FileAction, index: number, orig: Event) => {
const node = nav.children[index]
if (action === FileAction.Drag) {
// Without write access it stays a normal drag of the link
if (nav.permissions.write) {
nav.drag_start(orig as DragEvent, node)
}
return
}
orig.preventDefault() orig.preventDefault()
orig.stopPropagation() orig.stopPropagation()
@@ -63,42 +64,34 @@ const file_event: FileActionHandler = (action: FileAction, index: number, orig:
case FileAction.Click: case FileAction.Click:
creating_dir = false creating_dir = false
if (mode === "viewing") { if (!nav.selecting) {
nav.navigate(nav.children[index].path, true) nav.navigate(node.path, true)
} else if (mode === "moving") { } else if (!moving) {
nav.select(node, (orig as MouseEvent).shiftKey, show_hidden)
} else if (node.type === "dir" && !nav.selection.has(node.path)) {
// If we are moving files we can only enter directories, and only if // If we are moving files we can only enter directories, and only if
// they're not selected. That last requirement prevents people from // they're not selected. That last requirement prevents people from
// moving a directory into itself // moving a directory into itself
if (nav.children[index].type === "dir" && !nav.children[index].fm_selected) { nav.navigate(node.path, true)
nav.navigate(nav.children[index].path, true)
}
} else if (mode === "selecting") {
select_node(index)
} }
break break
case FileAction.Context: case FileAction.Context:
// If this is a touch event we will select the item // If this is a touch event we will select the item
if (navigator.maxTouchPoints && navigator.maxTouchPoints > 0) { if (navigator.maxTouchPoints && navigator.maxTouchPoints > 0) {
select_node(index) nav.select(node)
} else { } else {
file_menu.open(nav.children[index], orig.target, orig) file_menu.open(node, orig.target, orig)
} }
break break
case FileAction.Edit:
edit_window.edit(nav.children[index], false, "file")
break
case FileAction.Share: case FileAction.Share:
creating_dir = false creating_dir = false
edit_window.edit(nav.children[index], false, "share") edit_window.edit(node, false, "share")
break break
case FileAction.Branding: case FileAction.Branding:
edit_window.edit(nav.children[index], false, "branding") edit_window.edit(node, false, "branding")
break
case FileAction.Select:
select_node(index)
break break
case FileAction.Menu: case FileAction.Menu:
file_menu.open(nav.children[index], orig.target, orig) file_menu.open(node, orig.target, orig)
break break
} }
} }
@@ -114,45 +107,17 @@ const delete_selected = async () => {
try { try {
loading_start() loading_start()
// Save all promises with deletion requests in an array await Promise.all([...nav.selection.values()].map(node => fs_trash(node.path)))
let promises: Promise<GenericResponse>[] = []
nav.children.forEach(child => {
if (!child.fm_selected) {
return
}
promises.push(fs_trash(child.path))
})
// Wait for all the promises to finish
await Promise.all(promises)
} catch (err) { } catch (err) {
console.log(err) console.log(err)
alert("Delete failed: " + err.message + " ("+err.value+")") alert("Delete failed: " + err.message + " ("+err.value+")")
} finally { } finally {
viewing_mode() nav.set_selecting(false)
loading_finish() loading_finish()
await nav.reload() await nav.reload()
} }
} }
// Mode switches
const selecting_mode = () => {
mode = "selecting"
}
const viewing_mode = () => {
// Remove any items which we were moving
moving_items = []
// Unmark all the selected files and return to viewing mode
nav.children.forEach((child, i) => {
if (child.fm_selected) {
nav.children[i].fm_selected = false
}
})
mode = "viewing"
}
const toggle_view = () => { const toggle_view = () => {
if (directory_view === "list") { if (directory_view === "list") {
directory_view = "gallery" directory_view = "gallery"
@@ -169,14 +134,7 @@ const toggle_large_icons = () => {
localStorage.setItem("large_icons", JSON.stringify(large_icons)) localStorage.setItem("large_icons", JSON.stringify(large_icons))
} }
// Moving functions const keydown = (e: KeyboardEvent) => {
let moving_items: FSNode[] = []
// We need to detect if shift is pressed so we can select multiple items
let shift_pressed = false
let last_selected_node = -1
const keypress = (e: KeyboardEvent) => {
if ( if (
(document.activeElement as any).type !== undefined && (document.activeElement as any).type !== undefined &&
(document.activeElement as any).type === "text" (document.activeElement as any).type === "text"
@@ -184,102 +142,32 @@ const keypress = (e: KeyboardEvent) => {
return // Prevent shortcuts from interfering with input fields return // Prevent shortcuts from interfering with input fields
} }
if (e.key === "Shift") { if (e.key === "a" && e.ctrlKey) {
shift_pressed = e.type === "keydown" // CTRL + A selects all files which are visible
} else if (e.type === "keydown" && e.key === "a" && e.ctrlKey) { for (const child of nav.children) {
// CTRL + A selects all files if (show_hidden || !child.is_hidden()) {
selecting_mode() nav.selection.set(child.path, child)
for (let i = 0; i < nav.children.length; i++) {
nav.children[i].fm_selected = true
} }
}
nav.set_selecting(true)
e.preventDefault() e.preventDefault()
} else if (e.type === "keydown" && e.key === "Escape" && (mode !== "viewing" || creating_dir)) { } else if (e.key === "Escape" && (nav.selecting || creating_dir)) {
// When escape is pressed we return to viewing mode // When escape is pressed we return to viewing mode
viewing_mode() nav.set_selecting(false)
creating_dir = false creating_dir = false
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
} }
} }
const select_node = (index: number) => { // Runs every time the navigator changes
mode = "selecting"
if (shift_pressed) {
// If shift is pressed we do a range select. We select all files between
// the last selected file and the file that is being selected now
let id_low = Math.min(last_selected_node, index)
let id_high = Math.max(last_selected_node, index)
for (let i = id_low; i <= id_high; i++) {
if (i != last_selected_node) {
nav.children[i].fm_selected = !nav.children[i].fm_selected
}
}
} else {
nav.children[index].fm_selected = !nav.children[index].fm_selected
}
last_selected_node = index
}
// When the directory is reloaded we want to keep our selection, so this
// function watches the children array for changes and updates the selection
// when it changes
$effect.pre(() => { $effect.pre(() => {
if (!$nav.selecting) {
moving = false
}
creating_dir = false creating_dir = false
// Highlight the files which were previously selected
for (let i = 0; i < $nav.children.length; i++) {
for (let j = 0; j < moving_items.length; j++) {
if (moving_items[j].path === $nav.children[i].path) {
$nav.children[i].fm_selected = true
}
}
}
}) })
let moving_files = $state(0)
let moving_directories = $state(0)
const move_start = () => {
moving_files = 0
moving_directories = 0
moving_items = nav.children.reduce((acc, child) => {
if (child.fm_selected) {
if (child.type === "file") {
moving_files++
} else if (child.type === "dir") {
moving_directories++
}
acc.push(child)
}
return acc
}, [])
mode = "moving"
}
const move_here = async () => {
const target_dir = nav.base.path + "/"
try {
loading_start()
let promises = []
moving_items.forEach(item => {
console.log("moving", item.path, "to", target_dir + item.name)
promises.push(fs_rename(item.path, target_dir + item.name))
})
// Wait for all the promises to finish
await Promise.all(promises)
} catch (err) {
console.log(err)
alert("Move failed: " + err.message + " ("+err.value+")")
} finally {
viewing_mode()
nav.reload()
loading_finish()
}
}
// The toolbar is shown in the bar at the top of the page, under the breadcrumbs. // The toolbar is shown in the bar at the top of the page, under the breadcrumbs.
// Other pages don't have it // Other pages don't have it
onMount(() => { onMount(() => {
@@ -289,95 +177,106 @@ onMount(() => {
</script> </script>
<svelte:window <svelte:window
onkeydown={keypress} onkeydown={keydown}
onkeyup={keypress}
onscroll={() => scroll_positions.set(nav.base.path, window.scrollY)} onscroll={() => scroll_positions.set(nav.base.path, window.scrollY)}
/> />
{#snippet nav_buttons()}
<button onclick={navigate_back} use:drag_click title="Back">
<i class="icon i_arrow_back"></i>
</button>
<button onclick={() => nav.navigate_up()} use:drag_click disabled={$nav.path.length <= 1} title="Up">
<i class="icon i_north"></i>
</button>
<button onclick={() => nav.reload()} use:drag_click title="Refresh directory listing">
<i class="icon i_refresh"></i>
</button>
{/snippet}
{#snippet toolbar()} {#snippet toolbar()}
{#if mode === "viewing"} {#if !$nav.selecting}
<div class="toolbar"> <div class="toolbar">
<div class="toolbar_left"> <div class="toolbar_left">
<button onclick={() => {search_bar.open()}} title="Press / to search"> <button onclick={() => open_search()} title="Press / to search">
<i class="icon">search</i> <i class="icon i_search"></i>
</button>
<button onclick={navigate_back} title="Back">
<i class="icon">arrow_back</i>
</button>
<button onclick={() => nav.navigate_up()} disabled={$nav.path.length <= 1} title="Up">
<i class="icon">north</i>
</button>
<button onclick={() => nav.reload()} title="Refresh directory listing">
<i class="icon">refresh</i>
</button> </button>
{@render nav_buttons()}
{#if $nav.children.some(c => c.name === ".Trash" && c.type === "dir")} {#if $nav.children.some(c => c.name === ".Trash" && c.type === "dir")}
<button <button
onclick={() => nav.navigate($nav.children.find(c => c.name === ".Trash").path, true)} onclick={() => nav.navigate($nav.children.find(c => c.name === ".Trash").path, true)}
title="Open trash bin" title="Open trash bin"
> >
<i class="icon">delete</i> <i class="icon i_delete"></i>
</button> </button>
{/if} {/if}
</div> </div>
<div class="toolbar_middle"> <div class="toolbar_middle">
<button onclick={() => toggle_view()} title="Switch between gallery, list and compact view"> <button onclick={() => toggle_view()} title="Switch between gallery, list and compact view">
<i class="icon" class:button_highlight={directory_view === "list"}>list</i> <i class="icon i_list" class:button_highlight={directory_view === "list"}></i>
<i class="icon" class:button_highlight={directory_view === "gallery"}>collections</i> <i class="icon i_collections" class:button_highlight={directory_view === "gallery"}></i>
<i class="icon" class:button_highlight={directory_view === "compact"}>view_compact</i> <i class="icon i_view_compact" class:button_highlight={directory_view === "compact"}></i>
</button> </button>
<button class="button_large_icons" onclick={() => toggle_large_icons()} title="Switch between large and small icons"> <button class="button_large_icons" onclick={() => toggle_large_icons()} title="Switch between large and small icons">
{#if large_icons} {#if large_icons}
<i class="icon">zoom_out</i> <i class="icon i_zoom_out"></i>
{:else} {:else}
<i class="icon">zoom_in</i> <i class="icon i_zoom_in"></i>
{/if} {/if}
</button> </button>
<button onclick={() => {show_hidden = !show_hidden}} title="Toggle hidden files"> <button onclick={() => {show_hidden = !show_hidden}} title="Toggle hidden files">
{#if show_hidden} {#if show_hidden}
<i class="icon">visibility_off</i> <i class="icon i_visibility_off"></i>
{:else} {:else}
<i class="icon">visibility</i> <i class="icon i_visibility"></i>
{/if} {/if}
</button> </button>
</div> </div>
<div class="toolbar_right"> <div class="toolbar_right">
{#if $nav.permissions.write} {#if $nav.permissions.write}
<button onclick={() => upload_widget.pick_files()} title="Upload files to this directory"> <button onclick={() => pick_files()} title="Upload files to this directory">
<i class="icon">cloud_upload</i> <i class="icon i_cloud_upload"></i>
</button> </button>
<Button click={() => {creating_dir = !creating_dir}} highlight={creating_dir} icon="create_new_folder" title="Make folder"/> <Button click={() => {creating_dir = !creating_dir}} highlight={creating_dir} icon="create_new_folder" title="Make folder"/>
<button onclick={selecting_mode} title="Select and delete files"> <button onclick={() => nav.set_selecting(true)} title="Select and delete files">
<i class="icon">select_all</i> <i class="icon i_select_all"></i>
</button> </button>
{/if} {/if}
</div> </div>
</div> </div>
{:else if mode === "selecting"} {:else}
<div class="toolbar toolbar_edit"> <div class="toolbar toolbar_edit">
<Button click={viewing_mode} icon="close"/> <div>
<div class="toolbar_spacer">Selecting files</div> <Button click={() => nav.set_selecting(false)} icon="close" title="Clear selection"/>
<Button click={move_start} icon="drive_file_move" label="Move"/> {@render nav_buttons()}
</div>
<div class="toolbar_spacer">
{moving ? "Moving" : "Selected"} {$nav.selection.size} items
</div>
<div>
{#if moving}
<Button click={() => {creating_dir = !creating_dir}} highlight={creating_dir} icon="create_new_folder" title="Make folder"/>
<Button
click={() => nav.move_selection(nav.base.path)}
disabled={!$nav.can_move($nav.base.path)}
highlight
icon="done"
label="Move here"
/>
{:else}
<Button click={() => {moving = true}} icon="drive_file_move" label="Move"/>
<button onclick={delete_selected} class="button_red"> <button onclick={delete_selected} class="button_red">
<i class="icon">delete</i> <i class="icon i_delete"></i>
Delete Delete
</button> </button>
{/if}
</div> </div>
{:else if mode === "moving"}
<div class="toolbar toolbar_edit">
<Button click={viewing_mode} icon="close"/>
<Button click={() => nav.navigate_up()} disabled={$nav.path.length <= 1} icon="north"/>
<div class="toolbar_spacer">
Moving {moving_files} files and {moving_directories} directories
</div>
<Button click={() => {creating_dir = !creating_dir}} highlight={creating_dir} icon="create_new_folder" title="Make folder"/>
<Button click={move_here} highlight icon="done" label="Move here"/>
</div> </div>
{/if} {/if}
@@ -388,8 +287,9 @@ onMount(() => {
<div <div
class="container" class="container"
use:move_target={{nav, node: () => nav.base}}
use:drop_target={{ use:drop_target={{
upload: (files) => upload_widget.upload_files(files), upload: files => upload_files(files),
shadow: "var(--accent_color) 0 0 10px 2px inset", shadow: "var(--accent_color) 0 0 10px 2px inset",
}} }}
> >
@@ -1,17 +1,10 @@
export type FileEvent = {
index: number,
action: FileAction,
original: MouseEvent,
}
export enum FileAction { export enum FileAction {
Click, Click,
Context, Context,
Edit,
Share, Share,
Branding, Branding,
Select,
Download,
Menu, Menu,
Drag,
} }
export type FileActionHandler = ( export type FileActionHandler = (
action: FileAction, action: FileAction,
@@ -63,6 +63,9 @@ const delete_node = async () => {
<Button click={() => {dialog.close(); bookmark_add(node)}} icon="bookmark_add" label="Add bookmark"/> <Button click={() => {dialog.close(); bookmark_add(node)}} icon="bookmark_add" label="Add bookmark"/>
{/if} {/if}
{#if $nav.permissions.write} {#if $nav.permissions.write}
{#if $nav.children.includes(node)}
<Button click={() => {dialog.close(); nav.select(node)}} icon="select_all" label="Select"/>
{/if}
<Button click={() => {dialog.close(); delete_node()}} icon="delete" label="Delete"/> <Button click={() => {dialog.close(); delete_node()}} icon="delete" label="Delete"/>
{#if edit_window !== null} {#if edit_window !== null}
<Button click={() => {dialog.close(); edit_window.edit(node, false, "file")}} icon="edit" label="Edit"/> <Button click={() => {dialog.close(); edit_window.edit(node, false, "file")}} icon="edit" label="Edit"/>
@@ -7,33 +7,33 @@ import Modal from "util/Modal.svelte";
import { FSNavigator, path_link } from "filesystem/FSNavigator"; import { FSNavigator, path_link } from "filesystem/FSNavigator";
import { fs_encode_path, type FSNode } from "lib/FilesystemAPI.svelte"; import { fs_encode_path, type FSNode } from "lib/FilesystemAPI.svelte";
import { FileAction, type FileActionHandler } from "./FileManagerLib"; import { FileAction, type FileActionHandler } from "./FileManagerLib";
import CreateDirectory from "./CreateDirectory.svelte";
let nav = $state(new FSNavigator(false)) let nav = $state(new FSNavigator(false))
let modal: Modal = $state() let modal: Modal = $state()
let directory_view = $state("") let directory_view = $state("")
let large_icons = $state(false) let large_icons = $state(false)
let show_hidden = $state(false) let show_hidden = $state(false)
let creating_dir = $state(false)
let { let {
callback, callback,
select_multiple = false select_multiple = false,
directories = false,
}: { }: {
callback: (files: FSNode[]) => void callback: (files: FSNode[]) => void
select_multiple?: boolean select_multiple?: boolean
// Picks the directory which is open, instead of files in it
directories?: boolean
} = $props(); } = $props();
export const open = (path: string) => { export const open = (path: string) => {
creating_dir = false
modal.show() modal.show()
nav.set_selecting(false)
nav.navigate(path, false) nav.navigate(path, false)
} }
let selected_files = $derived($nav.children.reduce((acc, file) => {
if (file.fm_selected) {
acc++
}
return acc
}, 0))
// Navigation functions // Navigation functions
const file_event: FileActionHandler = (action: FileAction, index: number, orig: Event) => { const file_event: FileActionHandler = (action: FileAction, index: number, orig: Event) => {
@@ -42,21 +42,17 @@ const file_event: FileActionHandler = (action: FileAction, index: number, orig:
orig.preventDefault() orig.preventDefault()
if (nav.children[index].type === "dir") { if (nav.children[index].type === "dir") {
nav.navigate(nav.children[index].path, true) nav.navigate(nav.children[index].path, true)
} else { } else if (!directories) {
select_node(index) select_node(index, orig)
} }
break break
case FileAction.Context: case FileAction.Context:
// If this is a touch event we will select the item // If this is a touch event we will select the item
if (navigator.maxTouchPoints && navigator.maxTouchPoints > 0) { if (!directories && navigator.maxTouchPoints && navigator.maxTouchPoints > 0) {
orig.preventDefault() orig.preventDefault()
select_node(index) select_node(index, orig)
} }
break break
case FileAction.Select:
orig.preventDefault()
nav.children[index].fm_selected = !nav.children[index].fm_selected
break
} }
} }
@@ -72,50 +68,18 @@ const toggle_view = () => {
localStorage.setItem("directory_view", directory_view) localStorage.setItem("directory_view", directory_view)
} }
// We need to detect if shift is pressed so we can select multiple items const select_node = (index: number, e: Event) => {
let shift_pressed = false
let last_selected_node = -1
const detect_shift = (e: KeyboardEvent) => {
if (e.key === "Shift") {
shift_pressed = e.type === "keydown"
}
}
const select_node = (index: number) => {
if (select_multiple && shift_pressed) {
// If shift is pressed we do a range select. We select all files between
// the last selected file and the file that is being selected now
let id_low = Math.min(last_selected_node, index)
let id_high = Math.max(last_selected_node, index)
for (let i = id_low; i <= id_high; i++) {
if (i != last_selected_node) {
nav.children[i].fm_selected = !nav.children[i].fm_selected
}
}
} else {
// Deselect all other entries first
if (!select_multiple) { if (!select_multiple) {
for (let i = 0; i < nav.children.length; i++) { nav.selection.clear()
nav.children[i].fm_selected = false
} }
} nav.select(nav.children[index], select_multiple && (e as MouseEvent).shiftKey, show_hidden)
nav.children[index].fm_selected = !nav.children[index].fm_selected
}
last_selected_node = index
} }
let done = () => { let done = () => {
let selected_files: FSNode[] = [] if (directories) {
for (let i = 0; i < nav.children.length; i++) { callback([nav.base])
if (nav.children[i].fm_selected) { } else if (nav.selection.size > 0) {
selected_files.push(nav.children[i]) callback([...nav.selection.values()])
}
}
if (selected_files.length > 0) {
callback(selected_files)
} }
modal.hide() modal.hide()
} }
@@ -131,41 +95,48 @@ onMount(() => {
}) })
</script> </script>
<svelte:window onkeydown={detect_shift} onkeyup={detect_shift} />
<Modal bind:this={modal} width="900px"> <Modal bind:this={modal} width="900px">
{#snippet header()} {#snippet header()}
<div class="header" > <div class="header" >
<button class="button round" onclick={modal.hide}> <button class="button round" onclick={modal.hide} title="Close">
<i class="icon">close</i> <i class="icon i_close"></i>
</button> </button>
<button onclick={() => nav.navigate_up()} disabled={$nav.path.length <= 1} title="Up"> <button onclick={() => nav.navigate_up()} disabled={$nav.path.length <= 1} title="Up">
<i class="icon">north</i> <i class="icon i_north"></i>
</button> </button>
<button onclick={() => nav.reload()} title="Refresh directory listing"> <button onclick={() => nav.reload()} title="Refresh directory listing">
<i class="icon">refresh</i> <i class="icon i_refresh"></i>
</button> </button>
<div class="title"> <div class="title">
Selected {selected_files} files {#if directories}
Open the directory to pick
{:else}
Selected {$nav.selection.size} files
{/if}
</div> </div>
{#if $nav.permissions.write}
<button onclick={() => creating_dir = !creating_dir} class:button_highlight={creating_dir} title="Make folder">
<i class="icon i_create_new_folder"></i>
</button>
{/if}
<button onclick={() => {show_hidden = !show_hidden}} title="Toggle hidden files"> <button onclick={() => {show_hidden = !show_hidden}} title="Toggle hidden files">
{#if show_hidden} {#if show_hidden}
<i class="icon">visibility_off</i> <i class="icon i_visibility_off"></i>
{:else} {:else}
<i class="icon">visibility</i> <i class="icon i_visibility"></i>
{/if} {/if}
</button> </button>
<button onclick={() => toggle_view()} title="Switch between gallery, list and compact view"> <button onclick={() => toggle_view()} title="Switch between gallery, list and compact view">
<i class="icon" class:button_highlight={directory_view === "list"}>list</i> <i class="icon i_list" class:button_highlight={directory_view === "list"}></i>
<i class="icon" class:button_highlight={directory_view === "gallery"}>collections</i> <i class="icon i_collections" class:button_highlight={directory_view === "gallery"}></i>
<i class="icon" class:button_highlight={directory_view === "compact"}>view_compact</i> <i class="icon i_view_compact" class:button_highlight={directory_view === "compact"}></i>
</button> </button>
<button class="button button_highlight round" onclick={done}> <button class="button button_highlight round" onclick={done}>
<i class="icon">done</i> Pick <i class="icon i_done"></i> Pick
</button> </button>
</div> </div>
{/snippet} {/snippet}
@@ -177,20 +148,24 @@ onMount(() => {
use:path_link={{nav: nav, node: node}} use:path_link={{nav: nav, node: node}}
> >
{#if node.abuse_type !== undefined} {#if node.abuse_type !== undefined}
<i class="icon small">block</i> <i class="icon small i_block"></i>
{:else if node.is_shared()} {:else if node.is_shared()}
<i class="icon small">share</i> <i class="icon small i_share"></i>
{/if} {/if}
<div class="node_name" class:base={$nav.base_index === i}> <div class="node_name" class:base={$nav.base_index === i}>
{node.name} {node.name}
</div> </div>
</a> </a>
{#if $nav.base_index !== i} {#if $nav.base_index !== i}
<i class="icon">chevron_right</i> <i class="icon i_chevron_right"></i>
{/if} {/if}
{/each} {/each}
{#if creating_dir}
<CreateDirectory nav={nav}/>
{/if}
{#if directory_view === "list"} {#if directory_view === "list"}
<ListView <ListView
nav={nav} nav={nav}
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { fs_node_icon, fs_node_type, fs_encode_path } from "lib/FilesystemAPI.svelte"; import { fs_node_icon, fs_node_type, fs_encode_path } from "lib/FilesystemAPI.svelte";
import type { FSNavigator } from "filesystem/FSNavigator"; import { move_target, type FSNavigator } from "filesystem/FSNavigator";
import { FileAction, type FileActionHandler } from "./FileManagerLib"; import { FileAction, type FileActionHandler } from "./FileManagerLib";
let { let {
@@ -22,7 +22,9 @@ let {
href={"/d"+fs_encode_path(child.path)} href={"/d"+fs_encode_path(child.path)}
onclick={e => file_event(FileAction.Click, index, e)} onclick={e => file_event(FileAction.Click, index, e)}
oncontextmenu={e => file_event(FileAction.Context, index, e)} oncontextmenu={e => file_event(FileAction.Context, index, e)}
class:selected={child.fm_selected} ondragstart={e => file_event(FileAction.Drag, index, e)}
use:move_target={{nav, node: () => child}}
class:selected={$nav.selection.has(child.path)}
class:hidden={child.name.startsWith(".") && !show_hidden} class:hidden={child.name.startsWith(".") && !show_hidden}
class:large_icons class:large_icons
title={child.name} title={child.name}
@@ -33,6 +35,7 @@ let {
src={fs_node_icon(child, 256, 256)} src={fs_node_icon(child, 256, 256)}
loading="lazy" loading="lazy"
alt="" alt=""
draggable="false"
/> />
<div class="node_name"> <div class="node_name">
{child.name} {child.name}
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { formatDataVolume, formatDate, formatThousands } from "util/Formatting"; import { formatDataVolume, formatDate, formatThousands } from "util/Formatting";
import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte" import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte"
import type { FSNavigator } from "filesystem/FSNavigator"; import { move_target, type FSNavigator } from "filesystem/FSNavigator";
import SortButton from "layout/SortButton.svelte"; import SortButton from "layout/SortButton.svelte";
import { FileAction, type FileActionHandler } from "./FileManagerLib"; import { FileAction, type FileActionHandler } from "./FileManagerLib";
import Dialog from "layout/Dialog.svelte"; import Dialog from "layout/Dialog.svelte";
@@ -15,7 +15,8 @@ let {
show_hidden = false, show_hidden = false,
large_icons = false, large_icons = false,
hide_edit = false, hide_edit = false,
hide_branding = false hide_branding = false,
trash = false
}: { }: {
nav: FSNavigator nav: FSNavigator
file_event: FileActionHandler file_event: FileActionHandler
@@ -23,6 +24,7 @@ let {
large_icons?: boolean large_icons?: boolean
hide_edit?: boolean hide_edit?: boolean
hide_branding?: boolean hide_branding?: boolean
trash?: boolean
} = $props(); } = $props();
let dialog: Dialog = $state() let dialog: Dialog = $state()
@@ -78,6 +80,18 @@ onMount(load_settings)
Name Name
</SortButton> </SortButton>
</td> </td>
{#if trash}
<td class="hide_small">
<SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field="original_path">
Original location
</SortButton>
</td>
<td class="hide_small">
<SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field="deletion_date">
Deleted on
</SortButton>
</td>
{/if}
{#each columns as col} {#each columns as col}
<td class="hide_small" class:hidden={!config[col.field]}> <td class="hide_small" class:hidden={!config[col.field]}>
<SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field={col.field}> <SortButton active_field={$nav.sort_last_field} asc={$nav.sort_asc} sort_func={nav.sort_children} field={col.field}>
@@ -86,7 +100,7 @@ onMount(load_settings)
</td> </td>
{/each} {/each}
<td class="node_icons icons_wrap"> <td class="node_icons icons_wrap">
<Button flat icon="settings" click={e => dialog.open(e)} /> <Button flat icon="settings" click={e => dialog.open(e)} title="Columns"/>
</td> </td>
</tr> </tr>
</thead> </thead>
@@ -95,18 +109,27 @@ onMount(load_settings)
<tr <tr
onclick={e => file_event(FileAction.Click, index, e)} onclick={e => file_event(FileAction.Click, index, e)}
oncontextmenu={e => file_event(FileAction.Context, index, e)} oncontextmenu={e => file_event(FileAction.Context, index, e)}
ondragstart={e => file_event(FileAction.Drag, index, e)}
use:move_target={{nav, node: () => child}}
draggable="true"
class="node" class="node"
class:node_selected={child.fm_selected} class:node_selected={$nav.selection.has(child.path)}
class:hidden={child.name.startsWith(".") && !show_hidden} class:hidden={child.name.startsWith(".") && !show_hidden}
> >
<td> <td>
<img src={fs_node_icon(child, 64, 64)} class="node_icon" class:large_icons loading="lazy" alt="icon"/> <img src={fs_node_icon(child, 64, 64)} class="node_icon" class:large_icons loading="lazy" alt="icon" draggable="false"/>
</td> </td>
<td class="node_name"> <td class="node_name" class:half={trash}>
<a class="title_link" href={"/d"+fs_encode_path(child.path)}> <a class="title_link" href={"/d"+fs_encode_path(child.path)} draggable="false">
{child.name} {child.name}
</a> </a>
</td> </td>
{#if trash}
<td class="node_name half hide_small">{child.original_path}</td>
<td class="node_size hide_small">
{formatDate(child.deletion_date, true, true, false)}
</td>
{/if}
<td class="node_size hide_small" class:hidden={!config.modified}> <td class="node_size hide_small" class:hidden={!config.modified}>
{formatDate(child.modified, true, true, false)} {formatDate(child.modified, true, true, false)}
</td> </td>
@@ -139,24 +162,25 @@ onMount(load_settings)
<td class="node_icons"> <td class="node_icons">
<div class="icons_wrap"> <div class="icons_wrap">
{#if child.abuse_type !== undefined} {#if child.abuse_type !== undefined}
<i class="icon" title="This file / directory has received an abuse report. It cannot be shared">block</i> <i class="icon i_block" title="This file / directory has received an abuse report. It cannot be shared"></i>
{:else if child.is_shared()} {:else if child.is_shared()}
<a <a
href="/d/{child.id}" href="/d/{child.id}"
onclick={e => file_event(FileAction.Share, index, e)} onclick={e => file_event(FileAction.Share, index, e)}
class="button action_button" class="button action_button"
title="This file / directory is shared. Click to open public link"
> >
<i class="icon" title="This file / directory is shared. Click to open public link">share</i> <i class="icon i_share"></i>
</a> </a>
{/if} {/if}
{#if child.properties !== undefined && child.properties.branding_enabled === "true" && !hide_branding} {#if child.properties !== undefined && child.properties.branding_enabled === "true" && !hide_branding}
<button class="action_button" onclick={e => file_event(FileAction.Branding, index, e)}> <button class="action_button" onclick={e => file_event(FileAction.Branding, index, e)} title="Edit branding">
<i class="icon">palette</i> <i class="icon i_palette"></i>
</button> </button>
{/if} {/if}
{#if !hide_edit} {#if !hide_edit}
<button class="action_button" onclick={e => file_event(FileAction.Menu, index, e)}> <button class="action_button" onclick={e => file_event(FileAction.Menu, index, e)} title="Menu">
<i class="icon">menu</i> <i class="icon i_menu"></i>
</button> </button>
{/if} {/if}
</div> </div>
@@ -176,7 +200,7 @@ onMount(load_settings)
</div> </div>
{/each} {/each}
<button type="submit"> <button type="submit">
<i class="icon">save</i> <i class="icon i_save"></i>
Save Save
</button> </button>
</form> </form>
@@ -213,8 +237,8 @@ td {
text-decoration: none; text-decoration: none;
} }
.node.node_selected { .node.node_selected {
background-color: var(--accent_color) !important; background-color: var(--accent_shade) !important;
color: var(--accent_text_color); color: var(--link_color);
} }
td { td {
vertical-align: middle; vertical-align: middle;
@@ -231,9 +255,13 @@ td {
line-height: 1.2em; line-height: 1.2em;
word-break: break-all; word-break: break-all;
} }
/* In the trash the name shares its width with the original location */
.half {
width: 50%;
}
.title_link { .title_link {
text-decoration: none; text-decoration: none;
color: var(--body_text_color); color: unset;
} }
.node_size { .node_size {
min-width: 5em; min-width: 5em;
@@ -265,5 +293,8 @@ td {
.hide_small { .hide_small {
display: none; display: none;
} }
.half {
width: 100%;
}
} }
</style> </style>
+128 -182
View File
@@ -1,10 +1,13 @@
<script lang="ts"> <script lang="ts">
import { formatDataVolume, formatDate } from "util/Formatting"; import { formatDataVolume } from "util/Formatting";
import { fs_check_response, fs_encode_path, fs_get_trash, fs_node_icon, fs_path_url, type TrashEntry } from "lib/FilesystemAPI.svelte"; import { fs_check_response, fs_get_trash, fs_path_url, fs_rename, fs_trash, type FSNode } from "lib/FilesystemAPI.svelte";
import { loading_finish, loading_run, loading_start, loading_store } from "lib/Loading"; import { loading_run } from "lib/Loading";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { breadcrumbs_store } from "wrap/HeaderStore"; import { toolbar_store } from "wrap/HeaderStore";
import { FSNavigator } from "filesystem/FSNavigator"; import { FSNavigator } from "filesystem/FSNavigator";
import Button from "layout/Button.svelte";
import ListView from "./ListView.svelte";
import { FileAction, type FileActionHandler } from "./FileManagerLib";
let { let {
nav, nav,
@@ -14,214 +17,157 @@ let {
root_path?: string root_path?: string
} = $props(); } = $props();
let entries: TrashEntry[] = $state([]); // The trash entries are not the children of the .Trash directory, so they get a
let error: string = $state(""); // navigator of their own for the ListView to list and sort
const trash = new FSNavigator(false)
const load = async () => { let size = $derived($trash.children.reduce(
loading_run(async () => { (acc, node) => acc + (node.type === "dir" ? node.recursive_size : node.file_size), 0
))
const load = () => loading_run(async () => {
try { try {
entries = await fs_get_trash(root_path) trash.children = await fs_get_trash(root_path)
error = "";
} catch (err: any) { } catch (err: any) {
error = err?.message ?? JSON.stringify(err); alert("Failed to load the trash bin: " + (err.message ?? err))
} }
trash.selecting = false
trash.selection.clear()
trash.sort_children("")
}) })
};
const delete_entry = async (entry: TrashEntry) => { const file_event: FileActionHandler = (action, index, e) => {
if (!confirm(`Permanently delete "${entry.node.name}"?`)) return; if (action === FileAction.Drag) {
try { return
loading_start(); } else if (action === FileAction.Context) {
await fs_check_response( // On a touch screen a long press starts selecting, like in the file
await fetch(fs_path_url(entry.node.path) + "?trash", { method: "DELETE" }) // manager. A right click is left to the browser's own menu
); if (!navigator.maxTouchPoints) {
entries = entries.filter(e => e.node.id !== entry.node.id); return
} catch (err: any) {
alert(err?.message ?? JSON.stringify(err));
} finally {
loading_finish();
} }
}; trash.selecting = true
}
e.preventDefault()
e.stopPropagation()
const restore_entry = async (entry: TrashEntry) => { if (trash.selecting) {
if (!entry.original_path) { trash.select(trash.children[index], (e as MouseEvent).shiftKey)
alert("Original path is not known, cannot restore this file."); } else {
return; nav.navigate(trash.children[index].path, true)
}
}
const selected = () => [...trash.selection.values()]
// Runs an action on all the selected entries and reloads the listing
const run_selected = async (action: (node: FSNode) => Promise<any>) => {
const results = await loading_run(() => Promise.allSettled(selected().map(action)))
const failed = results.filter(r => r.status === "rejected") as PromiseRejectedResult[]
if (failed.length !== 0) {
alert(
failed.length + " of " + results.length + " failed: " +
(failed[0].reason.message ?? failed[0].reason)
)
}
await load()
}
const restore = () => run_selected(async node => {
if (!node.original_path) {
throw new Error("the original location of " + node.name + " is not known")
}
return fs_rename(node.path, root_path + node.original_path)
})
const delete_selected = () => {
if (confirm(`Permanently delete ${selected().length} of the items in the trash?`)) {
run_selected(node => fs_trash(node.path))
} }
try {
loading_start();
const form = new FormData();
form.append("action", "rename");
form.append("target", "/me" + entry.original_path);
await fs_check_response(
await fetch(fs_path_url(entry.node.path), { method: "POST", body: form })
);
entries = entries.filter(e => e.node.id !== entry.node.id);
} catch (err: any) {
alert(err?.message ?? JSON.stringify(err));
} finally {
loading_finish();
} }
};
const empty_trash = async () => { const empty_trash = async () => {
if (!confirm("Permanently delete all items in the trash?")) return; if (!confirm("Permanently delete all items in the trash?")) {
try { return
loading_start(); }
await fs_check_response( try {
await fetch(fs_path_url(root_path) + "?empty_trash", { method: "DELETE" }) await loading_run(async () => fs_check_response(
); await fetch(fs_path_url(root_path) + "?empty_trash", { method: "DELETE" })
entries = []; ))
} catch (err: any) { } catch (err: any) {
alert(err?.message ?? JSON.stringify(err)); alert(err.message ?? err)
} finally { }
loading_finish(); await load()
} }
};
onMount(() => { onMount(() => {
breadcrumbs_store.set(breadcrumbs) toolbar_store.set(toolbar)
load() load()
}); return () => toolbar_store.set(null)
})
</script> </script>
{#snippet toolbar()}
{#snippet breadcrumbs()} {#if $trash.selecting}
<i class="icon">delete</i> <div class="toolbar toolbar_edit">
<Button icon="close" click={() => trash.set_selecting(false)} title="Stop selecting"/>
<div class="toolbar_spacer">Selecting files</div>
<Button click={restore} icon="restore_from_trash" label="Restore"/>
<button onclick={delete_selected} class="button_red">
<i class="icon i_delete_forever"></i>
Delete
</button>
</div>
{:else}
<div class="toolbar">
<div> <div>
Trash bin <button onclick={() => history.back()} title="Back">
{#if $loading_store === 0 && entries.length === 0} <i class="icon i_arrow_back"></i>
(empty) </button>
{:else if entries.length !== 0} <button onclick={() => nav.navigate_up()} title="Up">
({formatDataVolume(entries.reduce( <i class="icon i_north"></i>
(acc, entry) => acc + entry.node.file_size, 0 </button>
), 3)}) <button onclick={load} title="Refresh trash bin">
<i class="icon i_refresh"></i>
</button>
</div>
<div>Trash bin ({formatDataVolume(size, 3)})</div>
<div>
{#if $trash.children.length !== 0}
<button onclick={() => trash.set_selecting(true)} title="Select files to restore or delete">
<i class="icon i_select_all"></i>
</button>
<button onclick={empty_trash} class="button_red">
<i class="icon i_delete_forever"></i>
Delete all
</button>
{/if} {/if}
</div> </div>
<div class="separator"></div> </div>
<button onclick={() => window.history.back()} title="Back">
<i class="icon">arrow_back</i>
</button>
<button onclick={() => nav.navigate_up()} disabled={$nav.path.length <= 1} title="Up">
<i class="icon">north</i>
</button>
<button onclick={() => nav.reload()} title="Refresh directory listing">
<i class="icon">refresh</i>
</button>
{#if entries.length !== 0}
<button class="button button_red" onclick={empty_trash}>
<i class="icon">delete_forever</i>
<span>Delete all</span>
</button>
{/if} {/if}
{/snippet} {/snippet}
{#if error} <ListView nav={trash} file_event={file_event} show_hidden hide_edit hide_branding trash/>
<p class="error">{error}</p>
{:else if entries.length > 0}
<table class="trash_table">
<thead>
<tr>
<td></td>
<td>Name</td>
<td class="hide_small">Original location</td>
<td class="hide_small">Deleted at</td>
<td class="hide_small">Size</td>
<td></td>
</tr>
</thead>
<tbody>
{#each entries as entry (entry.node.id)}
<tr class="entry">
<td class="icon_cell">
<img
src={fs_node_icon(entry.node, 32, 32)}
class="node_icon"
alt="icon"
/>
</td>
<td class="name_cell">
<a class="entry_link" href={"/d" + fs_encode_path(entry.node.path)}>
{entry.node.name}
</a>
</td>
<td class="hide_small">
{entry.original_path ? entry.original_path.slice(0, -entry.node.name.length) : "—"}
</td>
<td class="hide_small">
{entry.deletion_date ? formatDate(entry.deletion_date) : "—"}
</td>
<td class="hide_small">
{#if entry.node.type === "file"}
{formatDataVolume(entry.node.file_size, 3)}
{/if}
</td>
<td>
<div class="row_actions">
<button title="Restore to original location" onclick={() => restore_entry(entry)}>
<i class="icon">restore_from_trash</i>
</button>
<button class="button button_red" title="Delete permanently" onclick={() => delete_entry(entry)}>
<i class="icon">delete_forever</i>
</button>
</div>
</td>
</tr>
{/each}
</tbody>
</table>
{/if}
<style> <style>
.separator { /* Same as the toolbar of the file manager */
flex: 1 1 auto; .toolbar {
} display: flex;
.error { flex-direction: row;
color: var(--red_color); flex-wrap: wrap;
} justify-content: space-between;
.trash_table { align-items: center;
width: 100%;
border-collapse: collapse;
background: var(--body_background);
border-radius: 8px;
}
.trash_table td {
padding: 0;
}
.entry {
cursor: default;
border-top: 1px solid var(--separator); border-top: 1px solid var(--separator);
} }
.entry:hover { .toolbar > * {
background: var(--input_hover_background); flex: 0 0 content;
}
.icon_cell {
width: 2.5em;
}
.node_icon {
display: block;
width: 2em;
height: 2em;
object-fit: contain;
}
.name_cell {
word-break: break-all;
}
.entry_link {
color: var(--body_text_color);
text-decoration: none;
}
.entry_link:hover {
text-decoration: underline;
}
.row_actions {
display: flex; display: flex;
gap: 0.25em; flex-direction: row;
} }
@media (max-width: 600px) { .toolbar_spacer {
.hide_small { flex: 1 1 auto;
display: none; text-align: center;
} }
.toolbar_edit {
background-color: var(--green_tint);
} }
</style> </style>
@@ -1,157 +1,363 @@
<script lang="ts" module> <script lang="ts" module>
export type UploadJob = { // A file, and its path relative to the directory which it is uploaded to
task_id: number, export type Upload = { file: File, path: string }
file: File,
path: string, // The widget is mounted once, in App.svelte, so that uploads keep running when
component: UploadProgress, // the user opens another page. It sets these functions when it mounts
status: string, export let upload_files: (files: Upload[] | Promise<Upload[]>) => void
total_size: number, export let pick_files: () => void
loaded_size: number,
};
</script> </script>
<script lang="ts"> <script lang="ts">
import { tick } from "svelte"; import { global_navigator as nav } from "filesystem/FSNavigator";
import UploadProgress from "./UploadProgress.svelte"; import { fs_path_url } from "lib/FilesystemAPI.svelte";
import type { FSNavigator } from "filesystem/FSNavigator"; import { loading_run } from "lib/Loading";
import { user } from "lib/UserStore";
import { formatDataVolume, formatDuration } from "util/Formatting";
import ProgressBar from "util/ProgressBar.svelte";
import Button from "layout/Button.svelte";
let { nav }: { type Job = Upload & {
nav: FSNavigator; dir: string,
} = $props(); loaded: number,
// What loaded was at the previous update, the difference gives the speed
let file_input_field: HTMLInputElement = $state() prev: number,
let file_input_change = (e: Event) => { speed: number,
// Start uploading the files async xhr?: XMLHttpRequest,
upload_files((e.target as HTMLInputElement).files)
// This resets the file input field
file_input_field.nodeValue = ""
}
export const pick_files = () => {
file_input_field.click()
}
let visible = $state(false)
let upload_queue: UploadJob[] = $state([]);
let task_id_counter = 0
export const upload_files = async (files: File[]|FileList) => {
if (files.length === 0) {
return
} else if (nav.base.type !== "dir") {
alert("Can only upload to directory")
return
}
// Add files to the queue
for (let i = 0; i < files.length; i++) {
await upload_file(files[i])
}
}
export const upload_file = async (file: File) => {
if (nav.base.type !== "dir") {
alert("Can only upload to directory")
return
} else if (file.type === "" && file.size === 0) {
return
}
let path = nav.base.path + "/"
if (file.webkitRelativePath) {
path += file.webkitRelativePath
} else {
path += file.name
}
upload_queue.push({
task_id: task_id_counter,
file: file,
path: path,
component: null,
status: "queued",
total_size: file.size,
loaded_size: 0,
})
task_id_counter++
// Reassign array and wait for tick to complete. After the tick is completed
// each upload progress bar will have bound itself to its array item
upload_queue = upload_queue
if (active_uploads === 0 && status !== "uploading") {
status = "uploading"
visible = true
await tick()
await start_upload()
}
} }
const min_uploads = 2 const min_uploads = 2
const max_uploads = 20 const max_uploads = 20
// Milliseconds between two updates of the widget. The progress bars take as
// long to move to their new position
const update_interval = 250
let active_uploads = 0 // The uploads are deliberately not reactive. A dropped directory can hold
let status = $state("idle") // hundreds of thousands of files, and every running upload reports progress
// many times per second. Every update_interval, update() copies what the
// widget shows to view, so the cost of rendering does not depend on the size of
// the queue
let queue: Job[] = []
let active: Job[] = []
let failed: { path: string, message: string }[] = []
let files_total = 0
let files_done = 0
// In bytes. Files which failed or were cancelled are taken off the total
let size_total = 0
let size_done = 0
// Every byte which was sent, also for uploads which were aborted later
let transferred = 0
let transferred_prev = 0
let speed = 0
let updated = 0
let timer = 0
// What was transferred at each update of the last ten seconds, and how many
// bytes the running uploads may have left to send together, see schedule()
let samples: { time: number, sent: number }[] = []
let threshold = 0
// The title which the page set, and the one we replaced it with
let page_title = ""
let title = ""
const start_upload = async () => { let visible = $state(false)
active_uploads = 0 let collapsed = $state(false)
let uploading_size = 0 let paused = $state(false)
for (let i = 0; i < upload_queue.length; i++) { // The timer which waits to try again after the connection was lost
if (upload_queue[i]) { let retry = $state(0)
// If this file is queued, start the upload let view = $state.raw({
if (upload_queue[i].status === "queued") { uploading: false,
upload_queue[i].component.start() running: 0,
upload_queue[i].status = "uploading" percent: 0,
loaded: 0,
total: 0,
speed: 0,
eta: "",
files_done: 0,
files_total: 0,
rows: [] as { job: Job, loaded: number, speed: number, queued: boolean }[],
failed,
failed_count: 0,
})
let file_input: HTMLInputElement
pick_files = () => file_input.click()
const file_input_change = () => {
upload_files(Array.from(file_input.files, file => ({ file, path: file.name })))
// Without this the same file can't be picked twice in a row
file_input.value = ""
} }
// If this file is already uploading (or just started), count it upload_files = async files => {
if (upload_queue[i].status === "uploading") { // Reading a large directory takes a while. The files go to the directory
uploading_size += upload_queue[i].total_size // which they were dropped on, also if the user has left it by then
active_uploads++ const dir = nav.base.path
try {
files = await loading_run(async () => files)
} catch (err) {
alert("Failed to read the files: " + err)
return
}
if (files.length === 0) {
return
} }
// If the size threshold or the concurrent upload limit is reached if (active.length + queue.length === 0) {
// we break the loop. The system tries to keep an upload queue of files_total = files_done = size_total = size_done = speed = 0
// 100 MB and a minimum of two concurrent uploads. timer = window.setInterval(() => {
if ( update()
(uploading_size >= 100e6 && active_uploads >= min_uploads) || schedule()
active_uploads >= max_uploads }, update_interval)
}
const limit = $user?.subscription.file_size_limit || 20e9
for (const { file, path } of files) {
if (file.size > limit) {
failed.push({ path, message: "This file is too large. Check out " +
"the Pro subscription to increase the file size limit" })
continue
}
queue.push({ file, path, dir, loaded: 0, prev: 0, speed: 0 })
files_total++
size_total += file.size
}
visible = true
schedule()
update()
}
// Starts queued uploads until enough are running: at least two, and as many
// as it takes to have ten seconds of work at the speed of the last ten seconds.
// Small files are sent in large numbers at a time that way, and a slow
// connection is not divided over more large files than it can handle. A new
// connection starts with two uploads, and gets more as its speed shows
const schedule = () => {
let size = 0
for (const job of active) {
size += job.file.size - job.loaded
}
// Empty files don't count towards the speed, a directory full of them
// never gets over a threshold of zero. Hence the <=
while (
!paused && retry === 0 &&
queue.length > 0 && active.length < max_uploads &&
(size <= threshold || active.length < min_uploads)
) { ) {
console.debug("Current uploads", active_uploads, "uploads size", uploading_size) const job = queue.shift()
break size += job.file.size
active.push(job)
// Takes the job off the running uploads. Without an error it's done
const end = (error?: string) => {
job.xhr = undefined
active.splice(active.indexOf(job), 1)
if (error === undefined) {
transferred += job.file.size - job.loaded
files_done++
size_done += job.file.size
} else {
failed.push({ path: job.path, message: error })
files_total--
size_total -= job.file.size
} }
schedule()
}
const xhr = job.xhr = new XMLHttpRequest()
xhr.open("PUT", fs_path_url(job.dir + "/" + job.path) + "?make_parents=true")
xhr.upload.onprogress = e => {
transferred += e.loaded - job.loaded
job.loaded = e.loaded
}
xhr.onloadend = () => {
if (job.xhr !== xhr) {
return // Aborted by stop or cancel
} else if (xhr.status >= 400) {
// A proxy in front of the API does not answer with JSON
let error = xhr.statusText
try {
error = JSON.parse(xhr.response).message
} catch {}
end(error)
} else if (xhr.status !== 0) {
end()
} else {
// No response, the connection is gone. The file goes back to
// the front of the queue, and the queue waits. Without the
// wait every file in it would fail within seconds
job.xhr = undefined
active.splice(active.indexOf(job), 1)
job.loaded = job.prev = job.speed = 0
queue.unshift(job)
clearTimeout(retry)
retry = window.setTimeout(() => {
retry = 0
schedule()
}, 10e3)
} }
} }
if (active_uploads === 0) { // Firefox never ends the request for a file which was removed or
status = "finished" // truncated after it was picked: there is no error, it hangs. Reading
// the last byte of the file first shows if all of it is still there.
// Chromium refuses to read a file which changed in any way, with a
// NotReadableError, but does upload it. That one is not a reason to
// give up
job.file.slice(-1).arrayBuffer().then(
last => last.byteLength === Math.min(1, job.file.size),
err => err.name === "NotReadableError",
).then(readable => {
if (job.xhr !== xhr) {
return
} else if (readable) {
xhr.send(job.file)
} else {
end("The file was changed or removed after it was added")
}
})
}
if (timer !== 0 && active.length + queue.length === 0) {
clearInterval(timer)
timer = 0
paused = false
update()
// Show the new files. The other pages don't use the navigator, there a
// reload would put the directory in the address bar
if (window.location.pathname.startsWith("/d/")) {
nav.reload() nav.reload()
}
// Empty the queue to free any references to lingering components // Errors stay until the user has closed them
upload_queue = []
// In ten seconds we close the popup
setTimeout(() => { setTimeout(() => {
if (status === "finished") { if (timer === 0 && failed.length === 0) {
visible = false visible = false
} }
}, 10000) }, 10e3)
} else {
status = "uploading"
} }
} }
const finish_upload = () => { // The request is taken off the job first, that is how its loadend handler knows
// Update the queue so the status updates are properly rendered // that it was aborted on purpose
upload_queue = upload_queue const abort = (job: Job) => {
start_upload() const xhr = job.xhr
job.xhr = undefined
xhr.abort()
}
// A pause only holds the queue, the uploads which are running finish
const toggle_pause = () => {
paused = !paused
schedule()
update()
}
const stop = () => {
clearTimeout(retry)
retry = 0
active.forEach(abort)
active = []
queue = []
failed = []
visible = false
schedule()
}
const cancel = (job: Job) => {
const list = job.xhr === undefined ? queue : active
const index = list.indexOf(job)
if (index === -1) {
return // The row is older than the job, it has finished since
}
if (list === active) {
abort(job)
}
list.splice(index, 1)
files_total--
size_total -= job.file.size
schedule()
update()
}
const update = () => {
const now = performance.now()
const dt = (now - updated) / 1000
updated = now
// Speeds are moving averages over about the last three seconds. A sample
// weighs as much as the time which it covers, because the timer is not
// steady: browsers slow it down in a background tab, to once per minute even
const weight = 1 - Math.exp(-dt / 3)
const average = (speed: number, bytes: number) =>
dt > 0 ? speed + (bytes / dt - speed) * weight : speed
speed = average(speed, transferred - transferred_prev)
transferred_prev = transferred
// Ten seconds at the average speed of the last ten seconds is what was
// sent in that time. One sample from before it stays as the start of the
// period: in a background tab the timer runs as little as once per minute,
// and the period would be empty. It is longer than ten seconds then, so
// the amount is scaled back to ten
samples.push({ time: now, sent: transferred })
while (samples.length > 2 && now - samples[1].time >= 10e3) {
samples.shift()
}
threshold = (transferred - samples[0].sent) * 10e3 /
Math.max(10e3, now - samples[0].time)
let loaded = size_done
const rows = active.map(job => {
job.speed = average(job.speed, job.loaded - job.prev)
job.prev = job.loaded
loaded += job.loaded
return { job, loaded: job.loaded, speed: job.speed, queued: false }
})
// The start of the queue is shown too. With only the running uploads the
// list changes height all the time, and the widget jumps with it
for (const job of queue.slice(0, 50)) {
rows.push({ job, loaded: 0, speed: 0, queued: true })
}
const uploading = active.length + queue.length > 0
const percent = Math.floor(loaded / size_total * 100) || 0
// There is no sensible estimate while nothing is being sent, nor when it
// is over a hundred days, which is what a stalled connection gives.
// ponytail: estimated from bytes alone, which is too low when small files
// with their overhead per request are mixed with large ones. Weigh in the
// files per second if that turns out to matter
const left = (Math.floor((size_total - loaded) / speed) + 1) * 1000
const eta = !paused && active.length > 0 && left < 100 * 86400e3
? formatDuration(left, left < 60e3 ? 1 : 2)
: ""
view = {
uploading, percent, loaded, speed, eta, rows, files_done, files_total,
running: active.length,
total: size_total,
failed: failed.slice(0, 100),
failed_count: failed.length,
}
// Pages set the title when the user navigates. A title which is not the one
// we set is a new one, the progress goes in front of it
if (document.title !== title) {
page_title = document.title
}
document.title = !uploading ? page_title
: (paused ? `Paused ${percent}% ` : `${percent}% ${eta}`) + "/ " + page_title
// The browser collapses the whitespace in a title, so what we get back
// is not always what we set
title = document.title
} }
const leave_confirmation = (e: BeforeUnloadEvent) => { const leave_confirmation = (e: BeforeUnloadEvent) => {
if (status === "uploading") { if (active.length + queue.length > 0) {
e.preventDefault() e.preventDefault()
return "If you close this page your files will stop uploading. Do you want to continue?"
} else {
return null
} }
} }
</script> </script>
@@ -159,33 +365,94 @@ const leave_confirmation = (e: BeforeUnloadEvent) => {
<svelte:window onbeforeunload={leave_confirmation} /> <svelte:window onbeforeunload={leave_confirmation} />
<input <input
bind:this={file_input_field} bind:this={file_input}
onchange={file_input_change} onchange={file_input_change}
class="upload_input" type="file" name="file" multiple class="upload_input" type="file" name="file" multiple
/> />
{#if visible} {#if visible}
<div class="upload_widget"> <div class="upload_widget bubble">
<div class="header"> <div class="header">
{#if status === "idle"} <div class="grow">
Waiting for files <div class="ellipsis">
{:else if status === "uploading"} {#if !view.uploading}
Uploading files... Done{#if view.failed_count > 0}, {view.failed_count} failed{/if}
{:else if status === "finished"} {:else}
Done {retry !== 0 ? "Connection lost" : paused ? "Paused" : "Uploading"}
{view.percent}%{#if view.running > 0}, {formatDataVolume(view.speed, 3)}/s{/if}{#if view.eta !== ""}, {view.eta}left{/if}
{/if}
</div>
<ProgressBar total={view.total} used={view.loaded} speed={update_interval} animation="linear"/>
</div>
{#if view.uploading}
<Button
flat
icon={paused ? "play_arrow" : "pause"}
title={paused
? "Resume: start uploading the files in the queue again"
: "Pause: finish the uploads which are running, but don't start the files in the queue"}
click={toggle_pause}
/>
<Button
flat icon="stop"
title="Stop: abort the uploads which are running and empty the queue"
click={stop}
/>
{:else}
<Button flat icon="close" title="Close" click={stop}/>
{/if}
<Button
flat
icon={collapsed ? "expand_less" : "expand_more"}
title={collapsed ? "Expand" : "Collapse"}
click={() => collapsed = !collapsed}
/>
</div>
{#if !collapsed}
<div class="stats">
{view.files_done} / {view.files_total} files,
{formatDataVolume(view.loaded, 3)} /
{formatDataVolume(view.total, 3)}
{#if retry !== 0}
<br/>
Trying again every 10 seconds
{/if} {/if}
</div> </div>
<div class="body"> <div class="body">
{#each upload_queue as job, i} {#each view.rows as row (row.job)}
{#if job.status !== "finished"} <div class="row" class:queued={row.queued}>
<UploadProgress <div class="grow">
bind:this={upload_queue[i].component} <div class="ellipsis path" title={row.job.path}>
bind:job={upload_queue[i]} <span dir="ltr">{row.job.path}</span>
finish={finish_upload}
/>
{/if}
{/each}
</div> </div>
{#if row.queued}
{formatDataVolume(row.job.file.size, 3)}
{:else}
{formatDataVolume(row.loaded, 3)} /
{formatDataVolume(row.job.file.size, 3)},
{formatDataVolume(row.speed, 3)}/s
<ProgressBar total={row.job.file.size} used={row.loaded} speed={update_interval} animation="linear"/>
{/if}
</div>
<Button icon="cancel" title="Cancel" click={() => cancel(row.job)}/>
</div>
{/each}
{#each view.failed as file}
<div class="error">
<div class="ellipsis path" title={file.path}>
<span dir="ltr">{file.path}</span>
</div>
{file.message}
</div>
{/each}
{#if view.failed_count > view.failed.length}
<div class="error">
And {view.failed_count - view.failed.length} more
</div>
{/if}
</div>
{/if}
</div> </div>
{/if} {/if}
@@ -200,34 +467,59 @@ const leave_confirmation = (e: BeforeUnloadEvent) => {
position: fixed; position: fixed;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: auto; width: 600px;
min-width: 400px; max-width: calc(100% - 40px);
max-width: 80%;
height: auto;
max-height: 50%; max-height: 50%;
right: 20px; right: 20px;
bottom: 20px; bottom: 20px;
border-radius: 8px;
overflow: hidden; overflow: hidden;
color: var(--body_text_color);
box-shadow: 1px 1px 8px var(--shadow_color); box-shadow: 1px 1px 8px var(--shadow_color);
} }
.header { .header {
flex: 0 0 auto; flex: 0 0 auto;
background: var(--background_color); display: flex;
color: var(--background_text_color); align-items: center;
text-align: center; padding: 0 0 0 8px;
border-bottom: 1px solid var(--separator);
}
.header .ellipsis {
font-size: 1.2em; font-size: 1.2em;
padding: 4px; }
white-space: nowrap; .stats {
text-overflow: ellipsis; flex: 0 0 auto;
overflow: hidden; padding: 4px 8px;
text-align: center;
} }
.body { .body {
flex: 1 1 auto; flex: 1 1 auto;
background: var(--body_color);
color: var(--body_text_color);
overflow-y: auto; overflow-y: auto;
}
.row {
display: flex;
align-items: center;
padding: 2px 8px;
}
.grow {
flex: 1 1 auto;
min-width: 0;
}
.ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
/* A path which does not fit loses its start, the file name is the part which
matters. Text is cut off where it overflows, which is on the left in a box
which runs from right to left. The path inside it still runs left to right */
.path {
direction: rtl;
text-align: left; text-align: left;
} }
.error {
padding: 2px 8px;
background: var(--red_tint);
color: var(--red_color);
overflow-wrap: break-word;
}
</style> </style>
@@ -1,83 +0,0 @@
// Uploads a file to the logged in user's Nova 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
import { fs_path_url, type GenericResponse } from "lib/FilesystemAPI.svelte"
import { get_user } from "lib/NovaAPI"
// code and an error message
export const upload_file = async (
file: Blob,
path: string,
on_progress: (loaded: number, total: number) => void,
on_success: (id: string) => void,
on_error: (code: string, message: string) => void,
) => {
const user = await get_user()
// Check the file size limit. For free accounts it's 20 GB
if (user !== null && user.subscription.file_size_limit === 0) {
user.subscription.file_size_limit = 20e9
}
if (file.size > user.subscription.file_size_limit) {
on_error(
"file_too_large",
"This file is too large. Check out the Pro subscription to increase the file size limit"
)
return
}
console.debug("Uploading file to", fs_path_url(path))
let xhr = new XMLHttpRequest();
xhr.open("PUT", fs_path_url(path) + "?make_parents=true", 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: GenericResponse
if (xhr.status === 429) {
resp = {
value: "too_many_requests",
message: "Too many requests. Please wait a few seconds",
}
} else {
resp = JSON.parse(xhr.response) as GenericResponse
}
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);
return xhr
}
@@ -1,105 +0,0 @@
<script lang="ts">
import { upload_file } from "./UploadFunc";
import ProgressBar from "util/ProgressBar.svelte";
import Button from "layout/Button.svelte"
import type { UploadJob } from "./FSUploadWidget.svelte";
let {
job = $bindable(),
total = $bindable(0),
loaded = $bindable(0),
finish,
}: {
job: UploadJob
total?: number
loaded?: number
finish: () => void
} = $props();
let error_code = $state("")
let error_message = $state("")
let xhr: XMLHttpRequest = null
export const start = () => {
upload_file(
job.file,
job.path,
(prog_loaded, prog_total) => {
loaded = prog_loaded
total = prog_total
},
async () => {
job.status = "finished"
finish()
},
(code, message) => {
if (job.status === "finished") {
return
}
console.log("Upload error", code, message)
error_code = code
error_message = message
job.status = "error"
// We don't send the finished signal so the user can read the error
// messsage and manually dismiss it through the cancel button
},
).then(result => {
xhr = result
job.status = "uploading"
})
}
const cancel = () => {
job.status = "finished"
if (xhr && xhr.abort) {
xhr.abort()
}
xhr = null
finish()
}
</script>
<div class="prog" class:error={job.status === "error"}>
<div class="bar">
{job.file.name}<br/>
{#if error_code !== ""}
{error_message}<br/>
{error_code}<br/>
{/if}
<ProgressBar total={total} used={loaded} speed={500}/>
</div>
<div class="cancel">
<Button icon="cancel" click={cancel}/>
</div>
</div>
<style>
.prog {
display: flex;
flex-direction: row;
width: 100%;
overflow: hidden;
}
.bar {
flex: 1 1 auto;
padding: 2px 4px 1px 4px;
margin: 4px;
border-radius: 4px;
overflow: hidden;
line-break: anywhere;
}
.cancel {
flex: 0 0 content;
display: flex;
justify-content: center;
align-items: center; /* Stop stretching the button */
}
.error {
background: var(--red_tint);
color: var(--red_color);
}
</style>
+9 -12
View File
@@ -128,25 +128,25 @@ onMount(() => {
<track kind="captions"/> <track kind="captions"/>
</audio> </audio>
<div style="text-align: center;"> <div style="text-align: center;">
<button onclick={() => change_track(-1)}><i class="icon">skip_previous</i></button> <button onclick={() => change_track(-1)} title="Previous track"><i class="icon i_skip_previous"></i></button>
<button onclick={() => seek(-10)}><i class="icon">replay_10</i></button> <button onclick={() => seek(-10)} title="Back 10 seconds"><i class="icon i_replay_10"></i></button>
<button onclick={toggle_playback}> <button onclick={toggle_playback} title={playing ? "Pause" : "Play"}>
{#if playing} {#if playing}
<i class="icon">pause</i> <i class="icon i_pause"></i>
{:else} {:else}
<i class="icon">play_arrow</i> <i class="icon i_play_arrow"></i>
{/if} {/if}
</button> </button>
<button onclick={() => seek(10)}><i class="icon">forward_10</i></button> <button onclick={() => seek(10)} title="Forward 10 seconds"><i class="icon i_forward_10"></i></button>
<button onclick={() => change_track(1)}><i class="icon">skip_next</i></button> <button onclick={() => change_track(1)} title="Next track"><i class="icon i_skip_next"></i></button>
</div> </div>
<h2>Tracklist</h2> <h2>Tracklist</h2>
{#each siblings as sibling (sibling.id)} {#each siblings as sibling (sibling.id)}
{#if !sibling.is_hidden()} {#if !sibling.is_hidden()}
<a href={"/d"+fs_encode_path(sibling.path)} class="node" class:playing={sibling.path === $nav.base.path}> <a href={"/d"+fs_encode_path(sibling.path)} class="node" class:button_highlight={sibling.path === $nav.base.path}>
{#if sibling.path === $nav.base.path} {#if sibling.path === $nav.base.path}
<i class="play_arrow icon">play_arrow</i> <i class="play_arrow icon i_play_arrow"></i>
{:else} {:else}
<img src={fs_node_icon(sibling, 64, 64)} class="node_icon" alt="icon"/> <img src={fs_node_icon(sibling, 64, 64)} class="node_icon" alt="icon"/>
{/if} {/if}
@@ -185,7 +185,4 @@ onMount(() => {
.play_arrow { .play_arrow {
margin: 4px; margin: 4px;
} }
.playing {
color: var(--accent_color);
}
</style> </style>
@@ -1,14 +1,11 @@
<script lang="ts"> <script lang="ts">
import type { FSNode } from 'lib/FilesystemAPI.svelte'; import type { FSNode } from 'lib/FilesystemAPI.svelte';
import { run } from 'svelte/legacy';
let { path = [] }: {path: FSNode[]} = $props(); let { path = [] }: {path: FSNode[]} = $props();
let image_uri: string = $state() let { image_uri, image_link } = $derived.by(() => {
let image_link: string = $state() let image_uri: string = null
const update_links = (path: FSNode[]) => { let image_link: string = null
image_uri = null
image_link = null
for (let node of path) { for (let node of path) {
if (node.properties && node.properties.branding_enabled === "true") { if (node.properties && node.properties.branding_enabled === "true") {
if (node.properties.brand_header_image) { if (node.properties.brand_header_image) {
@@ -19,10 +16,8 @@ const update_links = (path: FSNode[]) => {
} }
} }
} }
} return { image_uri, image_link }
run(() => { })
update_links(path)
});
</script> </script>
{#if image_uri} {#if image_uri}
+2 -2
View File
@@ -37,11 +37,11 @@ let {
</table> </table>
<hr/> <hr/>
<button class="button_highlight" onclick={() => node.download()}> <button class="button_highlight" onclick={() => node.download()}>
<i class="icon">download</i> <i class="icon i_download"></i>
<span>Download</span> <span>Download</span>
</button> </button>
<button onclick={() => open_details()}> <button onclick={() => open_details()}>
<i class="icon">help</i> <i class="icon i_help"></i>
<span>Details</span> <span>Details</span>
</button> </button>
</IconBlock> </IconBlock>
@@ -14,23 +14,17 @@ import Torrent from "./Torrent.svelte";
import Zip from "./Zip.svelte"; import Zip from "./Zip.svelte";
import CustomBanner from "./CustomBanner.svelte"; import CustomBanner from "./CustomBanner.svelte";
import type { FSNavigator } from "filesystem/FSNavigator"; import type { FSNavigator } from "filesystem/FSNavigator";
import FsUploadWidget from "filesystem/upload_widget/FSUploadWidget.svelte";
import EditWindow from "filesystem/edit_window/EditWindow.svelte"; import EditWindow from "filesystem/edit_window/EditWindow.svelte";
import DetailsWindow from "filesystem/DetailsWindow.svelte"; import DetailsWindow from "filesystem/DetailsWindow.svelte";
import SearchBar from "filesystem/SearchBar.svelte";
let { let {
nav, nav,
upload_widget,
edit_window, edit_window,
details_window, details_window,
search_bar,
}: { }: {
nav: FSNavigator nav: FSNavigator
upload_widget: FsUploadWidget
edit_window: EditWindow edit_window: EditWindow
details_window: DetailsWindow details_window: DetailsWindow
search_bar: SearchBar
} = $props(); } = $props();
let viewer: any = $state() let viewer: any = $state()
@@ -92,7 +86,7 @@ export const seek = (delta: number) => {
{:else if viewer_type === "dir" && $nav.base.name === ".Trash"} {:else if viewer_type === "dir" && $nav.base.name === ".Trash"}
<TrashBin nav={nav} root_path={$nav.path[$nav.path.length - 2].path}/> <TrashBin nav={nav} root_path={$nav.path[$nav.path.length - 2].path}/>
{:else if viewer_type === "dir"} {:else if viewer_type === "dir"}
<FileManager nav={nav} upload_widget={upload_widget} edit_window={edit_window} search_bar={search_bar}> <FileManager nav={nav} edit_window={edit_window}>
<CustomBanner path={$nav.path}/> <CustomBanner path={$nav.path}/>
</FileManager> </FileManager>
{:else if viewer_type === "audio"} {:else if viewer_type === "audio"}
+3 -5
View File
@@ -52,14 +52,12 @@ export const update = async () => {
// Figure out if there are previous or next files. If not then we disable // Figure out if there are previous or next files. If not then we disable
// swiping controls in that direction // swiping controls in that direction
const siblings = await nav.get_siblings() const siblings = await nav.get_siblings()
for (let i = 0; i < siblings.length; i++) { const i = siblings.findIndex(s => s.name === nav.base.name)
if (siblings[i].name === nav.base.name) {
swipe_prev = i > 0 swipe_prev = i > 0
swipe_next = i < siblings.length-1 swipe_next = i !== -1 && i < siblings.length-1
if (i !== -1) {
preload(siblings[i-1]) preload(siblings[i-1])
preload(siblings[i+1]) preload(siblings[i+1])
break
}
} }
} }
+1 -1
View File
@@ -96,7 +96,7 @@ let magnet = $state("")
</p> </p>
{/if} {/if}
<button onclick={() => node.download()} class="button"> <button onclick={() => node.download()} class="button">
<i class="icon">download</i> <i class="icon i_download"></i>
<span>Download torrent file</span> <span>Download torrent file</span>
</button> </button>
</IconBlock> </IconBlock>
+16 -16
View File
@@ -118,35 +118,35 @@ const video_keydown = (e: KeyboardEvent) => {
<div class="controls"> <div class="controls">
<div class="spacer"></div> <div class="spacer"></div>
<button onclick={() => open_sibling(-1)}> <button onclick={() => open_sibling(-1)} title="Previous file">
<i class="icon">skip_previous</i> <i class="icon i_skip_previous"></i>
</button> </button>
<button onclick={() => seek(-10)}> <button onclick={() => seek(-10)} title="Back 10 seconds">
<i class="icon">replay_10</i> <i class="icon i_replay_10"></i>
</button> </button>
<button onclick={toggle_playback} class="button_highlight"> <button onclick={toggle_playback} class="button_highlight" title={playing ? "Pause" : "Play"}>
{#if playing} {#if playing}
<i class="icon">pause</i> <i class="icon i_pause"></i>
{:else} {:else}
<i class="icon">play_arrow</i> <i class="icon i_play_arrow"></i>
{/if} {/if}
</button> </button>
<button onclick={() => seek(10)}> <button onclick={() => seek(10)} title="Forward 10 seconds">
<i class="icon">forward_10</i> <i class="icon i_forward_10"></i>
</button> </button>
<button onclick={() => open_sibling(1)}> <button onclick={() => open_sibling(1)} title="Next file">
<i class="icon">skip_next</i> <i class="icon i_skip_next"></i>
</button> </button>
<div style="width: 16px; height: 8px;"></div> <div style="width: 16px; height: 8px;"></div>
<button onclick={toggle_mute} class:button_red={player && player.muted}> <button onclick={toggle_mute} class:button_red={player && player.muted} title="Mute">
{#if player && player.muted} {#if player && player.muted}
<i class="icon">volume_off</i> <i class="icon i_volume_off"></i>
{:else} {:else}
<i class="icon">volume_up</i> <i class="icon i_volume_up"></i>
{/if} {/if}
</button> </button>
<button onclick={toggle_fullscreen}> <button onclick={toggle_fullscreen} title="Fullscreen">
<i class="icon">fullscreen</i> <i class="icon i_fullscreen"></i>
</button> </button>
<div class="spacer"></div> <div class="spacer"></div>
</div> </div>
+11 -8
View File
@@ -48,19 +48,22 @@ export const update = async () => {
return return
} }
zip = await resp.json() as ZipEntry const z = await resp.json() as ZipEntry
// Check if the zip has the property which allows separate files to be // Check if the zip has the property which allows separate files to be
// downloaded. If so then we set the download URL for each file // downloaded. If so then we set the download URL for each file. This
if (zip.properties !== undefined) { // happens before the zip becomes state, else every file in the archive
if (zip.properties.includes("read_individual_files")) { // would get a state proxy instead of only the ones which are rendered
if (z.properties !== undefined) {
if (z.properties.includes("read_individual_files")) {
// Set the download URL for each file in the zip // Set the download URL for each file in the zip
recursive_set_url(fs_path_url(node.path)+"?zip_file=", zip) recursive_set_url(fs_path_url(node.path)+"?zip_file=", z)
} }
truncated = zip.properties.includes("truncated") truncated = z.properties.includes("truncated")
} }
uncomp_size = recursive_size(zip) uncomp_size = recursive_size(z)
zip = z
comp_ratio = (uncomp_size / node.file_size) comp_ratio = (uncomp_size / node.file_size)
status = "finished" status = "finished"
} catch (err) { } catch (err) {
@@ -125,7 +128,7 @@ const recursive_size = (file: ZipEntry) => {
</table> </table>
<hr/> <hr/>
<button class="button_highlight" onclick={() => node.download()}> <button class="button_highlight" onclick={() => node.download()}>
<i class="icon">download</i> <i class="icon i_download"></i>
<span>Download</span> <span>Download</span>
</button> </button>
</IconBlock> </IconBlock>
+7 -12
View File
@@ -13,6 +13,7 @@ let { item = {} as ZipEntry }: {
{#if child.children} {#if child.children}
<details bind:open={child.details_open}> <details bind:open={child.details_open}>
<summary> <summary>
<i class="icon {child.details_open ? 'i_folder_open' : 'i_folder'}"></i>
<div class="filename"> <div class="filename">
{name} {name}
( (
@@ -37,6 +38,7 @@ let { item = {} as ZipEntry }: {
{#each Object.entries(item.children) as [name, child]} {#each Object.entries(item.children) as [name, child]}
{#if !child.children} {#if !child.children}
<li> <li>
<i class="icon i_description"></i>
<div class="filename"> <div class="filename">
{name} {name}
( (
@@ -59,19 +61,13 @@ details {
} }
details > summary { details > summary {
list-style-type: none; list-style-type: none;
}
details > summary, li {
display: flex; display: flex;
align-items: center;
} }
details > summary::before { .icon {
font-family: 'Material Icons'; font-size: 1em;
content: 'folder';
}
details[open] > summary::before {
font-family: 'Material Icons';
content: 'folder_open';
}
li::before {
font-family: 'Material Icons';
content: 'description';
} }
ul { ul {
list-style-type: none; list-style-type: none;
@@ -80,7 +76,6 @@ ul {
border-left: 2px solid var(--separator); border-left: 2px solid var(--separator);
} }
.filename { .filename {
display: inline;
margin-left: 0.5em; margin-left: 0.5em;
} }
</style> </style>
-353
View File
@@ -1,353 +0,0 @@
<script>
import Tooltip from "layout/Tooltip.svelte";
import Euro from "util/Euro.svelte";
import OtherPlans from "layout/checkout/SubscriptionPlans.svelte";
import { user } from "lib/UserStore";
</script>
<section>
<p>
Nova features two different payment modes. We offer a monthly
subscription which is managed by Patreon, and a Prepaid subscription
which supports a dozen different payment providers. With Prepaid you pay
in advance to charge your credit, then usage will be subtracted from
your account credit. For low usage Prepaid is usually better as the
monthly fee is much lower.
</p>
</section>
<div class="horizontal_scroll">
<div class="grid">
<div></div>
<div class="top_row free_feat">
<span class="bold">Free</span>
</div>
<div class="top_row pro_feat">
<span class="bold">Pro</span>
</div>
<div class="top_row prepaid_feat">
<span class="bold">Prepaid</span>
</div>
<div class="left_col">
Recurring price
</div>
<div class="feature_cell free_feat">
<span class="bold">None</span>
</div>
<div class="feature_cell pro_feat">
<Tooltip>
{#snippet label()}
<span>
<span class="bold">€4 / month</span> or
<span class="bold">€40 / year</span>
</span>
{/snippet}
The Pro subscription is managed by Patreon. Patreon's own fees
and sales tax will be added to this price. After paying you need
to link your Nova account to Patreon to activate the plan.
</Tooltip>
</div>
<div class="feature_cell prepaid_feat">
<Tooltip>
{#snippet label()}
<span class="bold">€1 / month minimum</span>
{/snippet}
<p>
The minimum fee is only charged when usage is less than €1.
This calculation is per day, the €1 amount is divided by the
number of days in the month and if your usage is lower than
that, you will be charged the minimum fee.
</p>
</Tooltip>
</div>
<div class="left_col">
<a href="/about#toc_3">Transfer limit</a>
</div>
<div class="feature_cell free_feat">
<Tooltip>
{#snippet label()}
<span class="bold">6 GB per day</span>
{/snippet}
<p>
Free users are limited to downloading 6 GB per day, this
limit is linked to your IP address, even if you are logged
in to an account.
</p>
<p>
When the download limit is exceeded the download speed is
reduced to 1 MiB/s. You can have at most three concurrent
downloads running.
</p>
</Tooltip>
</div>
<div class="feature_cell pro_feat">
<Tooltip>
{#snippet label()}
<span class="bold">4 TB per 30 days</span>
{/snippet}
<p>
The transfer limit is used for downloading, sharing and
hotlinking files.
</p>
<p>
Paid plans do not have a concurrent connection limit.
</p>
</Tooltip>
</div>
<div class="feature_cell prepaid_feat">
<Tooltip>
{#snippet label()}
<span class="bold">€1 per TB transferred</span>
{/snippet}
<p>
Prepaid does not have a transfer limit, instead you are
charged for what you use at a rate of €1 per terabyte
downloaded. This applies to downloading your own files,
other people's files and others downloading your files (if
you have hotlinking enabled in your account settings).
</p>
<p>
Paid plans do not have a concurrent connection limit.
</p>
</Tooltip>
</div>
<div class="left_col">
<a href="/about#toc_6">Hotlinking</a>
</div>
<div class="feature_cell free_feat">
<span class="bold">Hotlinking not supported</span><br/>
Hotlinked files get blocked
</div>
<div class="feature_cell span2 right pro_feat">
<span class="bold">Hotlinking supported</span><br/>
Hotlinking uses your transfer limit
</div>
<div class="left_col">
Storage
</div>
<div class="feature_cell span2 left pro_feat">
<span class="bold">No limit</span><br/>
Files expire when they are not downloaded
</div>
<div class="feature_cell prepaid_feat">
<span class="bold">€4 / TB / month</span><br/>
No limit, you pay for what you use
</div>
<div class="left_col">
<a href="/about#toc_1">File expiry</a>
</div>
<div class="feature_cell free_feat">
<Tooltip>
{#snippet label()}
<span class="bold">120 days (4 months)</span>
{/snippet}
<p>
Files expire when they have not been downloaded in the last
120 days. A download is counted when more than 10% of the
whole file was downloaded in a single request.
</p>
</Tooltip>
</div>
<div class="feature_cell pro_feat">
<Tooltip>
{#snippet label()}
<span class="bold">240 days (8 months)</span>
{/snippet}
<p>
The Pro plan has 240 day file expiry. The same rules apply
as the free plan. Higher Patreon subscription plans are
available where files do not expire at all.
</p>
</Tooltip>
</div>
<div class="feature_cell prepaid_feat">
<Tooltip>
{#snippet label()}
<span class="bold">Files do not expire</span>
{/snippet}
<p>
Files don't expire while your Prepaid plan is active. If
your credit runs out you have one week to top up your
balance. If you fail to do so your files will revert to the
regular file expiry rules.
</p>
</Tooltip>
</div>
<div class="left_col">
Download page customization
</div>
<div class="feature_cell free_feat">
<span class="bold">None</span>
</div>
<div class="feature_cell pro_feat">
None
</div>
<div class="feature_cell prepaid_feat">
Theme, background, header and footer image can be customized
</div>
<div class="left_col">
Max file size
</div>
<div class="feature_cell free_feat">
<span class="bold">20 GB</span> per file
</div>
<div class="feature_cell span2 right pro_feat">
<span class="bold">100 GB</span> per file
</div>
<div class="left_col">
Payment processors
</div>
<div class="feature_cell free_feat">
<span class="bold">None</span>
</div>
<div class="feature_cell pro_feat">
<span class="bold">PayPal</span>, <span class="bold">Credit/debit</span>
</div>
<div class="feature_cell prepaid_feat">
<span class="bold">PayPal</span>,
<span class="bold">Bitcoin</span>,
<span class="bold">Litecoin</span>,
<span class="bold">Monero</span>
</div>
<div></div>
<div class="bottom_row free_feat">
Free
</div>
<div class="bottom_row pro_feat">
{#if $user !== null && $user.subscription.id === "patreon_1"}
You have this plan<br/>
Thank you for supporting Nova!
{:else}
<a href="https://www.patreon.com/join/nova/checkout?rid=5736701&cadence=1" class="button button_highlight round">
€ 4 per month
</a>
or
<a href="https://www.patreon.com/join/nova/checkout?rid=5736701&cadence=12" class="button button_highlight round">
€ 40 per year!
</a>
<br/>
(Excluding tax)
<br/>
Subscription managed by Patreon
{/if}
</div>
<div class="bottom_row prepaid_feat">
{#if $user === null}
<!-- User is not logged in -->
Account required<br/>
<a href="/login?redirect=/user/subscription/manage" class="button button_highlight round">
<i class="icon">login</i>
Log in
</a>
or
<a href="/register?redirect=/user/subscription/manage" class="button button_highlight round">
<i class="icon">how_to_reg</i>
Register
</a>
<br/>
Payments processed by Mollie<br/>
No recurring payments
{:else}
<!-- User is logged in -->
{#if $user.subscription.type === ""}
<a href="/user/subscription/manage#deposit" class="button button_highlight round">
Deposit credit
</a>
to activate Prepaid
{:else if $user.subscription.type === "patreon"}
Patreon subscription active. Prepaid cannot be activated
{:else if $user.subscription.type === "prepaid"}
Prepaid subscription is active<br/>
Current balance <Euro amount={$user.balance_micro_eur}/>
<br/>
<a href="/user/subscription/manage#deposit" class="button button_highlight round">
Top up my credit
</a>
{/if}
{/if}
</div>
</div>
</div>
<section>
<h2>Other plans available on Patreon</h2>
<OtherPlans/>
</section>
<style>
.bold {
font-weight: bold;
}
.horizontal_scroll {
overflow-x: scroll;
overflow-y: hidden;
width: 100%;
padding: 10px;
}
.grid {
display: grid;
grid-auto-flow: row;
grid-template-columns: 9em 1fr 1fr 1fr;
min-width: 50em;
max-width: 70em;
gap: 5px;
margin: auto;
}
.grid > div {
justify-content: center;
align-items: center;
align-content: center;
text-align: center;
padding: 0.25em;
min-height: 3em;
}
.left_col {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
border: 1px solid var(--separator);
}
.top_row {
border-top-left-radius: 6px;
border-top-right-radius: 6px;
}
.bottom_row {
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
border: 1px solid var(--separator);
font-weight: bold;
}
.feature_cell {
background-color: var(--card_color);
border: 1px solid var(--background_color);
}
.pro_feat {
border: 1px solid var(--accent_color);
}
.free_feat {
border: 1px solid #ebcb8b;
}
.prepaid_feat {
border: 1px solid #ec2cfa;
}
.span2 {
grid-column: span 2;
}
.span2.left {
border-image: linear-gradient(to right, #ebcb8b 0%, var(--accent_color) 100%) 1;
}
.span2.right {
border-image: linear-gradient(to right, var(--accent_color) 0%, #ec2cfa 100%) 1;
}
</style>
-30
View File
@@ -1,30 +0,0 @@
<script lang="ts">
import Checkout from "layout/checkout/Checkout.svelte";
import { user } from "lib/UserStore";
import LoginRegister from "login/LoginRegister.svelte";
import Euro from "util/Euro.svelte";
</script>
{#if $user !== null}
<div class="page_content">
<section>
{#if $user.subscription.id !== ""}
<p>
You already have the {$user.subscription.name} plan active.
Your account balance is <Euro
amount={$user.balance_micro_eur}/>. Subscriptions are
charged from this balance every day, use the form below to
top it up or to switch to another plan.
</p>
{:else}
<p>
Pick a subscription plan to upgrade your account. Your
account balance is <Euro amount={$user.balance_micro_eur}/>.
</p>
{/if}
<Checkout/>
</section>
</div>
{:else}
<LoginRegister/>
{/if}
+144 -49
View File
@@ -1,58 +1,86 @@
<script> <script lang="ts">
import Footer from "layout/Footer.svelte";
import { drop_target } from "lib/DropTarget";
import GetStarted from "./GetStarted.svelte";
import Pricing from "./Pricing.svelte";
import SubscriptionPlans from "layout/checkout/SubscriptionPlans.svelte"; import SubscriptionPlans from "layout/checkout/SubscriptionPlans.svelte";
import NovaLogo from "util/NovaLogo.svelte"; import NovaLogo from "util/NovaLogo.svelte";
import { user } from "lib/UserStore";
let upload_widget import LoginRegister from "login/LoginRegister.svelte";
import Showcase from "./Showcase.svelte";
import Euro from "util/Euro.svelte";
</script> </script>
<header class="logo_header"> <header class="hero">
<NovaLogo full style="display: block; height: 100px; max-width: 100%; margin: 50px auto;"/> <NovaLogo full style="display: block; height: 100px; max-width: 100%; margin: 50px auto 0 auto;"/>
</header> </header>
<div class="page_content"> <section>
<div class="highlight_yellow"> <div class="highlight_yellow">
This is a development server. All files and accounts may be lost when This is a development server. All files and accounts may be lost when
the final product launches. the final product launches.
</div> </div>
</section>
<section> <section>
<p> <p style="text-align: center;">
Nova.storage is a platform for cost-effective cloud storage and Nova.storage is a platform for cost-effective cloud storage and content
content delivery. We will store and serve your files at an extremely delivery. We store and serve your files at an extremely competitive
competitive rate. rate.
</p> </p>
<h2>Features</h2>
<ul>
<li>
Cloud storage with <a href="/filesystem#toc_7">rclone</a> and
FTPS support
</li>
<li>
Customizable download pages (custom branding colours, header and
background images)
</li>
<li>
Fault tolerance for up to four storage server failures
</li>
<li>
Caching servers highly optimized for long-distance data transfer
</li>
</ul>
<h3>What you don't get</h3>
<ul>
<li>
Data backups - Please keep a local copy of everything you store
in case of emergency
</li>
<li>
Commercial support - I'm busy, please don't bother me
</li>
</ul>
</section> </section>
<div class="highlights">
<div class="bubble">
<h3><i class="icon i_public"></i> Fully European</h3>
<p>
Nova is developed and operated entirely within Europe. With its
headquarters in the Netherlands and hosting in Germany.
</p>
</div>
<div class="bubble">
<h3><i class="icon i_storage"></i> Proven storage engine</h3>
<p>
Pixelstore, the storage engine behind Nova, has been running in
production for more than ten years. It is fine-tuned for
reliability and performance.
</p>
</div>
<div class="bubble">
<h3><i class="icon i_verified_user"></i> Fault-tolerant</h3>
<p>
The storage, database and caching layers all have redundancy built
in. Your files stay available through up to four storage server
failures.
</p>
</div>
<div class="bubble">
<h3>
<i class="icon i_speed"></i>
Highly optimised
</h3>
<p>
Our servers are tuned for high performance transfers over long
distances, so downloads stay fast no matter where you are in the
world.
</p>
</div>
<div class="bubble">
<h3><i class="icon i_hub"></i> Easy integration</h3>
<p>
Connect with the
<a href="https://docs.nova.storage/api/filesystem/">filesystem API</a>,
<a href="https://docs.nova.storage/filesystem/#s3">S3</a>,
<a href="https://docs.nova.storage/filesystem/#ftps">FTPS</a> or
<a href="https://docs.nova.storage/filesystem/#rclone">rclone</a>.
Backup tools, NAS devices and file managers work out of the box.
</p>
</div>
<div class="bubble">
<h3>
<i class="icon i_edit"></i>
Customizable</h3>
<p>
You can make Nova look however you want. Apply your brand colours,
add a custom wallpaper, link back to your own site, you name it.
</p>
</div>
</div> </div>
<header> <header>
@@ -60,19 +88,86 @@ let upload_widget
</header> </header>
<SubscriptionPlans/> <SubscriptionPlans/>
<section>
<p>
Every plan includes a fixed amount of storage and egress. If you need
more, you can turn on
<a href="/user/subscription/metered_billing">usage based billing</a>.
Usage above your plan is then charged from your account balance at these
rates:
</p>
<div class="rates">
<div class="bubble">
<div class="rate"><Euro amount={4e6}/> / TB / month</div>
Storage above your plan
</div>
<div class="bubble">
<div class="rate"><Euro amount={1e6}/> / TB</div>
Egress above your plan
</div>
</div>
</section>
<header>
<h1>Feature showcase</h1>
</header>
<Showcase/>
{#if $user === null}
<header>
<h1>Get started</h1>
</header>
<LoginRegister/>
{/if}
<style> <style>
header { .hero {
padding-top: 20px; padding: 0 8px 20px 8px;
padding-bottom: 20px;
} }
.logo_header { .highlights {
text-align: initial; display: grid;
padding-top: 0; grid-template-columns: repeat(auto-fill, minmax(min(18em, 100%), 1fr));
padding-bottom: 0; gap: 8px;
width: 100%;
max-width: 1000px;
margin: 12px auto;
padding: 0 4px;
}
.highlights > div {
margin: 0;
padding: 0 1em;
}
.highlights h3 {
display: flex;
align-items: center;
gap: 0.4em;
font-size: 1.3em;
border-bottom: none;
}
.highlights .icon {
color: var(--accent_color);
background: var(--accent_shade);
border-radius: 8px;
padding: 0.2em;
}
.rates {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
}
.rates > div {
flex: 0 1 16em;
margin: 0;
padding: 0.5em;
text-align: center;
}
.rate {
font-size: 1.5em;
line-height: 1.5;
} }
header > h1 { header > h1 {
margin-top: 30px; margin-top: 30px;
margin-bottom: 30px; margin-bottom: 30px;
} }
</style> </style>
-182
View File
@@ -1,182 +0,0 @@
<script>
import Euro from "util/Euro.svelte";
import ProgressBar from "util/ProgressBar.svelte";
let nova_storage = $state(0)
let nova_egress = $state(0)
let nova_total = $state(0)
let backblaze_storage = $state(0)
let backblaze_egress = $state(0)
let backblaze_api = $state(0)
let backblaze_total = $state(0)
let wasabi_storage = $state(0)
let wasabi_total = $state(0)
let price_max = $state(0)
let storage = $state(10) // TB
let egress = $state(10) // TB
let avg_file_size = $state(1000) // kB
$effect(() => {
// Nova has a minimum file size of 10kB. Calculate the number of files from
// storage and avg file size, then calculate storage usage based on that.
nova_storage = Math.max(storage * 4, ((storage*10)/avg_file_size)*4)
nova_egress = egress * 1
nova_total = nova_storage + nova_egress
// Egress at Backblaze is free up to three times the amount of storage, then
// it's $10/TB
backblaze_storage = storage * 6
backblaze_egress = Math.max(egress - (storage * 3), 0) * 10
backblaze_api = ((egress * 1e12) / (avg_file_size * 1e3)) * 0.0000004
backblaze_total = backblaze_storage + backblaze_egress + backblaze_api
// Wasabi does not have egress fees
wasabi_storage = storage * 6.99
wasabi_total = (egress > storage) ? 0 : wasabi_storage
price_max = Math.max(nova_total, backblaze_total, wasabi_total)
});
</script>
<h2>Price calculator</h2>
<div class="inputs">
<div>
<div class="usage_label">Storage</div>
<div class="usage_input">
<input type="number" bind:value={storage}/>
<div>TB / month</div>
</div>
</div>
<div>
<div class="usage_label">Egress</div>
<div class="usage_input">
<input type="number" bind:value={egress}/>
<div>TB / month</div>
</div>
</div>
<div>
<div class="usage_label">Average file size</div>
<div class="usage_input">
<input type="number" bind:value={avg_file_size}/>
<div>kB</div>
</div>
</div>
</div>
<div class="bars">
<div>
<div>
Nova.storage - <Euro amount={nova_total*1e6}/> / month<br/>
<Euro amount={nova_storage*1e6}/> storage,
<Euro amount={nova_egress*1e6}/> egress
<ProgressBar used={nova_total} total={price_max}/>
</div>
{#if avg_file_size < 10}
<div>
Nova counts a minimum file size of 10 kB. Files smaller than that
are rounded up to 10 kB.
</div>
{/if}
</div>
<div>
<div>
Backblaze B2 - <Euro symbol="$" amount={backblaze_total*1e6}/> / month<br/>
<Euro symbol="$" amount={backblaze_storage*1e6}/> storage,
<Euro symbol="$" amount={backblaze_egress*1e6}/> egress,
<Euro symbol="$" amount={backblaze_api*1e6}/> API calls
<ProgressBar used={backblaze_total} total={price_max}/>
</div>
</div>
<div>
<div>
Wasabi - <Euro symbol="$" amount={wasabi_total*1e6}/> / month<br/>
<Euro symbol="$" amount={wasabi_storage*1e6}/> storage
<ProgressBar used={wasabi_total} total={price_max}/>
</div>
{#if egress > storage}
<div>
Wasabi does not allow users to download more than their amount
of stored data per month. For this reason Wasabi is excluded
from price calculations when egress is higher than storage.
</div>
{/if}
</div>
</div>
<p>
Note that while Nova.storage might not seem to be the cheapest option in some
cases, most cloud providers have extra hidden costs for API calls and
region-specific prices. This makes it very hard to accurately compare the
pricing of these platforms. Nova.storage includes no hidden costs, I only
charge for storage and egress.
</p>
<p>
Large cloud providers like Amazon, Microsoft and Google are excluded from
this calculation because their pricing is too complex accurately compare
them. Just assume that Nova wil be cheaper.
</p>
<style>
.inputs {
display: flex;
flex-direction: row;
justify-content: center;
gap: 10px;
margin-bottom: 10px;
}
@media(max-width: 700px) {
.inputs {
flex-direction: column;
}
}
.inputs > div {
flex: 1 1 100%;
display: flex;
flex-direction: column;
border-radius: 6px;
overflow: hidden;
border: 2px solid var(--card_color);
}
.usage_label {
flex: 1 1 auto;
text-align: center;
font-size: 1.3em;
padding: 4px;
}
.usage_input {
flex: 1 1 auto;
background: var(--card_color);
display: flex;
flex-direction: row;
align-items: center;
}
.usage_input > input {
flex: 1 1 auto;
background: var(--card_color);
}
.usage_input > div {
flex: 0 0 auto;
background: var(--card_color);
}
.bars {
display: flex;
flex-direction: column;
justify-content: center;
gap: 10px;
}
.bars > div {
flex: 1 1 auto;
display: flex;
flex-direction: column;
border-radius: 6px;
overflow: hidden;
border: 2px solid var(--card_color);
}
.bars > div > div {
padding: 4px;
}
.bars > div > div:first-child {
background: var(--card_color);
}
</style>
+119
View File
@@ -0,0 +1,119 @@
<script lang="ts">
const slides = [
{
image: "download_page",
title: "Download pages",
text: `Share files and directories with a link. Visitors get a fast
download page in your own colours, with your header and background.`,
}, {
image: "access_control",
title: "Access control",
text: `Decide who can read, write and delete, per link, per user and per
password. Passwords double as S3 credentials.`,
}, {
image: "branding",
title: "Branding",
text: `Start from one of the theme presets or pick your own colours,
header image and background image.`,
}, {
image: "image_viewer",
title: "File previews",
text: `Images, videos, audio, PDFs and text files open right in the
browser, and archives can be browsed before downloading.`,
}, {
image: "statistics",
title: "Statistics",
text: `Follow the downloads and data transfer of every file, from the
last day up to five years back.`,
}, {
image: "remote_sync",
title: "Remote sync",
text: `Import from or export to S3, Backblaze B2, Azure, SFTP, FTP,
WebDAV or pixeldrain. Syncs run on our servers, so you can close the
page while they run.`,
},
]
let slider: HTMLDivElement
let current = $state(0)
const show = (i: number) => slider.scrollTo({
left: ((i + slides.length) % slides.length) * slider.clientWidth,
behavior: "smooth",
})
</script>
<div class="page_content showcase">
<div
class="slider"
bind:this={slider}
onscroll={() => current = Math.round(slider.scrollLeft / slider.clientWidth)}
>
{#each slides as slide (slide.image)}
<figure>
<img
src="/res/img/home/{slide.image}.webp"
alt={slide.title}
width="2000"
height="1250"
loading="lazy"
/>
<figcaption>{slide.text}</figcaption>
</figure>
{/each}
</div>
<div class="slider_nav">
<button onclick={() => show(current-1)} title="Previous">
<i class="icon i_chevron_left"></i>
</button>
{#each slides as slide, i (slide.image)}
<button class:button_highlight={i === current} onclick={() => show(i)}>
{slide.title}
</button>
{/each}
<button onclick={() => show(current+1)} title="Next">
<i class="icon i_chevron_right"></i>
</button>
</div>
</div>
<style>
/* Lines up with the cards on the home page, which have 4px of padding on each
side */
.showcase {
width: calc(100% - 8px);
max-width: 992px;
margin: 0 auto 12px auto;
padding: 8px;
}
.slider {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
overscroll-behavior-x: contain;
scrollbar-width: none;
}
.slider::-webkit-scrollbar {
display: none;
}
.slider > figure {
flex: 0 0 100%;
margin: 0;
scroll-snap-align: center;
}
.slider img {
display: block;
width: 100%;
height: auto;
border-radius: 6px;
border: 1px solid var(--separator);
}
.slider figcaption {
padding: 0.5em;
text-align: center;
}
.slider_nav {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
</style>
+1 -1
View File
@@ -1,4 +1,4 @@
<i class="icon star" title="These options require a Persistence (€8) subscription or Prepaid plan to use">star</i> <i class="icon star i_star" title="These options require a Persistence (€8) subscription or Prepaid plan to use"></i>
<style> <style>
.star { .star {
+1 -1
View File
@@ -1,4 +1,4 @@
<i class="icon star" title="These options require a Pro (€4) subscription or Prepaid plan to use">star</i> <i class="icon star i_star" title="These options require a Pro (€4) subscription or Prepaid plan to use"></i>
<style> <style>
.star { .star {
+2 -2
View File
@@ -65,7 +65,7 @@ let click_int = (e: MouseEvent) => {
disabled={disabled ? true:null} disabled={disabled ? true:null}
> >
{#if icon !== ""} {#if icon !== ""}
<i class="icon" class:small={icon_small}>{icon}</i> <i class="icon i_{icon}" class:small={icon_small}></i>
{/if} {/if}
{#if label !== ""} {#if label !== ""}
<span>{label}</span> <span>{label}</span>
@@ -85,7 +85,7 @@ let click_int = (e: MouseEvent) => {
style={style} style={style}
> >
{#if icon !== ""} {#if icon !== ""}
<i class="icon" class:small={icon_small}>{icon}</i> <i class="icon i_{icon}" class:small={icon_small}></i>
{/if} {/if}
{#if label !== ""} {#if label !== ""}
<span>{label}</span> <span>{label}</span>
+1 -1
View File
@@ -54,7 +54,7 @@ export const copy = (e: MouseEvent) => {
title="Copy text to clipboard" title="Copy text to clipboard"
disabled={disabled} disabled={disabled}
> >
<i class="icon">content_copy</i> <i class="icon i_content_copy"></i>
<span> <span>
{#if success} {#if success}
Copied! Copied!
+2 -1
View File
@@ -10,8 +10,9 @@ let {
class:button_highlight={toggle} class:button_highlight={toggle}
style="margin: 0;" style="margin: 0;"
onclick={() => toggle = !toggle} onclick={() => toggle = !toggle}
title="Help"
> >
<i class="icon">help</i> <i class="icon i_help"></i>
</button> </button>
<style> <style>
+6 -10
View File
@@ -23,30 +23,27 @@ import { formatDataVolume, formatDataVolumeBits, formatThousands } from "util/Fo
let { let {
index_field = "", index_field = "",
rows = $bindable([]), rows = [],
columns = [], columns = [],
sort_field = $bindable(index_field), sort_field = index_field,
totals = false totals = false
}: { }: {
index_field?: string; index_field?: string;
rows?: any; rows?: any[];
columns?: SortColumn[]; columns?: SortColumn[];
sort_field?: any; sort_field?: string;
totals?: boolean; totals?: boolean;
} = $props(); } = $props();
let asc = $state(true) let asc = $state(true)
const sort = (field: string) => { const sort = (field: string) => {
if (field !== "" && field === sort_field) { if (field === sort_field) {
asc = !asc asc = !asc
} }
if (field === "") {
field = sort_field
}
sort_field = field sort_field = field
console.log("sorting by", field, "asc", asc) console.log("sorting by", field, "asc", asc)
rows.sort((a, b) => { rows = [...rows].sort((a, b) => {
if (typeof (a[field]) === "number") { if (typeof (a[field]) === "number") {
// Sort ints from high to low // Sort ints from high to low
if (asc) { if (asc) {
@@ -63,7 +60,6 @@ const sort = (field: string) => {
} }
} }
}) })
rows = rows
} }
</script> </script>
+6 -3
View File
@@ -9,6 +9,7 @@ let {
highlight = false, highlight = false,
flat = false, flat = false,
action, action,
title,
children, children,
}: { }: {
on?: boolean; on?: boolean;
@@ -20,6 +21,7 @@ let {
highlight?: boolean; highlight?: boolean;
flat?: boolean; flat?: boolean;
action?: (e: MouseEvent) => void; action?: (e: MouseEvent) => void;
title?: string;
children?: import('svelte').Snippet; children?: import('svelte').Snippet;
} = $props(); } = $props();
@@ -34,6 +36,7 @@ const click = (e: MouseEvent) => {
<button <button
onclick={click} onclick={click}
type="button" type="button"
title={title}
class="button" class="button"
class:button_highlight={highlight} class:button_highlight={highlight}
class:group_first class:group_first
@@ -42,9 +45,9 @@ const click = (e: MouseEvent) => {
class:flat class:flat
> >
{#if on} {#if on}
<i class="icon on">{icon_on}</i> <i class="icon on i_{icon_on}"></i>
{:else} {:else}
<i class="icon off">{icon_off}</i> <i class="icon off i_{icon_off}"></i>
{/if} {/if}
{@render children?.()} {@render children?.()}
</button> </button>
@@ -54,7 +57,7 @@ const click = (e: MouseEvent) => {
flex: 0 0 content; flex: 0 0 content;
} }
.on { .on {
color: var(--accent_color); color: var(--link_color);
} }
.off { .off {
color: var(--red_color); color: var(--red_color);
+1 -1
View File
@@ -13,7 +13,7 @@ const open = () => dialog.open(button.getBoundingClientRect())
</script> </script>
<button bind:this={button} onclick={open} class="button round"> <button bind:this={button} onclick={open} class="button round">
<i class="icon">info</i>{@render label?.()} <i class="icon i_info"></i>{@render label?.()}
</button> </button>
<Dialog bind:this={dialog}> <Dialog bind:this={dialog}>
+5 -5
View File
@@ -171,7 +171,7 @@ const submit = async (e: SubmitEvent) => {
{#if covered} {#if covered}
<button type="submit" class="button_highlight" style="flex-direction: column;"> <button type="submit" class="button_highlight" style="flex-direction: column;">
<i class="icon">shopping_cart</i> <i class="icon i_shopping_cart"></i>
Activate plan {status.subscription.name} Activate plan {status.subscription.name}
({status.months} month{status.months === 1 ? "" : "s"}) ({status.months} month{status.months === 1 ? "" : "s"})
</button> </button>
@@ -203,7 +203,7 @@ const submit = async (e: SubmitEvent) => {
</div> </div>
<button type="submit" class="button_highlight"> <button type="submit" class="button_highlight">
<i class="icon">paid</i> Checkout <i class="icon i_paid"></i> Checkout
</button> </button>
</div> </div>
@@ -259,10 +259,10 @@ const submit = async (e: SubmitEvent) => {
</td> </td>
<td> <td>
{#if p.months === status.months} {#if p.months === status.months}
<i class="icon">check</i> Selected <i class="icon i_check"></i> Selected
{:else} {:else}
<button onclick={() => switch_period(p)}> <button onclick={() => switch_period(p)}>
<i class="icon">swap_horiz</i> Select <i class="icon i_swap_horiz"></i> Select
</button> </button>
{/if} {/if}
</td> </td>
@@ -280,7 +280,7 @@ const submit = async (e: SubmitEvent) => {
<style> <style>
.date { .date {
color: var(--accent_color); color: var(--link_color);
} }
/* layout.css collapses the table borders, which makes the browser ignore any /* layout.css collapses the table borders, which makes the browser ignore any
padding on the table itself. The cells line the table up with the rest of padding on the table itself. The cells line the table up with the rest of
@@ -1,5 +1,4 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { countries } from "country-data-list"; import { countries } from "country-data-list";
import { get_misc_vat_rate, put_user } from "lib/NovaAPI"; import { get_misc_vat_rate, put_user } from "lib/NovaAPI";
import { payment_providers, type CheckoutState } from "./CheckoutLib"; import { payment_providers, type CheckoutState } from "./CheckoutLib";
@@ -59,7 +58,7 @@ const format_country = (c: typeof countries.all[0]) => {
Please pick your country of residence Please pick your country of residence
</div> </div>
<div> <div>
<form onsubmit={preventDefault(set_country)} class="country_form"> <form onsubmit={set_country} class="country_form">
<div class="country_search"> <div class="country_search">
<datalist id="country_picker"> <datalist id="country_picker">
{#each countries.all.filter(c => c.status === "assigned") as c} {#each countries.all.filter(c => c.status === "assigned") as c}
@@ -73,7 +72,7 @@ const format_country = (c: typeof countries.all[0]) => {
placeholder="Search for country" placeholder="Search for country"
style="flex: 1 1 auto;"> style="flex: 1 1 auto;">
<button type="submit" class="button_highlight" style="flex: 0 0 auto;"> <button type="submit" class="button_highlight" style="flex: 0 0 auto;">
<i class="icon">send</i> <i class="icon i_send"></i>
Continue Continue
</button> </button>
</div> </div>
+1 -1
View File
@@ -30,7 +30,7 @@ const submit = async (e: SubmitEvent) => {
<button type="submit" class="button_highlight" style="align-self: end;"> <button type="submit" class="button_highlight" style="align-self: end;">
Continue Continue
<i class="icon">chevron_right</i> <i class="icon i_chevron_right"></i>
</button> </button>
</form> </form>
<hr/> <hr/>
+2 -2
View File
@@ -67,11 +67,11 @@ const cancel = async () => {
<SuccessMessage bind:this={cancel_message}/> <SuccessMessage bind:this={cancel_message}/>
<div class="options"> <div class="options">
<button onclick={extend}> <button onclick={extend}>
<i class="icon">more_time</i> <i class="icon i_more_time"></i>
Extend current plan (credit deposit) Extend current plan (credit deposit)
</button> </button>
<button onclick={cancel}> <button onclick={cancel}>
<i class="icon">cancel</i> <i class="icon i_cancel"></i>
Cancel current plan and return to Free Cancel current plan and return to Free
</button> </button>
</div> </div>
+1 -1
View File
@@ -45,7 +45,7 @@ export type Peer = {
ip: string ip: string
port: number port: number
hostname: string hostname: string
role: string services: string[] | null
reachable: boolean reachable: boolean
unreachable_count: number unreachable_count: number
latency: number latency: number
+4 -1
View File
@@ -12,13 +12,16 @@ export type Bookmark = {
label: string, label: string,
} }
export let bookmarks_failed = writable(false)
export let bookmarks_store = writable<Bookmark[]>( export let bookmarks_store = writable<Bookmark[]>(
[], [],
(set: (value: Bookmark[]) => void) => { (set: (value: Bookmark[]) => void) => {
bookmarks_get().then((bm: Bookmark[]) => { bookmarks_get().then((bm: Bookmark[]) => {
set(bm) set(bm)
}).catch((err: any) => { }).catch((err: any) => {
alert("Could not fetch bookmarks:\n" + JSON.stringify(err)) console.error("Could not fetch bookmarks", err)
bookmarks_failed.set(true)
}) })
}, },
) )
+49 -25
View File
@@ -1,7 +1,11 @@
import type { Upload } from "filesystem/upload_widget/FSUploadWidget.svelte"
export const drop_target = ( export const drop_target = (
node: HTMLElement, node: HTMLElement,
args: { args: {
upload: (files: File[]) => void, // Called as soon as the files are dropped, the promise resolves when
// all the dropped directories have been read
upload: (files: Promise<Upload[]>) => void,
shadow: string | undefined, shadow: string | undefined,
}, },
) => { ) => {
@@ -39,7 +43,7 @@ export const drop_target = (
const dragleave = (e: DragEvent) => { const dragleave = (e: DragEvent) => {
node.style.boxShadow = "" node.style.boxShadow = ""
} }
const drop = async (e: DragEvent) => { const drop = (e: DragEvent) => {
node.style.boxShadow = "" node.style.boxShadow = ""
if (can_upload(e)) { if (can_upload(e)) {
@@ -49,39 +53,59 @@ export const drop_target = (
return return
} }
// if directory support is available // The items are only valid until this function returns, so every entry
if (e.dataTransfer && e.dataTransfer.items && e.dataTransfer.items.length > 0) { // has to be taken out of them before the first await
const files: Upload[] = []
const reads: Promise<void>[] = []
for (let i = 0; i < e.dataTransfer.items.length; i++) { for (let i = 0; i < e.dataTransfer.items.length; i++) {
const entry: FileSystemEntry | null = e.dataTransfer.items[i].webkitGetAsEntry(); const entry = e.dataTransfer.items[i].webkitGetAsEntry()
if (entry !== null) { if (entry !== null) {
read_dir_recursive(entry); reads.push(read_entry(entry, files))
continue continue
} }
const file: File | null = e.dataTransfer.items[i].getAsFile();
// Files which are not on the disk have no entry, like an image
// which is dragged out of another web page
const file = e.dataTransfer.items[i].getAsFile()
if (file !== null) { if (file !== null) {
args.upload([file]); files.push({ file, path: file.name })
continue
} }
} }
} else if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length > 0) { args.upload(Promise.all(reads).then(() => files))
const files: File[] = []
for (let i = 0; i < e.dataTransfer.files.length; i++) {
files.push(e.dataTransfer.files[i])
} }
args.upload(files)
// Adds a file, or all the files in a directory, to the list. The path comes
// from the entry. Firefox also puts it in the file's webkitRelativePath,
// but Chromium leaves that empty for dropped files
const read_entry = async (entry: FileSystemEntry, files: Upload[]) => {
if (entry.isFile) {
files.push({
path: entry.fullPath.slice(1),
file: await new Promise<File>((resolve, reject) =>
(entry as FileSystemFileEntry).file(resolve, reject)
),
})
return
} }
// A reader returns the directory in parts, Chromium gives 100 entries
// at a time. An empty part marks the end
const reader = (entry as FileSystemDirectoryEntry).createReader()
while (true) {
const entries = await new Promise<FileSystemEntry[]>(
(resolve, reject) => reader.readEntries(resolve, reject)
)
if (entries.length === 0) {
return
}
// One at a time on purpose. Chromium asks another process for
// each file, and handles all the answers which have arrived in
// one go. Asking for a whole tree at once is a third faster, but
// freezes the page for seconds: 7 for 100k files
for (const e of entries) {
await read_entry(e, files)
} }
const read_dir_recursive = (item: FileSystemEntry) => {
if (item.isDirectory) {
(item as FileSystemDirectoryEntry).createReader().readEntries(entries => {
entries.forEach(entry => {
read_dir_recursive(entry);
});
});
} else {
(item as FileSystemFileEntry).file(file => {
args.upload([file])
});
} }
} }
+10 -36
View File
@@ -52,10 +52,9 @@ export class FSNode {
user_permissions?: { [index: string]: FSPermissions } user_permissions?: { [index: string]: FSPermissions }
password_permissions?: { [index: string]: FSPermissions } password_permissions?: { [index: string]: FSPermissions }
// Added by us // Only set on the nodes returned by fs_get_trash
original_path?: string
// Indicates whether the file is selected in the file manager deletion_date?: string
fm_selected?: boolean = $state(false)
is_shared = (): boolean => { is_shared = (): boolean => {
return (this.link_permissions !== undefined && this.link_permissions.read === true) || return (this.link_permissions !== undefined && this.link_permissions.read === true) ||
@@ -143,28 +142,10 @@ export type NodeOptions = {
// API methods // API methods
// =========== // ===========
// mkdir only supports the "mode" option export const fs_mkdir = async (path: string) => {
export const fs_mkdir = async (path: string, opts?: NodeOptions) => {
const form = new FormData() const form = new FormData()
form.append("action", "mkdir") form.append("action", "mkdir")
if (opts !== undefined && opts.mode !== undefined) {
form.append("mode", opts.mode.toFixed(0))
}
return await fs_check_response(
await fetch(fs_path_url(path), { method: "POST", body: form })
)
}
export const fs_mkdirall = async (path: string, opts: NodeOptions) => {
const form = new FormData()
form.append("action", "mkdirall")
if (opts && opts.mode) {
form.append("mode", opts.mode.toFixed(0))
}
return await fs_check_response( return await fs_check_response(
await fetch(fs_path_url(path), { method: "POST", body: form }) await fetch(fs_path_url(path), { method: "POST", body: form })
) )
@@ -251,22 +232,15 @@ export const fs_trash = async (path: string) => {
) as GenericResponse ) as GenericResponse
} }
export type TrashEntry = {
node: FSNode;
original_path: string;
deletion_date: string;
};
export const fs_get_trash = async (path: string) => { export const fs_get_trash = async (path: string) => {
let resp = await fs_check_response( const resp = await fs_check_response(
await fetch(fs_path_url(path) + "?trash") await fetch(fs_path_url(path) + "?trash")
) as TrashEntry[] ) as { node: FSNode, original_path: string, deletion_date: string }[]
resp.forEach((entry, index) => {
resp[index].node = Object.assign(new FSNode(), entry.node)
})
return resp // The trash metadata is moved into the node, so the trash can be listed
}; // like the children of a directory
return resp.map(({ node, ...info }) => Object.assign(new FSNode(), node, info))
}
export const fs_search = async (path: string, term: string, limit = 10) => { export const fs_search = async (path: string, term: string, limit = 10) => {
return await fs_check_response( return await fs_check_response(
+30
View File
@@ -95,6 +95,22 @@ export type UserSession = {
creation_time: string, creation_time: string,
last_used_time: string, last_used_time: string,
valid_domains: string[], valid_domains: string[],
// Whether this is the key the list of sessions was requested with
current: boolean,
// What the key is allowed to do
filesystem_read: boolean,
filesystem_write: boolean,
account_read: boolean,
account_write: boolean,
session_read: boolean,
session_write: boolean,
billing_read: boolean,
billing_write: boolean,
// IDs of the directories the key is limited to. Empty means no limit
filesystem_dirs: string[],
} }
// If cached_user is undefined it means that the value is not initialized yet, // If cached_user is undefined it means that the value is not initialized yet,
@@ -192,6 +208,20 @@ export const subscription_periods: SubscriptionPeriod[] = [
// same value the server divides the monthly fee by // same value the server divides the monthly fee by
export const days_per_month = 365.25 / 12 export const days_per_month = 365.25 / 12
// The price of the subscription period the user is in. This is also how far
// the balance can go below zero before usage above the plan is refused
export const period_price = (u: User) => {
const period = subscription_periods.find(p => p.months === u.subscription_months)
return period === undefined ? 0 :
u.subscription.monthly_fee * period.months * period.discount
}
// Whether usage above a limit of the plan is billed instead of refused. price
// is what the plan charges for that usage. The server does the same check in
// billsExtra
export const bills_extra = (u: User, price: number) =>
u.usage_based_billing && price > 0 && u.balance_micro_eur >= -period_price(u)
export const get_misc_subscriptions = async () => { export const get_misc_subscriptions = async () => {
return await check_response( return await check_response(
await fetch(get_endpoint() + "/misc/subscriptions") await fetch(get_endpoint() + "/misc/subscriptions")
+136
View File
@@ -0,0 +1,136 @@
<script lang="ts">
import { onMount } from "svelte";
import { loading_run } from "lib/Loading";
import { check_response, get_endpoint, get_user } from "lib/NovaAPI";
import type { FSNode } from "lib/FilesystemAPI.svelte";
import FilePicker from "filesystem/filemanager/FilePicker.svelte";
// An app sends the user here with an OAuth authorization request in the query
// string. The API gets it exactly as it came in, first to check it and then to
// approve it. Everything this page shows and every address it goes to comes
// out of the API's answer, the page itself never reads the request. The API
// and the browser can disagree about a query with the same parameter in it
// twice, and then the user would approve something else than what they see
const endpoint = get_endpoint() + "/user/oauth/authorize" + window.location.search
// What the app can do with each permission it can ask for
const permissions: {[name: string]: string} = {
filesystem_read: "See and download your files",
filesystem_write: "Upload, change, share and delete your files",
account_read: `See your account details, like your e-mail address and how
much storage you use`,
session_read: "See your API keys, except the ones which can do more than its own",
session_write: "Create API keys",
billing_read: "See your invoices and transactions",
billing_write: "Change your subscription and create invoices",
}
let username = $state("")
let request: {client_name: string, scope: string[], redirect_uri: string} = $state(null)
let errors: string[] = $state([])
// The directories the user limits the app to. With none the app can use all
// files
let dirs: FSNode[] = $state([])
let picker: FilePicker = $state()
const pick = (nodes: FSNode[]) => {
if (!dirs.some(dir => dir.id === nodes[0].id)) {
dirs.push(nodes[0])
}
}
const authorize = async (method: string) => {
try {
// The directories go in the body. The query is what the app asks for,
// and the API refuses a request which has them in there
const body = method !== "POST" ? undefined : new URLSearchParams({
filesystem_dirs: JSON.stringify(dirs.map(dir => dir.id)),
})
return await loading_run(async () => check_response(
await fetch(endpoint, {method: method, body: body})
))
} catch (err) {
// A request with several things wrong with it comes back as a list
errors = (err.errors ?? [err]).map((e: any) =>
(e.message ?? e) + (e.extra?.field ? " (" + e.extra.field + ")" : "")
)
request = null
}
}
const approve = async () => {
const approved = await authorize("POST")
if (approved !== undefined) {
window.location.href = approved.redirect_uri
}
}
onMount(async () => {
username = (await get_user()).username
request = await authorize("GET")
})
</script>
<div class="page_content">
<section>
{#if errors.length !== 0}
<h2>This app can't be given access</h2>
{#each errors as error}
<p>{error}</p>
{/each}
{:else if request}
<h2>{request.client_name} wants access to your account</h2>
<p>
You are logged in as {username}. If you approve,
{request.client_name} will be able to:
</p>
<ul>
{#each request.scope as name}
<li>{permissions[name]}</li>
{/each}
</ul>
{#if request.scope.some(name => name.startsWith("filesystem_"))}
{#if dirs.length === 0}
<p>
That goes for all your files. You can limit
{request.client_name} to the directories you pick.
</p>
{:else}
<p>{request.client_name} can only use the files in:</p>
<ul>
{#each dirs as dir, index (dir.id)}
<li>
{dir.path}
<button onclick={() => dirs.splice(index, 1)} title="Remove">
<i class="icon i_close"></i>
</button>
</li>
{/each}
</ul>
{/if}
<p>
<button onclick={() => picker.open("/me")}>
<i class="icon i_folder"></i>
{dirs.length === 0 ? "Pick directories" : "Add a directory"}
</button>
</p>
{/if}
<p>
You can take the access away again by deleting the key of the
app on the <a href="/user/api_keys">API keys page</a>.
</p>
<button class="button_highlight" onclick={approve}>
<i class="icon i_check"></i> Approve
</button>
<!-- For a request which was not approved the address has an error
in it, which tells the app that the user said no -->
<a class="button" href={request.redirect_uri} rel="external">
<i class="icon i_close"></i> Deny
</a>
{/if}
</section>
</div>
<FilePicker bind:this={picker} callback={pick} directories/>
+7 -5
View File
@@ -1,9 +1,11 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher, onMount } from "svelte"; import { onMount } from "svelte";
import Form, { type FormConfig } from "util/Form.svelte" import Form, { type FormConfig } from "util/Form.svelte"
import { check_response, get_endpoint } from "lib/NovaAPI"; import { check_response, get_endpoint } from "lib/NovaAPI";
let dispatch = createEventDispatcher() let { on_login }: {
on_login?: (login: {key: string}) => void;
} = $props();
const form_login: FormConfig = { const form_login: FormConfig = {
fields: [ fields: [
@@ -21,7 +23,7 @@ const form_login: FormConfig = {
login.` login.`
}, },
], ],
submit_label: `<i class="icon">send</i> Login`, submit_label: `<i class="icon i_send"></i> Login`,
on_submit: async (fields) => { on_submit: async (fields) => {
username = fields.username username = fields.username
password = fields.password password = fields.password
@@ -37,7 +39,7 @@ const form_otp: FormConfig = {
description: `Please enter the one-time password from your authenticator app` description: `Please enter the one-time password from your authenticator app`
}, },
], ],
submit_label: `<i class="icon">send</i> Login`, submit_label: `<i class="icon i_send"></i> Login`,
on_submit: async (fields) => { on_submit: async (fields) => {
totp = fields.totp totp = fields.totp
return await login() return await login()
@@ -100,7 +102,7 @@ const login = async (e?: SubmitEvent) => {
} }
} }
dispatch("login", {key: resp.auth_key}) on_login?.({key: resp.auth_key})
if (typeof login_redirect === "string" && login_redirect.startsWith("/")) { if (typeof login_redirect === "string" && login_redirect.startsWith("/")) {
console.debug("redirecting user to requested path", login_redirect) console.debug("redirecting user to requested path", login_redirect)
+11 -4
View File
@@ -10,21 +10,21 @@ let page = $state("login")
</script> </script>
<div class="tab_bar"> <div class="tab_bar">
<button onclick={() => page = "login"} class:button_highlight={page === "login"}> <button onclick={() => page = "login"} class:button_highlight={page === "login"}>
<i class="icon small">login</i> <i class="icon small i_login"></i>
<span>Login</span> <span>Login</span>
</button> </button>
<button onclick={() => page = "register"} class:button_highlight={page === "register"}> <button onclick={() => page = "register"} class:button_highlight={page === "register"}>
<i class="icon small">how_to_reg</i> <i class="icon small i_how_to_reg"></i>
<span>Register</span> <span>Register</span>
</button> </button>
</div> </div>
<div class="page_content"> <div class="page_content">
{#if page === "login"} {#if page === "login"}
<Login on:login={finish_login}/> <Login on_login={finish_login}/>
{:else if page === "register"} {:else if page === "register"}
<Register on:login={finish_login}/> <Register/>
{/if} {/if}
</div> </div>
@@ -35,4 +35,11 @@ let page = $state("login")
font-size: 1.3em; font-size: 1.3em;
justify-content: center; justify-content: center;
} }
.page_content {
margin-top: 0; /* Attach the buttons to the body */
width: calc(100% - 8px);
max-width: 992px;
margin: 0 auto 12px auto;
padding: 8px;
}
</style> </style>
+1 -1
View File
@@ -27,7 +27,7 @@ let form: FormConfig = {
"prevent you from logging into your new account" "prevent you from logging into your new account"
}, },
], ],
submit_label: `<i class="icon">send</i> Register`, submit_label: `<i class="icon i_send"></i> Register`,
on_submit: async fields => { on_submit: async fields => {
if (fields.password !== fields.password2) { if (fields.password !== fields.password2) {
return { return {
+4
View File
@@ -0,0 +1,4 @@
import App from "wrap/App.svelte";
import { mount } from "svelte";
mount(App, { target: document.body });
+401 -144
View File
@@ -1,187 +1,444 @@
<script> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { onMount } from "svelte";
import { loading_finish, loading_start } from "lib/Loading"; import { loading_run } from "lib/Loading";
import { check_response, dict_to_form, get_endpoint, type UserSession } from "lib/NovaAPI";
import { fs_get_node, type FSNode } from "lib/FilesystemAPI.svelte";
import FilePicker from "filesystem/filemanager/FilePicker.svelte";
import { formatDate } from "util/Formatting"; import { formatDate } from "util/Formatting";
import CopyButton from 'layout/CopyButton.svelte'; import CopyButton from "layout/CopyButton.svelte";
import NovaLogo from "util/NovaLogo.svelte"; import NovaLogo from "util/NovaLogo.svelte";
let loaded = $state(false) // Each part of the API has a read and a write permission
let rows = $state([]) const components: [string, string, keyof UserSession, keyof UserSession][] = [
["Files", "i_folder", "filesystem_read", "filesystem_write"],
["Account", "i_person", "account_read", "account_write"],
["API keys", "i_vpn_key", "session_read", "session_write"],
["Billing", "i_receipt", "billing_read", "billing_write"],
]
let keys: UserSession[] = $state([])
// The keys which are shown in full, the others are masked
let shown: {[key: string]: boolean} = $state({})
// Names of the directories which keys are limited to, by directory ID
let dir_names: {[id: string]: string} = $state({})
// The keys of which the whole user agent is shown
let agent_shown: {[key: string]: boolean} = $state({})
// The key which is being edited, and what its permissions and directories are
// going to be. Nothing changes until it is saved
let editing = $state("")
let edit_perms: {[name: string]: boolean} = $state({})
let edit_dirs: string[] = $state([])
let picker: FilePicker = $state()
const edit_key = (key: UserSession) => {
editing = key.auth_key
edit_dirs = [...key.filesystem_dirs]
edit_perms = {}
for (const [, , read, write] of components) {
edit_perms[read] = key[read] as boolean
edit_perms[write] = key[write] as boolean
}
}
const pick_dir = (nodes: FSNode[]) => {
const dir = nodes[0]
dir_names[dir.id] = dir.name
if (!edit_dirs.includes(dir.id)) {
edit_dirs.push(dir.id)
}
}
const save_key = async () => {
try {
await loading_run(async () => check_response(
await fetch(get_endpoint() + "/user/session", {
method: "PUT",
body: dict_to_form({
auth_key: editing,
...edit_perms,
filesystem_dirs: edit_dirs,
}),
})
))
} catch (err) {
alert("Failed to change key: " + (err.message ?? err))
return
}
editing = ""
await load_keys()
}
// Intl.RelativeTimeFormat is the browser's formatter for "5 minutes ago", it
// takes care of the plurals
const relative = new Intl.RelativeTimeFormat("en", {numeric: "always", style: "short"})
// The server records the use of a key once per hour, so for the last used time
// anything more exact than that would be made up
const ago = (time: string) => {
const seconds = (Date.now() - Date.parse(time)) / 1000
if (seconds >= 86400) {
return relative.format(-Math.floor(seconds / 86400), "day")
} else if (seconds >= 3600) {
return relative.format(-Math.floor(seconds / 3600), "hour")
} else if (seconds >= 60) {
return relative.format(-Math.floor(seconds / 60), "minute")
}
return "just now"
}
const load_keys = async () => { const load_keys = async () => {
loading_start()
try { try {
const resp = await fetch(window.api_endpoint+"/user/session") const resp: UserSession[] = await loading_run(async () => check_response(
if(resp.status >= 400) { await fetch(get_endpoint() + "/user/session")
let json = await resp.json() ))
if (json.value === "authentication_failed") {
window.location = "/login" // The key of this session goes first, then the most recently used ones
return keys = resp.sort((a, b) =>
} else { Number(b.current) - Number(a.current) ||
throw new Error(json.message) Date.parse(b.last_used_time) - Date.parse(a.last_used_time)
} )
}
rows = await resp.json()
rows.forEach(row => {
row.creation_date = new Date(row.creation_time)
row.last_used_date = new Date(row.last_used_time)
})
rows.sort((a, b) => {
return b.last_used_date - a.last_used_date
});
} catch (err) { } catch (err) {
alert(err) alert("Failed to load API keys: " + (err.message ?? err))
} finally { return
loading_finish() }
loaded = true
for (const id of new Set(keys.flatMap(key => key.filesystem_dirs))) {
if (dir_names[id] === undefined) {
// If the directory is gone the ID is shown instead
fs_get_node("/" + id).then(p => dir_names[id] = p.path[0].name, () => {})
}
}
} }
};
const create_key = async () => { const create_key = async () => {
loading_start()
try { try {
let form = new FormData() // Keys are made to be put in other programs, where they can leak. With
form.append("app_name", "website keys page") // account write a key can change the password and the e-mail address,
// which is enough to take the account over, so these don't get it
const resp = await fetch( const key: UserSession = await loading_run(async () => check_response(
window.api_endpoint+"/user/session", await fetch(get_endpoint() + "/user/session", {
{
method: "POST", method: "POST",
body: form, body: dict_to_form({
} app_name: "website keys page",
); account_write: false,
if(resp.status >= 400) { }),
throw new Error(await resp.text()); })
} ))
shown[key.auth_key] = true
} catch (err) { } catch (err) {
alert("Failed to create new API key! "+err) alert("Failed to create new API key: " + (err.message ?? err))
} finally {
loading_finish()
} }
load_keys(); await load_keys()
}
const delete_key = async (key: UserSession) => {
if (key.current && !confirm(
"This is the key you are logged in with. Deleting it logs you out. Continue?"
)) {
return
} }
const logout = async (key) => {
loading_start()
try { try {
const resp = await fetch( // A key is deleted by logging out with it
window.api_endpoint+"/user/session", await loading_run(async () => check_response(
{ await fetch(get_endpoint() + "/user/session", {
method: "DELETE", method: "DELETE",
headers: { headers: {"Authorization": "Basic " + btoa(":" + key.auth_key)},
"Authorization": "Basic "+btoa(":"+key), })
} ))
}
);
if(resp.status >= 400) {
throw new Error(await resp.text());
}
} catch (err) { } catch (err) {
alert("Failed to delete key: "+err) alert("Failed to delete key: " + (err.message ?? err))
} finally {
loading_finish()
} }
load_keys(); if (key.current) {
window.location.href = "/login"
} else {
await load_keys()
} }
}
onMount(load_keys)
</script> </script>
<section> <section>
{#if !loaded}
<div class="highlight_yellow">
<h2>Warning</h2>
<p> <p>
API keys are sensitive information. They can be used to gain API keys give apps access to your account. Whoever has a key can do
full control over your account. Do not show your API keys to everything the key is allowed to do, so don't show them to someone or
someone or something you don't trust! something you don't trust. A key expires 30 days after it was last used.
If you think someone is using your account without your permission,
delete all your keys and change your password.
</p> </p>
<button class="button_red" onclick={load_keys}>
<i class="icon">lock_open</i> Show API keys <div class="toolbar">
</button>
</div>
{:else}
<div class="toolbar" style="text-align: left;">
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<button onclick={create_key}> <button onclick={create_key}>
<i class="icon">add</i> Create new API key <i class="icon i_add"></i> Create new API key
</button> </button>
</div> </div>
{#each keys as key (key.auth_key)}
<div class="key" class:current={key.current}>
<div class="row">
<span class="app">
{#if key.app_name === "website login"}
<NovaLogo style="height: 1.5em;"/> Nova website
{:else if key.app_name === "website keys page"}
<i class="icon i_vpn_key"></i> Created on this page
{:else if key.app_name === "sharex"}
<img src="/res/img/sharex.png" alt=""/> ShareX
{:else if key.app_name === "jdownloader"}
<img src="/res/img/jdownloader.png" alt=""/> JDownloader
{:else}
<i class="icon i_apps"></i> {key.app_name || "Unnamed key"}
{/if}
</span>
{#if key.current}
<span class="badge">This session</span>
{/if}
<div class="toolbar_spacer"></div>
<!-- Not the session which is in use. Without its permissions
this page and the rest of the website stop working -->
{#if !key.current && editing !== key.auth_key}
<button onclick={() => edit_key(key)}>
<i class="icon i_edit"></i> Edit
</button>
{/if}
<button class="button_red" onclick={() => delete_key(key)}>
<i class="icon i_delete"></i> Delete
</button>
</div>
<div class="row">
<code>
{shown[key.auth_key] ? key.auth_key : key.auth_key.slice(0, 8) + "-••••-••••-••••-••••••••••••"}
</code>
<button
class:button_highlight={shown[key.auth_key]}
onclick={() => shown[key.auth_key] = !shown[key.auth_key]}
>
<i class="icon {shown[key.auth_key] ? 'i_visibility_off' : 'i_visibility'}"></i>
{shown[key.auth_key] ? "Hide" : "Show"}
</button>
<CopyButton text={key.auth_key}>Copy</CopyButton>
</div>
{#if editing === key.auth_key}
<div class="edit">
{#each components as [name, icon, read, write]}
<div class="row">
<span class="name"><i class="icon small {icon}"></i> {name}</span>
<label>
<input type="checkbox" bind:checked={edit_perms[read]}/> read
</label>
<!-- Account write can be taken away from a key, but
not given to one -->
{#if write !== "account_write" || key.account_write}
<label>
<input type="checkbox" bind:checked={edit_perms[write]}/> write
</label>
{/if}
</div>
{/each}
<div class="row">
{#if edit_dirs.length === 0}
<span>Files access is not limited to directories</span>
{:else}
<span>Files access is limited to</span>
{#each edit_dirs as id, index (id)}
<span>
<i class="icon small i_folder"></i>{dir_names[id] ?? id}
<button onclick={() => edit_dirs.splice(index, 1)} title="Remove">
<i class="icon small i_close"></i>
</button>
</span>
{/each}
{/if}
<button onclick={() => picker.open("/me")}>
<i class="icon i_folder"></i>
{edit_dirs.length === 0 ? "Limit to a directory" : "Add a directory"}
</button>
</div>
<div class="row">
<button class="button_highlight" onclick={save_key}>
<i class="icon i_save"></i> Save
</button>
<button onclick={() => editing = ""}>
<i class="icon i_close"></i> Cancel
</button>
</div>
</div>
{:else}
<div class="row permissions">
{#each components as [name, icon, read, write]}
<span class:none={!key[read] && !key[write]}>
<i class="icon small {icon}"></i>
{name}:
{#if key[read] && key[write]}
read / write
{:else if key[read]}
read only
{:else if key[write]}
write only
{:else}
no access
{/if}
</span>
{/each}
</div>
{#if key.filesystem_dirs.length !== 0}
<div class="row">
<span>Files access is limited to</span>
{#each key.filesystem_dirs as id}
<a href="/d/{id}"><i class="icon small i_folder"></i>{dir_names[id] ?? id}</a>
{/each}
</div>
{/if}
{/if} {/if}
<p> <div class="details">
If you delete the API key that you are currently using you will be <div>
logged out of your account. Keys are sorted based on how recently they <span>Created</span>
were used, so your session usually the top one. API keys expire 30 days {formatDate(key.creation_time, true, true, false)}
after the last time they're used. If you think someone is using your ({ago(key.creation_time)})
account without your authorization it's probably a good idea to delete
all your keys.
</p>
</section>
<div class="table_scroll">
<table style="text-align: left;">
<thead>
<tr>
<td>Key</td>
<td>Created</td>
<td>Last used ▼</td>
<td>IP address</td>
<td></td>
</tr>
</thead>
<tbody>
{#each rows as row (row.auth_key)}
<tr style="border-bottom: none;">
<td>
<CopyButton text={row.auth_key} small_icon>Copy</CopyButton>
{row.auth_key}
</td>
<td>{formatDate(row.creation_time, true, true, false)}</td>
<td>{formatDate(row.last_used_time, true, true, false)}</td>
<td>{row.creation_ip_address}</td>
<td>
<button onclick={(e) => {e.preventDefault();logout(row.auth_key)}} class="button button_red round">
<i class="icon">delete</i>
</button>
</td>
</tr>
<tr>
<td colspan="1">
{#if row.app_name === "website login"}
<NovaLogo style="height: 1.6em; vertical-align: middle;"/>
Nova website
{:else if row.app_name === "website keys page"}
<i class="icon">vpn_key</i>
Nova keys page
{:else if row.app_name === "sharex"}
<img src="/res/img/sharex.png" alt="ShareX logo" class="app_icon"/>
ShareX
{:else if row.app_name === "jdownloader"}
<img src="/res/img/jdownloader.png" alt="JDownloader logo" class="app_icon"/>
JDownloader
{:else}
Unknown app: {row.app_name}
{/if}
</td>
<td colspan="4">User-Agent: {row.user_agent}</td>
</tr>
{/each}
</tbody>
</table>
<br/>
</div> </div>
<div>
<span>Last used</span>
{formatDate(key.last_used_time, true, true, false)}
({ago(key.last_used_time)})
</div>
<div>
<span>IP address</span>
{key.creation_ip_address}
</div>
<div class="agent" class:agent_shown={agent_shown[key.auth_key]}>
<span>User agent</span>
<button
aria-expanded={!!agent_shown[key.auth_key]}
onclick={() => agent_shown[key.auth_key] = !agent_shown[key.auth_key]}
>
{key.user_agent}
</button>
</div>
</div>
</div>
{/each}
</section>
<FilePicker bind:this={picker} callback={pick_dir} directories/>
<style> <style>
.toolbar { .toolbar {
display: flex; display: flex;
flex-direction: row;
width: 100%;
} }
.toolbar > * { flex: 0 0 auto; } .toolbar_spacer {
.toolbar_spacer { flex: 1 1 auto; } flex: 1 1 auto;
}
.app_icon { .key {
height: 1.6em; margin: 0.8em 0;
vertical-align: middle; padding: 0.4em 0.6em;
border-radius: 8px;
border-left: 3px solid var(--separator);
background: var(--card_color);
}
.key.current {
border-left-color: var(--accent_color);
}
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.2em 0.5em;
margin: 0.3em 0;
}
/* An icon with text next to it. Flex centres the two on each other, inline
layout would put the icon on the baseline of the text */
.app,
.permissions > span,
.row > a,
.edit label,
.edit span {
display: inline-flex;
align-items: center;
gap: 0.3em;
}
/* The name of a permission, in front of its checkboxes */
.name {
min-width: 6em;
}
.app {
font-size: 1.1em;
}
.app > img {
height: 1.5em;
}
.badge {
padding: 0 0.6em;
border-radius: 1em;
color: var(--link_color);
background: var(--accent_shade);
}
/* The key takes the space the buttons leave, and is cut off when it doesn't
fit. It can still be copied in full */
code {
flex: 1 1 10em;
padding: 0.3em 0.5em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.permissions > span {
padding: 0.1em 0.5em;
border: 1px solid var(--separator);
border-radius: 6px;
}
.none,
.details span {
opacity: 0.6;
}
/* Each detail is a label with its value below it */
.details {
display: flex;
flex-wrap: wrap;
gap: 0.2em 1.5em;
font-size: 0.9em;
}
.details > div {
display: flex;
flex-direction: column;
}
/* The user agent gets the space which is left, and is cut off until it is
clicked. It's a button so it works with a keyboard too, without the looks of
one */
.agent {
flex: 1 1 10em;
min-width: 0;
}
.agent > button {
all: unset;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.agent_shown {
flex-basis: 100%;
}
.agent_shown > button {
white-space: normal;
overflow-wrap: anywhere;
} }
</style> </style>
+4 -4
View File
@@ -9,7 +9,7 @@ import { user } from "lib/UserStore";
let affiliate_link = $derived( let affiliate_link = $derived(
window.location.protocol+"//"+window.location.host + window.location.protocol+"//"+window.location.host +
"?ref=" + encodeURIComponent($user.username) "/user?ref=" + encodeURIComponent($user.username)
) )
let affiliate_deny = $state(false) let affiliate_deny = $state(false)
onMount(() => { onMount(() => {
@@ -74,7 +74,7 @@ let account_settings: FormConfig = $derived({
separator: true, separator: true,
}, },
], ],
submit_label: `<i class="icon">save</i> Save`, submit_label: `<i class="icon i_save"></i> Save`,
on_submit: async fields => { on_submit: async fields => {
if (fields.password_new1 != fields.password_new2) { if (fields.password_new1 != fields.password_new2) {
return { return {
@@ -122,7 +122,7 @@ let affiliate_settings: FormConfig = $derived({
extra.`, extra.`,
}, },
], ],
submit_label: `<i class="icon">save</i> Save`, submit_label: `<i class="icon i_save"></i> Save`,
on_submit: async fields => { on_submit: async fields => {
const form = new FormData() const form = new FormData()
form.append("affiliate_user_name", fields.affiliate_user_name) form.append("affiliate_user_name", fields.affiliate_user_name)
@@ -167,7 +167,7 @@ let delete_account: FormConfig = {
}, },
], ],
submit_red: true, submit_red: true,
submit_label: `<i class="icon">delete</i> Delete`, submit_label: `<i class="icon i_delete"></i> Delete`,
on_submit: async fields => { on_submit: async fields => {
const resp = await fetch( const resp = await fetch(
get_endpoint()+"/user", get_endpoint()+"/user",
+4 -4
View File
@@ -67,13 +67,13 @@ onMount(() => {
<h3>{month_str}</h3> <h3>{month_str}</h3>
<div class="toolbar"> <div class="toolbar">
<button onclick={last_month}> <button onclick={last_month}>
<i class="icon">chevron_left</i> <i class="icon i_chevron_left"></i>
Previous month Previous month
</button> </button>
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<button onclick={next_month}> <button onclick={next_month}>
Next month Next month
<i class="icon">chevron_right</i> <i class="icon i_chevron_right"></i>
</button> </button>
</div> </div>
@@ -119,13 +119,13 @@ onMount(() => {
{#if data.length > 100} {#if data.length > 100}
<div class="toolbar"> <div class="toolbar">
<button onclick={last_month}> <button onclick={last_month}>
<i class="icon">chevron_left</i> <i class="icon i_chevron_left"></i>
Previous month Previous month
</button> </button>
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<button onclick={next_month}> <button onclick={next_month}>
Next month Next month
<i class="icon">chevron_right</i> <i class="icon i_chevron_right"></i>
</button> </button>
</div> </div>
{/if} {/if}
+4 -8
View File
@@ -74,10 +74,10 @@ const deny = () => {
<Modal bind:this={modal} title="Affiliate sponsoring request" width="700px"> <Modal bind:this={modal} title="Affiliate sponsoring request" width="700px">
<section> <section>
<p> <p>
Hi! {referral} wants you to sponsor their Nova account. This Hi! {referral} wants you to sponsor their Nova account. This will
will give them €0.50 every month in Nova prepaid credit. They give them €0.01 every day in Nova prepaid credit. They can use this
can use this credit to get a discount on their file storage and credit to get a discount on their file storage and sharing costs.
sharing costs. Here is a short summary of what this entails: Here is a short summary of what this entails:
</p> </p>
<ul> <ul>
<li> <li>
@@ -97,10 +97,6 @@ const deny = () => {
You can change who you are sponsoring at any time on your <a You can change who you are sponsoring at any time on your <a
href="/user/settings">account settings page</a>. href="/user/settings">account settings page</a>.
</li> </li>
<li>
If you want to know more about the affiliate program check out
the <a href="/about#toc_12">Q&A page</a>.
</li>
</ul> </ul>
<p> <p>
If you click 'Accept' then the requested affiliate code will be If you click 'Accept' then the requested affiliate code will be
+4 -4
View File
@@ -52,7 +52,7 @@ let app_name = $derived(() => {
<!-- Show a back button if an app is selected --> <!-- Show a back button if an app is selected -->
{#if app_name} {#if app_name}
<a href="/user/connect_app" class="button"> <a href="/user/connect_app" class="button">
<i class="icon">arrow_back</i> <i class="icon i_arrow_back"></i>
Back to apps Back to apps
</a> </a>
{/if} {/if}
@@ -92,7 +92,7 @@ let app_name = $derived(() => {
{#if !api_key} {#if !api_key}
<div class="center"> <div class="center">
<button class="button_highlight" onclick={create_key}> <button class="button_highlight" onclick={create_key}>
<i class="icon">add</i> <i class="icon i_add"></i>
Generate key Generate key
</button> </button>
</div> </div>
@@ -102,7 +102,7 @@ let app_name = $derived(() => {
<div class="copy_container"> <div class="copy_container">
<CopyButton text={api_key}>Copy key to clipboard</CopyButton> <CopyButton text={api_key}>Copy key to clipboard</CopyButton>
<button onclick={toggle_show_key} class="copy_button" class:button_highlight={show_key !== ""}> <button onclick={toggle_show_key} class="copy_button" class:button_highlight={show_key !== ""}>
<i class="icon">visibility</i> <i class="icon i_visibility"></i>
{#if show_key === ""} {#if show_key === ""}
Show key Show key
{:else} {:else}
@@ -146,7 +146,7 @@ let app_name = $derived(() => {
<div class="center"> <div class="center">
<a href="/misc/sharex/nova.storage.sxcu" class="button button_highlight"> <a href="/misc/sharex/nova.storage.sxcu" class="button button_highlight">
<i class="icon small">save</i> <i class="icon small i_save"></i>
Download ShareX Uploader Download ShareX Uploader
</a> </a>
</div> </div>
+20 -8
View File
@@ -2,6 +2,7 @@
import ProgressBar from "util/ProgressBar.svelte"; import ProgressBar from "util/ProgressBar.svelte";
import { formatDataVolume, formatEuros } from "util/Formatting" import { formatDataVolume, formatEuros } from "util/Formatting"
import { user } from "lib/UserStore"; import { user } from "lib/UserStore";
import { bills_extra } from "lib/NovaAPI";
let { total = 0, used = 0 }: { let { total = 0, used = 0 }: {
total?: number; total?: number;
@@ -10,12 +11,15 @@ let { total = 0, used = 0 }: {
let frac = $derived(used / total) let frac = $derived(used / total)
let bill_shock = $derived($user !== null && $user.monthly_transfer_cap === total) let bill_shock = $derived($user !== null && $user.monthly_transfer_cap === total)
let billable = $derived($user !== null && $user.subscription.price_per_tb_bandwidth > 0) let price = $derived($user === null ? 0 : $user.subscription.price_per_tb_bandwidth)
let billed = $derived(billable && $user.usage_based_billing) let billed = $derived($user !== null && bills_extra($user, price))
// Usage based billing is on, but the balance is too far below zero for it
let overdrawn = $derived($user !== null && $user.usage_based_billing && price > 0 && !billed)
let included = $derived($user === null ? 0 : $user.subscription.monthly_transfer_cap) let included = $derived($user === null ? 0 : $user.subscription.monthly_transfer_cap)
</script> </script>
<ProgressBar total={total} used={used}></ProgressBar> <ProgressBar total={total} used={used} warn></ProgressBar>
<div class="gauge_labels"> <div class="gauge_labels">
<div> <div>
{formatDataVolume(used, 3)} {formatDataVolume(used, 3)}
@@ -47,17 +51,25 @@ let included = $derived($user === null ? 0 : $user.subscription.monthly_transfer
</p> </p>
{#if bill_shock} {#if bill_shock}
<p> <p>
This is your bill shock limit. <a href="/user/sharing">Increase This is your bill shock limit. <a href="/user/subscription/metered_billing">Increase
or disable the limit</a> to continue sharing files. or disable the limit</a> to continue sharing files.
</p> </p>
{:else if overdrawn}
<p>
Your balance is too far below zero to bill more data transfer.
Top up your credit to continue sharing files.
</p>
<a class="button button_highlight" href="/user/subscription/manage">
<i class="icon i_paid"></i> Top up credit
</a>
{:else} {:else}
<p> <p>
Upgrade your plan or enable Upgrade your plan or enable
<a href="/user/sharing">usage based billing</a> to continue <a href="/user/subscription/metered_billing">usage based billing</a> to continue
sharing files. sharing files.
</p> </p>
<a class="button button_highlight" href="/user/subscription/manage"> <a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options <i class="icon i_bolt"></i> Upgrade options
</a> </a>
{/if} {/if}
</div> </div>
@@ -70,11 +82,11 @@ let included = $derived($user === null ? 0 : $user.subscription.monthly_transfer
{#if bill_shock} {#if bill_shock}
<p> <p>
This is your bill shock limit, you can change it in the This is your bill shock limit, you can change it in the
<a href="/user/sharing">sharing settings</a>. <a href="/user/subscription/metered_billing">subscription settings</a>.
</p> </p>
{:else} {:else}
<a class="button button_highlight" href="/user/subscription/manage"> <a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options <i class="icon i_bolt"></i> Upgrade options
</a> </a>
{/if} {/if}
</div> </div>
+12
View File
@@ -11,6 +11,8 @@ import { onMount } from "svelte";
import { get_user, type User } from "lib/NovaAPI"; import { get_user, type User } from "lib/NovaAPI";
import SharingSettings from "./SharingSettings.svelte"; import SharingSettings from "./SharingSettings.svelte";
import SubscriptionManage from "./SubscriptionManage.svelte"; import SubscriptionManage from "./SubscriptionManage.svelte";
import SubscriptionUsage from "./SubscriptionUsage.svelte";
import RemoteSync from "./remote_sync/RemoteSync.svelte";
let pages: Tab[] = [ let pages: Tab[] = [
{ {
@@ -39,6 +41,11 @@ let pages: Tab[] = [
title: "Transactions", title: "Transactions",
icon: "receipt", icon: "receipt",
component: Transactions, component: Transactions,
}, {
path: "/user/subscription/metered_billing",
title: "Metered billing",
icon: "data_usage",
component: SubscriptionUsage,
}, },
], ],
}, { }, {
@@ -46,6 +53,11 @@ let pages: Tab[] = [
title: "Sharing settings", title: "Sharing settings",
icon: "share", icon: "share",
component: SharingSettings, component: SharingSettings,
}, {
path: "/user/remote_sync",
title: "Remote sync",
icon: "sync_alt",
component: RemoteSync,
}, { }, {
path: "/user/connect_app", path: "/user/connect_app",
title: "Apps", title: "Apps",
+5 -99
View File
@@ -1,14 +1,10 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte";
import { formatDataVolume, formatEuros } from "util/Formatting";
import ProgressBar from "util/ProgressBar.svelte";
import { loading_run } from "lib/Loading"; import { loading_run } from "lib/Loading";
import { get_endpoint, put_user } from 'lib/NovaAPI'; import { put_user } from 'lib/NovaAPI';
import SuccessMessage from 'util/SuccessMessage.svelte'; import SuccessMessage from 'util/SuccessMessage.svelte';
import { user } from "lib/UserStore"; import { user } from "lib/UserStore";
let success_message: SuccessMessage = $state() let success_message: SuccessMessage = $state()
let transfer_cap = $state($user === null ? 0 : $user.monthly_transfer_cap / 1e12)
const update_user = async (e: SubmitEvent) => { const update_user = async (e: SubmitEvent) => {
if (e !== null) { if (e !== null) {
@@ -16,10 +12,7 @@ const update_user = async (e: SubmitEvent) => {
} }
loading_run(async () => { loading_run(async () => {
try { try {
await put_user({ await put_user({embed_domains: embed_domains.join(" ")})
transfer_cap: transfer_cap*1e12,
embed_domains: embed_domains.join(" "),
})
success_message.set(true, "Sharing settings updated") success_message.set(true, "Sharing settings updated")
} catch (err) { } catch (err) {
@@ -28,40 +21,6 @@ const update_user = async (e: SubmitEvent) => {
}) })
} }
const set_usage_based_billing = (e: Event) => {
const input = e.target as HTMLInputElement
loading_run(async () => {
try {
await put_user({usage_based_billing: input.checked})
success_message.set(true, "Usage based billing updated")
} catch (err) {
input.checked = !input.checked
success_message.set(false, "Failed to update user: "+err)
}
})
}
let transfer_used = $state(0)
let load_transfer_used = () => {
let today = new Date()
let start = new Date()
start.setDate(start.getDate() - 30)
fetch(
get_endpoint() + "/user/time_series/egress" +
"?start=" + start.toISOString() +
"&end=" + today.toISOString() +
"&interval=60"
).then(resp => {
if (!resp.ok) { return Promise.reject("Error: " + resp.status); }
return resp.json();
}).then(resp => {
transfer_used = resp.amounts.reduce((acc, cur) => { return acc + cur }, 0)
}).catch(e => {
console.error("Error requesting time series: " + e);
})
}
// Embedding settings // Embedding settings
let embed_domains: string[] = $state($user === null ? [] : $user.embed_domains.split(" ")) let embed_domains: string[] = $state($user === null ? [] : $user.embed_domains.split(" "))
let new_domain: string = $state("") let new_domain: string = $state("")
@@ -79,58 +38,11 @@ const del_domain = (index: number) => {
embed_domains = embed_domains embed_domains = embed_domains
update_user(null) update_user(null)
} }
onMount(async () => {
load_transfer_used()
})
</script> </script>
<section> <section>
<SuccessMessage bind:this={success_message}/> <SuccessMessage bind:this={success_message}/>
{#if $user !== null && $user.subscription.type === "subscription"}
<h2>Usage based billing</h2>
<p>
When your storage or data transfer goes over the limits of your
plan, uploads and downloads are blocked. With usage based billing
they keep working and the usage above the limits is billed at
{formatEuros($user.subscription.price_per_tb_storage, 2)} per TB per
month for storage and
{formatEuros($user.subscription.price_per_tb_bandwidth, 2)} per TB
for data transfer.
</p>
<label>
<input type="checkbox" checked={$user.usage_based_billing} onchange={set_usage_based_billing}/>
Enable usage based billing
</label>
{/if}
<h2>Bill shock limit</h2>
<p>
Billshock limit in terabytes per month (1 TB = 1000 GB). Set to 0 to
disable.
</p>
<form onsubmit={update_user} class="billshock_container">
<input type="number" bind:value={transfer_cap} step="0.1" min="0" style="width: 5em;"/>
<div style="margin: 0.5em;">TB</div>
<button type="submit">
<i class="icon">save</i> Save
</button>
</form>
<p>
Bandwidth used in the last 30 days: {formatDataVolume(transfer_used, 3)},
new limit: {formatDataVolume(transfer_cap*1e12, 3)}
</p>
<ProgressBar used={transfer_used} total={transfer_cap*1e12}></ProgressBar>
<p>
The billshock limit limits how much bandwidth your account can use in a
30 day window. When this limit is reached hotlinking will be disabled
and you will no longer be charged for bandwidth usage. This is mostly
useful for the Prepaid subscription, but it works for Patreon plans too.
Set to 0 to disable the limit.
</p>
<h2>Embedding controls</h2> <h2>Embedding controls</h2>
<p> <p>
Here you can control which websites are allowed to embed your files in Here you can control which websites are allowed to embed your files in
@@ -144,7 +56,7 @@ onMount(async () => {
<div class="form_row"> <div class="form_row">
<span>Add domain name</span> <span>Add domain name</span>
<input class="grow" bind:value={new_domain} type="text"/> <input class="grow" bind:value={new_domain} type="text"/>
<button class="shrink" type="submit"><i class="icon">add</i> Add</button> <button class="shrink" type="submit"><i class="icon i_add"></i> Add</button>
</div> </div>
</form> </form>
<hr/> <hr/>
@@ -155,8 +67,8 @@ onMount(async () => {
{/if} {/if}
{#each embed_domains as domain, index} {#each embed_domains as domain, index}
<div class="form_row"> <div class="form_row">
<button class="shrink" type="button" onclick={() => del_domain(index)}> <button class="shrink" type="button" onclick={() => del_domain(index)} title="Remove">
<i class="icon">delete</i> <i class="icon i_delete"></i>
</button> </button>
<div>{domain}</div> <div>{domain}</div>
</div> </div>
@@ -165,12 +77,6 @@ onMount(async () => {
</section> </section>
<style> <style>
.billshock_container {
display: flex;
flex-direction: row;
align-items: center;
}
.highlight_border { .highlight_border {
text-align: initial; text-align: initial;
} }
+21 -6
View File
@@ -2,6 +2,7 @@
import { formatDataVolume, formatEuros } from "util/Formatting" import { formatDataVolume, formatEuros } from "util/Formatting"
import ProgressBar from "util/ProgressBar.svelte"; import ProgressBar from "util/ProgressBar.svelte";
import { user } from "lib/UserStore"; import { user } from "lib/UserStore";
import { bills_extra } from "lib/NovaAPI";
let { total = 0, used = 0 }: { let { total = 0, used = 0 }: {
total?: number; total?: number;
@@ -9,11 +10,14 @@ let { total = 0, used = 0 }: {
} = $props(); } = $props();
let frac = $derived(total <= 0 ? 0 : used / total) let frac = $derived(total <= 0 ? 0 : used / total)
let billable = $derived($user !== null && $user.subscription.price_per_tb_storage > 0) let price = $derived($user === null ? 0 : $user.subscription.price_per_tb_storage)
let billed = $derived(billable && $user.usage_based_billing) let billed = $derived($user !== null && bills_extra($user, price))
// Usage based billing is on, but the balance is too far below zero for it
let overdrawn = $derived($user !== null && $user.usage_based_billing && price > 0 && !billed)
</script> </script>
<ProgressBar total={total} used={used}></ProgressBar> <ProgressBar total={total} used={used} warn></ProgressBar>
<div class="gauge_labels"> <div class="gauge_labels">
<div> <div>
{formatDataVolume(used, 3)} {formatDataVolume(used, 3)}
@@ -35,17 +39,28 @@ let billed = $derived(billable && $user.usage_based_billing)
month. month.
</p> </p>
{/if} {/if}
{:else if frac > 1 && overdrawn}
<div class="highlight_yellow">
<p>
You are storing more than your plan includes, and your balance is
too far below zero to bill more storage. You can't upload new files
until you top up your credit. Your existing files stay available.
</p>
<a class="button button_highlight" href="/user/subscription/manage">
<i class="icon i_paid"></i> Top up credit
</a>
</div>
{:else if frac > 1} {:else if frac > 1}
<div class="highlight_yellow"> <div class="highlight_yellow">
<p> <p>
You are storing more than your plan allows, so you can't upload new You are storing more than your plan allows, so you can't upload new
files. Your existing files stay available. Delete some files or files. Your existing files stay available. Delete some files or
upgrade your plan to continue uploading, or enable upgrade your plan to continue uploading, or enable
<a href="/user/sharing">usage based billing</a> to pay for the <a href="/user/subscription/metered_billing">usage based billing</a> to pay for the
storage above the limit. storage above the limit.
</p> </p>
<a class="button button_highlight" href="/user/subscription/manage"> <a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options <i class="icon i_bolt"></i> Upgrade options
</a> </a>
</div> </div>
{:else if frac > 0.8} {:else if frac > 0.8}
@@ -55,7 +70,7 @@ let billed = $derived(billable && $user.usage_based_billing)
it runs out you won't be able to upload new files anymore. it runs out you won't be able to upload new files anymore.
</p> </p>
<a class="button button_highlight" href="/user/subscription/manage"> <a class="button button_highlight" href="/user/subscription/manage">
<i class="icon">bolt</i> Upgrade options <i class="icon i_bolt"></i> Upgrade options
</a> </a>
</div> </div>
{/if} {/if}
@@ -129,11 +129,11 @@ onMount(async () => {
<td> <td>
{#if row.status === "open"} {#if row.status === "open"}
<a href="/api/user/invoice/{row.id}/pay" class="button button_highlight"> <a href="/api/user/invoice/{row.id}/pay" class="button button_highlight">
<i class="icon">paid</i> Pay <i class="icon i_paid"></i> Pay
</a> </a>
{/if} {/if}
<a href="/api/user/invoice/{row.id}/pdf" target="_blank" class="button"> <a href="/api/user/invoice/{row.id}/pdf" target="_blank" class="button">
<i class="icon">description</i> PDF <i class="icon i_description"></i> PDF
</a> </a>
</td> </td>
</tr> </tr>
@@ -0,0 +1,101 @@
<script lang="ts">
import { formatDataVolume, formatEuros } from "util/Formatting";
import ProgressBar from "util/ProgressBar.svelte";
import { loading_run } from "lib/Loading";
import { period_price, put_user } from "lib/NovaAPI";
import SuccessMessage from "util/SuccessMessage.svelte";
import { user } from "lib/UserStore";
import ToggleButton from "layout/ToggleButton.svelte";
let success_message: SuccessMessage = $state()
// The toggle button has already flipped the value in the user store when this
// runs. put_user reloads the store from the server, so only a failed request
// has to flip it back
const set_usage_based_billing = () => {
loading_run(async () => {
try {
await put_user({usage_based_billing: $user.usage_based_billing})
success_message.set(true, "Usage based billing updated")
} catch (err) {
$user.usage_based_billing = !$user.usage_based_billing
success_message.set(false, "Failed to update user: "+(err?.message ?? err))
}
})
}
let transfer_cap = $state($user === null ? 0 : $user.monthly_transfer_cap / 1e12)
let transfer_used = $derived($user === null ? 0 : $user.monthly_transfer_used)
const set_transfer_cap = (e: SubmitEvent) => {
e.preventDefault()
loading_run(async () => {
try {
await put_user({transfer_cap: transfer_cap*1e12})
success_message.set(true, "Bill shock limit updated")
} catch (err) {
success_message.set(false, "Failed to update user: "+(err?.message ?? err))
}
})
}
</script>
<section>
<SuccessMessage bind:this={success_message}/>
{#if $user !== null && $user.subscription.type === "subscription"}
<h2>Usage based billing</h2>
<p>
When your storage or data transfer goes over the limits of your
plan, uploads and downloads are blocked. With usage based billing
they keep working and the usage above the limits is billed at
{formatEuros($user.subscription.price_per_tb_storage, 2)} per TB per
month for storage and
{formatEuros($user.subscription.price_per_tb_bandwidth, 2)} per TB
for data transfer.
</p>
<p>
This usage is charged from your account credit afterwards. When
your balance is more than {formatEuros(period_price($user), 2)} below zero
(the price of your subscription period) the limits of your plan
apply again, until you top up your credit.
</p>
<ToggleButton bind:on={$user.usage_based_billing} action={set_usage_based_billing}>
Usage based billing
</ToggleButton>
{/if}
<h2>Bill shock limit</h2>
<p>
Billshock limit in terabytes per month (1 TB = 1000 GB). Set to 0 to
disable.
</p>
<form onsubmit={set_transfer_cap} class="billshock_container">
<input type="number" bind:value={transfer_cap} step="0.1" min="0" style="width: 5em;"/>
<div style="margin: 0.5em;">TB</div>
<button type="submit">
<i class="icon i_save"></i> Save
</button>
</form>
<p>
Bandwidth used in the last 30 days: {formatDataVolume(transfer_used, 3)},
new limit: {formatDataVolume(transfer_cap*1e12, 3)}
</p>
<ProgressBar used={transfer_used} total={transfer_cap*1e12} warn></ProgressBar>
<p>
The billshock limit limits how much bandwidth your account can use in a
30 day window. When this limit is reached your files can't be downloaded
until your usage drops below it, and you will no longer be charged for
bandwidth usage. This is mostly useful with usage based billing, but it
works without it too. Set to 0 to disable the limit.
</p>
</section>
<style>
.billshock_container {
display: flex;
flex-direction: row;
align-items: center;
}
</style>
+9 -7
View File
@@ -99,11 +99,13 @@ onMount(() => {
<h2>Transaction log</h2> <h2>Transaction log</h2>
<p> <p>
Here is a log of all transactions on your account balance. Usage is Here is a log of all transactions on your account balance. Usage is
calculated per day. The storage charge is divided by the average number calculated per day. Storage and bandwidth are only charged for what you
of days in a month (30.4375). use above the amounts included in your plan, and that is the usage which
is listed here. The storage charge is divided by the average number of
days in a month (30.4375).
</p> </p>
<p> <p>
Example: If you have 2 TB stored on your Nova account at €4 per TB Example: If you store 2 TB more than your plan includes at €4 per TB
then the daily charge will be:<br/> then the daily charge will be:<br/>
2 TB * € 4 = € 8<br/> 2 TB * € 4 = € 8<br/>
@@ -114,13 +116,13 @@ onMount(() => {
<h3>{month_str}</h3> <h3>{month_str}</h3>
<div class="toolbar"> <div class="toolbar">
<button onclick={last_month}> <button onclick={last_month}>
<i class="icon">chevron_left</i> <i class="icon i_chevron_left"></i>
Previous month Previous month
</button> </button>
<div class="toolbar_spacer"></div> <div class="toolbar_spacer"></div>
<button onclick={next_month}> <button onclick={next_month}>
Next month Next month
<i class="icon">chevron_right</i> <i class="icon i_chevron_right"></i>
</button> </button>
</div> </div>
<ul> <ul>
@@ -129,11 +131,11 @@ onMount(() => {
</li> </li>
<li> <li>
Storage charge: <Euro amount={transactions.total_storage_charge} precision="4"/> Storage charge: <Euro amount={transactions.total_storage_charge} precision="4"/>
(used {formatDataVolume(transactions.total_storage_used, 3)}) ({formatDataVolume(transactions.total_storage_used, 3)} above your plan)
</li> </li>
<li> <li>
Bandwidth charge: <Euro amount={transactions.total_bandwidth_charge} precision="4"/> Bandwidth charge: <Euro amount={transactions.total_bandwidth_charge} precision="4"/>
(used {formatDataVolume(transactions.total_bandwidth_used, 3)}) ({formatDataVolume(transactions.total_bandwidth_used, 3)} above your plan)
</li> </li>
<li> <li>
Total charge: <Euro amount={transactions.total_deducted} precision="4"/> Total charge: <Euro amount={transactions.total_deducted} precision="4"/>
@@ -18,7 +18,7 @@ import { user } from "lib/UserStore";
</li> </li>
{/if} {/if}
<li> <li>
<i class="icon">settings</i> <i class="icon i_settings"></i>
<a href="/user/settings">Account settings</a> <a href="/user/settings">Account settings</a>
</li> </li>
</ul> </ul>
@@ -28,11 +28,11 @@ import { user } from "lib/UserStore";
<div class="button_row"> <div class="button_row">
<a href="/d/me" class="button"> <a href="/d/me" class="button">
<i class="icon">folder</i> <i class="icon i_folder"></i>
Filesystem Filesystem
</a> </a>
<button onclick={()=> logout_user("/")}> <button onclick={()=> logout_user("/")}>
<i class="icon">logout</i> <i class="icon i_logout"></i>
Log out Log out
</button> </button>
</div> </div>
Loaded 100 of 124 files, more files were not shown because too many files have changed in this diff. Show more