ycdl/frontends/ycdl_flask/templates/channels.html

114 lines
3 KiB
HTML
Raw Normal View History

2016-11-29 04:16:16 +00:00
<!DOCTYPE html5>
<html>
<head>
{% import "header.html" as header %}
<title>Channels</title>
<meta charset="UTF-8">
2020-01-07 05:55:01 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="icon" href="/favicon.png" type="image/png"/>
<link rel="stylesheet" href="/static/css/common.css">
<link rel="stylesheet" href="/static/css/ycdl.css">
2023-06-24 19:01:11 +00:00
{% if theme %}<link rel="stylesheet" href="/static/css/theme_{{theme}}.css">{% endif %}
<script src="/static/js/common.js"></script>
2020-06-17 21:13:33 +00:00
<script src="/static/js/api.js"></script>
<script src="/static/js/http.js"></script>
2022-03-15 20:52:29 +00:00
<script src="/static/js/spinners.js"></script>
2016-11-29 04:16:16 +00:00
<style>
#new_channel_textbox,
#new_channel_button
{
width: 200px;
}
2021-06-05 03:48:51 +00:00
#channel_list
{
display: flex;
flex-direction: column;
row-gap: 8px;
2021-06-05 03:48:51 +00:00
}
.channel_card
2016-11-29 04:16:16 +00:00
{
padding: 10px;
border-radius: 4px;
}
</style>
</head>
<body>
{{header.make_header()}}
<div id="content_body">
<div><button class="refresh_button button_with_spinner" onclick="return refresh_all_channels_form(false);">Refresh new videos</button></div>
<div><button class="refresh_button button_with_spinner" onclick="return refresh_all_channels_form(true);">Refresh everything</button></div>
2016-11-29 04:16:16 +00:00
<div>
<input type="text" id="new_channel_textbox" placeholder="Channel id">
<button id="new_channel_button" class="button_with_spinner" onclick="return add_channel_form();">Add new channel</button>
2016-11-29 04:16:16 +00:00
</div>
2021-06-05 03:48:51 +00:00
<div id="channel_list">
{% for channel in channels|sort(attribute='name', case_sensitive=False) %}
{% if channel.has_pending() %}
<div class="channel_card channel_card_pending">
2016-11-29 04:16:16 +00:00
{% else %}
<div class="channel_card channel_card_no_pending">
2016-11-29 04:16:16 +00:00
{% endif %}
<a href="/channel/{{channel.id}}">{{channel.name}}</a> <a href="/channel/{{channel.id}}/pending">(p)</a>
{% if channel.automark not in [none, "pending"] %}
<span>(automark: {{channel.automark}})</span>
{% endif %}
{% if not channel.autorefresh %}
<span>(autorefresh: no)</span>
{% endif %}
2016-11-29 04:16:16 +00:00
</div>
{% endfor %}
</div>
2016-11-29 04:16:16 +00:00
</div>
</body>
<script type="text/javascript">
var box = document.getElementById('new_channel_textbox');
var button = document.getElementById('new_channel_button');
common.bind_box_to_button(box, button);
2016-11-29 04:16:16 +00:00
2020-08-20 22:09:37 +00:00
function add_channel_form()
2016-11-29 04:16:16 +00:00
{
if (box.value === "")
2016-11-29 04:16:16 +00:00
{
2022-03-15 20:52:29 +00:00
return spinners.BAIL;
2016-11-29 04:16:16 +00:00
}
api.channels.add_channel(box.value, add_channel_callback);
2016-11-29 04:16:16 +00:00
}
function add_channel_callback(response)
2016-11-29 04:16:16 +00:00
{
if (response.meta.status == 200)
{
window.location.href = "/channel/" + response.data.id;
}
else
{
alert(JSON.stringify(response));
}
}
function refresh_all_channels_form(force)
{
console.log(`Refreshing all channels, force=${force}.`);
api.channels.refresh_all_channels(force, refresh_all_channels_callback)
}
function refresh_all_channels_callback(response)
{
if (response.meta.status == 200)
{
common.refresh();
}
else
{
alert(JSON.stringify(response));
}
}
2016-11-29 04:16:16 +00:00
</script>
</html>