From 0ea109968c45efa920916e9163230df2a1aef42d Mon Sep 17 00:00:00 2001 From: efarooqui Date: Tue, 25 Aug 2020 08:52:04 -0700 Subject: [PATCH] Pulling in associations correctly; condensed filters and narratives into associations --- example.config.js | 13 +++----- src/actions/index.js | 51 ++++++++++++----------------- src/reducers/validate/validators.js | 1 + 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/example.config.js b/example.config.js index 8eafa14..ac443c1 100644 --- a/example.config.js +++ b/example.config.js @@ -4,9 +4,8 @@ module.exports = { SERVER_ROOT: 'http://localhost:4040', EVENTS_EXT: '/api/timemap_data/export_events/deeprows', CATEGORIES_EXT: '/api/timemap_data/export_categories/rows', - FILTERS_EXT: '/api/timemap_data/export_filters/tree', + ASSOCIATIONS_EXT: '/api/timemap_data/export_associations/deeprows', SOURCES_EXT: '/api/timemap_data/export_sources/deepids', - NARRATIVE_EXT: '', SITES_EXT: '', SHAPES_EXT: '', DATE_FMT: 'MM/DD/YYYY', @@ -24,13 +23,11 @@ module.exports = { } }, features: { - USE_CATEGORIES: false, - CATEGORIES_AS_FILTERS: false, - USE_FILTERS: true, - FILTERS_AS_NARRATIVES: false, - USE_NARRATIVES: false, + USE_CATEGORIES: true, + CATEGORIES_AS_FILTERS: true, + USE_ASSOCIATIONS: true, USE_SOURCES: true, - USE_COVER: false, + USE_COVER: true, USE_SEARCH: false, USE_SITES: false, USE_SHAPES: false, diff --git a/src/actions/index.js b/src/actions/index.js index 44be864..f1541bc 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -5,9 +5,8 @@ import { urlFromEnv } from '../common/utilities' // const CONFIG_URL = urlFromEnv('CONFIG_EXT') const EVENT_DATA_URL = urlFromEnv('EVENTS_EXT') const CATEGORY_URL = urlFromEnv('CATEGORIES_EXT') -const FILTERS_URL = urlFromEnv('FILTERS_EXT') +const ASSOCIATIONS_URL = urlFromEnv('ASSOCIATIONS_EXT') const SOURCES_URL = urlFromEnv('SOURCES_EXT') -const NARRATIVE_URL = urlFromEnv('NARRATIVES_EXT') const SITES_URL = urlFromEnv('SITES_EXT') const SHAPES_URL = urlFromEnv('SHAPES_EXT') @@ -50,31 +49,18 @@ export function fetchDomain () { .catch(() => handleError(domainMsg('categories'))) } - let narPromise = Promise.resolve([]) - if (features.USE_NARRATIVES) { - narPromise = fetch(NARRATIVE_URL) - .then(response => response.json()) - .catch(() => handleError(domainMsg('narratives'))) - } - - let sitesPromise = Promise.resolve([]) - if (features.USE_SITES) { - sitesPromise = fetch(SITES_URL) - .then(response => response.json()) - .catch(() => handleError(domainMsg('sites'))) - } - - let filtersPromise = Promise.resolve([]) - if (features.USE_FILTERS) { - if (!FILTERS_URL) { - filtersPromise = Promise.resolve(handleError('USE_FILTERS is true, but you have not provided a FILTERS_EXT')) + let associationsPromise = Promise.resolve([]) + if (features.USE_ASSOCIATIONS) { + if (!ASSOCIATIONS_URL) { + associationsPromise = Promise.resolve(handleError('USE_ASSOCIATIONS is true, but you have not provided a ASSOCIATIONS_EXT')) } else { - filtersPromise = fetch(FILTERS_URL) + associationsPromise = fetch(ASSOCIATIONS_URL) .then(response => response.json()) - .catch(() => handleError(domainMsg('filters'))) + .catch(() => handleError(domainMsg('associations'))) } } + let sourcesPromise = Promise.resolve([]) if (features.USE_SOURCES) { if (!SOURCES_URL) { @@ -86,6 +72,13 @@ export function fetchDomain () { } } + let sitesPromise = Promise.resolve([]) + if (features.USE_SITES) { + sitesPromise = fetch(SITES_URL) + .then(response => response.json()) + .catch(() => handleError(domainMsg('sites'))) + } + let shapesPromise = Promise.resolve([]) if (features.USE_SHAPES) { shapesPromise = fetch(SHAPES_URL) @@ -96,21 +89,19 @@ export function fetchDomain () { return Promise.all([ eventPromise, catPromise, - narPromise, - sitesPromise, - filtersPromise, + associationsPromise, sourcesPromise, + sitesPromise, shapesPromise ]) .then(response => { const result = { events: response[0], categories: response[1], - narratives: response[2], - sites: response[3], - filters: response[4], - sources: response[5], - shapes: response[6], + associations: response[2], + sources: response[3], + sites: response[4], + shapes: response[5], notifications } if (Object.values(result).some(resp => resp.hasOwnProperty('error'))) { diff --git a/src/reducers/validate/validators.js b/src/reducers/validate/validators.js index 05e6dbb..2fcb7be 100644 --- a/src/reducers/validate/validators.js +++ b/src/reducers/validate/validators.js @@ -75,6 +75,7 @@ function validateFilterTree (node, parent, set, duplicates, hasFilterDescription * Validate domain schema */ export function validateDomain (domain, features) { + console.info(domain) const sanitizedDomain = { events: [], categories: [],