mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-08 22:08:16 -06:00
Add actions: copy to clipboard, download response file
This commit is contained in:
@@ -4,6 +4,8 @@ import { useBoolean } from "usehooks-ts";
|
|||||||
import {
|
import {
|
||||||
LinkIcon,
|
LinkIcon,
|
||||||
CodeBracketIcon,
|
CodeBracketIcon,
|
||||||
|
DocumentArrowDownIcon,
|
||||||
|
ClipboardDocumentIcon,
|
||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
|
|
||||||
type AbstractCardProps = {
|
type AbstractCardProps = {
|
||||||
@@ -28,12 +30,6 @@ const AbstractCard: FunctionComponent<AbstractCardProps> = ({
|
|||||||
{header != undefined || data != undefined ? (
|
{header != undefined || data != undefined ? (
|
||||||
<div className="flex bg-zinc-700 p-2 pl-3 md:pl-5">
|
<div className="flex bg-zinc-700 p-2 pl-3 md:pl-5">
|
||||||
<div className="grow space-x-2">{header}</div>
|
<div className="grow space-x-2">{header}</div>
|
||||||
{data != undefined ? (
|
|
||||||
<div className="pr-1">
|
|
||||||
<CodeBracketIcon
|
|
||||||
onClick={toggleRaw}
|
|
||||||
className="h-6 w-6 cursor-pointer"
|
|
||||||
/>
|
|
||||||
{url != undefined ? (
|
{url != undefined ? (
|
||||||
<div className="pr-2">
|
<div className="pr-2">
|
||||||
<a href={url} target="_blank" rel="noreferrer">
|
<a href={url} target="_blank" rel="noreferrer">
|
||||||
@@ -41,6 +37,47 @@ const AbstractCard: FunctionComponent<AbstractCardProps> = ({
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
{data != undefined ? (
|
||||||
|
<>
|
||||||
|
<div className="pr-2">
|
||||||
|
<ClipboardDocumentIcon
|
||||||
|
onClick={() => {
|
||||||
|
// stringify the JSON object, then begin the async clipboard write
|
||||||
|
navigator.clipboard.writeText(JSON.stringify(data, null, 4)).then(() => {
|
||||||
|
console.log('Copied to clipboard.');
|
||||||
|
}, (err) => {
|
||||||
|
if (err instanceof Error)
|
||||||
|
console.error(`Failed to copy to clipboard (${err.toString()}).`);
|
||||||
|
else
|
||||||
|
console.error("Failed to copy to clipboard.");
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
className="h-6 w-6 cursor-pointer"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="pr-2">
|
||||||
|
<DocumentArrowDownIcon
|
||||||
|
onClick={() => {
|
||||||
|
const file = new Blob([JSON.stringify(data, null, 4)], {
|
||||||
|
type: "application/json",
|
||||||
|
});
|
||||||
|
|
||||||
|
const anchor = document.createElement("a");
|
||||||
|
anchor.href = URL.createObjectURL(file);
|
||||||
|
anchor.download = "response.json";
|
||||||
|
anchor.click();
|
||||||
|
}}
|
||||||
|
className="h-6 w-6 cursor-pointer"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="pr-1">
|
||||||
|
<CodeBracketIcon
|
||||||
|
onClick={toggleRaw}
|
||||||
|
className="h-6 w-6 cursor-pointer"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="max-w-full p-2 px-4 overflow-x-auto">
|
<div className="max-w-full p-2 px-4 overflow-x-auto">
|
||||||
|
|||||||
Reference in New Issue
Block a user