Skip to content

Commit

Permalink
Staging update (#247)
Browse files Browse the repository at this point in the history
* fix dataset collaborator and issue delete authorization

* fix(map view): prevent client error when legend config is empty

* Feature/pending datasets (#198)

* Add pending_datasets table init and CRUD

* Add approval_status and draft to metadata

* Fix draft permissions

* [main.yml] Init. pendingdb tables

* Run WRI unit tests first

* Fix paths in unit tests script

* Run WRI unit tests first in src

* Fix OR in unit tests script

---------

Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>

* Rm test.yml (#202)

* [xl]: approval ui implementation

* add approval permission

* Normalize filenames instead of using a uuid (#205)

* approval workflow implementation

* add test

* fix test

* update permission

* add issue tab indexing

* update approval workflow

* update documentation

* display filled metadata fields

* Prefect datapusher (#208)

* Prefect datapusher

* Progress

* Datapusher

* Use default id

* Progress

* Datapusher ci/cd (#207)

* [main.yml] Add CI/CD for datapusher

* [values.yaml.dev.template] Add github sha for datapusher

* Progress

* Progress

* Progress

* Progress

* Fix build

* FInisihed

* Remove rm command

* Fix tests

* Fix tests

* Wait on prefect

* Fix typo

* Trigger CI

* Change viewport

* Update tests

* Update github action

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Check logs

* Fix tests

* Fix tests

* Datapusher token

* Fix tests

* Fix tests

* Fix tests

* Init exteions

* Fix tests

* Fix tests

* Change permissions of file

* Fix tests

* Fix test

* Trigger CI

* Remove api_token

* Fix tests

* Fix build

* Update datapusher

* Fix tests

* Fix unit tests

* Fix test.ini

---------

Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>

* Return RW Error message (#210)

* Return RW Error message

* Fix build

* Trigger CI

* Fix file upload

* Fix datapusher and resource upload (#211)

* Improvements table view (#212)

* Improvements table view

* Datepicker on tabular view

* Default values (#213)

* Default values

* Fix pagination

* Enable other data formats (#215)

* Fix datafiles editing (#216)

* Feat/chart view connector url (#219)

* feat: basic chart creation functionallity

* feat: chart view creation/visualization

* feat(chart view): fix self is not defined error, imrpove formats select, responsiveness fixes

* fix(chart view): dybamic import chart

* fix(chart view): dybamic import chart

* feat(chat view): public view options

* feat(chat view): implement pie charts

* feat(chat view): implement embedding

* fix(chart view): minor fixes to the editor

* fix(chart view): show all format options

* feat(chart view): refactor components structure

* feat(chart view): makes it possible to create chart views based on connector url

* fix(chart view): linting errors

* fix(chart view): chart creation button (#222)

* QA Fixes (#223)

* Show datapusher status (#225)

* Show datapusher status

* Status on tab for datapusher

* Add spinner to scheduled

* Fix/chart view ii (#226)

* feat(chart view): allow users to see dataset charts

* feat(chart view): dataset views are now embedable

* feat(chart view): update resource and view update button label

* feat(chart view): show a tooltip with a message when chart view cannot be saved due to pending preview update

* fix(chart view): enable tooltips by default

* feat(chart view): start implementing chart view icons

* fix(chart view): fix page braking when maps are present

* fix build

* trigger build

* temporarily remove test

* Fix xlsx datapusher (#227)

* Fix datastore query (#228)

* Fix/chart view ii (#229)

* feat(chart view): allow users to see dataset charts

* feat(chart view): dataset views are now embedable

* feat(chart view): update resource and view update button label

* feat(chart view): show a tooltip with a message when chart view cannot be saved due to pending preview update

* fix(chart view): enable tooltips by default

* feat(chart view): start implementing chart view icons

* fix(chart view): fix page braking when maps are present

* fix build

* trigger build

* temporarily remove test

* build: add map test again

* build: remove temporary test

* feat(chart view): maintain flag on dataset that indicates whether it has chart views or not

* fix(chart view): do not allow category, measure and dimension to be the same

* fix(map view): fix tests

* build: add map test again

* fix(map view): fix tests

* fix(tests): remove unnecessary file

* fix build

* feat(chart view): add tests

* feat(chart view): add docs

* fix: remove unnecessary header from rw api

* fix(chart view): proxy requests to rw api (#230)

* Tabular preview fixes (#231)

* Tabular preview fixes

* Add back ()

* Trigger CI

* Fix/chart view iii (#234)

* fix(chart view): add loading indicator for view create and update + fix success notification theme

* fix(chart view): fix plot height issue when plot is refreshed

* fix(chart view): tweak sorting behavior

* Docs datapusher tabular preview (#232)

* Boot up staging env (#21)

* Add staging files
* Enable s3filestore and disable init cont.
* Initial frontend (#23)

---------

Co-authored-by: Luccas Mateus <luccasmmg@gmail.com>

* [hotfix] Fix cert manager name for ingress

* [main.yml] Fix frontend build secrets

* [cost-splitting] Change the links according to the branch

* [cost-splitting] Update branch name

* Avoid overwriting cost splitting files of staging

* Fix url for cypress tests

* Sync dev to staging and enable frontend deployment (#47)

* Updating the storage report

* Cost splitting will now run on different buckets (#24)

Depending on branch

* Updating the storage report

* Switch to cost splitting branch for s3filestore

* Updating the storage report

* Updating the storage report

* [Dockerfile] Enable s3filestore

* [values.yaml.dev.template] Enable s3filestore

* Normalize date string

* Updating the storage report

* Add all files

* Updating the storage report

* Fix typo

* Updating the storage report

* Get org title

* Updating the storage report

* Fix typo

* Updating the storage report

* Debug

* Updating the storage report

* Clear stuff

* Updating the storage report

* Updating the storage report

* Initial frontend (#25)

Co-authored-by: Luccas Mateus <luccasmmg@gmail.com>

* Rename the base directory as it includes frontend too now

* Use datapusher from the ecr

* Enable frontend and use images from ECR

* Enable frontend build and push

* [values.yaml.dev.temp] Add frontend ingress

* [main.yml] Fix CKAN_IMAGE for building

* [main.yml] Fix Trivy repo variable

* Add Site Title for frontend env

* Enable auth and fix frontend svc

* Run builds on dev and PRs to dev only

* Changing text color

* Fix cost splitting CI

* [images][l]: add images

* [package][s]: add headlessui

* [taildwind.config][m]: add custom themes

* [components][l]: implement shared and locallize components

* [footer][m]: implement footer component

* [Header][s]: implement header component

* [_documents][s]: add font url to document level

* [Search][m]: implement search page

* [search-page][s]: remove div and use fragment

* [fix][l]: update styling

* [package][s]: add swiper

* [Carousel][m]: add swiper carousel

* [carouselnavbutton][m]: add carousel nav button

* [Carousel][l]: wrap higlight and recetly sections inide carousel

* [Footer][s]: fix footer alignment issue

* [Header][s]: remove comment

* [Carousel][s]: remove state

* fix spacing to correct vieport

* Shell for search page

* Advanced search

* Fix build

* feat(odp-136): implement explore topics page UI

* fix(odp-136): eslint errors

* Little fixes

* Text-xs on small mobile

* Individual page for topic

* Copy button

* Acumin Pro used

* Add WRI extension and update CKAN package schema (#20)

* Sync dev with master (#19)

* Fix/broken build (#13)

* [cost-splitting-report.yml] Add permissions

* [values.yaml.dev.template] Add quotes to the bool env variables

---------

Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>

* Update cost-splitting-report.yml

---------

Co-authored-by: Luccas Mateus <Luccasmmg@gmail.com>

* Add wri extension and update package schema

* Add gitkeep for src directory

* Update gitignore

* Use symlink for ckanext-wri

* Fix tests

* [GitHub Actions] try ckan-dev instead of localhost

* [GitHub Actions] Add wait-on to docker step

* [GitHub Actions] Revert wait-on

* [GitHub Actions] Fix repo path

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension - fix path

* [GitHub Actions] Install wri extension - fix path and add APP_DIR

* [GitHub Actions] Install wri extension - try symlink in cwd

* [GitHub Actions] Install wri extension - remove symlink and update path

* [GitHub Actions] Install wri extension - add debug log

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension

* [GitHub Actions] Install wri extension - mv extension during action

* [GitHub Actions] Install wri extension - mv extension during action

* [GitHub Actions] Install wri extension - mv extension during action

* [GitHub Actions] Fix tests

* [GitHub Actions] Generate JWT tokens

* [GitHub Actions] Install openssl

* [GitHub Actions] Install openssl as root

* [GitHub Actions] Fix key generation

* [GitHub Actions] Fix key generation - remove pre-generated keys

* [GitHub Actions] Test adding plugins directly in test

* [GitHub Actions] Update scheming env variables

* Fix schema validators

* Fix schema validators

* Remove debugging output

* Dummy commit to run CI/CD

* Update docs

---------

Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>
Co-authored-by: Luccas Mateus <Luccasmmg@gmail.com>

* fix: minor typo on classname

* [Odp 147]:Team metadata page implementation [mockup implementation] (#35)

* [tailwindconfig][s]" add maxwidth

* add icon and image

* Team page implementation

* [TeamHeader][l]: update styling

* group component

* add activity icons

* [ActivityStream][l]: add activity stream components

* [DatasetList][l]: component to list all dataset

* [Teams][xl]: add teams page

* update teams page- move to a subpage

* update vertical space

* Little fixes

---------

Co-authored-by: Luccas Mateus <luccasmmg@gmail.com>

* build: trigger reubild

* feat(odp-137): implement UI for explore teams page

* Enable scheming extension on test site

* build: dummy commit to trigger build

* Dummy commit to rerun CI/CD

* Another dummy commit to rerun CI/CD

* Another dummy commit to rerun CI/CD

* Trigger CI

* build: dummy commit to trigger build

* Temporarily remove unit tests

* Fix schema tests

* Fixes odp-134 - Misc (#39)

* fixe alignment issues

* [Recent][s]:add shadows to bottom

* update styling

* Fix responsiveness

* Fix icons

* [TeamSearchResults][[s]: add pagination

* fix: active link effect and login button spacing on mobile (#41)

* fix: active link effect and login button spacing on mobile

* Change route name to match url

---------

Co-authored-by: Luccas Mateus <luccasmmg@gmail.com>

* Fix share topic button (#43)

* [values.yaml.dev.template] Increase frontend resources (#44)

* fix styling and spacing (#45)

* [main.yml] Fix frontend build secrets

* [cost-splitting] Change the links according to the branch

* [cost-splitting] Update branch name

* Avoid overwriting cost splitting files of staging

* Fix url for cypress tests

---------

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Luccas Mateus <Luccasmmg@gmail.com>
Co-authored-by: Michael Polidori <contact@michaelpolidori.com>
Co-authored-by: steveoni <steohenoni2@gmail.com>
Co-authored-by: João Demenech <joao.demenech@datopian.com>
Co-authored-by: Demenech <joaommdemenech@gmail.com>

* [main.yml] Use same url for int tests as dev

* [codeql] Use staging branch

* Sync staging to dev (#105)

* Fix Staging Title

* Fix download link (#136) (#137)

* Fix download link

* Change update to patch

* [Bypassed][Dockerfile] Disable public signup

* Remove test.yml as not currently needed

* Merge Dev to Staging (#201)

* fix(map view): prevent client error when legend config is empty

* Feature/pending datasets (#198)

* Add pending_datasets table init and CRUD

* Add approval_status and draft to metadata

* Fix draft permissions

* [main.yml] Init. pendingdb tables

* Run WRI unit tests first

* Fix paths in unit tests script

* Run WRI unit tests first in src

* Fix OR in unit tests script

---------

Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>

* Rm test.yml (#202)

---------

Co-authored-by: Demenech <joaommdemenech@gmail.com>
Co-authored-by: João Demenech <joao.demenech@datopian.com>
Co-authored-by: Michael Polidori <contact@michaelpolidori.com>
Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>

* Datapusher docs

* Update docs

* Fix typo

* Add retry

* Fix test

* Fix tests

* Fix datapusher

* Fix types

* Revert "Merge branch 'staging' of https://github.com/wri/wri-odp into docs-datapusher-tabular-preview"

This reverts commit 2d72215, reversing
changes made to b5b90fa.

---------

Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>
Co-authored-by: MuhammadIsmailShahzad <ismailshahzadmirza@gmail.com>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Michael Polidori <contact@michaelpolidori.com>
Co-authored-by: steveoni <steohenoni2@gmail.com>
Co-authored-by: João Demenech <joao.demenech@datopian.com>
Co-authored-by: Demenech <joaommdemenech@gmail.com>

* update activity stream to fetch filter data via server request (#241)

* Make datapusher not conflict with multiple environmetns (#243)

* Make datapusher not conflict with multiple environmetns

* fix typo

* Trigger CI (#244)

* Trigger CI

* Trigger CI

* Add retries

* Fix: Create resource view for non-public datasets not working (#245)

* fix(chart view): auth header not beingproperly passed

* trigger build

* fix: fix conflict markers

---------

Co-authored-by: steveoni <steohenoni2@gmail.com>
Co-authored-by: Michael Polidori <contact@michaelpolidori.com>
Co-authored-by: Muhammad Ismail Shahzad <57398621+MuhammadIsmailShahzad@users.noreply.github.com>
Co-authored-by: Luccas Mateus <Luccasmmg@gmail.com>
Co-authored-by: MuhammadIsmailShahzad <ismailshahzadmirza@gmail.com>
Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
7 people authored Jan 31, 2024
1 parent 2904926 commit b3f43f5
Show file tree
Hide file tree
Showing 17 changed files with 220 additions and 114 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ jobs:
--build-arg NEXT_PUBLIC_CKAN_URL=${{ secrets.STAGING_FRONTEND_CKAN_URL }} \
deployment/frontend
docker push $REGISTRY/$FRONTEND_REPO:$IMAGE_TAG
- name: Build and push Datapusher image to ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
DATAPUSHER_REPO: ${{ secrets.ECR_DATAPUSHER_REPO}}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$DATAPUSHER_REPO:$IMAGE_TAG \
datapusher
docker push $REGISTRY/$DATAPUSHER_REPO:$IMAGE_TAG
- name: Set up Docker Containers
env:
CKAN_IMAGE: '${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_CKAN_REPO }}:${{ github.sha }}'
Expand Down
1 change: 1 addition & 0 deletions ckan-backend-dev/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ CKANEXT__AUTH__AZURE_CLIENT_ID=ffffffff-ffff-ffff-ffff-ffffffffffff
# custom auth
CKANEXT__WRI__ODP_URL=http://frontend:3000
CKANEXT__WRI__PREFECT_URL=http://prefect:4200
CKANEXT__WRI__DATAPUSHER_DEPLOYMENT_NAME=datapusher-dev

# DataAPI
#CKANEXT__DATA_API__HASURA_URL=http://hasura-svc:80
Expand Down
1 change: 1 addition & 0 deletions ckan-backend-dev/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ services:
restart: always
environment:
- PREFECT_API_URL=http://prefect:4200/api
- DEPLOYMENT_NAME=datapusher-dev
- CKAN_DATASTORE_READ_URL=postgresql://ckandbuser:ckandbpassword@db/datastore
- CKAN_DATASTORE_WRITE_URL=postgresql://ckandbuser:ckandbpassword@db/datastore
depends_on:
Expand Down
1 change: 1 addition & 0 deletions ckan-backend-dev/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ services:
restart: always
environment:
- PREFECT_API_URL=http://prefect:4200/api
- DEPLOYMENT_NAME=datapusher-dev
- CKAN_DATASTORE_READ_URL=postgresql://ckandbuser:ckandbpassword@db/datastore
- CKAN_DATASTORE_WRITE_URL=postgresql://ckandbuser:ckandbpassword@db/datastore
depends_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def datapusher_submit(context: Context, data_dict: dict[str, Any]):
return False

prefect_url: str = config.get("ckanext.wri.prefect_url")
deployment_name: str = config.get("ckanext.wri.datapusher_deployment_name")

callback_url_base = config.get("ckan.datapusher.callback_url_base") or config.get(
"ckan.site_url"
Expand Down Expand Up @@ -159,7 +160,7 @@ def datapusher_submit(context: Context, data_dict: dict[str, Any]):
api_token = p.toolkit.get_action('api_token_create')(None, {"user": "ckan_admin", "name": "datapusher"}).get('token') if force else api_token
try:
deployment = requests.get(
urljoin(prefect_url, "api/deployments/name/push-to-datastore/datapusher")
urljoin(prefect_url, f"api/deployments/name/push-to-datastore/{deployment_name}")
)
deployment = deployment.json()
deployment_id = deployment["id"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def pending_dataset_delete(context: Context, data_dict: DataDict):
raise tk.ValidationError(_(f"Pending Dataset not found: {package_id}"))
# was returining pending_dataset db object
# change to return package_id or can none either way
return package_id
return package_id
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ def pending_diff_show(context: Context, data_dict: DataDict):

try:
pending_dataset = PendingDatasets.get(package_id=package_id)
log.error("===============pending dataset=================")
log.error(pending_dataset)
if pending_dataset is not None:
pending_dataset = pending_dataset.get("package_data")
existing_dataset = get_action("package_show")(context, {"id": package_id})
Expand Down
1 change: 1 addition & 0 deletions ckan-backend-dev/src/ckanext-wri/ckanext/wri/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def configure(self, config):
missing_config = "{0} is not configured. Please amend your .ini file."
config_options = (
'ckanext.wri.prefect_url',
'ckanext.wri.datapusher_deployment_name',
)
for option in config_options:
if not config.get(option, None):
Expand Down
1 change: 1 addition & 0 deletions ckan-backend-dev/src/ckanext-wri/test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ api_token.jwt.algorithm = RS256
api_token.jwt.encode.secret = file:/srv/app/jwtRS256.key
api_token.jwt.decode.secret = file:/srv/app/jwtRS256.key.pub
ckanext.wri.prefect_url = http://prefect:4200
ckanext.wri.datapusher_deployment_name = datapusher

# Logging configuration
[loggers]
Expand Down
2 changes: 2 additions & 0 deletions datapusher/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

_DATABASE_URI = os.environ['CKAN_DATASTORE_WRITE_URL']
_WRITE_ENGINE_URL = os.environ['CKAN_DATASTORE_WRITE_URL']
_DEPLOYMENT_NAME = os.environ['DEPLOYMENT_NAME']
_QSVDP_BIN = '/root/.cargo/bin/qsvdp' if os.environ.get('QSVPDP_BIN') is None else os.environ['QSVPDP_BIN']
_CKAN_URL = 'http://ckan-dev:5000' if os.environ.get('CKAN_URL') is None else os.environ['CKAN_URL']
_TYPES = "String", "Float", "Integer", "DateTime", "Date", "NULL"
Expand All @@ -35,6 +36,7 @@ def _parse_bool(val: Union[str, bool]) -> bool: # pylint: disable=E1136
# DataPusherPlusConfig class with required fields, default values, type checking, and typecasting for int and bool values
class DataPusherPlusConfig(MutableMapping):
# ckan_service_provider settings
DEPLOYMENT_NAME: str = _DEPLOYMENT_NAME
CKAN_URL: str = _CKAN_URL
SQLALCHEMY_DATABASE_URI: str = _DATABASE_URI
WRITE_ENGINE_URL: str = _WRITE_ENGINE_URL
Expand Down
2 changes: 1 addition & 1 deletion datapusher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def push_to_datastore(resource_id, api_key):

if __name__ == "__main__":
datastore_deployment = push_to_datastore.to_deployment(
name="datapusher",
name=config.get('DEPLOYMENT_NAME'),
parameters={"resource_id": "test_id", "api_key": "api_key"},
enforce_parameter_schema=False,
is_schedule_active=False,
Expand Down
2 changes: 0 additions & 2 deletions deployment/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ You can check out the [create-t3-app GitHub repository](https://github.com/t3-os

Follow our deployment guides for [Vercel](https://create.t3.gg/en/deployment/vercel), [Netlify](https://create.t3.gg/en/deployment/netlify) and [Docker](https://create.t3.gg/en/deployment/docker) for more information.



Original file line number Diff line number Diff line change
@@ -1,58 +1,92 @@
import React, { useState } from 'react'
import ActivitystreamHeader from './ActivitystreamHeader'
import ActivityStreamCard from '../../_shared/ActivityStreamCard'
import { api } from '@/utils/api';
import Spinner from '@/components/_shared/Spinner';
import type { SearchInput } from '@/schema/search.schema';
import Pagination from '../_shared/Pagination';
import { useQuery } from 'react-query';
import { filterObjects, searchArrayForKeyword } from "@/utils/general";
import { api } from '@/utils/api'
import Spinner from '@/components/_shared/Spinner'
import type { SearchInput } from '@/schema/search.schema'
import Pagination from '../_shared/Pagination'
import { useQuery } from 'react-query'
import { filterObjects, searchArrayForKeyword } from '@/utils/general'

export default function ActivityList() {
const [query, setQuery] = useState<SearchInput>({ search: '', fq: {}, page: { start: 0, rows: 10 } })
const { data, isLoading } = api.dashboardActivity.listActivityStreamDashboard.useQuery({ search: '', page: { start: 0, rows: 10000 } });
const [query, setQuery] = useState<SearchInput>({
search: '',
fq: {},
page: { start: 0, rows: 10 },
})
const [serverQuery, setServerQuery] = useState<SearchInput>({
search: '',
fq: {},
page: { start: 0, rows: 1000 },
})
const { data, isLoading } =
api.dashboardActivity.listActivityStreamDashboard.useQuery(serverQuery)

const processedActivity = useQuery(['processedActivitystream', data, query], () => {
if (!data) return { activity: [], count: 0 };
const searchTerm = query.search.toLowerCase();
const activity = data.activity;
let filteredActivity = activity;
if (searchTerm) {
filteredActivity = searchArrayForKeyword(activity, searchTerm);
}
const processedActivity = useQuery(
['processedActivitystream', data, query],
() => {
if (!data) return { activity: [], count: 0 }
const searchTerm = query.search.toLowerCase()
const activity = data.activity
let filteredActivity = activity
if (searchTerm) {
filteredActivity = searchArrayForKeyword(activity, searchTerm)
}

const fq = query.fq!;
if (fq && Object.keys(fq).length > 0) {
console.log("in here")
filteredActivity = filterObjects(filteredActivity, fq);
}
const fq = query.fq!
if (fq && Object.keys(fq).length > 0) {
console.log('in here fg: ', fq)
filteredActivity = filterObjects(filteredActivity, fq)
}

const start = query.page.start;
const rows = query.page.rows;
const slicedData = filteredActivity.slice(start, start + rows);
return { activity: slicedData, count: filteredActivity.length };
}, {
enabled: !!data, // Only run the query when data is available
});
const start = query.page.start
const rows = query.page.rows
const slicedData = filteredActivity.slice(start, start + rows)
return { activity: slicedData, count: filteredActivity.length }
},
{
enabled: !!data, // Only run the query when data is available
}
)

return (
<section className="max-w-8xl w-full flex flex-col gap-y-5 sm:gap-y-0">
<ActivitystreamHeader
setQuery={setQuery}
query={query}
setServerQuery={setServerQuery}
serverQuery={serverQuery}
Pagination={
<Pagination
setQuery={setQuery}
query={query}
isLoading={processedActivity.isLoading}
count={processedActivity.data?.count}
/>
}
/>


return (
<section className='max-w-8xl w-full flex flex-col gap-y-5 sm:gap-y-0'>
<ActivitystreamHeader setQuery={setQuery} query={query} Pagination={<Pagination setQuery={setQuery} query={query} isLoading={processedActivity.isLoading} count={processedActivity.data?.count} />} />

{
isLoading || processedActivity.isLoading ? <div className='flex justify-center items-center h-screen'><Spinner className="mx-auto my-2" /></div> : (
processedActivity.data?.activity === undefined || processedActivity.data?.activity.length === 0 ? <div className='flex justify-center items-center h-screen'>No data</div> :
processedActivity.data?.activity.map((items, index) => {
return (
<div className=' hover:bg-slate-100 pl-6 p-1 mb-2 pb-2 rounded-md' key={index}>
<ActivityStreamCard activity={items} />
{isLoading || processedActivity.isLoading ? (
<div className="flex justify-center items-center h-screen">
<Spinner className="mx-auto my-2" />
</div>
) : processedActivity.data?.activity === undefined ||
processedActivity.data?.activity.length === 0 ? (
<div className="flex justify-center items-center h-screen">
No data
</div>
)
})
)
}
</section>
)
) : (
processedActivity.data?.activity.map((items, index) => {
return (
<div
className=" hover:bg-slate-100 pl-6 p-1 mb-2 pb-2 rounded-md"
key={index}
>
<ActivityStreamCard activity={items} />
</div>
)
})
)}
</section>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import { Group } from '@portaljs/ckan'
function LeftNode({
setQuery,
query,
setServerQuery,
serverQuery,
}: {
setServerQuery: React.Dispatch<React.SetStateAction<SearchInput>>
serverQuery: SearchInput
setQuery: React.Dispatch<React.SetStateAction<SearchInput>>
query: SearchInput
}) {
Expand Down Expand Up @@ -110,8 +114,8 @@ function LeftNode({
)
)}
filtername="packageId"
setQuery={setQuery}
query={query}
setQuery={setServerQuery}
query={serverQuery}
/>
) : (
''
Expand All @@ -126,8 +130,8 @@ function LeftNode({
)
)}
filtername="orgId"
setQuery={setQuery}
query={query}
setQuery={setServerQuery}
query={serverQuery}
/>
) : (
''
Expand All @@ -152,15 +156,26 @@ function LeftNode({
export default function ActivitystreamHeader({
setQuery,
query,
setServerQuery,
serverQuery,
Pagination,
}: {
setQuery: React.Dispatch<React.SetStateAction<SearchInput>>
query: SearchInput
setServerQuery: React.Dispatch<React.SetStateAction<SearchInput>>
serverQuery: SearchInput
Pagination?: React.ReactNode
}) {
return (
<TableHeader
leftNode={<LeftNode setQuery={setQuery} query={query} />}
leftNode={
<LeftNode
setServerQuery={setServerQuery}
serverQuery={serverQuery}
setQuery={setQuery}
query={query}
/>
}
rightStyle="sm:mt-4"
Pagination={Pagination}
/>
Expand Down
2 changes: 1 addition & 1 deletion deployment/frontend/src/pages/api/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function handler(

const { url, headers } = body

const response = await fetch(url, headers)
const response = await fetch(url, { headers })

return res.json(await response.json())
}
Loading

0 comments on commit b3f43f5

Please sign in to comment.