import React, {useState} from "react"; import {Card, Confirm, Container, Header, Image, Loader, Placeholder, Segment} from "semantic-ui-react"; import { CardGroupCentered, ClearButton, HelpHeader, PageContainer, Paginator, SearchInput, TabLinks, textEllipsis, uploadDate, WROLModeMessage } from "./Common"; import {deleteArchive, postDownload, refreshArchives} from "../api"; import Button from "semantic-ui-react/dist/commonjs/elements/Button"; import {Link, Route, Switch, useHistory} from "react-router-dom"; import {ArchivePlaceholder} from "./Placeholder"; import Table from "semantic-ui-react/dist/commonjs/collections/Table"; import Message from "semantic-ui-react/dist/commonjs/collections/Message"; import {useArchive, useArchives, useDomains} from "../hooks/customHooks"; function ArchivePage(props) { const [deleteOpen, setDeleteOpen] = useState(false); const [syncOpen, setSyncOpen] = useState(false); const history = useHistory(); const archiveId = props.match.params.archive_id; const [archive, alternatives] = useArchive(archiveId); if (archive === null) { return ; } if (archive === undefined) { return <> Unknown archive This archive does not exist > } 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 ? `/media/${encodeURIComponent(archive.readability_path)}` : null; const singlefileButton = ; const readabilityLink = readabilityUrl ? : ; const screenshot = screenshotUrl ? : null; const localDeleteArchive = async () => { setDeleteOpen(false); await deleteArchive(archive.id); } const localSyncArchive = async () => { setSyncOpen(false); await postDownload(archive.url, 'archive'); } const syncButton = (<> setSyncOpen(true)} content='Sync'/> setSyncOpen(false)} onConfirm={localSyncArchive} /> >); const deleteButton = (<> setDeleteOpen(true)} content='Delete' aria-label='Delete'/> setDeleteOpen(false)} onConfirm={localDeleteArchive} /> >); let alternativesList = ; if (alternatives && alternatives.length > 0) { alternativesList = ; } else if (alternatives && alternatives.length === 0) { alternativesList = No alternatives available; } return ( <> history.goBack()}/> {screenshot} {textEllipsis(archive.title || archive.url, 100)} {uploadDate(archive.archive_datetime)} {textEllipsis(archive.url, 100)} {singlefileButton} {readabilityLink} {syncButton} {deleteButton} {alternativesList} > ) } function ArchiveCard({archive, setDomain}) { const imageSrc = archive.screenshot_path ? `/media/${encodeURIComponent(archive.screenshot_path)}` : null; const singlefileUrl = archive.singlefile_path ? `/media/${encodeURIComponent(archive.singlefile_path)}` : null; const domain = archive.domain.domain; return ( {textEllipsis(archive.title || archive.url, 100)} {setDomain && setDomain(domain)} className="no-link-underscore card-link"> {textEllipsis(domain, 40)} } {uploadDate(archive.archive_datetime)} ) } function ArchiveCards({archives, setDomain}) { return ( {archives.map((i) => { return })} ) } export function ArchivesList({archives, searchStr, setDomain}) { if (archives === null || archives === undefined) { // Fetching archives. return ; } else if (archives.length === 0 && searchStr) { // Search with no results. return No archives found! Is your search too restrictive?; } else if (archives.length === 0) { // No archives fetched. return No archives Have you archived any webpages? ; } else { // Archives fetched successfully! return ; } } export function Archives() { const {archives, setPage, totalPages, searchStr, activePage, setSearchStr, domain, setDomain, search} = useArchives(20); let domainClearButton = null; if (domain) { domainClearButton = setDomain(null)} style={{marginBottom: '1em'}} label={`Domain: ${domain}`} />; } return ( <> {domainClearButton} > ) } class ManageArchives extends React.Component { async refresh() { await refreshArchives(); } render() { return (<> Refresh Archive Files Find any new archive files. Remove Archives which no longer have files. >) } } function Domains() { const [domains] = useDomains(); const row = (domain) => { return {domain['domain']} {domain['url_count']} } if (domains && domains.length > 0) { return ( <> Domain Archives {domains.map(row)} > ) } if (domains === null) { return (<> >) } return (<> No domains yet. Archive some webpages! >) } export function ArchiveRoute(props) { const links = [ {text: 'Archives', to: '/archive', exact: true, key: 'archive'}, {text: 'Domains', to: '/archive/domains', key: 'domains'}, {text: 'Manage', to: '/archive/manage', key: 'manage'}, ]; return }
No alternatives available
{textEllipsis(archive.url, 100)}
{textEllipsis(archive.title || archive.url, 100)}
{uploadDate(archive.archive_datetime)}
No archives found! Is your search too restrictive?