Update Edit window to operate on NodeOptions
This commit is contained in:
@@ -27,6 +27,8 @@ export type FSNode = {
|
|||||||
abuse_type?: string,
|
abuse_type?: string,
|
||||||
abuse_report_time?: string,
|
abuse_report_time?: string,
|
||||||
|
|
||||||
|
custom_domain_name?: string,
|
||||||
|
|
||||||
file_size: number,
|
file_size: number,
|
||||||
file_type: string,
|
file_type: string,
|
||||||
sha256_sum: string,
|
sha256_sum: string,
|
||||||
@@ -72,6 +74,9 @@ export type FSContext = {
|
|||||||
// API parameters
|
// API parameters
|
||||||
// ==============
|
// ==============
|
||||||
|
|
||||||
|
// NodeOptions are options which can be applied by sending a PUT request to a
|
||||||
|
// filesystem node. This includes all values which can be set in
|
||||||
|
// FSNode.properties
|
||||||
export type NodeOptions = {
|
export type NodeOptions = {
|
||||||
mode?: number,
|
mode?: number,
|
||||||
created?: string,
|
created?: string,
|
||||||
@@ -82,6 +87,11 @@ export type NodeOptions = {
|
|||||||
link_permissions?: FSPermissions,
|
link_permissions?: FSPermissions,
|
||||||
user_permissions?: { [index: string]: FSPermissions },
|
user_permissions?: { [index: string]: FSPermissions },
|
||||||
password_permissions?: { [index: string]: FSPermissions },
|
password_permissions?: { [index: string]: FSPermissions },
|
||||||
|
|
||||||
|
// Custom domain name options
|
||||||
|
custom_domain_name?: string,
|
||||||
|
custom_domain_cert?: string,
|
||||||
|
custom_domain_key?: string,
|
||||||
} & FSNodeProperties
|
} & FSNodeProperties
|
||||||
|
|
||||||
// API methods
|
// API methods
|
||||||
|
@@ -1,36 +1,36 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Button from "layout/Button.svelte";
|
import Button from "layout/Button.svelte";
|
||||||
import type { FSNode, FSPermissions } from "filesystem/FilesystemAPI";
|
import type { FSPermissions, NodeOptions } from "filesystem/FilesystemAPI";
|
||||||
import PermissionButton from "./PermissionButton.svelte";
|
import PermissionButton from "./PermissionButton.svelte";
|
||||||
|
|
||||||
export let file: FSNode
|
export let options: NodeOptions
|
||||||
|
|
||||||
let new_user_id = ""
|
let new_user_id = ""
|
||||||
let new_user_perms = <FSPermissions>{read: true}
|
let new_user_perms = <FSPermissions>{read: true}
|
||||||
const add_user = (e: SubmitEvent) => {
|
const add_user = (e: SubmitEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (file.user_permissions === undefined) {
|
if (options.user_permissions === undefined) {
|
||||||
file.user_permissions = {} as {[index: string]: FSPermissions}
|
options.user_permissions = {} as {[index: string]: FSPermissions}
|
||||||
}
|
}
|
||||||
file.user_permissions[new_user_id] = structuredClone(new_user_perms)
|
options.user_permissions[new_user_id] = structuredClone(new_user_perms)
|
||||||
}
|
}
|
||||||
const del_user = (id: string) => {
|
const del_user = (id: string) => {
|
||||||
delete file.user_permissions[id]
|
delete options.user_permissions[id]
|
||||||
file.user_permissions = file.user_permissions
|
options.user_permissions = options.user_permissions
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_password = ""
|
let new_password = ""
|
||||||
let new_password_perms = <FSPermissions>{read: true}
|
let new_password_perms = <FSPermissions>{read: true}
|
||||||
const add_password = (e: SubmitEvent) => {
|
const add_password = (e: SubmitEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (file.password_permissions === undefined) {
|
if (options.password_permissions === undefined) {
|
||||||
file.password_permissions = {} as {[index: string]: FSPermissions}
|
options.password_permissions = {} as {[index: string]: FSPermissions}
|
||||||
}
|
}
|
||||||
file.password_permissions[new_password] = structuredClone(new_password_perms)
|
options.password_permissions[new_password] = structuredClone(new_password_perms)
|
||||||
}
|
}
|
||||||
const del_password = (pass: string) => {
|
const del_password = (pass: string) => {
|
||||||
delete file.password_permissions[pass]
|
delete options.password_permissions[pass]
|
||||||
file.password_permissions = file.password_permissions
|
options.password_permissions = options.password_permissions
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ const del_password = (pass: string) => {
|
|||||||
Anyone with the link can...
|
Anyone with the link can...
|
||||||
</div>
|
</div>
|
||||||
<div class="perms">
|
<div class="perms">
|
||||||
<PermissionButton bind:permissions={file.link_permissions}/>
|
<PermissionButton bind:permissions={options.link_permissions}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -71,15 +71,15 @@ const del_password = (pass: string) => {
|
|||||||
<PermissionButton bind:permissions={new_user_perms}/>
|
<PermissionButton bind:permissions={new_user_perms}/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{#if file.user_permissions !== undefined}
|
{#if options.user_permissions !== undefined}
|
||||||
{#each Object.keys(file.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"/>
|
||||||
<div class="grow id">
|
<div class="grow id">
|
||||||
{id}
|
{id}
|
||||||
</div>
|
</div>
|
||||||
<div class="perms">
|
<div class="perms">
|
||||||
<PermissionButton bind:permissions={file.user_permissions[id]}/>
|
<PermissionButton bind:permissions={options.user_permissions[id]}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -101,15 +101,15 @@ const del_password = (pass: string) => {
|
|||||||
<PermissionButton bind:permissions={new_password_perms}/>
|
<PermissionButton bind:permissions={new_password_perms}/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{#if file.password_permissions !== undefined}
|
{#if options.password_permissions !== undefined}
|
||||||
{#each Object.keys(file.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"/>
|
||||||
<div class="grow id">
|
<div class="grow id">
|
||||||
{password}
|
{password}
|
||||||
</div>
|
</div>
|
||||||
<div class="perms">
|
<div class="perms">
|
||||||
<PermissionButton bind:permissions={file.password_permissions[password]}/>
|
<PermissionButton bind:permissions={options.password_permissions[password]}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
@@ -1,22 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
import ThemePresets from "./ThemePresets.svelte";
|
import ThemePresets from "./ThemePresets.svelte";
|
||||||
import { fs_update, fs_node_type, type FSNode } from "filesystem/FilesystemAPI";
|
import { fs_update, fs_node_type, type FSNode, type NodeOptions } from "filesystem/FilesystemAPI";
|
||||||
import CustomBanner from "filesystem/viewers/CustomBanner.svelte";
|
import CustomBanner from "filesystem/viewers/CustomBanner.svelte";
|
||||||
import HelpButton from "layout/HelpButton.svelte";
|
import HelpButton from "layout/HelpButton.svelte";
|
||||||
import FilePicker from "filesystem/filemanager/FilePicker.svelte";
|
import FilePicker from "filesystem/filemanager/FilePicker.svelte";
|
||||||
let dispatch = createEventDispatcher()
|
let dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let file: FSNode
|
export let file: FSNode
|
||||||
export let enabled = false
|
export let options: NodeOptions
|
||||||
|
export let enabled: boolean
|
||||||
|
|
||||||
$: update_colors(file)
|
$: update_colors(options)
|
||||||
const update_colors = (file: FSNode) => {
|
const update_colors = (options: NodeOptions) => {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
file.properties.branding_enabled = "true"
|
options.branding_enabled = "true"
|
||||||
dispatch("style_change")
|
dispatch("style_change")
|
||||||
} else {
|
} else {
|
||||||
file.properties.branding_enabled = ""
|
options.branding_enabled = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ const handle_picker = async (e: CustomEvent<FSNode[]>) => {
|
|||||||
alert("Please select one file")
|
alert("Please select one file")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let f = e.detail[0]
|
const f = e.detail[0]
|
||||||
let file_id = f.id
|
let file_id = f.id
|
||||||
|
|
||||||
if (fs_node_type(f) !== "image") {
|
if (fs_node_type(f) !== "image") {
|
||||||
@@ -53,9 +54,9 @@ const handle_picker = async (e: CustomEvent<FSNode[]>) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (picking === "brand_header_image") {
|
if (picking === "brand_header_image") {
|
||||||
file.properties.brand_header_image = file_id
|
options.brand_header_image = file_id
|
||||||
} else if (picking === "brand_background_image") {
|
} else if (picking === "brand_background_image") {
|
||||||
file.properties.brand_background_image = file_id
|
options.brand_background_image = file_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ let highlight_info = false
|
|||||||
|
|
||||||
<fieldset disabled={!enabled} style="text-align: center;">
|
<fieldset disabled={!enabled} style="text-align: center;">
|
||||||
<legend>Theme presets</legend>
|
<legend>Theme presets</legend>
|
||||||
<ThemePresets bind:properties={file.properties}/>
|
<ThemePresets bind:properties={options}/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="grid" disabled={!enabled}>
|
<fieldset class="grid" disabled={!enabled}>
|
||||||
@@ -88,8 +89,8 @@ let highlight_info = false
|
|||||||
<div style="display: inline-block">Highlight</div>
|
<div style="display: inline-block">Highlight</div>
|
||||||
<HelpButton bind:toggle={highlight_info}/>
|
<HelpButton bind:toggle={highlight_info}/>
|
||||||
</div>
|
</div>
|
||||||
<input type="color" bind:value={file.properties.brand_highlight_color}/>
|
<input type="color" bind:value={options.brand_highlight_color}/>
|
||||||
<input type="text" bind:value={file.properties.brand_highlight_color}/>
|
<input type="text" bind:value={options.brand_highlight_color}/>
|
||||||
{#if highlight_info}
|
{#if highlight_info}
|
||||||
<p class="span3">
|
<p class="span3">
|
||||||
The highlight colour is used for highlighting selected buttons and
|
The highlight colour is used for highlighting selected buttons and
|
||||||
@@ -99,20 +100,20 @@ let highlight_info = false
|
|||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
<div>Button and input</div>
|
<div>Button and input</div>
|
||||||
<input type="color" bind:value={file.properties.brand_input_color}/>
|
<input type="color" bind:value={options.brand_input_color}/>
|
||||||
<input type="text" bind:value={file.properties.brand_input_color}/>
|
<input type="text" bind:value={options.brand_input_color}/>
|
||||||
<div>Delete button</div>
|
<div>Delete button</div>
|
||||||
<input type="color" bind:value={file.properties.brand_danger_color}/>
|
<input type="color" bind:value={options.brand_danger_color}/>
|
||||||
<input type="text" bind:value={file.properties.brand_danger_color}/>
|
<input type="text" bind:value={options.brand_danger_color}/>
|
||||||
<div>Background</div>
|
<div>Background</div>
|
||||||
<input type="color" bind:value={file.properties.brand_background_color}/>
|
<input type="color" bind:value={options.brand_background_color}/>
|
||||||
<input type="text" bind:value={file.properties.brand_background_color}/>
|
<input type="text" bind:value={options.brand_background_color}/>
|
||||||
<div>Body</div>
|
<div>Body</div>
|
||||||
<input type="color" bind:value={file.properties.brand_body_color}/>
|
<input type="color" bind:value={options.brand_body_color}/>
|
||||||
<input type="text" bind:value={file.properties.brand_body_color}/>
|
<input type="text" bind:value={options.brand_body_color}/>
|
||||||
<div>Card</div>
|
<div>Card</div>
|
||||||
<input type="color" bind:value={file.properties.brand_card_color}/>
|
<input type="color" bind:value={options.brand_card_color}/>
|
||||||
<input type="text" bind:value={file.properties.brand_card_color}/>
|
<input type="text" bind:value={options.brand_card_color}/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="grid" disabled={!enabled}>
|
<fieldset class="grid" disabled={!enabled}>
|
||||||
@@ -129,15 +130,15 @@ let highlight_info = false
|
|||||||
<i class="icon">folder_open</i>
|
<i class="icon">folder_open</i>
|
||||||
Pick
|
Pick
|
||||||
</button>
|
</button>
|
||||||
<input type="text" bind:value={file.properties.brand_header_image}/>
|
<input type="text" bind:value={options.brand_header_image}/>
|
||||||
<div>Header image link</div>
|
<div>Header image link</div>
|
||||||
<input class="span2" type="text" bind:value={file.properties.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 on:click={() => pick_image("brand_background_image")}>
|
<button on:click={() => pick_image("brand_background_image")}>
|
||||||
<i class="icon">folder_open</i>
|
<i class="icon">folder_open</i>
|
||||||
Pick
|
Pick
|
||||||
</button>
|
</button>
|
||||||
<input type="text" bind:value={file.properties.brand_background_image}/>
|
<input type="text" bind:value={options.brand_background_image}/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset disabled={!enabled}>
|
<fieldset disabled={!enabled}>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { fs_rename, fs_update, type FSNode, type FSNodeProperties, type NodeOptions } from "filesystem/FilesystemAPI";
|
import { fs_rename, fs_update, type FSNode, type NodeOptions } from "filesystem/FilesystemAPI";
|
||||||
import Modal from "util/Modal.svelte";
|
import Modal from "util/Modal.svelte";
|
||||||
import BrandingOptions from "./BrandingOptions.svelte";
|
import BrandingOptions from "./BrandingOptions.svelte";
|
||||||
import { branding_from_node } from "./Branding";
|
import { branding_from_node } from "./Branding";
|
||||||
@@ -10,6 +10,7 @@ import type { FSNavigator } from "filesystem/FSNavigator";
|
|||||||
|
|
||||||
export let nav: FSNavigator
|
export let nav: FSNavigator
|
||||||
let file: FSNode = {} as FSNode
|
let file: FSNode = {} as FSNode
|
||||||
|
let options: NodeOptions = {} as NodeOptions
|
||||||
|
|
||||||
let custom_css = ""
|
let custom_css = ""
|
||||||
|
|
||||||
@@ -30,18 +31,28 @@ export const edit = (f: FSNode, oae = false, open_tab = "") => {
|
|||||||
// 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
|
||||||
new_name = file.name
|
new_name = file.name
|
||||||
shared = !(file.id === undefined || file.id === "")
|
|
||||||
|
|
||||||
if (file.properties === undefined) {
|
if (file.properties === undefined) {
|
||||||
file.properties = {} as FSNodeProperties
|
options = {} as NodeOptions
|
||||||
|
} else {
|
||||||
|
options = file.properties
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shared && file.link_permissions === undefined) {
|
options.custom_domain_name = file.custom_domain_name
|
||||||
|
|
||||||
|
options.shared = !(file.id === undefined || file.id === "")
|
||||||
|
if (options.shared) {
|
||||||
|
if (file.link_permissions === undefined) {
|
||||||
// Default to read-only for public links
|
// Default to read-only for public links
|
||||||
file.link_permissions = { owner: false, read: true, write: false, delete: false}
|
file.link_permissions = { owner: false, read: true, write: false, delete: false}
|
||||||
|
} else {
|
||||||
|
options.link_permissions = file.link_permissions
|
||||||
|
}
|
||||||
|
options.user_permissions = file.user_permissions
|
||||||
|
options.password_permissions = file.password_permissions
|
||||||
}
|
}
|
||||||
|
|
||||||
branding_enabled = file.properties.branding_enabled === "true"
|
branding_enabled = options.branding_enabled === "true"
|
||||||
if (branding_enabled) {
|
if (branding_enabled) {
|
||||||
custom_css = branding_from_node(file)
|
custom_css = branding_from_node(file)
|
||||||
} else {
|
} else {
|
||||||
@@ -55,7 +66,6 @@ let tab = "file"
|
|||||||
let open_after_edit = false
|
let open_after_edit = false
|
||||||
|
|
||||||
let new_name = ""
|
let new_name = ""
|
||||||
let shared = false
|
|
||||||
let branding_enabled = false
|
let branding_enabled = false
|
||||||
|
|
||||||
const save = async (keep_editing = false) => {
|
const save = async (keep_editing = false) => {
|
||||||
@@ -64,25 +74,9 @@ const save = async (keep_editing = false) => {
|
|||||||
let new_file: FSNode
|
let new_file: FSNode
|
||||||
try {
|
try {
|
||||||
nav.set_loading(true)
|
nav.set_loading(true)
|
||||||
let opts = {
|
options.branding_enabled = JSON.stringify(branding_enabled)
|
||||||
shared: shared,
|
|
||||||
branding_enabled: JSON.stringify(branding_enabled)
|
|
||||||
} as NodeOptions
|
|
||||||
|
|
||||||
if (branding_enabled && file.properties !== undefined) {
|
new_file = await fs_update(file.path, options)
|
||||||
for (let field of Object.keys(file.properties)) {
|
|
||||||
console.log("setting", field, "to", file.properties[field])
|
|
||||||
opts[field] = file.properties[field]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shared) {
|
|
||||||
opts.link_permissions = file.link_permissions
|
|
||||||
opts.user_permissions = file.user_permissions
|
|
||||||
opts.password_permissions = file.password_permissions
|
|
||||||
}
|
|
||||||
|
|
||||||
new_file = await fs_update(file.path, opts)
|
|
||||||
|
|
||||||
if (new_name !== file.name) {
|
if (new_name !== file.name) {
|
||||||
let parent = file.path.slice(0, -file.name.length)
|
let parent = file.path.slice(0, -file.name.length)
|
||||||
@@ -128,7 +122,7 @@ const save = async (keep_editing = false) => {
|
|||||||
<i class="icon">share</i>
|
<i class="icon">share</i>
|
||||||
Sharing
|
Sharing
|
||||||
</button>
|
</button>
|
||||||
{#if shared && $nav.permissions.owner}
|
{#if options.shared && $nav.permissions.owner}
|
||||||
<button class:button_highlight={tab === "access"} on:click={() => tab = "access"}>
|
<button class:button_highlight={tab === "access"} on:click={() => tab = "access"}>
|
||||||
<i class="icon">key</i>
|
<i class="icon">key</i>
|
||||||
Access control
|
Access control
|
||||||
@@ -152,12 +146,13 @@ const save = async (keep_editing = false) => {
|
|||||||
bind:open_after_edit
|
bind:open_after_edit
|
||||||
/>
|
/>
|
||||||
{:else if tab === "share"}
|
{:else if tab === "share"}
|
||||||
<SharingOptions bind:file bind:shared on:save={() => save(true)} />
|
<SharingOptions bind:file bind:options on:save={() => save(true)} />
|
||||||
{:else if tab === "access"}
|
{:else if tab === "access"}
|
||||||
<AccessControl bind:file />
|
<AccessControl bind:options />
|
||||||
{:else if tab === "branding"}
|
{:else if tab === "branding"}
|
||||||
<BrandingOptions
|
<BrandingOptions
|
||||||
bind:enabled={branding_enabled}
|
bind:enabled={branding_enabled}
|
||||||
|
bind:options={options}
|
||||||
bind:file
|
bind:file
|
||||||
on:style_change={e => custom_css = branding_from_node(file)}
|
on:style_change={e => custom_css = branding_from_node(file)}
|
||||||
/>
|
/>
|
||||||
|
@@ -3,20 +3,19 @@ import { createEventDispatcher } from "svelte";
|
|||||||
import { domain_url } from "util/Util.svelte";
|
import { domain_url } from "util/Util.svelte";
|
||||||
import CopyButton from "layout/CopyButton.svelte";
|
import CopyButton from "layout/CopyButton.svelte";
|
||||||
import { formatDate } from "util/Formatting";
|
import { formatDate } from "util/Formatting";
|
||||||
import type { FSNode } from "filesystem/FilesystemAPI";
|
import type { FSNode, NodeOptions } from "filesystem/FilesystemAPI";
|
||||||
|
|
||||||
let dispatch = createEventDispatcher()
|
let dispatch = createEventDispatcher()
|
||||||
export let shared: boolean
|
|
||||||
export let file: FSNode = {} as FSNode
|
export let file: FSNode = {} as FSNode
|
||||||
|
export let options: NodeOptions
|
||||||
|
|
||||||
let embed_html: string
|
let embed_html: string
|
||||||
let preview_area: HTMLDivElement
|
let preview_area: HTMLDivElement
|
||||||
|
|
||||||
$: is_shared = file.id !== undefined && file.id !== ""
|
|
||||||
$: share_link = window.location.protocol+"//"+window.location.host+"/d/"+file.id
|
$: share_link = window.location.protocol+"//"+window.location.host+"/d/"+file.id
|
||||||
$: embed_iframe(file)
|
$: embed_iframe(file, options)
|
||||||
let embed_iframe = (file: FSNode) => {
|
let embed_iframe = (file: FSNode, options: NodeOptions) => {
|
||||||
if (!is_shared) {
|
if (!options.shared) {
|
||||||
example = false
|
example = false
|
||||||
embed_html = "File is not shared, can't generate embed code"
|
embed_html = "File is not shared, can't generate embed code"
|
||||||
return
|
return
|
||||||
@@ -32,7 +31,7 @@ let embed_iframe = (file: FSNode) => {
|
|||||||
|
|
||||||
let example = false
|
let example = false
|
||||||
const toggle_example = () => {
|
const toggle_example = () => {
|
||||||
if (is_shared) {
|
if (options.shared) {
|
||||||
example = !example
|
example = !example
|
||||||
if (example) {
|
if (example) {
|
||||||
preview_area.innerHTML = embed_html
|
preview_area.innerHTML = embed_html
|
||||||
@@ -47,7 +46,7 @@ const update_shared = () => {
|
|||||||
// the sharing link. But if the user disables sharing we don't automatically
|
// the sharing link. But if the user disables sharing we don't automatically
|
||||||
// save so that the user can't accidentally discard a sharing link that's in
|
// save so that the user can't accidentally discard a sharing link that's in
|
||||||
// use
|
// use
|
||||||
if (shared) {
|
if (options.shared && !file.id) {
|
||||||
dispatch("save")
|
dispatch("save")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +67,7 @@ const update_shared = () => {
|
|||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
form="edit_form"
|
form="edit_form"
|
||||||
bind:checked={shared}
|
bind:checked={options.shared}
|
||||||
on:change={update_shared}
|
on:change={update_shared}
|
||||||
id="shared"
|
id="shared"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@@ -76,8 +75,8 @@ const update_shared = () => {
|
|||||||
/>
|
/>
|
||||||
<label for="shared">Share this file or directory</label>
|
<label for="shared">Share this file or directory</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form_grid">
|
<div class="link_grid">
|
||||||
{#if is_shared}
|
{#if options.shared}
|
||||||
<span>Public link: <a href={share_link}>{share_link}</a></span>
|
<span>Public link: <a href={share_link}>{share_link}</a></span>
|
||||||
<CopyButton text={share_link}>Copy</CopyButton>
|
<CopyButton text={share_link}>Copy</CopyButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -109,7 +108,7 @@ const update_shared = () => {
|
|||||||
<textarea bind:value={embed_html} style="width: 100%; height: 4em;"></textarea>
|
<textarea bind:value={embed_html} style="width: 100%; height: 4em;"></textarea>
|
||||||
<br/>
|
<br/>
|
||||||
<CopyButton text={embed_html}>Copy HTML</CopyButton>
|
<CopyButton text={embed_html}>Copy HTML</CopyButton>
|
||||||
<button on:click={toggle_example} class:button_highlight={example} disabled={!is_shared}>
|
<button on:click={toggle_example} class:button_highlight={example} disabled={!options.shared}>
|
||||||
<i class="icon">visibility</i> Show example
|
<i class="icon">visibility</i> Show example
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -118,14 +117,41 @@ const update_shared = () => {
|
|||||||
<div bind:this={preview_area} style="text-align: center;"></div>
|
<div bind:this={preview_area} style="text-align: center;"></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<!-- <fieldset>
|
||||||
|
<legend>Custom domain</legend>
|
||||||
|
<p>
|
||||||
|
Experimental options
|
||||||
|
</p>
|
||||||
|
<div class="form_grid">
|
||||||
|
<label for="custom_domain_name">Domain name</label>
|
||||||
|
<input
|
||||||
|
id="custom_domain_name"
|
||||||
|
bind:value={options.custom_domain_name}
|
||||||
|
type="text"
|
||||||
|
disabled={!options.shared}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label for="custom_domain_cert">Certificate</label>
|
||||||
|
<textarea id="custom_domain_cert" bind:value={options.custom_domain_cert} style="height: 4em;"></textarea>
|
||||||
|
|
||||||
|
<label for="custom_domain_key">Key</label>
|
||||||
|
<textarea id="custom_domain_key" bind:value={options.custom_domain_key} style="height: 4em;"></textarea>
|
||||||
|
</div>
|
||||||
|
</fieldset> -->
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.center {
|
.center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form_grid {
|
.link_grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 10fr auto;
|
grid-template-columns: 10fr auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
/* .form_grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
align-items: center;
|
||||||
|
} */
|
||||||
</style>
|
</style>
|
||||||
|
@@ -7,8 +7,8 @@ import Modal from "util/Modal.svelte";
|
|||||||
import LoadingIndicator from "util/LoadingIndicator.svelte";
|
import LoadingIndicator from "util/LoadingIndicator.svelte";
|
||||||
import Breadcrumbs from "filesystem/Breadcrumbs.svelte"
|
import Breadcrumbs from "filesystem/Breadcrumbs.svelte"
|
||||||
import { FSNavigator } from "filesystem/FSNavigator";
|
import { FSNavigator } from "filesystem/FSNavigator";
|
||||||
import type { FMNodeEvent } from "./FileManager.svelte";
|
|
||||||
import type { FSNode } from "filesystem/FilesystemAPI";
|
import type { FSNode } from "filesystem/FilesystemAPI";
|
||||||
|
import { FileAction, type FileEvent } from "./FileManagerLib";
|
||||||
|
|
||||||
let nav = new FSNavigator(false)
|
let nav = new FSNavigator(false)
|
||||||
let modal: Modal
|
let modal: Modal
|
||||||
@@ -33,25 +33,30 @@ $: selected_files = $nav.children.reduce((acc, file) => {
|
|||||||
|
|
||||||
// Navigation functions
|
// Navigation functions
|
||||||
|
|
||||||
const node_click = (e: CustomEvent<FMNodeEvent>) => {
|
const file_event = (e: CustomEvent<FileEvent>) => {
|
||||||
const index = e.detail.index
|
const index = e.detail.index
|
||||||
|
|
||||||
|
switch (e.detail.action) {
|
||||||
|
case FileAction.Click:
|
||||||
|
e.detail.original.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 {
|
||||||
select_node(index)
|
select_node(index)
|
||||||
}
|
}
|
||||||
}
|
break
|
||||||
let node_context = (e: CustomEvent<FMNodeEvent>) => {
|
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) {
|
||||||
e.detail.original.preventDefault()
|
e.detail.original.preventDefault()
|
||||||
node_select(e)
|
select_node(index)
|
||||||
}
|
}
|
||||||
}
|
break
|
||||||
const node_select = (e: CustomEvent<FMNodeEvent>) => {
|
case FileAction.Select:
|
||||||
const index = e.detail.index
|
e.detail.original.preventDefault()
|
||||||
nav.children[index].fm_selected = !nav.children[index].fm_selected
|
nav.children[index].fm_selected = !nav.children[index].fm_selected
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggle_view = () => {
|
const toggle_view = () => {
|
||||||
@@ -171,18 +176,14 @@ onMount(() => {
|
|||||||
large_icons={large_icons}
|
large_icons={large_icons}
|
||||||
hide_edit
|
hide_edit
|
||||||
hide_branding
|
hide_branding
|
||||||
on:node_click={node_click}
|
on:file={file_event}
|
||||||
on:node_context={node_context}
|
|
||||||
on:node_select={node_select}
|
|
||||||
/>
|
/>
|
||||||
{:else if directory_view === "gallery"}
|
{:else if directory_view === "gallery"}
|
||||||
<GalleryView
|
<GalleryView
|
||||||
nav={nav}
|
nav={nav}
|
||||||
show_hidden={show_hidden}
|
show_hidden={show_hidden}
|
||||||
large_icons={large_icons}
|
large_icons={large_icons}
|
||||||
on:node_click={node_click}
|
on:file={file_event}
|
||||||
on:node_context={node_context}
|
|
||||||
on:node_select={node_select}
|
|
||||||
/>
|
/>
|
||||||
{:else if directory_view === "compact"}
|
{:else if directory_view === "compact"}
|
||||||
<CompactView
|
<CompactView
|
||||||
@@ -190,9 +191,7 @@ onMount(() => {
|
|||||||
show_hidden={show_hidden}
|
show_hidden={show_hidden}
|
||||||
large_icons={large_icons}
|
large_icons={large_icons}
|
||||||
hide_edit
|
hide_edit
|
||||||
on:node_click={node_click}
|
on:file={file_event}
|
||||||
on:node_context={node_context}
|
|
||||||
on:node_select={node_select}
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user