butons to episodes page

pull/53/head
Akhil Gupta 4 years ago
parent 1fee977ab5
commit 665edb0171

@ -340,6 +340,15 @@
}
socket.send(getWebsocketMessage("Enqueue",`{"itemId":"${id}"}`))
}
function enquePodcast(id){
if(!socket){
return
}
socket.send(getWebsocketMessage("Enqueue",`{"podcastId":"${id}"}`))
}
function playPodcast(id){
openPlayer("",id)
}
</script>
</body>
</html>

@ -415,149 +415,7 @@
{{ $len := len .podcasts}}
podcasts: {{if gt $len 0}} {{ .podcasts }} {{else}} [] {{end}},
}})
function downloadAllEpisodes(id) {
var confirmed = confirm(
"Are you sure you want to download all episodes of this podcast?"
);
if (!confirmed) {
return false;
}
axios
.get("/podcasts/" + id + "/download")
.then(function (response) {
Vue.toasted.show(
"All episodes of this podcast have been enqueued to download.",
{
theme: "bubble",
type: "info",
position: "top-right",
duration: 5000,
}
);
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
function deletePodcast(id,onSuccess) {
if (typeof id !== 'string'){
id= id.getAttribute('data-id')
}
console.log(id)
var confirmed = confirm(
"Are you sure you want to delete this podcast and all files?"
);
if (!confirmed) {
return false;
}
axios
.delete("/podcasts/" + id)
.then(function (response) {
Vue.toasted.show("Podcast deleted successfully.", {
theme: "bubble",
type: "success",
position: "top-right",
duration: 5000,
});
app.removePodcast(id)
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
function deletePodcastEpisodes(id) {
if (typeof id !== 'string'){
id= id.getAttribute('data-id')
}
console.log(id);
var confirmed = confirm(
"Are you sure you want to delete all episodes of this podcast?"
);
if (!confirmed) {
return false;
}
axios
.delete("/podcasts/" + id + "/items")
.then(function (response) {
Vue.toasted.show("Podcast Episodes deleted successfully.", {
theme: "bubble",
type: "success",
position: "top-right",
duration: 5000,
});
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
function deleteOnlyPodcast(id) {
if (typeof id !== 'string'){
id= id.getAttribute('data-id')
}
console.log(id);
var confirmed = confirm(
"Are you sure you want to delete this podcast (without deleting the files)?"
);
if (!confirmed) {
return false;
}
axios
.delete("/podcasts/" + id + "/podcast")
.then(function (response) {
Vue.toasted.show("Podcast deleted successfully.", {
theme: "bubble",
type: "success",
position: "top-right",
duration: 5000,
});
app.removePodcast(id)
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
</script>
<script>

@ -142,6 +142,31 @@ div#overlay{
<div></div>
</a>
<h1>{{ .title }}</h1>
{{if .podcastId }}
<button
class="button"
title="Download all episode files"
onclick="downloadAllEpisodes({{ .podcastId }})"
>
<i class="fas fa-download"></i>
</button>
<button
class="button"
title="Play all episodes"
onclick="playPodcast({{ .podcastId }})"
>
<i class="fas fa-play"></i>
</button>
<button
class="button button-enqueue"
title="Add all episodes to existing player playlist"
onclick="enquePodcast({{ .podcastId }})"
>
<i class="fas fa-plus"></i>
</button>
{{end}}
</section>
<nav class="navbar">
<div class="container">

@ -103,5 +103,148 @@
// console.log('Message from server ', event.data);
// });
}
function downloadAllEpisodes(id) {
var confirmed = confirm(
"Are you sure you want to download all episodes of this podcast?"
);
if (!confirmed) {
return false;
}
axios
.get("/podcasts/" + id + "/download")
.then(function (response) {
Vue.toasted.show(
"All episodes of this podcast have been enqueued to download.",
{
theme: "bubble",
type: "info",
position: "top-right",
duration: 5000,
}
);
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
function deletePodcast(id,onSuccess) {
if (typeof id !== 'string'){
id= id.getAttribute('data-id')
}
console.log(id)
var confirmed = confirm(
"Are you sure you want to delete this podcast and all files?"
);
if (!confirmed) {
return false;
}
axios
.delete("/podcasts/" + id)
.then(function (response) {
Vue.toasted.show("Podcast deleted successfully.", {
theme: "bubble",
type: "success",
position: "top-right",
duration: 5000,
});
app.removePodcast(id)
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
function deletePodcastEpisodes(id) {
if (typeof id !== 'string'){
id= id.getAttribute('data-id')
}
console.log(id);
var confirmed = confirm(
"Are you sure you want to delete all episodes of this podcast?"
);
if (!confirmed) {
return false;
}
axios
.delete("/podcasts/" + id + "/items")
.then(function (response) {
Vue.toasted.show("Podcast Episodes deleted successfully.", {
theme: "bubble",
type: "success",
position: "top-right",
duration: 5000,
});
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
function deleteOnlyPodcast(id) {
if (typeof id !== 'string'){
id= id.getAttribute('data-id')
}
console.log(id);
var confirmed = confirm(
"Are you sure you want to delete this podcast (without deleting the files)?"
);
if (!confirmed) {
return false;
}
axios
.delete("/podcasts/" + id + "/podcast")
.then(function (response) {
Vue.toasted.show("Podcast deleted successfully.", {
theme: "bubble",
type: "success",
position: "top-right",
duration: 5000,
});
app.removePodcast(id)
})
.catch(function (error) {
if (error.response && error.response.data && error.response.data.message) {
Vue.toasted.show(error.response.data.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
</script>
{{end}}

@ -82,6 +82,7 @@ func PodcastPage(c *gin.Context) {
"nextPage": nextPage,
"previousPage": previousPage,
"downloadedOnly": false,
"podcastId": searchByIdQuery.Id,
})
} else {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})

Loading…
Cancel
Save