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/src/api/actions/updateUserConfig.ts b/frontend/src/api/actions/updateUserConfig.ts index 84c5ce3d..4557f287 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 { ViewLayoutType } from '../../pages/Home'; import APIClient from '../../functions/APIClient'; +import { SortByType, SortOrderType } from '../loader/loadVideoListByPage'; export type ColourVariants = | 'dark.css' diff --git a/frontend/src/api/loader/loadVideoListByPage.ts b/frontend/src/api/loader/loadVideoListByPage.ts index 06066f77..b598df87 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,45 @@ 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', +}; + +export const SortByExpandedEnum = { + ...SortByEnum, + 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/Filterbar.tsx b/frontend/src/components/Filterbar.tsx index 57394b19..32a91b1d 100644 --- a/frontend/src/components/Filterbar.tsx +++ b/frontend/src/components/Filterbar.tsx @@ -4,10 +4,15 @@ import iconAdd from '/img/icon-add.svg'; import iconSubstract from '/img/icon-substract.svg'; import iconGridView from '/img/icon-gridview.svg'; import iconListView from '/img/icon-listview.svg'; -import { SortByType, SortOrderType } from '../pages/Home'; import { useUserConfigStore } from '../stores/UserConfigStore'; import { ViewStyles } from '../configuration/constants/ViewStyle'; import updateUserConfig, { UserConfigType } from '../api/actions/updateUserConfig'; +import { + SortByEnum, + SortByType, + SortOrderEnum, + SortOrderType, +} from '../api/loader/loadVideoListByPage'; type FilterbarProps = { hideToggleText: string; @@ -67,12 +72,9 @@ const Filterbar = ({ hideToggleText, viewStyleName, showSort = true }: Filterbar handleUserConfigUpdate({ sort_by: event.target.value as SortByType }); }} > - - - - - - + {Object.entries(SortByEnum).map(([key, value]) => { + return ; + })} diff --git a/frontend/src/components/SettingsNavigation.tsx b/frontend/src/components/SettingsNavigation.tsx index 5475614b..970f16b7 100644 --- a/frontend/src/components/SettingsNavigation.tsx +++ b/frontend/src/components/SettingsNavigation.tsx @@ -26,6 +26,9 @@ const SettingsNavigation = () => {
+ Show watched:{' '}
+
+
+ Sort by:
+
+
+
No videos found
} + + {hasVideos && ( +| + {channel.channel_name} + | ++ {title} + | +{vid_type} | +{videoStream.width} | +{videoStream.height} | +{humanFileSize(media_size, useSiUnits)} | +{videoStream.codec} | +{humanFileSize(videoStream.bitrate, useSiUnits)} | +{audioStream.codec} | +{humanFileSize(audioStream.bitrate, useSiUnits)} | +
| Channel name | +Video title | +Type | +
+ {
+ onHeaderClicked('width');
+ }}
+ >
+
+
+
+ |
+
+ {
+ onHeaderClicked('height');
+ }}
+ >
+ |
+
+ {
+ onHeaderClicked('mediasize');
+ }}
+ >
+ |
+ Video codec | +Video bitrate | +Audio codec | +Audio bitrate | +
|---|