Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client/commoncss.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 40 additions & 6 deletions client/episodes_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<span v-show="!showFilters">Show Filters</span>
<span v-show="showFilters">Hide Filters</span>
</button>
<form @submit.prevent="submitFilters()" v-show="showFilters">
<form id="filters" @submit.prevent="submitFilters()" v-show="showFilters">
<div class="row">
<input class="columns five" type="search" @input="searchQueryUpated()" v-model="filter.q" placeholder="Search">
<div class="columns three"> <vue-multiselect v-model="selectedSorting" :options="sortOptions" :searchable="false"
Expand Down Expand Up @@ -103,8 +103,14 @@
</vue-multiselect>
<div class="columns three"> <vue-multiselect v-model="selectedDownloadStatus" :options="downloadStatusOptions" :searchable="false"
:multiple="false" :close-on-select="true" :clear-on-select="true" :allow-empty="false" :show-labels="false"
placeholder="Sort By" label="Label" track-by="Value" :preselect-first="true">
placeholder="Download Status" label="Label" track-by="Value" :preselect-first="true">
</vue-multiselect></div>
<div class="columns three"> <vue-multiselect v-model="selectedEpisodeType" :options="episodeTypeOptions" :searchable="false"
:multiple="false" :close-on-select="true" :clear-on-select="true" :allow-empty="false" :show-labels="false"
placeholder="Episode Type" label="Label" track-by="Value" :preselect-first="true">
</vue-multiselect></div>
</div>
<div class="row">
<div class="columns three">
<a title="Play items in this page" v-if="podcastItems.length" class="button" @click="playPage()"><i class="fas fa-play"></i></a>
<a title="Enqueue items in this page" v-if="podcastItems.length" class="button button-enqueue" @click="enqueuePage()"><i class="fas fa-plus"></i></a>
Expand Down Expand Up @@ -352,7 +358,11 @@ <h4>
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){
Expand Down Expand Up @@ -400,11 +410,17 @@ <h4>
}

for(var i=0;i<this.downloadStatusOptions.length;i++){
if(this.downloadStatusOptions[i].Value===this.filter.isDownloaded.toString()){
if(this.downloadStatusOptions[i].Value===this.filter.downloadStatus.toString()){
this.selectedDownloadStatus=this.downloadStatusOptions[i]
}
}

for(var i=0;i<this.episodeTypeOptions.length;i++){
if(this.episodeTypeOptions[i].Value===this.filter.episodeType.toString()){
this.selectedEpisodeType=this.episodeTypeOptionsOptions[i]
}
}

for(var i=0;i<this.playedStatusOptions.length;i++){
if(this.playedStatusOptions[i].Value===this.filter.isPlayed.toString()){
this.selectedPlayedStatus=this.playedStatusOptions[i]
Expand Down Expand Up @@ -525,6 +541,7 @@ <h4>
this.selectedPodcasts=[];
this.selectedTags=[];
this.selectedDownloadStatus=this.downloadStatusOptions[0];
this.selectedEpisodeType=this.episodeTypeOptions[0];
this.selectedPlayedStatus=this.playedStatusOptions[0];
},
removeStartingSlash(url){
Expand Down Expand Up @@ -568,6 +585,7 @@ <h4>
selectedPodcasts:[],
selectedTags:[],
selectedDownloadStatus:"",
selectedEpisodeType:"",
selectedPlayedStatus:"",
countOptions:[10,20,30,40,50,100],
showFilters:localStorage && localStorage.showFilters && JSON.parse(localStorage.showFilters),
Expand All @@ -580,8 +598,24 @@ <h4>
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"}
],
}})
</script>

Expand Down
28 changes: 14 additions & 14 deletions db/dbfunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions model/queryModels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down