mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 05:18:34 +03:00
refmt source URL and reducers
to use ES6 spread syntax
This commit is contained in:
@@ -3,8 +3,8 @@ module.exports = {
|
||||
SERVER_ROOT: 'http://localhost:4040',
|
||||
EVENT_EXT: '/api/example/export_events/rows',
|
||||
CATEGORY_EXT: '/api/example/export_categories/rows',
|
||||
EVENT_DESC_ROOT: '/api/example/export_events/ids',
|
||||
TAG_TREE_EXT: '/api/example/export_tags/tree',
|
||||
SOURCES_EXT: '/api/example/export_events/ids',
|
||||
TAGS_EXT: '/api/example/export_tags/tree',
|
||||
SITES_EXT: '/api/example/export_sites/rows',
|
||||
MAP_ANCHOR: [31.356397, 34.784818],
|
||||
INCOMING_DATETIME_FORMAT: '%m/%d/%YT%H:%M',
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
// TODO: move to util lib
|
||||
function urlFromEnv(ext) {
|
||||
if (process.env[ext]) {
|
||||
return `${process.env.SERVER_ROOT}${process.env[ext]}`
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: relegate these URLs entirely to environment variables
|
||||
const EVENT_DATA_URL = `${process.env.SERVER_ROOT}${process.env.EVENT_EXT}`
|
||||
const CATEGORY_URL = `${process.env.SERVER_ROOT}${process.env.CATEGORY_EXT}`
|
||||
const TAG_TREE_URL = `${process.env.SERVER_ROOT}${process.env.TAG_TREE_EXT}`
|
||||
const SITES_URL = `${process.env.SERVER_ROOT}${process.env.SITES_EXT}`
|
||||
const EVENT_DATA_URL = urlFromEnv('EVENT_EXT')
|
||||
const CATEGORY_URL = urlFromEnv('CATEGORY_EXT')
|
||||
const TAG_URL = urlFromEnv('TAGS_EXT')
|
||||
const SOURCES_URL = urlFromEnv('SOURCES_EXT')
|
||||
const SITES_URL = urlFromEnv('SITES_EXT')
|
||||
const eventUrlMap = (event) => `${process.env.SERVER_ROOT}${process.env.EVENT_DESC_ROOT}/${(event.id) ? event.id : event}`
|
||||
|
||||
/*
|
||||
@@ -120,7 +130,11 @@ export function fetchSelected(selected) {
|
||||
}
|
||||
return dispatch => {
|
||||
dispatch(updateSelected(selected))
|
||||
dispatch(toggleFetchingSources())
|
||||
if (!SOURCES_URL) {
|
||||
dispatch(fetchSourceError('No source extension specified.'))
|
||||
} else {
|
||||
dispatch(toggleFetchingSources())
|
||||
}
|
||||
|
||||
// const urls = events.map(eventUrlMap)
|
||||
// return Promise.all(
|
||||
@@ -213,13 +227,6 @@ export function toggleFetchingSources() {
|
||||
}
|
||||
}
|
||||
|
||||
// export const TOGGLE_FETCHING_EVENTS = 'TOGGLE_FETCHING_EVENTS'
|
||||
// export function toggleFetchingEvents() {
|
||||
// return {
|
||||
// type: TOGGLE_FETCHING_EVENTS
|
||||
// }
|
||||
// }
|
||||
|
||||
export const TOGGLE_LANGUAGE = 'TOGGLE_LANGUAGE';
|
||||
export function toggleLanguage(language) {
|
||||
return {
|
||||
@@ -248,3 +255,13 @@ export function toggleNotifications() {
|
||||
type: TOGGLE_NOTIFICATIONS
|
||||
}
|
||||
}
|
||||
|
||||
// ERRORS
|
||||
|
||||
export const FETCH_SOURCE_ERROR = 'FETCH_SOURCE_ERROR'
|
||||
export function fetchSourceError(msg) {
|
||||
return {
|
||||
type: FETCH_SOURCE_ERROR,
|
||||
msg
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,35 +10,43 @@ import {
|
||||
} from '../actions'
|
||||
|
||||
function toggleFetchingDomain(uiState, action) {
|
||||
return Object.assign({}, uiState, {
|
||||
flags: Object.assign({}, uiState.flags, {
|
||||
return {
|
||||
...uiState,
|
||||
flags: {
|
||||
...uiState.flags,
|
||||
isFetchingDomain: !uiState.flags.isFetchingDomain
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleFetchingSources(uiState, action) {
|
||||
return Object.assign({}, uiState, {
|
||||
flags: Object.assign({}, uiState.flags, {
|
||||
return {
|
||||
...uiState,
|
||||
flags: {
|
||||
...uiState.flags,
|
||||
isFetchingSources: !uiState.flags.isFetchingSources
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleInfoPopup(uiState, action) {
|
||||
return Object.assign({}, uiState, {
|
||||
flags: Object.assign({}, uiState.flags, {
|
||||
return {
|
||||
...uiState,
|
||||
flags: {
|
||||
...uiState.flags,
|
||||
isInfopopup: !uiState.flags.isInfopopup
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleNotifications(uiState, action) {
|
||||
return Object.assign({}, uiState, {
|
||||
flags: Object.assign({}, uiState.flags, {
|
||||
return {
|
||||
...uiState,
|
||||
flags: {
|
||||
...uiState.flags,
|
||||
isNotification: !uiState.flags.isNotification
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ui(uiState = initial.ui, action) {
|
||||
|
||||
@@ -119,10 +119,10 @@ const initial = {
|
||||
|
||||
narratives: {
|
||||
default: {
|
||||
style: 'dotted', // ['dotted', 'solid']
|
||||
opacity: 0.4, // range between 0 and 1
|
||||
style: 'solid', // ['dotted', 'solid']
|
||||
opacity: 0.9, // range between 0 and 1
|
||||
stroke: 'red', // Any hex or rgb code
|
||||
strokeWidth: 2
|
||||
strokeWidth: 5
|
||||
},
|
||||
narrative_1: {
|
||||
style: 'solid', // ['dotted', 'solid']
|
||||
|
||||
Reference in New Issue
Block a user