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

Feat: updated pagination on list projects #264

Merged
merged 12 commits into from
Oct 8, 2024
Merged

Conversation

Pradip-p
Copy link
Collaborator

@Pradip-p Pradip-p commented Oct 4, 2024

Description:

This PR updates the pagination response format for better clarity and consistency. The new response structure includes an empty results array and a pagination object with the following fields:

  • If projects not found
{
  "results": [],
  "pagination": {
    "has_next": false,
    "has_prev": false,
    "next_num": null,
    "prev_num": null,
    "page": 1,
    "per_page": 10,
    "total": 0
  }
}
  • If project:
{
  "results": [
    {
      "id": "33ca93f6-6ac4-4c91-9dc2-4d52cf14b021",
      "slug": "this-is-test-projects-041020240848",
      "name": "This is test projects",
      "description": "This is test projects",
      "per_task_instructions": "",
      "requires_approval_from_manager_for_locking": false,
      "outline": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -69.841946,
              18.518616
            ],
            [
              -69.841946,
              18.510113
            ],
            [
              -69.830249,
              18.510113
            ],
            [
              -69.830249,
              18.518616
            ],
            [
              -69.841946,
              18.518616
            ]
          ]
        ]
      },
      "no_fly_zones": null,
      "total_task_count": 80,
      "tasks": [],
      "image_url": "http://minio:9000/dtm-data/projects/33ca93f6-6ac4-4c91-9dc2-4d52cf14b021/map_screenshot.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minio%2F20241004%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241004T084822Z&X-Amz-Expires=18000&X-Amz-SignedHeaders=host&X-Amz-Signature=afb1d5e96515cc283726dc8b00d47c62eee26b67ae44ef66f71924a1658c8b8a",
      "ongoing_task_count": 0
    }
  ],
  "pagination": {
    "has_next": false,
    "has_prev": false,
    "next_num": null,
    "prev_num": null,
    "page": 1,
    "per_page": 10,
    "total": 1
  }
}

Changes Made:

  • Updated pagination response structure in the API to include:
    • results: an empty array when no items are available.
    • pagination: an object detailing the pagination status and parameters.

@github-actions github-actions bot added enhancement New feature or request backend Related to backend code labels Oct 4, 2024
@Pradip-p Pradip-p changed the title feat: updated pagination on list projects Feat: updated pagination on list projects Oct 4, 2024
@Pradip-p Pradip-p requested a review from nrjadkry October 4, 2024 08:50
@Pradip-p Pradip-p self-assigned this Oct 4, 2024
@nrjadkry
Copy link
Collaborator

nrjadkry commented Oct 4, 2024

I think we dont need outline since we use map_screenshot, but instead we can pass centroid since frontend plots the centroid in map.
Also, We should merge this only after @suzit-10 implements this in frontend.

@suzit-10
Copy link
Collaborator

suzit-10 commented Oct 8, 2024

I've pushed the frontend changes required for this pagination and project search feature

  • Update project listing logic as per the response
  • Add UI and implement the pagination, the pagination includes features like going to a specific page number by input, clicking on the page number or clicking the next or previous button, select the rows per page.
  • implement project search by project name
  • Show only those projects on the map that are displayed on the project list.

Screenshot of project dashboard page :
Screenshot from 2024-10-08 10-00-58

@nrjadkry
Copy link
Collaborator

nrjadkry commented Oct 8, 2024

Fantastic @suzit-10 . I will merge this pull request and we can see them in the development server.

@nrjadkry nrjadkry merged commit 9c7f1e8 into develop Oct 8, 2024
2 checks passed
nrjadkry added a commit that referenced this pull request Oct 9, 2024
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/commitizen-tools/commitizen: v3.29.0 → v3.29.1](commitizen-tools/commitizen@v3.29.0...v3.29.1)
- [github.com/astral-sh/ruff-pre-commit: v0.6.7 → v0.6.8](astral-sh/ruff-pre-commit@v0.6.7...v0.6.8)

* feat: added updated at field in task events table

* fix: handle exception if project not found in db

* feat(user-profile): pass watch on form props

* fix(user-profile)-#209: able to submit if the password and confirm password not matched

* fix(user-profile)-#208: validation issue

* feat: added updated_at field  when user request, lock, unlock task

* feat: added updated_at in task details endpoint

* fix: get superuser from user table instead of access token

* feat: update file and folder structure and rename `UserProfile` to `Complete UserProfile`

* refac: remove super user from AuthUser Schemas

* feat: add Breadcrumb component

