import { html, LitElement } from "./lib/lit.min.js"; export class GetBlobForm extends LitElement { static properties = { hasBlob: { state: true }, }; createRenderRoot() { return this; } async submit(e) { e.preventDefault(); const formData = new FormData(e.target); const sha256 = formData.get("sha256"); this.hasBlob = await fetch("/" + sha256, { method: "HEAD" }).then((res) => res.ok); if (this.hasBlob) { window.open("/" + sha256, "_blank"); } } renderResults() { return html`
${this.blobs.map( (blob) => html`
${blob.sha256}
`, )}
`; } renderForm() { return html`
${this.hasBlob === false ? html`

Blob missing

` : null}
`; } render() { if (this.blob) { return this.renderResults(); } return this.renderForm(); } } customElements.define("get-blob-form", GetBlobForm);