From 3a61b757d60fc4488be408f66c4bda732739aa91 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 8 Jan 2024 14:45:38 -0500 Subject: [PATCH 1/3] Add a select field to handle enums --- src/addons/dispatch/Form.svelte | 1 + src/addons/dispatch/fields/index.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/addons/dispatch/Form.svelte b/src/addons/dispatch/Form.svelte index 865cd7f62..c973f4114 100644 --- a/src/addons/dispatch/Form.svelte +++ b/src/addons/dispatch/Form.svelte @@ -78,6 +78,7 @@ required={required.includes(name)} bind:value={$values[name]} defaultValue={params.default} + choices={params.enum} /> {/each} diff --git a/src/addons/dispatch/fields/index.js b/src/addons/dispatch/fields/index.js index 37481959c..3582ad74d 100644 --- a/src/addons/dispatch/fields/index.js +++ b/src/addons/dispatch/fields/index.js @@ -2,6 +2,7 @@ import ArrayField from "./ArrayField.svelte"; import Checkbox from "./Checkbox.svelte"; import Number from "./Number.svelte"; import Text from "./Text.svelte"; +import Select from "./Select.svelte"; // https://json-schema.org/understanding-json-schema/reference/type.html const fields = { @@ -31,5 +32,10 @@ export function autofield(params, fallback = Text) { return fallback; } + // only string enums for now + if (type === "string" && params.enum) { + return Select; + } + return fields[type]; } From d1714ef0269cf3bc2a8151805459adf1c0c09f3e Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 8 Jan 2024 14:45:58 -0500 Subject: [PATCH 2/3] really commit --- src/addons/dispatch/fields/Select.svelte | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/addons/dispatch/fields/Select.svelte diff --git a/src/addons/dispatch/fields/Select.svelte b/src/addons/dispatch/fields/Select.svelte new file mode 100644 index 000000000..4e936cf8a --- /dev/null +++ b/src/addons/dispatch/fields/Select.svelte @@ -0,0 +1,23 @@ + + + + + From 66eb18bdbc7372f9ae98eaa11d27f9953210495d Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 8 Jan 2024 17:04:19 -0500 Subject: [PATCH 3/3] bind:value --- src/addons/dispatch/fields/Select.svelte | 2 +- src/addons/fixtures/addons.json | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/addons/dispatch/fields/Select.svelte b/src/addons/dispatch/fields/Select.svelte index 4e936cf8a..9b1fd3839 100644 --- a/src/addons/dispatch/fields/Select.svelte +++ b/src/addons/dispatch/fields/Select.svelte @@ -12,7 +12,7 @@ - {#if !required} {/if} diff --git a/src/addons/fixtures/addons.json b/src/addons/fixtures/addons.json index eae9e4169..4abea2dc2 100644 --- a/src/addons/fixtures/addons.json +++ b/src/addons/fixtures/addons.json @@ -30,6 +30,7 @@ "type": "object", "title": "Scraper", "required": ["site", "project"], + "categories": ["monitor"], "properties": { "site": { "type": "string", @@ -65,10 +66,11 @@ "description": "Recursively scrape same-domain links found on the page (Must be between 0 and 2)" }, "access_level": { + "enum": ["public", "organization", "private"], "type": "string", "title": "Access Level", "default": "public", - "description": "Access level (public, private, or organization) of documents scraped." + "description": "Access level of documents scraped." }, "slack_webhook": { "type": "string", @@ -77,18 +79,20 @@ "description": "Enter a slack webhook to enable Slack notifications" } }, - "description": "

This add-on will scrape and optionally crawl a given site for documents to upload to DocumentCloud. It can also alert you of given keywords appearing in those documents.

", + "description": "

Scrape and optionally crawl a given site for documents to upload to DocumentCloud.

", "eventOptions": { "name": "site", "events": ["hourly", "daily", "weekly"] - } + }, + "instructions": "

You may specify a project to scrape the documents into as well as an access level. \nScraper can alert you by email or Slack notification when given keywords appear in\ndocuments if you specify keywords to monitor. For Slack notifications, you must provide a webhook.

\n

The crawl depth is a parameter that tells the Scraper how many clicks deep away from the\nsite you specify in order to continue looking for documents. \nIf the PDFs are directly linked on the site you provide \n(1 click to get to the PDF), 0 is the crawl depth you should use. \nIf the site you provide a link to contains multiple links to other pages that have PDFs linked to those pages, \nyour crawl depth would be 1. A crawl depth of 2 is the maximum supported.

\n

The Scraper Add-On now supports Google Drive links. \nIt will upload the first 30 Google Drive documents it sees per run. \nScraper will upload the first 100 regular documents it sees per run. \nThe Scraper keeps track of which documents it has seen and already uploaded.

" }, "created_at": "2022-05-17T13:49:53.635344Z", - "updated_at": "2023-05-12T16:48:05.637062Z", + "updated_at": "2024-01-08T19:55:22.662655Z", "active": false, "default": true, - "featured": false + "featured": true }, + { "id": 110, "user": 20080,