* feat: replace user-profile layout component and and add new route called complete-profile

* feat: added two new enums such as IMAGE_UPLOADED & IMAGE_PROCESSED

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(task-description): Remove BLOB middleware for processing result downloads

* fix: issues reslove on updated date

* feat: added change password based on old and new password

* feat(individual-project): post date with other data on task lock/unlock

* feat(task-description): show task locked date

* feat(update-profile): add BasicDetails component

* feat(update-profile): add Header component

* feat(update-profile): add OrganizationDetail component

* feat(update-profile): add Password component

* feat(update-profile): add OtherDetails component

* feat: add common css class main-content that gives the full screen height after reducing the nav bar height

* feat(user-profile): add UpdateUserProfile component

* feat: remove the route `user-profile` add `complete-profile` from the list of routes without navbar

* feat(user-profile): update basic details

* refactor: remove user data fetching on projects page

* refactor(user-profile): revalidate user details data on basic details patch success

* feat: store user details on local storage on fetch success

* feat(user-profile): create user profile patch service

* feat(user-profile): call user details api on userProfile of nav section

* feat(user-profile): update organization details

* feat(user-profile): update other details

* feat(user-profile): update password

* fix: typo

* fix: minor style

* fix: typo

* fix(ser-profile): make patch request on profile data change

* feat(user-profile): show error message

* hot-fix(user-profile): check old & new password before verify the password

* fix: added message if user do not sent old and new password

* refac: exception raise on password check

* feat(user-profile): redirect to complete profile page if the user not completed the signup

* feat(user-profile): redirect to complete profile on google auth success

* fix(user-profile): minor UI

* fix(user-profile): navigate to complete profile only after the profile fetching is completed

* fix: typo

* used presigned url for map screenshot in projects endpoint

* feat: added search features in projects read endpoit

* fix(update-userProfile): update background color

* feat(dashboard): show user role

* feat: updated the task as completed after process from s3

