update link action icons
This commit is contained in:
parent
d906391ae2
commit
e910172558
|
@ -4,8 +4,6 @@ import {
|
||||||
LinkIncludingShortenedCollectionAndTags,
|
LinkIncludingShortenedCollectionAndTags,
|
||||||
} from "@/types/global";
|
} from "@/types/global";
|
||||||
import usePermissions from "@/hooks/usePermissions";
|
import usePermissions from "@/hooks/usePermissions";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { faEllipsis } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import EditLinkModal from "@/components/ModalContent/EditLinkModal";
|
import EditLinkModal from "@/components/ModalContent/EditLinkModal";
|
||||||
import DeleteLinkModal from "@/components/ModalContent/DeleteLinkModal";
|
import DeleteLinkModal from "@/components/ModalContent/DeleteLinkModal";
|
||||||
import PreservedFormatsModal from "@/components/ModalContent/PreservedFormatsModal";
|
import PreservedFormatsModal from "@/components/ModalContent/PreservedFormatsModal";
|
||||||
|
@ -13,15 +11,13 @@ import useLinkStore from "@/store/links";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import useAccountStore from "@/store/account";
|
import useAccountStore from "@/store/account";
|
||||||
|
|
||||||
export default function LinkActions({
|
type Props = {
|
||||||
link,
|
|
||||||
collection,
|
|
||||||
position,
|
|
||||||
}: {
|
|
||||||
link: LinkIncludingShortenedCollectionAndTags;
|
link: LinkIncludingShortenedCollectionAndTags;
|
||||||
collection: CollectionIncludingMembersAndLinkCount;
|
collection: CollectionIncludingMembersAndLinkCount;
|
||||||
position?: string;
|
position?: string;
|
||||||
}) {
|
}
|
||||||
|
|
||||||
|
export default function LinkActions({ link, collection, position }: Props) {
|
||||||
const permissions = usePermissions(link.collection.id as number);
|
const permissions = usePermissions(link.collection.id as number);
|
||||||
|
|
||||||
const [editLinkModal, setEditLinkModal] = useState(false);
|
const [editLinkModal, setEditLinkModal] = useState(false);
|
||||||
|
@ -46,7 +42,7 @@ export default function LinkActions({
|
||||||
toast.dismiss(load);
|
toast.dismiss(load);
|
||||||
|
|
||||||
response.ok &&
|
response.ok &&
|
||||||
toast.success(`Link ${isAlreadyPinned ? "Unpinned!" : "Pinned!"}`);
|
toast.success(`Link ${isAlreadyPinned ? "Unpinned!" : "Pinned!"}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteLink = async () => {
|
const deleteLink = async () => {
|
||||||
|
@ -74,14 +70,10 @@ export default function LinkActions({
|
||||||
role="button"
|
role="button"
|
||||||
className="btn btn-ghost btn-sm btn-square text-neutral"
|
className="btn btn-ghost btn-sm btn-square text-neutral"
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon
|
<i id={"expand-dropdown" + collection.id} title="More" className="bi-three-dots text-xl"/>
|
||||||
icon={faEllipsis}
|
|
||||||
title="More"
|
|
||||||
className="w-5 h-5"
|
|
||||||
id={"expand-dropdown" + collection.id}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<ul className="dropdown-content z-[20] menu shadow bg-base-200 border border-neutral-content rounded-box w-44 mr-1">
|
<ul
|
||||||
|
className="dropdown-content z-[20] menu shadow bg-base-200 border border-neutral-content rounded-box w-44 mr-1">
|
||||||
{permissions === true ? (
|
{permissions === true ? (
|
||||||
<li>
|
<li>
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Toaster } from "react-hot-toast";
|
|
||||||
import CollectionSelection from "@/components/InputSelect/CollectionSelection";
|
|
||||||
import TagSelection from "@/components/InputSelect/TagSelection";
|
|
||||||
import TextInput from "@/components/TextInput";
|
|
||||||
import unescapeString from "@/lib/client/unescapeString";
|
|
||||||
import useLinkStore from "@/store/links";
|
import useLinkStore from "@/store/links";
|
||||||
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
|
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import Link from "next/link";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { faLink, faTrashCan } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import Modal from "../Modal";
|
import Modal from "../Modal";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
|
@ -57,19 +49,7 @@ export default function DeleteLinkModal({ onClose, activeLink }: Props) {
|
||||||
<p>Are you sure you want to delete this Link?</p>
|
<p>Are you sure you want to delete this Link?</p>
|
||||||
|
|
||||||
<div role="alert" className="alert alert-warning">
|
<div role="alert" className="alert alert-warning">
|
||||||
<svg
|
<i className="bi-exclamation-triangle text-xl"/>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
className="stroke-current shrink-0 h-6 w-6"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth="2"
|
|
||||||
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
<span>
|
<span>
|
||||||
<b>Warning:</b> This action is irreversible!
|
<b>Warning:</b> This action is irreversible!
|
||||||
</span>
|
</span>
|
||||||
|
@ -84,7 +64,7 @@ export default function DeleteLinkModal({ onClose, activeLink }: Props) {
|
||||||
className={`ml-auto btn w-fit text-white flex items-center gap-2 duration-100 bg-red-500 hover:bg-red-400 hover:dark:bg-red-600 cursor-pointer`}
|
className={`ml-auto btn w-fit text-white flex items-center gap-2 duration-100 bg-red-500 hover:bg-red-400 hover:dark:bg-red-600 cursor-pointer`}
|
||||||
onClick={deleteLink}
|
onClick={deleteLink}
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon icon={faTrashCan} className="h-5" />
|
<i className="bi-trash text-xl"/>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Toaster } from "react-hot-toast";
|
|
||||||
import CollectionSelection from "@/components/InputSelect/CollectionSelection";
|
import CollectionSelection from "@/components/InputSelect/CollectionSelection";
|
||||||
import TagSelection from "@/components/InputSelect/TagSelection";
|
import TagSelection from "@/components/InputSelect/TagSelection";
|
||||||
import TextInput from "@/components/TextInput";
|
import TextInput from "@/components/TextInput";
|
||||||
|
@ -8,8 +7,6 @@ import useLinkStore from "@/store/links";
|
||||||
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
|
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { faLink } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import Modal from "../Modal";
|
import Modal from "../Modal";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -89,10 +86,7 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
|
||||||
title={link.url}
|
title={link.url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
<FontAwesomeIcon
|
<i className="bi-link-45deg text-xl"/>
|
||||||
icon={faLink}
|
|
||||||
className="mt-1 w-5 h-5 min-w-[1.25rem]"
|
|
||||||
/>
|
|
||||||
<p>{shortendURL}</p>
|
<p>{shortendURL}</p>
|
||||||
</Link>
|
</Link>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
|
@ -122,13 +116,13 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
|
||||||
defaultValue={
|
defaultValue={
|
||||||
link.collection.id
|
link.collection.id
|
||||||
? {
|
? {
|
||||||
value: link.collection.id,
|
value: link.collection.id,
|
||||||
label: link.collection.name,
|
label: link.collection.name,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
value: null as unknown as number,
|
value: null as unknown as number,
|
||||||
label: "Unorganized",
|
label: "Unorganized",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
|
@ -1,32 +1,13 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import useLinkStore from "@/store/links";
|
import useLinkStore from "@/store/links";
|
||||||
import {
|
import { ArchivedFormat, LinkIncludingShortenedCollectionAndTags, } from "@/types/global";
|
||||||
ArchivedFormat,
|
|
||||||
LinkIncludingShortenedCollectionAndTags,
|
|
||||||
} from "@/types/global";
|
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import {
|
|
||||||
faArrowUpRightFromSquare,
|
|
||||||
faCloudArrowDown,
|
|
||||||
faLink,
|
|
||||||
faTrashCan,
|
|
||||||
faUpRightFromSquare,
|
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import Modal from "../Modal";
|
import Modal from "../Modal";
|
||||||
import {
|
|
||||||
faFileImage,
|
|
||||||
faFileLines,
|
|
||||||
faFilePdf,
|
|
||||||
} from "@fortawesome/free-regular-svg-icons";
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import {
|
import { pdfAvailable, readabilityAvailable, screenshotAvailable, } from "@/lib/shared/getArchiveValidity";
|
||||||
pdfAvailable,
|
import PreservedFormatRow from "@/components/PreserverdFormatRow";
|
||||||
readabilityAvailable,
|
|
||||||
screenshotAvailable,
|
|
||||||
} from "@/lib/shared/getArchiveValidity";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onClose: Function;
|
onClose: Function;
|
||||||
|
@ -92,25 +73,6 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
|
||||||
} else toast.error(data.response);
|
} else toast.error(data.response);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDownload = (format: ArchivedFormat) => {
|
|
||||||
const path = `/api/v1/archives/${link?.id}?format=${format}`;
|
|
||||||
fetch(path)
|
|
||||||
.then((response) => {
|
|
||||||
if (response.ok) {
|
|
||||||
// Create a temporary link and click it to trigger the download
|
|
||||||
const link = document.createElement("a");
|
|
||||||
link.href = path;
|
|
||||||
link.download = format === ArchivedFormat.png ? "Screenshot" : "PDF";
|
|
||||||
link.click();
|
|
||||||
} else {
|
|
||||||
console.error("Failed to download file");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error("Error:", error);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal toggleModal={onClose}>
|
<Modal toggleModal={onClose}>
|
||||||
<p className="text-xl font-thin">Preserved Formats</p>
|
<p className="text-xl font-thin">Preserved Formats</p>
|
||||||
|
@ -129,112 +91,18 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
|
||||||
|
|
||||||
<div className={`flex flex-col gap-3`}>
|
<div className={`flex flex-col gap-3`}>
|
||||||
{readabilityAvailable(link) ? (
|
{readabilityAvailable(link) ? (
|
||||||
<div className="flex justify-between items-center pr-1 border border-neutral-content rounded-md">
|
<PreservedFormatRow name={'Readable'} icon={'bi-file-earmark-text'} format={ArchivedFormat.readability}
|
||||||
<div className="flex gap-2 items-center">
|
activeLink={link}/>
|
||||||
<div className="bg-primary text-primary-content p-2 rounded-l-md">
|
|
||||||
<FontAwesomeIcon icon={faFileLines} className="w-6 h-6" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>Readable</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex gap-1">
|
|
||||||
{/* <div
|
|
||||||
onClick={() => handleDownload(ArchivedFormat.pdf)}
|
|
||||||
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faCloudArrowDown}
|
|
||||||
className="w-5 h-5 cursor-pointer text-neutral"
|
|
||||||
/>
|
|
||||||
</div> */}
|
|
||||||
|
|
||||||
<Link
|
|
||||||
href={`/preserved/${link?.id}?format=${ArchivedFormat.readability}`}
|
|
||||||
target="_blank"
|
|
||||||
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faArrowUpRightFromSquare}
|
|
||||||
className="w-5 h-5 text-neutral"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : undefined}
|
) : undefined}
|
||||||
|
|
||||||
{screenshotAvailable(link) ? (
|
{screenshotAvailable(link) ? (
|
||||||
<div className="flex justify-between items-center pr-1 border border-neutral-content rounded-md">
|
<PreservedFormatRow name={'Screenshot'} icon={'bi-file-earmark-image'} format={ArchivedFormat.png}
|
||||||
<div className="flex gap-2 items-center">
|
activeLink={link} downloadable={true}/>
|
||||||
<div className="bg-primary text-primary-content p-2 rounded-l-md">
|
|
||||||
<FontAwesomeIcon icon={faFileImage} className="w-6 h-6" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>Screenshot</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex gap-1">
|
|
||||||
<div
|
|
||||||
onClick={() => handleDownload(ArchivedFormat.png)}
|
|
||||||
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faCloudArrowDown}
|
|
||||||
className="w-5 h-5 cursor-pointer text-neutral"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Link
|
|
||||||
href={`/api/v1/archives/${link?.id}?format=${
|
|
||||||
link.screenshotPath?.endsWith("png")
|
|
||||||
? ArchivedFormat.png
|
|
||||||
: ArchivedFormat.jpeg
|
|
||||||
}`}
|
|
||||||
target="_blank"
|
|
||||||
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faUpRightFromSquare}
|
|
||||||
className="w-5 h-5 text-neutral"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : undefined}
|
) : undefined}
|
||||||
|
|
||||||
{pdfAvailable(link) ? (
|
{pdfAvailable(link) ? (
|
||||||
<div className="flex justify-between items-center pr-1 border border-neutral-content rounded-md">
|
<PreservedFormatRow name={'PDF'} icon={'bi-file-earmark-pdf'} format={ArchivedFormat.pdf}
|
||||||
<div className="flex gap-2 items-center">
|
activeLink={link} downloadable={true}/>
|
||||||
<div className="bg-primary text-primary-content p-2 rounded-l-md">
|
|
||||||
<FontAwesomeIcon icon={faFilePdf} className="w-6 h-6" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>PDF</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex gap-1">
|
|
||||||
<div
|
|
||||||
onClick={() => handleDownload(ArchivedFormat.pdf)}
|
|
||||||
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faCloudArrowDown}
|
|
||||||
className="w-5 h-5 cursor-pointer text-neutral"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Link
|
|
||||||
href={`/api/v1/archives/${link?.id}?format=${ArchivedFormat.pdf}`}
|
|
||||||
target="_blank"
|
|
||||||
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon={faArrowUpRightFromSquare}
|
|
||||||
className="w-5 h-5 text-neutral"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : undefined}
|
) : undefined}
|
||||||
|
|
||||||
<div className="flex flex-col-reverse sm:flex-row sm:gap-3 items-center justify-center">
|
<div className="flex flex-col-reverse sm:flex-row sm:gap-3 items-center justify-center">
|
||||||
|
@ -272,10 +140,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
|
||||||
<p className="whitespace-nowrap">
|
<p className="whitespace-nowrap">
|
||||||
View latest snapshot on archive.org
|
View latest snapshot on archive.org
|
||||||
</p>
|
</p>
|
||||||
<FontAwesomeIcon
|
<i className="bi-box-arrow-up-right"/>
|
||||||
icon={faArrowUpRightFromSquare}
|
|
||||||
className="w-4 h-4"
|
|
||||||
/>
|
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import useLinkStore from "@/store/links";
|
||||||
|
import {
|
||||||
|
ArchivedFormat,
|
||||||
|
LinkIncludingShortenedCollectionAndTags,
|
||||||
|
} from "@/types/global";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
name: string,
|
||||||
|
icon: string,
|
||||||
|
format: ArchivedFormat,
|
||||||
|
activeLink: LinkIncludingShortenedCollectionAndTags,
|
||||||
|
downloadable?: boolean,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function PreservedFormatRow({ name, icon, format, activeLink, downloadable }: Props) {
|
||||||
|
const session = useSession();
|
||||||
|
const { getLink } = useLinkStore();
|
||||||
|
|
||||||
|
const [link, setLink] =
|
||||||
|
useState<LinkIncludingShortenedCollectionAndTags>(activeLink);
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let isPublicRoute = router.pathname.startsWith("/public")
|
||||||
|
? true
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const data = await getLink(link.id as number, isPublicRoute);
|
||||||
|
setLink(
|
||||||
|
(data as any).response as LinkIncludingShortenedCollectionAndTags
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
|
||||||
|
let interval: any;
|
||||||
|
if (link?.screenshotPath === "pending" || link?.pdfPath === "pending") {
|
||||||
|
interval = setInterval(async () => {
|
||||||
|
const data = await getLink(link.id as number, isPublicRoute);
|
||||||
|
setLink(
|
||||||
|
(data as any).response as LinkIncludingShortenedCollectionAndTags
|
||||||
|
);
|
||||||
|
}, 5000);
|
||||||
|
} else {
|
||||||
|
if (interval) {
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (interval) {
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [link?.screenshotPath, link?.pdfPath, link?.readabilityPath]);
|
||||||
|
|
||||||
|
const updateArchive = async () => {
|
||||||
|
const load = toast.loading("Sending request...");
|
||||||
|
|
||||||
|
const response = await fetch(`/api/v1/links/${link?.id}/archive`, {
|
||||||
|
method: "PUT",
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
toast.dismiss(load);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
toast.success(`Link is being archived...`);
|
||||||
|
getLink(link?.id as number);
|
||||||
|
} else toast.error(data.response);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDownload = () => {
|
||||||
|
const path = `/api/v1/archives/${link?.id}?format=${format}`;
|
||||||
|
fetch(path)
|
||||||
|
.then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
|
// Create a temporary link and click it to trigger the download
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = path;
|
||||||
|
link.download = format === ArchivedFormat.png ? "Screenshot" : "PDF";
|
||||||
|
link.click();
|
||||||
|
} else {
|
||||||
|
console.error("Failed to download file");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error:", error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex justify-between items-center pr-1 border border-neutral-content rounded-md">
|
||||||
|
<div className="flex gap-2 items-center">
|
||||||
|
<div className="bg-primary text-primary-content p-2 rounded-l-md">
|
||||||
|
<i className={`${icon} text-2xl`}/>
|
||||||
|
</div>
|
||||||
|
<p>{name}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-1">
|
||||||
|
{downloadable || false ? (
|
||||||
|
<div
|
||||||
|
onClick={() => handleDownload()}
|
||||||
|
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
||||||
|
>
|
||||||
|
<i className="bi-cloud-arrow-down text-xl text-neutral"/>
|
||||||
|
</div>
|
||||||
|
) : undefined}
|
||||||
|
|
||||||
|
<Link
|
||||||
|
href={
|
||||||
|
`${
|
||||||
|
format === ArchivedFormat.readability
|
||||||
|
? `/preserved/${link?.id}?format=${format}`
|
||||||
|
: `/api/v1/archives/${link?.id}?format=${
|
||||||
|
link.screenshotPath?.endsWith("png")
|
||||||
|
? ArchivedFormat.png
|
||||||
|
: ArchivedFormat.jpeg
|
||||||
|
}`
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
target="_blank"
|
||||||
|
className="cursor-pointer hover:opacity-60 duration-100 p-2 rounded-md"
|
||||||
|
>
|
||||||
|
<i className="bi-box-arrow-up-right text-xl text-neutral"/>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Ŝarĝante…
Reference in New Issue