From dd51c329e0c91bd2758eef7bcfda67ad172c55c1 Mon Sep 17 00:00:00 2001 From: aunefyren Date: Sat, 15 Oct 2022 23:47:53 +0200 Subject: [PATCH] CSS updates and leaderboard stats Expanding items on hover Admin can enable/disable leaderboard stats --- config_default.json | 1 + file_config.go | 1 + models.go | 1 + route_statistics.go | 20 ++++++++++++++++++++ web/admin.js | 12 ++++++++++++ web/admin/index.html | 1 + web/assets/css/wrapped.css | 15 +++++++++------ web/get_stats.js | 24 +++++++++++++++--------- 8 files changed, 60 insertions(+), 15 deletions(-) diff --git a/config_default.json b/config_default.json index 8a2cd80..7e66932 100644 --- a/config_default.json +++ b/config_default.json @@ -78,6 +78,7 @@ "get_year_stats_music":true, "get_year_stats_music_title":"Top artists", "get_year_stats_leaderboard":true, + "get_year_stats_leaderboard_number":false, "get_year_stats_leaderboard_title":"Top users", "get_year_stats_movies_duration_title":"All users combined spent {movie_duration_sum} watching movies.", "get_year_stats_shows_duration_title":"All users combined spent {show_duration_sum} watching shows.", diff --git a/file_config.go b/file_config.go index 6711037..9dcdd59 100644 --- a/file_config.go +++ b/file_config.go @@ -134,6 +134,7 @@ func CreateConfigFile() error { config.WrapperrCustomize.GetYearStatsShows = true config.WrapperrCustomize.GetYearStatsMusic = true config.WrapperrCustomize.GetYearStatsLeaderboard = true + config.WrapperrCustomize.GetYearStatsLeaderboardNumbers = false err := SaveConfig(&config) if err != nil { diff --git a/models.go b/models.go index 5a351af..6acc989 100644 --- a/models.go +++ b/models.go @@ -148,6 +148,7 @@ type WrapperrCustomize struct { GetYearStatsMusic bool `json:"get_year_stats_music"` GetYearStatsMusicTitle string `json:"get_year_stats_music_title"` GetYearStatsLeaderboard bool `json:"get_year_stats_leaderboard"` + GetYearStatsLeaderboardNumbers bool `json:"get_year_stats_leaderboard_numbers"` GetYearStatsLeaderboardTitle string `json:"get_year_stats_leaderboard_title"` GetYearStatsMoviesDurationTitle string `json:"get_year_stats_movies_duration_title"` GetYearStatsShowsDurationTitle string `json:"get_year_stats_shows_duration_title"` diff --git a/route_statistics.go b/route_statistics.go index 88e5a11..11effa6 100644 --- a/route_statistics.go +++ b/route_statistics.go @@ -1066,6 +1066,26 @@ func WrapperrLoopData(user_id int, config *WrapperrConfig, wrapperr_data []Wrapp wrapperr_reply.YearStats.YearMovies.Message = "All users processed." + // Scrub the data after ordering array + if !config.WrapperrCustomize.GetYearStatsLeaderboardNumbers { + for index, _ := range wrapperr_reply.YearStats.YearUsers.Data.UsersPlays { + wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].Duration = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].DurationArtists = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].DurationMovies = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].DurationShows = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].Plays = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].PausedCounter = 0 + } + for index, _ := range wrapperr_reply.YearStats.YearUsers.Data.UsersDuration { + wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].Duration = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].DurationArtists = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].DurationMovies = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].DurationShows = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].Plays = 0 + wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].PausedCounter = 0 + } + } + } else { wrapperr_reply.YearStats.YearUsers.Data.UsersDuration = []WrapperrYearUserEntry{} wrapperr_reply.YearStats.YearUsers.Data.UsersPlays = []WrapperrYearUserEntry{} diff --git a/web/admin.js b/web/admin.js index b194a4f..aee9fb7 100644 --- a/web/admin.js +++ b/web/admin.js @@ -1349,6 +1349,15 @@ function set_wrapperr_customization() { html += '/>
'; html += ''; + html += '
'; + html += '