diff --git a/imports/api/ActiveFires/server/publications.js b/imports/api/ActiveFires/server/publications.js index 5bdfcce..701e9a1 100644 --- a/imports/api/ActiveFires/server/publications.js +++ b/imports/api/ActiveFires/server/publications.js @@ -118,10 +118,10 @@ Meteor.publish('activefiresmyloc', function activeInMyLoc(zoom, lat, lng, height check(height, NullOr(Number)); check(width, NullOr(Number)); // console.log(`Check active fires in ${lat},${lng} with zoom ${zoom} pixels in ${height}x${width} map`); - if (lat === null || lng === null) { - const location = localize(); - // console.log(`${location.latitude}, ${location.longitude}`); - return activefires(zoom, location.latitude, location.longitude, height, width); + if (lat && lng) { + return activefires(zoom, lat, lng, height, width); } - return activefires(zoom, lat, lng, height, width); + const location = localize(); + // console.log(`${location.latitude}, ${location.longitude}`); + return activefires(zoom, location.latitude, location.longitude, height, width); }); diff --git a/imports/api/Users/Users.js b/imports/api/Users/Users.js index 486730a..a4523af 100644 --- a/imports/api/Users/Users.js +++ b/imports/api/Users/Users.js @@ -3,13 +3,13 @@ import { Meteor } from 'meteor/meteor'; import SimpleSchema from 'simpl-schema'; import { defaultCreatedAt, defaultUpdateAt } from '/imports/api/Utility/Utils.js'; -import i18n from 'i18next'; const schemaUserProfile = new SimpleSchema({ - // name: { type: String, optional: true }, - name: Object, + /* Our users has a name of type Object while Google Service, for instance, not */ + /* name: { type: String, optional: true }, */ + /* name: Object, 'name.first': String, - 'name.last': String, + 'name.last': String, */ lang: { type: String, optional: true }, telegramChatId: { type: Number, optional: true }, telegramUsername: { type: String, optional: true }, diff --git a/imports/ui/components/Public/Public.js b/imports/ui/components/Public/Public.js index 317e373..202b59e 100644 --- a/imports/ui/components/Public/Public.js +++ b/imports/ui/components/Public/Public.js @@ -2,14 +2,18 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Route, Redirect } from 'react-router-dom'; -const Public = ({ loggingIn, authenticated, component, path, exact, ...rest }) => ( +const Public = ({ + loggingIn, authenticated, component, location, path, exact, ...rest +}) => ( ( !authenticated ? - (React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) : - () + (React.createElement(component, { + ...props, ...rest, loggingIn, authenticated +})) : + () )} /> ); @@ -17,7 +21,7 @@ const Public = ({ loggingIn, authenticated, component, path, exact, ...rest }) = Public.propTypes = { loggingIn: PropTypes.bool.isRequired, authenticated: PropTypes.bool.isRequired, - component: PropTypes.func.isRequired, + component: PropTypes.func.isRequired }; export default Public; diff --git a/imports/ui/components/SelectionMap/SelectionMap.js b/imports/ui/components/SelectionMap/SelectionMap.js index 5be19d6..efd493f 100644 --- a/imports/ui/components/SelectionMap/SelectionMap.js +++ b/imports/ui/components/SelectionMap/SelectionMap.js @@ -74,7 +74,7 @@ class SelectionMap extends Component { onFstBtn() { this.props.onFstBtn({ - location: { lat: this.state.center[0], lon: this.state.center[1] }, + location: { lat: this.state.marker[0], lon: this.state.marker[1] }, distance: this.state.distance }); } @@ -113,7 +113,7 @@ class SelectionMap extends Component { fit() { // console.log("fit!"); - if (this.props.currentSubs.length > 0 && this.state.subsFit) { + if (this.props.currentSubs.length > 0 && this.state.subsFit && this.props.action !== action.add) { // has autofit, do nothing } else if (this.selectionMap && this.distanceCircle) { if (!this.getMap().getBounds().contains(this.distanceCircle.leafletElement.getBounds())) { diff --git a/imports/ui/pages/FireSubscription/FireSubscription.js b/imports/ui/pages/FireSubscription/FireSubscription.js index 00f5d96..0bd9518 100644 --- a/imports/ui/pages/FireSubscription/FireSubscription.js +++ b/imports/ui/pages/FireSubscription/FireSubscription.js @@ -20,7 +20,10 @@ class FireSubscription extends React.Component { zoom: this.props.zoom, distance: this.props.distance }; - // console.log(this.props.location.state); + if (props.location) { + console.log(props.location.state); + } + console.log(this.state); } componentDidMount() { diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index baee395..08ad493 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -38,7 +38,10 @@ class FiresMap extends React.Component { constructor(props) { super(props); this.state = { - viewport: this.props.viewport, + viewport: { + center: props.center, + zoom: props.zoom + }, useMarkers: false, showSubsUnion: true }; @@ -214,7 +217,8 @@ FiresMap.propTypes = { activefires: PropTypes.arrayOf(PropTypes.object).isRequired, firealerts: PropTypes.arrayOf(PropTypes.object).isRequired, activefirestotal: PropTypes.number.isRequired, - viewport: PropTypes.object.isRequired, + center: PropTypes.arrayOf(PropTypes.number), + zoom: PropTypes.number, t: PropTypes.func.isRequired }; @@ -224,6 +228,7 @@ export default translate([], { wait: true })(withTracker(() => { Meteor.autorun(() => { if (geolocation.get() && init) { center.set(geolocation.get()); + // console.log(`Geolocation ${geolocation.get()}`); init = false; } if (mapSize.get()) { @@ -258,9 +263,7 @@ export default translate([], { wait: true })(withTracker(() => { firealerts: FireAlertsCollection.find().fetch().map(doc => ( { _id: doc._id, lat: doc.location.lat, lon: doc.location.lon } )), - viewport: { - center: geolocation.get(), - zoom: zoom.get() - } + center: geolocation.get(), + zoom: zoom.get() }; })(FiresMap)); diff --git a/imports/ui/pages/Login/Login.js b/imports/ui/pages/Login/Login.js index 8c004fb..6043955 100644 --- a/imports/ui/pages/Login/Login.js +++ b/imports/ui/pages/Login/Login.js @@ -16,7 +16,8 @@ class Login extends React.Component { super(props); this.t = props.t; this.handleSubmit = this.handleSubmit.bind(this); - // console.log(this.props.location.state); + console.log(this.props.location.state); + this.state = props.location.state; } componentDidMount() { @@ -110,6 +111,7 @@ class Login extends React.Component { Login.propTypes = { history: PropTypes.object.isRequired, t: PropTypes.func.isRequired, + location: PropTypes.object }; export default translate([], { wait: true })(Login); diff --git a/imports/ui/pages/NewSubscription/NewSubscription.js b/imports/ui/pages/NewSubscription/NewSubscription.js index a5e55a3..dcb3d6b 100644 --- a/imports/ui/pages/NewSubscription/NewSubscription.js +++ b/imports/ui/pages/NewSubscription/NewSubscription.js @@ -11,7 +11,15 @@ class NewSubscription extends Component { const pushState = this.props.location.state; this.state = { center: pushState ? pushState.center : [null, null], - zoom: pushState ? pushState.zoom : null + zoom: pushState ? pushState.zoom : null, + // we have a subscription from home? + doc: pushState && pushState.location ? { + location: { + lat: pushState.location.lat, + lot: pushState.location.lon + }, + distance: pushState.distance + } : undefined }; } @@ -24,6 +32,7 @@ class NewSubscription extends Component { history={history} center={this.state.center} zoom={this.state.zoom} + doc={this.state.doc} /> ); diff --git a/imports/ui/pages/Signup/Signup.js b/imports/ui/pages/Signup/Signup.js index bb34baa..50bc845 100644 --- a/imports/ui/pages/Signup/Signup.js +++ b/imports/ui/pages/Signup/Signup.js @@ -1,3 +1,5 @@ +/* eslint-disable react/jsx-indent-props */ + import React from 'react'; import { Row, FormGroup, ControlLabel, Button } from 'react-bootstrap'; import Col from '../../components/Col/Col'; @@ -6,6 +8,8 @@ import { Link } from 'react-router-dom'; import { Meteor } from 'meteor/meteor'; import { Accounts } from 'meteor/accounts-base'; import { Bert } from 'meteor/themeteorchef:bert'; +import randomHex from 'random-hexadecimal'; +import Icon from '../../components/Icon/Icon'; import OAuthLoginButtons from '../../components/OAuthLoginButtons/OAuthLoginButtons'; import InputHint from '../../components/InputHint/InputHint'; import AccountPageFooter from '../../components/AccountPageFooter/AccountPageFooter'; @@ -64,7 +68,7 @@ class Signup extends React.Component { } handleSubmit() { - const { history } = this.props; + const { history, t } = this.props; Accounts.createUser({ email: this.emailAddress.value, @@ -80,31 +84,35 @@ class Signup extends React.Component { Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger'); } else { Meteor.call('users.sendVerificationEmail'); - Bert.alert('Welcome!', 'success'); + Bert.alert(t('Bienvenid@!'), 'success'); history.push('/subscriptions'); + } }); } render() { + const { t, history } = this.props; return (
-

{this.t('Registrarse')}

+

{t('Registrarse')}

- {/* - - */} + + + @@ -113,7 +121,7 @@ class Signup extends React.Component { - {this.t('Nombre')} + {t('Nombre')} - {this.t('Apellidos')} + {t('Apellidos')} - {this.t('Correo electrónico')} + {t('Correo electrónico')} - {this.t('Contraseña')} + {t('Contraseña')} (this.password = password)} className="form-control" /> - {this.t('Usa al menos seis caracteres.')} + {t('Usa al menos seis caracteres.')} - + -

{this.t('¿Ya tienes un cuenta?')} {this.t('Iniciar sesión')}.

+

{t('¿Ya tienes un cuenta?')} {t('Iniciar sesión')}.

@@ -165,7 +173,8 @@ class Signup extends React.Component { } Signup.propTypes = { - history: PropTypes.object.isRequired + history: PropTypes.object.isRequired, + location: PropTypes.object }; export default translate([], { wait: true })(Signup); diff --git a/imports/ui/pages/Subscriptions/Subscriptions.js b/imports/ui/pages/Subscriptions/Subscriptions.js index bfed714..e169148 100644 --- a/imports/ui/pages/Subscriptions/Subscriptions.js +++ b/imports/ui/pages/Subscriptions/Subscriptions.js @@ -19,9 +19,16 @@ class Subscriptions extends Component { constructor(props) { super(props); this.t = props.t; - this.state = { - action: action.view - }; + if (props.location.state) { + const received = props.location.state; + props.history.push(`${this.props.match.url}/new`, { + location: received.location, + distance: received.distance, + center: [received.location.lat, received.location.lon] + }); + } + this.state = {}; + this.state.action = action.view; this.onViewportChanged = this.onViewportChanged.bind(this); this.onFstBtn = this.onFstBtn.bind(this); this.onSndBtn = this.onSndBtn.bind(this); @@ -109,7 +116,8 @@ Subscriptions.propTypes = { subscriptions: PropTypes.arrayOf(PropTypes.object).isRequired, match: PropTypes.object.isRequired, t: PropTypes.func.isRequired, - history: PropTypes.object.isRequired + history: PropTypes.object.isRequired, + location: PropTypes.object }; export default translate([], { wait: true })(withTracker(() => { diff --git a/imports/ui/stylesheets/new-age.scss b/imports/ui/stylesheets/new-age.scss index 80d2e35..bad8fab 100644 --- a/imports/ui/stylesheets/new-age.scss +++ b/imports/ui/stylesheets/new-age.scss @@ -190,6 +190,7 @@ div.section.contact ul.list-social li.social-google-plus a:hover { font-size: 16px; } +.OAuthLoginButton-telegram, .OAuthLoginButtons > .btn { letter-spacing: inherit; text-transform: none; diff --git a/package-lock.json b/package-lock.json index e0777d6..cfe5e28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2342,6 +2342,11 @@ "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, + "clamp": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/clamp/-/clamp-1.0.1.tgz", + "integrity": "sha1-ZqDmQBGBbjcZaCj9yMjBRzEshjQ=" + }, "classnames": { "version": "2.2.5", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.5.tgz", @@ -5250,6 +5255,11 @@ "number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz" } }, + "is-function": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz", + "integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU=" + }, "is-glob": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", @@ -5270,6 +5280,11 @@ "xtend": "4.0.1" } }, + "is-nil": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-nil/-/is-nil-1.0.1.tgz", + "integrity": "sha1-LauingtYUGOHXntTnQcfWxWTeWk=" + }, "is-number": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", @@ -5279,6 +5294,11 @@ "kind-of": "3.2.2" } }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=" + }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", @@ -7615,6 +7635,11 @@ "tmpl": "1.0.4" } }, + "max-safe-int": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/max-safe-int/-/max-safe-int-1.0.0.tgz", + "integrity": "sha1-RPuo7Jk97ZH7LFo15xz5yfNpzlI=" + }, "maxmind": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/maxmind/-/maxmind-2.3.0.tgz", @@ -9624,6 +9649,33 @@ "ret": "0.1.15" } }, + "random-hexadecimal": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/random-hexadecimal/-/random-hexadecimal-1.0.3.tgz", + "integrity": "sha1-vg80y8Jbnz21I8NZpUarl//zz1c=", + "requires": { + "random-natural": "1.0.3" + } + }, + "random-integral": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/random-integral/-/random-integral-1.0.3.tgz", + "integrity": "sha1-j/PBF1ZcmgS2bd1VnzrtKb0PD2w=", + "requires": { + "clamp": "1.0.1", + "max-safe-int": "1.0.0", + "to-integer": "1.0.1" + } + }, + "random-natural": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/random-natural/-/random-natural-1.0.3.tgz", + "integrity": "sha1-7yhhWwPCy3Gq6/fyT0hyZqRDxcA=", + "requires": { + "max-safe-int": "1.0.0", + "random-integral": "1.0.3" + } + }, "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", @@ -11301,6 +11353,24 @@ "integrity": "sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=", "dev": true }, + "to-integer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/to-integer/-/to-integer-1.0.1.tgz", + "integrity": "sha1-URrUHc5qk3MKjztuNaFk/YKUZNo=", + "requires": { + "is-function": "1.0.1", + "is-nil": "1.0.1", + "is-object": "1.0.1", + "is-symbol": "1.0.1" + }, + "dependencies": { + "is-symbol": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", + "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=" + } + } + }, "tough-cookie": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", diff --git a/package.json b/package.json index c84db79..ac2601a 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "nodemailer": "^4.4.1", "popper.js": "^1.12.7", "prop-types": "^15.6.0", + "random-hexadecimal": "^1.0.3", "rc-slider": "^8.5.0", "rc-tooltip": "^3.7.0", "react": "^16.0.0", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 1266dff..4b0439e 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -180,5 +180,8 @@ "No": "No", "Sobre los datos y imágenes usados": "Sobre los datos y imágenes usados", "Términos de Servicio": "Términos de Servicio", - "Política de Privacidad": "Política de Privacidad" + "Política de Privacidad": "Política de Privacidad", + "No estás suscrito a fuegos en ninguna zona": "No estás suscrito a fuegos en ninguna zona", + "Iniciar sesión con Telegram": + "Iniciar sesión con Telegram" }