* Feat: updated pagination on list projects (#264)

* feat: updated pagination on list projects

* refactor(project): make fetching query dyanamic so the querykey, params can be pass dynamically

* refactor(project): update project list fetching service params

* feat: add usePagination hook

* feat: add Pagination component

* refactor(dashboard-map-section): remove api call and get project list through props

* feat(project-dashboard): implement pagination on project list

* feat: update searchInput component

* feat(project-dashboard): implement project search

* feat(project-dashboard): make responsive header

* fix: added new pydentic model class for read the single project

---------

Co-authored-by: Sujit <[email protected]>

* feat: update task state to reflect the start of image processing

* fix: remove comment from the task update function

* fix: adjust the state based on processing...

* fix: refine the state of task processing

* Feat: Updated the task as completed after process from S3 (#270)

* feat: updated the task as completed after process from s3

* feat: update task state to reflect the start of image processing

* fix: remove comment from the task update function

* fix: adjust the state based on processing...

* fix: refine the state of task processing

* feat(projects): Show status on project card

* feat(dashboard): update UI and pass other project details on project card props

* feat: update the status of each projects on projects list endpoint

* feat(dashboard): show slug on project card

* feat: refine the status of tasks

* feat(project-details): add new status on legend

* feat(project-details): show skeleton on project data fetching

* feat(project-details): fill different color for completed task and image uploaded task

show go to task button

* feat(project-details): show loader on table

* feat(dashboard): make logs table responsive

* feat: add Status chip component

* feat(project-dashboard): show complete status on project card

* feat: fill circle color code from properties on VectorLayerWithCluster component

* feat(project-description): add different color code as per project status on properties of projects geojson

* hotfix: Update project/id to project_id in S3 image processing logic

* feat: reduce table height

* feat(project-details): image processing status text update

* fix(project-details): available tasks not showing on table

behave the task not having state as available tasks

* fix: added asyncio event loop to call async update_task_state in process_images_from_s3

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Feat: Show project status and task status on map and project cards (#272)

* fix(update-userProfile): update background color

* feat(dashboard): show user role

* feat(projects): Show status on project card

* feat(dashboard): update UI and pass other project details on project card props

* feat(dashboard): show slug on project card

* feat(project-details): add new status on legend

* feat(project-details): show skeleton on project data fetching

* feat(project-details): fill different color for completed task and image uploaded task

show go to task button

* feat(project-details): show loader on table

* feat(dashboard): make logs table responsive

* feat: add Status chip component

* feat(project-dashboard): show complete status on project card

* feat: fill circle color code from properties on VectorLayerWithCluster component

* feat(project-description): add different color code as per project status on properties of projects geojson

* feat: reduce table height

* feat(project-details): image processing status text update

* fix(project-details): available tasks not showing on table

behave the task not having state as available tasks

---------

Co-authored-by: Sujit <[email protected]>

* fix: resolve RuntimeError for missing event loop in AnyIO worker thread

* hot-fix: minor UI issue on chip

* feat: added asgiref package to convert the async to sync function

* feat(project-description): increase opacity of task completed tasks fill color

* fix: completed task status count

* fix: update ongoing_task_count to count tasks in specific states of projects

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Pradip-p <[email protected]>
Co-authored-by: Sujit <[email protected]>
Co-authored-by: Pradip Thapa <[email protected]>
Co-authored-by: Sujit <[email protected]>
nrjadkry added a commit that referenced this pull request Oct 14, 2024
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/commitizen-tools/commitizen: v3.29.0 → v3.29.1](commitizen-tools/commitizen@v3.29.0...v3.29.1)
- [github.com/astral-sh/ruff-pre-commit: v0.6.7 → v0.6.8](astral-sh/ruff-pre-commit@v0.6.7...v0.6.8)

* feat: added updated at field in task events table

* fix: handle exception if project not found in db

* feat(user-profile): pass watch on form props

* fix(user-profile)-#209: able to submit if the password and confirm password not matched

* fix(user-profile)-#208: validation issue

* feat: added updated_at field  when user request, lock, unlock task

* feat: added updated_at in task details endpoint

* fix: get superuser from user table instead of access token

* feat: update file and folder structure and rename `UserProfile` to `Complete UserProfile`

* refac: remove super user from AuthUser Schemas

* feat: add Breadcrumb component

* feat: replace user-profile layout component and and add new route called complete-profile

* feat: added two new enums such as IMAGE_UPLOADED & IMAGE_PROCESSED

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(task-description): Remove BLOB middleware for processing result downloads

* fix: issues reslove on updated date

* feat: added change password based on old and new password

* feat(individual-project): post date with other data on task lock/unlock

* feat(task-description): show task locked date

* feat(update-profile): add BasicDetails component

* feat(update-profile): add Header component

* feat(update-profile): add OrganizationDetail component

* feat(update-profile): add Password component

* feat(update-profile): add OtherDetails component

* feat: add common css class main-content that gives the full screen height after reducing the nav bar height

* feat(user-profile): add UpdateUserProfile component

* feat: remove the route `user-profile` add `complete-profile` from the list of routes without navbar

* feat(user-profile): update basic details

* refactor: remove user data fetching on projects page

* refactor(user-profile): revalidate user details data on basic details patch success

* feat: store user details on local storage on fetch success

* feat(user-profile): create user profile patch service

* feat(user-profile): call user details api on userProfile of nav section

* feat(user-profile): update organization details

* feat(user-profile): update other details

* feat(user-profile): update password

* fix: typo

* fix: minor style

* fix: typo

* fix(ser-profile): make patch request on profile data change

* feat(user-profile): show error message

* hot-fix(user-profile): check old & new password before verify the password

* fix: added message if user do not sent old and new password

* refac: exception raise on password check

* feat(user-profile): redirect to complete profile page if the user not completed the signup

* feat(user-profile): redirect to complete profile on google auth success

* fix(user-profile): minor UI

* fix(user-profile): navigate to complete profile only after the profile fetching is completed

* fix: typo

* used presigned url for map screenshot in projects endpoint

* feat: added search features in projects read endpoit

* fix(update-userProfile): update background color

* feat(dashboard): show user role

* feat: updated the task as completed after process from s3

* Feat: updated pagination on list projects (#264)

* feat: updated pagination on list projects

* refactor(project): make fetching query dyanamic so the querykey, params can be pass dynamically

* refactor(project): update project list fetching service params

* feat: add usePagination hook

* feat: add Pagination component

* refactor(dashboard-map-section): remove api call and get project list through props

* feat(project-dashboard): implement pagination on project list

* feat: update searchInput component

* feat(project-dashboard): implement project search

* feat(project-dashboard): make responsive header

* fix: added new pydentic model class for read the single project

---------

Co-authored-by: Sujit <[email protected]>

* feat: update task state to reflect the start of image processing

* fix: remove comment from the task update function

* fix: adjust the state based on processing...

* fix: refine the state of task processing

* Feat: Updated the task as completed after process from S3 (#270)

* feat: updated the task as completed after process from s3

* feat: update task state to reflect the start of image processing

* fix: remove comment from the task update function

* fix: adjust the state based on processing...

* fix: refine the state of task processing

* feat(projects): Show status on project card

* feat(dashboard): update UI and pass other project details on project card props

* feat: update the status of each projects on projects list endpoint

* feat(dashboard): show slug on project card

* feat: refine the status of tasks

* feat(project-details): add new status on legend

* feat(project-details): show skeleton on project data fetching

* feat(project-details): fill different color for completed task and image uploaded task

show go to task button

* feat(project-details): show loader on table

* feat(dashboard): make logs table responsive

* feat: add Status chip component

* feat(project-dashboard): show complete status on project card

* feat: fill circle color code from properties on VectorLayerWithCluster component

* feat(project-description): add different color code as per project status on properties of projects geojson

* hotfix: Update project/id to project_id in S3 image processing logic

* feat: reduce table height

* feat(project-details): image processing status text update

* fix(project-details): available tasks not showing on table

behave the task not having state as available tasks

* fix: added asyncio event loop to call async update_task_state in process_images_from_s3

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Feat: Show project status and task status on map and project cards (#272)

* fix(update-userProfile): update background color

* feat(dashboard): show user role

* feat(projects): Show status on project card

* feat(dashboard): update UI and pass other project details on project card props

* feat(dashboard): show slug on project card

* feat(project-details): add new status on legend

* feat(project-details): show skeleton on project data fetching

* feat(project-details): fill different color for completed task and image uploaded task

show go to task button

* feat(project-details): show loader on table

* feat(dashboard): make logs table responsive

* feat: add Status chip component

* feat(project-dashboard): show complete status on project card

* feat: fill circle color code from properties on VectorLayerWithCluster component

* feat(project-description): add different color code as per project status on properties of projects geojson

* feat: reduce table height

* feat(project-details): image processing status text update

* fix(project-details): available tasks not showing on table

behave the task not having state as available tasks

---------

Co-authored-by: Sujit <[email protected]>

* fix: resolve RuntimeError for missing event loop in AnyIO worker thread

* hot-fix: minor UI issue on chip

* feat: added asgiref package to convert the async to sync function

* feat(project-description): increase opacity of task completed tasks fill color

* fix: completed task status count

* fix: update ongoing_task_count to count tasks in specific states of projects

* fix: optimize project status calculation logic & update ongoing status count.

* fix(task-description): set height to update takeoff point button section

* feat: added new assets download endpoint

* fix: remove await from assets download endpoint

* fix(task-description): set height to update takeoff point button section (#281)

Co-authored-by: Sujit <[email protected]>

* feat: added users authentication

* feat(project-dashboard): udpdate row per page options

* feat(project-dashboard): update map and project card style

* feat(task-description): update assest information api endpoint

* feat(individual-project): get assets list

* feat(individual-project):fetch all assets and modify project details to insert each assets on respective task detail

* Style: update rows per page and set project card column to 3  (#283)

* fix(task-description): set height to update takeoff point button section

* feat(project-dashboard): udpdate row per page options

* feat(project-dashboard): update map and project card style

---------

Co-authored-by: Sujit <[email protected]>

* feat(individual-project):add loader

* Feat: Updated endpoints(download-assets) to fetch task assets status. (#282)

* feat: added new assets download endpoint

* fix: remove await from assets download endpoint

* feat: added users authentication

* chore: update verison drone_flightplan to v0.3.1

* fix: resolve deprecated async pool initialization in psycopg

* Feat: Update assets downloading endpoint on individual project (#284)

* fix(task-description): set height to update takeoff point button section

* feat(project-dashboard): udpdate row per page options

* feat(project-dashboard): update map and project card style

* feat(task-description): update assest information api endpoint

* feat(individual-project): get assets list

* feat(individual-project):fetch all assets and modify project details to insert each assets on respective task detail

---------

Co-authored-by: Sujit <[email protected]>

---------

Co-authored-by: Sujit <[email protected]>
Co-authored-by: Sujit <[email protected]>

* fix(project-details): add `/` on api endpoint

* feat(project-description): call assets api only on contirbution tab is on view

* fix: merge conflict

* fix(backend): reslove merge conflict in pyproject.toml

* fix(backend): returns values from calculations function

* fix(backend): reslove merge conflict in pyproject.toml

* fix: update the pdm lock file

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Niraj Adhikari <[email protected]>
Co-authored-by: Sujit <[email protected]>
Co-authored-by: Niraj Adhikari <[email protected]>
Co-authored-by: Sujit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code enhancement New feature or request frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants