add reindex buttons to templates
This commit is contained in:
parent
71dd63d3f0
commit
18f6455eb2
|
@ -47,10 +47,20 @@
|
|||
{% elif channel_info.channel_views > 0 %}
|
||||
<p>Channel views: {{ channel_info.channel_views|intcomma }}</p>
|
||||
{% endif %}
|
||||
<button onclick="deleteConfirm()" id="delete-item">Delete Channel</button>
|
||||
<div class="delete-confirm" id="delete-button">
|
||||
<span>Delete {{ channel_info.channel_name }} including all videos? </span><button class="danger-button" onclick="deleteChannel(this)" data-id="{{ channel_info.channel_id }}">Delete</button> <button onclick="cancelDelete()">Cancel</button>
|
||||
<div class="button-box">
|
||||
<button onclick="deleteConfirm()" id="delete-item">Delete Channel</button>
|
||||
<div class="delete-confirm" id="delete-button">
|
||||
<span>Delete {{ channel_info.channel_name }} including all videos? </span><button class="danger-button" onclick="deleteChannel(this)" data-id="{{ channel_info.channel_id }}">Delete</button> <button onclick="cancelDelete()">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
{% if reindex %}
|
||||
<p>Reindex scheduled</p>
|
||||
{% else %}
|
||||
<div id="reindex-button" class="button-box">
|
||||
<button data-id="{{ channel_info.channel_id }}" data-type="channel" onclick="reindex(this)" title="Reindex Channel {{ channel_info.channel_name }}">Reindex</button>
|
||||
<button data-id="{{ channel_info.channel_id }}" data-type="channel" data-extract-videos="true" onclick="reindex(this)" title="Reindex Videos of {{ channel_info.channel_name }}">Reindex Videos</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -52,6 +52,14 @@
|
|||
<p>Total Videos archived: {{ max_hits }}/{{ playlist_info.playlist_entries|length }}</p>
|
||||
<p>Watched: <button title="Mark all videos from {{ playlist_info.playlist_name }} as watched" type="button" id="watched-button" data-id="{{ playlist_info.playlist_id }}" onclick="isWatchedButton(this)">Mark as watched</button></p>
|
||||
{% endif %}
|
||||
{% if reindex %}
|
||||
<p>Reindex scheduled</p>
|
||||
{% else %}
|
||||
<div id="reindex-button" class="button-box">
|
||||
<button data-id="{{ playlist_info.playlist_id }}" data-type="playlist" onclick="reindex(this)" title="Reindex Playlist {{ playlist_info.playlist_name }}">Reindex</button>
|
||||
<button data-id="{{ playlist_info.playlist_id }}" data-type="playlist" data-extract-videos="true" onclick="reindex(this)" title="Reindex Videos of {{ playlist_info.playlist_name }}">Reindex Videos</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -56,10 +56,19 @@
|
|||
{% else %}
|
||||
<p>Youtube: Deactivated</p>
|
||||
{% endif %}
|
||||
<a download="" href="/media/{{ video.media_url }}"><button id="download-item">Download File</button></a>
|
||||
<button onclick="deleteConfirm()" id="delete-item">Delete Video</button>
|
||||
<div class="delete-confirm" id="delete-button">
|
||||
<span>Are you sure? </span><button class="danger-button" onclick="deleteVideo(this)" data-id="{{ video.youtube_id }}" data-redirect = "{{ video.channel.channel_id }}">Delete</button> <button onclick="cancelDelete()">Cancel</button>
|
||||
{% if reindex %}
|
||||
<p>Reindex scheduled</p>
|
||||
{% else %}
|
||||
<div id="reindex-button" class="button-box">
|
||||
<button data-id="{{ video.youtube_id }}" data-type="video" onclick="reindex(this)" title="Reindex {{ video.title }}">Reindex</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="button-box">
|
||||
<a download="" href="/media/{{ video.media_url }}"><button id="download-item">Download File</button></a>
|
||||
<button onclick="deleteConfirm()" id="delete-item">Delete Video</button>
|
||||
<div class="delete-confirm" id="delete-button">
|
||||
<span>Are you sure? </span><button class="danger-button" onclick="deleteVideo(this)" data-id="{{ video.youtube_id }}" data-redirect = "{{ video.channel.channel_id }}">Delete</button> <button onclick="cancelDelete()">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -35,6 +35,7 @@ from home.src.frontend.searching import SearchHandler
|
|||
from home.src.index.channel import YoutubeChannel, channel_overwrites
|
||||
from home.src.index.generic import Pagination
|
||||
from home.src.index.playlist import YoutubePlaylist
|
||||
from home.src.index.reindex import ReindexProgress
|
||||
from home.src.ta.config import AppConfig, ScheduleBuilder
|
||||
from home.src.ta.helper import UrlListParser, time_parser
|
||||
from home.src.ta.ta_redis import RedisArchivist
|
||||
|
@ -569,17 +570,18 @@ class ChannelIdAboutView(ChannelIdBaseView):
|
|||
self.initiate_vars(request)
|
||||
self.channel_has_pending(channel_id)
|
||||
|
||||
path = f"ta_channel/_doc/{channel_id}"
|
||||
response, _ = ElasticWrap(path).get()
|
||||
|
||||
response, _ = ElasticWrap(f"ta_channel/_doc/{channel_id}").get()
|
||||
channel_info = SearchProcess(response).process()
|
||||
channel_name = channel_info["channel_name"]
|
||||
reindex = ReindexProgress(
|
||||
request_type="channel", request_id=channel_id
|
||||
).get_progress()
|
||||
|
||||
self.context.update(
|
||||
{
|
||||
"title": "Channel: About " + channel_name,
|
||||
"title": "Channel: About " + channel_info["channel_name"],
|
||||
"channel_info": channel_info,
|
||||
"channel_overwrite_form": ChannelOverwriteForm,
|
||||
"reindex": reindex.get("state"),
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -706,12 +708,17 @@ class PlaylistIdView(ArchivistResultsView):
|
|||
self._update_view_data(playlist_id, playlist_info)
|
||||
self.find_results()
|
||||
self.match_progress()
|
||||
reindex = ReindexProgress(
|
||||
request_type="playlist", request_id=playlist_id
|
||||
).get_progress()
|
||||
|
||||
self.context.update(
|
||||
{
|
||||
"title": "Playlist: " + playlist_name,
|
||||
"playlist_info": playlist_info,
|
||||
"playlist_name": playlist_name,
|
||||
"channel_info": channel_info,
|
||||
"reindex": reindex.get("state"),
|
||||
}
|
||||
)
|
||||
return render(request, "home/playlist_id.html", self.context)
|
||||
|
@ -844,11 +851,8 @@ class VideoView(View):
|
|||
def get(self, request, video_id):
|
||||
"""get single video"""
|
||||
config_handler = AppConfig(request.user.id)
|
||||
position = time_parser(request.GET.get("t"))
|
||||
path = f"ta_video/_doc/{video_id}"
|
||||
look_up = SearchHandler(path, config=False)
|
||||
video_hit = look_up.get_data()
|
||||
video_data = video_hit[0]["source"]
|
||||
look_up = SearchHandler(f"ta_video/_doc/{video_id}", config=False)
|
||||
video_data = look_up.get_data()[0]["source"]
|
||||
try:
|
||||
rating = video_data["stats"]["average_rating"]
|
||||
video_data["stats"]["average_rating"] = self.star_creator(rating)
|
||||
|
@ -861,16 +865,20 @@ class VideoView(View):
|
|||
else:
|
||||
playlist_nav = False
|
||||
|
||||
video_title = video_data["title"]
|
||||
reindex = ReindexProgress(
|
||||
request_type="video", request_id=video_id
|
||||
).get_progress()
|
||||
|
||||
context = {
|
||||
"video": video_data,
|
||||
"playlist_nav": playlist_nav,
|
||||
"title": video_title,
|
||||
"title": video_data.get("title"),
|
||||
"colors": config_handler.colors,
|
||||
"cast": config_handler.config["application"]["enable_cast"],
|
||||
"version": settings.TA_VERSION,
|
||||
"config": config_handler.config,
|
||||
"position": position,
|
||||
"position": time_parser(request.GET.get("t")),
|
||||
"reindex": reindex.get("state"),
|
||||
}
|
||||
return render(request, "home/video.html", context)
|
||||
|
||||
|
|
|
@ -119,6 +119,10 @@ button:hover {
|
|||
color: var(--main-bg);
|
||||
}
|
||||
|
||||
.button-box {
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
.unsubscribe {
|
||||
background-color: var(--accent-font-light);
|
||||
}
|
||||
|
|
|
@ -147,6 +147,24 @@ function toggleCheckbox(checkbox) {
|
|||
}, 500);
|
||||
}
|
||||
|
||||
// start reindex task
|
||||
function reindex(button) {
|
||||
let apiEndpoint = '/api/refresh/';
|
||||
if (button.getAttribute('data-extract-videos')) {
|
||||
apiEndpoint += '?extract_videos=true';
|
||||
}
|
||||
let type = button.getAttribute('data-type');
|
||||
let id = button.getAttribute('data-id');
|
||||
|
||||
let data = {};
|
||||
data[type] = [id];
|
||||
|
||||
apiRequest(apiEndpoint, 'POST', data);
|
||||
let message = document.createElement('p');
|
||||
message.innerText = 'Reindex scheduled';
|
||||
document.getElementById('reindex-button').replaceWith(message);
|
||||
}
|
||||
|
||||
// download page buttons
|
||||
function rescanPending() {
|
||||
let payload = JSON.stringify({ rescan_pending: true });
|
||||
|
|
Loading…
Reference in New Issue