view src/ingest/IngestStatus.ts @ 17:071943adf000

dnd a file or a url which we'll queue and fetch
author drewp@bigasterisk.com
date Sun, 16 Apr 2023 03:19:33 -0700
parents b73941c4dc0a
children 111a41817968
line wrap: on
line source

import { LitElement, html, css } from "lit";
import { customElement, property } from "lit/decorators.js";

interface Row {
  url: string;
  t: string;
  progress: string;
}

@customElement("ingest-status")
export class IngestStatus extends LitElement {
  @property() queue: Row[] = [];
  static styles = [
    css`
      table {
        background: #ccc;
      }
    `,
  ];
  connectedCallback(): void {
    super.connectedCallback();
    const es = new EventSource("../api/ingest/queue");
    es.onmessage = (ev) => {
      this.queue = JSON.parse(ev.data);
    };
  }
  render() {
    return html`
      <table>
        <thead>
          <th>Queued at</th>
          <th>Progress</th>
          <th>Source</th>
        </thead>
        <tbody id="processing">
          ${this.queue.map(
            (row) => html`
              <tr>
                <td>${row.t}</td>
                <td>${row.progress}</td>
                <td>${row.url}</td>
              </tr>
            `
          )}
        </tbody>
      </table>
    `;
  }
}