Commit 695b2f07 authored by Florent Chehab's avatar Florent Chehab
Browse files

Redux added and display universities marker with no ajax operationnal

parent 72ceace6
Pipeline #26451 failed with stages
in 1 minute and 26 seconds
import { ADD_ARTICLE } from "../constants/action-types";
export const addArticle = article => ({ type: ADD_ARTICLE, payload: article });
\ No newline at end of file
import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import store from "../store/index";
import Dashboard from "./Dashboard";
import UnivMap from './UnivMap';
const App = () => (
<Dashboard />
<Provider store={store}>
<Dashboard />
</Provider>
);
const wrapper = document.getElementById("app");
wrapper ? ReactDOM.render(<App />, wrapper) : null;
\ No newline at end of file
wrapper ? ReactDOM.render(<App />, wrapper) : null;
import React, { Component } from 'react';
import { connect } from "react-redux";
import { Map, TileLayer, Marker, Popup, LayersControl, FeatureGroup, Circle, LayerGroup } from 'react-leaflet';
// import MarkerClusterGroup from 'react-leaflet-markercluster';
export default class UnivMap extends Component {
state = {
lat: 51.505,
lng: -0.09,
zoom: 13,
height: '200px'
}
render() {
const position = [this.state.lat, this.state.lng]
return (
<Map center={position} zoom={this.state.zoom} style={{ height: "500px" }}>
<LayersControl position="topright">
<LayersControl.BaseLayer name="OpenStreetMap France" checked={false}>
<TileLayer
attribution='&copy; Openstreetmap France | &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
url="https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png"
maxZoom={20}
/>
</LayersControl.BaseLayer>
<LayersControl.BaseLayer name="Stamen Watercolor" checked={true}>
<LayerGroup>
<TileLayer
attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
url="https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png"
minZoom={1}
maxZoom={18}
subdomains='abcd'
/>
<TileLayer
attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
url="https://stamen-tiles-{s}.a.ssl.fastly.net/toner-labels/{z}/{x}/{y}.png"
minZoom={1}
subdomains='abcd'
maxZoom={18}
/>
</LayerGroup>
</LayersControl.BaseLayer>
<LayersControl.BaseLayer name="Esri WorldImagery">
<TileLayer
attribution="Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
/>
</LayersControl.BaseLayer>
</LayersControl>
</Map>
)
}
}
const mapStateToProps = state => {
return { universities: state.universities };
};
const ToConnectUnivMap = ({ universities }) => (
<Map center={[51, 0]} zoom={13} style={{ height: "500px" }}>
<LayersControl position="topright">
<LayersControl.BaseLayer name="OpenStreetMap France" checked={false}>
<TileLayer
attribution='&copy; Openstreetmap France | &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
url="https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png"
maxZoom={20}
/>
</LayersControl.BaseLayer>
<LayersControl.BaseLayer name="Stamen Watercolor" checked={true}>
<LayerGroup>
<TileLayer
attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
url="https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png"
minZoom={1}
maxZoom={18}
subdomains='abcd'
/>
<TileLayer
attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
url="https://stamen-tiles-{s}.a.ssl.fastly.net/toner-labels/{z}/{x}/{y}.png"
minZoom={1}
subdomains='abcd'
maxZoom={18}
/>
</LayerGroup>
</LayersControl.BaseLayer>
<LayersControl.BaseLayer name="Esri WorldImagery">
<TileLayer
attribution="Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
/>
</LayersControl.BaseLayer>
</LayersControl>
{universities.map(el => (
<Marker position={[el.univCampus[0].lat, el.univCampus[0].lon]}>
<Popup>
{el.name}
</Popup>
</Marker>
))}
</Map>
)
const UnivMap = connect(mapStateToProps)(ToConnectUnivMap);
export default UnivMap;
export const ADD_ARTICLE = "ADD_ARTICLE";
\ No newline at end of file
import { ADD_ARTICLE } from "../constants/action-types";
const initialState = {
universities: [
{
"name": "Technische Universitat Ilmenau",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 1,
"univCampus": [
{
"id": 1,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Technische Universitat Ilmenau",
"comment": null,
"lat": "50.683868",
"lon": "10.932905",
"city": 1,
"university": 1
}
]
},
{
"name": "Universidad Del Salvador",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 2,
"univCampus": [
{
"id": 2,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidad Del Salvador",
"comment": null,
"lat": "-34.556265",
"lon": "-58.730054",
"city": 2,
"university": 2
}
]
},
{
"name": "Swinburne University Of Technology",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 3,
"univCampus": [
{
"id": 3,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Swinburne University Of Technology",
"comment": null,
"lat": "-37.852408",
"lon": "144.991823",
"city": 3,
"university": 3
}
]
},
{
"name": "Technische Universitat Graz",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 4,
"univCampus": [
{
"id": 4,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Technische Universitat Graz",
"comment": null,
"lat": "47.058210",
"lon": "15.460196",
"city": 4,
"university": 4
}
]
},
{
"name": "Universiteit Gent",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 5,
"univCampus": [
{
"id": 5,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universiteit Gent",
"comment": null,
"lat": "51.045041",
"lon": "3.725557",
"city": 5,
"university": 5
}
]
},
{
"name": "Universidade Federal De Minas Gerais",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 6,
"univCampus": [
{
"id": 6,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal De Minas Gerais",
"comment": null,
"lat": "-19.871890",
"lon": "-43.963093",
"city": 6,
"university": 6
}
]
},
{
"name": "Universidade Federal De Campina Grande",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 7,
"univCampus": [
{
"id": 7,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal De Campina Grande",
"comment": null,
"lat": "-6.762874",
"lon": "-38.228158",
"city": 7,
"university": 7
}
]
},
{
"name": "Universidade Estadual De Campinas (Unicamp)",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 8,
"univCampus": [
{
"id": 8,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Estadual De Campinas (Unicamp)",
"comment": null,
"lat": "-22.822478",
"lon": "-47.064260",
"city": 8,
"university": 8
}
]
},
{
"name": "Universidade Caxias Do Sul",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 9,
"univCampus": [
{
"id": 9,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Caxias Do Sul",
"comment": null,
"lat": "-29.162535",
"lon": "-51.148365",
"city": 9,
"university": 9
}
]
},
{
"name": "Pontificia Universidade Catolica Do Parana",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 10,
"univCampus": [
{
"id": 10,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Pontificia Universidade Catolica Do Parana",
"comment": null,
"lat": "-23.299078",
"lon": "-51.210269",
"city": 10,
"university": 10
}
]
},
{
"name": "Universidade Federal Do Parana",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 11,
"univCampus": [
{
"id": 11,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal Do Parana",
"comment": null,
"lat": "-23.598446",
"lon": "-51.673289",
"city": 10,
"university": 11
}
]
},
{
"name": "Universidade Tecnologica Federal Do Parana",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 12,
"univCampus": [
{
"id": 12,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Tecnologica Federal Do Parana",
"comment": null,
"lat": "-25.052164",
"lon": "-50.131186",
"city": 10,
"university": 12
}
]
},
{
"name": "Universidade Federal De Santa Catarina",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 13,
"univCampus": [
{
"id": 13,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal De Santa Catarina",
"comment": null,
"lat": "-27.603374",
"lon": "-48.522463",
"city": 11,
"university": 13
}
]
},
{
"name": "Universidade Federal De Itajuba",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 14,
"univCampus": [
{
"id": 14,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal De Itajuba",
"comment": null,
"lat": "-22.413797",
"lon": "-45.450273",
"city": 12,
"university": 14
}
]
},
{
"name": "Universidade Federal Da Paraiba",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 15,
"univCampus": [
{
"id": 15,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal Da Paraiba",
"comment": null,
"lat": "-6.750559",
"lon": "-35.645450",
"city": 13,
"university": 15
}
]
},
{
"name": "Universidade Federal Juiz De Fora",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 16,
"univCampus": [
{
"id": 16,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal Juiz De Fora",
"comment": null,
"lat": "-21.776894",
"lon": "-43.369181",
"city": 14,
"university": 16
}
]
},
{
"name": "Universidad Estadual De Maringa",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 17,
"univCampus": [
{
"id": 17,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidad Estadual De Maringa",
"comment": null,
"lat": "-23.779030",
"lon": "-53.325268",
"city": 15,
"university": 17
}
]
},
{
"name": "Universidade Federal De Pernambuco",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 18,
"univCampus": [
{
"id": 18,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal De Pernambuco",
"comment": null,
"lat": "-8.052543",
"lon": "-34.951029",
"city": 16,
"university": 18
}
]
},
{
"name": "Universidade Federal De Rio De Janeiro",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 19,
"univCampus": [
{
"id": 19,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal De Rio De Janeiro",
"comment": null,
"lat": "-22.245954",
"lon": "-42.523287",
"city": 17,
"university": 19
}
]
},
{
"name": "Escola Politecnica Da Universidade De Sao Paulo",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 20,
"univCampus": [
{
"id": 20,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Escola Politecnica Da Universidade De Sao Paulo",
"comment": null,
"lat": "-23.555211",
"lon": "-46.731040",
"city": 18,
"university": 20
}
]
},
{
"name": "Universidade Federal De Uberlandia",
"acronym": null,
"logo": "http://127.0.0.1:8000/media/path/to/my/default/image.jpg",
"id": 21,
"univCampus": [
{
"id": 21,
"modified_by": null,
"modified_date": null,
"usefull_links": [],
"is_main_campus": true,
"name": "Campus Universidade Federal De Uberlandia",
"comment": null,
"lat": "-18.941683",
"lon": "-48.214870",
"city": 19,