Making example label a tag.

Tags can be created and deleted in UI.

Adding tag_file using id to avoid session error.

Using UTC in test.

Matching tag_names style in test.

Tag icon is displayed on file rows.

Archives, Videos and Files can be filtered by their tags.

Tags can be added and removed from UI.

Tags are displayed in VideoPlayer.

The tags of a file are returned in it's JSON.

Video favorites are converted to Favorite tag on channel config import.

Updating tests to match frontend usage.

PDF creator and modification time are displayed.

Reworking file search to use Video.__json__ for complex video relations.

Archives can be viewed.

Removing ebook.title.

Reworking alembic migration to be an upgrade rather than a replace.

Skipping test on circleci.

Clearing out video caption index only if extract_subtitles if off.

Channel tests pass.

Some video tests pass.

Missing videos can be found.  A video can be downloaded.

Orphaned files can be found.

Videos can be tagged.

Videos can be searched.

Videos can be modeled.

Converting some tests to use FileGroup.primary_path.

Adding archive and domains to alembic migration.

Testing cascading Archive titles.

Archives now uses FileGroup.

archive.lib tests pass.

Archive is partially converted to FileGroup.

Calculating FileGroup.primary file on refresh, rather than on select.

wrolpi tests pass.

Using FilesType to convert between str/pathlib.Path for FileGroup.files.

Using list of files in FileGroup.files instead of dictionary.

Storing files in dedicated FileGroup.files to avoid overwriting them.

Adding comment explaining CASE.

Not overwriting FileGroup.data on refresh if no change has been detected.

Removing File model in favor of FileGroup.data.

Adding typing to Files methods.

Files are indexed using the primary mimetype of the FileGroup.

files test_lib tests pass.

Removing file_group_file in favor of simple one-to-many relationship.

PDF files are indexed during refresh.

Adding Tag and TagFile to tag files with specific tags.

Only iterating when full_stem_ids has contents.

Testing that FileGroups are related to their Files.

Files and file_groups are created and linked.

Bump webpack from 5.75.0 to 5.76.1 in /app (#160)

Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.76.1.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.75.0...v5.76.1)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Roland 2023-03-24 08:58:18 -06:00
parent 9fbfc8c0a7
commit 5615ce542d
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
71 changed files with 4160 additions and 3161 deletions

View file

