mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 05:39:57 -05:00
Moving data from models to FileGroup.
* Ebook.creator -> FileGroup.author * Video.viewed -> FileGroup.viewed * Video.duration -> FileGroup.length * Video.url -> FileGroup.url * Archive.url -> FileGroup.url
This commit is contained in:
parent
ae9d188391
commit
15687e534a
32 changed files with 418 additions and 209 deletions
|
|
@ -69,10 +69,7 @@ function ArchivePage() {
|
|||
const {archiveFile, history, fetchArchive} = useArchive(archiveId);
|
||||
const {theme} = useContext(ThemeContext);
|
||||
|
||||
let title;
|
||||
if (archiveFile && archiveFile.archive) {
|
||||
title = archiveFile.archive.title;
|
||||
}
|
||||
let title = archiveFile ? archiveFile.title ? archiveFile.title : archiveFile.name : null;
|
||||
useTitle(title);
|
||||
|
||||
if (archiveFile === null) {
|
||||
|
|
@ -168,7 +165,7 @@ function ArchivePage() {
|
|||
await fetchArchive();
|
||||
}
|
||||
|
||||
const archivedDatetimeString = isoDatetimeToString(data.archive_datetime, true);
|
||||
const archivedDatetimeString = isoDatetimeToString(archiveFile.download_datetime, true);
|
||||
const publishedDatetimeString = archiveFile.published_datetime ? isoDatetimeToString(archiveFile.published_datetime, true)
|
||||
: 'unknown';
|
||||
const modifiedDatetimeString = archiveFile.published_modified_datetime
|
||||
|
|
@ -305,7 +302,7 @@ export function ArchiveCard({file}) {
|
|||
</CardLink>}
|
||||
<CardMeta {...s}>
|
||||
<p>
|
||||
{isoDatetimeToString(data.archive_datetime)}
|
||||
{isoDatetimeToString(file.published_datetime)}
|
||||
</p>
|
||||
</CardMeta>
|
||||
<CardDescription>
|
||||
|
|
@ -426,8 +423,11 @@ function ArchivesPage() {
|
|||
} = useSearchArchives();
|
||||
|
||||
let archiveOrders = [
|
||||
{value: 'date', text: 'Date'},
|
||||
{value: 'published_datetime', text: 'Published Date', short: 'P.Date'},
|
||||
{value: 'published_modified_datetime', text: 'Modified Date', short: 'M.Date'},
|
||||
{value: 'download_datetime', text: 'Download Date', short: 'D.Date'},
|
||||
{value: 'size', text: 'Size'},
|
||||
{value: 'viewed', text: 'Recently Viewed', short: 'R.Viewed'},
|
||||
];
|
||||
|
||||
if (searchStr) {
|
||||
|
|
|
|||
|
|
@ -148,27 +148,26 @@ export function isoDatetimeToElapsedPopup(dt) {
|
|||
return secondsToElapsedPopup(d.getTime() / 1000);
|
||||
}
|
||||
|
||||
export function secondsToDuration(video) {
|
||||
let duration = video.duration;
|
||||
let hours = Math.floor(duration / 3600);
|
||||
duration -= hours * 3600;
|
||||
let minutes = Math.floor(duration / 60);
|
||||
let seconds = duration - (minutes * 60);
|
||||
export function secondsToHMS(totalSeconds) {
|
||||
let hours = Math.floor(totalSeconds / 3600);
|
||||
totalSeconds -= hours * 3600;
|
||||
let minutes = Math.floor(totalSeconds / 60);
|
||||
let seconds = totalSeconds - (minutes * 60);
|
||||
|
||||
hours = String('00' + hours).slice(-2);
|
||||
minutes = String('00' + minutes).slice(-2);
|
||||
seconds = String('00' + seconds).slice(-2);
|
||||
|
||||
return [hours, minutes, seconds];
|
||||
return {hours, minutes, seconds};
|
||||
}
|
||||
|
||||
export function Duration({video}) {
|
||||
let [hours, minutes, seconds] = secondsToDuration(video);
|
||||
export function Duration({totalSeconds}) {
|
||||
const {hours, minutes, seconds} = secondsToHMS(totalSeconds);
|
||||
|
||||
if (hours > 0) {
|
||||
return <div className="duration-overlay">{hours}:{minutes}:{seconds}</div>
|
||||
} else if (video.duration) {
|
||||
return <div className="duration-overlay">{minutes}:{seconds}</div>
|
||||
return <div className='duration-overlay'>{hours}:{minutes}:{seconds}</div>
|
||||
} else if (totalSeconds) {
|
||||
return <div className='duration-overlay'>{minutes}:{seconds}</div>
|
||||
} else {
|
||||
return <></>
|
||||
}
|
||||
|
|
@ -224,7 +223,7 @@ export function RequiredAsterisk() {
|
|||
return <span style={{color: '#db2828'}}> *</span>
|
||||
}
|
||||
|
||||
export let defaultVideoOrder = '-upload_date';
|
||||
export let defaultVideoOrder = '-published_datetime';
|
||||
export let defaultSearchOrder = 'rank';
|
||||
|
||||
export const frequencyOptions = [{key: null, text: '', value: null}, {
|
||||
|
|
@ -1277,7 +1276,7 @@ export function SortButton({sorts = []}) {
|
|||
</Modal>
|
||||
<ButtonGroup icon>
|
||||
<Button icon={desc ? 'sort down' : 'sort up'} onClick={() => toggleDesc()}/>
|
||||
<Button content={selectedSort['text']} onClick={() => setOpen(true)}/>
|
||||
<Button content={selectedSort['short'] || selectedSort['text']} onClick={() => setOpen(true)}/>
|
||||
</ButtonGroup>
|
||||
</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ import {Headlines} from "./Headline";
|
|||
|
||||
function EbookCard({file}) {
|
||||
const {s} = useContext(ThemeContext);
|
||||
let {data} = file;
|
||||
|
||||
const downloadUrl = `/download/${encodeMediaPath(file.primary_path)}`;
|
||||
const isEpub = file['mimetype'].startsWith('application/epub');
|
||||
|
|
@ -83,12 +82,12 @@ function EbookCard({file}) {
|
|||
<CardHeader>
|
||||
<Container textAlign='left'>
|
||||
<ExternalCardLink to={viewerUrl || downloadUrl}>
|
||||
{cardTitleWrapper(data ? data.title : file.title)}
|
||||
{cardTitleWrapper(file ? file.title : file.title)}
|
||||
</ExternalCardLink>
|
||||
</Container>
|
||||
</CardHeader>
|
||||
<CardMeta>
|
||||
{data.creator ? <b {...s}>{data.creator}</b> : null}
|
||||
{file.author ? <b {...s}>{file.author}</b> : null}
|
||||
{file.size && <p {...s}>{humanFileSize(file.size)}</p>}
|
||||
</CardMeta>
|
||||
</CardContent>
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
|||
const navigate = useNavigate();
|
||||
const videoRef = React.useRef();
|
||||
|
||||
useTitle(videoFile === null || videoFile === undefined ? null : videoFile.video.title);
|
||||
useTitle(videoFile ? videoFile.title ? videoFile.title : videoFile.name : null);
|
||||
let video;
|
||||
if (videoFile) {
|
||||
video = videoFile.video;
|
||||
|
|
@ -241,7 +241,7 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
|||
<Segment>
|
||||
|
||||
<Header as='h2'>{title}</Header>
|
||||
{video.upload_date && <h3>{isoDatetimeToString(video.upload_date)}</h3>}
|
||||
{videoFile.published_datetime && <h3>{isoDatetimeToString(videoFile.published_datetime)}</h3>}
|
||||
<h3>
|
||||
{channel && <Link to={`/videos/channel/${channel.id}/video`}>
|
||||
{channel.name}
|
||||
|
|
|
|||
|
|
@ -84,10 +84,11 @@ function VideosPage() {
|
|||
useTitle(title);
|
||||
|
||||
let videoOrders = [
|
||||
{value: 'upload_date', text: 'Date'},
|
||||
{value: 'duration', text: 'Duration'},
|
||||
{value: 'published_datetime', text: 'Published Date', short: 'P.Date'},
|
||||
{value: 'length', text: 'Length'},
|
||||
{value: 'size', text: 'Size'},
|
||||
{value: 'view_count', text: 'Views'},
|
||||
{value: 'viewed', text: 'Recently Viewed', short: 'R.Viewed'},
|
||||
]
|
||||
|
||||
if (searchStr) {
|
||||
|
|
@ -291,7 +292,7 @@ export function VideoCard({file}) {
|
|||
// Default to video FilePreview for lone video files.
|
||||
let video_url;
|
||||
|
||||
const upload_date = isoDatetimeToString(video.upload_date);
|
||||
const published_datetime = isoDatetimeToString(file.published_datetime);
|
||||
// A video may not have a channel.
|
||||
const channel = video.channel ? video.channel : null;
|
||||
let channel_url = null;
|
||||
|
|
@ -320,7 +321,7 @@ export function VideoCard({file}) {
|
|||
const color = mimetypeColor(file.mimetype);
|
||||
return <Card color={color}>
|
||||
{poster}
|
||||
<Duration video={video}/>
|
||||
<Duration totalSeconds={file.length}/>
|
||||
<CardContent {...s}>
|
||||
<CardHeader>
|
||||
<Container textAlign='left'>
|
||||
|
|
@ -332,7 +333,7 @@ export function VideoCard({file}) {
|
|||
{channel && <Link to={channel_url} className="no-link-underscore card-link">
|
||||
<b {...s}>{channel.name}</b>
|
||||
</Link>}
|
||||
<p {...s}>{upload_date}</p>
|
||||
<p {...s}>{published_datetime}</p>
|
||||
</Container>
|
||||
</CardDescription>
|
||||
</CardContent>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue