sidferreira / aor-firebase-client Goto Github PK
View Code? Open in Web Editor NEWFirebase client for Admin on Rest
License: MIT License
Firebase client for Admin on Rest
License: MIT License
Hi,
Admin-On-Rest was renamed to React Admin with its 2.0 upgrade.
Will you plan to support this version as well ?
Thank you!
Right now we seem to be sending the entire record to Firebase's update
function, instead of just the properties that have been updated in AOR. This could cause problems. To illustrate:
foo
in AOR.foo
joins a group bar
in My app.users/foo/groups/bar
in Firebase DB.foo
's name to "John Doe" in AOR.users/foo/groups/bar
will be deleted from Firebase DB by AOR.users/foo/name
will be set to "John Doe" in Firebase DB by AOR.foo
is no longer a member of group bar
in my app.Could it be solved by a comparison of params.previousData
vs params.data
before posting to firebase, then posting only the fields that have been changed?
I spotted two errors in the README example.
firebaseConfig
instead of trackedResources
:This:
<Admin restClient={RestClient(trackedResources, clientOptions)} >
should be:
<Admin restClient={RestClient(firebaseConfig, clientOptions)} >
clientOptions.trackedResources
object should be isPublic:true
instead of public: true,
according to the source code.Hi guys !
First of all, thanks for your library :) I have a issue when I want to insert data in firebase ! Data are inserted but not in the correct path on firebase !
This is my route when I want to create an event for example:
http://localhost:3000/admin/events/create
I would to like that data are inserted into /events, but here data are saved in /admin/events.
This is normal because your library uses the basepath which corresponds to the location path:
restClient.js#L142
Maybe, it could be better to to get the firebase reference on the resource, not on the basepath, like you do
Thanks in advance !
I'm having an issue with loading my data. I get a popup that says Cannot read property then of undefined
and I'm assuming that means it can not load the data.
App.js
import React from 'react';
import UserIcon from 'material-ui/svg-icons/social/group';
import { Admin, Resource } from 'admin-on-rest';
import { UserList } from './Users';
import { RestClient, AuthClient } from 'aor-firebase-client';
import config from './app.json' // IT PULLS IN MY CONFIG AS EXPECTED
const trackedResources = ['users, connections']
const App = () => (
<Admin restClient={RestClient(trackedResources, config.firebaseConfig)} authClient={AuthClient}>
<Resource name="users" list={UserList} icon={UserIcon} />
</Admin>
);
export default App;
Users.js
import React from 'react';
import { List, Datagrid, EmailField, TextField } from 'admin-on-rest';
export const UserList = (props) => (
<List title="All users" {...props}>
<Datagrid>
<TextField source="company" />
<TextField source="name" />
<TextField source="paymentId" />
<EmailField source="email" />
</Datagrid>
</List>
);
schema
users
id
name
company
email
paymentId
When I try to add RestClient to admin like this:
<Admin restClient={RestClient(trackedResources, firebaseConfig)} authClient={AuthClient}>
<Resource name="users" list={UserList} edit={UserEdit} icon={UserIcon}/>
</Admin>
And the resource "users" is guarded by firebase permission rules, and is not loaded. The login page is either hanged if access "/users" directly, or login successfully but then "users" is not loaded.
After debugging, it seems to me that the firebase client is binding to the resource "users" without checking for authentication status, the firebase web-socket frame returns "permission denied" and then hang then.
There might be 2 improvements needed:
I can't get the user to persist.
I can login fine, but upon browser refresh, firebase.auth().currentUser is null.
The token firebaseToken is set in localStorage.
Everything else is pretty similar to your demo.
And, how is data structured in firebase? E.g. from your demo?
admin-on-rest changed name on react-admin. Can u fix it?
Firebase token seems to expire every 1 hour.
This causes problems when there are actions to be made, is there a way to automatically refresh the token in the background before the hour expires? Or some other solution?
We want the logged-in user to remain logged-in until they choose to logout.
Thanks.
P.S. Similar discussion here (for Android apps though):
https://stackoverflow.com/questions/38350843/how-to-handle-custom-firebase-token-expiry-in-firebase-3-x-x
P.S. Using react-admin v2.1.2
(please update for latest react-admin, thanks!)
Now, all data is fetched to the client and then all operations like filtering apply to these data in the client side. This approach is not ideal for huge data.
When using authClient I get the following error:
TypeError: __webpack_require__.i(...) is not a function
App
src/App.js:19
16 | const trackedResources = ['configs'];
17 |
18 | const App = () => (
> 19 | <Admin restClient={RestClient(trackedResources, firebaseConfig)} authClient={AuthClient(firebaseConfig)}>
20 | <Resource name="Configs" list={ConfigList} edit={ConfigEdit} />
21 | </Admin>
22 | );
View compiled
It works when removed. My code is really simple:
// in src/App.js
import React from 'react';
import {Admin, Resource} from 'admin-on-rest';
import {ConfigList, ConfigEdit} from './config';
import {RestClient, AuthClient} from 'aor-firebase-client';
const firebaseConfig = {
};
const trackedResources = ['configs'];
const App = () => (
<Admin restClient={RestClient(trackedResources, firebaseConfig)} authClient={AuthClient(firebaseConfig)}>
<Resource name="Configs" list={ConfigList} edit={ConfigEdit} />
</Admin>
);
export default App;
Hi, starting up a new project with this client. I was wondering if there were a way to access the Firebase schema in the demo, or at least for you to provide an example. No problem getting the auth to work, but having issues loading resources as the loading circle just keeps spinning without any feedback on whether it's actually sending the firebase db query.
So, guys, I'm really sad that I'm not delivering the updates here as I want.
The fact is that I'm having a CRAZY amount of work since August.
So, in order to plan things a bit, I would like to know if you guys would like to help me on TESTING the new version.
Testing is BY FAR what takes most of the time. If you guys are up to helping on it, I can start working in a new version (react-admin based and include Firestore) if you guys accept to help me on it.
So, I would like to anyone who wants to help at least on testing to reply here.
@Kmaschta @photocat @nietzscheson @afilp @pelanmar1 @leomyth330 @erickvictor @georgerb @bvivek20 @jesster2k10 @matseriksen @roadev @jjjjjjjjjjjjjjjjjjjj @RWOverdijk @Hosnidokht
Important to mention that I'm not using it that much, so, I will need this help in order to help you.
I want to rewrite it from scratch, first for RealTime Database and later for Firestore, in a well structured way that allows you to override parts of the code and improve functionality.
ps: Anyone that wants helps CODING it will be welcome too :)
According to the recommended approach to save files and images in firebase, it is necessary to save these files in storage first (e.x, ) and then add file URL to realtime database with the other data. it needs to implement in CREATE, UPDATE and DELETE.
In this case the target and id is sending in params and needs to handle.
I tried with sample project and it works fine until creating the model. But after creating, it redirects to edit page and all inputs are empty.
It's filled again if I refresh the browser.
How can I fix this?
Hi! Great lib.
I advise you to add the admin-on-rest
tag to your Github repository, and open a PR on https://github.com/marmelab/admin-on-rest/blob/master/docs/RestClients.md to add your client there.
Any plans to support the new React Admin and Firestore?
Im playing around with the demo and when I try to login with the user I created in firebase, the user is found, but says "access denied". In firebase auth it says I was logged in. Anybody know how to fix this?
'./reference' does not contain an export named 'AUTH_CHECK'.
import React from 'react';
import { Admin, Resource } from 'admin-on-rest';
import { RestClient } from 'aor-firebase-client';
import { PostList } from './posts';
const firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: "",
messagingSenderId: ""
};
const clientOptions = {
timestampFieldNames: {
createdAt: 'createdAt',
updatedAt: 'updatedAt'
},
trackedResources: {
name: 'posts', // The name reference to be used in all other places in AOR
path: 'blog', // The path in the database. If missing will use the name
public: true,
uploadFields: [] // The string name of the field
} // A single string assumes path and name as equal, non private and without upload fields
}
const App = () => (
< Admin restClient={RestClient(clientOptions)} >
< /Admin>
);
export default App;
Is any way this can be used to connect with firestore instead of realtime database?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.