Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom React Frontend + geonode API #11919

Open
flieks opened this issue Feb 2, 2024 · 14 comments
Open

Custom React Frontend + geonode API #11919

flieks opened this issue Feb 2, 2024 · 14 comments

Comments

@flieks
Copy link

flieks commented Feb 2, 2024

I know there is the mapstore example project to use mapstore frontend
https://github.com/GeoNode/geonode-mapstore-client

but it is using there own plugin architecture with old react 16 and redux so it is not what we want.

I would want to develop our own frontend and connect to geonode api but i can not find in the docs how to only run the backend API. We also want to connect our own azure SSO AD.

if i run geonode from the devcontainer all 8 docker containers startup but the django4geonode fails because it cant connect to the postgres db:
connection to server at "db" (172.22.0.6), port 5432 failed: FATAL: password authentication failed for user "geonode_data"

db4geonode ran fine, only has this in the end
PostgreSQL Database directory appears to contain a database; Skipping initialization

i cannot access postgress from pgadmin app or browser (localhost:5432). According to .devcontainer/.env vars:
DATABASE_HOST=db
DATABASE_PORT=5432
DATABASE_URL=postgis://geonode:geonode@db:5432/geonode

Greetings

@flieks
Copy link
Author

flieks commented Feb 2, 2024

I can run the project now and view it in browser localhost. Just not yet connect in pgadmin.
i puted host db, the creds from the root env file

POSTGRES_USER=postgres
POSTGRES_PASSWORD=xxxxxxx

DATABASE_HOST=db
DATABASE_PORT=5432

But i get
connection is bad: No such host is known.

@mattiagiupponi
Copy link
Contributor

db4geonode ran fine, only has this in the end
PostgreSQL Database directory appears to contain a database; Skipping initialization

This (usually) means that the docker db volumes where already there.
If you can, i would suggest u to delete the volumes and re-run the docker container.

db is the service name we use in the docker. I guess if you want to see it from pg-admin u should expose the port in the docker-file and then use localhost to connect pgadmin to the db

@flieks
Copy link
Author

flieks commented Feb 2, 2024

@mattiagiupponi

Thanks, i changed dockerFile to this
EXPOSE 8000 5432

and used localhost as host
and from .env

POSTGRES_USER=postgres
POSTGRES_PASSWORD=xxxxxxx

But still i get the error in pgadmin
connection failed: :1), port 5432 failed: FATAL: password authentication failed for user "postgres"

@flieks
Copy link
Author

flieks commented Feb 2, 2024

i also uncommented

ports:
     - "5432:5432"

in docker-compose.yml and docker-compose-dev.yml but did not help

@ridoo
Copy link
Contributor

ridoo commented Feb 3, 2024

I would want to develop our own frontend and connect to geonode api but i can not find in the docs how to only run the backend API. We also want to connect our own azure SSO AD.

Do you have specific requirements your web client shall be able to serve. The one you already mention is Azure SSO which could be already possible. Not sure if you already had a look here:

However, I am more interested in how far you plan to get when implementing a custom solution based on the GeoNode API. I am asking because from different kinds of project contexts we often have (naturally) different kinds of requirements, but mostly the need for light-weighted clients.

However, running a completely headless GeoNode would be as simple as removing the GeoNode-mapstore-client from INSTALLED_APPS, I guess. But I am sure, that you will run into some limitations regarding API (at least when using the current version). See

What is your approach and will it be OpenSource?

@flieks
Copy link
Author

flieks commented Feb 4, 2024

@ridoo that is interesting. Thanks for the links.

Indeed i didnt develop yet in mapstore/geonode but checked a bit both codebases. And mapstore is heavy java with react and geonode is all django so also backend and frontend mixed. I see the django and api are in same container so the API isnt really seperated yet.

We are still investigating all options how we want to build it. It is for private company so will not be open source.

I also tested the map search on the right in geonode after i added 2 datasets to the map. I clicked on something in a layer to see its metadata on the right which was some description. I then searched for 1 word that is in the description but it could not find it. It only showed addresses that had that keyword. A major functionality that we need it cross-layer and cross-attribute search. Is that possible with geonode ?

Thanks

@ridoo
Copy link
Contributor

ridoo commented Feb 4, 2024

I see the django and api are in same container so the API isnt really seperated yet.

GeoSolutions is going away from using Django templates and using react client (MapStore2) and REST API instead. In fact, this was a huge step in v4 (but I am unsure if v4 is feature par with v3 again), but there are some legacy parts still using templates, and the metadata editor is one (the last?). However, migrating the editor is not straight forward and we evaluating some conceptual ideas here (using OpenAPI description vs. geonode-mapstore-client API).

A major functionality that we need it cross-layer and cross-attribute search. Is that possible with geonode ?

What do you mean by that? If you want to search in GeoNode by content this is not possible, as it serves metadata about geo data. However, we at 52n are about to evaluate ways to make possible cross data search in research data infrastructures without adding a bottleneck into the whole system. However, we are in the starting phase here, so if you are interested you may want to share your thoughts and requirements.

