From e7030573775c459fc14b061203fb5c406760b0c8 Mon Sep 17 00:00:00 2001 From: vjrj Date: Thu, 1 Mar 2018 17:10:31 +0100 Subject: [PATCH 001/222] Dup subscriptions not allowed --- imports/api/Subscriptions/methods.js | 4 ++++ .../ui/components/SubscriptionEditor/SubscriptionEditor.js | 4 +++- public/locales/en/common.json | 4 +++- public/locales/es/common.json | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/imports/api/Subscriptions/methods.js b/imports/api/Subscriptions/methods.js index e7e3bef..d3608f0 100644 --- a/imports/api/Subscriptions/methods.js +++ b/imports/api/Subscriptions/methods.js @@ -25,6 +25,10 @@ Meteor.methods({ ...doc }; // console.log(newDoc); + const already = Subscriptions.findOne(newDoc); + if (already) { + throw new Meteor.Error('500', 'on-already-subscribed'); + } return Subscriptions.insert(newDoc); } catch (exception) { console.error(exception); diff --git a/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js b/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js index f846aca..1a36f81 100644 --- a/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js +++ b/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js @@ -35,7 +35,9 @@ class SubscriptionEditor extends React.Component { if (authenticated) { Meteor.call(methodToCall, doc, (error, subscriptionId) => { if (error) { - Bert.alert(error.reason, 'danger'); + if (error.reason && error.reason.reason) { + Bert.alert(t(error.reason.reason), 'danger'); + } } else { const confirmation = existingSubscription ? t('Zona actualizada') : t('Zona añadida'); Bert.alert(confirmation, 'success'); diff --git a/public/locales/en/common.json b/public/locales/en/common.json index e6fd058..e9339bc 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -232,5 +232,7 @@ "Estás subscrito a una zona muy grande": "You are subscribed to a very large area", "Lugar no encontrado": - "Place not found" + "Place not found", + "on-already-subscribed": + "Upppps: You have already subscribed to that zone before" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 7d910b4..2b1b215 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -319,5 +319,7 @@ "Estás subscrito a una zona muy grande": "Estás subscrito a una zona muy grande", "Lugar no encontrado": - "Lugar no encontrado" + "Lugar no encontrado", + "on-already-subscribed": + "Upppps: Ya te habías suscrito a esa zona antes" } From 91c67f0b5f9efc1c73f2b59e41463dc9c88095f2 Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 07:22:19 +0100 Subject: [PATCH 002/222] Don't fit subsunion when adding --- imports/ui/components/SelectionMap/SelectionMap.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/ui/components/SelectionMap/SelectionMap.js b/imports/ui/components/SelectionMap/SelectionMap.js index a621e2e..88889bf 100644 --- a/imports/ui/components/SelectionMap/SelectionMap.js +++ b/imports/ui/components/SelectionMap/SelectionMap.js @@ -42,7 +42,7 @@ class SelectionMap extends Component { zoom: props.zoom || 11, distance: props.distance, draggable: true, - subsFit: true + subsFit: this.props.action !== action.add }; this.getMap = this.getMap.bind(this); @@ -68,11 +68,11 @@ class SelectionMap extends Component { marker: nextMarker, distance: nextProps.distance || this.state.distance }); - this.fit(); + // this.fit(); } componentDidUpdate() { - // this.fit(); + this.fit(); } onFstBtn() { From ceebb5d5ad22f3ca84c933dd7b827fe38143be67 Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 07:36:54 +0100 Subject: [PATCH 003/222] Improved subs messages --- imports/ui/components/DistanceSlider/DistanceSlider.js | 2 +- .../ui/components/SubscriptionEditor/SubscriptionEditor.js | 3 ++- public/locales/en/common.json | 5 +++-- public/locales/es/common.json | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/imports/ui/components/DistanceSlider/DistanceSlider.js b/imports/ui/components/DistanceSlider/DistanceSlider.js index 3647c2e..f5d20f1 100644 --- a/imports/ui/components/DistanceSlider/DistanceSlider.js +++ b/imports/ui/components/DistanceSlider/DistanceSlider.js @@ -54,7 +54,7 @@ class DistanceSlider extends React.Component { render() { return (
-

¿A que distancia a la redonda quieres recibir notificaciones?

+

¿A que distancia a la redonda quieres recibir notificaciones de fuegos?

this.onSubs(state)} /> ); diff --git a/public/locales/en/common.json b/public/locales/en/common.json index e9339bc..de9ba7d 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -78,12 +78,13 @@ "Nuevas notificaciones de {{app}}": "New notifications of {{app}}", "Mis zonas": "My areas", "Nueva zona": "New area", - "Subscribirme a fuegos en este radio": "Subscribe to fires in this radio", + "Suscribirme a fuegos en este radio": "Subscribe to fires in this radio", + "Suscribirme a este radio": "Subscribe to this radio", "Créditos": "Credits", "Escribe aquí un lugar": "Write here a place", "Indícanos la posición de la zona a vigilar (por ej. tu pueblo, una calle, etc):": "Tell us the position of the area to be monitored (eg your town, a street, etc.):", "También puedes seleccionar la zona en el mapa arrastrando el puntero naranja.": "You can also select the area on the map by dragging the orange pointer.", - "¿A que distancia a la redonda quieres recibir notificaciones?": "At what distance around you want to receive notifications?", + "¿A que distancia a la redonda quieres recibir notificaciones de fuegos?": "At what distance around you want to receive fire notifications?", "Pulsa para activar": "Click to activate", "Arrastrar para seleccionar otro punto": "Drag to select another point", "Mapa gris de OpenStreetMap": "Grey map from OpenStreetMap", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 2b1b215..a4fa53f 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -138,12 +138,13 @@ "Suscripción actualizada", "Mis zonas": "Mis zonas", "Nueva zona": "Nueva zona", - "Subscribirme a fuegos en este radio": "Subscribirme a fuegos en este radio", + "Suscribirme a fuegos en este radio": "Suscribirme a fuegos en este radio", + "Suscribirme a este radio": "Suscribirme a este radio", "Créditos": "Créditos", "Escribe aquí un lugar": "Escribe aquí un lugar", "Indícanos la posición de la zona a vigilar (por ej. tu pueblo, una calle, etc):": "Indícanos la posición de la zona a vigilar (por ej. tu pueblo, una calle, etc):", "También puedes seleccionar la zona en el mapa arrastrando el puntero naranja.": "También puedes seleccionar la zona en el mapa arrastrando el puntero naranja.", - "¿A que distancia a la redonda quieres recibir notificaciones?": "¿A que distancia a la redonda quieres recibir notificaciones?", + "¿A que distancia a la redonda quieres recibir notificaciones de fuegos?": "¿A que distancia a la redonda quieres recibir notificaciones de fuegos?", "Pulsa para activar": "Pulsa para activar", "Arrastrar para seleccionar otro punto": "Arrastrar para seleccionar otro punto", "Mapa gris de OpenStreetMap": "Mapa gris de OpenStreetMap", From 3ce7d65bb8b287042b333f8964f5e149e0bcbbe3 Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 09:22:55 +0100 Subject: [PATCH 004/222] Disable btn on action in Subscriptions --- .../components/SelectionMap/SelectionMap.js | 2 ++ .../SubscriptionEditor/SubscriptionEditor.js | 8 ++++++- .../FireSubscription/FireSubscription.js | 21 ++++++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/imports/ui/components/SelectionMap/SelectionMap.js b/imports/ui/components/SelectionMap/SelectionMap.js index 88889bf..d56ee95 100644 --- a/imports/ui/components/SelectionMap/SelectionMap.js +++ b/imports/ui/components/SelectionMap/SelectionMap.js @@ -249,6 +249,7 @@ class SelectionMap extends Component { }
); @@ -114,7 +118,8 @@ FireSubscription.propTypes = { distance: PropTypes.number, focusInput: PropTypes.bool.isRequired, subsBtn: PropTypes.string.isRequired, - onSubs: PropTypes.func.isRequired + onSubs: PropTypes.func.isRequired, + disableFstBtn: PropTypes.bool.isRequired }; export default translate([], { wait: true })(FireSubscription); From 9062012d182ad6e73b244d8af2e0c074d2274bab Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 10:08:13 +0100 Subject: [PATCH 005/222] Unsuscribe translation --- imports/ui/pages/Subscriptions/Subscriptions.js | 3 ++- public/locales/en/common.json | 2 ++ public/locales/es/common.json | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/imports/ui/pages/Subscriptions/Subscriptions.js b/imports/ui/pages/Subscriptions/Subscriptions.js index 765711d..6e7e9b9 100644 --- a/imports/ui/pages/Subscriptions/Subscriptions.js +++ b/imports/ui/pages/Subscriptions/Subscriptions.js @@ -63,7 +63,7 @@ class Subscriptions extends Component { if (error) { Bert.alert(error.reason, 'danger'); } else { - Bert.alert('Subscription deleted!', 'success'); + Bert.alert(t('Desuscrito'), 'success'); if (num === 1) { // it was 1, now deleted this.setState({ action: action.view }); } @@ -110,6 +110,7 @@ class Subscriptions extends Component { loadingSubs={this.props.loading} currentSubs={this.props.subscriptions} onRemove={(id) => { this.handleRemove(id); }} + disableFstBtn={false} /> ) : ); diff --git a/public/locales/en/common.json b/public/locales/en/common.json index de9ba7d..fc0d65a 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -61,6 +61,8 @@ "Todavía sin subscriptiones": "No subscriptions yet", "Suscripción añadida": "Subscription added", "Suscripción actualizada": "Subscription updated", + "Desuscrito": + "Subscription deleted", "Última actualización, {{when}}": "Last updated, {{when}}", "Has iniciado sesión con {{service}} usando la dirección de correo {{email}}.": "You're logged in with {{service}} using the email address {{email}}.", "Uso de Cookies": "Use of Cookies", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index a4fa53f..7320d87 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -136,6 +136,8 @@ "Suscripción añadida", "Suscripción actualizada": "Suscripción actualizada", + "Desuscrito": + "Desuscrito", "Mis zonas": "Mis zonas", "Nueva zona": "Nueva zona", "Suscribirme a fuegos en este radio": "Suscribirme a fuegos en este radio", From 8deaafb96b5d7201141f525d5f1bf95e1479f10a Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 10:08:52 +0100 Subject: [PATCH 006/222] Better error return in subscriptions --- imports/api/Subscriptions/methods.js | 24 +++++++++---------- .../SubscriptionEditor/SubscriptionEditor.js | 6 +++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/imports/api/Subscriptions/methods.js b/imports/api/Subscriptions/methods.js index d3608f0..618ed21 100644 --- a/imports/api/Subscriptions/methods.js +++ b/imports/api/Subscriptions/methods.js @@ -17,21 +17,21 @@ Meteor.methods({ distance: Number }); const type = 'web'; + const newDoc = { + owner: this.userId, + type, + geo: geo(doc), + ...doc + }; + // console.log(newDoc); + const already = Subscriptions.findOne(newDoc); + if (already) { + throw new Meteor.Error('on-already-subscribed', 'The user is already subscribed to this area'); + } try { - const newDoc = { - owner: this.userId, - type, - geo: geo(doc), - ...doc - }; - // console.log(newDoc); - const already = Subscriptions.findOne(newDoc); - if (already) { - throw new Meteor.Error('500', 'on-already-subscribed'); - } return Subscriptions.insert(newDoc); } catch (exception) { - console.error(exception); + // console.error(exception); throw new Meteor.Error('500', exception); } }, diff --git a/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js b/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js index 4a4d4fd..7e48939 100644 --- a/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js +++ b/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js @@ -40,8 +40,10 @@ class SubscriptionEditor extends React.Component { Meteor.call(methodToCall, doc, (error, subscriptionId) => { if (error) { self.setState({ disableFstBtn: false }); - if (error.reason && error.reason.reason) { - Bert.alert(t(error.reason.reason), 'danger'); + if (error.error && error.error === 'on-already-subscribed') { + Bert.alert(t(error.error), 'danger'); + } else if (error.reason) { + Bert.alert(error.reason, 'danger'); } } else { self.setState({ disableFstBtn: false }); From ac33bfa15849166f203ffbce62e70f0993598eea Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 10:38:04 +0100 Subject: [PATCH 007/222] Space in center btn --- imports/ui/components/CenterInMyPosition/CenterInMyPosition.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js index cad75da..6fde995 100644 --- a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js +++ b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js @@ -49,7 +49,7 @@ class CenterInMyPosition extends React.Component { const msg = t('Centrar en tu ubicación'); return ( ); } } From ea8f6fbf5b1d73df261f386a8c1c1029a2d8b570 Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 10:38:45 +0100 Subject: [PATCH 008/222] Disable btn only in authenticated --- imports/ui/components/SubscriptionEditor/SubscriptionEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js b/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js index 7e48939..4654189 100644 --- a/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js +++ b/imports/ui/components/SubscriptionEditor/SubscriptionEditor.js @@ -34,9 +34,9 @@ class SubscriptionEditor extends React.Component { const authenticated = !!Meteor.userId(); const self = this; - self.setState({ disableFstBtn: true }); if (authenticated) { + self.setState({ disableFstBtn: true }); Meteor.call(methodToCall, doc, (error, subscriptionId) => { if (error) { self.setState({ disableFstBtn: false }); From f17fd13c2abaa4eb8d95fb4a83bb55323b6d487c Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 10:39:14 +0100 Subject: [PATCH 009/222] Propagate locate state in signup --- imports/ui/pages/Signup/Signup.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imports/ui/pages/Signup/Signup.js b/imports/ui/pages/Signup/Signup.js index d89af19..2dbe15b 100644 --- a/imports/ui/pages/Signup/Signup.js +++ b/imports/ui/pages/Signup/Signup.js @@ -89,7 +89,8 @@ class Signup extends React.Component { } else { Meteor.call('users.sendVerificationEmail'); Bert.alert(t('Bienvenid@!'), 'success'); - history.push('/subscriptions'); + // Already done in Public.js with state (for add) + // history.push('/subscriptions'); } }); } From 38b47698066805cda6b9a73a5772edd7f4ab719e Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 2 Mar 2018 12:53:03 +0100 Subject: [PATCH 010/222] Added subscriptions cancel --- imports/ui/components/SelectionMap/SelectionMap.js | 2 +- .../SubscriptionEditor/SubscriptionEditor.js | 1 + .../ui/pages/FireSubscription/FireSubscription.js | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/imports/ui/components/SelectionMap/SelectionMap.js b/imports/ui/components/SelectionMap/SelectionMap.js index d56ee95..2908c39 100644 --- a/imports/ui/components/SelectionMap/SelectionMap.js +++ b/imports/ui/components/SelectionMap/SelectionMap.js @@ -244,7 +244,7 @@ class SelectionMap extends Component { bsStyle="warning" onClick={event => this.onSndBtn(event)} > - {this.props.sndBtn} + {this.props.sndBtn.match(/^fa-/) ? : this.props.sndBtn } } @@ -117,11 +118,11 @@ class Feedback extends Component { id="feedback-tab" onClick={(event) => { this.onTabClick(event); }} > - {this.t('Feedback')} + {t('Feedback')} } - + ); } } @@ -133,7 +134,7 @@ Feedback.propTypes = { isHome: PropTypes.bool.isRequired }; -export default translate([], { wait: true })(withTracker(props => ({ +export default translate()(withTracker(props => ({ emailAddress: props.emailAddress, emailVerified: props.emailVerified, isHome: isHome() From 337931b6c2ea26aa0e5efe2b603ec67f3839c009 Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 11:38:09 +0100 Subject: [PATCH 018/222] Updated i18next --- package-lock.json | 30 ++++++++++++++---------------- package.json | 6 +++--- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 848df6c..e92a4dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4903,6 +4903,11 @@ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==" }, + "hoist-non-react-statics": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.3.1.tgz", + "integrity": "sha1-ND24TGAYxlB3iJgkATWhQg7iLOA=" + }, "home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", @@ -4990,9 +4995,9 @@ } }, "i18next": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-10.2.1.tgz", - "integrity": "sha512-7h/ILxepsAjQCMabPvevDZcn+Nxc4/5v52NkMtrzgVOe14BGlGQDs2ygRPki+45VFmRsz2e/In6veRIKQEBGkQ==" + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-10.5.0.tgz", + "integrity": "sha512-soHpHN/J8fpkt6z3mEsvO5Uf4huBLk1gYpwK7GwRJOBCJz6Zq4LgMjJ5pr8Lz0+lVwyzKW3zun7+C4pS4LZJ6Q==" }, "i18next-browser-languagedetector": { "version": "2.1.0", @@ -5049,9 +5054,9 @@ } }, "i18next-xhr-backend": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/i18next-xhr-backend/-/i18next-xhr-backend-1.5.0.tgz", - "integrity": "sha1-/uSugDh5uCS++GWnfW62FkqNYfE=" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/i18next-xhr-backend/-/i18next-xhr-backend-1.5.1.tgz", + "integrity": "sha512-9OLdC/9YxDvTFcgsH5t2BHCODHEotHCa6h7Ly0EUlUC7Y2GS09UeoHOGj3gWKQ3HCqXz8NlH4gOrK3NNc9vPuw==" }, "iconv-lite": { "version": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.17.tgz", @@ -10333,20 +10338,13 @@ } }, "react-i18next": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-7.1.1.tgz", - "integrity": "sha1-T7XLTvf3rU/HfMKY6Sln0H1t7nU=", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-7.4.0.tgz", + "integrity": "sha1-B6M25J/I8lmdCBNtcxNOPcSDC0k=", "requires": { "hoist-non-react-statics": "2.3.1", "html-parse-stringify2": "2.0.1", "prop-types": "15.6.0" - }, - "dependencies": { - "hoist-non-react-statics": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.3.1.tgz", - "integrity": "sha1-ND24TGAYxlB3iJgkATWhQg7iLOA=" - } } }, "react-leaflet": { diff --git a/package.json b/package.json index 153add9..dc4abab 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,11 @@ "handlebars": "^4.0.11", "history": "^4.7.2", "html5-device-mockups": "^3.2.0", - "i18next": "^10.0.7", + "i18next": "^10.5.0", "i18next-browser-languagedetector": "^2.1.0", "i18next-localstorage-cache": "^1.1.1", "i18next-sync-fs-backend": "^1.0.0", - "i18next-xhr-backend": "^1.5.0", + "i18next-xhr-backend": "^1.5.1", "immutability-helper": "^2.5.1", "indexof": "0.0.1", "iron": "^5.0.4", @@ -60,7 +60,7 @@ "react-confirm": "^0.1.16", "react-dom": "^16.0.0", "react-helmet": "^5.2.0", - "react-i18next": "^7.1.1", + "react-i18next": "^7.4.0", "react-leaflet": "^1.8.0", "react-leaflet-control": "^1.4.0", "react-leaflet-fullscreen": "0.0.6", From cbc3d07f4a4593adbcff085e79beed63e642b5eb Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 11:38:49 +0100 Subject: [PATCH 019/222] Removed fragment in SubsMap --- imports/ui/pages/Subscriptions/SubscriptionsMap.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/ui/pages/Subscriptions/SubscriptionsMap.js b/imports/ui/pages/Subscriptions/SubscriptionsMap.js index f71cd5c..a7e7ab2 100644 --- a/imports/ui/pages/Subscriptions/SubscriptionsMap.js +++ b/imports/ui/pages/Subscriptions/SubscriptionsMap.js @@ -2,7 +2,7 @@ /* eslint-disable react/jsx-indent-props */ /* eslint-disable react/jsx-indent */ -import React, { Fragment } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import { Button, ButtonGroup, Row, Col } from 'react-bootstrap'; import { Meteor } from 'meteor/meteor'; @@ -95,7 +95,7 @@ class SubscriptionsMap extends React.Component { const title = `${t('AppName')}: ${t('Zonas vigiladas')}`; console.log(`Rendering Subs users ready ${this.props.subsready} viewport: ${JSON.stringify(this.state.viewport)}`); return ( - +
{ !isHome() && {title} @@ -152,7 +152,7 @@ class SubscriptionsMap extends React.Component { { !isHome() && } - +
); } } From e175762c4e16913b491339b681b62f4216f601cc Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 11:41:12 +0100 Subject: [PATCH 020/222] ZonesMap refactor --- imports/ui/pages/ZonesMap/ZonesMap.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/imports/ui/pages/ZonesMap/ZonesMap.js b/imports/ui/pages/ZonesMap/ZonesMap.js index 1ad2cad..8b3955a 100644 --- a/imports/ui/pages/ZonesMap/ZonesMap.js +++ b/imports/ui/pages/ZonesMap/ZonesMap.js @@ -1,26 +1,28 @@ +/* eslint-disable react/jsx-indent-props */ /* eslint-disable import/no-absolute-path */ -import React, { Fragment } from 'react'; -import PropTypes from 'prop-types'; -import { translate } from 'react-i18next'; +/* eslint-disable import/no-absolute-path */ + +import React, { Component } from 'react'; import SubscriptionsMap from '/imports/ui/pages/Subscriptions/SubscriptionsMap'; -class ZonesMap extends React.Component { +export default class ZonesMap extends Component { constructor(props) { super(props); - this.t = props.t; + this.state = { + }; } render() { return ( - +
- +
); } } ZonesMap.propTypes = { - history: PropTypes.object.isRequired }; -export default translate([], { wait: true })(ZonesMap); +ZonesMap.defaultProps = { +}; From dfd31e69ca4c2caafb8668870359f37ab7825d16 Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 11:41:43 +0100 Subject: [PATCH 021/222] Refactor App for better ErrorHandling when i18next is not ready --- .../components/ErrorBoundary/ErrorBoundary.js | 31 ++-- imports/ui/layouts/App/App.js | 145 +++++++++--------- 2 files changed, 93 insertions(+), 83 deletions(-) diff --git a/imports/ui/components/ErrorBoundary/ErrorBoundary.js b/imports/ui/components/ErrorBoundary/ErrorBoundary.js index 1e0c654..a6676ec 100644 --- a/imports/ui/components/ErrorBoundary/ErrorBoundary.js +++ b/imports/ui/components/ErrorBoundary/ErrorBoundary.js @@ -4,9 +4,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { translate } from 'react-i18next'; import { Row, Col } from 'react-bootstrap'; -import { withTracker } from 'meteor/react-meteor-data'; import ravenLogger from '/imports/startup/client/ravenLogger'; import './ErrorBoundary.scss'; @@ -14,7 +12,6 @@ import './ErrorBoundary.scss'; class ErrorBoundary extends Component { constructor(props) { super(props); - this.t = props.t; this.state = { hasError: false }; } @@ -29,33 +26,41 @@ class ErrorBoundary extends Component { } render() { + const { + appName, title, subTitle, children + } = this.props; if (this.state.hasError) { // You can render any custom fallback UI return (
-

{this.t('AppNameFull')}

-

{this.t('general-error-title')}

-

- {this.t('general-error-description')} -

+

{appName}

+

{title}

+

{subTitle}

); } - return this.props.children; + return children; } } ErrorBoundary.propTypes = { - t: PropTypes.func.isRequired + appName: PropTypes.string, + title: PropTypes.string, + subTitle: PropTypes.string, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node + ]).isRequired }; ErrorBoundary.defaultProps = { + appName: 'All Against Fire!', + title: 'Upppps: Something has gone wrong', + subTitle: 'We are investigating the problem, try again in a while' }; -export default translate([], { wait: true })(withTracker(props => ({ - // props.something -}))(ErrorBoundary)); +export default ErrorBoundary; diff --git a/imports/ui/layouts/App/App.js b/imports/ui/layouts/App/App.js index c8fd5fd..52a57ca 100644 --- a/imports/ui/layouts/App/App.js +++ b/imports/ui/layouts/App/App.js @@ -37,16 +37,16 @@ import VerifyEmail from '../../pages/VerifyEmail/VerifyEmail'; import RecoverPassword from '../../pages/RecoverPassword/RecoverPassword'; import ResetPassword from '../../pages/ResetPassword/ResetPassword'; import Profile from '../../pages/Profile/Profile'; -import NotFound from '../../pages/NotFound/NotFound'; -import FiresMap from '../../pages/FiresMap/FiresMap'; import Fires from '../../pages/Fires/Fires'; import Sandbox from '../../pages/Sandbox/Sandbox'; +import ZonesMap from '../../pages/ZonesMap/ZonesMap'; +import FiresMap from '../../pages/FiresMap/FiresMap'; +import NotFound from '../../pages/NotFound/NotFound'; import Terms from '../../pages/Terms/Terms'; import About from '../../pages/About/About'; import Privacy from '../../pages/Privacy/Privacy'; import License from '../../pages/License/License'; import Credits from '../../pages/Credits/Credits'; -import ZonesMap from '../../pages/ZonesMap/ZonesMap'; import Footer from '../../components/Footer/Footer'; import Feedback from '../../components/Feedback/Feedback'; import ReSendEmail from '../../components/ReSendEmail/ReSendEmail'; @@ -57,9 +57,6 @@ import './App.scss'; class LocationListener extends Component { // https://stackoverflow.com/questions/43512450/react-router-v4-route-onchange-event - static contextTypes = { - router: PropTypes.object - }; componentDidMount() { this.handleLocationChange(this.context.router.history.location); @@ -75,82 +72,90 @@ class LocationListener extends Component { // your staff here console.log(`----- location: '${location.pathname}'`); Meteor.Piwik.trackPage(location.pathname); - // Meteor.isReadyForSpiderable = true; } + // https://stackoverflow.com/questions/39133797/react-only-return-props-children render() { return this.props.children; } } +LocationListener.contextTypes = { + router: PropTypes.object +}; + +LocationListener.propTypes = { + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node + ]).isRequired +}; + const App = props => ( /* https://react.i18next.com/components/i18nextprovider.html */ - - - - - { !props.loading ? -
- - - {i18n.t('AppName')} - - - - - - +
+ {props.i18nReady.get() && + + + + + + { !props.loading && +
+ + + {i18n.t('AppName')} + + + + + + - - - - {/* - - - - */} - - - - - - - {/* */} - - - - - - - - - - - {/* } /> */} + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - -
- - - {props.i18nReady.get() && - - } -
: ''} -
-
-
-
+ + + + + + + + + + + + +
+ + + {props.i18nReady.get() && } +
} + + + + + } +
); App.defaultProps = { From 965a80fb3fbb658c293e60d4e576a497956a89ae Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 11:43:17 +0100 Subject: [PATCH 022/222] ie9 gfys --- imports/startup/client/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/imports/startup/client/index.js b/imports/startup/client/index.js index ccebfda..6cff432 100644 --- a/imports/startup/client/index.js +++ b/imports/startup/client/index.js @@ -5,4 +5,8 @@ import App from '../../ui/layouts/App/App'; import '../../ui/stylesheets/app.scss'; -Meteor.startup(() => render(, document.getElementById('react-root'))); +// https://stackoverflow.com/questions/19562207/jquery-detect-browser-ie9-and-below-and-throw-up-a-modal-to-upgrade +const isIE9OrBelow = () => /MSIE\s/.test(navigator.userAgent) && parseFloat(navigator.appVersion.split('MSIE')[1]) < 10; + +if (isIE9OrBelow()) window.alert('You are using an outdated browser. Please use Chrome or Firefox to display this site.'); +else Meteor.startup(() => render(, document.getElementById('react-root'))); From 815bbb48fe3e7d9f337af53d6174b40ec52ce48a Mon Sep 17 00:00:00 2001 From: vjrj Date: Sun, 4 Mar 2018 10:44:26 +0100 Subject: [PATCH 023/222] Added opacity to maps --- imports/ui/components/Maps/DefMapLayers.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/imports/ui/components/Maps/DefMapLayers.js b/imports/ui/components/Maps/DefMapLayers.js index 33da655..0db329c 100644 --- a/imports/ui/components/Maps/DefMapLayers.js +++ b/imports/ui/components/Maps/DefMapLayers.js @@ -11,6 +11,8 @@ import { TileLayer, LayersControl } from 'react-leaflet'; const { BaseLayer } = LayersControl; +const defOpacity = 0.7; + class DefMapLayers extends Component { constructor(props) { super(props); @@ -31,6 +33,7 @@ class DefMapLayers extends Component { const osmgraylayer = ( @@ -38,6 +41,7 @@ class DefMapLayers extends Component { const osmlayer = ( @@ -49,15 +53,15 @@ class DefMapLayers extends Component { {/* React.Fragment does not work here */} { this.state.gkey && - + } { this.state.gkey && - + } { this.state.gkey && - + } ); From 2e09100bdcb6a1ff0d00fd5d1c607f11f327be48 Mon Sep 17 00:00:00 2001 From: vjrj Date: Sun, 4 Mar 2018 10:55:14 +0100 Subject: [PATCH 024/222] Cancel btn in SelectionMap only in subscriptions. Added title --- imports/ui/components/SelectionMap/SelectionMap.js | 5 ++++- imports/ui/pages/FireSubscription/FireSubscription.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/imports/ui/components/SelectionMap/SelectionMap.js b/imports/ui/components/SelectionMap/SelectionMap.js index 2908c39..0d0f30d 100644 --- a/imports/ui/components/SelectionMap/SelectionMap.js +++ b/imports/ui/components/SelectionMap/SelectionMap.js @@ -242,6 +242,7 @@ class SelectionMap extends Component { { this.props.sndBtn && this.props.onSndBtn &&