diff --git a/client/commoncss.html b/client/commoncss.html index 7723449..bda418b 100644 --- a/client/commoncss.html +++ b/client/commoncss.html @@ -51,6 +51,12 @@ max-width: 1140px; } } + form#filters div.row { + margin-bottom: 18px; + } + form#filters div.row input { + margin-bottom: 0; + } .header { margin-top: 6rem; text-align: center; diff --git a/client/episodes_new.html b/client/episodes_new.html index 387974b..ed837fb 100644 --- a/client/episodes_new.html +++ b/client/episodes_new.html @@ -73,7 +73,7 @@ Show Filters Hide Filters -
+
+ placeholder="Download Status" label="Label" track-by="Value" :preselect-first="true">
+
+
+
+
@@ -352,7 +358,11 @@

this.submitFilters() }, selectedDownloadStatus(current,old){ - this.filter.isDownloaded=current.Value; + this.filter.downloadStatus=current.Value; + this.submitFilters() + }, + selectedEpisodeType(current,old){ + this.filter.episodeType=current.Value; this.submitFilters() }, selectedPlayedStatus(current,old){ @@ -400,11 +410,17 @@

} for(var i=0;i this.selectedPodcasts=[]; this.selectedTags=[]; this.selectedDownloadStatus=this.downloadStatusOptions[0]; + this.selectedEpisodeType=this.episodeTypeOptions[0]; this.selectedPlayedStatus=this.playedStatusOptions[0]; }, removeStartingSlash(url){ @@ -568,6 +585,7 @@

selectedPodcasts:[], selectedTags:[], selectedDownloadStatus:"", + selectedEpisodeType:"", selectedPlayedStatus:"", countOptions:[10,20,30,40,50,100], showFilters:localStorage && localStorage.showFilters && JSON.parse(localStorage.showFilters), @@ -580,8 +598,24 @@

tags:{{.tags}}, sortOptions:{{.sortOptions}}, pagingOptions:[10,20,50,100], - downloadStatusOptions:[{"Label":"All","Value":"nil"},{"Label":"Downloaded Only","Value":"true"},{"Label":"Not Downloaded","Value":"false"}], - playedStatusOptions:[{"Label":"All","Value":"nil"},{"Label":"Played Only","Value":"true"},{"Label":"Unplayed only","Value":"false"}], + downloadStatusOptions:[ + {"Label":"All","Value":"nil"}, + {"Label":"Downloaded","Value":"2"}, + {"Label":"Not Downloaded","Value":"0"}, + {"Label":"Deleted","Value":"3"}, + {"Label":"Downloading","Value":"1"} + ], + episodeTypeOptions:[ + {"Label":"All","Value":"nil"}, + {"Label":"Regular Episode","Value":"full"}, + {"Label":"Bonus Episode","Value":"bonus"}, + {"Label":"Trailer","Value":"trailer"} + ], + playedStatusOptions:[ + {"Label":"All","Value":"nil"}, + {"Label":"Played Only","Value":"true"}, + {"Label":"Unplayed only","Value":"false"} + ], }}) diff --git a/db/dbfunctions.go b/db/dbfunctions.go index 7d001ea..f70f8fd 100644 --- a/db/dbfunctions.go +++ b/db/dbfunctions.go @@ -58,14 +58,14 @@ func GetPaginatedPodcastItemsNew(queryModel model.EpisodesFilter) (*[]PodcastIte var podcasts []PodcastItem var total int64 query := DB.Debug().Preload("Podcast") - if queryModel.IsDownloaded != nil { - isDownloaded, err := strconv.ParseBool(*queryModel.IsDownloaded) - if err == nil { - if isDownloaded { - query = query.Where("download_status=?", Downloaded) - } else { - query = query.Where("download_status!=?", Downloaded) - } + if queryModel.DownloadStatus != nil && *queryModel.DownloadStatus != "nil" { + query = query.Where("download_status=?", queryModel.DownloadStatus) + } + if queryModel.EpisodeType != nil && *queryModel.EpisodeType != "nil" { + if *queryModel.EpisodeType == "full" { + query = query.Where(DB.Where("episode_type=\"full\"").Or("episode_type=\"\"")) + } else { + query = query.Where("episode_type=?", queryModel.EpisodeType) } } if queryModel.IsPlayed != nil { @@ -252,16 +252,16 @@ func GetEpisodeNumber(podcastItemId, podcastId string) (int, error) { var id string var sequence int row := DB.Raw(`;With cte as( - SELECT - id, - RANK() OVER (ORDER BY pub_date) as sequence - FROM + SELECT + id, + RANK() OVER (ORDER BY pub_date) as sequence + FROM podcast_items WHERE podcast_id=? ) - select * - from cte + select * + from cte where id = ? `, podcastId, podcastItemId).Row() error := row.Scan(&id, &sequence) diff --git a/model/queryModels.go b/model/queryModels.go index dcc6e5f..c9b49e1 100644 --- a/model/queryModels.go +++ b/model/queryModels.go @@ -22,12 +22,13 @@ const ( type EpisodesFilter struct { Pagination - IsDownloaded *string `uri:"isDownloaded" query:"isDownloaded" json:"isDownloaded" form:"isDownloaded"` - IsPlayed *string `uri:"isPlayed" query:"isPlayed" json:"isPlayed" form:"isPlayed"` - Sorting EpisodeSort `uri:"sorting" query:"sorting" json:"sorting" form:"sorting"` - Q string `uri:"q" query:"q" json:"q" form:"q"` - TagIds []string `uri:"tagIds" query:"tagIds[]" json:"tagIds" form:"tagIds[]"` - PodcastIds []string `uri:"podcastIds" query:"podcastIds[]" json:"podcastIds" form:"podcastIds[]"` + DownloadStatus *string `uri:"downloadStatus" query:"downloadStatus" json:"downloadStatus" form:"downloadStatus"` + EpisodeType *string `uri:"episodeType" query:"episodeType" json:"episodeType" form:"episodeType"` + IsPlayed *string `uri:"isPlayed" query:"isPlayed" json:"isPlayed" form:"isPlayed"` + Sorting EpisodeSort `uri:"sorting" query:"sorting" json:"sorting" form:"sorting"` + Q string `uri:"q" query:"q" json:"q" form:"q"` + TagIds []string `uri:"tagIds" query:"tagIds[]" json:"tagIds" form:"tagIds[]"` + PodcastIds []string `uri:"podcastIds" query:"podcastIds[]" json:"podcastIds" form:"podcastIds[]"` } func (filter *EpisodesFilter) VerifyPaginationValues() {