@ -34,20 +34,21 @@ import {deleteArchives, postDownload} 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, useQuery, useSearchArchives} from "../hooks/customHooks";
import {FileCards, FilesView} from "./Files";
import {FileCards, FileRowTagIcon, FilesView} from "./Files";
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
import Dropdown from "semantic-ui-react/dist/commonjs/modules/Dropdown";
import _ from "lodash";
import {ThemeContext} from "../contexts/contexts";
import {Button, Card, CardIcon, Header, Loader, Placeholder, Segment} from "./Theme";
import {SortableTable} from "./SortableTable";
import {taggedImageLabel, TagsDisplay} from "../Tags";
function ArchivePage() {
const [deleteOpen, setDeleteOpen] = useState(false);
const [updateOpen, setUpdateOpen] = useState(false);
const navigate = useNavigate();
const {archiveId} = useParams();
const {archiveFile, history} = useArchive(archiveId);
const {archiveFile, history, fetchArchive} = useArchive(archiveId);
let title;
if (archiveFile && archiveFile.archive) {
@ -65,11 +66,11 @@ function ArchivePage() {
</>
}
const {archive} = archiveFile;
const {data} = archiveFile;
const singlefileUrl = archive.singlefile_path ? `/media/${encodeURIComponent(archive.singlefile_path)}` : null;
const screenshotUrl = archive.screenshot_path ? `/media/${encodeURIComponent(archive.screenshot_path)}` : null;
const readabilityUrl = archive.readability_path;
const singlefileUrl = data.singlefile_path ? `/media/${encodeURIComponent(data.singlefile_path)}` : null;
const screenshotUrl = data.screenshot_path ? `/media/${encodeURIComponent(data.screenshot_path)}` : null;
const readabilityUrl = data.readability_path;
const singlefileButton = <ExternalCardLink to={singlefileUrl}>
<Button content='View' color='blue'/>
@ -85,12 +86,12 @@ function ArchivePage() {
const localDeleteArchive = async () => {
setDeleteOpen(false);
await deleteArchives([archive.id]);
await deleteArchives([data.id]);
navigate(-1);
}
const localUpdateArchive = async () => {
setUpdateOpen(false);
await postDownload(archive.url, 'archive');
await postDownload(data.url, 'archive');
}
const updateButton = (<>
@ -121,7 +122,7 @@ function ArchivePage() {
historyList = <FileCards files={history}/>;
}
const domain = archive.domain ? archive.domain.domain : null;
const domain = data.domain ? data.domain.domain : null;
let domainHeader;
if (domain) {
const domainUrl = `/archive?domain=${domain}`;
@ -133,10 +134,10 @@ function ArchivePage() {
}
let urlHeader;
if (archive.url) {
if (data.url) {
urlHeader = <Header as='h5'>
<ExternalCardLink to={archive.url}>
{textEllipsis(archive.url)}
<ExternalCardLink to={data.url}>
{textEllipsis(data.url)}
</ExternalCardLink>
</Header>;
}
@ -147,9 +148,9 @@ function ArchivePage() {
<Segment>
{screenshot}
<ExternalCardLink to={singlefileUrl}>
<Header as='h2'>{textEllipsis(archive.title || archive.url)}</Header>
<Header as='h2'>{textEllipsis(data.title || data.url)}</Header>
</ExternalCardLink>
<Header as='h3'>{isoDatetimeToString(archive.archive_datetime)}</Header>
<Header as='h3'>{isoDatetimeToString(data.archive_datetime)}</Header>
{domainHeader}
{urlHeader}
@ -159,6 +160,10 @@ function ArchivePage() {
{deleteButton}
</Segment>
<Segment>
<TagsDisplay fileGroup={archiveFile} onClick={fetchArchive}/>
</Segment>
<Segment>
<HelpHeader
headerContent='History'
@ -171,17 +176,18 @@ function ArchivePage() {
export function ArchiveCard({file}) {
const {s} = useContext(ThemeContext);
const {archive} = file;
const {data} = file;
const imageSrc = archive.screenshot_path ? `/media/${encodeURIComponent(archive.screenshot_path)}` : null;
const singlefileUrl = archive.singlefile_path ? `/media/${encodeURIComponent(archive.singlefile_path)}` : null;
const imageSrc = data.screenshot_path ? `/media/${encodeURIComponent(data.screenshot_path)}` : null;
const singlefileUrl = data.singlefile_path ? `/media/${encodeURIComponent(data.singlefile_path)}` : null;
let screenshot = <CardIcon><FileIcon file={file}/></CardIcon>;
const imageLabel = file.tags && file.tags.length ? taggedImageLabel : null;
if (imageSrc) {
screenshot = <Image src={imageSrc} wrapped style={{position: 'relative', width: '100%'}}/>;
screenshot = <Image src={imageSrc} wrapped style={{position: 'relative', width: '100%'}} label={imageLabel}/>;
}
const domain = archive.domain ? archive.domain.domain : null;
const domain = data ? data.domain : null;
const domainUrl = `/archive?domain=${domain}`;
return <Card color={mimetypeColor(file.mimetype)}>
@ -194,7 +200,7 @@ export function ArchiveCard({file}) {
<CardHeader>
<Container textAlign='left'>
<ExternalCardLink to={singlefileUrl}>
{cardTitleWrapper(archive.title || archive.url)}
{cardTitleWrapper(file.title || data.url)}
</ExternalCardLink>
</Container>
</CardHeader>
@ -204,15 +210,15 @@ export function ArchiveCard({file}) {
</CardLink>}
<CardMeta {...s}>
<p>
{isoDatetimeToString(archive.archive_datetime)}
{isoDatetimeToString(data.archive_datetime)}
</p>
</CardMeta>
<CardDescription>
<Link to={`/archive/${archive.id}`}>
<Link to={`/archive/${data.id}`}>
<Button icon='file alternate' content='Details'
labelPosition='left'/>
</Link>
<Button icon='external' href={archive.url} target='_blank' rel='noopener noreferrer'/>
<Button icon='external' href={data.url} target='_blank' rel='noopener noreferrer'/>
</CardDescription>
</CardContent>
</Card>
@ -427,10 +433,10 @@ function Archives() {
}
export function ArchiveRowCells({file}) {
const {archive} = file;
const {data} = file;
const archiveUrl = `/archive/${archive.id}`;
const posterUrl = archive.screenshot_path ? `/media/${encodeURIComponent(archive.screenshot_path)}` : null;
const archiveUrl = `/archive/${data.id}`;
const posterUrl = data.screenshot_path ? `/media/${encodeURIComponent(data.screenshot_path)}` : null;
let poster;
if (posterUrl) {
@ -448,7 +454,8 @@ export function ArchiveRowCells({file}) {
</TableCell>
<TableCell>
<CardLink to={archiveUrl}>
{textEllipsis(archive.title || archive.stem)}
<FileRowTagIcon file={file}/>
{textEllipsis(file.title || file.stem)}
</CardLink>
</TableCell>
</React.Fragment>

View file

@ -1,5 +1,5 @@
import React, {useContext, useEffect, useState} from "react";
import {Card, Container, IconGroup, Input, Modal, Pagination} from 'semantic-ui-react';
import {Card, Container, IconGroup, Image, Input, Modal, Pagination} from 'semantic-ui-react';
import {Link, NavLink, useNavigate} from "react-router-dom";
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
import {useDirectories, useDownloaders, useHotspot, useSettings, useThrottle} from "../hooks/customHooks";
@ -117,7 +117,7 @@ export function Duration({video}) {
export function isoDatetimeToString(dt) {
// Convert a datetime to a human-readable date format.
let d = <></>;
let d = <React.Fragment/>;
if (dt) {
d = new Date(dt);
d = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
@ -444,8 +444,8 @@ export function CardGroupCentered(props) {
export function CardPosterLink({to, poster_url, imageLabel, external = false}) {
const {s} = useContext(ThemeContext);
const style = {display: 'flex', justifyContent: 'center', ...s['style']};
const image = <img src={poster_url} alt={imageLabel}
style={{maxHeight: '163px', width: 'auto'}}
const image = <Image src={poster_url} label={imageLabel}
style={{maxHeight: '163px', width: 'auto'}}
/>;
if (external === true && to) {
return <a href={to} target='_blank' rel='noreferrer' style={style}>
@ -461,12 +461,12 @@ export function CardPosterLink({to, poster_url, imageLabel, external = false}) {
}
}
export function HelpPopup({icon, size, content, position}) {
export function HelpPopup({icon, size, content, position, iconSize = 'small'}) {
return <Popup
content={content}
size={size || null}
position={position || 'left center'}
trigger={<Icon circular link name={icon || 'question'} size='small'
trigger={<Icon circular link name={icon || 'question'} size={iconSize}
style={{marginLeft: '0.25em', marginRight: '0.25em'}}
/>}
/>
@ -616,8 +616,9 @@ export function isZipMimetype(mimetype) {
export function FileIcon({file, disabled = true, size = 'huge', ...props}) {
// Default to a grey file icon.
const {mimetype, path} = file;
const lowerPath = path.toLowerCase();
const {mimetype, path, primary_path} = file;
// `file` may be a file_group or a file.
const lowerPath = primary_path ? primary_path.toLocaleString() : path.toLowerCase();
props['name'] = 'file';
props['color'] = mimetypeColor(mimetype);
if (mimetype) {
@ -851,3 +852,25 @@ export const cardTitleWrapper = (title, maxLength = 100, breakWord = true) => {
const style = breakWord ? {overflowWrap: 'break-word'} : null;
return <span style={style}>{textEllipsis(title, maxLength)}</span>
}
function luma(color) {
let rgb = (typeof color === 'string') ? hexToRGBArray(color) : color;
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]); // SMPTE C, Rec. 709 weightings
}
function hexToRGBArray(color) {
if (color.length === 7) {
color = color.slice(1);
}
if (color.length !== 6) {
console.error('Invalid hex color: ' + color);
return;
}
let rgb = [];
for (let i = 0; i <= 2; i++) rgb[i] = parseInt(color.substr(i * 2, 2), 16);
return rgb;
}
export function contrastingColor(color) {
return (luma(color) >= 120) ? '#000000' : '#dddddd';
}

View file

@ -7,6 +7,7 @@ import {
Container,
Dropdown,
Image,
Label,
PlaceholderLine,
TableCell,
TableHeaderCell,
@ -40,6 +41,7 @@ import {FileBrowser} from "./FileBrowser";
import {refreshDirectoryFiles, refreshFiles} from "../api";
import {useSubscribeEventName} from "../Events";
import {FilePreviewContext} from "./FilePreview";
import {TagsContext} from "../Tags";
export function FilesPage() {
@ -50,20 +52,18 @@ export function FilesPage() {
function EbookCard({file}) {
const {s} = useContext(ThemeContext);
let {ebook, suffix} = file;
let {data} = file;
const downloadUrl = `/download/${encodeURIComponent(file.path)}`;
const downloadUrl = `/download/${encodeURIComponent(file.primary_path)}`;
const isEpub = file['mimetype'].startsWith('application/epub');
const viewerUrl = isEpub ? `/epub.html?url=${downloadUrl}` : null;
let cover = <FileIcon file={file}/>;
if (ebook && ebook.cover_path) {
const coverSrc = `/media/${encodeURIComponent(ebook.cover_path)}`;
if (data && data.cover_path) {
const coverSrc = `/media/${encodeURIComponent(data.cover_path)}`;
cover = <CardPosterLink poster_url={coverSrc}/>;
}
suffix = suffix ? _.trimStart(suffix, '.').toUpperCase() : null;
const color = mimetypeColor(file.mimetype);
return <Card color={color}>
<PreviewLink file={file}>
@ -73,12 +73,13 @@ function EbookCard({file}) {
<CardHeader>
<Container textAlign='left'>
<ExternalCardLink to={viewerUrl || downloadUrl}>
{ebook ? ebook.title : file.title}
{data ? data.title : file.title}
</ExternalCardLink>
</Container>
</CardHeader>
<CardMeta>
<pre {...s}>{suffix}</pre>
{data.creator ? <b {...s}>{data.creator}</b> : null}
{file.size && <p {...s}>{humanFileSize(file.size)}</p>}
</CardMeta>
</CardContent>
</Card>
@ -88,7 +89,7 @@ function EbookCard({file}) {
function ImageCard({file}) {
const {s} = useContext(ThemeContext);
const {setPreviewFile} = React.useContext(FilePreviewContext);
const url = `/media/${encodeURIComponent(file.path)}`;
const url = `/media/${encodeURIComponent(file.primary_path)}`;
let poster = <FileIcon file={file}/>;
if (file.size && file.size < 50000000) {
@ -107,7 +108,7 @@ function ImageCard({file}) {
<CardContent {...s}>
<CardHeader>
<ExternalCardLink to={url} className='no-link-underscore card-link'>
<p>{textEllipsis(file.title || file.stem || file.path)}</p>
<p>{textEllipsis(file.title || file.stem || file.primary_path)}</p>
</ExternalCardLink>
</CardHeader>
<CardMeta {...s}>
@ -127,17 +128,19 @@ function FileCard({file}) {
file.mimetype.startsWith('application/epub') || file.mimetype.startsWith('application/x-mobipocket-ebook')
);
if (file.model === 'video' && file['video']) {
return <VideoCard key={file['path']} file={file}/>;
} else if (file.model === 'archive' && file['archive']) {
return <ArchiveCard key={file['path']} file={file}/>;
if (file.model === 'video') {
return <VideoCard key={file['primary_path']} file={file}/>;
} else if (file.model === 'archive') {
return <ArchiveCard key={file['primary_path']} file={file}/>;
} else if (file.mimetype && file.mimetype.startsWith('image/')) {
return <ImageCard key={file['path']} file={file}/>;
return <ImageCard key={file['primary_path']} file={file}/>;
} else if (isEbookType) {
return <EbookCard key={file['path']} file={file}/>;
return <EbookCard key={file['primary_path']} file={file}/>;
}
const downloadUrl = `/download/${encodeURIComponent(file.path)}`;
const {data} = file;
const {author} = data;
const downloadUrl = `/download/${encodeURIComponent(file.primary_path)}`;
const color = mimetypeColor(file.mimetype);
const size = file.size !== null && file.size !== undefined ? humanFileSize(file.size) : null;
@ -150,10 +153,11 @@ function FileCard({file}) {
<CardContent {...s}>
<CardHeader>
<ExternalCardLink to={downloadUrl}>
{cardTitleWrapper(file.title || file.stem || file.path)}
{cardTitleWrapper(file.title || file.stem || file.primary_path)}
</ExternalCardLink>
</CardHeader>
<p>{isoDatetimeToString(file.modified / 1000)}</p>
{author && <b {...s}>{author}</b>}
<p>{isoDatetimeToString(file.modified)}</p>
<p>{size}</p>
</CardContent>
</Card>
@ -162,7 +166,7 @@ function FileCard({file}) {
export function FileCards({files}) {
if (!_.isEmpty(files)) {
return <CardGroupCentered>
{files.map(i => <FileCard key={i['path']} file={i}/>)}
{files.map(i => <FileCard key={i['primary_path']} file={i}/>)}
</CardGroupCentered>
} else if (files && files.length === 0) {
return <Segment>No results!</Segment>
@ -172,7 +176,7 @@ export function FileCards({files}) {
}
function ImageRowCells({file}) {
const url = `/media/${encodeURIComponent(file.path)}`;
const url = `/media/${encodeURIComponent(file.primary_path)}`;
let poster = <FileIcon file={file} size='large'/>;
if (file.size && file.size < 50000000) {
@ -189,18 +193,18 @@ function ImageRowCells({file}) {
</TableCell>
<TableCell>
<PreviewLink file={file}>
<p>{textEllipsis(file.title || file.stem || file.path)}</p>
<p>{textEllipsis(file.title || file.stem || file.primary_path)}</p>
</PreviewLink>
</TableCell>
</React.Fragment>
}
export function EbookRowCells({file}) {
const {ebook} = file;
const {data} = file;
let cover = <CardIcon><FileIcon file={file}/></CardIcon>;
if (ebook && ebook.cover_path) {
const coverSrc = `/media/${encodeURIComponent(ebook.cover_path)}`;
if (data && data.cover_path) {
const coverSrc = `/media/${encodeURIComponent(data.cover_path)}`;
cover = <Image wrapped src={coverSrc} width='50px'/>;
}
@ -211,7 +215,7 @@ export function EbookRowCells({file}) {
</TableCell>
<TableCell>
<PreviewLink file={file}>
{textEllipsis(ebook.title || file.title)}
{textEllipsis(file.title || file.stem)}
</PreviewLink>
</TableCell>
</React.Fragment>
@ -224,12 +228,12 @@ function FileRow({file}) {
if (file.model === 'video' && 'video' in file) {
return <VideoRowCells file={file}/>;
} else if (file.model === 'archive' && 'archive' in file) {
} else if (file.model === 'archive') {
return <ArchiveRowCells file={file}/>;
} else if (file.mimetype && file.mimetype.startsWith('image/')) {
return <ImageRowCells file={file}/>;
} else if (isEbookType) {
return <EbookRowCells key={file['path']} file={file}/>;
return <EbookRowCells key={file['primary_path']} file={file}/>;
}
// Fragment for SelectableRow
@ -266,6 +270,14 @@ export function FileTable({files, selectOn, onSelect, footer, selectedKeys}) {
}
}
export function FileRowTagIcon({file}) {
if (file.tags && file.tags.length) {
return <Label circular color='green' style={{padding: '0.5em', marginRight: '0.5em'}}>
<Icon name='tag' style={{margin: 0}}/>
</Label>;
}
}
export function FilesView({
files,
limit,
@ -347,19 +359,20 @@ export function FilesView({
const filtersDropdown = <Dropdown selection clearable search
multiple={multipleFilters || undefined}
options={filterOptions}
placeholder={filterPlaceholder || 'Filters'}
options={filterOptions || []}
placeholder={filterPlaceholder || 'Files Types'}
onChange={(e, {value}) => setFilters(value)}
style={{marginLeft: '0.3em'}}
style={{marginLeft: '0.3em', marginTop: '0.3em'}}
value={activeFilters}
/>;
return <>
<Grid columns={menuColumnsCount || 1} stackable>
<Grid.Column mobile={8} computer={6}>
<Grid.Column mobile={16} computer={12}>
{selectButton}
{viewButton}
{limitDropdown}
<TagsFilesGroupDropdown/>
{filterOptions && filtersDropdown}
</Grid.Column>
{menuColumns}
@ -369,6 +382,38 @@ export function FilesView({
</>
}
export function TagsFilesGroupDropdown({onChange}) {
// Creates a dropdown that the User can use to manipulate the tag query.
const {searchParams, updateQuery} = useQuery();
const activeTag = searchParams.get('tag');
const {tags} = React.useContext(TagsContext);
const localOnChange = (name) => {
updateQuery({'tag': name});
if (onChange) {
onChange(name);
}
}
let tagOptions = [];
if (tags && tags.length) {
for (let i = 0; i < tags.length; i++) {
const {name} = tags[i];
tagOptions = [...tagOptions, {key: name, text: name, value: name}];
}
return <Dropdown selection clearable search
options={tagOptions || []}
placeholder={'Tags'}
onChange={(e, {value}) => localOnChange(value)}
style={{marginLeft: '0.3em', marginTop: '0.3em'}}
value={activeTag}
/>;
} else {
return <React.Fragment/>
}
}
export function FilesSearchView({
showView = true,
showLimit = false,
@ -391,7 +436,6 @@ export function FilesSearchView({
const {searchFiles, limit, setLimit, totalPages, activePage, setPage} =
useSearchFiles(24, emptySearch, model);
const {searchParams, updateQuery} = useQuery();
const setView = (value) => updateQuery({view: value});
const view = searchParams.get('view');

View file

@ -19,6 +19,7 @@ import {useChannel} from "../hooks/customHooks";
import {ThemeContext} from "../contexts/contexts";
import {Button, darkTheme, Header, Icon, Segment, Tab, TabPane} from "./Theme";
import {VideoCard} from "./Videos";
import {TagsDisplay} from "../Tags";
const MEDIA_PATH = '/media';
@ -26,6 +27,7 @@ const MEDIA_PATH = '/media';
function videoFileLink(path, directory = false) {
if (path) {
const href = directory ?
// Add / to end of directory.
`${MEDIA_PATH}/${encodeURIComponent(path)}/` :
`${MEDIA_PATH}/${encodeURIComponent(path)}`;
return <a href={href} target='_blank' rel='noopener noreferrer'>
@ -36,7 +38,7 @@ function videoFileLink(path, directory = false) {
}
}
function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
const {theme} = useContext(ThemeContext);
const navigate = useNavigate();
@ -84,30 +86,12 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
let vttCaptions = video.caption_path && video.caption_path.endsWith('.vtt');
let description = 'No description available.';
let viewCount = video.view_count;
if (video.info_json && video.info_json['description']) {
if (video && video['description']) {
// Only replace empty description if there is one available.
description = video.info_json['description'];
description = video['description'];
description = chaptersInDescription(description, setVideoTime)
viewCount = viewCount || video.info_json['view_count'];
}
const favorite = video && video.favorite;
let handleFavorite = async (e) => {
e.preventDefault();
if (video) {
setFavorite(!favorite);
}
}
const favorite_button = (<Button
color='green'
style={{'margin': '0.5em'}}
onClick={handleFavorite}
>
<Icon name='heart'/>
{favorite ? 'Unfavorite' : 'Favorite'}
</Button>);
let descriptionPane = {
menuItem: 'Description', render: () => <TabPane>
<pre className="wrap-text">
@ -119,13 +103,13 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
let aboutPane = {
menuItem: 'About', render: () => <TabPane>
<h3>Size</h3>
<p>{video.size ? humanFileSize(video.size) : 'Unknown'}</p>
<p>{videoFile.size ? humanFileSize(videoFile.size) : 'Unknown'}</p>
<h3>Source URL</h3>
<p>{video.url ? <a href={video.url}>{video.url}</a> : 'N/A'}</p>
<h3>View Count</h3>
<p>{viewCount ? humanNumber(viewCount) : 'N/A'}</p>
<p>{video.view_count ? humanNumber(video.view_count) : 'N/A'}</p>
<h3>Censored</h3>
<p>{video.censored ? 'Yes' : 'No'}</p>
@ -138,25 +122,30 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
</TabPane>
};
const {poster_file, caption_files, info_json_file} = video;
let filesPane = {
menuItem: 'Files', render: () => <TabPane>
<h3>Video File</h3>
{videoFileLink(video['video_path'])}
<h4>Info JSON File</h4>
<PreviewPath
path={video['info_json_path']}
mimetype='application/json'>{video['info_json_path']}</PreviewPath>
{info_json_file &&
<PreviewPath
path={info_json_file['path']}
mimetype={info_json_file['mimetype']}>{info_json_file['path']}</PreviewPath>
}
<h4>Caption File</h4>
<PreviewPath
path={video['caption_path']}
mimetype='text/'>{video['caption_path']}</PreviewPath>
<h4>Caption Files</h4>
{caption_files &&
caption_files.map(i => <PreviewPath key={i['path']} {...i}>{i['path']}</PreviewPath>)
}
<h4>Poster File</h4>
<PreviewPath
path={video['poster_path']}
mimetype='image/'>{video['poster_path']}</PreviewPath>
{poster_file &&
<PreviewPath
path={poster_file['path']}
mimetype={poster_file['mimetype']}>{poster_file['path']}</PreviewPath>
}
<h4>Directory</h4>
{videoFileLink(videoFile['directory'], true)}
@ -188,7 +177,7 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
<Container style={{marginTop: '1em'}}>
<Segment>
<Header as='h2'>{video.title || video.video_path}</Header>
<Header as='h2'>{videoFile.title || videoFile.stem || video.video_path}</Header>
{video.upload_date && <h3>{isoDatetimeToString(video.upload_date)}</h3>}
<h3>
{channel && <Link to={`/videos/channel/${channel.id}/video`}>
@ -197,7 +186,6 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
</h3>
<p>
{favorite_button}
<a href={downloadUrl} target='_blank' rel='noopener noreferrer'>
<Button style={{margin: '0.5em'}}>
<Icon name='download'/>
@ -217,6 +205,11 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {
onConfirm={() => handleDeleteVideo(video.id)}
/>
</p>
<br/>
</Segment>
<Segment>
<TagsDisplay fileGroup={videoFile} onClick={fetchVideo}/>
</Segment>
<Tab menu={tabMenu} panes={tabPanes}/>

View file

@ -34,26 +34,27 @@ import {
} from "semantic-ui-react";
import {Channels, EditChannel, NewChannel} from "./Channels";
import {useChannel, useQuery, useSearchVideos, useVideo, useVideoStatistics} from "../hooks/customHooks";
import {FilesView} from "./Files";
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";
import {Button, Card, CardIcon, Header, Loader, Placeholder, Segment, Statistic, StatisticGroup} from "./Theme";
import {deleteVideos} from "../api";
import {ThemeContext} from "../contexts/contexts";
import _ from "lodash";
import {taggedImageLabel} from "../Tags";
export function VideoWrapper() {
const {videoId} = useParams();
const {videoFile, prevFile, nextFile, setFavorite} = useVideo(videoId);
const {videoFile, prevFile, nextFile, fetchVideo} = useVideo(videoId);
// Scroll to the top when videoId changes.
useEffect(scrollToTop, [videoId]);
return <VideoPage videoFile={videoFile} prevFile={prevFile} nextFile={nextFile}
setFavorite={setFavorite} autoplay={true}/>
return <VideoPage videoFile={videoFile} prevFile={prevFile} nextFile={nextFile} fetchVideo={fetchVideo}
autoplay={true}/>
}
function VideosPage({filter}) {
function VideosPage() {
const {channelId} = useParams();
const {searchParams, updateQuery} = useQuery();
@ -69,31 +70,19 @@ function VideosPage({filter}) {
searchOrder = defaultSearchOrder;
}
let filtersEnabled = searchParams.getAll('filter');
filtersEnabled = filter ? [...filtersEnabled, filter] : filtersEnabled;
const {searchStr, setSearchStr, videos, activePage, setPage, limit, setLimit, totalPages, setOrderBy, fetchVideos} =
useSearchVideos(null, channelId, searchOrder, filtersEnabled);
useSearchVideos(null, channelId, searchOrder);
const setView = (value) => updateQuery({view: value});
const view = searchParams.get('view');
const {channel} = useChannel(channelId);
let title = 'Videos';
if (filter && filter.indexOf('favorite') >= 0) {
title = 'Favorite Videos';
}
if (channel && channel.name) {
title = `${channel.name} Videos`;
}
useTitle(title);
const filterOptions = [
{text: 'Favorites', key: 'favorite', value: 'favorite'},
{text: 'Censored', key: 'censored', value: 'censored'},
];
const setFilters = (value) => updateQuery({filter: value});
let videoOrders = [
{key: '-upload_date', value: '-upload_date', text: 'Newest'},
{key: 'upload_date', value: 'upload_date', text: 'Oldest'},
@ -219,10 +208,6 @@ function VideosPage({filter}) {
setView={setView}
setLimit={setLimit}
setPage={setPage}
filterOptions={filterOptions}
activeFilters={filtersEnabled}
setFilters={setFilters}
multipleFilters={true}
menuColumnsCount={3}
menuColumns={menuColumns}
>
@ -242,7 +227,6 @@ function Statistics() {
const videoNames = [
{key: 'videos', label: 'Videos'},
{key: 'favorites', label: 'Favorite Videos'},
{key: 'sum_size', label: 'Total Size'},
{key: 'max_size', label: 'Largest Video'},
{key: 'week', label: 'Downloads Past Week'},
@ -283,7 +267,6 @@ function Statistics() {
export function VideosRoute(props) {
const links = [
{text: 'Videos', to: '/videos', key: 'videos', end: true},
{text: 'Favorites', to: '/videos/favorites', key: 'favorites'},
{text: 'Channels', to: '/videos/channel', key: 'channel'},
{text: 'Statistics', to: '/videos/statistics', key: 'statistics'},
];
@ -292,7 +275,6 @@ export function VideosRoute(props) {
<TabLinks links={links}/>
<Routes>
<Route path='/' exact element={<VideosPage/>}/>
<Route path='favorites' exact element={<VideosPage filter='favorite' header='Favorite Videos'/>}/>
<Route path='channel' exact element={<Channels/>}/>
<Route path='statistics' exact element={<Statistics/>}/>
<Route path='channel/new' exact element={<NewChannel/>}/>
@ -303,7 +285,7 @@ export function VideosRoute(props) {
}
export function VideoCard({file}) {
const {video} = file;
const {video, tags} = file;
const {s} = useContext(ThemeContext);
let video_url = `/videos/video/${video.id}`;
@ -317,10 +299,7 @@ export function VideoCard({file}) {
}
const poster_url = video.poster_path ? `/media/${encodeURIComponent(video.poster_path)}` : null;
let imageLabel = null;
if (video.favorite) {
imageLabel = {corner: 'left', icon: 'heart', color: 'green'};
}
let imageLabel = !_.isEmpty(tags) ? taggedImageLabel : null;
let poster = <Link to={video_url}><CardIcon><FileIcon file={file}/></CardIcon></Link>;
if (poster_url) {
poster = <CardPosterLink to={video_url} poster_url={poster_url} imageLabel={imageLabel}/>;
@ -334,7 +313,7 @@ export function VideoCard({file}) {
<CardHeader>
<Container textAlign='left'>
<Link to={video_url} className="no-link-underscore card-link">
<p {...s}>{cardTitleWrapper(video.title || video.stem || video.video_path)}</p>
<p {...s}>{cardTitleWrapper(file.title || file.name || video.stem || video.video_path)}</p>
</Link>
</Container>
</CardHeader>
@ -357,12 +336,10 @@ export function VideoRowCells({file}) {
const poster_url = video.poster_path ? `/media/${encodeURIComponent(video.poster_path)}` : null;
let poster;
let imageLabel = video.favorite ? {corner: 'left', icon: 'heart', color: 'green'} : null;
if (poster_url) {
poster = <CardLink to={video_url}>
<Image wrapped
src={poster_url}
label={imageLabel}
width='50px'
/>
</CardLink>
@ -379,6 +356,7 @@ export function VideoRowCells({file}) {
</TableCell>
<TableCell>
<CardLink to={video_url}>
<FileRowTagIcon file={file}/>
{textEllipsis(video.title || video.stem || video.video_path)}
</CardLink>
</TableCell>

View file

@ -51,7 +51,7 @@ class WROLMode extends React.Component {
want to prevent any potential loss of data.
</Header>
<p {...t}>
Note: User settings and favorites can still be modified.
Note: User settings and tags can still be modified.
</p>
<Toggle
checked={this.state.WROLMode}