meteor3: purge dead client packages — web UI renders on 3.1
alanning:roles removed (client crashed the whole bundle; plain user.roles checks instead), selaias:cookie-consent replaced by in-repo React banner, publish-performant-counts vendored with countAsync, Meteor.autorun dropped (App)/Tracker.autorun (FiresMap), and the map publications not covered by the REST smoke (activefiresmyloc, activefiresunionmyloc, fireAlerts, oauth.verifyConfiguration) converted to async APIs. Verified in browser: / and /fires render with map + cookie banner, zero uncaught exceptions. REST smoke byte-identical (12/12).
This commit is contained in:
parent
0ff9848cd4
commit
eb3aec82ae
16 changed files with 194 additions and 50 deletions
|
|
@ -16,7 +16,7 @@ Meteor.publish('activefirestotal', function total() {
|
|||
return counter;
|
||||
});
|
||||
|
||||
const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => {
|
||||
const activefires = async (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => {
|
||||
const fires = ActiveFires.find({
|
||||
ourid: {
|
||||
$geoWithin: {
|
||||
|
|
@ -36,10 +36,10 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
|
|||
}
|
||||
});
|
||||
|
||||
if (Meteor.isDevelopment) console.log(`Active fires total: ${fires.count()}`);
|
||||
if (Meteor.isDevelopment) console.log(`Active fires total: ${await fires.countAsync()}`);
|
||||
|
||||
if (withMarks && fires.fetch().length > 0) {
|
||||
const union = firesUnion(fires);
|
||||
if (withMarks && (await fires.fetchAsync()).length > 0) {
|
||||
const union = await firesUnion(fires);
|
||||
const falsePos = whichAreFalsePositives(FalsePositives, union);
|
||||
const industries = whichAreFalsePositives(Industries, union);
|
||||
return [fires, falsePos, industries];
|
||||
|
|
@ -48,7 +48,7 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
|
|||
return fires;
|
||||
};
|
||||
|
||||
Meteor.publish('activefiresmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
||||
Meteor.publish('activefiresmyloc', async function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
||||
// latitude -90 and 90 and the longitude between -180 and 180
|
||||
check(northEastLng, NumberBetween(-180, 180));
|
||||
check(southWestLat, NumberBetween(-90, 90));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Meteor.publish('activefiresuniontotal', function total() {
|
|||
return counter;
|
||||
});
|
||||
|
||||
const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
|
||||
const activeFiresUnion = async (b1, b2, c1, c2, withMarks) => {
|
||||
// a --- b
|
||||
// c --- d
|
||||
const geometry = {
|
||||
|
|
@ -46,7 +46,7 @@ const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
|
|||
}
|
||||
});
|
||||
|
||||
if (Meteor.isDevelopment) console.log(`Active fires union total: ${fires.count()}`);
|
||||
if (Meteor.isDevelopment) console.log(`Active fires union total: ${await fires.countAsync()}`);
|
||||
|
||||
/*
|
||||
if (withMarks && fires.fetch().length > 0) {
|
||||
|
|
@ -59,7 +59,7 @@ const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
|
|||
return fires;
|
||||
};
|
||||
|
||||
Meteor.publish('activefiresunionmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
||||
Meteor.publish('activefiresunionmyloc', async function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
||||
// latitude -90 and 90 and the longitude between -180 and 180
|
||||
check(northEastLng, NumberBetween(-180, 180));
|
||||
check(southWestLat, NumberBetween(-90, 90));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { check } from 'meteor/check';
|
|||
import { NumberBetween } from '/imports/modules/server/other-checks';
|
||||
import FireAlerts from '../FireAlerts';
|
||||
|
||||
Meteor.publish('fireAlerts', function fireAlerts(northEastLng, northEastLat, southWestLng, southWestLat) {
|
||||
Meteor.publish('fireAlerts', async function fireAlerts(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));
|
||||
|
|
@ -37,6 +37,6 @@ Meteor.publish('fireAlerts', function fireAlerts(northEastLng, northEastLat, sou
|
|||
track: 1
|
||||
}
|
||||
});
|
||||
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${fires.count()}`);
|
||||
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${await fires.countAsync()}`);
|
||||
return fires;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ import { ServiceConfiguration } from 'meteor/service-configuration';
|
|||
import rateLimit from '../../../modules/rate-limit';
|
||||
|
||||
Meteor.methods({
|
||||
'oauth.verifyConfiguration': function oauthVerifyConfiguration(services) {
|
||||
'oauth.verifyConfiguration': async function oauthVerifyConfiguration(services) {
|
||||
check(services, Array);
|
||||
|
||||
try {
|
||||
const verifiedServices = [];
|
||||
services.forEach((service) => {
|
||||
if (ServiceConfiguration.configurations.findOne({ service })) {
|
||||
for (const service of services) {
|
||||
if (await ServiceConfiguration.configurations.findOneAsync({ service })) {
|
||||
verifiedServices.push(service);
|
||||
}
|
||||
});
|
||||
}
|
||||
return verifiedServices.sort();
|
||||
} catch (exception) {
|
||||
throw new Meteor.Error('500', exception);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* global CookieConsent Intl */
|
||||
/* global Intl */
|
||||
import i18n from 'i18next';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
|
|
@ -89,23 +89,9 @@ i18n.use(backend)
|
|||
|
||||
i18nReady.set(true);
|
||||
|
||||
// cookies eu consent
|
||||
const cookiesOpt = {
|
||||
cookieTitle: t('Uso de Cookies'),
|
||||
cookieMessage: t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso'),
|
||||
/* cookieMessage: t('Uso de Cookies'),
|
||||
cookieMessageImply: t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso'), */
|
||||
showLink: false,
|
||||
position: 'bottom',
|
||||
linkText: 'Lee más',
|
||||
linkRouteName: '/privacy',
|
||||
acceptButtonText: t('Aceptar'),
|
||||
html: false,
|
||||
expirationInDays: 70,
|
||||
forceShow: false
|
||||
};
|
||||
|
||||
CookieConsent.init(cookiesOpt);
|
||||
// Cookie consent banner: selaias:cookie-consent (Blaze, dead on Meteor 3)
|
||||
// replaced by the React component imports/ui/components/CookieConsent,
|
||||
// which reuses the same i18n keys.
|
||||
});
|
||||
|
||||
Meteor.subscribe('userData'); // lang is there
|
||||
|
|
|
|||
|
|
@ -1,5 +1,18 @@
|
|||
/* global Facts */
|
||||
import { Roles } from 'meteor/alanning:roles';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Facts } from 'meteor/facts-base';
|
||||
|
||||
Facts.setUserIdFilter(userId => Roles.userIsInRole(userId, ['admin']));
|
||||
/*
|
||||
* alanning:roles removed (1.x is dead on Meteor 3 — crashes the whole client
|
||||
* bundle at load — and 4.x needs a data migration we don't want). Admin check
|
||||
* against the plain `user.roles` field, cached at startup: facts are
|
||||
* dev/admin instrumentation and the admin set essentially never changes.
|
||||
*/
|
||||
const adminIds = new Set();
|
||||
|
||||
Meteor.startup(async () => {
|
||||
await Meteor.users
|
||||
.find({ roles: 'admin' }, { fields: { _id: 1 } })
|
||||
.forEachAsync(u => adminIds.add(u._id));
|
||||
});
|
||||
|
||||
Facts.setUserIdFilter(userId => adminIds.has(userId));
|
||||
|
|
|
|||
45
imports/ui/components/CookieConsent/CookieConsent.js
Normal file
45
imports/ui/components/CookieConsent/CookieConsent.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import React, { Component } from 'react';
|
||||
import i18n from 'i18next';
|
||||
import './CookieConsent.scss';
|
||||
|
||||
/*
|
||||
* Minimal cookie-consent banner replacing selaias:cookie-consent (Blaze,
|
||||
* dead on Meteor 3: its `Cookies` global is gone and it crashed the whole
|
||||
* client bundle at load). Same behavior: informative banner, dismissed once.
|
||||
*/
|
||||
const STORAGE_KEY = 'tcef-cookie-consent';
|
||||
|
||||
class CookieConsent extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
let accepted = false;
|
||||
try {
|
||||
accepted = window.localStorage.getItem(STORAGE_KEY) === 'yes';
|
||||
} catch (e) { /* storage disabled: show banner every time */ }
|
||||
this.state = { accepted };
|
||||
this.accept = this.accept.bind(this);
|
||||
}
|
||||
|
||||
accept() {
|
||||
try {
|
||||
window.localStorage.setItem(STORAGE_KEY, 'yes');
|
||||
} catch (e) { /* ignore */ }
|
||||
this.setState({ accepted: true });
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.accepted) return null;
|
||||
return (
|
||||
<div className="CookieConsent">
|
||||
<span>
|
||||
{i18n.t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso')}
|
||||
</span>
|
||||
<button type="button" className="btn btn-primary btn-sm" onClick={this.accept}>
|
||||
{i18n.t('Aceptar')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default CookieConsent;
|
||||
20
imports/ui/components/CookieConsent/CookieConsent.scss
Normal file
20
imports/ui/components/CookieConsent/CookieConsent.scss
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
.CookieConsent {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1em;
|
||||
padding: 0.75em 1em;
|
||||
background: rgba(0, 0, 0, 0.85);
|
||||
color: #fff;
|
||||
font-size: 0.9em;
|
||||
|
||||
button {
|
||||
margin-left: 1em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ import { I18nextProvider } from 'react-i18next';
|
|||
import { Helmet } from 'react-helmet';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { withTracker } from 'meteor/react-meteor-data';
|
||||
import { Roles } from 'meteor/alanning:roles';
|
||||
// https://github.com/gadicc/meteor-blaze-react-component/
|
||||
import Blaze from 'meteor/gadicc:blaze-react-component';
|
||||
// i18n
|
||||
|
|
@ -48,6 +47,7 @@ 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 CookieConsent from '../../components/CookieConsent/CookieConsent';
|
||||
import Footer from '../../components/Footer/Footer';
|
||||
import Feedback from '../../components/Feedback/Feedback';
|
||||
import ReSendEmail from '../../components/ReSendEmail/ReSendEmail';
|
||||
|
|
@ -151,7 +151,7 @@ const App = props => (
|
|||
<Footer />
|
||||
<Reconnect {...props} />
|
||||
<Feedback {...props} />
|
||||
{props.i18nReady.get() && <Blaze template="cookieConsent" /> }
|
||||
{props.i18nReady.get() && <CookieConsent /> }
|
||||
</div>}
|
||||
</LocationListener>
|
||||
</Router>
|
||||
|
|
@ -183,19 +183,16 @@ export default withTracker(() => {
|
|||
const loggingIn = Meteor.loggingIn();
|
||||
const user = Meteor.user();
|
||||
const userId = Meteor.userId();
|
||||
const loading = !Roles.subscription.ready() || !i18nReady.get();
|
||||
const loading = !i18nReady.get();
|
||||
const name = user && user.profile && user.profile.name && getUserName(user.profile.name);
|
||||
const emailAddress = user && user.emails && user.emails[0].address;
|
||||
Meteor.autorun(() => {
|
||||
console.log(`i18n ready?: ${i18nReady.get()}`);
|
||||
});
|
||||
return {
|
||||
loading,
|
||||
loggingIn,
|
||||
i18nReady,
|
||||
authenticated: !loggingIn && !!userId,
|
||||
name: name || emailAddress,
|
||||
roles: !loading && Roles.getRolesForUser(userId),
|
||||
roles: (user && user.roles) || [],
|
||||
userId,
|
||||
emailAddress,
|
||||
emailVerified: user && user.emails ? user && user.emails && user.emails[0].verified : true
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { ButtonGroup, Row, Col, Checkbox } from 'react-bootstrap';
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { withTracker } from 'meteor/react-meteor-data';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { Trans, translate } from 'react-i18next';
|
||||
import { Map } from 'react-leaflet';
|
||||
|
|
@ -408,7 +409,7 @@ export default translate([], { wait: true })(withTracker(() => {
|
|||
}
|
||||
// Disable, because this increase the number of fires by one
|
||||
// Meteor.subscribe('lastFireDetected');
|
||||
Meteor.autorun(() => {
|
||||
Tracker.autorun(() => {
|
||||
if ((centerStored !== [0, 0] || geolocation.get()) && geoInit) {
|
||||
center.set(centerStored || geolocation.get());
|
||||
// console.log(`Geolocation ${geolocation.get()}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue