diff --git a/app/src/components/Archive.js b/app/src/components/Archive.js index d456b221..fecb705b 100644 --- a/app/src/components/Archive.js +++ b/app/src/components/Archive.js @@ -39,7 +39,7 @@ import { import {deleteArchives, postDownload, tagFileGroup, untagFileGroup} from "../api"; import {Link, Route, Routes, useNavigate, useParams} from "react-router-dom"; import Message from "semantic-ui-react/dist/commonjs/collections/Message"; -import {useArchive, useDomains, useSearchArchives, useSearchDomain} from "../hooks/customHooks"; +import {useArchive, useDomains, useSearchArchives, useSearchDomain, useSearchOrder} from "../hooks/customHooks"; import {FileCards, FileRowTagIcon, FilesView} from "./Files"; import Grid from "semantic-ui-react/dist/commonjs/collections/Grid"; import _ from "lodash"; @@ -537,6 +537,8 @@ function ArchivesPage() { export function ArchiveRowCells({file}) { const {data} = file; + let {sort} = useSearchOrder(); + sort = sort ? sort.replace(/^-+/, '') : null; const archiveUrl = `/archive/${data.id}`; const posterPath = findPosterPath(file); @@ -551,6 +553,17 @@ export function ArchiveRowCells({file}) { poster = ; } + let dataCell = file.published_datetime ? isoDatetimeToString(file.published_datetime) : ''; + if (sort === 'published_modified_datetime') { + dataCell = file.published_modified_datetime ? isoDatetimeToString(file.published_modified_datetime) : ''; + } else if (sort === 'download_datetime') { + dataCell = file.download_datetime ? isoDatetimeToString(file.download_datetime) : ''; + } else if (sort === 'size') { + dataCell = humanFileSize(file.size); + } else if (sort === 'viewed') { + dataCell = isoDatetimeToString(file.viewed); + } + // Fragment for SelectableRow return @@ -562,6 +575,7 @@ export function ArchiveRowCells({file}) { {textEllipsis(file.title || file.stem)} + {dataCell} } diff --git a/app/src/components/Files.js b/app/src/components/Files.js index eacba3ba..c0a4054b 100644 --- a/app/src/components/Files.js +++ b/app/src/components/Files.js @@ -190,6 +190,7 @@ function ImageRowCells({file}) {

{textEllipsis(file.title || file.stem || file.primary_path)}

+ {humanFileSize(file.size)} } @@ -212,6 +213,7 @@ export function EbookRowCells({file}) { {textEllipsis(file.title || file.stem)} + {humanFileSize(file.size)} } @@ -239,12 +241,13 @@ function FileRow({file}) { {textEllipsis(file.title || file.name || file.stem)} + } export function FileTable({files, selectOn, onSelect, footer, selectedKeys}) { if (files && files.length > 0) { - const headerContents = ['Poster', 'Title']; + const headerContents = ['Poster', 'Title', 'Data']; const rows = files.map(i => ); return ; - let header = {file.title || file.name || video.stem || video.name}; + let header = {file.title || file.name || video.stem || video.name}; if (video_url) { // Link to Channel-Video page or Video page. header = {header}; @@ -341,6 +352,8 @@ export function VideoCard({file}) { export function VideoRowCells({file}) { const {video} = file; + let {sort} = useSearchOrder(); + sort = sort ? sort.replace(/^-+/, '') : null; let video_url = `/videos/video/${video.id}`; const poster_path = findPosterPath(file); @@ -358,6 +371,17 @@ export function VideoRowCells({file}) { poster = ; } + let dataCell = file.published_datetime ? isoDatetimeToString(file.published_datetime) : ''; + if (sort === 'length') { + dataCell = secondsToFullDuration(file.length || 0); + } else if (sort === 'size') { + dataCell = humanFileSize(file.size); + } else if (sort === 'view_count') { + dataCell = humanNumber(video.view_count || 0); + } else if (sort === 'viewed') { + dataCell = isoDatetimeToString(file.viewed); + } + // Fragment for SelectableRow return @@ -371,5 +395,6 @@ export function VideoRowCells({file}) { {textEllipsis(file.title || video.stem || video.video_path)} + {dataCell} } diff --git a/wrolpi/files/models.py b/wrolpi/files/models.py index a0a7d01c..98e79e5e 100644 --- a/wrolpi/files/models.py +++ b/wrolpi/files/models.py @@ -125,7 +125,8 @@ class FileGroup(ModelHelper, Base): 'suffix': suffix, 'tags': tags, 'title': self.title, - 'url': self.url + 'url': self.url, + 'viewed': self.viewed, } return d