From 358c6a7f7f2e1695ce960a565fa7854061c917f7 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 22 Oct 2021 18:48:58 +1100 Subject: [PATCH] Fix refresh for embedded csv When we don't have files, refresh from the embedded CSV's Change-Id: I6fef7426b2feda2cf8505c261eecdcc6bd6c9285 --- generate_page_example.html | 12 ++++++++++-- js/dashboard.js | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/generate_page_example.html b/generate_page_example.html index b007b50..4d84849 100644 --- a/generate_page_example.html +++ b/generate_page_example.html @@ -590,8 +590,16 @@ function change_granularity(granularity, aggr_function) { function refresh() { d3.select('#dashboard').html(""); d3.select('#focus').html(""); - for (i in gFiles) { - processFile(gFiles[i]); + if (gFiles.length > 0) { + for (let i = 0; i < gFiles.length; ++i) { + processFile(gFiles[i]); + } + } else { + // If we don't have any files, refresh from the + // embedded CSV's directly + for (let i = 0; i < gCSVs.length; ++i) { + processCSV(gCSVs[i], "csv " + i) + } } } diff --git a/js/dashboard.js b/js/dashboard.js index 08f510b..28028b7 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -567,8 +567,16 @@ function change_granularity(granularity, aggr_function) { function refresh() { d3.select('#dashboard').html(""); d3.select('#focus').html(""); - for (i in gFiles) { - processFile(gFiles[i]); + if (gFiles.length > 0) { + for (let i = 0; i < gFiles.length; ++i) { + processFile(gFiles[i]); + } + } else { + // If we don't have any files, refresh from the + // embedded CSV's directly + for (let i = 0; i < gCSVs.length; ++i) { + processCSV(gCSVs[i], "csv " + i) + } } }