Don't show downloads graph for directories

This commit is contained in:
2023-05-25 23:21:39 +02:00
parent 976a37f299
commit f9904ba1e9

View File

@@ -6,13 +6,14 @@ import { fs_timeseries } from "./FilesystemAPI";
import { fs_path_url } from "./FilesystemUtil"; import { fs_path_url } from "./FilesystemUtil";
import { generate_share_url } from "./Sharebar.svelte"; import { generate_share_url } from "./Sharebar.svelte";
import { color_by_name } from "../util/Util.svelte"; import { color_by_name } from "../util/Util.svelte";
import { tick } from "svelte";
export let state export let state
export let visible = false export let visible = false
export const toggle = () => visible = !visible export const toggle = () => visible = !visible
$: visibility_change(visible) $: visibility_change(visible)
const visibility_change = (visible) => { const visibility_change = visible => {
if (visible) { if (visible) {
update_chart(state.base, 0, 0) update_chart(state.base, 0, 0)
} }
@@ -40,7 +41,12 @@ let total_bandwidth_paid = 0
$: update_chart(state.base, chart_timespan, chart_interval) $: update_chart(state.base, chart_timespan, chart_interval)
let update_chart = async (base, timespan, interval) => { let update_chart = async (base, timespan, interval) => {
if (!visible) { if (chart === undefined) {
// Wait for the chart element to render, if it's not rendered already
await tick()
}
if (!visible || base.type !== "file" || chart === undefined) {
return return
} }
@@ -170,6 +176,7 @@ let update_chart = async (base, timespan, interval) => {
{/if} {/if}
</table> </table>
{#if state.base.type === "file"}
<h3 class="indent">Download statistics</h3> <h3 class="indent">Download statistics</h3>
<div class="button_bar"> <div class="button_bar">
@@ -183,6 +190,7 @@ let update_chart = async (base, timespan, interval) => {
</div> </div>
<Chart bind:this={chart} /> <Chart bind:this={chart} />
{/if}
</Modal> </Modal>
<style> <style>