AvatarsRegistre no suspense
This commit is contained in:
parent
56a0b76c6d
commit
023f73355d
@ -120,8 +120,13 @@ if (Meteor.isServer) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Meteor.publish('avatars.all', () => {
|
Meteor.publish('avatars.all', () => {
|
||||||
return Avatars.collection.find({});
|
return Avatars.collection.find();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Meteor.publish('avatarsregistre.all', () => {
|
||||||
|
return AvatarsRegistre.collection.find();
|
||||||
|
});
|
||||||
|
|
||||||
// Meteor.publish('files.avatar', () => {
|
// Meteor.publish('files.avatar', () => {
|
||||||
// return FilesCol.collection.find({
|
// return FilesCol.collection.find({
|
||||||
@ -225,6 +230,15 @@ Meteor.methods({
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create a new instance of the FilesCollection
|
||||||
|
const AvatarsRegistre = new FilesCollection({
|
||||||
|
collectionName: 'AvatarsRegistre',
|
||||||
|
storagePath: 'assets/avatarRegistreStorage',
|
||||||
|
downloadRoute: '/avatar-registre',
|
||||||
|
permissions: 0o755,
|
||||||
|
cacheControl: 'public, max-age=31536000',
|
||||||
|
allowClientCode: false, // Disallow remove files from Client
|
||||||
|
});
|
||||||
|
|
||||||
// Create a new instance of the FilesCollection
|
// Create a new instance of the FilesCollection
|
||||||
const Avatars = new FilesCollection({
|
const Avatars = new FilesCollection({
|
||||||
@ -272,4 +286,4 @@ Meteor.methods({
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export { FilesCol, Avatars };
|
export { FilesCol, AvatarsRegistre, Avatars };
|
||||||
@ -2,10 +2,11 @@ import React, { useState, useEffect, useRef } from 'react';
|
|||||||
import { Accounts } from 'meteor/accounts-base';
|
import { Accounts } from 'meteor/accounts-base';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { useTracker, useSubscribe, useFind } from 'meteor/react-meteor-data/suspense';
|
// import { useTracker, useSubscribe, useFind } from 'meteor/react-meteor-data/suspense';
|
||||||
|
import { useSubscribe, useFind } from 'meteor/react-meteor-data';
|
||||||
import { Roles } from 'meteor/roles';
|
import { Roles } from 'meteor/roles';
|
||||||
import { ROLS_GLOBALS } from '../roles';
|
import { ROLS_GLOBALS } from '../roles';
|
||||||
import { Avatars } from '/imports/api/files.js';
|
import { AvatarsRegistre } from '/imports/api/files.js';
|
||||||
import AvatarFileUpload from '/imports/ui/files/AvatarFileUpload';
|
import AvatarFileUpload from '/imports/ui/files/AvatarFileUpload';
|
||||||
|
|
||||||
|
|
||||||
@ -26,12 +27,10 @@ export const Login = () => {
|
|||||||
|
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
|
|
||||||
// useSubscribe('avatars.all');
|
// useSubscribe('avatarsregistre.all');
|
||||||
|
const isLoading = useSubscribe('avatarsregistre.all');
|
||||||
|
|
||||||
// files = useFind(Avatars, [
|
const files = useFind(() => AvatarsRegistre.find(), []);
|
||||||
// {},
|
|
||||||
// { sort: { createdAt: -1 } },
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// }, []);
|
// }, []);
|
||||||
|
|
||||||
@ -76,6 +75,7 @@ export const Login = () => {
|
|||||||
email,
|
email,
|
||||||
password
|
password
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("userId deL NOU USUARI: ", userId);
|
console.log("userId deL NOU USUARI: ", userId);
|
||||||
userId && await Roles.addUsersToRolesAsync(userId, [ROLS_GLOBALS.USUARI]);
|
userId && await Roles.addUsersToRolesAsync(userId, [ROLS_GLOBALS.USUARI]);
|
||||||
navigate('/');
|
navigate('/');
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { useTracker, useSubscribe, useFind } from 'meteor/react-meteor-data/susp
|
|||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import React, { useState, useRef, Suspense } from 'react';
|
import React, { useState, useRef, Suspense } from 'react';
|
||||||
// import PropTypes from 'prop-types';
|
// import PropTypes from 'prop-types';
|
||||||
import { Avatars } from '/imports/api/files.js';
|
import { AvatarsRegistre } from '/imports/api/files.js';
|
||||||
|
|
||||||
import IndividualFileStart from '/imports/ui/files/IndividualFile.jsx'; // <-------------------------
|
import IndividualFileStart from '/imports/ui/files/IndividualFile.jsx'; // <-------------------------
|
||||||
|
|
||||||
@ -23,16 +23,16 @@ const AvatarFileUpload = (props) => {
|
|||||||
// const refForm = useRef();
|
// const refForm = useRef();
|
||||||
const fileinput = useRef();
|
const fileinput = useRef();
|
||||||
|
|
||||||
useSubscribe('avatars.all');
|
useSubscribe('avatarsregistre.all');
|
||||||
|
|
||||||
const files = useFind(Avatars, [
|
const files = useFind(AvatarsRegistre, [
|
||||||
{},
|
{},
|
||||||
{ sort: { createdAt: -1 } },
|
{ sort: { createdAt: -1 } },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// const files = useTracker("avatars", async () => {
|
// const files = useTracker("avatars", async () => {
|
||||||
// // const docsReadyYet = filesHandle.ready();
|
// // const docsReadyYet = filesHandle.ready();
|
||||||
// const files = await Avatars?.find({meta:{userId: props.uidProvisional || Meteor.userId(), entId: props.entId}}, {sort: {name: 1}})//.fetchAsync(); // Meteor.userId() ?? "nop"
|
// const files = await AvatarsRegistre?.find({meta:{userId: props.uidProvisional || Meteor.userId(), entId: props.entId}}, {sort: {name: 1}})//.fetchAsync(); // Meteor.userId() ?? "nop"
|
||||||
|
|
||||||
// return files;
|
// return files;
|
||||||
// }, []);
|
// }, []);
|
||||||
@ -59,7 +59,7 @@ const AvatarFileUpload = (props) => {
|
|||||||
// setPreview(file);
|
// setPreview(file);
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
let uploadInstance = Avatars.insert({
|
let uploadInstance = AvatarsRegistre.insert({
|
||||||
file,
|
file,
|
||||||
meta: {
|
meta: {
|
||||||
locator: props.fileLocator,
|
locator: props.fileLocator,
|
||||||
@ -153,7 +153,7 @@ const AvatarFileUpload = (props) => {
|
|||||||
|
|
||||||
const Display = async () => await files?.map(async (aFile, key) => {
|
const Display = async () => await files?.map(async (aFile, key) => {
|
||||||
|
|
||||||
let link = await Avatars.findOneAsync({_id: aFile._id}); //The "view/download" link
|
let link = await AvatarsRegistre.findOneAsync({_id: aFile._id}); //The "view/download" link
|
||||||
let linkOriginalURL = `${window.location.origin}${link._fileRef._downloadRoute}/${link._fileRef._collectionName}/${link._fileRef._id}/original/${link._fileRef._id}.${link._fileRef.extension}`;
|
let linkOriginalURL = `${window.location.origin}${link._fileRef._downloadRoute}/${link._fileRef._collectionName}/${link._fileRef._id}/original/${link._fileRef._id}.${link._fileRef.extension}`;
|
||||||
|
|
||||||
// Send out components that show details of each file
|
// Send out components that show details of each file
|
||||||
@ -214,7 +214,7 @@ const AvatarFileUpload = (props) => {
|
|||||||
|
|
||||||
// const filesHandle = Meteor.subscribe('files.all');
|
// const filesHandle = Meteor.subscribe('files.all');
|
||||||
// const docsReadyYet = filesHandle.ready();
|
// const docsReadyYet = filesHandle.ready();
|
||||||
// const files = Avatars.find({meta:{userId: props.uidProvisional || Meteor.userId()}}, {sort: {name: 1}}).fetch(); // Meteor.userId() ?? "nop"
|
// const files = AvatarsRegistre.find({meta:{userId: props.uidProvisional || Meteor.userId()}}, {sort: {name: 1}}).fetch(); // Meteor.userId() ?? "nop"
|
||||||
|
|
||||||
// return {
|
// return {
|
||||||
// docsReadyYet,
|
// docsReadyYet,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user