This commit is contained in:
greeneclipse committed 2026-10-27 14:53:19 +01:00
1 parent c347d2418f
commit 1ad180a052
49 files changed
+6339 -89

No files matched your search

+2 -2
View File
@@ -1962,7 +1962,7 @@ export const en: MessageDict = {
"feeds.field.type": "Type",
"feeds.field.file": "CSV file",
"feeds.fileHint":
"Max 5 MiB. After creating the feed, map columns and then sync, just as with URL feeds.",
"CSV, XML, JSON or Excel (.xls, .xlsx, .xlsm; zip several workbooks to import them as one feed). Max 32 MiB. After creating the feed, map columns and then sync, just as with URL feeds.",
"feeds.field.interval": "Auto-sync interval (minutes)",
"feeds.field.intervalHint":
"How often Descrybe should pull this feed automatically while it is active. Use Sync on the feed list for a one-off pull; that does not change this schedule.",
@@ -2684,7 +2684,7 @@ export const en: MessageDict = {
"flash.campaign.scheduleFailed": "Schedule failed",
"flash.campaign.saveFailed": "Save failed",
"flash.feed.copyFailed": "Could not copy URL",
"flash.feed.csvRequired": "Please choose a .csv file.",
"flash.feed.csvRequired": "Please choose a CSV, XML, JSON or Excel file.",
"flash.feed.csvFileRequired": "Please choose a CSV file.",
"flash.feed.urlRequired": "Feed URL is required.",
"flash.feed.updated": "Feed updated.",
@@ -94,6 +94,9 @@
"description",
"processed_name",
"processed_description",
"short_description",
"meta_title",
"meta_description",
"status",
"feed_id",
"gtin",
+15 -5
View File
@@ -527,10 +527,18 @@ function openAdd(source: "url" | "file" = "url") {
}
}
function fileFeedType(name: string): "csv" | "xml" | "json" | "excel" {
const lower = name.toLowerCase();
if (lower.endsWith(".json")) return "json";
if (lower.endsWith(".xml")) return "xml";
if (/\.(xlsx?|xlsm|zip)$/.test(lower)) return "excel";
return "csv";
}
function onCsvSelected(event: Event) {
const input = event.currentTarget as HTMLInputElement;
const file = input.files?.[0] ?? null;
if (file && !/\.(csv|json|xml)$/i.test(file.name)) {
if (file && !/\.(csv|json|xml|xlsx?|xlsm|zip)$/i.test(file.name)) {
formFile = null;
input.value = "";
error = i18n.t("flash.feed.csvRequired");
@@ -570,7 +578,7 @@ function openAdd(source: "url" | "file" = "url") {
}
const body = new FormData();
body.append("name", formName.trim());
body.append("feed_type", formFile?.name.toLowerCase().endsWith(".json") ? "json" : formFile?.name.toLowerCase().endsWith(".xml") ? "xml" : "csv");
body.append("feed_type", fileFeedType(formFile.name));
body.append("sync_interval_minutes", String(parseSyncIntervalMinutes(formInterval)));
body.append("content_language", formLanguage);
body.append("file", formFile);
@@ -599,7 +607,7 @@ function openAdd(source: "url" | "file" = "url") {
showAdd = false;
const createdId = created?.id != null ? String(created.id) : "";
trackEvent("feed_created", {
feed_type: formSource === "file" ? "csv" : formType
feed_type: formSource === "file" && formFile ? fileFeedType(formFile.name) : formType
});
success = createdId ? i18n.t("feeds.createdMapHint") : i18n.t("feeds.createdPlain");
notifySuccess(i18n.t("toast.feed.created"), {
@@ -1282,10 +1290,11 @@ function openAdd(source: "url" | "file" = "url") {
<option value="xml">XML</option>
<option value="csv">CSV</option>
<option value="json">JSON</option>
<option value="excel">Excel</option>
</Select>
</div>
{#if formType === "json"}<p class="text-xs text-muted-foreground">JSON arrays and nested products/results/items are supported. Map a record path if needed.</p>{:else}
<FeedFormatHelp format={formType === "csv" ? "csv" : "xml"} />{/if}
<FeedFormatHelp format={formType === "csv" || formType === "excel" ? "csv" : "xml"} />{/if}
<div class="space-y-2 rounded-md border p-3">
<p class="text-sm font-medium">Optional HTTP authentication</p>
<Select bind:value={formAuthType}><option value="bearer">Bearer token</option><option value="header">API key / custom header</option></Select>
@@ -1303,7 +1312,7 @@ function openAdd(source: "url" | "file" = "url") {
id="add-feed-file"
bind:this={formFileInput}
type="file"
accept=".csv,.xml,.json,text/csv,application/xml,application/json"
accept=".csv,.xml,.json,.xls,.xlsx,.xlsm,.zip,text/csv,application/xml,application/json,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel.sheet.macroEnabled.12,application/zip"
class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm file:mr-3 file:rounded-md file:border-0 file:bg-muted file:px-3 file:py-1.5 file:text-sm file:font-medium"
onchange={onCsvSelected}
required={formSource === "file"}
@@ -1405,6 +1414,7 @@ function openAdd(source: "url" | "file" = "url") {
<option value="xml">XML</option>
<option value="csv">CSV</option>
<option value="json">JSON</option>
<option value="excel">Excel</option>
</Select>
{#if editing && isFileFeed(editing)}
<p class="text-xs text-muted-foreground">{i18n.t("feeds.csvTypeLocked")}</p>
@@ -167,6 +167,7 @@
const isCsv = $derived(
schemaFormat === "csv" ||
schemaFormat === "excel" ||
String(feed?.feed_type ?? "").toLowerCase() === "csv" ||
String(feed?.feed_type ?? "").toLowerCase() === "excel"
);