Skip to content
Snippets Groups Projects
Commit c0cc9537 authored by Esko Ikkala's avatar Esko Ikkala
Browse files

Update babel and rxjs

parent 3604ebb8
No related branches found
No related tags found
No related merge requests found
{ {
"presets": [ "presets": [
"env", "@babel/preset-env",
"react", "@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
] ]
} }
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"dev": "concurrently \"npm run server\" \"npm run client\"", "dev": "concurrently \"npm run server\" \"npm run client\"",
"build": "npm run build-client && npm run build-server", "build": "npm run build-client && npm run build-server",
"client": "webpack-dev-server --config webpack.client.dev.js", "client": "webpack-dev-server --config webpack.client.dev.js",
"server": "nodemon src/server/index.js --exec babel-node ", "server": "nodemon src/server/index.js --exec babel-node",
"build-client": "webpack --progress --config webpack.client.prod.js", "build-client": "webpack --progress --config webpack.client.prod.js",
"build-server": "babel --no-babelrc --presets=es2015 src/server --out-dir ./dist/server", "build-server": "babel --no-babelrc --presets=es2015 src/server --out-dir ./dist/server",
"serve": "NODE_ENV=production node dist/server/index.js", "serve": "NODE_ENV=production node dist/server/index.js",
...@@ -20,48 +20,47 @@ ...@@ -20,48 +20,47 @@
"author": "Esko Ikkala", "author": "Esko Ikkala",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"babel-cli": "^6.26.0", "@babel/cli": "^7.0.0",
"babel-core": "^6.26.3", "@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^8.2.6", "babel-eslint": "^8.2.6",
"babel-jest": "^22.4.4", "babel-jest": "^22.4.4",
"babel-loader": "^7.1.5", "babel-loader": "^8.0.4",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"clean-webpack-plugin": "^0.1.19", "clean-webpack-plugin": "^0.1.19",
"concurrently": "^3.6.1", "concurrently": "^3.6.1",
"copy-webpack-plugin": "^4.5.2", "copy-webpack-plugin": "^4.5.2",
"css-loader": "^0.28.11", "css-loader": "^0.28.11",
"enzyme": "^3.6.0", "enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.5.0", "enzyme-adapter-react-16": "^1.6.0",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-plugin-import": "^2.14.0", "eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.22.0", "eslint-plugin-jest": "^21.24.1",
"eslint-plugin-jsx-a11y": "^6.1.1", "eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1", "eslint-plugin-react": "^7.11.1",
"eslint-watch": "^3.1.5", "eslint-watch": "^3.1.5",
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"html-webpack-plugin": "^3.0.7", "html-webpack-plugin": "^3.0.7",
"jest": "^22.4.4", "jest": "^22.4.4",
"jest-enzyme": "^6.0.4", "jest-enzyme": "^6.1.2",
"react-test-renderer": "^16.5.1", "react-test-renderer": "^16.5.2",
"style-loader": "^0.20.3", "style-loader": "^0.20.3",
"webpack": "^4.19.0", "webpack": "^4.20.2",
"webpack-cli": "^2.1.5", "webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.8", "webpack-dev-server": "^3.1.9",
"webpack-merge": "^4.1.4" "webpack-merge": "^4.1.4"
}, },
"dependencies": { "dependencies": {
"@material-ui/core": "^3.1.0", "@material-ui/core": "^3.2.0",
"@material-ui/icons": "^3.0.1", "@material-ui/icons": "^3.0.1",
"@material-ui/lab": "^3.0.0-alpha.16", "@material-ui/lab": "^3.0.0-alpha.19",
"Leaflet.Control.Opacity": "git+https://github.com/SemanticComputing/Leaflet.Control.Opacity.git", "Leaflet.Control.Opacity": "git+https://github.com/SemanticComputing/Leaflet.Control.Opacity.git",
"Leaflet.extra-markers": "git+https://github.com/SemanticComputing/Leaflet.ExtraMarkers.git", "Leaflet.extra-markers": "git+https://github.com/SemanticComputing/Leaflet.ExtraMarkers.git",
"autosuggest-highlight": "^3.1.1", "autosuggest-highlight": "^3.1.1",
"babel-preset-stage-2": "^6.24.1",
"bootstrap": "^4.1.3", "bootstrap": "^4.1.3",
"express": "^4.16.3", "express": "^4.16.3",
"geographiclib": "^1.49.0",
"google-maps": "^3.3.0", "google-maps": "^3.3.0",
"immutable": "^3.8.2", "immutable": "^3.8.2",
"leaflet": "^1.3.4", "leaflet": "^1.3.4",
...@@ -70,11 +69,10 @@ ...@@ -70,11 +69,10 @@
"leaflet.smooth_marker_bouncing": "^1.2.0", "leaflet.smooth_marker_bouncing": "^1.2.0",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"node-fetch": "^2.2.0", "node-fetch": "^2.2.0",
"react": "^16.5.1", "react": "^16.5.2",
"react-alert-template-basic": "^1.0.0", "react-alert-template-basic": "^1.0.0",
"react-autosuggest": "^9.4.1",
"react-csv": "^1.0.15", "react-csv": "^1.0.15",
"react-dom": "^16.5.1", "react-dom": "^16.5.2",
"react-google-maps": "^9.4.5", "react-google-maps": "^9.4.5",
"react-redux": "^5.0.7", "react-redux": "^5.0.7",
"react-redux-toastr": "^7.4.0", "react-redux-toastr": "^7.4.0",
...@@ -87,6 +85,8 @@ ...@@ -87,6 +85,8 @@
"redux-observable": "^0.18.0", "redux-observable": "^0.18.0",
"redux-responsive": "^4.3.8", "redux-responsive": "^4.3.8",
"reselect": "^3.0.1", "reselect": "^3.0.1",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"superagent": "^3.8.3", "superagent": "^3.8.3",
"victory": "^0.26.1" "victory": "^0.26.1"
} }
......
import 'rxjs';
import _ from 'lodash'; import { ajax } from 'rxjs/ajax';
import { ajax } from 'rxjs/observable/dom/ajax'; import { mergeMap, map } from 'rxjs/operators';
import { combineEpics } from 'redux-observable'; import { combineEpics, ofType } from 'redux-observable';
import { Observable } from 'rxjs/Observable';
import { import {
updateManuscripts, updateManuscripts,
updatePlaces, updatePlaces,
updateFacet, updateFacet,
updateGeoJSON, //updateGeoJSON,
FETCH_FACET, FETCH_FACET,
FETCH_FACET_FAILED, //FETCH_FACET_FAILED,
FETCH_MANUSCRIPTS, FETCH_MANUSCRIPTS,
FETCH_MANUSCRIPTS_FAILED, //FETCH_MANUSCRIPTS_FAILED,
FETCH_PLACES, FETCH_PLACES,
FETCH_PLACES_FAILED, //FETCH_PLACES_FAILED,
GET_GEOJSON, //GET_GEOJSON,
GET_GEOJSON_FAILED //GET_GEOJSON_FAILED
} from '../actions'; } from '../actions';
const hiplaApiUrl = (process.env.NODE_ENV === 'development') const hiplaApiUrl = (process.env.NODE_ENV === 'development')
? 'http://localhost:3001/' ? 'http://localhost:3001/'
: 'http://193.166.25.181:3006/'; : 'http://193.166.25.181:3006/';
const pickSelectedDatasets = (datasets) => { const getManuscripts = action$ => action$.pipe(
let selected = []; ofType(FETCH_MANUSCRIPTS),
Object.keys(datasets).map(key => { mergeMap(action => {
if (datasets[key].selected) { const searchUrl = hiplaApiUrl + 'manuscripts';
selected.push(key); const requestUrl = `${searchUrl}?page=${action.page}`;
} return ajax.getJSON(requestUrl).pipe(
}); map(response => updateManuscripts({ manuscripts: response }))
return selected; );
}; })
);
const getManuscripts = (action$) => {
const searchUrl = hiplaApiUrl + 'manuscripts';
return action$.ofType(FETCH_MANUSCRIPTS)
.switchMap(action => {
const requestUrl = `${searchUrl}?page=${action.page}`;
return ajax.getJSON(requestUrl)
.map(response => updateManuscripts({ manuscripts: response }))
.catch(error => Observable.of({
type: FETCH_MANUSCRIPTS_FAILED,
error: error,
}));
});
};
const getPlaces = (action$, store) => { const getPlaces = action$ => action$.pipe(
const searchUrl = hiplaApiUrl + 'places'; ofType(FETCH_PLACES),
return action$.ofType(FETCH_PLACES) mergeMap(() => {
.switchMap(() => { const searchUrl = hiplaApiUrl + 'places';
const { datasets } = store.getState().search; const requestUrl = `${searchUrl}`;
const dsParams = _.map(pickSelectedDatasets(datasets), ds => `dataset=${ds}`).join('&'); return ajax.getJSON(requestUrl).pipe(
const requestUrl = `${searchUrl}?${dsParams}`; map(response => updatePlaces({ places: response }))
return ajax.getJSON(requestUrl) );
.map(response => updatePlaces({ places: response })) })
.catch(error => Observable.of({ );
type: FETCH_PLACES_FAILED,
error: error,
}));
});
};
const getFacet = (action$) => { const getFacet = action$ => action$.pipe(
const searchUrl = hiplaApiUrl + 'facet'; ofType(FETCH_FACET),
return action$.ofType(FETCH_FACET) mergeMap((action) => {
.switchMap((action) => { const searchUrl = hiplaApiUrl + 'facet';
const requestUrl = `${searchUrl}?property=${action.property}`; const requestUrl = `${searchUrl}?property=${action.property}`;
return ajax.getJSON(requestUrl) return ajax.getJSON(requestUrl).pipe(
.map(response => updateFacet({ values: response })) map(response => updateFacet({ values: response }))
.catch(error => Observable.of({ );
type: FETCH_FACET_FAILED, })
error: error, );
}));
});
};
const getGeoJSONEpic = (action$) => { // const getGeoJSONEpic = (action$) => {
const wfsUrl = hiplaApiUrl + 'wfs'; // const wfsUrl = hiplaApiUrl + 'wfs';
return action$.ofType(GET_GEOJSON) // return action$.ofType(GET_GEOJSON)
.switchMap(action => { // .switchMap(action => {
let s = ''; // let s = '';
action.layerIDs.map(layerID => { // action.layerIDs.map(layerID => {
s += `&layerID=${layerID}`; // s += `&layerID=${layerID}`;
}); // });
const requestUrl = `${wfsUrl}?${s}`; // const requestUrl = `${wfsUrl}?${s}`;
return ajax.getJSON(requestUrl) // return ajax.getJSON(requestUrl)
// .map(response => { // // .map(response => {
// console.log(response) // // console.log(response)
// }) // // })
.map(response => updateGeoJSON({ geoJSON: response })) // .map(response => updateGeoJSON({ geoJSON: response }))
.catch(error => Observable.of({ // .catch(error => Observable.of({
type: GET_GEOJSON_FAILED, // type: GET_GEOJSON_FAILED,
error: error, // error: error,
})); // }));
}); // });
}; // };
const rootEpic = combineEpics( const rootEpic = combineEpics(
getManuscripts, getManuscripts,
getPlaces, getPlaces,
getFacet, getFacet,
getGeoJSONEpic // getGeoJSONEpic
); );
export default rootEpic; export default rootEpic;
...@@ -32,10 +32,7 @@ module.exports = { ...@@ -32,10 +32,7 @@ module.exports = {
{ {
test: /\.js$/, test: /\.js$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: 'babel-loader', use: ['babel-loader']
query: {
presets: ['es2015', 'react', 'stage-2']
},
}, },
{ {
test: /\.css$/, test: /\.css$/,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment