From 042346a833e855c331f8b7c581a0a3f449ba1946 Mon Sep 17 00:00:00 2001 From: Miguel Sozinho Ramalho <19508417+msramalho@users.noreply.github.com> Date: Mon, 9 Oct 2023 13:20:37 +0100 Subject: [PATCH] moves API data to S3, allows external use (#74) --- config.js | 11 ++++++----- package.json | 1 + src/common/data/copy.json | 4 ++++ src/components/controls/DownloadButton.jsx | 5 ++++- src/components/controls/DownloadPanel.jsx | 1 + vite.config.js | 4 ++++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/config.js b/config.js index cf8e78a..511701a 100755 --- a/config.js +++ b/config.js @@ -3,10 +3,11 @@ const one_day = 1440; const config = { title: "ukraine", display_title: "Civilian Harm\nin Ukraine", - SERVER_ROOT: "https://ukraine.bellingcat.com/ukraine-server", - EVENTS_EXT: "/api/ukraine/export_events/deeprows", - SOURCES_EXT: "/api/ukraine/export_sources/deepids", - ASSOCIATIONS_EXT: "/api/ukraine/export_associations/deeprows", + SERVER_ROOT: "https://bellingcat-embeds.ams3.cdn.digitaloceanspaces.com/production/ukr", + EVENTS_EXT: "/timemap/events.json", + SOURCES_EXT: "/timemap/sources.json", + ASSOCIATIONS_EXT: "/timemap/associations.json", + API_DATA: "https://bellingcat-embeds.ams3.cdn.digitaloceanspaces.com/production/ukr/timemap/api.json", MAPBOX_TOKEN: "pk.eyJ1IjoiYmVsbGluZ2NhdC1tYXBib3giLCJhIjoiY2tleW0wbWliMDA1cTJ5bzdkbTRraHgwZSJ9.GJQkjPzj8554VhR5SPsfJg", // MEDIA_EXT: "/api/media", @@ -38,7 +39,7 @@ const config = { { label: "Zoom to 1 month", duration: 31 * one_day }, { label: "Zoom to 6 months", duration: 6 * 31 * one_day }, { label: "Zoom to 1 year", duration: 12 * 31 * one_day }, - { label: "Zoom to 1.5 years", duration: 18 * 31 * one_day }, + { label: "Zoom to 2 years", duration: 24 * 31 * one_day }, ], range: { /** diff --git a/package.json b/package.json index f268fb6..4e049db 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "dev": "vite", "build": "vite build", + "preview": "vite preview", "dev:wsl": "vite --host", "test": "vitest", "eslint": "eslint src --ext jsx", diff --git a/src/common/data/copy.json b/src/common/data/copy.json index eac9782..d36377c 100644 --- a/src/common/data/copy.json +++ b/src/common/data/copy.json @@ -214,6 +214,10 @@ "title": "Download events", "description": "Export the most recent available events in different formats.", "formats": { + "api": { + "label": "API", + "description": "An API endpoint where you can always fetch the entire dataset in JSON format with tools like curl. Useful for integrating the data in other services and visualizaitons." + }, "csv": { "label": "CSV", "description": "CSV file where sources and filters are concatenated into a single column each due to data structure limitations." diff --git a/src/components/controls/DownloadButton.jsx b/src/components/controls/DownloadButton.jsx index a5cb12e..c02929f 100644 --- a/src/components/controls/DownloadButton.jsx +++ b/src/components/controls/DownloadButton.jsx @@ -3,11 +3,14 @@ import dayjs from "dayjs"; import { Parser } from "@json2csv/plainjs"; import copy from "../../common/data/copy.json"; import { downloadAsFile } from "../../common/utilities"; +import config from "../../../config"; export class DownloadButton extends Component { onDownload(format, domain) { let filename = `ukr-civharm-${dayjs().format("YYYY-MM-DD")}`; - if (format === "csv") { + if (format === "api") { + window.open(config["API_DATA"], '_blank'); + }else if (format === "csv") { let outputData = this.getCsvData(domain); downloadAsFile(`${filename}.csv`, outputData); } else if (format === "json") { diff --git a/src/components/controls/DownloadPanel.jsx b/src/components/controls/DownloadPanel.jsx index c679749..e956a8b 100644 --- a/src/components/controls/DownloadPanel.jsx +++ b/src/components/controls/DownloadPanel.jsx @@ -13,6 +13,7 @@ const DownloadPanel = ({ language, title, description, domain }) => { }} />
+ diff --git a/vite.config.js b/vite.config.js index cde7502..0636c6d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -12,6 +12,10 @@ export default defineConfig({ "/api": { target: "https://ukraine.bellingcat.com/ukraine-server", changeOrigin: true, + }, + "/timemap": { + target: "https://bellingcat-embeds.ams3.cdn.digitaloceanspaces.com/production/ukr", + changeOrigin: true, } } },