From 1e9e870df8dff8f04f492f193210baf628184159 Mon Sep 17 00:00:00 2001 From: vjrj Date: Thu, 22 Feb 2018 11:23:18 +0100 Subject: [PATCH 001/248] Minor fixes in about --- private/pages/about-en.md | 4 +++- private/pages/about-es.md | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/private/pages/about-en.md b/private/pages/about-en.md index e683d48..6c34fe2 100644 --- a/private/pages/about-en.md +++ b/private/pages/about-en.md @@ -21,6 +21,8 @@ We also maintain an archive as documentation of the fires. There, those affected In such a difficult climate, in which the last thing we have to do is emit more CO2, we believe that we must take more legal measures before reaching this point where certain people profit from fires and other people like us, we have to shut them down. -You can participate in this initiative, from helping to monitor your area, spreanding the word about this initiative among your contacts, helping to translate these tools into your language, contributing ideas or developing them, and/or helping to pay for the [expenses of our servers](https://comunes.org/donate). You can contact us if you have more questions at [fires@comunes.org](mailto:fires@comunes.org). +**They also ask us, why do we develop something like this if it does not enrich us [sic]. Maybe that's exactly the problem, that what enriches some is to burn what belongs to everyone. And who cares what is of everyone?** + +You can participate in this initiative, from helping to monitor your area, spreanding the word about this initiative among your contacts, [helping to translate](https://translate.comunes.org/projects/todos-contra-el-fuego/) these tools into your language, contributing ideas or developing them, and/or helping to pay for the [expenses of our servers](https://comunes.org/donate). You can contact us if you have more questions at [fires@comunes.org](mailto:fires@comunes.org). Thank you, diff --git a/private/pages/about-es.md b/private/pages/about-es.md index b10a471..d879457 100644 --- a/private/pages/about-es.md +++ b/private/pages/about-es.md @@ -11,7 +11,7 @@ Estos fuegos intencionados son comunes en España, de donde surge esta iniciativ Los incendiarios son más conscientes que nadie de este colapso y lo utilizan para que sus fuegos sean más efectivos. Como los avisos de fuegos no se comunican a las personas dispuestas a actuar o en peligro, la indefensión es total. -**En la orografía quebrada de nuestra zona, un fuego te gana la espalda y no te enteras. Así que la detección tempranay pública de fuegos es crucial, más cuando tenemos pocos medios para combatirlos.** +**En la orografía quebrada de nuestra zona, un fuego te gana la espalda y no te enteras. Así que la detección temprana y pública de fuegos es crucial, más cuando tenemos pocos medios para combatirlos.** Imaginamos que existen herramientas digitales de este tipo que gestionan los servicios de emergencia, pero no son públicos, por lo menos no aquí. Por eso nos animamos a desarrollar estas herramientas. @@ -21,6 +21,8 @@ También mantenemos un archivo documental de los fuegos en el que los afectados En un momento climático tan difícil, en el que lo último que tenemos que hacer es emitir más CO2, creemos que hay que tomar más medidas legales antes de llegar a este punto en el que ciertas personas se lucran de los incendios y otras personas como nosotras tengamos que andar apagándolos. -Puedes participar en esta iniciativa, desde ayudando a vigilar tu zona, difundiendo esta iniciativa entre tus contactos, ayudando a traducir estas herramientas a tu idioma, aportando ideas o desarrollándolas, y/o ayudando a costear los gastos de [nuestros servidores](https://comunes.org/donate). Puedes contactarnos si tienes más dudas en [fuegos@comunes.org](mailto:fuegos@comunes.org). +**También nos preguntan, porqué desarrollamos algo así si no nos enriquece [sic]. Quizás ese es exactamente el problema, que lo que enriquece a algunos es quemar lo que es de tod@s. ¿Y quien cuida lo que es de tod@s?** + +Puedes participar en esta iniciativa, desde ayudando a vigilar tu zona, difundiendo esta iniciativa entre tus contactos, [ayudando a traducir](https://translate.comunes.org/projects/todos-contra-el-fuego/) estas herramientas a tu idioma, aportando ideas o desarrollándolas, y/o ayudando a costear los gastos de [nuestros servidores](https://comunes.org/donate). Puedes contactarnos si tienes más dudas en [fuegos@comunes.org](mailto:fuegos@comunes.org). Gracias, From c90ed5f1d8734ceb0f58ff6f0bbacae37d91942c Mon Sep 17 00:00:00 2001 From: SergioEstan <36745969+SergioEstan@users.noreply.github.com> Date: Thu, 22 Feb 2018 22:17:23 +0100 Subject: [PATCH 002/248] Update about-en.md --- private/pages/about-en.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/private/pages/about-en.md b/private/pages/about-en.md index 6c34fe2..580c9db 100644 --- a/private/pages/about-en.md +++ b/private/pages/about-en.md @@ -1,4 +1,4 @@ -We are neighbors who at some point have been forced to put out intentional fires in the forest of our town, or we had to pack our bags because the fire surrounded our houses, or the fire has devastated our farms, or that simply this affects us. +We are neighbors who at some point have been forced to put out intentional fires in the forest of our town, or we had to pack our bags because the fire surrounded our houses, or the fire has devastated our farms, or that this simply affects us.
@@ -7,21 +7,21 @@ We are neighbors who at some point have been forced to put out intentional fires These intentional fires are common in Spain, where this initiative comes from. And this happens because not everyone is against forest fires: there are many [interests and motivations](http://www.naturalezacantabrica.es/2015/12/el-infierno-en-asturies-quien-quema-el.html), more than you can [imagine](http://ctxt.es/es/20170906/Politica/14827/ctxt-incendios-corrupci%C3%B3n-portugal-Avialsa-Faasa.htm). -**In the north of Spain, usually humid, when the weather conditions are favorable, the arson fires multiply. This situation sometimes causes that emergency services become collapsed and can not go to all the [fires](https://elpais.com/elpais/2017/10/17/inenglish/1508231214_008450.html). So the neighbors have no choice but to [organize](https://www.vice.com/en_au/article/bjvwgv/photos-of-galicians-fighting-wildfires-together) themself.** +**In the north of Spain, usually humid, when the weather conditions are favorable, the arson fires multiply. This situation sometimes causes the emergency services to collapse and so they cannot turn up to all of the [fires](https://elpais.com/elpais/2017/10/17/inenglish/1508231214_008450.html). So the neighbors have no choice but to [organize](https://www.vice.com/en_au/article/bjvwgv/photos-of-galicians-fighting-wildfires-together) themself.** -The arsonists handle the same saturation so that their fires are more effective, and since the information that is sent from the individuals to the emergency services is not reverted to people willing to act or in danger, the defenselessness is total. +The arsonists are conscious of these saturations, so their fires are very effective. The information that is sent from different individuals to the emergency services is not announced to people willing to act nor to those that are in danger, they are completely defenceless. **In the broken orography of our area, a fire can reach your back quite quickly. So the early and public detection of fires is crucial, especially when we have little means to combat them.** -We imagine that there are digital tools of this type that our emergency services manage, but they are not public, at least not here. This encouraged us to develop these tools. +We imagine that there are digital tools of this type that our emergency services use, but they are not public, at least not here. This encouraged us to develop these tools. -In addition, according to friends from other latitudes, these problems happen in their countries also, so we have translated and shared with everyone as Free Software [these tools](https://github.com/comunes/todos-contra-el-fuego). +In addition, according to friends from other latitudes, these problems also take place in their countries, so we have translated it and shared it with everyone as Free Software [these tools](https://github.com/comunes/todos-contra-el-fuego). -We also maintain an archive as documentation of the fires. There, those affected by fire can provide information and thus help, for example, to investigate the causes of each fire. And we are developing more tools of this type. +We also maintain an archive of the documentation of the fires. There, those who have been affected by fires can provide information and thus help, for example, to investigate the causes of each fire. We are also developing more tools of this type. -In such a difficult climate, in which the last thing we have to do is emit more CO2, we believe that we must take more legal measures before reaching this point where certain people profit from fires and other people like us, we have to shut them down. +In such a difficult climate, in which the last thing we have to do is emit more CO2, we believe that we must take more legal measures before reaching this point where certain people profit from fires and other people like us, have to shut them down. -**They also ask us, why do we develop something like this if it does not enrich us [sic]. Maybe that's exactly the problem, that what enriches some is to burn what belongs to everyone. And who cares what is of everyone?** +**They also ask us, why do we develop something like this if it does not enrich us [sic]. Maybe that's exactly the problem, that what enriches some people is to burn what belongs to everyone. And who cares about what is of everyone?** You can participate in this initiative, from helping to monitor your area, spreanding the word about this initiative among your contacts, [helping to translate](https://translate.comunes.org/projects/todos-contra-el-fuego/) these tools into your language, contributing ideas or developing them, and/or helping to pay for the [expenses of our servers](https://comunes.org/donate). You can contact us if you have more questions at [fires@comunes.org](mailto:fires@comunes.org). From 5e9e6896c060fa2d5cc8e95dcde859608faf59f2 Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 23 Feb 2018 17:02:54 +0100 Subject: [PATCH 003/248] Fire icon sizes --- designs/icons-tcef.svg | 6 +++--- imports/ui/components/Maps/FireIconMark.js | 15 +++++++++++++-- imports/ui/components/Maps/Icons.js | 18 ++++++++++++++++++ public/fire-marker-l.png | Bin 0 -> 720 bytes public/fire-marker-m.png | Bin 0 -> 542 bytes public/fire-marker-s.png | Bin 0 -> 399 bytes 6 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 public/fire-marker-l.png create mode 100644 public/fire-marker-m.png create mode 100644 public/fire-marker-s.png diff --git a/designs/icons-tcef.svg b/designs/icons-tcef.svg index fd3a447..8bfd7f1 100644 --- a/designs/icons-tcef.svg +++ b/designs/icons-tcef.svg @@ -338,9 +338,9 @@ + inkscape:export-filename="/mnt/md1/proyectos/dev/todos-contra-el-fuego-web/public/fire-marker-s.png" + inkscape:export-xdpi="2" + inkscape:export-ydpi="2"> { !falsePositives && - + } { falsePositives && @@ -54,6 +64,7 @@ FireIconMark.propTypes = { // https://github.com/PaulLeCam/react-leaflet/tree/master/src/propTypes lat: PropTypes.number.isRequired, lon: PropTypes.number.isRequired, + scan: PropTypes.number, nasa: PropTypes.bool, falsePositives: PropTypes.bool.isRequired, id: PropTypes.object.isRequired, diff --git a/imports/ui/components/Maps/Icons.js b/imports/ui/components/Maps/Icons.js index 2c04886..7b9ecdb 100644 --- a/imports/ui/components/Maps/Icons.js +++ b/imports/ui/components/Maps/Icons.js @@ -12,6 +12,24 @@ export const fireIcon = new Leaflet.Icon({ * popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor */ }); +export const fireIconL = new Leaflet.Icon({ + iconUrl: '/fire-marker-l.png', + iconSize: [16, 24], + iconAnchor: [8, 26] +}); + +export const fireIconM = new Leaflet.Icon({ + iconUrl: '/fire-marker-m.png', + iconSize: [12, 17], + iconAnchor: [6, 19] +}); + +export const fireIconS = new Leaflet.Icon({ + iconUrl: '/fire-marker-s.png', + iconSize: [8, 12], + iconAnchor: [4, 14] +}); + export const industryIcon = new Leaflet.Icon({ iconUrl: '/industry-marker.png', iconSize: [32, 37], diff --git a/public/fire-marker-l.png b/public/fire-marker-l.png new file mode 100644 index 0000000000000000000000000000000000000000..0a20859bd5b6ccf70d71556b7a8b9b0b0b9957da GIT binary patch literal 720 zcmV;>0x$iEP)LoK~y-6jg(JFR8bVhfA`MQ8Ar*Pd1K-bRJaf{X{D1)wvDJw zPzn7RDyXQ9ZE7JwEyINnE&2mdYi$uh1VJt`R7wPW?}`221f`{5kmES|PK$JydCi;V ztnNAA`M&d=dwCCh!rDr+9pm!oHfsEO0JI;_KF=qBEg9ZhCMU~@_{JavY?DdbL~N6X z6A8i%fDJ^mHi8u+u+?is$z(_j z+#{S!d7+SY8mJ3shJb{h&qz-iRUITTa36Hh)`oUndIefa5tU)kaP>No<7WT}wzLvX z?k#LtG&J;xhZu-NsXuapX!<;%*7hPSoJ_Gi_G&ZzU5}YYRW}XK@+Q!0cur(vvPr23Q^+`Ade$U5kuqgr|8&!C+Z( z_T3E2Z^r=8a7BUW)oSjd_z94CGwMs0T#j#jz2LeixYM@4a2~Yc9JEbVou;6y%vjWHo02&({qe?Ve-aJNOS{{>NJJ8t=aV0000ugK~yM_jge1C6k!;~f8V#Q>*gP1W-iH=vKi7!;btbZ6d`!u zlj6~f-4dchNaqL--GUTv;tC-iJ4qcPDFPSVnTa*JNx_z*2)oqM_;%Q4UB_MMxqZ){ z_kF(agAiUp#4&j2THFY0E#X>RuuVMMUZuUN&+He62`DnslE=SOmhF7Etv{`5t;~gGGcK z&;}42OohAN(EtU5+tCO+C}taVYwq#skRquZgOn&f0-dM!cXc!H-ofAh!PoH-5CN!Y zU?FUd58tGJW0Poag7#}^&W~jRsiZ}5H#l`?C%OD~o8;yv;_1=)fY{(r?Fxc>u0C~S zjEhTapwE7d@BOURgmtap13*XSUQ_dNrA+zV8-QIrRyFVpkl#i3j2WQx^a=jqK~;pA zA*cdSFnQou>W{awECKvVS-#KDiDPo;nq*I2_8)AMQBgdKU%fsNz0?=`Rmc~s-}Z9t g$1Gj(I0}4!0ZUzmJ!*|3C;$Ke07*qoM6N<$f)=pqAOHXW literal 0 HcmV?d00001 diff --git a/public/fire-marker-s.png b/public/fire-marker-s.png new file mode 100644 index 0000000000000000000000000000000000000000..954e689873640c23b19cd2d09c5077af603c3594 GIT binary patch literal 399 zcmeAS@N?(olHy`uVBq!ia0vp^96-#&!3HGb=lz)rq*#ibJVQ8upoSx*1IXtr@Q5r1 z(*7XKnB4XEI*=h*;u=vBoS#-wo>-L1P+nfHmzkGcoSayYs+V7sKKq@G6axbzkEe@c zh{V*=3AWyc6GU3)tLRSUyZX%6Ri%TKTPdjE^@TjA3kMzV$jGpi|8H2`F?;p9rrpgy zm_@kCUd-lN>uTMxV|(4P@4Hk~`R09`S8Zo8!6_nT?b;hp>^W}SS}IyKC$@n(VY$4H zLBto=8?m1(`tnzH2pK26V6Jp9FqzZxW~YeK4wh4$3sVD2lAe08Tz4?FHt(N1`#?_{ z!@9eHYq}n?tzbw=ul;lR^N|X!wHaBhEtmUvwwXW4{-B|xwD;GhjHBLc5d~b6r>xIA z87g+X)p*@;b(7o$v)7ycoAB&!Z+{uLwBL&<5%0tPzDPF_5fn6ZoA>>@i+0~JuD3!q qEL(S9KivF&`Pv6@+GQ&DUWjKD#b?}f-YEwRJO)o!KbLh*2~7a$ji9># literal 0 HcmV?d00001 From a8dc8a6b58aec4dd9a48263f5084ec7190d4b344 Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 23 Feb 2018 17:11:45 +0100 Subject: [PATCH 004/248] More accurate firemap legend --- imports/ui/pages/FiresMap/FiresMap.js | 4 +++- public/locales/en/common.json | 3 ++- public/locales/es/common.json | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index 1d26eb7..849ffe5 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -207,8 +207,10 @@ class FiresMap extends React.Component { En rojo, {{ count: this.props.activefires.length + this.props.firealerts.length }} fuegos activos en el mapa. Hay un total de {{ countTotal: this.props.activefirestotal }} fuegos activos detectados en todo el mundo por la NASA. Datos actualizados . }

- {isNotHomeAndMobile && + {isNotHomeAndMobile && this.props.firealerts.length > 0 &&

En naranja, los fuegos notificados por nuestros usuarios/as recientemente.

} + {isNotHomeAndMobile && this.props.firealerts.length === 0 && +

No hay fuegos notificados recientemente por nuestros usuarios/as en esta zona.

} {isNotHomeAndMobile && diff --git a/public/locales/en/common.json b/public/locales/en/common.json index ad31218..f8c1571 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -216,5 +216,6 @@ "Sobre '{{appName}}'": "About '{{appName}}'", "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?": - "Neighborhoods monitoring and fighting fires? What is all this about?" + "Neighborhoods monitoring and fighting fires? What is all this about?", + "noActiveNeigFireInMap": "There are no fires recently reported by our users in this area." } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index cec8929..73025d7 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -303,5 +303,6 @@ "Sobre '{{appName}}'": "Sobre '{{appName}}'", "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?": - "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?" + "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?", + "noActiveNeigFireInMap": "No hay fuegos notificados recientemente por nuestros usuarios/as en esta zona." } From 1ad6bf17cb47af8be6ef82bc27e2ace7d300e29c Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 23 Feb 2018 17:50:38 +0100 Subject: [PATCH 005/248] Def scan for neighbors alerts --- imports/api/FalsePositives/server/publications.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imports/api/FalsePositives/server/publications.js b/imports/api/FalsePositives/server/publications.js index 18305c4..69ab992 100644 --- a/imports/api/FalsePositives/server/publications.js +++ b/imports/api/FalsePositives/server/publications.js @@ -18,7 +18,8 @@ Meteor.publish('falsePositivesTotal', function total() { export const whichAreFalsePositives = (fires) => { const group = new L.FeatureGroup(); const remap = fires.fetch().map(function remap(doc) { - return { location: { lat: doc.lat, lon: doc.lon }, distance: doc.scan }; + // default scan: 1 for neightbor alerts + return { location: { lat: doc.lat, lon: doc.lon }, distance: doc.scan || 1 }; }); const result = calcUnion(remap, group, sub => sub); From ccbfe642a854fca7bf3b705f0c86871ece6d4d6f Mon Sep 17 00:00:00 2001 From: vjrj Date: Mon, 26 Feb 2018 12:11:23 +0100 Subject: [PATCH 006/248] Added industries collection --- bin/eu-eea-e-prtr.awk | 14 +++++ bin/us-epa-frs.awk | 10 ++++ .../api/ActiveFires/server/publications.js | 10 ++-- .../api/FalsePositives/server/publications.js | 43 ++++++++-------- imports/api/Fires/server/publications.js | 11 ++-- imports/api/Industries/Industries.js | 39 ++++++++++++++ imports/api/Industries/IndustryRegistries.js | 29 +++++++++++ imports/startup/server/migrations.js | 18 +++++++ imports/ui/components/Maps/FireCircleMark.js | 48 ++++++++++++------ imports/ui/components/Maps/FireIconMark.js | 26 +++++++--- imports/ui/components/Maps/FireList.js | 9 ++-- imports/ui/components/Maps/Icons.js | 6 +++ imports/ui/components/Maps/MarkListeners.js | 4 ++ imports/ui/layouts/App/App.js | 3 +- imports/ui/pages/Fires/Fires.js | 20 +++++++- imports/ui/pages/FiresMap/FiresMap.js | 37 +++++++++++++- public/industry-marker-reg.png | Bin 0 -> 360 bytes public/locales/en/common.json | 4 +- public/locales/es/common.json | 4 +- 19 files changed, 277 insertions(+), 58 deletions(-) create mode 100755 bin/eu-eea-e-prtr.awk create mode 100755 bin/us-epa-frs.awk create mode 100644 imports/api/Industries/Industries.js create mode 100644 imports/api/Industries/IndustryRegistries.js create mode 100644 imports/ui/components/Maps/MarkListeners.js create mode 100644 public/industry-marker-reg.png diff --git a/bin/eu-eea-e-prtr.awk b/bin/eu-eea-e-prtr.awk new file mode 100755 index 0000000..afaa839 --- /dev/null +++ b/bin/eu-eea-e-prtr.awk @@ -0,0 +1,14 @@ +# cat dbo.PUBLISH_FACILITYREPORT.csv| ./eu-eea-e-prtr.awk | mongoimport -d "fuegos" -c "industries" + +gawk -F',' 'NR>1 { \ + gsub(/"/,"",$6); + gsub(/"/,"",$5); + gsub(/\t/,"",$6); + gsub(/\t/,"",$5); + gsub(/\x1a/,"",$5); + gsub(/\x1a/,"",$6); + lon = $14+0; + lat = $13+0; + if (lon != 0 && lat != 0 && lon > -180 && lon < 180 && lat >= -90 && lat <= 90) + printf("{name:\"%s, %s\",geo:{type:\"Point\",coordinates:[%s,%s]},registry:\"1\"}\n" \ + ,$6,$5,lon,lat)}' diff --git a/bin/us-epa-frs.awk b/bin/us-epa-frs.awk new file mode 100755 index 0000000..56aec61 --- /dev/null +++ b/bin/us-epa-frs.awk @@ -0,0 +1,10 @@ +# cat NATIONAL_SINGLE.CSV| ./us-epa-frs.awk | mongoimport -d "fuegos" -c "industries" + +gawk -F',' 'NR>1{ \ + gsub(/"/,"",$33); + gsub(/"/,"",$32); + gsub(/"/,"",$3); + gsub(/\t/,"",$3); + lon = $33+0; + lat = $32+0; + if (lon != 0 && lat != 0 && lon > -180 && lon < 180 && lat >= -90 && lat <= 90) { printf("{name:\"%s\",geo:{type:\"Point\",coordinates:[%s,%s]},registry:\"2\"}\n",name,lon,lat)}}' diff --git a/imports/api/ActiveFires/server/publications.js b/imports/api/ActiveFires/server/publications.js index 6fd66eb..c6de899 100644 --- a/imports/api/ActiveFires/server/publications.js +++ b/imports/api/ActiveFires/server/publications.js @@ -5,7 +5,9 @@ import { Meteor } from 'meteor/meteor'; import { check } from 'meteor/check'; import { NumberBetween } from '/imports/modules/server/other-checks'; -import { whichAreFalsePositives } from '/imports/api/FalsePositives/server/publications'; +import { whichAreFalsePositives, firesUnion } from '/imports/api/FalsePositives/server/publications'; +import FalsePositives from '/imports/api/FalsePositives/FalsePositives'; +import Industries from '/imports/api/Industries/Industries'; import ActiveFires from '../ActiveFires'; const counter = new Counter('countActiveFires', ActiveFires.find({})); @@ -37,8 +39,10 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit // console.log(`Fires total: ${fires.count()}`); if (withMarks && fires.fetch().length > 0) { - const falsePos = whichAreFalsePositives(fires); - return [fires, falsePos]; + const union = firesUnion(fires); + const falsePos = whichAreFalsePositives(FalsePositives, union); + const industries = whichAreFalsePositives(Industries, union); + return [fires, falsePos, industries]; } return fires; diff --git a/imports/api/FalsePositives/server/publications.js b/imports/api/FalsePositives/server/publications.js index 69ab992..659c2d4 100644 --- a/imports/api/FalsePositives/server/publications.js +++ b/imports/api/FalsePositives/server/publications.js @@ -7,6 +7,7 @@ import { check } from 'meteor/check'; import { NumberBetween } from '/imports/modules/server/other-checks'; import L from 'leaflet-headless'; import calcUnion from '/imports/ui/components/Maps/SubsUnion/Unify'; +import Industries from '/imports/api/Industries/Industries'; import FalsePositives from '../FalsePositives'; const counter = new Counter('countFalsePositives', FalsePositives.find({})); @@ -15,18 +16,21 @@ Meteor.publish('falsePositivesTotal', function total() { return counter; }); -export const whichAreFalsePositives = (fires) => { +export const firesUnion = (fires) => { const group = new L.FeatureGroup(); const remap = fires.fetch().map(function remap(doc) { // default scan: 1 for neightbor alerts return { location: { lat: doc.lat, lon: doc.lon }, distance: doc.scan || 1 }; }); - const result = calcUnion(remap, group, sub => sub); + const union = calcUnion(remap, group, sub => sub); + return union; +}; - const falsePos = FalsePositives.find({ +export const whichAreFalsePositives = (collection, union) => { + const result = collection.find({ geo: { $geoWithin: { - $geometry: result[0].geometry + $geometry: union[0].geometry } } }, { @@ -40,11 +44,11 @@ export const whichAreFalsePositives = (fires) => { /* console.log(`False positive total: ${falsePos.count()}`); console.log(`False positives: ${JSON.stringify(falsePos.fetch())}`); */ - return falsePos; + return result; }; -const falsePositives = (northEastLng, northEastLat, southWestLng, southWestLat) => { - const fires = FalsePositives.find({ +const find = (collection, northEastLng, northEastLat, southWestLng, southWestLat) => { + const fires = collection.find({ geo: { $geoWithin: { $box: [ @@ -60,19 +64,6 @@ const falsePositives = (northEastLng, northEastLat, southWestLng, southWestLat) // when: 1, fireId: 1 } - }).serverTransform(function transformDoc(odoc) { - const doc = odoc; - // Destructuring gives me an error: "Cannot destructure property `geo` of 'undefined'" - const geo = doc.geo; - if (geo) { - doc.lat = geo.coordinates[1]; - doc.lon = geo.coordinates[0]; - } - doc._id = doc.fireId; - doc.id = doc.fireId; - delete doc.geo; - // console.log(doc); - return doc; }); // console.log(`Fires total: ${fires.count()}`); return fires; @@ -85,5 +76,15 @@ Meteor.publishTransformed('falsePositivesMyloc', function falsePositivesInMyLoc( check(southWestLng, NumberBetween(-180, 180)); check(northEastLat, NumberBetween(-90, 90)); - return falsePositives(northEastLng, northEastLat, southWestLng, southWestLat); + return find(FalsePositives, northEastLng, northEastLat, southWestLng, southWestLat); +}); + +Meteor.publishTransformed('industriesMyloc', function industriesInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat) { + // latitude -90 and 90 and the longitude between -180 and 180 + check(northEastLng, NumberBetween(-180, 180)); + check(southWestLat, NumberBetween(-90, 90)); + check(southWestLng, NumberBetween(-180, 180)); + check(northEastLat, NumberBetween(-90, 90)); + + return find(Industries, northEastLng, northEastLat, southWestLng, southWestLat); }); diff --git a/imports/api/Fires/server/publications.js b/imports/api/Fires/server/publications.js index 1dba8dc..96d6a85 100644 --- a/imports/api/Fires/server/publications.js +++ b/imports/api/Fires/server/publications.js @@ -9,7 +9,10 @@ import NodeGeocoder from 'node-geocoder'; import { gmapServerKey } from '/imports/startup/server/IPGeocoder'; import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires'; import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts'; -import { whichAreFalsePositives } from '/imports/api/FalsePositives/server/publications'; +import { whichAreFalsePositives, firesUnion } from '/imports/api/FalsePositives/server/publications'; +import FalsePositives from '/imports/api/FalsePositives/FalsePositives'; +import Industries from '/imports/api/Industries/Industries'; + import FiresCollection from '../Fires'; function findFire(unsealed) { @@ -115,8 +118,10 @@ Meteor.publish('fireFromId', function fireFromId(_id) { const fire = FiresCollection.find(new Meteor.Collection.ObjectID(_id)); if (fire.count() !== 0) { // console.info(`Archive fire found: ${_id}`); - const falsePos = whichAreFalsePositives(fire); - return [fire, falsePos]; + const union = firesUnion(fire); + const falsePos = whichAreFalsePositives(FalsePositives, union); + const industries = whichAreFalsePositives(Industries, union); + return [fire, falsePos, industries]; } console.info(`Fire not found: ${_id}`); // Not found in active fires! diff --git a/imports/api/Industries/Industries.js b/imports/api/Industries/Industries.js new file mode 100644 index 0000000..f77ab9d --- /dev/null +++ b/imports/api/Industries/Industries.js @@ -0,0 +1,39 @@ +/* eslint-disable consistent-return */ + +import { Mongo } from 'meteor/mongo'; +import SimpleSchema from 'simpl-schema'; +import LocationSchema from '/imports/api/Utility/LocationSchema.js'; + +const Industries = new Mongo.Collection('industries'); + +Industries.allow({ + insert: () => false, + update: () => false, + remove: () => false +}); + +Industries.deny({ + insert: () => true, + update: () => true, + remove: () => true +}); + +Industries.schema = new SimpleSchema({ + geo: LocationSchema, + name: { type: String, optional: true }, + registry: String +}); + +Industries.attachSchema(Industries.schema); + +export const industriesRemap = (odoc) => { + const doc = odoc; + const geo = doc.geo; + doc.lat = geo.coordinates[1]; + doc.lon = geo.coordinates[0]; + doc.id = doc._id; + delete doc.geo; + return doc; +}; + +export default Industries; diff --git a/imports/api/Industries/IndustryRegistries.js b/imports/api/Industries/IndustryRegistries.js new file mode 100644 index 0000000..5eec43b --- /dev/null +++ b/imports/api/Industries/IndustryRegistries.js @@ -0,0 +1,29 @@ +/* eslint-disable consistent-return */ + +import { Mongo } from 'meteor/mongo'; +import SimpleSchema from 'simpl-schema'; + +const IndustryRegistries = new Mongo.Collection('industryregistries', { idGeneration: 'MONGO' }); + +IndustryRegistries.allow({ + insert: () => false, + update: () => false, + remove: () => false +}); + +IndustryRegistries.deny({ + insert: () => true, + update: () => true, + remove: () => true +}); + +IndustryRegistries.schema = new SimpleSchema({ + name: String, + agency: String, + region: String + +}); + +IndustryRegistries.attachSchema(IndustryRegistries.schema); + +export default IndustryRegistries; diff --git a/imports/startup/server/migrations.js b/imports/startup/server/migrations.js index f420f82..3f77de7 100644 --- a/imports/startup/server/migrations.js +++ b/imports/startup/server/migrations.js @@ -7,6 +7,8 @@ import UserSubsToFiresCollection from '/imports/api/Subscriptions/Subscriptions' import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts'; import SiteSettings from '/imports/api/SiteSettings/SiteSettings'; import FalsePositives from '/imports/api/FalsePositives/FalsePositives'; +import Industries from '/imports/api/Industries/Industries'; +import IndustryRegistries from '/imports/api/Industries/IndustryRegistries'; Meteor.startup(() => { // https://github.com/percolatestudio/meteor-migrations @@ -127,6 +129,22 @@ Meteor.startup(() => { } }); + Migrations.add({ + version: 9, + up: function siteSettingsAddIndex() { + Industries._ensureIndex({ registry: 1 }); + Industries._ensureIndex({ geo: '2dsphere' }); + // https://www.eea.europa.eu/data-and-maps/data/member-states-reporting-art-7-under-the-european-pollutant-release-and-transfer-register-e-prtr-regulation-16 + IndustryRegistries.insert({ + _id: '1', name: 'E-PRTR', agency: 'EEA', region: 'EU' + }); + // https://www.epa.gov/enviro/epa-frs-facilities-state-single-file-csv-download + IndustryRegistries.insert({ + _id: '2', name: 'FRS', agency: 'EPA', region: 'US' + }); + } + }); + // Set createdAt in users & subs Migrations.migrateTo('latest'); diff --git a/imports/ui/components/Maps/FireCircleMark.js b/imports/ui/components/Maps/FireCircleMark.js index d90e312..e4a3460 100644 --- a/imports/ui/components/Maps/FireCircleMark.js +++ b/imports/ui/components/Maps/FireCircleMark.js @@ -1,22 +1,40 @@ -import React from 'react'; +import React, { Component } from 'react'; import { Circle } from 'react-leaflet'; import PropTypes from 'prop-types'; +import { onMarkClick } from './MarkListeners'; import FirePopup from './FirePopup'; -const FireCircleMark = ({ - lat, - lon, - nasa, - scan, - id, - when, - history, - t -}) => ( - - - -); + +class FireCircleMark extends Component { + constructor(props) { + super(props); + this.t = props.t; + this.onClick = this.onClick.bind(this); + } + + onClick() { + const { history, nasa, id } = this.props; + onMarkClick(history, nasa, id); + } + + render() { + const { + lat, + lon, + scan, + nasa, + id, + history, + when, + t + } = this.props; + return ( + + + + ); + } +} FireCircleMark.propTypes = { scan: PropTypes.number.isRequired, diff --git a/imports/ui/components/Maps/FireIconMark.js b/imports/ui/components/Maps/FireIconMark.js index 9de93b2..4f9ab4c 100644 --- a/imports/ui/components/Maps/FireIconMark.js +++ b/imports/ui/components/Maps/FireIconMark.js @@ -2,7 +2,8 @@ import React, { Component, Fragment } from 'react'; import { CircleMarker, Marker, Tooltip } from 'react-leaflet'; import PropTypes from 'prop-types'; -import { fireIconS, fireIconM, fireIconL, nFireIcon, industryIcon } from '/imports/ui/components/Maps/Icons'; +import { fireIconS, fireIconM, fireIconL, nFireIcon, industryIcon, regIndustryIcon } from '/imports/ui/components/Maps/Icons'; +import { onMarkClick } from './MarkListeners'; import { translate } from 'react-i18next'; import FirePopup from './FirePopup'; @@ -14,8 +15,8 @@ class FireIconMark extends Component { } onClick() { - // console.log('onClick fired'); - this.props.history.push(`/fire/${this.props.nasa ? 'active' : 'alert'}/${this.props.id}`); + const { history, nasa, id } = this.props; + onMarkClick(history, nasa, id); } // Some docs: @@ -36,22 +37,34 @@ class FireIconMark extends Component { id, history, falsePositives, + industries, when, t } = this.props; return (
- { !falsePositives && + { !falsePositives && !industries && } - { falsePositives && + { industries && + {t('Es una industria (fuente: registro oficial)')} + } + { /* disabled */ industries && false && } + { falsePositives && !industries && {t('Es una industria')} { /* disabled because was a past fire (and can be marked multiple times) */ false && } } - { !falsePositives && + { !falsePositives && !industries && } @@ -67,6 +80,7 @@ FireIconMark.propTypes = { scan: PropTypes.number, nasa: PropTypes.bool, falsePositives: PropTypes.bool.isRequired, + industries: PropTypes.bool.isRequired, id: PropTypes.object.isRequired, history: PropTypes.object.isRequired, when: PropTypes.instanceOf(Date), diff --git a/imports/ui/components/Maps/FireList.js b/imports/ui/components/Maps/FireList.js index ecf22f1..a5979d7 100644 --- a/imports/ui/components/Maps/FireList.js +++ b/imports/ui/components/Maps/FireList.js @@ -9,17 +9,17 @@ import FirePixel from '/imports/ui/components/Maps/FirePixel'; export default function FireList(props) { const { - fires, scale, useMarkers, nasa, t, history, falsePositives + fires, scale, useMarkers, nasa, t, history, falsePositives, industries } = props; const useMarks = useMarkers && scale; const usePixel = !nasa || !scale; /* console.log(`Using marks: ${useMarks}, using pixels: ${usePixel}`); */ let items; if (useMarks) { - items = fires.map(({ _id, ...otherProps }) => ()); - } else if (usePixel && !falsePositives) { + items = fires.map(({ _id, ...otherProps }) => ()); + } else if (usePixel && !falsePositives && !industries) { items = fires.map(({ _id, ...otherProps }) => ()); - } else if (!falsePositives) { + } else if (!falsePositives && !industries) { items = fires.map(({ _id, ...otherProps }) => ()); } return (
{items}
); @@ -31,6 +31,7 @@ FireList.propTypes = { useMarkers: PropTypes.bool.isRequired, nasa: PropTypes.bool.isRequired, falsePositives: PropTypes.bool.isRequired, + industries: PropTypes.bool.isRequired, history: PropTypes.object.isRequired, t: PropTypes.func.isRequired }; diff --git a/imports/ui/components/Maps/Icons.js b/imports/ui/components/Maps/Icons.js index 7b9ecdb..95adf71 100644 --- a/imports/ui/components/Maps/Icons.js +++ b/imports/ui/components/Maps/Icons.js @@ -36,6 +36,12 @@ export const industryIcon = new Leaflet.Icon({ iconAnchor: [16, 20] }); +export const regIndustryIcon = new Leaflet.Icon({ + iconUrl: '/industry-marker-reg.png', + iconSize: [32, 37], + iconAnchor: [16, 20] +}); + export const nFireIcon = new Leaflet.Icon({ iconUrl: '/n-fire-marker.png', iconSize: [16, 24], // size of the icon diff --git a/imports/ui/components/Maps/MarkListeners.js b/imports/ui/components/Maps/MarkListeners.js new file mode 100644 index 0000000..5a85b44 --- /dev/null +++ b/imports/ui/components/Maps/MarkListeners.js @@ -0,0 +1,4 @@ +export const onMarkClick = (history, nasa, id) => { + // console.log('onClick fired'); + history.push(`/fire/${nasa ? 'active' : 'alert'}/${id}`); +}; diff --git a/imports/ui/layouts/App/App.js b/imports/ui/layouts/App/App.js index 4011296..c8fd5fd 100644 --- a/imports/ui/layouts/App/App.js +++ b/imports/ui/layouts/App/App.js @@ -115,7 +115,8 @@ const App = props => ( - + {/* */} + diff --git a/imports/ui/pages/Fires/Fires.js b/imports/ui/pages/Fires/Fires.js index 5662a3c..6c3f528 100644 --- a/imports/ui/pages/Fires/Fires.js +++ b/imports/ui/pages/Fires/Fires.js @@ -21,6 +21,7 @@ import { dateLongFormat } from '/imports/api/Common/dates'; import '/imports/startup/client/comments'; import FalsePositiveTypes from '/imports/api/FalsePositives/FalsePositiveTypes'; import FalsePositivesCollection, { falsePositivesRemap } from '/imports/api/FalsePositives/FalsePositives'; +import IndustriesCollection, { industriesRemap } from '/imports/api/Industries/Industries'; import ShareIt from '/imports/ui/components/ShareIt/ShareIt'; import './Fires.scss'; @@ -76,6 +77,7 @@ class Fire extends React.Component { notfound, loading, fire, t } = this.props; if (Meteor.isDevelopment) console.log(`False positives total: ${this.props.falsePositives.length}`); + if (Meteor.isDevelopment) console.log(`Industries total: ${this.props.industries.length}`); /* console.log(`loading fire: ${loading}`); * console.log(`Not found fire: ${notfound}`); */ if (fire && fire.when) { @@ -109,7 +111,7 @@ class Fire extends React.Component { fillColor="red" fillOpacity={0.0} interactive={false} - radius={fire.scan ? fire.scan * 1000 : 300} + radius={fire.scan ? fire.scan * 500 : 300} ref={(circle) => { this.circle = circle; this.handleLeafletLoad(circle); }} /> @@ -121,6 +123,17 @@ class Fire extends React.Component { useMarkers nasa={false} falsePositives + industries={false} + /> + @@ -136,7 +149,7 @@ class Fire extends React.Component { {(fire.type !== 'vecinal') && - { this.props.falsePositives.length > 0 && + { (this.props.falsePositives.length > 0 || this.props.industries.length > 0) && Parece que este fuego no es un fuego forestal. @@ -196,6 +209,7 @@ Fire.propTypes = { loading: PropTypes.bool.isRequired, notfound: PropTypes.bool.isRequired, falsePositives: PropTypes.arrayOf(PropTypes.object).isRequired, + industries: PropTypes.arrayOf(PropTypes.object).isRequired, fromHash: PropTypes.bool.isRequired, active: PropTypes.bool.isRequired, alert: PropTypes.bool.isRequired, @@ -236,12 +250,14 @@ const FireContainer = withTracker(({ match }) => { /* console.log(`loading fire: ${loading}`); * console.log(`Not found fire: ${notfound}`); */ const falsePositives = FalsePositivesCollection.find().fetch().map(falsePositivesRemap); + const industries = IndustriesCollection.find().fetch().map(industriesRemap); return { loading, active, alert, fromHash, falsePositives, + industries, fire: FiresCollection.findOne(), notfound, when: subscription.ready() && FiresCollection.findOne() ? FiresCollection.findOne().when : null diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index 849ffe5..865b29c 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -27,6 +27,7 @@ import DefMapLayers from '/imports/ui/components/Maps/DefMapLayers'; import FromNow from '/imports/ui/components/FromNow/FromNow'; import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires'; import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts'; +import IndustriesCollection, { industriesRemap } from '/imports/api/Industries/Industries'; import FalsePositivesCollection, { falsePositivesRemap } from '/imports/api/FalsePositives/FalsePositives'; import SiteSettings from '/imports/api/SiteSettings/SiteSettings'; import { isNotHomeAndMobile, isChrome } from '/imports/ui/components/Utils/isMobile'; @@ -187,6 +188,8 @@ class FiresMap extends React.Component { if (Meteor.isDevelopment) console.log(`False positives total: ${this.props.falsePositives.length}`); + if (Meteor.isDevelopment) console.log(`Industries total: ${this.props.industries.length}`); + return ( /* Large number of markers: https://stackoverflow.com/questions/43015854/large-dataset-of-markers-or-dots-in-leaflet/43019740#43019740 */ @@ -270,6 +273,17 @@ class FiresMap extends React.Component { useMarkers={this.state.useMarkers} nasa={false} falsePositives + industries={false} + /> + = MAXZOOM} + useMarkers={this.state.useMarkers} + nasa={false} + falsePositives={false} + industries /> } @@ -318,6 +334,7 @@ FiresMap.propTypes = { activefires: PropTypes.arrayOf(PropTypes.object).isRequired, firealerts: PropTypes.arrayOf(PropTypes.object).isRequired, falsePositives: PropTypes.arrayOf(PropTypes.object).isRequired, + industries: PropTypes.arrayOf(PropTypes.object).isRequired, lastCheck: PropTypes.instanceOf(Date), activefirestotal: PropTypes.number.isRequired, center: PropTypes.arrayOf(PropTypes.number), @@ -331,6 +348,10 @@ FiresMap.propTypes = { let geoInit = true; export default translate([], { wait: true })(withTracker(() => { + // const firesType = match.params.type; + // const withIndustries = firesType === 'with-industries'; + // console.log(`With industries: ${withIndustries}`); + let subscription; let alertSubscription; @@ -339,6 +360,7 @@ export default translate([], { wait: true })(withTracker(() => { const marksStored = store.get('firesmap_marks'); const showUnionStored = store.get('firesmap_showunion'); zoom.set(zoomStored || 8); + center.set(centerStored || [0, 0]); if (typeof marksStored === 'boolean') { marks.set(marksStored); } @@ -346,7 +368,7 @@ export default translate([], { wait: true })(withTracker(() => { showUnion.set(showUnionStored); } Meteor.autorun(() => { - if ((centerStored || geolocation.get()) && geoInit) { + if ((centerStored !== [0, 0] || geolocation.get()) && geoInit) { center.set(centerStored || geolocation.get()); // console.log(`Geolocation ${geolocation.get()}`); geoInit = false; @@ -367,16 +389,28 @@ export default translate([], { wait: true })(withTracker(() => { mapSize.get()[1].lng, mapSize.get()[1].lat ); + /* if (withIndustries) { + Meteor.subscribe( + 'industriesMyloc', + mapSize.get()[0].lng, + mapSize.get()[0].lat, + mapSize.get()[1].lng, + mapSize.get()[1].lat + ); + } */ } }); Meteor.subscribe('activefirestotal'); + const settingsSubs = Meteor.subscribe('settings'); const lastCheck = SiteSettings.findOne({ name: 'last-fire-check' }); const userSubs = SiteSettings.findOne({ name: 'subs-public-union' }); const userSubsBounds = SiteSettings.findOne({ name: 'subs-public-union-bounds' }); const fireAlerts = FireAlertsCollection.find().fetch(); const falsePositives = FalsePositivesCollection.find().fetch().map(falsePositivesRemap); + const industries = IndustriesCollection.find().fetch().map(industriesRemap); + return { loading: !subscription ? true : !(subscription.ready() && settingsSubs.ready() && alertSubscription.ready()), userSubs: userSubs ? userSubs.value : null, @@ -387,6 +421,7 @@ export default translate([], { wait: true })(withTracker(() => { activefirestotal: Counter.get('countActiveFires') + fireAlerts.length, firealerts: fireAlerts, falsePositives, + industries, lastCheck: lastCheck ? lastCheck.value : null, center: center.get(), marks: marks.get(), diff --git a/public/industry-marker-reg.png b/public/industry-marker-reg.png new file mode 100644 index 0000000000000000000000000000000000000000..a73f6a00698288320bc130e796af772b1f5955a2 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^3P7yN!3HFix4(7=Qk(@Ik;M!Q+`=Ht$S`Y;1Oo%3 zl&6bhNJMLLf&}a01d*PmKm#tfgBlVE2Ryi){{w;iQ6V?CIo}K}9%AGHg3nvcjLuxY zna`!iw+5|Nr%@nkJzKfojkH1L=5qZ?*q_=L63{YPLKTqKz<2?bO&i`2}7~N(&@fpO-D~|4JY;1gZ`?b7Hx9>KCIrD3pdqDzE zZ*B)$I%jTy>~zZ;suCYkoM)W=E sCI(Wh%yO*F)+{Ts1n0S(Ji*3r=J19sKVKNu1A~si)78&qol`;+0FRiQ6951J literal 0 HcmV?d00001 diff --git a/public/locales/en/common.json b/public/locales/en/common.json index f8c1571..c1a927d 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -217,5 +217,7 @@ "About '{{appName}}'", "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?": "Neighborhoods monitoring and fighting fires? What is all this about?", - "noActiveNeigFireInMap": "There are no fires recently reported by our users in this area." + "noActiveNeigFireInMap": "There are no fires recently reported by our users in this area.", + "Es una industria (fuente: registro oficial)": + "It's an industry (source: oficial register)" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 73025d7..2b6eeaf 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -304,5 +304,7 @@ "Sobre '{{appName}}'", "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?": "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?", - "noActiveNeigFireInMap": "No hay fuegos notificados recientemente por nuestros usuarios/as en esta zona." + "noActiveNeigFireInMap": "No hay fuegos notificados recientemente por nuestros usuarios/as en esta zona.", + "Es una industria (fuente: registro oficial)": + "Es una industria (fuente: registro oficial)" } From 1df41f1e5abe604475142d45260aba269f0fa343 Mon Sep 17 00:00:00 2001 From: vjrj Date: Mon, 26 Feb 2018 16:36:52 +0100 Subject: [PATCH 007/248] Industry message changed --- imports/ui/components/Maps/FireIconMark.js | 2 +- public/locales/en/common.json | 2 +- public/locales/es/common.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/imports/ui/components/Maps/FireIconMark.js b/imports/ui/components/Maps/FireIconMark.js index 4f9ab4c..7199aa4 100644 --- a/imports/ui/components/Maps/FireIconMark.js +++ b/imports/ui/components/Maps/FireIconMark.js @@ -60,7 +60,7 @@ class FireIconMark extends Component { />} { falsePositives && !industries && - {t('Es una industria')} + {t('Es una industria (fuente: nuestros usuarios/as)')} { /* disabled because was a past fire (and can be marked multiple times) */ false && } } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index c1a927d..7cb6a28 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -180,7 +180,7 @@ "¿No es un fuego forestal?": "Isn't that a forest fire?", "Regístrate o inicia sesión para aportar información sobre este fuego": "Sign up or login to provide information about this fire", "Fuego no encontrado": "Fire not found", - "Es una industria": "It's an industry", + "Es una industria (fuente: nuestros usuarios/as)": "It's an industry (source: our users)", "Es una quema controlada": "It's a controlled burning", "Parece una falsa alarma": "It seems a false alarm", "Fuegos activos en el mundo actualizados en tiempo real": "Active fires in the world updated in real time", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 2b6eeaf..8700443 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -243,8 +243,8 @@ "Regístrate o inicia sesión para aportar información sobre este fuego", "Fuego no encontrado": "Fuego no encontrado", - "Es una industria": - "Es una industria", + "Es una industria (fuente: nuestros usuarios/as)": + "Es una industria (fuente: nuestros usuarios/as)", "Es una quema controlada": "Es una quema controlada", "Parece una falsa alarma": From 1cf2a6883ad7ad4af31b15ed8aecd5f02a75674a Mon Sep 17 00:00:00 2001 From: vjrj Date: Mon, 26 Feb 2018 20:11:41 +0100 Subject: [PATCH 008/248] Fix some file fallback retrieval for some langs. Added tests --- imports/api/Utility/server/files.js | 5 ++-- test/file.test.js | 40 +++++++++++++++++++++++++++++ test/siteSettings.test.js | 6 +++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 test/file.test.js diff --git a/imports/api/Utility/server/files.js b/imports/api/Utility/server/files.js index fe800f8..ceb0fc9 100644 --- a/imports/api/Utility/server/files.js +++ b/imports/api/Utility/server/files.js @@ -3,13 +3,14 @@ import fs from 'fs'; const as = f => `assets/app/${f}`; export const getFallbackLang = (lang) => { - if (lang === 'ast' || lang === 'gl' || lang === 'eu' || lang === 'ca') { + if (lang === 'ast' || lang === 'gl' || lang === 'eu' || lang === 'ca' || + (lang && lang.match(/es_.*/)) || + (lang && lang.match(/es-.*/))) { return 'es'; } return 'en'; }; - export const getFileNameOfLang = (dir, fileName, ext, lang) => { const base = `${dir}/${fileName}`; const fallback = getFallbackLang(lang); diff --git a/test/file.test.js b/test/file.test.js new file mode 100644 index 0000000..90f3cd7 --- /dev/null +++ b/test/file.test.js @@ -0,0 +1,40 @@ +/* eslint-env mocha */ +/* eslint-disable func-names, prefer-arrow-callback */ +/* eslint-disable import/no-absolute-path */ + +import { chai } from 'meteor/practicalmeteor:chai'; +import { getFileNameOfLang } from '/imports/api/Utility/server/files.js'; + +describe('get file of page', () => { + it('lang es retrieve es', async () => { + chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'es')); + }); + + it('lang en retrieve en', async () => { + chai.expect('pages/about-en.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'en')); + }); + + it('lang gl retrieve es', async () => { + chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'gl')); + }); + + it('lang ast retrieve es', async () => { + chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'gl')); + }); + + it('lang eu retrieve es', async () => { + chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'eu')); + }); + + it('lang ca retrieve es', async () => { + chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'ca')); + }); + + it('lang es-PE retrieve es', async () => { + chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'es-PE')); + }); + + it('lang es_PE retrieve es', async () => { + chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'es_PE')); + }); +}); diff --git a/test/siteSettings.test.js b/test/siteSettings.test.js index a2b3888..64b8ef1 100644 --- a/test/siteSettings.test.js +++ b/test/siteSettings.test.js @@ -10,6 +10,7 @@ const setting = { name: 'site-test', value: 'Some value', description: 'Some description', + isPublic: true, type: 'string' }; @@ -19,6 +20,11 @@ describe('site settings store', () => { }); it('should insert settings', () => { + // Remove previous test register + const alreadyInserted = SiteSettings.findOne({ name: 'site-test' }); + if (alreadyInserted) { + SiteSettings.remove(alreadyInserted._id); + } const id = SiteSettings.insert(setting); SiteSettings.getSchema(setting.type).validate(setting); From 2fe2412e73373d85b389b4e84bb0ed2f3c67c047 Mon Sep 17 00:00:00 2001 From: vjrj Date: Mon, 26 Feb 2018 20:30:23 +0100 Subject: [PATCH 009/248] Some comments --- imports/api/Industries/Industries.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imports/api/Industries/Industries.js b/imports/api/Industries/Industries.js index f77ab9d..d6aba72 100644 --- a/imports/api/Industries/Industries.js +++ b/imports/api/Industries/Industries.js @@ -6,6 +6,10 @@ import LocationSchema from '/imports/api/Utility/LocationSchema.js'; const Industries = new Mongo.Collection('industries'); +// For now using: +// https://www.eea.europa.eu/data-and-maps/data/member-states-reporting-art-7-under-the-european-pollutant-release-and-transfer-register-e-prtr-regulation-16 +// https://www.epa.gov/enviro/epa-frs-facilities-state-single-file-csv-download + Industries.allow({ insert: () => false, update: () => false, From f5d43dba764dbb527b7e17e48deb159d5d754066 Mon Sep 17 00:00:00 2001 From: vjrj Date: Mon, 26 Feb 2018 20:30:46 +0100 Subject: [PATCH 010/248] Removed duplicated code --- imports/api/Utility/server/files.js | 10 +--------- imports/startup/server/accounts/lang-fallback.js | 2 +- test/file.test.js | 4 ---- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/imports/api/Utility/server/files.js b/imports/api/Utility/server/files.js index ceb0fc9..717f19f 100644 --- a/imports/api/Utility/server/files.js +++ b/imports/api/Utility/server/files.js @@ -1,16 +1,8 @@ import fs from 'fs'; +import getFallbackLang from '/imports/startup/server/accounts/lang-fallback'; const as = f => `assets/app/${f}`; -export const getFallbackLang = (lang) => { - if (lang === 'ast' || lang === 'gl' || lang === 'eu' || lang === 'ca' || - (lang && lang.match(/es_.*/)) || - (lang && lang.match(/es-.*/))) { - return 'es'; - } - return 'en'; -}; - export const getFileNameOfLang = (dir, fileName, ext, lang) => { const base = `${dir}/${fileName}`; const fallback = getFallbackLang(lang); diff --git a/imports/startup/server/accounts/lang-fallback.js b/imports/startup/server/accounts/lang-fallback.js index af96ce5..67fbb66 100644 --- a/imports/startup/server/accounts/lang-fallback.js +++ b/imports/startup/server/accounts/lang-fallback.js @@ -1,5 +1,5 @@ const getFallbackLang = (lang) => { - if (lang && (lang === 'ast' || lang === 'gl' || lang === 'eu' || lang === 'ca' || lang.match(/^es/))) { + if (lang && (lang === 'ast' || lang === 'gl' || lang === 'eu' || lang === 'ca' || lang.match(/^es-/))) { return 'es'; } return 'en'; diff --git a/test/file.test.js b/test/file.test.js index 90f3cd7..d4454fb 100644 --- a/test/file.test.js +++ b/test/file.test.js @@ -33,8 +33,4 @@ describe('get file of page', () => { it('lang es-PE retrieve es', async () => { chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'es-PE')); }); - - it('lang es_PE retrieve es', async () => { - chai.expect('pages/about-es.md').to.deep.equal(getFileNameOfLang('pages', 'about', 'md', 'es_PE')); - }); }); From 73588a67d2dc9da203433f410f5d511a25602bac Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 09:13:53 +0100 Subject: [PATCH 011/248] Limit sitemap list of fires --- imports/startup/server/sitemaps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/startup/server/sitemaps.js b/imports/startup/server/sitemaps.js index 67559a7..c1fe573 100644 --- a/imports/startup/server/sitemaps.js +++ b/imports/startup/server/sitemaps.js @@ -27,7 +27,7 @@ sitemaps.add('/sitemap.xml', () => { }); }); */ - Fires.find().fetch().forEach((fire) => { + Fires.find({}, { limit: 100, sort: { createdAt: -1 } }).fetch().forEach((fire) => { // Search the last comment of tha fire const lastComment = Comments.getCollection().findOne({ referenceId: `fire-${fire._id}` }, { sort: { createdAt: -1 } }); out.push({ From b5620cea46b77034119a0653ae0ae7b388b9ab56 Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 11:08:55 +0100 Subject: [PATCH 012/248] Added progress bar to fires map --- imports/ui/components/Loading/LoadingBar.js | 24 +++++++++++++++++ imports/ui/components/Loading/LoadingBar.scss | 5 ++++ imports/ui/pages/FiresMap/FiresMap.js | 4 +++ package-lock.json | 27 +++++++++++++++++++ package.json | 1 + 5 files changed, 61 insertions(+) create mode 100644 imports/ui/components/Loading/LoadingBar.js create mode 100644 imports/ui/components/Loading/LoadingBar.scss diff --git a/imports/ui/components/Loading/LoadingBar.js b/imports/ui/components/Loading/LoadingBar.js new file mode 100644 index 0000000..943e9a5 --- /dev/null +++ b/imports/ui/components/Loading/LoadingBar.js @@ -0,0 +1,24 @@ +/* eslint-disable react/jsx-indent */ + +import React from 'react'; +import PropTypes from 'prop-types'; +import { Line } from 'react-progressbar.js'; + +import './LoadingBar.scss'; + +// Check: https://github.com/kimmobrunfeldt/react-progressbar.js/pull/26 +const LoadingBar = ({ progress }) => ( +
+ +
+); + +export default LoadingBar; + +LoadingBar.propTypes = { + progress: PropTypes.number.isRequired +}; diff --git a/imports/ui/components/Loading/LoadingBar.scss b/imports/ui/components/Loading/LoadingBar.scss new file mode 100644 index 0000000..a570180 --- /dev/null +++ b/imports/ui/components/Loading/LoadingBar.scss @@ -0,0 +1,5 @@ +.loading-bar { + height: 3px; + overflow: hidden; + margin-top: -3px; +} diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index 865b29c..155f202 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -12,6 +12,7 @@ import { Helmet } from 'react-helmet'; import { Trans, translate } from 'react-i18next'; import { Map } from 'react-leaflet'; import Control from 'react-leaflet-control'; +import LoadingBar from '/imports/ui/components/Loading/LoadingBar'; import _ from 'lodash'; import store from 'store'; import L from 'leaflet'; @@ -235,6 +236,9 @@ class FiresMap extends React.Component {

+ {this.props.loading || !this.props.subsready ? + + : ''} {/* https://github.com/CliffCloud/Leaflet.Sleep */} { diff --git a/package-lock.json b/package-lock.json index 44d1d4c..3b0e2cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7698,6 +7698,11 @@ "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=" }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" + }, "lodash.isfunction": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.8.tgz", @@ -9929,6 +9934,14 @@ "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", "dev": true }, + "progressbar.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/progressbar.js/-/progressbar.js-1.0.1.tgz", + "integrity": "sha1-9/v8GVJA/guzL2972y5/9ADqcfk=", + "requires": { + "shifty": "1.5.4" + } + }, "promise": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", @@ -10412,6 +10425,15 @@ "prop-types": "15.6.0" } }, + "react-progressbar.js": { + "version": "git://github.com/squarecat/react-progressbar.js.git#1ff715a3c9dc0f8089127902824cf13a8907f96f", + "requires": { + "lodash.isequal": "4.5.0", + "progressbar.js": "1.0.1", + "react": "16.2.0", + "react-dom": "16.2.0" + } + }, "react-resize-detector": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/react-resize-detector/-/react-resize-detector-1.1.0.tgz", @@ -11232,6 +11254,11 @@ "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", "dev": true }, + "shifty": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/shifty/-/shifty-1.5.4.tgz", + "integrity": "sha1-1DYvyRTdKA3fblIr5AiyEgMgg0Y=" + }, "signal-exit": { "version": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" diff --git a/package.json b/package.json index 26191ba..5c59245 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "react-leaflet-google": "^3.2.1", "react-leaflet-sidebarv2": "^0.5.1", "react-places-autocomplete": "^5.4.3", + "react-progressbar.js": "git://github.com/squarecat/react-progressbar.js.git", "react-resize-detector": "^1.1.0", "react-router-bootstrap": "^0.24.4", "react-router-dom": "^4.2.2", From dc92574bc3159e4a07911cf714055e8215f4c149 Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 11:37:54 +0100 Subject: [PATCH 013/248] Full screen on maps --- imports/ui/components/Maps/FullScreenMap.js | 28 +++++++++++++++++++ .../components/SelectionMap/SelectionMap.js | 3 ++ imports/ui/pages/Fires/Fires.js | 2 ++ imports/ui/pages/FiresMap/FiresMap.js | 2 ++ .../pages/Subscriptions/SubscriptionsMap.js | 2 ++ package-lock.json | 13 +++++++++ package.json | 1 + public/locales/en/common.json | 6 +++- public/locales/es/common.json | 6 +++- 9 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 imports/ui/components/Maps/FullScreenMap.js diff --git a/imports/ui/components/Maps/FullScreenMap.js b/imports/ui/components/Maps/FullScreenMap.js new file mode 100644 index 0000000..9563037 --- /dev/null +++ b/imports/ui/components/Maps/FullScreenMap.js @@ -0,0 +1,28 @@ +/* eslint-disable react/jsx-indent-props */ +/* eslint-disable import/no-absolute-path */ +/* eslint-disable import/no-absolute-path */ + +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { translate } from 'react-i18next'; +import FullscreenControl from 'react-leaflet-fullscreen'; +import 'react-leaflet-fullscreen/dist/styles.css'; + +class FullScreenMap extends Component { + render() { + const { t } = this.props; + return ( + + ); + } +} + +FullScreenMap.propTypes = { + t: PropTypes.func.isRequired +}; + +export default translate([], { wait: true })(FullScreenMap); diff --git a/imports/ui/components/SelectionMap/SelectionMap.js b/imports/ui/components/SelectionMap/SelectionMap.js index 94c065b..a621e2e 100644 --- a/imports/ui/components/SelectionMap/SelectionMap.js +++ b/imports/ui/components/SelectionMap/SelectionMap.js @@ -23,6 +23,8 @@ import { Row, Col, Button, ButtonGroup } from 'react-bootstrap'; import subsUnion from '/imports/ui/components/Maps/SubsUnion/SubsUnion'; import UserSubsToFiresCollection from '/imports/api/Subscriptions/Subscriptions'; import { isChrome } from '/imports/ui/components/Utils/isMobile'; +import FullScreenMap from '/imports/ui/components/Maps/FullScreenMap'; + import './SelectionMap.scss'; export const action = { @@ -253,6 +255,7 @@ class SelectionMap extends Component { + diff --git a/imports/ui/pages/Fires/Fires.js b/imports/ui/pages/Fires/Fires.js index 6c3f528..e5bf45f 100644 --- a/imports/ui/pages/Fires/Fires.js +++ b/imports/ui/pages/Fires/Fires.js @@ -23,6 +23,7 @@ import FalsePositiveTypes from '/imports/api/FalsePositives/FalsePositiveTypes'; import FalsePositivesCollection, { falsePositivesRemap } from '/imports/api/FalsePositives/FalsePositives'; import IndustriesCollection, { industriesRemap } from '/imports/api/Industries/Industries'; import ShareIt from '/imports/ui/components/ShareIt/ShareIt'; +import FullScreenMap from '/imports/ui/components/Maps/FullScreenMap'; import './Fires.scss'; class Fire extends React.Component { @@ -136,6 +137,7 @@ class Fire extends React.Component { industries /> +

{t('Coordenadas:')} {fire.lat}, {fire.lon}

{(fire.type === 'modis' || fire.type === 'viirs') && diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index 155f202..a65bb88 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -34,6 +34,7 @@ import SiteSettings from '/imports/api/SiteSettings/SiteSettings'; import { isNotHomeAndMobile, isChrome } from '/imports/ui/components/Utils/isMobile'; import { isHome } from '/imports/ui/components/Utils/location'; import ShareIt from '/imports/ui/components/ShareIt/ShareIt'; +import FullScreenMap from '/imports/ui/components/Maps/FullScreenMap'; import './FiresMap.scss'; @@ -316,6 +317,7 @@ class FiresMap extends React.Component { this.centerOnUserLocation(viewport)} onlyIcon {... this.props} /> + diff --git a/imports/ui/pages/Subscriptions/SubscriptionsMap.js b/imports/ui/pages/Subscriptions/SubscriptionsMap.js index 44e2b5d..f71cd5c 100644 --- a/imports/ui/pages/Subscriptions/SubscriptionsMap.js +++ b/imports/ui/pages/Subscriptions/SubscriptionsMap.js @@ -24,6 +24,7 @@ import SiteSettings from '/imports/api/SiteSettings/SiteSettings'; import { isChrome } from '/imports/ui/components/Utils/isMobile'; import { isHome } from '/imports/ui/components/Utils/location'; import ShareIt from '/imports/ui/components/ShareIt/ShareIt'; +import FullScreenMap from '/imports/ui/components/Maps/FullScreenMap'; import './SubscriptionsMap.scss'; @@ -141,6 +142,7 @@ class SubscriptionsMap extends React.Component { + diff --git a/package-lock.json b/package-lock.json index 3b0e2cb..848df6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7535,6 +7535,11 @@ "resolved": "https://registry.npmjs.org/leaflet-sleep/-/leaflet-sleep-0.5.1.tgz", "integrity": "sha1-kfhDPzjtu2uKm3jT0E7HOW6fYPY=" }, + "leaflet.fullscreen": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/leaflet.fullscreen/-/leaflet.fullscreen-1.4.4.tgz", + "integrity": "sha512-HxHDHAQt/Q7nMlo/v3MUhir30GXt4YXIbmyJT53EnnBAyXC6IbKXeCnl2Mlsj6V5kSBwh3J8No6btaBdAz64og==" + }, "leven": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", @@ -10385,6 +10390,14 @@ "prop-types": "15.6.0" } }, + "react-leaflet-fullscreen": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/react-leaflet-fullscreen/-/react-leaflet-fullscreen-0.0.6.tgz", + "integrity": "sha512-YWP58+mgpyAbTPGdMRRWGuHV4GrkThmDRXth7qcVGqBxJTj1Nt4xy2zwOKcEYtfTimiG4lEXS18UQ+5cyuh0FQ==", + "requires": { + "leaflet.fullscreen": "1.4.4" + } + }, "react-leaflet-google": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/react-leaflet-google/-/react-leaflet-google-3.2.1.tgz", diff --git a/package.json b/package.json index 5c59245..153add9 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "react-i18next": "^7.1.1", "react-leaflet": "^1.8.0", "react-leaflet-control": "^1.4.0", + "react-leaflet-fullscreen": "0.0.6", "react-leaflet-google": "^3.2.1", "react-leaflet-sidebarv2": "^0.5.1", "react-places-autocomplete": "^5.4.3", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 7cb6a28..09ac8d8 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -219,5 +219,9 @@ "Neighborhoods monitoring and fighting fires? What is all this about?", "noActiveNeigFireInMap": "There are no fires recently reported by our users in this area.", "Es una industria (fuente: registro oficial)": - "It's an industry (source: oficial register)" + "It's an industry (source: oficial register)", + "Pantalla completa": + "Fullscreen", + "Salir de pantalla completa": + "Exit fullscreen mode" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 8700443..fd3c095 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -306,5 +306,9 @@ "¿Vecindarios vigilando y combatiendo fuegos? ¿de qué va todo esto?", "noActiveNeigFireInMap": "No hay fuegos notificados recientemente por nuestros usuarios/as en esta zona.", "Es una industria (fuente: registro oficial)": - "Es una industria (fuente: registro oficial)" + "Es una industria (fuente: registro oficial)", + "Pantalla completa": + "Pantalla completa", + "Salir de pantalla completa": + "Salir de pantalla completa" } From a3bdcb39828ff73eba45b9fbeff66a7602471bbe Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 16:50:26 +0100 Subject: [PATCH 014/248] Added more industries --- bin/au-dee-npi.awk | 16 ++++++++++++++++ bin/ca-godp-npri.awk | 19 +++++++++++++++++++ imports/api/Industries/Industries.js | 15 +++++++++++++++ imports/startup/server/migrations.js | 13 +++++++++++++ 4 files changed, 63 insertions(+) create mode 100755 bin/au-dee-npi.awk create mode 100755 bin/ca-godp-npri.awk diff --git a/bin/au-dee-npi.awk b/bin/au-dee-npi.awk new file mode 100755 index 0000000..dec11cd --- /dev/null +++ b/bin/au-dee-npi.awk @@ -0,0 +1,16 @@ +# cat file.csv| ./au-dee-npi.awk | mongoimport -d "fuegos" -c "industries" + +gawk -F',' 'NR>1 { \ + gsub(/"/,"",$5); + gsub(/"/,"",$6); + gsub(/\t/,"",$13); + gsub(/\t/,"",$14); + gsub(/\x1a/,"",$13); + gsub(/\x1a/,"",$14); + lon = $14+0; + lat = $13+0; + name= $5", "$6 + gsub(/^, /,"",name); + if (lon != 0 && lat != 0 && lon > -180 && lon < 180 && lat >= -90 && lat <= 90) + printf("{name:\"%s\",geo:{type:\"Point\",coordinates:[%s,%s]},registry:\"4\"}\n" \ + ,name,lon,lat)}' diff --git a/bin/ca-godp-npri.awk b/bin/ca-godp-npri.awk new file mode 100755 index 0000000..e618ec6 --- /dev/null +++ b/bin/ca-godp-npri.awk @@ -0,0 +1,19 @@ +# cat file.csv| ./ca-godp-npri.awk | uniq | mongoimport -d "fuegos" -c "industries" + +gawk -F',' 'NR>1 { \ + gsub(/"/,"",$3); + gsub(/"/,"",$4); + gsub(/\t/,"",$3); + gsub(/\t/,"",$4); + gsub(/\x1a/,"",$3); + gsub(/\x1a/,"",$4); + lon = $16+0; + lat = $15+0; + if ($3 != $4) + name= $3", "$4 + else + name=$3 + gsub(/^, /,"",name); + # if (lon != 0 && lat != 0 && lon > -180 && lon < 180 && lat >= -90 && lat <= 90) + printf("{name:\"%s\",geo:{type:\"Point\",coordinates:[%s,%s]},registry:\"3\"}\n" \ + ,name,lon,lat)}' diff --git a/imports/api/Industries/Industries.js b/imports/api/Industries/Industries.js index d6aba72..dd1fde0 100644 --- a/imports/api/Industries/Industries.js +++ b/imports/api/Industries/Industries.js @@ -6,10 +6,25 @@ import LocationSchema from '/imports/api/Utility/LocationSchema.js'; const Industries = new Mongo.Collection('industries'); +// https://prtr.unece.org/prtr-global-map // For now using: + +// AUSTRALIA +// https://data.gov.au/dataset/npi# +// +// EUROPE // https://www.eea.europa.eu/data-and-maps/data/member-states-reporting-art-7-under-the-european-pollutant-release-and-transfer-register-e-prtr-regulation-16 +// +// CANADA +// https://www.canada.ca/en/environment-climate-change/services/national-pollutant-release-inventory/tools-resources-data/access.html +// +// USA // https://www.epa.gov/enviro/epa-frs-facilities-state-single-file-csv-download +// TODO: +// http://www.nite.go.jp/ +// http://www.retc.cl/datos-retc/ + Industries.allow({ insert: () => false, update: () => false, diff --git a/imports/startup/server/migrations.js b/imports/startup/server/migrations.js index 3f77de7..8605bd0 100644 --- a/imports/startup/server/migrations.js +++ b/imports/startup/server/migrations.js @@ -145,6 +145,19 @@ Meteor.startup(() => { } }); + Migrations.add({ + version: 10, + up: function siteSettingsAddIndex() { + IndustryRegistries.insert({ + _id: '3', name: 'NPRI', agency: 'GCODP', region: 'Canada' + }); + IndustryRegistries.insert({ + _id: '4', name: 'NPI', agency: 'DEE', region: 'Australia' + }); + } + }); + + // Set createdAt in users & subs Migrations.migrateTo('latest'); From d106fff245e42d0ba11c9a1d18140c2c547d669b Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 17:00:37 +0100 Subject: [PATCH 015/248] Refactor autocomplete --- .../pages/FireSubscription/FireSubscription.js | 3 +++ .../pages/FireSubscription/SubsAutocomplete.js | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/imports/ui/pages/FireSubscription/FireSubscription.js b/imports/ui/pages/FireSubscription/FireSubscription.js index 34431fe..4aac3b7 100644 --- a/imports/ui/pages/FireSubscription/FireSubscription.js +++ b/imports/ui/pages/FireSubscription/FireSubscription.js @@ -78,6 +78,9 @@ class FireSubscription extends React.Component {
this.onAutocompleteChange(value)} />
diff --git a/imports/ui/pages/FireSubscription/SubsAutocomplete.js b/imports/ui/pages/FireSubscription/SubsAutocomplete.js index 7bf8ef4..0f6a852 100644 --- a/imports/ui/pages/FireSubscription/SubsAutocomplete.js +++ b/imports/ui/pages/FireSubscription/SubsAutocomplete.js @@ -20,12 +20,7 @@ class SubsAutocomplete extends React.Component { geocodeByAddress(address) .then(results => getLatLng(results[0])) .then(({ lat, lng }) => { - // console.log('Success Yay', { lat, lng }) - // const newState = update(this.state, {$merge: {lat: lat, lng: lng}}); - // console.log(newState); - // this.setState(newState); self.props.onChange({ lat, lng }); - // console.log(this.state); }) .catch((error) => { console.log(error); @@ -56,11 +51,15 @@ class SubsAutocomplete extends React.Component { {formattedSuggestion.secondaryText}
); + const { + t, label, placeHolder, helpText + } = this.props; + return (
- Indícanos la posición de la zona a vigilar (por ej. tu pueblo, una calle, etc): + {t(label)} this.onChange(address), - placeholder: this.props.t('Escribe aquí un lugar'), + placeholder: t(placeHolder), onBlur: () => { /* console.log('Blur event!'); */ }, onFocus: () => { /* console.log('Focused!'); */ }, autoFocus: this.props.focusInput }} /> - También puedes seleccionar la zona en el mapa arrastrando el puntero naranja. + {t(helpText)}
); @@ -100,6 +99,9 @@ class SubsAutocomplete extends React.Component { SubsAutocomplete.propTypes = { focusInput: PropTypes.bool.isRequired, t: PropTypes.func.isRequired, + label: PropTypes.string.isRequired, + placeHolder: PropTypes.string.isRequired, + helpText: PropTypes.string.isRequired, i18n: PropTypes.object.isRequired }; From 5d216d81d42fe7b990fb13edc751791702a931ed Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 17:46:00 +0100 Subject: [PATCH 016/248] Location search in Fire Map --- .../LocationAutocomplete.js} | 14 +++---- .../FireSubscription/FireSubscription.js | 6 +-- imports/ui/pages/FiresMap/FiresMap.js | 42 ++++++++++++++----- public/locales/en/common.json | 4 +- public/locales/es/common.json | 4 +- 5 files changed, 47 insertions(+), 23 deletions(-) rename imports/ui/{pages/FireSubscription/SubsAutocomplete.js => components/LocationAutocomplete/LocationAutocomplete.js} (90%) diff --git a/imports/ui/pages/FireSubscription/SubsAutocomplete.js b/imports/ui/components/LocationAutocomplete/LocationAutocomplete.js similarity index 90% rename from imports/ui/pages/FireSubscription/SubsAutocomplete.js rename to imports/ui/components/LocationAutocomplete/LocationAutocomplete.js index 0f6a852..c781b55 100644 --- a/imports/ui/pages/FireSubscription/SubsAutocomplete.js +++ b/imports/ui/components/LocationAutocomplete/LocationAutocomplete.js @@ -1,11 +1,11 @@ /* eslint-disable react/jsx-indent-props */ import React from 'react'; import PropTypes from 'prop-types'; -import { Trans, translate } from 'react-i18next'; +import { translate } from 'react-i18next'; import PlacesAutocomplete, { geocodeByAddress, getLatLng } from 'react-places-autocomplete'; import { FormGroup, ControlLabel, HelpBlock } from 'react-bootstrap'; -class SubsAutocomplete extends React.Component { +class LocationAutocomplete extends React.Component { constructor(props) { super(props); this.state = { @@ -58,9 +58,7 @@ class SubsAutocomplete extends React.Component { return (
- - {t(label)} - + { label.length > 0 && {t(label)} } - {t(helpText)} + { helpText.length > 0 && {t(helpText)} }
); } } -SubsAutocomplete.propTypes = { +LocationAutocomplete.propTypes = { focusInput: PropTypes.bool.isRequired, t: PropTypes.func.isRequired, label: PropTypes.string.isRequired, @@ -105,4 +103,4 @@ SubsAutocomplete.propTypes = { i18n: PropTypes.object.isRequired }; -export default translate([], { wait: true })(SubsAutocomplete); +export default translate([], { wait: true })(LocationAutocomplete); diff --git a/imports/ui/pages/FireSubscription/FireSubscription.js b/imports/ui/pages/FireSubscription/FireSubscription.js index 4aac3b7..8013b86 100644 --- a/imports/ui/pages/FireSubscription/FireSubscription.js +++ b/imports/ui/pages/FireSubscription/FireSubscription.js @@ -7,8 +7,8 @@ import { translate } from 'react-i18next'; import DistanceSlider from '/imports/ui/components/DistanceSlider/DistanceSlider'; import SelectionMap, { action } from '/imports/ui/components/SelectionMap/SelectionMap'; import Gkeys from '/imports/startup/client/Gkeys'; -import CenterInMyPosition from '/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js'; -import SubsAutocomplete from './SubsAutocomplete'; +import CenterInMyPosition from '/imports/ui/components/CenterInMyPosition/CenterInMyPosition'; +import LocationAutocomplete from '/imports/ui/components/LocationAutocomplete/LocationAutocomplete'; import { isNotHomeAndMobile } from '/imports/ui/components/Utils/isMobile'; class FireSubscription extends React.Component { @@ -76,7 +76,7 @@ class FireSubscription extends React.Component { {isNotHomeAndMobile &&
- { + self.setState({ init: true }); + }); } /* shouldComponentUpdate(nextProps, nextState) { @@ -108,6 +115,10 @@ class FiresMap extends React.Component { this.debounceView(viewport); } + onAutocompleteChange(value) { + this.handleViewportChange({ center: [value.lat, value.lng], zoom: DEFZOOM - 1 }); + } + getMap() { return this.fireMap.leafletElement; } @@ -192,6 +203,10 @@ class FiresMap extends React.Component { if (Meteor.isDevelopment) console.log(`Industries total: ${this.props.industries.length}`); + if (!this.state.init) { + return
; + } + return ( /* Large number of markers: https://stackoverflow.com/questions/43015854/large-dataset-of-markers-or-dots-in-leaflet/43019740#43019740 */ @@ -220,6 +235,13 @@ class FiresMap extends React.Component { {isNotHomeAndMobile && + this.onAutocompleteChange(value)} + /> this.setShowSubsUnion(e.target.checked)}> Resaltar en verde el área vigilada por nuestros usuarios/as (*) @@ -365,7 +387,7 @@ export default translate([], { wait: true })(withTracker(() => { const zoomStored = store.get('firesmap_zoom'); const marksStored = store.get('firesmap_marks'); const showUnionStored = store.get('firesmap_showunion'); - zoom.set(zoomStored || 8); + zoom.set(zoomStored || DEFZOOM); center.set(centerStored || [0, 0]); if (typeof marksStored === 'boolean') { marks.set(marksStored); @@ -396,13 +418,13 @@ export default translate([], { wait: true })(withTracker(() => { mapSize.get()[1].lat ); /* if (withIndustries) { - Meteor.subscribe( - 'industriesMyloc', - mapSize.get()[0].lng, - mapSize.get()[0].lat, - mapSize.get()[1].lng, - mapSize.get()[1].lat - ); + Meteor.subscribe( + 'industriesMyloc', + mapSize.get()[0].lng, + mapSize.get()[0].lat, + mapSize.get()[1].lng, + mapSize.get()[1].lat + ); } */ } }); diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 09ac8d8..909a0bb 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -223,5 +223,7 @@ "Pantalla completa": "Fullscreen", "Salir de pantalla completa": - "Exit fullscreen mode" + "Exit fullscreen mode", + "Escribe un lugar para centrar el mapa": + "Write a place to center the map" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index fd3c095..6f2051f 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -310,5 +310,7 @@ "Pantalla completa": "Pantalla completa", "Salir de pantalla completa": - "Salir de pantalla completa" + "Salir de pantalla completa", + "Escribe un lugar para centrar el mapa": + "Escribe un lugar para centrar el mapa" } From c2270a860e7e583f1d1af1582eee947cf067f07b Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 18:50:38 +0100 Subject: [PATCH 017/248] Fix error message in geolocation --- .../CenterInMyPosition/CenterInMyPosition.js | 11 +++++++++++ public/locales/en/common.json | 4 +++- public/locales/es/common.json | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js index c143a23..3ee6020 100644 --- a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js +++ b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js @@ -5,6 +5,7 @@ import { Tracker } from 'meteor/tracker'; import { ReactiveVar } from 'meteor/reactive-var'; import { Button } from 'react-bootstrap'; import { translate } from 'react-i18next'; +import { Bert } from 'meteor/themeteorchef:bert'; import './CenterInMyPosition.scss'; @@ -32,6 +33,16 @@ class CenterInMyPosition extends React.Component { // self.onViewportChanged(viewport); computation.stop(); } + // https://developer.mozilla.org/en-US/docs/Web/API/PositionError) + const error = Geolocation.error(); + if (error) { + const cod = error.code; + // window.alert(cod); + if (cod === 1) Bert.alert(self.props.t('geo-not-perms-error'), 'danger'); + else if (cod === 2) Bert.alert(self.props.t('geo-not-avail-error'), 'danger'); + else Bert.alert(error.message, 'danger'); + computation.stop(); + } }); } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 909a0bb..d45b7ac 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -225,5 +225,7 @@ "Salir de pantalla completa": "Exit fullscreen mode", "Escribe un lugar para centrar el mapa": - "Write a place to center the map" + "Write a place to center the map", + "geo-not-perms-error": "Upppps: it seems we do not have permission to know your location", + "geo-not-avail-error": "Upppps: it seems your location is not available" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 6f2051f..5d3e5fa 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -312,5 +312,7 @@ "Salir de pantalla completa": "Salir de pantalla completa", "Escribe un lugar para centrar el mapa": - "Escribe un lugar para centrar el mapa" + "Escribe un lugar para centrar el mapa", + "geo-not-perms-error": "Upppps: parece que no tenemos permiso para conocer tu ubicación", + "geo-not-avail-error": "Upppps: parece tu ubicación no está disponible" } From 0342bdf33f2301b3f59376d6d4588fed8278d9a6 Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 18:53:01 +0100 Subject: [PATCH 018/248] Removing logs --- imports/ui/components/CenterInMyPosition/CenterInMyPosition.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js index 3ee6020..2f037cb 100644 --- a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js +++ b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js @@ -16,7 +16,6 @@ class CenterInMyPosition extends React.Component { // only with SSL: // https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition - console.log('Center'); // https://stackoverflow.com/questions/31608579/somethings-wrong-with-my-meteor-geolocation-functions const userGeoLocation = new ReactiveVar(null); const self = this; @@ -29,8 +28,6 @@ class CenterInMyPosition extends React.Component { zoom: 11 }; self.props.onClick(viewport); - // console.log(viewport); - // self.onViewportChanged(viewport); computation.stop(); } // https://developer.mozilla.org/en-US/docs/Web/API/PositionError) From 2bad9d4083b5c6d81f18e02ced72e559ef59a7f1 Mon Sep 17 00:00:00 2001 From: vjrj Date: Tue, 27 Feb 2018 19:32:43 +0100 Subject: [PATCH 019/248] New geolocation error --- imports/ui/components/CenterInMyPosition/CenterInMyPosition.js | 1 + public/locales/en/common.json | 3 ++- public/locales/es/common.json | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js index 2f037cb..cad75da 100644 --- a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js +++ b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js @@ -37,6 +37,7 @@ class CenterInMyPosition extends React.Component { // window.alert(cod); if (cod === 1) Bert.alert(self.props.t('geo-not-perms-error'), 'danger'); else if (cod === 2) Bert.alert(self.props.t('geo-not-avail-error'), 'danger'); + else if (cod === 3) Bert.alert(self.props.t('geo-not-timeout-error'), 'danger'); else Bert.alert(error.message, 'danger'); computation.stop(); } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index d45b7ac..8e980ee 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -227,5 +227,6 @@ "Escribe un lugar para centrar el mapa": "Write a place to center the map", "geo-not-perms-error": "Upppps: it seems we do not have permission to know your location", - "geo-not-avail-error": "Upppps: it seems your location is not available" + "geo-not-avail-error": "Upppps: it seems your location is not available", + "geo-not-timeout-error": "Upppps: Your device is taking too long to know your location" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 5d3e5fa..5e6c074 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -314,5 +314,6 @@ "Escribe un lugar para centrar el mapa": "Escribe un lugar para centrar el mapa", "geo-not-perms-error": "Upppps: parece que no tenemos permiso para conocer tu ubicación", - "geo-not-avail-error": "Upppps: parece tu ubicación no está disponible" + "geo-not-avail-error": "Upppps: parece tu ubicación no está disponible", + "geo-not-timeout-error": "Upppps: tu dispositivo está tardando demasiado en conocer tu ubicación" } From 58c557ecb2aa24836568b4d5bbd7b3115a2d9dc0 Mon Sep 17 00:00:00 2001 From: vjrj Date: Wed, 28 Feb 2018 01:36:34 +0100 Subject: [PATCH 020/248] Reconnect only for anon users --- imports/ui/components/Reconnect/Reconnect.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/imports/ui/components/Reconnect/Reconnect.js b/imports/ui/components/Reconnect/Reconnect.js index c2fdb04..2de4d5c 100644 --- a/imports/ui/components/Reconnect/Reconnect.js +++ b/imports/ui/components/Reconnect/Reconnect.js @@ -1,7 +1,7 @@ /* eslint-disable react/jsx-indent-props */ /* eslint-disable import/no-absolute-path */ -import React, { Component } from 'react'; +import React, { Fragment, Component } from 'react'; import PropTypes from 'prop-types'; import { translate } from 'react-i18next'; import { Meteor } from 'meteor/meteor'; @@ -10,20 +10,25 @@ import Blaze from 'meteor/gadicc:blaze-react-component'; class Reconnect extends Component { render() { - const { t } = this.props; + const { t, authenticated } = this.props; + // console.log(`Reconnect ${!authenticated ? 'enabled' : 'disabled'}`); return ( - + { !authenticated && + + /> } + ); } } Reconnect.propTypes = { - t: PropTypes.func.isRequired + t: PropTypes.func.isRequired, + authenticated: PropTypes.bool.isRequired }; Reconnect.defaultProps = { From 7d5fe8f0eed4f62ae309ebd831b3c9138318f29e Mon Sep 17 00:00:00 2001 From: vjrj Date: Wed, 28 Feb 2018 01:52:10 +0100 Subject: [PATCH 021/248] isHomeAndMobile reactive --- imports/ui/components/Utils/isMobile.js | 4 ++-- imports/ui/pages/FireSubscription/FireSubscription.js | 4 ++-- imports/ui/pages/FiresMap/FiresMap.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/imports/ui/components/Utils/isMobile.js b/imports/ui/components/Utils/isMobile.js index 4328a3d..00b91a7 100644 --- a/imports/ui/components/Utils/isMobile.js +++ b/imports/ui/components/Utils/isMobile.js @@ -2,8 +2,8 @@ import isMobile from 'ismobilejs'; import { isHome } from './location'; // https://github.com/ReactTraining/react-router/issues/184 -export const isHomeAndMobile = isHome() && isMobile.any; -export const isNotHomeAndMobile = !isHomeAndMobile; +export const isHomeAndMobile = () => isHome() && isMobile.any; +export const isNotHomeAndMobile = () => !isHomeAndMobile(); export const isAnyMobile = isMobile.any; // https://stackoverflow.com/questions/18625321/detect-webkit-browser-in-javascript export const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); diff --git a/imports/ui/pages/FireSubscription/FireSubscription.js b/imports/ui/pages/FireSubscription/FireSubscription.js index 8013b86..177cbd7 100644 --- a/imports/ui/pages/FireSubscription/FireSubscription.js +++ b/imports/ui/pages/FireSubscription/FireSubscription.js @@ -73,7 +73,7 @@ class FireSubscription extends React.Component { return (
- {isNotHomeAndMobile && + {isNotHomeAndMobile() &&
} this.onSliderChange(value)} /> - {isNotHomeAndMobile && + {isNotHomeAndMobile() && this.centerOnUserLocation(viewport)} /> diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index f4c1604..cd47ac5 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -227,13 +227,13 @@ class FiresMap extends React.Component { En rojo, {{ count: this.props.activefires.length + this.props.firealerts.length }} fuegos activos en el mapa. Hay un total de {{ countTotal: this.props.activefirestotal }} fuegos activos detectados en todo el mundo por la NASA. Datos actualizados . }

- {isNotHomeAndMobile && this.props.firealerts.length > 0 && + {isNotHomeAndMobile() && this.props.firealerts.length > 0 &&

En naranja, los fuegos notificados por nuestros usuarios/as recientemente.

} - {isNotHomeAndMobile && this.props.firealerts.length === 0 && + {isNotHomeAndMobile() && this.props.firealerts.length === 0 &&

No hay fuegos notificados recientemente por nuestros usuarios/as en esta zona.

} - {isNotHomeAndMobile && + {isNotHomeAndMobile() && Date: Wed, 28 Feb 2018 11:22:01 +0100 Subject: [PATCH 022/248] Warning big zones subscriptions --- imports/ui/pages/Subscriptions/Subscriptions.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/imports/ui/pages/Subscriptions/Subscriptions.js b/imports/ui/pages/Subscriptions/Subscriptions.js index 78fbcad..765711d 100644 --- a/imports/ui/pages/Subscriptions/Subscriptions.js +++ b/imports/ui/pages/Subscriptions/Subscriptions.js @@ -80,7 +80,8 @@ class Subscriptions extends Component { const { loading, t, - subscriptions + subscriptions, + maxDistance } = this.props; const firstBtnTitle = ['Añadir zona', '', 'Terminar']; // view, add, edit return (!loading ? ( @@ -92,6 +93,9 @@ class Subscriptions extends Component { { subscriptions.length === 0 ? No estás suscrito a fuegos en ninguna zona : En verde, áreas de las que recibirás alertas de fuegos + } + { maxDistance && maxDistance.distance > 20 && + Estás subscrito a una zona muy grande }
{ // console.log(UserSubsToFiresCollection.find().fetch()); return { loading: !subscription.ready(), - subscriptions: UserSubsToFiresCollection.find({ owner: Meteor.userId() }).fetch() + subscriptions: UserSubsToFiresCollection.find({ owner: Meteor.userId() }).fetch(), + maxDistance: UserSubsToFiresCollection.findOne({ owner: Meteor.userId() }, { sort: { distance: -1 } }) }; })(Subscriptions)); From ae2695ea1f41ce0931a481956552b6581407dc67 Mon Sep 17 00:00:00 2001 From: vjrj Date: Wed, 28 Feb 2018 11:26:00 +0100 Subject: [PATCH 023/248] i18n subs limit --- public/locales/en/common.json | 4 +++- public/locales/es/common.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 8e980ee..30f5d8d 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -228,5 +228,7 @@ "Write a place to center the map", "geo-not-perms-error": "Upppps: it seems we do not have permission to know your location", "geo-not-avail-error": "Upppps: it seems your location is not available", - "geo-not-timeout-error": "Upppps: Your device is taking too long to know your location" + "geo-not-timeout-error": "Upppps: Your device is taking too long to know your location", + "Estás subscrito a una zona muy grande": + "You are subscribed to a very large area" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 5e6c074..be7a976 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -315,5 +315,7 @@ "Escribe un lugar para centrar el mapa", "geo-not-perms-error": "Upppps: parece que no tenemos permiso para conocer tu ubicación", "geo-not-avail-error": "Upppps: parece tu ubicación no está disponible", - "geo-not-timeout-error": "Upppps: tu dispositivo está tardando demasiado en conocer tu ubicación" + "geo-not-timeout-error": "Upppps: tu dispositivo está tardando demasiado en conocer tu ubicación", + "Estás subscrito a una zona muy grande": + "Estás subscrito a una zona muy grande" } From e972419b3e6541bef023ce79711a5c848d779c34 Mon Sep 17 00:00:00 2001 From: vjrj Date: Thu, 1 Mar 2018 11:04:35 +0100 Subject: [PATCH 024/248] Added link to About --- private/pages/about-es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private/pages/about-es.md b/private/pages/about-es.md index d879457..7e5317c 100644 --- a/private/pages/about-es.md +++ b/private/pages/about-es.md @@ -19,7 +19,7 @@ Además, según nos cuentan amigos de otras latitudes estos mismos problemas suc También mantenemos un archivo documental de los fuegos en el que los afectados puedan aportar información y así ayudar, por ejemplo, a la investigación sobre las causas de cada fuego. Y estamos desarrollando más herramientas de este tipo. -En un momento climático tan difícil, en el que lo último que tenemos que hacer es emitir más CO2, creemos que hay que tomar más medidas legales antes de llegar a este punto en el que ciertas personas se lucran de los incendios y otras personas como nosotras tengamos que andar apagándolos. +En un momento climático tan difícil, en el que lo último que tenemos que hacer es emitir más CO2, creemos que hay que tomar más medidas legales (como [está](https://www.ecologistasenaccion.org/article35834.html)) antes de llegar a este punto en el que ciertas personas se lucran de los incendios y otras personas como nosotras tengamos que andar apagándolos. **También nos preguntan, porqué desarrollamos algo así si no nos enriquece [sic]. Quizás ese es exactamente el problema, que lo que enriquece a algunos es quemar lo que es de tod@s. ¿Y quien cuida lo que es de tod@s?** From a83495deea39f08d0d671cc112f8958eacf9d05a Mon Sep 17 00:00:00 2001 From: vjrj Date: Thu, 1 Mar 2018 16:47:17 +0100 Subject: [PATCH 025/248] Minor change in error reporting --- imports/ui/components/ErrorBoundary/ErrorBoundary.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imports/ui/components/ErrorBoundary/ErrorBoundary.js b/imports/ui/components/ErrorBoundary/ErrorBoundary.js index cc1f95b..1e0c654 100644 --- a/imports/ui/components/ErrorBoundary/ErrorBoundary.js +++ b/imports/ui/components/ErrorBoundary/ErrorBoundary.js @@ -22,8 +22,10 @@ class ErrorBoundary extends Component { // Display fallback UI this.setState({ hasError: true }); // You can also log the error to an error reporting service - ravenLogger.log(error); - ravenLogger.log(info); + // console.log(`typeof error ${typeof error}`); + // console.log(`typeof info ${typeof info}`); + ravenLogger.log(error, info); + // ravenLogger.log(info); } render() { From 621cf4e2adb4d1db0d6f5246af5ffd33fb2196f0 Mon Sep 17 00:00:00 2001 From: vjrj Date: Thu, 1 Mar 2018 16:47:37 +0100 Subject: [PATCH 026/248] Improved autocomplete error handling --- .../LocationAutocomplete.js | 59 ++++++++++++++----- public/locales/en/common.json | 4 +- public/locales/es/common.json | 4 +- 3 files changed, 49 insertions(+), 18 deletions(-) diff --git a/imports/ui/components/LocationAutocomplete/LocationAutocomplete.js b/imports/ui/components/LocationAutocomplete/LocationAutocomplete.js index c781b55..7eaf046 100644 --- a/imports/ui/components/LocationAutocomplete/LocationAutocomplete.js +++ b/imports/ui/components/LocationAutocomplete/LocationAutocomplete.js @@ -4,30 +4,55 @@ import PropTypes from 'prop-types'; import { translate } from 'react-i18next'; import PlacesAutocomplete, { geocodeByAddress, getLatLng } from 'react-places-autocomplete'; import { FormGroup, ControlLabel, HelpBlock } from 'react-bootstrap'; +import { Bert } from 'meteor/themeteorchef:bert'; + +// Sample: +// https://github.com/kenny-hibino/react-places-autocomplete/blob/master/demo/components/SearchBar.js class LocationAutocomplete extends React.Component { constructor(props) { super(props); this.state = { - address: '' + address: '', + loading: false // we can use it with a spinner }; + this.handleSelect = this.handleSelect.bind(this); + this.handleChange = this.handleChange.bind(this); + this.onError = this.onError.bind(this); } - onChange(address) { this.setState({ address }); } + onError(error) { + if (error === 'ZERO_RESULTS') { + Bert.alert(this.props.t('Lugar no encontrado'), 'alert'); + } + } + + handleChange(address) { + this.setState({ address }); + } handleSelect(address) { + this.setState({ + address, + loading: true + }); const self = this; - geocodeByAddress(address) - .then(results => getLatLng(results[0])) - .then(({ lat, lng }) => { - self.props.onChange({ lat, lng }); - }) - .catch((error) => { - console.log(error); - if (error === 'ZERO_RESULTS') { - console.log('No results'); - } - }); + try { + geocodeByAddress(address) + .then(results => getLatLng(results[0])) + .then((result) => { + if (result && result.lat && result.lng) { + const { lat, lng } = result; + self.props.onChange({ lat, lng }); + self.setState({ + loading: false + }); + } + }) + .catch((error) => { self.onError(error); }); + } catch (error) { + self.onError(error); + } } render() { @@ -69,8 +94,10 @@ class LocationAutocomplete extends React.Component { }} googleLogo={false} highlightFirstSuggestion - onSelect={address => this.handleSelect(address)} - onEnterKeyDown={address => this.handleSelect(address)} + onChange={this.handleChange} + onSelect={this.handleSelect} + onEnterKeyDown={this.handleSelect} + onError={this.onError} options={{ // location: new google.maps.LatLng(-34, 151), // radius: 2000, @@ -80,7 +107,7 @@ class LocationAutocomplete extends React.Component { inputProps={ { value: this.state.address, - onChange: address => this.onChange(address), + onChange: this.handleChange, placeholder: t(placeHolder), onBlur: () => { /* console.log('Blur event!'); */ }, onFocus: () => { /* console.log('Focused!'); */ }, diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 30f5d8d..e6fd058 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -230,5 +230,7 @@ "geo-not-avail-error": "Upppps: it seems your location is not available", "geo-not-timeout-error": "Upppps: Your device is taking too long to know your location", "Estás subscrito a una zona muy grande": - "You are subscribed to a very large area" + "You are subscribed to a very large area", + "Lugar no encontrado": + "Place not found" } diff --git a/public/locales/es/common.json b/public/locales/es/common.json index be7a976..7d910b4 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -317,5 +317,7 @@ "geo-not-avail-error": "Upppps: parece tu ubicación no está disponible", "geo-not-timeout-error": "Upppps: tu dispositivo está tardando demasiado en conocer tu ubicación", "Estás subscrito a una zona muy grande": - "Estás subscrito a una zona muy grande" + "Estás subscrito a una zona muy grande", + "Lugar no encontrado": + "Lugar no encontrado" } From e7030573775c459fc14b061203fb5c406760b0c8 Mon Sep 17 00:00:00 2001 From: vjrj Date: Thu, 1 Mar 2018 17:10:31 +0100 Subject: [PATCH 027/248] 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 028/248] 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 029/248] 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 030/248] 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 031/248] 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 032/248] 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 033/248] 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 034/248] 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 035/248] 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 036/248] 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 } }
); } - return (); + return (
); } scaleHeader() { @@ -88,7 +88,7 @@ class Index extends Component { {title} {/* https://v4-alpha.getbootstrap.com/components/carousel/ */} - +
@@ -99,10 +99,10 @@ class Index extends Component { > {/* for dev ^^^: data-interval=false */}
    -
  1. -
  2. -
  3. -
  4. +
  5. +
  6. +
  7. +
@@ -192,8 +192,8 @@ class Index extends Component { > {/* for dev ^^^: data-interval=false */}
    -
  1. -
  2. +
  3. +
@@ -300,7 +300,7 @@ class Index extends Component {
- +
); } From fa4af5e5fe01c147a06b296ba1f56c5e66f02b55 Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 08:41:23 +0100 Subject: [PATCH 039/248] Refactor i18n client code --- imports/startup/client/i18n.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/imports/startup/client/i18n.js b/imports/startup/client/i18n.js index 69771e2..2fdc6b4 100644 --- a/imports/startup/client/i18n.js +++ b/imports/startup/client/i18n.js @@ -70,16 +70,17 @@ i18n.use(backend) console.error(err); return; } - i18nReady.set(true); + console.log(`Language initialized: ${i18n.language}`); + // document.title = t('AppName'); // Accounts translation // https://github.com/softwarerero/meteor-accounts-t9n - // console.log("Language: " + i18n.language); T9n.setLanguage(i18n.language); // console.log(T9n.get('error.accounts.User not found')); - moment.locale(i18n.language); + i18nReady.set(true); + // cookies eu consent const cookiesOpt = { cookieTitle: t('Uso de Cookies'), From 5996f3a74aedea822e7044d6a24bd22177cd9d3a Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 08:41:53 +0100 Subject: [PATCH 040/248] Simplify Test page --- imports/ui/pages/TestError/TestError.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/imports/ui/pages/TestError/TestError.js b/imports/ui/pages/TestError/TestError.js index 66f3721..f8f51ce 100644 --- a/imports/ui/pages/TestError/TestError.js +++ b/imports/ui/pages/TestError/TestError.js @@ -3,20 +3,16 @@ /* eslint-disable import/no-absolute-path */ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { translate } from 'react-i18next'; -import { withTracker } from 'meteor/react-meteor-data'; class TestError extends Component { constructor(props) { super(props); - this.t = props.t; this.state = { }; + throw new Error('Just testing'); } render() { - throw new Error('Just testing'); return (
); @@ -24,13 +20,9 @@ class TestError extends Component { } TestError.propTypes = { - t: PropTypes.func.isRequired }; TestError.defaultProps = { }; -// export default translate([], { wait: true })(TestError); -export default translate([], { wait: true })(withTracker(props => ({ - // props.something -}))(TestError)); +export default TestError; From 64b2affee4cf6867e5866930a4bb7c81badff470 Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 09:05:55 +0100 Subject: [PATCH 041/248] Clean in Profile --- imports/ui/pages/Profile/Profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/ui/pages/Profile/Profile.js b/imports/ui/pages/Profile/Profile.js index cb58761..665e9d7 100644 --- a/imports/ui/pages/Profile/Profile.js +++ b/imports/ui/pages/Profile/Profile.js @@ -269,7 +269,7 @@ Profile.propTypes = { i18n: PropTypes.object.isRequired }; -export default translate([], { wait: true })(withTracker(() => { +export default translate()(withTracker(() => { const subscription = Meteor.subscribe('users.editProfile'); return { From 8b0577b46f4bae1c1b60b1ea80e56525e54c33f2 Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 10:54:53 +0100 Subject: [PATCH 042/248] Refactor Reconnect --- imports/ui/components/Reconnect/Reconnect.js | 27 ++++++++------------ 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/imports/ui/components/Reconnect/Reconnect.js b/imports/ui/components/Reconnect/Reconnect.js index 2de4d5c..19bbfb5 100644 --- a/imports/ui/components/Reconnect/Reconnect.js +++ b/imports/ui/components/Reconnect/Reconnect.js @@ -1,30 +1,24 @@ /* eslint-disable react/jsx-indent-props */ /* eslint-disable import/no-absolute-path */ -import React, { Fragment, Component } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import { translate } from 'react-i18next'; import { Meteor } from 'meteor/meteor'; import { Tracker } from 'meteor/tracker'; import Blaze from 'meteor/gadicc:blaze-react-component'; -class Reconnect extends Component { - render() { - const { t, authenticated } = this.props; - // console.log(`Reconnect ${!authenticated ? 'enabled' : 'disabled'}`); - return ( - - { !authenticated && - ( +
+ { !authenticated && + } - - ); - } -} + /> } +
+); Reconnect.propTypes = { t: PropTypes.func.isRequired, @@ -36,11 +30,12 @@ Reconnect.defaultProps = { export default translate([], { wait: true })(Reconnect); +/* if (!Meteor.isProduction) { // We clear the console on disconnect during development Tracker.autorun(() => { if (Meteor.status().status === 'waiting') { - // console.clear(); + console.clear(); } }); -} +} */ From 83f5048ff83ab14e03c4960254eaa36a633ef1f0 Mon Sep 17 00:00:00 2001 From: vjrj Date: Sat, 3 Mar 2018 11:26:19 +0100 Subject: [PATCH 043/248] Refactor Feedback --- imports/ui/components/Feedback/Feedback.js | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/imports/ui/components/Feedback/Feedback.js b/imports/ui/components/Feedback/Feedback.js index 26338cb..bbcab29 100644 --- a/imports/ui/components/Feedback/Feedback.js +++ b/imports/ui/components/Feedback/Feedback.js @@ -2,7 +2,7 @@ /* eslint-disable import/no-absolute-path */ /* eslint-disable import/no-absolute-path */ -import React, { Component, Fragment } from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Meteor } from 'meteor/meteor'; import { translate } from 'react-i18next'; @@ -18,13 +18,13 @@ import './Feedback.scss'; class Feedback extends Component { constructor(props) { super(props); - this.t = props.t; this.handleSubmit = this.handleSubmit.bind(this); this.onTabClick = this.onTabClick.bind(this); } componentDidMount() { const component = this; + const { t } = this.props; validate(component.form, { rules: { @@ -38,11 +38,11 @@ class Feedback extends Component { }, messages: { feedbackText: { - required: this.t('Por favor, escribe aquí tu feedback...') + required: t('Por favor, escribe aquí tu feedback...') }, email: { - required: this.t('Tu correo'), - email: this.t('¿Es correcto este correo?') + required: t('Tu correo'), + email: t('¿Es correcto este correo?') } }, submitHandler() { component.handleSubmit(); } @@ -71,8 +71,9 @@ class Feedback extends Component { render() { // console.log(`Render Feedback because isHome ${this.props.isHome}, email: '${this.props.emailAddress}'`); const disabled = this.props.emailVerified && this.props.emailAddress; + const { t } = this.props; return ( - +
{ !this.props.isHome &&
(this.formdiv = formdiv)} style={{ display: 'none' }} className="card"> @@ -88,7 +89,7 @@ class Feedback extends Component { name="email" className="form-control" ref={email => (this.email = email)} - placeholder={this.t('Tu correo')} + placeholder={t('Tu correo')} key={disabled ? 'disabledEmail' : 'enabledEmail'} disabled={disabled} defaultValue={disabled ? this.props.emailAddress : ''} @@ -103,13 +104,13 @@ class Feedback extends Component { className="form-control" name="feedbackText" ref={feedbackText => (this.feedbackText = feedbackText)} - placeholder={this.t('Por favor, escribe aquí tu feedback...')} + placeholder={t('Por favor, escribe aquí tu feedback...')} rows="6" />
@@ -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 044/248] 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 045/248] 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 046/248] 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 047/248] 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 048/248] 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 049/248] 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 050/248] 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 &&