diff --git a/files/config.go b/files/config.go index 928e0b8..a46409c 100644 --- a/files/config.go +++ b/files/config.go @@ -136,6 +136,8 @@ func CreateConfigFile() error { config.CreateShareLinks = true config.WinterTheme = true config.BasicAuth = false + config.WrappedDynamic = false + config.WrappedDynamicDays = 0 config.WrapperrCustomize.StatsTopListLength = 10 config.WrapperrCustomize.ObfuscateOtherUsers = true config.WrapperrCustomize.StatsOrderByDuration = true diff --git a/models/config.go b/models/config.go index 24d7f12..4b305f7 100644 --- a/models/config.go +++ b/models/config.go @@ -1,24 +1,26 @@ package models type WrapperrConfig struct { - TautulliConfig []TautulliConfig `json:"tautulli_config"` - WrapperrCustomize WrapperrCustomize `json:"wrapperr_customize"` - WrapperrVersion string `json:"wrapperr_version"` - Timezone string `json:"timezone"` - ApplicationName string `json:"application_name"` - ApplicationURL string `json:"application_url"` - UseCache bool `json:"use_cache"` - UseLogs bool `json:"use_logs"` - ClientKey string `json:"client_key"` - WrapperrRoot string `json:"wrapperr_root"` - PrivateKey string `json:"private_key"` - CreateShareLinks bool `json:"create_share_links"` - WrappedStart int `json:"wrapped_start"` - WrappedEnd int `json:"wrapped_end"` - WrapperrPort int `json:"wrapperr_port"` - PlexAuth bool `json:"plex_auth"` - BasicAuth bool `json:"basic_auth"` - WinterTheme bool `json:"winter_theme"` + TautulliConfig []TautulliConfig `json:"tautulli_config"` + WrapperrCustomize WrapperrCustomize `json:"wrapperr_customize"` + WrapperrVersion string `json:"wrapperr_version"` + Timezone string `json:"timezone"` + ApplicationName string `json:"application_name"` + ApplicationURL string `json:"application_url"` + UseCache bool `json:"use_cache"` + UseLogs bool `json:"use_logs"` + ClientKey string `json:"client_key"` + WrapperrRoot string `json:"wrapperr_root"` + PrivateKey string `json:"private_key"` + CreateShareLinks bool `json:"create_share_links"` + WrappedStart int `json:"wrapped_start"` + WrappedEnd int `json:"wrapped_end"` + WrappedDynamic bool `json:"wrapped_dynamic"` + WrappedDynamicDays int `json:"wrapped_dynamic_days"` + WrapperrPort int `json:"wrapperr_port"` + PlexAuth bool `json:"plex_auth"` + BasicAuth bool `json:"basic_auth"` + WinterTheme bool `json:"winter_theme"` } type WrapperrConfigLegacy struct { @@ -47,17 +49,19 @@ type SetWrapperrConfig struct { TautulliConfig []TautulliConfig `json:"tautulli_config"` WrapperrCustomize WrapperrCustomize `json:"wrapperr_customize"` WrapperrData struct { - UseCache bool `json:"use_cache"` - UseLogs bool `json:"use_logs"` - PlexAuth bool `json:"plex_auth"` - BasicAuth bool `json:"basic_auth"` - WrapperrRoot string `json:"wrapperr_root"` - CreateShareLinks bool `json:"create_share_links"` - Timezone string `json:"timezone"` - ApplicationName string `json:"application_name"` - ApplicationURL string `json:"application_url"` - WrappedStart int `json:"wrapped_start"` - WrappedEnd int `json:"wrapped_end"` - WinterTheme bool `json:"winter_theme"` + UseCache bool `json:"use_cache"` + UseLogs bool `json:"use_logs"` + PlexAuth bool `json:"plex_auth"` + BasicAuth bool `json:"basic_auth"` + WrapperrRoot string `json:"wrapperr_root"` + CreateShareLinks bool `json:"create_share_links"` + Timezone string `json:"timezone"` + ApplicationName string `json:"application_name"` + ApplicationURL string `json:"application_url"` + WrappedStart int `json:"wrapped_start"` + WrappedEnd int `json:"wrapped_end"` + WinterTheme bool `json:"winter_theme"` + WrappedDynamic bool `json:"wrapped_dynamic"` + WrappedDynamicDays int `json:"wrapped_dynamic_days"` } `json:"wrapperr_data"` } diff --git a/modules/statistics.go b/modules/statistics.go index a61a25e..5c045c5 100644 --- a/modules/statistics.go +++ b/modules/statistics.go @@ -36,6 +36,12 @@ func GetWrapperStatistics(user_name string, user_friendlyname string, user_id in log.Println("Cache stage completed for " + user_name + ".") + // Change wrapped start & end dates if dynamic setting is configured + if config.WrappedDynamic { + config.WrappedEnd = int(time.Now().Unix()) + config.WrappedStart = int(time.Now().AddDate(0, 0, -config.WrappedDynamicDays).Unix()) + } + // Download/refresh data-set from Tautulli wrapperr_data, wrapperr_data_complete, err := WrapperrDownloadDays(user_id, wrapperr_data, cacheLimit, config) if err != nil { diff --git a/routes/admin.go b/routes/admin.go index ae25cd8..49bcb35 100644 --- a/routes/admin.go +++ b/routes/admin.go @@ -117,6 +117,8 @@ func ApiSetConfig(context *gin.Context) { config.ApplicationURL = config_payload.WrapperrData.ApplicationURL config.WrappedEnd = config_payload.WrapperrData.WrappedEnd config.WrappedStart = config_payload.WrapperrData.WrappedStart + config.WrappedDynamic = config_payload.WrapperrData.WrappedDynamic + config.WrappedDynamicDays = config_payload.WrapperrData.WrappedDynamicDays config.WinterTheme = config_payload.WrapperrData.WinterTheme err = files.SaveConfig(config) diff --git a/web/assets/css/admin.css b/web/assets/css/admin.css index 5a676b6..ae48972 100644 --- a/web/assets/css/admin.css +++ b/web/assets/css/admin.css @@ -518,4 +518,12 @@ a { align-content: center; justify-content: center; align-items: center; +} + +.dynamic-enabled, .static-enabled { + display: flex; +} + +.dynamic-disabled, .static-disabled { + display: none; } \ No newline at end of file diff --git a/web/html/settings.html b/web/html/settings.html index 9c483cd..b952db5 100644 --- a/web/html/settings.html +++ b/web/html/settings.html @@ -81,6 +81,8 @@ var application_url_str = ''; var wrapped_start = ''; var wrapped_end = ''; +var wrapped_dynamic = false; +var wrapped_dynamic_days = 0; var create_share_links = ''; var obfuscate_other_users = false; diff --git a/web/js/adminFunctions.js b/web/js/adminFunctions.js index 82ae60b..7891598 100644 --- a/web/js/adminFunctions.js +++ b/web/js/adminFunctions.js @@ -164,6 +164,9 @@ function get_config(cookie) { wrapped_end = new Date(0); wrapped_end.setUTCSeconds(result.data.wrapped_end); + wrapped_dynamic = result.data.wrapped_dynamic + wrapped_dynamic_days = result.data.wrapped_dynamic_days + stats_order_by_plays = result.data.wrapperr_customize.stats_order_by_plays; stats_order_by_duration = result.data.wrapperr_customize.stats_order_by_duration; diff --git a/web/js/settings.js b/web/js/settings.js index efab2b8..c41cff9 100644 --- a/web/js/settings.js +++ b/web/js/settings.js @@ -25,6 +25,20 @@ function loadAdminPage() { html += '