Pulling in associations correctly; condensed filters and narratives into associations

This commit is contained in:
efarooqui
2020-08-25 08:52:04 -07:00
parent 19201a5808
commit 0ea109968c
3 changed files with 27 additions and 38 deletions

View File

@@ -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,

View File

@@ -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'))) {

View File

@@ -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: [],