2022-08-06 05:22:07 +00:00
|
|
|
import React, {useContext, useState} from "react";
|
2026-02-23 17:29:09 -07:00
|
|
|
import {useHotkeys} from "react-hotkeys-hook";
|
2022-02-02 08:24:34 -07:00
|
|
|
import {
|
2022-11-30 20:13:54 -07:00
|
|
|
CardContent,
|
|
|
|
|
CardDescription,
|
|
|
|
|
CardHeader,
|
|
|
|
|
CardMeta,
|
2022-08-06 05:22:07 +00:00
|
|
|
Container,
|
2025-12-05 18:26:36 -07:00
|
|
|
Form,
|
2023-10-20 18:53:26 -06:00
|
|
|
GridColumn,
|
|
|
|
|
GridRow,
|
2023-04-09 14:34:33 -06:00
|
|
|
Image,
|
|
|
|
|
Input,
|
2025-12-17 17:27:17 -07:00
|
|
|
PlaceholderHeader,
|
|
|
|
|
PlaceholderLine,
|
|
|
|
|
StatisticLabel,
|
|
|
|
|
StatisticValue,
|
2022-08-06 05:22:07 +00:00
|
|
|
TableCell,
|
2025-12-05 18:26:36 -07:00
|
|
|
TextArea,
|
2022-08-06 05:22:07 +00:00
|
|
|
} from "semantic-ui-react";
|
2025-12-17 17:27:17 -07:00
|
|
|
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
2022-08-06 05:22:07 +00:00
|
|
|
import {
|
2023-07-21 15:14:09 -06:00
|
|
|
APIButton,
|
2022-11-30 19:31:18 -07:00
|
|
|
BackButton,
|
2023-01-04 09:14:33 -07:00
|
|
|
CardLink,
|
2026-03-28 14:19:09 -06:00
|
|
|
DirectoryLink,
|
2023-10-20 18:53:26 -06:00
|
|
|
encodeMediaPath,
|
|
|
|
|
ErrorMessage,
|
2022-08-06 05:22:07 +00:00
|
|
|
ExternalCardLink,
|
|
|
|
|
FileIcon,
|
2023-03-29 13:46:39 -06:00
|
|
|
findPosterPath,
|
2023-04-09 14:52:44 -06:00
|
|
|
humanFileSize,
|
2025-12-17 17:27:17 -07:00
|
|
|
humanNumber,
|
2025-01-26 12:44:16 -07:00
|
|
|
InfoHeader,
|
2024-08-20 13:13:21 -06:00
|
|
|
isoDatetimeToAgoPopup,
|
2022-08-06 05:22:07 +00:00
|
|
|
mimetypeColor,
|
2023-02-15 21:05:34 -07:00
|
|
|
PageContainer,
|
2023-08-26 20:28:34 -06:00
|
|
|
PreviewPath,
|
2025-12-24 12:30:04 -07:00
|
|
|
resolveDataPath,
|
2023-04-09 14:34:33 -06:00
|
|
|
SearchInput,
|
|
|
|
|
SortButton,
|
2022-01-29 22:25:35 -07:00
|
|
|
TabLinks,
|
2022-01-29 21:24:39 -07:00
|
|
|
textEllipsis,
|
2022-10-25 15:57:44 -06:00
|
|
|
useTitle
|
2022-01-29 21:24:39 -07:00
|
|
|
} from "./Common";
|
2025-12-06 14:49:46 -07:00
|
|
|
import {
|
|
|
|
|
deleteDomain,
|
2026-05-03 18:50:22 -06:00
|
|
|
deleteFileGroups,
|
2026-01-23 19:51:02 -07:00
|
|
|
fetchArchiveBrowsers,
|
2025-12-22 17:56:35 -07:00
|
|
|
fetchArchiveDownloaderConfig,
|
2025-12-06 14:49:46 -07:00
|
|
|
generateArchiveScreenshot,
|
|
|
|
|
getCollectionTagInfo,
|
2025-12-22 17:56:35 -07:00
|
|
|
postArchiveFileFormat,
|
2025-12-06 14:49:46 -07:00
|
|
|
postDownload,
|
2026-01-23 19:51:02 -07:00
|
|
|
previewBatchReorganization,
|
2025-12-06 14:49:46 -07:00
|
|
|
refreshDomain,
|
|
|
|
|
tagDomain,
|
|
|
|
|
tagFileGroup,
|
2025-12-22 17:56:35 -07:00
|
|
|
untagFileGroup,
|
|
|
|
|
updateArchiveDownloaderConfig,
|
2025-12-06 14:49:46 -07:00
|
|
|
} from "../api";
|
2025-12-22 17:56:35 -07:00
|
|
|
import {InputForm, useForm} from "../hooks/useForm";
|
2026-05-03 17:28:06 -06:00
|
|
|
import {TaggedDeleteConfirmModal} from "./TaggedDeleteConfirmModal";
|
2025-10-29 22:16:33 -06:00
|
|
|
import {CollectionTagModal} from "./collections/CollectionTagModal";
|
2026-01-23 19:51:02 -07:00
|
|
|
import {CollectionReorganizeModal} from "./collections/CollectionReorganizeModal";
|
|
|
|
|
import {BatchReorganizeModal} from "./collections/BatchReorganizeModal";
|
2026-01-31 12:54:27 -07:00
|
|
|
import {useReorganizationStatus} from "../contexts/FileWorkerStatusContext";
|
2025-12-07 11:54:20 -07:00
|
|
|
import {Link, Route, Routes, useLocation, useNavigate, useParams} from "react-router";
|
2022-01-15 18:05:51 -07:00
|
|
|
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
2025-12-25 09:14:00 -07:00
|
|
|
import {
|
|
|
|
|
useArchive,
|
2026-02-02 15:15:28 -07:00
|
|
|
useArchiveStatistics,
|
2026-01-23 19:51:02 -07:00
|
|
|
useDockerized,
|
2025-12-25 09:14:00 -07:00
|
|
|
useDomain,
|
|
|
|
|
useDomains,
|
|
|
|
|
useOneQuery,
|
|
|
|
|
useSearchArchives,
|
|
|
|
|
useSearchDomain,
|
|
|
|
|
useSearchOrder
|
|
|
|
|
} from "../hooks/customHooks";
|
2023-04-09 14:34:33 -06:00
|
|
|
import {FileCards, FileRowTagIcon, FilesView} from "./Files";
|
2022-08-06 05:22:07 +00:00
|
|
|
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
|
|
|
|
import _ from "lodash";
|
2023-04-09 14:13:36 -06:00
|
|
|
import {Media, ThemeContext} from "../contexts/contexts";
|
2025-12-17 17:27:17 -07:00
|
|
|
import {Button, Card, darkTheme, Header, Loader, Placeholder, Popup, Segment, Statistic, Tab} from "./Theme";
|
2026-04-09 16:18:26 -06:00
|
|
|
import {BulkTagModal} from "./BulkTagModal";
|
2025-12-06 14:49:46 -07:00
|
|
|
import {taggedImageLabel, TagsSelector} from "../Tags";
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
import {AddToPlaylistButton} from "./AddToPlaylist";
|
Add PWA: installable app, offline calculators, read-only Inventory
Make the React app an installable PWA whose app shell, calculators
(incl. the One Time Pad), and Inventory work offline. Driving use case:
reference an inventory (e.g. Fasteners) from an iPhone with no connection.
Phase 1 — service worker (Workbox InjectManifest, production build only):
- service-worker.js: precache the shell (calculators work offline),
NavigationRoute for deep links, NetworkFirst cache of GET /api/inventory
and /api/inventory/catalog (wrolpi-inventory), NetworkOnly /api/status.
- serviceWorkerRegistration.js + registration in index.js.
- Add workbox-* runtime deps (pinned 6.5.4 to match CRA's bundled plugin).
Phase 2 — offline hardening + read-only Inventory:
- api.js maps offline fetch failures (TypeError / timeout / !navigator.onLine)
to ApiDownError so the existing nav apiDown indicator lights up.
- toast.js wrapper swallows error toasts while offline; repoint the toast
import in the 13 files that raise them (App.js container left as-is).
- PwaContext (usePwa() -> {offline, isStandalone}), provider mounted in
App.js inside StatusProvider. Default offline:false so components render
without the provider in tests.
- Inventory is read-only offline: InventoryRoute disables the edit buttons
and shows a banner; InventoryTable hides the new-item row, checkboxes and
delete, and disables click-to-edit. Values stay visible for reference.
Phase 3 — iOS Add-to-Home-Screen meta tags in public/index.html.
Verified end-to-end against the real API: SW caches the inventory, then with
the origin stopped the cached inventory still renders read-only (reactively
and on cold reload). All 676 Jest tests pass (incl. new InventoryTable
offline tests).
Media "Save for offline" + a Downloads list are intentionally deferred.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 15:21:25 -06:00
|
|
|
import {toast} from "../toast";
|
2025-01-26 12:44:16 -07:00
|
|
|
import {API_ARCHIVE_UPLOAD_URI, Downloaders} from "./Vars";
|
2025-10-29 22:16:33 -06:00
|
|
|
import {CollectionTable} from "./collections/CollectionTable";
|
|
|
|
|
import {CollectionEditForm} from "./collections/CollectionEditForm";
|
|
|
|
|
import {RecurringDownloadsTable} from "./admin/Downloads";
|
2025-12-05 18:26:36 -07:00
|
|
|
import {DestinationForm} from "./Download";
|
2022-08-06 05:22:07 +00:00
|
|
|
|
|
|
|
|
function ArchivePage() {
|
|
|
|
|
const navigate = useNavigate();
|
2026-03-20 15:38:32 -06:00
|
|
|
const {fileGroupId} = useParams();
|
|
|
|
|
const {archiveFile, history, fetchArchive} = useArchive(fileGroupId);
|
2023-08-26 20:28:34 -06:00
|
|
|
const {theme} = useContext(ThemeContext);
|
2026-05-03 17:28:06 -06:00
|
|
|
const [taggedFileGroups, setTaggedFileGroups] = useState(null);
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2023-10-24 10:20:06 -06:00
|
|
|
let title = archiveFile ? archiveFile.title ? archiveFile.title : archiveFile.name : null;
|
2022-10-25 15:57:44 -06:00
|
|
|
useTitle(title);
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
if (archiveFile === null) {
|
2022-05-16 17:56:55 -06:00
|
|
|
return <Segment><Loader active/></Segment>;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
2022-08-06 05:22:07 +00:00
|
|
|
if (archiveFile === undefined) {
|
2022-05-16 17:56:55 -06:00
|
|
|
return <>
|
|
|
|
|
<Header as='h2'>Unknown archive</Header>
|
2022-09-28 09:38:05 -06:00
|
|
|
<Header as='h4'>This archive does not exist</Header>
|
2022-05-16 17:56:55 -06:00
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-24 12:30:04 -07:00
|
|
|
const {data, size, directory} = archiveFile;
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2025-12-24 12:30:04 -07:00
|
|
|
// Resolve data paths (filename-only) to full relative paths using directory
|
|
|
|
|
const singlefilePath = resolveDataPath(data.singlefile_path, directory);
|
|
|
|
|
const readabilityPath = resolveDataPath(data.readability_path, directory);
|
|
|
|
|
const screenshotPath = resolveDataPath(data.screenshot_path, directory);
|
|
|
|
|
|
|
|
|
|
const singlefileUrl = singlefilePath ? `/media/${encodeMediaPath(singlefilePath)}` : null;
|
|
|
|
|
const readabilityUrl = readabilityPath ? `/media/${encodeMediaPath(readabilityPath)}` : null;
|
|
|
|
|
const screenshotUrl = screenshotPath ? `/media/${encodeMediaPath(screenshotPath)}` : null;
|
2022-05-16 17:56:55 -06:00
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
const singlefileButton = <ExternalCardLink to={singlefileUrl}>
|
2023-04-05 10:18:52 -06:00
|
|
|
<Button content='View' color='violet'/>
|
2022-08-06 05:22:07 +00:00
|
|
|
</ExternalCardLink>;
|
2024-05-25 09:40:13 -06:00
|
|
|
const readButton = <ExternalCardLink to={readabilityUrl}>
|
|
|
|
|
<Button content='Read' color='blue' disabled={!!!readabilityUrl}/>
|
|
|
|
|
</ExternalCardLink>
|
2022-05-16 17:56:55 -06:00
|
|
|
|
|
|
|
|
const screenshot = screenshotUrl ?
|
|
|
|
|
<Image src={screenshotUrl} size='large' style={{marginTop: '1em', marginBottom: '1em'}}/> :
|
|
|
|
|
null;
|
|
|
|
|
|
2026-05-03 17:28:06 -06:00
|
|
|
const localDeleteArchive = async (force = false) => {
|
2026-05-03 18:50:22 -06:00
|
|
|
const result = await deleteFileGroups([archiveFile.id], force);
|
2026-05-03 17:28:06 -06:00
|
|
|
if (result && result.tagged) {
|
|
|
|
|
setTaggedFileGroups(result.file_groups);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-07-21 15:14:09 -06:00
|
|
|
toast({
|
|
|
|
|
type: 'success',
|
|
|
|
|
title: 'Archive Deleted',
|
|
|
|
|
description: 'Archive was successfully deleted.',
|
|
|
|
|
time: 2000,
|
|
|
|
|
})
|
2022-09-23 16:22:57 -06:00
|
|
|
navigate(-1);
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
2024-04-14 14:05:22 -06:00
|
|
|
|
2022-11-14 15:42:57 -07:00
|
|
|
const localUpdateArchive = async () => {
|
2024-11-02 15:14:02 -06:00
|
|
|
const downloadData = {urls: [archiveFile.url], downloader: Downloaders.Archive};
|
|
|
|
|
const response = await postDownload(downloadData);
|
2024-04-14 14:02:02 -06:00
|
|
|
if (response.ok) {
|
|
|
|
|
toast({
|
|
|
|
|
type: 'success',
|
|
|
|
|
title: 'Archive Downloading',
|
|
|
|
|
description: 'Archive update has been scheduled.',
|
|
|
|
|
time: 2000,
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-05-16 17:56:55 -06:00
|
|
|
}
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2025-10-19 11:40:02 -06:00
|
|
|
const localGenerateScreenshot = async () => {
|
2026-03-20 15:38:32 -06:00
|
|
|
const success = await generateArchiveScreenshot(archiveFile.id);
|
2025-10-19 11:40:02 -06:00
|
|
|
if (success) {
|
|
|
|
|
// Refresh the archive data after a short delay to show the new screenshot
|
|
|
|
|
setTimeout(() => fetchArchive(), 2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-21 15:14:09 -06:00
|
|
|
const updateButton = <APIButton
|
|
|
|
|
text='Update'
|
|
|
|
|
color='green'
|
|
|
|
|
confirmContent='Download the latest version of this URL?'
|
|
|
|
|
confirmButton='Update'
|
|
|
|
|
onClick={localUpdateArchive}
|
|
|
|
|
obeyWROLMode={true}
|
2023-08-26 20:28:34 -06:00
|
|
|
style={{marginTop: '0.5em'}}
|
|
|
|
|
>
|
|
|
|
|
Update
|
|
|
|
|
</APIButton>;
|
2023-07-21 15:14:09 -06:00
|
|
|
const deleteButton = <APIButton
|
|
|
|
|
text='Delete'
|
|
|
|
|
color='red'
|
|
|
|
|
confirmContent='Are you sure you want to delete this archive? All files will be deleted'
|
|
|
|
|
confirmButton='Delete'
|
2026-05-03 17:28:06 -06:00
|
|
|
onClick={() => localDeleteArchive(false)}
|
2023-07-21 15:14:09 -06:00
|
|
|
obeyWROLMode={true}
|
2023-08-26 20:28:34 -06:00
|
|
|
>
|
|
|
|
|
Delete
|
|
|
|
|
</APIButton>;
|
2025-10-19 11:40:02 -06:00
|
|
|
const generateScreenshotButton = !screenshotUrl ? <APIButton
|
|
|
|
|
text='Generate Screenshot'
|
|
|
|
|
color='yellow'
|
|
|
|
|
confirmContent='Generate a screenshot for this archive?'
|
|
|
|
|
confirmButton='Generate'
|
|
|
|
|
onClick={localGenerateScreenshot}
|
|
|
|
|
obeyWROLMode={true}
|
|
|
|
|
style={{marginTop: '0.5em'}}
|
|
|
|
|
>
|
|
|
|
|
Generate Screenshot
|
|
|
|
|
</APIButton> : null;
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2022-11-14 15:42:57 -07:00
|
|
|
let historyList = <Loader active/>;
|
2023-01-04 09:14:33 -07:00
|
|
|
if (history && history.length === 0) {
|
2022-11-14 15:42:57 -07:00
|
|
|
historyList = <p>No history available</p>;
|
2023-01-04 09:14:33 -07:00
|
|
|
} else if (history) {
|
|
|
|
|
historyList = <FileCards files={history}/>;
|
2022-01-03 15:13:02 -07:00
|
|
|
}
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2023-07-27 15:53:47 -06:00
|
|
|
const domain = data.domain ? data.domain : null;
|
2023-08-26 20:28:34 -06:00
|
|
|
let domainHeader = <p>Unknown</p>;
|
2022-10-27 11:30:53 -06:00
|
|
|
if (domain) {
|
2026-03-20 15:38:32 -06:00
|
|
|
const domainUrl = `/archives?domain=${domain}`;
|
2023-07-27 15:53:47 -06:00
|
|
|
domainHeader = <Header as='h4'>
|
2023-10-31 10:20:45 -06:00
|
|
|
<a href={domainUrl}>{domain}</a>
|
2022-10-27 11:30:53 -06:00
|
|
|
</Header>;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-02 16:30:01 -06:00
|
|
|
const localAddTag = async (name) => {
|
2023-05-29 18:04:03 -06:00
|
|
|
await tagFileGroup(archiveFile, name);
|
2023-04-02 16:30:01 -06:00
|
|
|
await fetchArchive();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const localRemoveTag = async (name) => {
|
2023-05-29 18:04:03 -06:00
|
|
|
await untagFileGroup(archiveFile, name);
|
2023-04-02 16:30:01 -06:00
|
|
|
await fetchArchive();
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-25 09:14:00 -07:00
|
|
|
const downloadDatetimeString = archiveFile.download_datetime ?
|
|
|
|
|
isoDatetimeToAgoPopup(archiveFile.download_datetime, true) : 'unknown';
|
|
|
|
|
const publishedDatetimeString = archiveFile.published_datetime ?
|
|
|
|
|
isoDatetimeToAgoPopup(archiveFile.published_datetime, true) : 'unknown';
|
2023-10-20 18:53:26 -06:00
|
|
|
const modifiedDatetimeString = archiveFile.published_modified_datetime
|
2024-11-02 15:14:02 -06:00
|
|
|
? isoDatetimeToAgoPopup(archiveFile.published_modified_datetime, true)
|
2023-10-20 18:53:26 -06:00
|
|
|
: 'unknown';
|
|
|
|
|
|
2023-08-26 20:28:34 -06:00
|
|
|
const aboutPane = {
|
2025-12-07 11:32:07 -07:00
|
|
|
menuItem: 'About', render: () => <Tab.Pane>
|
2023-08-26 20:28:34 -06:00
|
|
|
<Header as={'h3'}>Domain</Header>
|
|
|
|
|
{domainHeader}
|
|
|
|
|
|
|
|
|
|
<Header as='h3'>Size</Header>
|
|
|
|
|
{humanFileSize(size)}
|
|
|
|
|
|
|
|
|
|
<Header as={'h3'}>URL</Header>
|
2023-10-31 10:20:45 -06:00
|
|
|
<p>{archiveFile.url ? <a href={archiveFile.url}>{archiveFile.url}</a> : 'N/A'}</p>
|
2023-10-20 18:53:26 -06:00
|
|
|
|
|
|
|
|
<Header as={'h3'}>Modified Date</Header>
|
|
|
|
|
<p>{modifiedDatetimeString}</p>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Tab.Pane>
|
2023-08-26 20:28:34 -06:00
|
|
|
};
|
|
|
|
|
|
2026-03-28 14:19:09 -06:00
|
|
|
// Helper to find file size from the files array by resolved path
|
|
|
|
|
const findFileSize = (resolvedPath) => {
|
|
|
|
|
if (!resolvedPath || !archiveFile.files) return null;
|
|
|
|
|
const file = archiveFile.files.find(i => String(i.path) === String(resolvedPath));
|
|
|
|
|
return file && file.size
|
|
|
|
|
? <span style={{marginLeft: '1em', color: 'grey'}}>({humanFileSize(file.size)})</span>
|
|
|
|
|
: null;
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-24 12:30:04 -07:00
|
|
|
// Helper to resolve and preview a data path
|
|
|
|
|
const localPreviewPath = (dataPath, mimetype) => {
|
|
|
|
|
const resolvedPath = resolveDataPath(dataPath, directory);
|
|
|
|
|
if (resolvedPath) {
|
2026-03-28 14:19:09 -06:00
|
|
|
return <><PreviewPath path={resolvedPath} mimetype={mimetype}
|
|
|
|
|
taggable={false}>{resolvedPath}</PreviewPath>{findFileSize(resolvedPath)}</>
|
2023-08-26 20:28:34 -06:00
|
|
|
} else {
|
|
|
|
|
return 'Unknown'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-28 14:19:09 -06:00
|
|
|
const tableStyle = {width: '100%', borderCollapse: 'separate', borderSpacing: '0 0.7em'};
|
|
|
|
|
const labelStyle = {whiteSpace: 'nowrap', paddingRight: '1.5em', verticalAlign: 'top'};
|
2023-08-26 20:28:34 -06:00
|
|
|
const filesPane = {
|
2025-12-07 11:32:07 -07:00
|
|
|
menuItem: 'Files', render: () => <Tab.Pane>
|
2026-03-28 14:19:09 -06:00
|
|
|
<table style={tableStyle}>
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Singlefile File</strong></td>
|
|
|
|
|
<td>{localPreviewPath(data.singlefile_path, 'text/html')}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Readability File</strong></td>
|
|
|
|
|
<td>{localPreviewPath(data.readability_path, 'text/html')}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Readability Text File</strong></td>
|
|
|
|
|
<td>{localPreviewPath(data.readability_txt_path, 'text/plain')}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Readability JSON File</strong></td>
|
|
|
|
|
<td>{localPreviewPath(data.readability_json_path, 'application/json')}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Screenshot File</strong></td>
|
|
|
|
|
<td>
|
|
|
|
|
{screenshotPath
|
|
|
|
|
? <><PreviewPath path={screenshotPath} mimetype='image/*'
|
|
|
|
|
taggable={false}>{screenshotPath}</PreviewPath>{findFileSize(screenshotPath)}</>
|
|
|
|
|
: 'Unknown'}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Directory</strong></td>
|
|
|
|
|
<td><DirectoryLink path={archiveFile.directory}/></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Tab.Pane>
|
2023-08-26 20:28:34 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const tabPanes = [aboutPane, filesPane];
|
|
|
|
|
const tabMenu = theme === darkTheme ? {inverted: true, attached: true} : {attached: true};
|
|
|
|
|
|
2023-02-17 16:09:24 -07:00
|
|
|
return <>
|
|
|
|
|
<BackButton/>
|
2022-05-16 17:56:55 -06:00
|
|
|
|
2023-02-17 16:09:24 -07:00
|
|
|
<Segment>
|
|
|
|
|
{screenshot}
|
|
|
|
|
<ExternalCardLink to={singlefileUrl}>
|
2023-04-06 11:05:14 -06:00
|
|
|
<Header as='h2'>{textEllipsis(archiveFile.title || data.url)}</Header>
|
2023-02-17 16:09:24 -07:00
|
|
|
</ExternalCardLink>
|
2023-10-20 18:53:26 -06:00
|
|
|
|
|
|
|
|
<Header as='h3'>Author: {archiveFile.author ? archiveFile.author : 'unknown'}</Header>
|
|
|
|
|
|
|
|
|
|
<Grid columns={2} stackable>
|
|
|
|
|
<GridRow>
|
|
|
|
|
<GridColumn>
|
|
|
|
|
<Header as='h4'>Published: {publishedDatetimeString}</Header>
|
|
|
|
|
</GridColumn>
|
|
|
|
|
<GridColumn>
|
2025-12-25 09:14:00 -07:00
|
|
|
<Header as='h4'>Downloaded: {downloadDatetimeString}</Header>
|
2023-10-20 18:53:26 -06:00
|
|
|
</GridColumn>
|
|
|
|
|
</GridRow>
|
|
|
|
|
</Grid>
|
2023-02-17 16:09:24 -07:00
|
|
|
|
2023-08-28 09:47:51 -06:00
|
|
|
{singlefileButton}
|
2024-05-25 09:40:13 -06:00
|
|
|
{readButton}
|
2023-02-17 16:09:24 -07:00
|
|
|
{updateButton}
|
|
|
|
|
{deleteButton}
|
2025-10-19 11:40:02 -06:00
|
|
|
{generateScreenshotButton}
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
<AddToPlaylistButton fileGroupId={archiveFile.id}/>
|
2023-02-17 16:09:24 -07:00
|
|
|
</Segment>
|
|
|
|
|
|
2023-03-24 08:58:18 -06:00
|
|
|
<Segment>
|
2024-07-22 16:36:57 -06:00
|
|
|
<TagsSelector
|
|
|
|
|
selectedTagNames={archiveFile['tags']}
|
|
|
|
|
onAdd={localAddTag}
|
|
|
|
|
onRemove={localRemoveTag}
|
|
|
|
|
/>
|
2023-03-24 08:58:18 -06:00
|
|
|
</Segment>
|
|
|
|
|
|
2023-08-26 20:28:34 -06:00
|
|
|
<Tab menu={tabMenu} panes={tabPanes}/>
|
|
|
|
|
|
2023-02-17 16:09:24 -07:00
|
|
|
<Segment>
|
2025-01-24 14:28:04 -07:00
|
|
|
<InfoHeader
|
2023-02-17 16:09:24 -07:00
|
|
|
headerContent='History'
|
|
|
|
|
popupContent='Other archives of this URL created at different times.'
|
|
|
|
|
/>
|
|
|
|
|
{historyList}
|
|
|
|
|
</Segment>
|
2026-05-03 17:28:06 -06:00
|
|
|
|
|
|
|
|
<TaggedDeleteConfirmModal
|
|
|
|
|
open={taggedFileGroups !== null}
|
|
|
|
|
taggedFileGroups={taggedFileGroups}
|
|
|
|
|
onCancel={() => setTaggedFileGroups(null)}
|
|
|
|
|
onConfirm={async () => {
|
|
|
|
|
setTaggedFileGroups(null);
|
|
|
|
|
await localDeleteArchive(true);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-02-17 16:09:24 -07:00
|
|
|
</>
|
2022-05-16 17:56:55 -06:00
|
|
|
}
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
export function ArchiveCard({file}) {
|
|
|
|
|
const {s} = useContext(ThemeContext);
|
2026-03-17 18:35:57 -06:00
|
|
|
const {sort} = useSearchOrder();
|
|
|
|
|
const sortField = sort ? sort.replace(/^-/, '') : null;
|
2025-12-24 12:30:04 -07:00
|
|
|
const {data, directory} = file;
|
|
|
|
|
|
|
|
|
|
// Resolve data paths (filename-only) to full relative paths using directory
|
|
|
|
|
const screenshotPath = resolveDataPath(data.screenshot_path, directory);
|
|
|
|
|
const singlefilePath = resolveDataPath(data.singlefile_path, directory);
|
2022-05-16 17:56:55 -06:00
|
|
|
|
2025-12-24 12:30:04 -07:00
|
|
|
const imageSrc = screenshotPath ? `/media/${encodeMediaPath(screenshotPath)}` : null;
|
|
|
|
|
const singlefileUrl = singlefilePath ? `/media/${encodeMediaPath(singlefilePath)}` : null;
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2025-12-07 11:32:07 -07:00
|
|
|
let screenshot = <Card.Icon><FileIcon file={file}/></Card.Icon>;
|
2023-03-24 08:58:18 -06:00
|
|
|
const imageLabel = file.tags && file.tags.length ? taggedImageLabel : null;
|
2022-08-06 05:22:07 +00:00
|
|
|
if (imageSrc) {
|
2023-03-24 08:58:18 -06:00
|
|
|
screenshot = <Image src={imageSrc} wrapped style={{position: 'relative', width: '100%'}} label={imageLabel}/>;
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-24 08:58:18 -06:00
|
|
|
const domain = data ? data.domain : null;
|
2026-03-20 15:38:32 -06:00
|
|
|
const domainUrl = `/archives?domain=${domain}`;
|
2022-01-30 16:27:06 -07:00
|
|
|
|
2024-08-20 13:13:21 -06:00
|
|
|
const title = file.title || data.url;
|
|
|
|
|
const header = <ExternalCardLink to={singlefileUrl} className='card-title-ellipsis'>{title}</ExternalCardLink>;
|
|
|
|
|
const dt = file.published_datetime || file.published_modified_datetime || file.modified;
|
2023-02-17 16:09:24 -07:00
|
|
|
return <Card color={mimetypeColor(file.mimetype)}>
|
|
|
|
|
<div>
|
|
|
|
|
<ExternalCardLink to={singlefileUrl}>
|
|
|
|
|
{screenshot}
|
|
|
|
|
</ExternalCardLink>
|
|
|
|
|
</div>
|
|
|
|
|
<CardContent {...s}>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<Container textAlign='left'>
|
2024-08-20 13:13:21 -06:00
|
|
|
<Popup on='hover'
|
|
|
|
|
trigger={header}
|
|
|
|
|
content={title}/>
|
2023-02-17 16:09:24 -07:00
|
|
|
</Container>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
{domain &&
|
|
|
|
|
<CardLink to={domainUrl}>
|
2023-11-02 10:07:49 -06:00
|
|
|
<span {...s}>{domain}</span>
|
2023-02-17 16:09:24 -07:00
|
|
|
</CardLink>}
|
|
|
|
|
<CardMeta {...s}>
|
2026-03-17 18:35:57 -06:00
|
|
|
{sortField === 'published_modified_datetime'
|
|
|
|
|
? isoDatetimeToAgoPopup(file.published_modified_datetime, false)
|
|
|
|
|
: sortField === 'download_datetime'
|
|
|
|
|
? isoDatetimeToAgoPopup(file.download_datetime, false)
|
|
|
|
|
: sortField === 'size'
|
|
|
|
|
? humanFileSize(file.size)
|
|
|
|
|
: sortField === 'viewed'
|
|
|
|
|
? isoDatetimeToAgoPopup(file.viewed, false)
|
|
|
|
|
: isoDatetimeToAgoPopup(dt, false)
|
|
|
|
|
}
|
2023-02-17 16:09:24 -07:00
|
|
|
</CardMeta>
|
|
|
|
|
<CardDescription>
|
2026-03-20 15:38:32 -06:00
|
|
|
<Link to={`/archives/${file.id}`}>
|
2023-02-17 16:09:24 -07:00
|
|
|
<Button icon='file alternate' content='Details'
|
|
|
|
|
labelPosition='left'/>
|
|
|
|
|
</Link>
|
2023-10-31 10:20:45 -06:00
|
|
|
<Button icon='external' href={file.url} target='_blank' rel='noopener noreferrer'/>
|
2023-02-17 16:09:24 -07:00
|
|
|
</CardDescription>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
2022-01-03 15:13:02 -07:00
|
|
|
}
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2025-12-05 17:12:21 -07:00
|
|
|
// Domain table column configuration
|
|
|
|
|
const DOMAIN_COLUMNS = [
|
|
|
|
|
{key: 'domain', label: 'Domain', sortable: true, width: 7},
|
|
|
|
|
{key: 'tag_name', label: 'Tag', sortable: true, width: 2},
|
|
|
|
|
{key: 'archive_count', label: 'Archives', sortable: true, align: 'right', width: 2},
|
2025-12-06 14:49:46 -07:00
|
|
|
{
|
|
|
|
|
key: 'min_download_frequency',
|
|
|
|
|
label: 'Download Frequency',
|
|
|
|
|
sortable: true,
|
|
|
|
|
format: 'frequency',
|
|
|
|
|
width: 2,
|
|
|
|
|
hideOnMobile: true
|
|
|
|
|
},
|
2025-12-05 17:12:21 -07:00
|
|
|
{key: 'size', label: 'Size', sortable: true, align: 'right', format: 'bytes', width: 2, hideOnMobile: true},
|
|
|
|
|
{key: 'actions', label: 'Manage', sortable: false, type: 'actions', width: 1}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const DOMAIN_ROUTES = {
|
2026-03-20 15:38:32 -06:00
|
|
|
list: '/archives/domains',
|
|
|
|
|
edit: '/archives/domain/:id/edit',
|
|
|
|
|
search: '/archives',
|
2025-12-05 17:12:21 -07:00
|
|
|
searchParam: 'domain'
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-17 17:27:17 -07:00
|
|
|
function DomainStatistics({statistics}) {
|
|
|
|
|
if (!statistics) {
|
|
|
|
|
return <></>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <Segment>
|
|
|
|
|
<Header as='h1'>Statistics</Header>
|
|
|
|
|
<Statistic>
|
|
|
|
|
<StatisticValue>{statistics.archive_count}</StatisticValue>
|
|
|
|
|
<StatisticLabel>Archives</StatisticLabel>
|
|
|
|
|
</Statistic>
|
|
|
|
|
<Statistic>
|
|
|
|
|
<StatisticValue>{humanFileSize(statistics.size, true)}</StatisticValue>
|
|
|
|
|
<StatisticLabel>Total Size</StatisticLabel>
|
|
|
|
|
</Statistic>
|
|
|
|
|
<Statistic>
|
|
|
|
|
<StatisticValue>{humanFileSize(statistics.largest_archive, true)}</StatisticValue>
|
|
|
|
|
<StatisticLabel>Largest Archive</StatisticLabel>
|
|
|
|
|
</Statistic>
|
|
|
|
|
<Statistic>
|
|
|
|
|
<StatisticValue>{humanNumber(statistics.archive_tags)}</StatisticValue>
|
|
|
|
|
<StatisticLabel>Archive Tags</StatisticLabel>
|
|
|
|
|
</Statistic>
|
|
|
|
|
</Segment>
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-09 14:13:36 -06:00
|
|
|
export function DomainsPage() {
|
2022-10-25 15:57:44 -06:00
|
|
|
useTitle('Archive Domains');
|
|
|
|
|
|
2025-12-05 17:12:21 -07:00
|
|
|
const [domains] = useDomains();
|
2025-10-29 22:16:33 -06:00
|
|
|
const [searchStr, setSearchStr] = useOneQuery('domain');
|
2026-02-23 17:29:09 -07:00
|
|
|
const searchInputRef = React.useRef();
|
|
|
|
|
|
|
|
|
|
useHotkeys('f', (e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (searchInputRef.current) {
|
|
|
|
|
searchInputRef.current.focus();
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false});
|
2025-10-29 22:16:33 -06:00
|
|
|
|
|
|
|
|
// Header section matching ChannelsPage pattern
|
|
|
|
|
const header = <div style={{marginBottom: '1em'}}>
|
|
|
|
|
<Grid stackable columns={2}>
|
|
|
|
|
<Grid.Row>
|
|
|
|
|
<Grid.Column>
|
|
|
|
|
<SearchInput
|
|
|
|
|
placeholder='Domain filter...'
|
|
|
|
|
size='large'
|
|
|
|
|
searchStr={searchStr}
|
|
|
|
|
disabled={!Array.isArray(domains) || domains.length === 0}
|
|
|
|
|
onClear={() => setSearchStr('')}
|
|
|
|
|
onChange={setSearchStr}
|
|
|
|
|
onSubmit={null}
|
2026-02-23 17:29:09 -07:00
|
|
|
inputRef={searchInputRef}
|
2025-10-29 22:16:33 -06:00
|
|
|
/>
|
|
|
|
|
</Grid.Column>
|
|
|
|
|
<Grid.Column textAlign='right'>
|
|
|
|
|
{/* No "New Domain" button - domains are auto-created */}
|
|
|
|
|
</Grid.Column>
|
|
|
|
|
</Grid.Row>
|
|
|
|
|
</Grid>
|
|
|
|
|
</div>;
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
// Empty state
|
|
|
|
|
if (domains && domains.length === 0) {
|
2023-01-04 09:14:33 -07:00
|
|
|
return <>
|
2025-10-29 22:16:33 -06:00
|
|
|
{header}
|
|
|
|
|
<Message>
|
|
|
|
|
<Message.Header>No domains yet. Archive some webpages!</Message.Header>
|
|
|
|
|
</Message>
|
2023-01-04 09:14:33 -07:00
|
|
|
</>;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
// Error state
|
|
|
|
|
if (domains === undefined) {
|
|
|
|
|
return <>
|
|
|
|
|
{header}
|
|
|
|
|
<ErrorMessage>Could not fetch Domains</ErrorMessage>
|
|
|
|
|
</>;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
return <>
|
|
|
|
|
{header}
|
|
|
|
|
<CollectionTable
|
|
|
|
|
collections={domains}
|
2025-12-05 17:12:21 -07:00
|
|
|
columns={DOMAIN_COLUMNS}
|
|
|
|
|
routes={DOMAIN_ROUTES}
|
2025-10-29 22:16:33 -06:00
|
|
|
searchStr={searchStr}
|
|
|
|
|
/>
|
|
|
|
|
</>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function DomainEditPage() {
|
|
|
|
|
const {domainId} = useParams();
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const {domain, form, fetchDomain} = useDomain(parseInt(domainId));
|
|
|
|
|
|
|
|
|
|
// Modal state for tagging
|
|
|
|
|
const [tagEditModalOpen, setTagEditModalOpen] = useState(false);
|
2026-01-23 19:51:02 -07:00
|
|
|
// Modal state for reorganization
|
|
|
|
|
const [reorganizeModalOpen, setReorganizeModalOpen] = useState(false);
|
2025-10-29 22:16:33 -06:00
|
|
|
|
|
|
|
|
useTitle(`Edit Domain: ${domain?.domain || '...'}`);
|
|
|
|
|
|
|
|
|
|
// Wrap form.onSubmit to add toast and refresh domain data
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
if (form && form.onSubmit) {
|
|
|
|
|
const originalOnSubmit = form.onSubmit;
|
|
|
|
|
form.onSubmit = async () => {
|
|
|
|
|
try {
|
|
|
|
|
await originalOnSubmit();
|
|
|
|
|
toast({
|
|
|
|
|
type: 'success',
|
|
|
|
|
title: 'Domain Updated',
|
|
|
|
|
description: 'Domain was successfully updated',
|
|
|
|
|
time: 3000,
|
|
|
|
|
});
|
|
|
|
|
// Refresh domain data to show updated values
|
|
|
|
|
await fetchDomain();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Failed to update domain:', e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}, [form, fetchDomain]);
|
|
|
|
|
|
|
|
|
|
// Handler for tag modal save
|
|
|
|
|
const handleTagSave = async (tagName, directory) => {
|
|
|
|
|
try {
|
|
|
|
|
await tagDomain(parseInt(domainId), tagName, directory);
|
|
|
|
|
toast({
|
|
|
|
|
type: 'success',
|
|
|
|
|
title: 'Domain Tagged',
|
|
|
|
|
description: `Domain "${domain?.domain}" has been tagged with "${tagName}"`,
|
|
|
|
|
time: 3000,
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Failed to tag domain', e);
|
|
|
|
|
} finally {
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
|
await fetchDomain();
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handler for fetching tag info
|
|
|
|
|
const handleGetTagInfo = async (tagName) => {
|
|
|
|
|
if (domain?.id) {
|
|
|
|
|
return await getCollectionTagInfo(domain.id, tagName);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleRefreshDomain = async (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
await refreshDomain(parseInt(domainId));
|
|
|
|
|
// Refresh domain data after completion
|
|
|
|
|
await fetchDomain();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!form.ready) {
|
|
|
|
|
return <Loader active>Loading domain...</Loader>;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
// Handler for domain deletion
|
|
|
|
|
const handleDelete = async () => {
|
|
|
|
|
try {
|
|
|
|
|
let response = await deleteDomain(parseInt(domainId));
|
|
|
|
|
if (response.status === 204) {
|
2026-03-20 15:38:32 -06:00
|
|
|
navigate('/archives/domains');
|
2025-10-29 22:16:33 -06:00
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Failed to delete domain', e);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const deleteButton = <APIButton
|
|
|
|
|
color='red'
|
|
|
|
|
size='small'
|
|
|
|
|
confirmContent='Are you sure you want to delete this domain? No archive files will be deleted, but archives will be orphaned.'
|
|
|
|
|
confirmButton='Delete'
|
|
|
|
|
confirmHeader='Delete Domain?'
|
|
|
|
|
onClick={handleDelete}
|
|
|
|
|
obeyWROLMode={true}
|
|
|
|
|
style={{marginTop: '1em'}}
|
|
|
|
|
>Delete</APIButton>;
|
|
|
|
|
|
|
|
|
|
const refreshButton = domain?.directory ? (
|
|
|
|
|
<APIButton
|
|
|
|
|
color='blue'
|
|
|
|
|
size='small'
|
|
|
|
|
onClick={handleRefreshDomain}
|
|
|
|
|
obeyWROLMode={true}
|
|
|
|
|
style={{marginTop: '1em'}}
|
|
|
|
|
>Refresh</APIButton>
|
|
|
|
|
) : null;
|
|
|
|
|
|
|
|
|
|
const tagButton = <Button
|
|
|
|
|
type="button"
|
|
|
|
|
size='small'
|
|
|
|
|
onClick={() => setTagEditModalOpen(true)}
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
color='violet'
|
2025-10-29 22:16:33 -06:00
|
|
|
style={{marginTop: '1em'}}
|
|
|
|
|
>Tag</Button>;
|
|
|
|
|
|
2026-01-23 19:51:02 -07:00
|
|
|
const reorganizeButton = (
|
|
|
|
|
<APIButton
|
|
|
|
|
color='orange'
|
|
|
|
|
size='small'
|
|
|
|
|
onClick={() => setReorganizeModalOpen(true)}
|
|
|
|
|
obeyWROLMode={true}
|
|
|
|
|
style={{marginTop: '1em'}}
|
|
|
|
|
>Reorganize Files</APIButton>
|
|
|
|
|
);
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
const actionButtons = <>
|
|
|
|
|
{deleteButton}
|
|
|
|
|
{refreshButton}
|
|
|
|
|
{tagButton}
|
2026-01-23 19:51:02 -07:00
|
|
|
{reorganizeButton}
|
2025-10-29 22:16:33 -06:00
|
|
|
</>;
|
2023-01-31 18:08:07 -07:00
|
|
|
|
2025-12-05 18:26:36 -07:00
|
|
|
const [descriptionProps] = form.getCustomProps({name: 'description', path: 'description'});
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
return <>
|
2025-10-29 22:16:33 -06:00
|
|
|
<BackButton/>
|
2026-03-20 15:38:32 -06:00
|
|
|
<Link to={`/archives?domain=${domain?.domain}`}>
|
2025-12-17 17:27:17 -07:00
|
|
|
<Button>Archives</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
|
2026-01-23 19:51:02 -07:00
|
|
|
{domain?.needs_reorganization && (
|
|
|
|
|
<Message warning>
|
|
|
|
|
<Message.Header>File Format Changed</Message.Header>
|
|
|
|
|
<p>
|
|
|
|
|
The file name format has changed. Click "Reorganize Files" to move existing files
|
|
|
|
|
to match the new format.
|
|
|
|
|
</p>
|
|
|
|
|
</Message>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
<CollectionEditForm
|
|
|
|
|
form={form}
|
|
|
|
|
title={`Edit Domain: ${domain?.domain || '...'}`}
|
|
|
|
|
wrolModeContent='Domain editing is disabled while in WROL Mode.'
|
|
|
|
|
actionButtons={actionButtons}
|
|
|
|
|
appliedTagName={domain?.tag_name}
|
2025-12-05 18:26:36 -07:00
|
|
|
>
|
|
|
|
|
<GridRow>
|
|
|
|
|
<GridColumn>
|
|
|
|
|
<DestinationForm
|
|
|
|
|
form={form}
|
|
|
|
|
label='Directory'
|
|
|
|
|
name='directory'
|
|
|
|
|
path='directory'
|
|
|
|
|
/>
|
|
|
|
|
</GridColumn>
|
|
|
|
|
</GridRow>
|
|
|
|
|
<GridRow>
|
|
|
|
|
<GridColumn>
|
|
|
|
|
<Form.Field>
|
|
|
|
|
<label>Description</label>
|
|
|
|
|
<TextArea
|
|
|
|
|
placeholder='Optional description'
|
|
|
|
|
{...descriptionProps}
|
|
|
|
|
onChange={(e, {value}) => descriptionProps.onChange(value)}
|
|
|
|
|
rows={3}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Field>
|
|
|
|
|
</GridColumn>
|
|
|
|
|
</GridRow>
|
|
|
|
|
</CollectionEditForm>
|
2025-10-29 22:16:33 -06:00
|
|
|
|
|
|
|
|
{/* Tag Modal */}
|
|
|
|
|
<CollectionTagModal
|
|
|
|
|
open={tagEditModalOpen}
|
|
|
|
|
onClose={() => setTagEditModalOpen(false)}
|
|
|
|
|
currentTagName={domain?.tag_name}
|
|
|
|
|
originalDirectory={domain?.directory}
|
|
|
|
|
getTagInfo={handleGetTagInfo}
|
|
|
|
|
onSave={handleTagSave}
|
|
|
|
|
collectionName="Domain"
|
2025-12-06 09:27:40 -07:00
|
|
|
hasDirectory={!!domain?.directory}
|
2023-01-31 18:08:07 -07:00
|
|
|
/>
|
2025-10-29 22:16:33 -06:00
|
|
|
|
2026-01-23 19:51:02 -07:00
|
|
|
{/* Reorganize Modal */}
|
|
|
|
|
<CollectionReorganizeModal
|
|
|
|
|
open={reorganizeModalOpen}
|
|
|
|
|
onClose={() => setReorganizeModalOpen(false)}
|
|
|
|
|
collectionId={domain?.id}
|
|
|
|
|
collectionName={domain?.domain}
|
|
|
|
|
onComplete={fetchDomain}
|
|
|
|
|
needsReorganization={domain?.needs_reorganization}
|
|
|
|
|
/>
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
{/* Downloads Segment */}
|
|
|
|
|
<Segment>
|
|
|
|
|
<Header as='h1'>Downloads</Header>
|
|
|
|
|
<RecurringDownloadsTable
|
|
|
|
|
downloads={domain?.downloads}
|
|
|
|
|
fetchDownloads={fetchDomain}
|
|
|
|
|
/>
|
|
|
|
|
</Segment>
|
2025-12-17 17:27:17 -07:00
|
|
|
|
|
|
|
|
{domain && domain.statistics && <DomainStatistics statistics={domain.statistics}/>}
|
2022-08-06 05:22:07 +00:00
|
|
|
</>;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2025-12-22 17:56:35 -07:00
|
|
|
function ArchiveFileNameForm({form}) {
|
|
|
|
|
const [message, setMessage] = React.useState(null);
|
|
|
|
|
|
|
|
|
|
const onChange = async (value) => {
|
|
|
|
|
const response = await postArchiveFileFormat(value);
|
|
|
|
|
const {error, preview} = await response.json();
|
|
|
|
|
if (error) {
|
|
|
|
|
setMessage({content: error, header: 'Invalid File Name', negative: true});
|
|
|
|
|
} else {
|
|
|
|
|
setMessage({content: preview, header: 'File Name Preview', positive: true});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const label = <InfoHeader
|
|
|
|
|
headerSize='h5'
|
|
|
|
|
headerContent='Archive File Format'
|
|
|
|
|
popupProps={{wide: 'very', position: 'top left'}}
|
|
|
|
|
popupContent={<>
|
|
|
|
|
<p>Variables:</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>%(title)s</code> - Page title</li>
|
|
|
|
|
<li><code>%(download_datetime)s</code> - Full datetime (YYYY-MM-DD-HH-MM-SS)</li>
|
|
|
|
|
<li><code>%(download_date)s</code> - Date only (YYYY-MM-DD)</li>
|
|
|
|
|
<li><code>%(download_year)s</code> - Year</li>
|
|
|
|
|
<li><code>%(download_month)s</code> - Month (zero-padded)</li>
|
|
|
|
|
<li><code>%(download_day)s</code> - Day (zero-padded)</li>
|
|
|
|
|
<li><code>%(domain)s</code> - Domain name</li>
|
2025-12-23 19:11:07 -07:00
|
|
|
<li><code>%(ext)s</code> - File extension (required, must be at end)</li>
|
2025-12-22 17:56:35 -07:00
|
|
|
</ul>
|
2025-12-23 19:11:07 -07:00
|
|
|
<p>Subdirectories supported: <code>%(download_year)s/%(title)s.%(ext)s</code></p>
|
2025-12-22 17:56:35 -07:00
|
|
|
</>}
|
|
|
|
|
/>;
|
|
|
|
|
|
|
|
|
|
return <InputForm
|
|
|
|
|
form={form}
|
|
|
|
|
name='file_name_format'
|
|
|
|
|
path='file_name_format'
|
|
|
|
|
label={label}
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
message={message}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-23 19:51:02 -07:00
|
|
|
function BrowserConfigForm({form, browsers, browsersAvailable}) {
|
|
|
|
|
const {t} = React.useContext(ThemeContext);
|
|
|
|
|
const [useCustomPath, setUseCustomPath] = useState(false);
|
|
|
|
|
|
|
|
|
|
// Determine if custom path is being used based on current value
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
const currentBrowser = form.formData?.browser_executable;
|
|
|
|
|
if (currentBrowser) {
|
|
|
|
|
// Check if current value matches any known browser
|
|
|
|
|
const isKnownBrowser = browsers.some(b => b.path === currentBrowser || b.key === currentBrowser);
|
|
|
|
|
setUseCustomPath(!isKnownBrowser);
|
|
|
|
|
}
|
|
|
|
|
}, [form.formData?.browser_executable, browsers]);
|
|
|
|
|
|
|
|
|
|
if (!browsersAvailable) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build dropdown options: auto-detect + installed browsers + custom
|
|
|
|
|
const browserOptions = [
|
|
|
|
|
{key: 'auto', value: '', text: 'Auto-detect (recommended)'},
|
|
|
|
|
...browsers.map(b => ({key: b.key, value: b.path, text: `${b.name} (${b.path})`})),
|
|
|
|
|
{key: 'custom', value: '__custom__', text: 'Custom path...'},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const handleBrowserChange = (e, {value}) => {
|
|
|
|
|
if (value === '__custom__') {
|
|
|
|
|
setUseCustomPath(true);
|
|
|
|
|
form.setValue('browser_executable', '');
|
|
|
|
|
} else {
|
|
|
|
|
setUseCustomPath(false);
|
|
|
|
|
form.setValue('browser_executable', value || null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const currentValue = form.formData?.browser_executable || '';
|
|
|
|
|
const dropdownValue = useCustomPath ? '__custom__' : currentValue;
|
|
|
|
|
|
|
|
|
|
return <>
|
|
|
|
|
<Header as='h4'>Browser Settings</Header>
|
|
|
|
|
<p {...t}>
|
|
|
|
|
Configure which browser SingleFile uses to create archives.
|
|
|
|
|
These settings only apply to native deployments (Raspberry Pi/Debian).
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<Form.Field>
|
|
|
|
|
<label {...t}>Browser</label>
|
|
|
|
|
<Form.Dropdown
|
|
|
|
|
selection
|
|
|
|
|
options={browserOptions}
|
|
|
|
|
value={dropdownValue}
|
|
|
|
|
onChange={handleBrowserChange}
|
|
|
|
|
placeholder='Select browser...'
|
|
|
|
|
/>
|
|
|
|
|
</Form.Field>
|
|
|
|
|
|
|
|
|
|
{useCustomPath && (
|
|
|
|
|
<Form.Field>
|
|
|
|
|
<label {...t}>Custom Browser Path</label>
|
|
|
|
|
<Input
|
|
|
|
|
fluid
|
|
|
|
|
placeholder='/usr/bin/chromium'
|
|
|
|
|
value={form.formData?.browser_executable || ''}
|
|
|
|
|
onChange={(e) => form.setValue('browser_executable', e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
<small {...t}>Enter the absolute path to the browser executable.</small>
|
|
|
|
|
</Form.Field>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<Form.Field>
|
|
|
|
|
<label {...t}>Browser Arguments</label>
|
|
|
|
|
<Input
|
|
|
|
|
fluid
|
|
|
|
|
placeholder='["--no-sandbox"]'
|
|
|
|
|
value={form.formData?.browser_args || '["--no-sandbox"]'}
|
|
|
|
|
onChange={(e) => form.setValue('browser_args', e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
<small {...t}>JSON array of arguments passed to the browser. Default: ["--no-sandbox"]</small>
|
|
|
|
|
</Form.Field>
|
|
|
|
|
|
|
|
|
|
<Form.Field>
|
|
|
|
|
<label {...t}>User Agent</label>
|
|
|
|
|
<Input
|
|
|
|
|
fluid
|
|
|
|
|
placeholder='Leave empty to use system default'
|
|
|
|
|
value={form.formData?.user_agent || ''}
|
|
|
|
|
onChange={(e) => form.setValue('user_agent', e.target.value || null)}
|
|
|
|
|
/>
|
|
|
|
|
<small {...t}>Custom user agent string. Leave empty to use the system default.</small>
|
|
|
|
|
</Form.Field>
|
|
|
|
|
</>;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-26 12:44:16 -07:00
|
|
|
function ArchiveSettingsPage() {
|
2025-12-22 17:56:35 -07:00
|
|
|
useTitle('Archive Settings');
|
|
|
|
|
|
2025-01-26 12:44:16 -07:00
|
|
|
const {t} = React.useContext(ThemeContext);
|
2026-01-23 19:51:02 -07:00
|
|
|
const dockerized = useDockerized();
|
|
|
|
|
const [batchModalOpen, setBatchModalOpen] = useState(false);
|
|
|
|
|
const [domainsNeedingReorg, setDomainsNeedingReorg] = useState(0);
|
|
|
|
|
const [fetchingReorgCount, setFetchingReorgCount] = useState(true);
|
|
|
|
|
const [browsers, setBrowsers] = useState([]);
|
|
|
|
|
const [browsersAvailable, setBrowsersAvailable] = useState(false);
|
|
|
|
|
|
2026-01-31 12:54:27 -07:00
|
|
|
// Check if batch reorganization is currently active for domains
|
|
|
|
|
const {isReorganizing, taskType, collectionKind} = useReorganizationStatus();
|
|
|
|
|
const isBatchReorganizingDomains = isReorganizing && taskType === 'batch_reorganize' && collectionKind === 'domain';
|
|
|
|
|
|
|
|
|
|
// Check how many domains need reorganization on mount (skip if batch is in progress)
|
2026-01-23 19:51:02 -07:00
|
|
|
React.useEffect(() => {
|
2026-01-31 12:54:27 -07:00
|
|
|
if (isBatchReorganizingDomains) {
|
|
|
|
|
// Skip fetching preview while batch reorganization is in progress
|
|
|
|
|
setFetchingReorgCount(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-01-23 19:51:02 -07:00
|
|
|
setFetchingReorgCount(true);
|
|
|
|
|
previewBatchReorganization('domain')
|
|
|
|
|
.then(data => {
|
|
|
|
|
setDomainsNeedingReorg(data.total_collections || 0);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
setDomainsNeedingReorg(0);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setFetchingReorgCount(false);
|
|
|
|
|
});
|
2026-01-31 12:54:27 -07:00
|
|
|
}, [isBatchReorganizingDomains]);
|
2026-01-23 19:51:02 -07:00
|
|
|
|
|
|
|
|
// Fetch available browsers on mount (only if not dockerized)
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
if (dockerized === false) {
|
|
|
|
|
fetchArchiveBrowsers()
|
|
|
|
|
.then(data => {
|
|
|
|
|
setBrowsers(data.browsers || []);
|
|
|
|
|
setBrowsersAvailable(data.available === true);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
setBrowsers([]);
|
|
|
|
|
setBrowsersAvailable(false);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [dockerized]);
|
2023-04-09 14:13:36 -06:00
|
|
|
|
2025-12-22 17:56:35 -07:00
|
|
|
const emptyFormData = {
|
2025-12-23 19:11:07 -07:00
|
|
|
file_name_format: '%(download_datetime)s_%(title)s.%(ext)s',
|
2026-01-23 19:51:02 -07:00
|
|
|
browser_executable: null,
|
|
|
|
|
browser_args: '["--no-sandbox"]',
|
|
|
|
|
user_agent: null,
|
2025-12-22 17:56:35 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const configSubmitter = async () => {
|
|
|
|
|
return await updateArchiveDownloaderConfig(configForm.formData);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const configForm = useForm({
|
|
|
|
|
fetcher: fetchArchiveDownloaderConfig,
|
|
|
|
|
submitter: configSubmitter,
|
|
|
|
|
emptyFormData,
|
|
|
|
|
});
|
|
|
|
|
|
2025-01-26 12:44:16 -07:00
|
|
|
const urlClipboardButton = <APIButton
|
|
|
|
|
icon='copy'
|
|
|
|
|
onClick={() => navigator.clipboard.writeText(API_ARCHIVE_UPLOAD_URI)}
|
|
|
|
|
/>;
|
|
|
|
|
const dataFieldNameClipboardButton = <APIButton
|
|
|
|
|
icon='copy'
|
|
|
|
|
onClick={() => navigator.clipboard.writeText('singlefile_contents')}
|
|
|
|
|
/>;
|
|
|
|
|
const urlFieldNameClipboardButton = <APIButton
|
|
|
|
|
icon='copy'
|
|
|
|
|
onClick={() => navigator.clipboard.writeText('url')}
|
|
|
|
|
/>;
|
2023-09-07 20:13:36 -06:00
|
|
|
|
2025-01-26 12:44:16 -07:00
|
|
|
return <PageContainer>
|
2025-12-22 17:56:35 -07:00
|
|
|
<Segment>
|
|
|
|
|
<Header as='h3'>Archive Downloader Config</Header>
|
|
|
|
|
|
|
|
|
|
<Form>
|
|
|
|
|
<Grid>
|
|
|
|
|
<GridRow columns={1}>
|
|
|
|
|
<GridColumn mobile={16} computer={8}>
|
|
|
|
|
<ArchiveFileNameForm form={configForm}/>
|
|
|
|
|
</GridColumn>
|
|
|
|
|
</GridRow>
|
2026-01-23 19:51:02 -07:00
|
|
|
|
|
|
|
|
{/* Browser settings - only shown on native deployments */}
|
|
|
|
|
{!dockerized && browsersAvailable && (
|
|
|
|
|
<GridRow columns={1}>
|
|
|
|
|
<GridColumn mobile={16} computer={8}>
|
|
|
|
|
<BrowserConfigForm
|
|
|
|
|
form={configForm}
|
|
|
|
|
browsers={browsers}
|
|
|
|
|
browsersAvailable={browsersAvailable}
|
|
|
|
|
/>
|
|
|
|
|
</GridColumn>
|
|
|
|
|
</GridRow>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-12-22 17:56:35 -07:00
|
|
|
<GridRow columns={1}>
|
|
|
|
|
<GridColumn textAlign='right'>
|
|
|
|
|
<APIButton
|
|
|
|
|
disabled={configForm.disabled || !configForm.ready}
|
|
|
|
|
type='submit'
|
|
|
|
|
style={{marginTop: '0.5em'}}
|
|
|
|
|
onClick={configForm.onSubmit}
|
|
|
|
|
id='archive_settings_save_button'
|
|
|
|
|
>Save</APIButton>
|
|
|
|
|
</GridColumn>
|
|
|
|
|
</GridRow>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Form>
|
|
|
|
|
</Segment>
|
|
|
|
|
|
2026-01-23 19:51:02 -07:00
|
|
|
<Segment>
|
|
|
|
|
<Header as='h4'>File Organization</Header>
|
|
|
|
|
<p>
|
|
|
|
|
{fetchingReorgCount
|
|
|
|
|
? 'Checking for domains that need reorganization...'
|
|
|
|
|
: <>
|
|
|
|
|
<strong>{domainsNeedingReorg}</strong> domain{domainsNeedingReorg !== 1 ? 's' : ''}
|
|
|
|
|
{domainsNeedingReorg > 0
|
|
|
|
|
? ' have files that do not match the current file name format.'
|
|
|
|
|
: '. All domains are organized correctly.'}
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
</p>
|
|
|
|
|
<Button
|
|
|
|
|
color='orange'
|
|
|
|
|
onClick={() => setBatchModalOpen(true)}
|
|
|
|
|
id='reorganize_all_domains_button'
|
|
|
|
|
disabled={fetchingReorgCount || domainsNeedingReorg === 0}
|
|
|
|
|
loading={fetchingReorgCount}
|
|
|
|
|
>
|
|
|
|
|
<Icon name='folder open outline'/> Reorganize All Domains
|
|
|
|
|
</Button>
|
|
|
|
|
</Segment>
|
|
|
|
|
|
|
|
|
|
<BatchReorganizeModal
|
|
|
|
|
open={batchModalOpen}
|
|
|
|
|
onClose={() => setBatchModalOpen(false)}
|
|
|
|
|
kind='domain'
|
|
|
|
|
onComplete={() => {
|
|
|
|
|
setBatchModalOpen(false);
|
|
|
|
|
setDomainsNeedingReorg(0);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
2025-12-22 17:56:35 -07:00
|
|
|
<Segment>
|
|
|
|
|
<Header as='h3'>SingleFile Browser Extension</Header>
|
|
|
|
|
|
|
|
|
|
<p {...t}>
|
|
|
|
|
These are the settings necessary to configure the <a
|
2026-02-15 17:26:36 -07:00
|
|
|
href="https://github.com/gildas-lormeau/SingleFile?tab=readme-ov-file#install"
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
target='_blank'>SingleFile Browser
|
2025-12-22 17:56:35 -07:00
|
|
|
Extension</a> to automatically upload to your WROLPi.
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<label {...t}>Upload URL</label>
|
|
|
|
|
<Input fluid
|
|
|
|
|
value={API_ARCHIVE_UPLOAD_URI}
|
|
|
|
|
label={urlClipboardButton}
|
|
|
|
|
/>
|
|
|
|
|
<label {...t}>Data Field Name</label>
|
|
|
|
|
<Input fluid
|
|
|
|
|
value='singlefile_contents'
|
|
|
|
|
label={dataFieldNameClipboardButton}
|
|
|
|
|
/>
|
|
|
|
|
<label {...t}>URL Field Name</label>
|
|
|
|
|
<Input fluid
|
|
|
|
|
value='url'
|
|
|
|
|
label={urlFieldNameClipboardButton}
|
|
|
|
|
/>
|
|
|
|
|
</Segment>
|
2025-01-26 12:44:16 -07:00
|
|
|
</PageContainer>
|
2023-04-09 14:13:36 -06:00
|
|
|
}
|
|
|
|
|
|
2023-07-21 15:14:09 -06:00
|
|
|
function ArchivesPage() {
|
2022-09-23 16:22:57 -06:00
|
|
|
const [selectedArchives, setSelectedArchives] = useState([]);
|
2026-04-09 16:18:26 -06:00
|
|
|
const [bulkTagOpen, setBulkTagOpen] = useState(false);
|
2026-05-03 17:28:06 -06:00
|
|
|
const [taggedFileGroups, setTaggedFileGroups] = useState(null);
|
2026-02-23 17:29:09 -07:00
|
|
|
const searchInputRef = React.useRef();
|
|
|
|
|
|
|
|
|
|
useHotkeys('f', (e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (searchInputRef.current) {
|
|
|
|
|
searchInputRef.current.focus();
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false});
|
2022-09-23 16:22:57 -06:00
|
|
|
|
2025-12-17 17:27:17 -07:00
|
|
|
const {domain, domains} = useSearchDomain();
|
|
|
|
|
|
|
|
|
|
// Find the domain object from the domains list to get the ID for the edit link
|
|
|
|
|
const domainObj = domain && domains ? domains.find(d => d.domain === domain) : null;
|
|
|
|
|
|
|
|
|
|
let title = 'Archives';
|
|
|
|
|
if (domainObj && domainObj.domain) {
|
|
|
|
|
title = `${domainObj.domain} Archives`;
|
|
|
|
|
}
|
|
|
|
|
useTitle(title);
|
2022-01-15 18:05:51 -07:00
|
|
|
|
2022-09-23 16:22:57 -06:00
|
|
|
const {
|
|
|
|
|
archives,
|
|
|
|
|
totalPages,
|
|
|
|
|
activePage,
|
|
|
|
|
setPage,
|
|
|
|
|
searchStr,
|
|
|
|
|
setSearchStr,
|
2022-10-24 15:08:53 -06:00
|
|
|
fetchArchives,
|
2023-04-09 14:13:36 -06:00
|
|
|
} = useSearchArchives();
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2022-10-24 15:17:48 -06:00
|
|
|
let archiveOrders = [
|
2023-10-24 10:20:06 -06:00
|
|
|
{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'},
|
2023-04-09 14:13:36 -06:00
|
|
|
{value: 'size', text: 'Size'},
|
2023-10-24 10:20:06 -06:00
|
|
|
{value: 'viewed', text: 'Recently Viewed', short: 'R.Viewed'},
|
2022-08-06 05:22:07 +00:00
|
|
|
];
|
|
|
|
|
|
2022-10-24 15:17:48 -06:00
|
|
|
if (searchStr) {
|
2023-04-09 14:13:36 -06:00
|
|
|
archiveOrders = [{value: 'rank', text: 'Rank'}, ...archiveOrders];
|
2022-10-24 15:17:48 -06:00
|
|
|
}
|
|
|
|
|
|
2022-09-23 16:22:57 -06:00
|
|
|
const onSelect = (path, checked) => {
|
2022-10-24 17:15:15 -06:00
|
|
|
if (checked && path) {
|
|
|
|
|
setSelectedArchives([...selectedArchives, path]);
|
|
|
|
|
} else if (path) {
|
|
|
|
|
setSelectedArchives(selectedArchives.filter(i => i !== path));
|
2022-09-23 16:22:57 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-03 18:50:22 -06:00
|
|
|
const fileGroupIdsForSelection = () => archives
|
2026-05-03 17:28:06 -06:00
|
|
|
.filter(i => selectedArchives.indexOf(i['primary_path']) >= 0)
|
|
|
|
|
.map(i => i['id']);
|
|
|
|
|
|
|
|
|
|
const onDelete = async (force = false) => {
|
2026-05-03 18:50:22 -06:00
|
|
|
const fileGroupIds = fileGroupIdsForSelection();
|
|
|
|
|
const result = await deleteFileGroups(fileGroupIds, force);
|
2026-05-03 17:28:06 -06:00
|
|
|
if (result && result.tagged) {
|
|
|
|
|
setTaggedFileGroups(result.file_groups);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-09-23 16:22:57 -06:00
|
|
|
await fetchArchives();
|
|
|
|
|
setSelectedArchives([]);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 17:15:15 -06:00
|
|
|
const invertSelection = async () => {
|
|
|
|
|
const newSelectedArchives = archives.map(archive => archive['key']).filter(i => selectedArchives.indexOf(i) < 0);
|
|
|
|
|
setSelectedArchives(newSelectedArchives);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const clearSelection = async (e) => {
|
|
|
|
|
if (e) e.preventDefault();
|
|
|
|
|
setSelectedArchives([]);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-09 16:18:26 -06:00
|
|
|
const onBulkTagComplete = async () => {
|
|
|
|
|
await fetchArchives();
|
|
|
|
|
setSelectedArchives([]);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 16:22:57 -06:00
|
|
|
const selectElm = <div style={{marginTop: '0.5em'}}>
|
2026-04-09 16:18:26 -06:00
|
|
|
<Button
|
|
|
|
|
color='violet'
|
|
|
|
|
disabled={_.isEmpty(selectedArchives)}
|
|
|
|
|
onClick={() => setBulkTagOpen(true)}
|
|
|
|
|
>Tag</Button>
|
2023-07-27 15:53:47 -06:00
|
|
|
<APIButton
|
2022-09-23 16:22:57 -06:00
|
|
|
color='red'
|
2023-01-04 09:14:33 -07:00
|
|
|
disabled={_.isEmpty(selectedArchives)}
|
2022-09-23 16:22:57 -06:00
|
|
|
confirmButton='Delete'
|
2023-07-27 15:53:47 -06:00
|
|
|
confirmContent='Are you sure you want to delete these archives files? This cannot be undone.'
|
2026-05-03 17:28:06 -06:00
|
|
|
onClick={() => onDelete(false)}
|
2023-07-27 15:53:47 -06:00
|
|
|
>Delete</APIButton>
|
2022-10-24 17:15:15 -06:00
|
|
|
<Button
|
|
|
|
|
color='grey'
|
2023-01-04 11:16:40 -07:00
|
|
|
onClick={invertSelection}
|
2023-01-04 09:14:33 -07:00
|
|
|
disabled={_.isEmpty(archives)}
|
2022-10-24 17:15:15 -06:00
|
|
|
>
|
|
|
|
|
Invert
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
color='yellow'
|
2023-01-04 11:16:40 -07:00
|
|
|
onClick={clearSelection}
|
2023-01-04 09:14:33 -07:00
|
|
|
disabled={_.isEmpty(archives) || _.isEmpty(selectedArchives)}
|
2022-10-24 17:15:15 -06:00
|
|
|
>
|
|
|
|
|
Clear
|
|
|
|
|
</Button>
|
2026-04-09 16:18:26 -06:00
|
|
|
<BulkTagModal
|
|
|
|
|
open={bulkTagOpen}
|
|
|
|
|
onClose={() => setBulkTagOpen(false)}
|
|
|
|
|
paths={selectedArchives}
|
|
|
|
|
onComplete={onBulkTagComplete}
|
|
|
|
|
/>
|
2022-09-23 16:22:57 -06:00
|
|
|
</div>;
|
|
|
|
|
|
2026-04-09 16:18:26 -06:00
|
|
|
const {body, paginator, viewButton, limitDropdown, tagQuerySelector} = FilesView(
|
2024-07-22 16:36:57 -06:00
|
|
|
{
|
|
|
|
|
files: archives,
|
|
|
|
|
activePage: activePage,
|
|
|
|
|
totalPages: totalPages,
|
|
|
|
|
selectElem: selectElm,
|
|
|
|
|
selectedKeys: selectedArchives,
|
|
|
|
|
onSelect: onSelect,
|
|
|
|
|
setPage: setPage,
|
|
|
|
|
headlines: !!searchStr
|
|
|
|
|
},
|
2023-04-09 14:13:36 -06:00
|
|
|
);
|
|
|
|
|
|
2024-02-19 15:08:04 -07:00
|
|
|
|
|
|
|
|
const [localSearchStr, setLocalSearchStr] = React.useState(searchStr || '');
|
2023-11-22 12:19:49 -07:00
|
|
|
const searchInput = <SearchInput
|
2024-02-19 15:08:04 -07:00
|
|
|
onChange={setLocalSearchStr}
|
2024-05-08 17:44:44 -06:00
|
|
|
onClear={() => setLocalSearchStr(null)}
|
2024-02-19 15:08:04 -07:00
|
|
|
searchStr={localSearchStr}
|
2023-11-22 12:19:49 -07:00
|
|
|
onSubmit={setSearchStr}
|
|
|
|
|
placeholder='Search Archives...'
|
2026-02-23 17:29:09 -07:00
|
|
|
inputRef={searchInputRef}
|
2023-04-09 14:13:36 -06:00
|
|
|
/>;
|
|
|
|
|
|
2025-12-17 17:27:17 -07:00
|
|
|
// Domain header with edit link when filtering by domain
|
|
|
|
|
let header;
|
|
|
|
|
if (domainObj && domainObj.domain) {
|
2026-03-20 15:38:32 -06:00
|
|
|
const editLink = `/archives/domain/${domainObj.id}/edit`;
|
2025-12-17 17:27:17 -07:00
|
|
|
header = <>
|
|
|
|
|
<Header as='h1'>
|
|
|
|
|
{domainObj.domain}
|
|
|
|
|
<Link to={editLink}>
|
|
|
|
|
<Icon name='edit' style={{marginLeft: '0.5em'}}/>
|
|
|
|
|
</Link>
|
|
|
|
|
</Header>
|
|
|
|
|
</>;
|
|
|
|
|
} else if (domain) {
|
|
|
|
|
// Domain filter is set but domain object not loaded yet
|
|
|
|
|
header = <Placeholder style={{marginBottom: '1em'}}>
|
|
|
|
|
<PlaceholderHeader>
|
|
|
|
|
<PlaceholderLine/>
|
|
|
|
|
</PlaceholderHeader>
|
|
|
|
|
</Placeholder>;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-09 14:13:36 -06:00
|
|
|
return <>
|
2025-12-17 17:27:17 -07:00
|
|
|
{header}
|
2023-04-09 14:13:36 -06:00
|
|
|
<Media at='mobile'>
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.Row>
|
|
|
|
|
<Grid.Column width={2}>{viewButton}</Grid.Column>
|
|
|
|
|
<Grid.Column width={4}>{limitDropdown}</Grid.Column>
|
|
|
|
|
<Grid.Column width={2}>{tagQuerySelector}</Grid.Column>
|
2026-04-09 16:18:26 -06:00
|
|
|
<Grid.Column width={8}><SortButton sorts={archiveOrders}/></Grid.Column>
|
2023-04-09 14:13:36 -06:00
|
|
|
</Grid.Row>
|
2023-11-21 13:13:29 -07:00
|
|
|
<Grid.Row width={16}>
|
|
|
|
|
<Grid.Column>{searchInput}</Grid.Column>
|
2023-04-09 14:13:36 -06:00
|
|
|
</Grid.Row>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Media>
|
|
|
|
|
<Media greaterThanOrEqual='tablet'>
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.Row>
|
|
|
|
|
<Grid.Column width={1}>{viewButton}</Grid.Column>
|
|
|
|
|
<Grid.Column width={2}>{limitDropdown}</Grid.Column>
|
|
|
|
|
<Grid.Column width={1}>{tagQuerySelector}</Grid.Column>
|
2023-11-21 13:13:29 -07:00
|
|
|
<Grid.Column width={3}><SortButton sorts={archiveOrders}/></Grid.Column>
|
2026-04-09 16:18:26 -06:00
|
|
|
<Grid.Column width={9}>{searchInput}</Grid.Column>
|
2023-04-09 14:13:36 -06:00
|
|
|
</Grid.Row>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Media>
|
|
|
|
|
{body}
|
|
|
|
|
{paginator}
|
2026-05-03 17:28:06 -06:00
|
|
|
<TaggedDeleteConfirmModal
|
|
|
|
|
open={taggedFileGroups !== null}
|
|
|
|
|
taggedFileGroups={taggedFileGroups}
|
|
|
|
|
onCancel={() => setTaggedFileGroups(null)}
|
|
|
|
|
onConfirm={async () => {
|
|
|
|
|
setTaggedFileGroups(null);
|
|
|
|
|
await onDelete(true);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-04-09 14:13:36 -06:00
|
|
|
</>
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
2022-01-03 15:13:02 -07:00
|
|
|
|
2022-11-04 09:58:38 -06:00
|
|
|
export function ArchiveRowCells({file}) {
|
2023-03-24 08:58:18 -06:00
|
|
|
const {data} = file;
|
2023-11-02 16:56:05 -06:00
|
|
|
let {sort} = useSearchOrder();
|
|
|
|
|
sort = sort ? sort.replace(/^-+/, '') : null;
|
2022-11-04 09:58:38 -06:00
|
|
|
|
2026-03-20 15:38:32 -06:00
|
|
|
const archiveUrl = `/archives/${file.id}`;
|
2023-03-29 13:46:39 -06:00
|
|
|
const posterPath = findPosterPath(file);
|
|
|
|
|
const posterUrl = posterPath ? `/media/${encodeMediaPath(posterPath)}` : null;
|
2022-11-04 09:58:38 -06:00
|
|
|
|
|
|
|
|
let poster;
|
|
|
|
|
if (posterUrl) {
|
|
|
|
|
poster = <CardLink to={archiveUrl}>
|
|
|
|
|
<Image wrapped src={posterUrl} width='50px'/>
|
|
|
|
|
</CardLink>;
|
|
|
|
|
} else {
|
|
|
|
|
poster = <FileIcon file={file} size='large'/>;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 15:14:02 -06:00
|
|
|
let dataCell = file.published_datetime ? isoDatetimeToAgoPopup(file.published_datetime) : '';
|
2023-11-02 16:56:05 -06:00
|
|
|
if (sort === 'published_modified_datetime') {
|
2024-11-02 15:14:02 -06:00
|
|
|
dataCell = file.published_modified_datetime ? isoDatetimeToAgoPopup(file.published_modified_datetime) : '';
|
2023-11-02 16:56:05 -06:00
|
|
|
} else if (sort === 'download_datetime') {
|
2024-11-02 15:14:02 -06:00
|
|
|
dataCell = file.download_datetime ? isoDatetimeToAgoPopup(file.download_datetime) : '';
|
2023-11-02 16:56:05 -06:00
|
|
|
} else if (sort === 'size') {
|
|
|
|
|
dataCell = humanFileSize(file.size);
|
|
|
|
|
} else if (sort === 'viewed') {
|
2024-11-02 15:14:02 -06:00
|
|
|
dataCell = isoDatetimeToAgoPopup(file.viewed);
|
2023-11-02 16:56:05 -06:00
|
|
|
}
|
|
|
|
|
|
2022-11-04 09:58:38 -06:00
|
|
|
// Fragment for SelectableRow
|
2023-02-17 16:09:24 -07:00
|
|
|
return <React.Fragment>
|
2022-11-04 09:58:38 -06:00
|
|
|
<TableCell>
|
|
|
|
|
<center>{poster}</center>
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell>
|
|
|
|
|
<CardLink to={archiveUrl}>
|
2023-03-24 08:58:18 -06:00
|
|
|
<FileRowTagIcon file={file}/>
|
|
|
|
|
{textEllipsis(file.title || file.stem)}
|
2022-11-04 09:58:38 -06:00
|
|
|
</CardLink>
|
|
|
|
|
</TableCell>
|
2023-11-02 16:56:05 -06:00
|
|
|
<TableCell>{dataCell}</TableCell>
|
2023-02-17 16:09:24 -07:00
|
|
|
</React.Fragment>
|
2022-11-04 09:58:38 -06:00
|
|
|
}
|
|
|
|
|
|
2026-02-02 15:15:28 -07:00
|
|
|
function ArchiveStatistics() {
|
|
|
|
|
useTitle('Archive Statistics');
|
|
|
|
|
|
|
|
|
|
const {statistics} = useArchiveStatistics();
|
|
|
|
|
|
|
|
|
|
if (statistics === null) {
|
|
|
|
|
// Request is pending.
|
|
|
|
|
return <Loader active inline='centered'/>
|
|
|
|
|
} else if (statistics === undefined) {
|
|
|
|
|
return <ErrorMessage>Unable to fetch Archive Statistics</ErrorMessage>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {archives, historical, domains} = statistics;
|
|
|
|
|
|
|
|
|
|
const archiveNames = [
|
|
|
|
|
{key: 'archives', label: 'Archives'},
|
|
|
|
|
{key: 'sum_size', label: 'Total Size'},
|
|
|
|
|
{key: 'max_size', label: 'Largest Archive'},
|
|
|
|
|
{key: 'week', label: 'Downloads Past Week'},
|
|
|
|
|
{key: 'month', label: 'Downloads Past Month'},
|
|
|
|
|
{key: 'year', label: 'Downloads Past Year'},
|
|
|
|
|
];
|
|
|
|
|
const historicalNames = [
|
|
|
|
|
{key: 'average_count', label: 'Average Monthly Downloads'},
|
|
|
|
|
{key: 'average_size', label: 'Average Monthly Usage'},
|
|
|
|
|
];
|
|
|
|
|
const domainNames = [
|
|
|
|
|
{key: 'domains', label: 'Domains'},
|
|
|
|
|
{key: 'tagged_domains', label: 'Tagged Domains'},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const buildSegment = (title, names, stats) => {
|
|
|
|
|
return <Segment>
|
|
|
|
|
<Header textAlign='center' as='h1'>{title}</Header>
|
|
|
|
|
<Statistic.Group>
|
|
|
|
|
{names.map(
|
|
|
|
|
({key, label}) =>
|
|
|
|
|
<Statistic key={key} style={{margin: '2em'}}>
|
|
|
|
|
<StatisticValue>{stats[key]}</StatisticValue>
|
|
|
|
|
<StatisticLabel>{label}</StatisticLabel>
|
|
|
|
|
</Statistic>
|
|
|
|
|
)}
|
|
|
|
|
</Statistic.Group>
|
|
|
|
|
</Segment>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <>
|
|
|
|
|
{buildSegment('Archives', archiveNames, archives)}
|
|
|
|
|
{buildSegment('Historical Archives', historicalNames, historical)}
|
|
|
|
|
{buildSegment('Domains', domainNames, domains)}
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
export function ArchiveRoute() {
|
2025-10-29 22:16:33 -06:00
|
|
|
const location = useLocation();
|
|
|
|
|
const path = location.pathname;
|
|
|
|
|
|
2022-01-29 22:25:35 -07:00
|
|
|
const links = [
|
2025-10-29 22:16:33 -06:00
|
|
|
{
|
|
|
|
|
text: 'Archives',
|
2026-03-20 15:38:32 -06:00
|
|
|
to: '/archives',
|
2025-10-29 22:16:33 -06:00
|
|
|
end: true,
|
2026-03-20 15:38:32 -06:00
|
|
|
isActive: () => path === '/archives' || /^\/archives\/\d+$/.test(path)
|
2025-10-29 22:16:33 -06:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: 'Domains',
|
2026-03-20 15:38:32 -06:00
|
|
|
to: '/archives/domains',
|
|
|
|
|
isActive: () => path.startsWith('/archives/domain')
|
2025-10-29 22:16:33 -06:00
|
|
|
},
|
2026-03-20 15:38:32 -06:00
|
|
|
{text: 'Settings', to: '/archives/settings'},
|
|
|
|
|
{text: 'Statistics', to: '/archives/statistics'},
|
2022-01-29 21:24:39 -07:00
|
|
|
];
|
2022-01-31 09:32:06 -07:00
|
|
|
return <PageContainer>
|
2022-01-29 22:25:35 -07:00
|
|
|
<TabLinks links={links}/>
|
2022-08-06 05:22:07 +00:00
|
|
|
<Routes>
|
2023-07-21 15:14:09 -06:00
|
|
|
<Route path='/' element={<ArchivesPage/>}/>
|
2023-04-09 14:13:36 -06:00
|
|
|
<Route path='domains' element={<DomainsPage/>}/>
|
2025-10-29 22:16:33 -06:00
|
|
|
<Route path='domain/:domainId/edit' element={<DomainEditPage/>}/>
|
2025-01-26 12:44:16 -07:00
|
|
|
<Route path='settings' element={<ArchiveSettingsPage/>}/>
|
2026-02-02 15:15:28 -07:00
|
|
|
<Route path='statistics' element={<ArchiveStatistics/>}/>
|
2026-03-20 15:38:32 -06:00
|
|
|
<Route path=':fileGroupId' element={<ArchivePage/>}/>
|
2022-08-06 05:22:07 +00:00
|
|
|
</Routes>
|
2022-01-31 09:32:06 -07:00
|
|
|
</PageContainer>
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|