Skip to content

Support modifications via a proposal layer - #67

Open
danaradg wants to merge 13 commits into
hasadna:mainfrom
danaradg:main
Open

Support modifications via a proposal layer#67
danaradg wants to merge 13 commits into
hasadna:mainfrom
danaradg:main

Conversation

@danaradg

Copy link
Copy Markdown

What was achieved

  • Users can authenticate with Google
  • Users can see their location on the map
  • Authenticated users can:
    • Confirm unconfirmed trees
    • Mark information as up to date
    • Edit tree fields and upload images
    • View field change history

Behind the Scenes

  • Change history is stored in Firebase separately from the original dataset. The UI merges the information.
  • There's a feature flag called enableauth that is false by default, and only when enabled the UI shows the new interfaces. You can enable it by adding ?enableauth=true to the URL.
  • Firebase is currently hosted in a temporary Google Classroom GCP project and needs to be setup under Hasadna's resources.

Setting Up Firestore

  1. In GCP, create a new Firestore project

  2. In the project, initialize FireStore and create a new DB called "treebase-proposals", with a collection called "propsoals". Set the following access rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /proposals/{proposalId} {
      // Allow anyone to read existing proposals
      allow read: if true;

      // Allow any authenticated user (including anonymous & Google users) to create proposals
      allow create: if request.auth != null;

      // Allow author to update or delete their proposal
      allow update, delete: if request.auth != null && request.auth.uid == resource.data.authorUid;
    }
  }
} 
  1. In the project, initialize Storage. Set the following access rules:
rules_version = '2';

service firebase.storage {
  match /b/{bucket}/o {
    match /proposals/images/{fileName} {
      allow read, write: if request.auth != null;
    }
  }
}
  1. Under Settings -> General for the Firebase project, scroll down to Your Apps -> SDK setup and configuration -> Config. Copy the code snippet containing the API key, domains, paths, etc and paste it into app/config/firebase_config.ts

Gaps & Future Work

  • The current version expects the Firebase config file to be under projects/treebase/src/app/config/firebase-config.ts. It should take the path from the environment.
  • The app is not mobile friendly. There are issues with the map's touch interface which is crucial for selecting trees, and there are issues with the layout making the sidebar unusable.
  • Any authenticated user can edit any tree. At minimum we need to be able to restrict editing to only persons assigned to the municipality where the tree resides in.
  • All proposals are currently pulled from the DB at startup, and this is obviously not scalable. It's easy to limit it with respect to the tree sidebar view, but a bit harder around the map view where we use it to check if the certainty of the tree has changed.
  • Proposals should be periodically synched in the background to create a new version of the dataset. Then we can shard the proposals database by date and merge only proposals since the last sync point.

lisardggY and others added 13 commits July 30, 2026 17:21
Add AuthService for Google Auth management using Google Auth Lib and integrate single avatar image with Google login dropdown menu matching app color scheme and warning notice in top level nav bar (HeaderComponent). Add Material Icons stylesheet link to index.html.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99
Add AuthService for Google Auth management using Google Auth Lib and integrate single avatar image with Google login dropdown menu matching app color scheme and warning notice in top level nav bar (HeaderComponent). Add Material Icons stylesheet link to index.html.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99
Add AuthService for Google Auth management using Google Auth Lib and integrate single avatar image with Google login dropdown menu matching app color scheme and warning notice in top level nav bar (HeaderComponent). Add Material Icons stylesheet link to index.html.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99
Add AuthService and UI for Google logins
Add FeatureFlag support

* Create featureflags.ts under app/config containing active feature flags: EnableAuth = true.
* Update the auth service to always return "no authentication" if EnableAuth = false.
* Update the header to only show the Login button if EnableAuth = true.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Add EnableAuth feature flag check to AuthService and HeaderComponent

Check EnableAuth feature flag from FeatureFlag.ts in AuthService and HeaderComponent. When disabled, AuthService loads in disabled mode and login buttons are hidden from the top-level nav bar while maintaining non-auth guest behavior for other services.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Rename FeatureFlag.ts to featuresflag.ts and update import path

Rename FeatureFlag.ts to featuresflag.ts under app/config and update import reference in AuthService.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Export FeatureFlag enum from featureflags.ts and update AuthService usage

Export FeatureFlag enum from app/config/featureflags.ts and update AuthService to use FeatureFlag.EnableAuth instead of hardcoded strings.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Support URL query parameter overrides for feature flags

Allow overriding feature flags via URL query parameters for testing (e.g. ?EnableAuth=false or ?EnableAuth=true).

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Rename feature flag EnableProposalApproval to EnableTreeEditing

Rename FeatureFlag member EnableProposalApproval to EnableTreeEditing in app/config/featureflags.ts.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Remove EnableTreeEditing feature flag

Remove EnableTreeEditing feature flag from app/config/featureflags.ts.

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Import FIREBASE_CONFIG from firebase-config instead of template in AuthService

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99

* Clean top navbar links in HeaderComponent

TAG=agy
CONV=57f44933-b7b2-4627-89b3-01b432e15d99
Create ProposalBackendService

List and Create Proposals from FireStore.
Store images in FireBase Storage.
Enable showing user location
Enable dataset change proposals
@lisardggY

Copy link
Copy Markdown

Ideally, we would want to integrate the auth-service with the backend service used by the SocialProcurement site to assign roles to users based on municipal association.

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

Successfully merging this pull request may close these issues.

2 participants