mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 20:29:36 +00:00
Add Ignored tab to Channel page (#927)
* Add Ignored tab to Channel page * fix for Ignored button action * use ignored parameter as bool --------- Co-authored-by: Simon <simobilleter@gmail.com>
This commit is contained in:
@@ -90,6 +90,7 @@ class ChannelNavSerializer(serializers.Serializer):
|
|||||||
"""serialize channel navigation"""
|
"""serialize channel navigation"""
|
||||||
|
|
||||||
has_pending = serializers.BooleanField()
|
has_pending = serializers.BooleanField()
|
||||||
|
has_ignored = serializers.BooleanField()
|
||||||
has_playlists = serializers.BooleanField()
|
has_playlists = serializers.BooleanField()
|
||||||
has_videos = serializers.BooleanField()
|
has_videos = serializers.BooleanField()
|
||||||
has_streams = serializers.BooleanField()
|
has_streams = serializers.BooleanField()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class ChannelNav:
|
|||||||
"""build nav items"""
|
"""build nav items"""
|
||||||
nav = {
|
nav = {
|
||||||
"has_pending": self._get_has_pending(),
|
"has_pending": self._get_has_pending(),
|
||||||
|
"has_ignored": self._get_has_ignored(),
|
||||||
"has_playlists": self._get_has_playlists(),
|
"has_playlists": self._get_has_playlists(),
|
||||||
}
|
}
|
||||||
nav.update(self._get_vid_types())
|
nav.update(self._get_vid_types())
|
||||||
@@ -63,6 +64,24 @@ class ChannelNav:
|
|||||||
|
|
||||||
return bool(response["hits"]["hits"])
|
return bool(response["hits"]["hits"])
|
||||||
|
|
||||||
|
def _get_has_ignored(self):
|
||||||
|
"""Check if there are ignored videos in the download queue"""
|
||||||
|
data = {
|
||||||
|
"size": 1,
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"must": [
|
||||||
|
{"term": {"status": {"value": "ignore"}}},
|
||||||
|
{"term": {"channel_id": {"value": self.channel_id}}},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"_source": False,
|
||||||
|
}
|
||||||
|
response, _ = ElasticWrap("ta_download/_search").get(data=data)
|
||||||
|
|
||||||
|
return bool(response["hits"]["hits"])
|
||||||
|
|
||||||
def _get_has_playlists(self):
|
def _get_has_playlists(self):
|
||||||
"""check if channel has playlists"""
|
"""check if channel has playlists"""
|
||||||
path = "ta_playlist/_search"
|
path = "ta_playlist/_search"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export type ChannelNavResponseType = {
|
|||||||
has_shorts: boolean;
|
has_shorts: boolean;
|
||||||
has_playlists: boolean;
|
has_playlists: boolean;
|
||||||
has_pending: boolean;
|
has_pending: boolean;
|
||||||
|
has_ignored: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadChannelNav = async (youtubeChannelId: string) => {
|
const loadChannelNav = async (youtubeChannelId: string) => {
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ const Routes = {
|
|||||||
Playlists: '/playlist/',
|
Playlists: '/playlist/',
|
||||||
Playlist: (id: string) => `/playlist/${id}`,
|
Playlist: (id: string) => `/playlist/${id}`,
|
||||||
Downloads: '/downloads/',
|
Downloads: '/downloads/',
|
||||||
DownloadsByChannelId: (channelId: string) => `/downloads/?channel=${channelId}`,
|
DownloadsByChannelId: (channelId: string) => `/downloads/?channel=${channelId}&ignored=false`,
|
||||||
|
IgnoredByChannelId: (channelId: string) => `/downloads/?channel=${channelId}&ignored=true`,
|
||||||
Search: '/search/',
|
Search: '/search/',
|
||||||
SettingsDashboard: '/settings/',
|
SettingsDashboard: '/settings/',
|
||||||
SettingsUser: '/settings/user/',
|
SettingsUser: '/settings/user/',
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const ChannelBase = () => {
|
|||||||
const { data: channelNavData } = channelNav ?? {};
|
const { data: channelNavData } = channelNav ?? {};
|
||||||
|
|
||||||
const channel = channelResponseData;
|
const channel = channelResponseData;
|
||||||
const { has_streams, has_shorts, has_playlists, has_pending } = channelNavData || {};
|
const { has_streams, has_shorts, has_playlists, has_pending, has_ignored } = channelNavData || {};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
@@ -84,6 +84,11 @@ const ChannelBase = () => {
|
|||||||
<h3>Downloads</h3>
|
<h3>Downloads</h3>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
{has_ignored && isAdmin && (
|
||||||
|
<Link to={Routes.IgnoredByChannelId(channelId)}>
|
||||||
|
<h3>Ignored</h3>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Notifications
|
<Notifications
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ const Download = () => {
|
|||||||
const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType;
|
const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType;
|
||||||
|
|
||||||
const channelFilterFromUrl = searchParams.get('channel');
|
const channelFilterFromUrl = searchParams.get('channel');
|
||||||
|
const ignoredOnlyParam = searchParams.get('ignored');
|
||||||
|
|
||||||
const [refresh, setRefresh] = useState(false);
|
const [refresh, setRefresh] = useState(false);
|
||||||
const [showHiddenForm, setShowHiddenForm] = useState(false);
|
const [showHiddenForm, setShowHiddenForm] = useState(false);
|
||||||
@@ -82,7 +83,8 @@ const Download = () => {
|
|||||||
|
|
||||||
const view = userConfig.view_style_downloads;
|
const view = userConfig.view_style_downloads;
|
||||||
const gridItems = userConfig.grid_items;
|
const gridItems = userConfig.grid_items;
|
||||||
const showIgnored = userConfig.show_ignored_only;
|
const showIgnored =
|
||||||
|
ignoredOnlyParam !== null ? ignoredOnlyParam === 'true' : userConfig.show_ignored_only;
|
||||||
const isGridView = view === ViewStyles.grid;
|
const isGridView = view === ViewStyles.grid;
|
||||||
const gridView = isGridView ? `boxed-${gridItems}` : '';
|
const gridView = isGridView ? `boxed-${gridItems}` : '';
|
||||||
const gridViewGrid = isGridView ? `grid-${gridItems}` : '';
|
const gridViewGrid = isGridView ? `grid-${gridItems}` : '';
|
||||||
@@ -234,6 +236,9 @@ const Download = () => {
|
|||||||
id="showIgnored"
|
id="showIgnored"
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
handleUserConfigUpdate({ show_ignored_only: !showIgnored });
|
handleUserConfigUpdate({ show_ignored_only: !showIgnored });
|
||||||
|
const newParams = new URLSearchParams(searchParams.toString());
|
||||||
|
newParams.set('ignored', String(!showIgnored));
|
||||||
|
setSearchParams(newParams);
|
||||||
setRefresh(true);
|
setRefresh(true);
|
||||||
}}
|
}}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
|||||||
Reference in New Issue
Block a user