mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Adding data column to file list view, this displays data of the current order_by.
This commit is contained in:
parent
8ff34f5822
commit
2870612436
4 changed files with 48 additions and 5 deletions
|
|
@ -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 = <FileIcon file={file} size='large'/>;
|
||||
}
|
||||
|
||||
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 <React.Fragment>
|
||||
<TableCell>
|
||||
|
|
@ -562,6 +575,7 @@ export function ArchiveRowCells({file}) {
|
|||
{textEllipsis(file.title || file.stem)}
|
||||
</CardLink>
|
||||
</TableCell>
|
||||
<TableCell>{dataCell}</TableCell>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ function ImageRowCells({file}) {
|
|||
<p>{textEllipsis(file.title || file.stem || file.primary_path)}</p>
|
||||
</PreviewLink>
|
||||
</TableCell>
|
||||
<TableCell>{humanFileSize(file.size)}</TableCell>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
@ -212,6 +213,7 @@ export function EbookRowCells({file}) {
|
|||
{textEllipsis(file.title || file.stem)}
|
||||
</PreviewLink>
|
||||
</TableCell>
|
||||
<TableCell>{humanFileSize(file.size)}</TableCell>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
|
|
@ -239,12 +241,13 @@ function FileRow({file}) {
|
|||
<FileRowTagIcon file={file}/>
|
||||
<PreviewLink file={file}>{textEllipsis(file.title || file.name || file.stem)}</PreviewLink>
|
||||
</TableCell>
|
||||
<TableCell/>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
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 => <FileRow key={i['key']} file={i}/>);
|
||||
return <SelectableTable
|
||||
headerContents={headerContents}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,15 @@ import {
|
|||
ErrorMessage,
|
||||
FileIcon,
|
||||
findPosterPath,
|
||||
humanFileSize,
|
||||
humanNumber,
|
||||
isoDatetimeToString,
|
||||
mimetypeColor,
|
||||
PageContainer,
|
||||
PreviewLink,
|
||||
scrollToTop,
|
||||
SearchInput,
|
||||
secondsToFullDuration,
|
||||
SortButton,
|
||||
TabLinks,
|
||||
textEllipsis,
|
||||
|
|
@ -36,7 +39,14 @@ import {
|
|||
TableCell
|
||||
} from "semantic-ui-react";
|
||||
import {ChannelsPage, EditChannel, NewChannel} from "./Channels";
|
||||
import {useChannel, useQuery, useSearchVideos, useVideo, useVideoStatistics} from "../hooks/customHooks";
|
||||
import {
|
||||
useChannel,
|
||||
useQuery,
|
||||
useSearchOrder,
|
||||
useSearchVideos,
|
||||
useVideo,
|
||||
useVideoStatistics
|
||||
} from "../hooks/customHooks";
|
||||
import {FileRowTagIcon, FilesView} from "./Files";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
|
|
@ -306,7 +316,8 @@ export function VideoCard({file}) {
|
|||
|
||||
let poster = <CardPoster to={video_url} file={file}/>;
|
||||
|
||||
let header = <span {...s} className='card-title-ellipsis'>{file.title || file.name || video.stem || video.name}</span>;
|
||||
let header = <span {...s}
|
||||
className='card-title-ellipsis'>{file.title || file.name || video.stem || video.name}</span>;
|
||||
if (video_url) {
|
||||
// Link to Channel-Video page or Video page.
|
||||
header = <Link to={video_url} className="no-link-underscore card-link">{header}</Link>;
|
||||
|
|
@ -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 = <FileIcon file={file} size='large'/>;
|
||||
}
|
||||
|
||||
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 <React.Fragment>
|
||||
<TableCell>
|
||||
|
|
@ -371,5 +395,6 @@ export function VideoRowCells({file}) {
|
|||
{textEllipsis(file.title || video.stem || video.video_path)}
|
||||
</CardLink>
|
||||
</TableCell>
|
||||
<TableCell>{dataCell}</TableCell>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue