From dc69b4086c2a9d521285a8741af44f5df12f8804 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Mon, 8 Aug 2022 18:44:07 +0200 Subject: [PATCH] Split activity graph into component & typed --- src/api.ts | 6 +- src/components/Graph.vue | 191 ++++++++++++++ src/icons/IconActivity.vue | 8 +- src/icons/IconSettings.vue | 1 - src/pages/ActivityPage.vue | 507 +++++++++++++++---------------------- 5 files changed, 399 insertions(+), 314 deletions(-) create mode 100644 src/components/Graph.vue diff --git a/src/api.ts b/src/api.ts index 91582da..1a6fabd 100644 --- a/src/api.ts +++ b/src/api.ts @@ -444,8 +444,8 @@ const unlinkPlexAccount = () => { // - - - User graphs - - - -const fetchChart = (urlPath, days, chartType) => { - const url = new URL("/api/v1/user" + urlPath, SEASONED_URL); +const fetchGraphData = (urlPath, days, chartType) => { + const url = new URL("/api/v1/user/" + urlPath, SEASONED_URL); url.searchParams.append("days", days); url.searchParams.append("y_axis", chartType); @@ -544,7 +544,7 @@ export { logout, getSettings, updateSettings, - fetchChart, + fetchGraphData, getEmoji, elasticSearchMoviesAndShows }; diff --git a/src/components/Graph.vue b/src/components/Graph.vue new file mode 100644 index 0000000..cd8ff43 --- /dev/null +++ b/src/components/Graph.vue @@ -0,0 +1,191 @@ + + + + + diff --git a/src/icons/IconActivity.vue b/src/icons/IconActivity.vue index 396de1a..d8a381e 100644 --- a/src/icons/IconActivity.vue +++ b/src/icons/IconActivity.vue @@ -5,13 +5,17 @@ width="24" height="24" viewBox="0 0 24 24" - fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" - style="transition: stroke-width 0.5s ease" > + + diff --git a/src/icons/IconSettings.vue b/src/icons/IconSettings.vue index 6aea9df..9f515b2 100644 --- a/src/icons/IconSettings.vue +++ b/src/icons/IconSettings.vue @@ -10,7 +10,6 @@ stroke-width="2" stroke-linecap="round" stroke-linejoin="round" - style="transition: stroke-width 0.5s ease" > diff --git a/src/pages/ActivityPage.vue b/src/pages/ActivityPage.vue index fefb0ee..adce7f9 100644 --- a/src/pages/ActivityPage.vue +++ b/src/pages/ActivityPage.vue @@ -12,6 +12,7 @@ type="number" pattern="[0-9]*" :style="{ maxWidth: `${3 + 0.5 * days.length}rem` }" + @change="fetchChartData" /> @@ -19,348 +20,238 @@ Data sorted by:

Activity per day:

-
- +
+

Activity per day of week:

-
- +
+
-
-

Must be authenticated

+
+

Must be authenticated

-