Fix double api call in edit window

This commit is contained in:
2023-05-25 14:47:36 +02:00
parent 794a38da19
commit fff705bc2a
7 changed files with 49 additions and 24 deletions

View File

@@ -317,16 +317,24 @@ onDestroy(() => {
<thead>
<tr>
<td>
<button on:click={() => { getStats('query_name') }}>Query</button>
<button on:click={() => { getStats('query_name') }}>
Query
</button>
</td>
<td>
<button style="cursor: pointer;" on:click={() => { getStats('calls') }}>Calls</button>
<button style="cursor: pointer;" on:click={() => { getStats('calls') }}>
Calls
</button>
</td>
<td>
<button style="cursor: pointer;" on:click={() => { getStats('average_duration') }}>Avg dur</button>
<button style="cursor: pointer;" on:click={() => { getStats('average_duration') }}>
Avg
</button>
</td>
<td>
<button style="cursor: pointer;" on:click={() => { getStats('total_duration') }}>Total dur</button>
<button style="cursor: pointer;" on:click={() => { getStats('total_duration') }}>
Total
</button>
</td>
<td>Callers</td>
</tr>

View File

@@ -12,11 +12,12 @@ let file = {
};
export let visible
export const edit = (f, t = "file") => {
export const edit = (f, oae = false, t = "file") => {
file = f
open_after_edit = oae
tab = t
console.log("Editing file", f)
file = f
console.log("Editing file", file)
file_name = file.name
shared = !(file.id === undefined || file.id === "")
@@ -26,6 +27,7 @@ export const edit = (f, t = "file") => {
}
let tab = "file"
let open_after_edit = false
let file_name = ""
let shared = false
@@ -58,7 +60,11 @@ const save = async () => {
return
}
fs_navigator.navigate(file.path, false)
if (open_after_edit) {
fs_navigator.navigate(file.path, false)
} else {
fs_navigator.reload()
}
}
const delete_file = async () => {
try {
@@ -69,12 +75,16 @@ const delete_file = async () => {
return
}
fs_navigator.navigate(file.path, false)
if (open_after_edit) {
fs_navigator.navigate(file.path, false)
} else {
fs_navigator.reload()
}
visible = false
}
</script>
<Modal bind:visible={visible} title="Edit {file.name}" width="600px" on:save={save} form="file_edit_form">
<Modal bind:visible={visible} title="Edit {file.name}" width="600px" form="file_edit_form">
<div class="tab_bar">
<button class:button_highlight={tab === "file"} on:click={() => tab = "file"}>
<i class="icon">edit</i>

View File

@@ -58,7 +58,7 @@ const keydown = e => {
if (edit_visible) {
edit_visible = false
} else {
edit_window.edit(state.base)
edit_window.edit(state.base, true)
}
break;
case "s":

View File

@@ -54,6 +54,10 @@ export const navigate = async (path, push_history) => {
}
}
export const reload = () => {
navigate(state.base.path, false)
}
export const open_node = (node, push_history) => {
// We need to properly URL encode the file paths so they don't cause
// issues.. but we also want the slashes to stay clean. So here we encode

View File

@@ -38,7 +38,7 @@ $: share_url = generate_share_url(state.path)
let link_copied = false
const copy_link = () => {
if (share_url === "") {
edit_window.edit(state.base, "share")
edit_window.edit(state.base, "share", true)
return
}
@@ -48,18 +48,18 @@ const copy_link = () => {
}
let share = async () => {
if (share_url === "") {
edit_window.edit(state.base, "share")
edit_window.edit(state.base, "share", true)
return
}
try {
if (navigator.share) {
await navigator.share({
title: state.base.name,
text: "I would like to share '" + state.base.name + "' with you",
url: share_url
})
} catch (err) {
console.debug("Navigator does not support sharing:", err)
} else {
console.debug("Navigator does not support sharing")
sharebar_visible = !sharebar_visible
}
}
@@ -119,7 +119,7 @@ let share = async () => {
</button>
{#if state.base.path !== "/"}
<button on:click={() => edit_window.edit(state.base)} class="toolbar_button" class:button_highlight={edit_visible}>
<button on:click={() => edit_window.edit(state.base, true)} class="toolbar_button" class:button_highlight={edit_visible}>
<i class="icon">edit</i> <u>E</u>dit
</button>
{/if}

View File

@@ -35,7 +35,7 @@ const node_click = e => {
}
const node_settings = e => {
edit_window.edit(state.children[e.detail])
edit_window.edit(state.children[e.detail], false)
}
const navigate_up = () => {
creating_dir = false
@@ -45,7 +45,6 @@ const navigate_up = () => {
fs_navigator.navigate(state.path[state.path.length-2].path, true)
}
}
const reload = () => { fs_navigator.navigate(state.base.path) }
const delete_selected = () => {
if (mode !== "selecting") {
@@ -82,7 +81,7 @@ const delete_selected = () => {
alert("Delete failed: ", err)
}).finally(() => {
mode = "viewing"
reload()
fs_navigator.reload()
})
}
const toggle_select = () => {
@@ -125,7 +124,7 @@ onMount(() => {
<button on:click={navigate_up} disabled={state.path.length <= 1} title="Back">
<i class="icon">arrow_back</i>
</button>
<button on:click={reload} title="Refresh directory listing">
<button on:click={fs_navigator.reload()} title="Refresh directory listing">
<i class="icon">refresh</i>
</button>
<button on:click={() => toggle_view()} title="Switch between gallery view and list view">
@@ -184,14 +183,18 @@ onMount(() => {
<br/>
{/if}
{#if creating_dir}
<CreateDirectory state={state} on:done={() => {reload(); creating_dir = false;}} on:loading></CreateDirectory>
<CreateDirectory
state={state}
on:done={() => {fs_navigator.reload(); creating_dir = false;}}
on:loading
/>
{/if}
<FileUploader
bind:this={uploader}
bucket_id={state.root.id}
target_dir={state.base.path}
on:reload={reload}
on:reload={fs_navigator.reload}
write_password={state.write_password}
></FileUploader>

View File

@@ -75,7 +75,7 @@ const keydown = e => {
class="button button_highlight"
type="submit"
form="{form}"
on:click={() => {dispatch("save"); hide()}}
on:click={hide}
>
<i class="icon">save</i> Save
</button>