@flieks
Copy link
Author

flieks commented Feb 4, 2024

The problem is mapstore has its own complex plugin architecture and layers build on (old) redux and on an old version of react with webpack. All that stuff dictates then the entire frontend setup. We would prefer using react 18, atom based state, apollo, VITE build system and more simplified folder structure because it wont use redux where these actions/components/containers are in different locations. We want to go much further then standard mapstore functionality and not all are map related features.

Does this mean geonode could be discontinued if they move more and more to mapstore ?
Or maybe python API from geonode will still survive nstead of the JAVA one from mapstore.

About cross-layer, i mean search in all metadata of all shapefiles (attributes) wherever they are located (all layers or dataset in db). Possibly importing and indexing this in elasticsearch is the way to go here.

@flieks
Copy link
Author

flieks commented Feb 4, 2024

I am also wondering if geonode will fetch changes that were added to WMS layers after this WMS was added to geonode and its resources were imported via the harvester into postgis. And how does it get these changes/additions ?

@giohappy
Copy link
Contributor

giohappy commented Feb 5, 2024

Does this mean geonode could be discontinued if they move more and more to mapstore ?
Or maybe python API from geonode will still survive instead of the JAVA one from mapstore.

@flieks I know MapStore can be a bit confusing (for historical reasons). Let me clarify some points:

  • MapStore refers both to a product (with its own Java-based backend, known as "GeoStore") and a JS framework / client application
  • MapStore as a client application is what has been adopted in GeoNode to implement its client app. As @ridoo said we have started the transition toward a separation between the client app and the backend API with GeoNode 4. There's still some work to complete it but this is the direction
  • There isn't any plan to drop the GeoNode backend and replace it with GeoStore. On the contrary, the plan is to make the MapStore client the more agnostic as possible, by implementing adapters for the different backends (GeoNdoe, GeoStore). There are functionalities in some of MapStore's plugins that are tied to the Geostore API, or to the "MapStore product" layout, but we're working to reduce this coupling. I can already announce that we're advancing the MapStore module in GeoNode to the latest version for this reason, to put it on pair with the MapStore product and share more functionalities between the various products. As an example, I know of projects that are employing Flutter to develop mobile apps on tome of the GeoNode APis (integrated with Oauth2 authentication)

At the moment the GeoNode API covers everything that can be done from its frontends (MapStore + legacy templates). It's not as clean and auto-documented as everybody wishes, but I would say that with some effort you can drive GeoNode completely with a custom frontend app. @ridoo what do you think we miss here?

@flieks
Copy link
Author

flieks commented Feb 5, 2024

@giohappy thanks for the clarification.

This the latest geonode API?
geonode swagger v2
because @ridoo was talking about v4. He probably meant the mapstore client v4 is feature par with latest mapstore2.

Is there a github repo or folder where only the api is inside or it could be as easy of removing the geonode django code and folders from this repo main branch ?

About mapstore client, you mean this repo here ?
mapstore client
There are files in geonode_mapstore_client/client/ with the react code.
And lots of django template files in geonode_mapstore_client/templates/geonode-mapstore-client. We will need this django templates ?

Does the current geonode api allow searching in multiple layers and multiple feature metadata attribute fields at once ? I think some kind of indexing like with elasticsearch would be needed for that..

@dgquail
Copy link

dgquail commented May 13, 2024

Hello everyone. I have been reading this interesting thread and had some queries regarding mapstore client (mapstore2) and geonode.
Looking a little at the geonode repository, we have noticed that, for example in version 4.2.0 of geonode, it has as in requirements.txt:
django-geonode-mapstore-client==4.2.0.

Now looking at the code in the geonode-mapstore-client repository in the file geonode_mapstore_client/client/package.json it has Mapstore2 as a dependency on the following line:
"mapstore": "file:MapStore2",
which is a specific commit of the Mapstore2 project (geosolutions-it/MapStore2@ce0069d).

The question is:
Could this dependency on mapstore-client be changed and go to the latest version of Mapstore2?
Could a React upgrade be done both in mapstore-client and in Mapstore2?
What could happen to geonde?

What we are looking for is to have a geonode with the latest versions of React and Mapstore2, or the most recent.
I appreciate in advance if you can give me your observations or suggestions.

Thanks!

@ridoo
Copy link
Contributor

ridoo commented May 13, 2024

Hey @dgquail, GeoSolutions is currently working on updating geonode-mapstore-client to use latest MapStore2. The dependency is declared as Git submodule. However, that MapStore2 version is using react version 16 .. not sure when they will upgrade to v18, though.

@giohappy
Copy link
Contributor

giohappy commented May 13, 2024

I confirm what @ridoo said. GeoNode 4.3.0, which should be released in a few days, will be aligned with MapStore 2024.01.00, which has been released a few days ago.

The React version adopted by the client depends on the version in MapStore. I'm not aware of any plan for its upgrade, for the moment, although the team is certainly willing to do it sooner than later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants