From 70695b6854f33a492a0d75ff4421c89d09fafd4e Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Sun, 31 Jan 2021 11:46:31 +0200 Subject: [PATCH] Display query path on success as well --- .../queries/filter/filters/AllPlayersFilter.java | 2 +- .../main/resources/assets/plan/web/js/query.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/filters/AllPlayersFilter.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/filters/AllPlayersFilter.java index 0866968e4..74b27098e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/filters/AllPlayersFilter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/filters/AllPlayersFilter.java @@ -43,7 +43,7 @@ public class AllPlayersFilter implements Filter { @Override public String getKind() { - return "all"; + return "allPlayers"; } @Override diff --git a/Plan/common/src/main/resources/assets/plan/web/js/query.js b/Plan/common/src/main/resources/assets/plan/web/js/query.js index 72ce2f762..506d30e8a 100644 --- a/Plan/common/src/main/resources/assets/plan/web/js/query.js +++ b/Plan/common/src/main/resources/assets/plan/web/js/query.js @@ -260,7 +260,7 @@ function getQueryAddress() { if (timestamp) return `./v1/query?timestamp=${timestamp}`; const encodedQuery = encodeURIComponent(JSON.stringify(query)); - const encodedView = encodeURIComponent(JSON.stringify(queryState.filters)); + const encodedView = encodeURIComponent(JSON.stringify(queryState.view)); return `./v1/query?q=${encodedQuery}&view=${encodedView}`; } @@ -280,10 +280,11 @@ function runQuery() { if (previousPath) previousPath.remove(); if (json) { if (json.data) { - renderResults(json); + displayResults(json); + displayResultPath(json); } else if (json.path) { // filters resulted in 0 players matched - renderResultPath(json); + displayResultPath(json); // Reset query queryButton.removeAttribute('disabled'); queryButton.classList.remove('disabled'); @@ -300,7 +301,7 @@ function runQuery() { }); } -function renderResultPath(json) { +function displayResultPath(json) { const gotResults = Boolean(json.data); let pathHtml = ``; for (let i = 0; i < json.path.length; i++) { @@ -322,8 +323,8 @@ function renderResultPath(json) { window.scrollTo(0, 0); // Scroll to top } -function renderResults(json) { - renderDataResultScreen(json.data.players.data.length, json.view ? json.view : {}); +function displayResults(json) { + displayDataResultScreen(json.data.players.data.length, json.view ? json.view : {}); // Set URL so that the query result can be shared window.history.replaceState({}, '', `${location.pathname}?timestamp=${json.timestamp}`); @@ -383,7 +384,7 @@ function renderResults(json) { document.querySelector("#data_average_session_length").innerHTML = session_data.average_session_length; } -function renderDataResultScreen(resultCount, view) { +function displayDataResultScreen(resultCount, view) { const afterDate = queryState.view.afterDate ? queryState.view.afterDate : view.afterDate; const beforeDate = queryState.view.beforeDate ? queryState.view.beforeDate : view.beforeDate; const afterTime = queryState.view.afterTime ? queryState.view.afterTime : view.afterTime;