diff --git a/backend/user/serializers.py b/backend/user/serializers.py index 3c89d5cb..be617437 100644 --- a/backend/user/serializers.py +++ b/backend/user/serializers.py @@ -31,7 +31,9 @@ class UserMeConfigSerializer(serializers.Serializer): page_size = serializers.IntegerField() sort_by = serializers.ChoiceField(choices=SortEnum.names()) sort_order = serializers.ChoiceField(choices=OrderEnum.values()) - view_style_home = serializers.ChoiceField(choices=["grid", "list"]) + view_style_home = serializers.ChoiceField( + choices=["grid", "list", "table"] + ) view_style_channel = serializers.ChoiceField(choices=["grid", "list"]) view_style_downloads = serializers.ChoiceField(choices=["grid", "list"]) view_style_playlist = serializers.ChoiceField(choices=["grid", "list"]) diff --git a/backend/video/src/constants.py b/backend/video/src/constants.py index 12fc4b23..11b7de74 100644 --- a/backend/video/src/constants.py +++ b/backend/video/src/constants.py @@ -31,6 +31,8 @@ class SortEnum(enum.Enum): LIKES = "stats.like_count" DURATION = "player.duration" MEDIASIZE = "media_size" + WIDTH = "streams.width" + HEIGHT = "streams.height" @classmethod def values(cls) -> list[str]: diff --git a/frontend/public/img/icon-tableview.svg b/frontend/public/img/icon-tableview.svg new file mode 100644 index 00000000..fe81095c --- /dev/null +++ b/frontend/public/img/icon-tableview.svg @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/frontend/src/api/actions/updateUserConfig.ts b/frontend/src/api/actions/updateUserConfig.ts index ac806e20..9d2aac7a 100644 --- a/frontend/src/api/actions/updateUserConfig.ts +++ b/frontend/src/api/actions/updateUserConfig.ts @@ -1,5 +1,6 @@ -import { SortByType, SortOrderType, ViewLayoutType } from '../../pages/Home'; +import { ViewStylesType } from '../../configuration/constants/ViewStyle'; import APIClient from '../../functions/APIClient'; +import { SortByType, SortOrderType } from '../loader/loadVideoListByPage'; export type ColourVariants = | 'dark.css' @@ -26,10 +27,10 @@ export type UserConfigType = { page_size: number; sort_by: SortByType; sort_order: SortOrderType; - view_style_home: ViewLayoutType; - view_style_channel: ViewLayoutType; - view_style_downloads: ViewLayoutType; - view_style_playlist: ViewLayoutType; + view_style_home: ViewStylesType; + view_style_channel: ViewStylesType; + view_style_downloads: ViewStylesType; + view_style_playlist: ViewStylesType; grid_items: number; hide_watched: boolean; file_size_unit: 'binary' | 'metric'; diff --git a/frontend/src/api/loader/loadVideoListByPage.ts b/frontend/src/api/loader/loadVideoListByPage.ts index 06066f77..b7a4af93 100644 --- a/frontend/src/api/loader/loadVideoListByPage.ts +++ b/frontend/src/api/loader/loadVideoListByPage.ts @@ -1,4 +1,4 @@ -import { ConfigType, SortByType, SortOrderType, VideoType } from '../../pages/Home'; +import { ConfigType, VideoType } from '../../pages/Home'; import { PaginationType } from '../../components/Pagination'; import APIClient from '../../functions/APIClient'; @@ -8,9 +8,41 @@ export type VideoListByFilterResponseType = { paginate?: PaginationType; }; -type WatchTypes = 'watched' | 'unwatched' | 'continue'; +export type SortByType = + | 'published' + | 'downloaded' + | 'views' + | 'likes' + | 'duration' + | 'mediasize' + | 'width' + | 'height'; +export const SortByEnum = { + Published: 'published', + Downloaded: 'downloaded', + Views: 'views', + Likes: 'likes', + Duration: 'duration', + 'Media Size': 'mediasize', + Width: 'width', + Height: 'height', +}; + +export type SortOrderType = 'asc' | 'desc'; +export const SortOrderEnum = { + Asc: 'asc', + Desc: 'desc', +}; + export type VideoTypes = 'videos' | 'streams' | 'shorts'; +export type WatchTypes = 'watched' | 'unwatched' | 'continue'; +export const WatchTypesEnum = { + Watched: 'watched', + Unwatched: 'unwatched', + Continue: 'continue', +}; + type FilterType = { page?: number; playlist?: string; diff --git a/frontend/src/components/ChannelList.tsx b/frontend/src/components/ChannelList.tsx index 9bb42e50..75319fe5 100644 --- a/frontend/src/components/ChannelList.tsx +++ b/frontend/src/components/ChannelList.tsx @@ -16,7 +16,7 @@ type ChannelListProps = { const ChannelList = ({ channelList, refreshChannelList }: ChannelListProps) => { const { userConfig } = useUserConfigStore(); - const viewLayout = userConfig.view_style_channel; + const viewStyle = userConfig.view_style_channel; if (!channelList || channelList.length === 0) { return
No channels found.
; @@ -26,8 +26,8 @@ const ChannelList = ({ channelList, refreshChannelList }: ChannelListProps) => { <> {channelList.map(channel => { return ( -No playlists found.
; @@ -24,7 +24,7 @@ const PlaylistList = ({ playlistList, setRefresh }: PlaylistListProps) => { <> {playlistList.map((playlist: PlaylistType) => { return ( -