From 70874888edc1b9956ac0ddcc54a0f6e8c50e4289 Mon Sep 17 00:00:00 2001 From: auslin-aot <99173163+auslin-aot@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:23:05 +0530 Subject: [PATCH 1/4] Update requirements to point to the release branch & Fix workflow listing in create filter in multitenancy (#2015) * Update requirements to point to release branch * Workflow dropdown in Create new filter. --------- Co-authored-by: josephalexantony-aot --- forms-flow-api/requirements.txt | 2 +- forms-flow-api/requirements/prod.txt | 2 +- forms-flow-documents/requirements.txt | 2 +- forms-flow-documents/requirements/prod.txt | 2 +- .../src/components/ServiceFlow/list/sort/CreateNewFilter.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/forms-flow-api/requirements.txt b/forms-flow-api/requirements.txt index f6c800f9e8..f19659bc7a 100644 --- a/forms-flow-api/requirements.txt +++ b/forms-flow-api/requirements.txt @@ -27,7 +27,7 @@ ecdsa==0.18.0 flask-jwt-oidc==0.3.0 flask-marshmallow==1.2.1 flask-restx==1.3.0 -formsflow_api_utils @ git+https://github.com/AOT-Technologies/forms-flow-ai.git@master#subdirectory=forms-flow-api-utils +formsflow_api_utils @ git+https://github.com/AOT-Technologies/forms-flow-ai.git@release/6.0.0#subdirectory=forms-flow-api-utils gunicorn==21.2.0 h11==0.14.0 h2==4.1.0 diff --git a/forms-flow-api/requirements/prod.txt b/forms-flow-api/requirements/prod.txt index a6f27b1533..d7d4c2196c 100644 --- a/forms-flow-api/requirements/prod.txt +++ b/forms-flow-api/requirements/prod.txt @@ -16,4 +16,4 @@ sqlalchemy_utils markupsafe PyJWT redis -git+https://github.com/AOT-Technologies/forms-flow-ai.git@master#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils \ No newline at end of file +git+https://github.com/AOT-Technologies/forms-flow-ai.git@release/6.0.0#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils \ No newline at end of file diff --git a/forms-flow-documents/requirements.txt b/forms-flow-documents/requirements.txt index 47256d17ba..a295a7206c 100644 --- a/forms-flow-documents/requirements.txt +++ b/forms-flow-documents/requirements.txt @@ -27,7 +27,7 @@ ecdsa==0.18.0 flask-jwt-oidc==0.3.0 flask-marshmallow==1.2.1 flask-restx==1.3.0 -formsflow_api_utils @ git+https://github.com/AOT-Technologies/forms-flow-ai.git@master#subdirectory=forms-flow-api-utils +formsflow_api_utils @ git+https://github.com/AOT-Technologies/forms-flow-ai.git@release/6.0.0#subdirectory=forms-flow-api-utils gunicorn==21.2.0 h11==0.14.0 h2==4.1.0 diff --git a/forms-flow-documents/requirements/prod.txt b/forms-flow-documents/requirements/prod.txt index d8a0272cd0..e30e85bba9 100644 --- a/forms-flow-documents/requirements/prod.txt +++ b/forms-flow-documents/requirements/prod.txt @@ -17,4 +17,4 @@ PyJWT selenium selenium-wire nested-lookup -git+https://github.com/AOT-Technologies/forms-flow-ai.git@master#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils \ No newline at end of file +git+https://github.com/AOT-Technologies/forms-flow-ai.git@release/6.0.0#egg=formsflow_api_utils&subdirectory=forms-flow-api-utils \ No newline at end of file diff --git a/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js b/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js index 054364bec9..f3005b6433 100644 --- a/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js +++ b/forms-flow-web/src/components/ServiceFlow/list/sort/CreateNewFilter.js @@ -259,7 +259,7 @@ export default function CreateNewFilterDrawer({ useEffect(() => { if (openFilterDrawer) { dispatch(fetchUserList()); // if the create new filter open then need to fetch list of users - dispatch(fetchAllBpmProcesses()); // if the create new filter open then need to fetch all bpm process + dispatch(fetchAllBpmProcesses({ tenant_key: tenantKey })); // if the create new filter open then need to fetch all bpm process } // if the create new filter open then need to fetch all forms if (openFilterDrawer && !forms?.data?.length) { From d872c51680f15ae199e910df2ad92039f6f71413 Mon Sep 17 00:00:00 2001 From: auslin-aot Date: Mon, 22 Apr 2024 13:19:03 +0530 Subject: [PATCH 2/4] configure_logs to toggle file log rotation. --- deployment/docker/docker-compose.yml | 2 ++ deployment/docker/sample.env | 2 ++ forms-flow-api/docker-compose.yml | 1 + forms-flow-api/sample.env | 1 + forms-flow-data-analysis-api/docker-compose.yml | 2 +- forms-flow-data-analysis-api/sample.env | 1 + forms-flow-documents/docker-compose.yml | 1 + forms-flow-documents/sample.env | 1 + 8 files changed, 10 insertions(+), 1 deletion(-) diff --git a/deployment/docker/docker-compose.yml b/deployment/docker/docker-compose.yml index 7a89428777..74f90a078d 100644 --- a/deployment/docker/docker-compose.yml +++ b/deployment/docker/docker-compose.yml @@ -246,6 +246,7 @@ services: API_LOG_ROTATION_WHEN: ${API_LOG_ROTATION_WHEN:-d} API_LOG_ROTATION_INTERVAL: ${API_LOG_ROTATION_INTERVAL:-1} API_LOG_BACKUP_COUNT: ${API_LOG_BACKUP_COUNT:-7} + CONFIGURE_LOGS: ${CONFIGURE_LOGS:-true} REDIS_URL: ${REDIS_URL:-redis://redis:6379/0} stdin_open: true # -i @@ -287,6 +288,7 @@ services: API_LOG_ROTATION_WHEN: ${API_LOG_ROTATION_WHEN:-d} API_LOG_ROTATION_INTERVAL: ${API_LOG_ROTATION_INTERVAL:-1} API_LOG_BACKUP_COUNT: ${API_LOG_BACKUP_COUNT:-7} + CONFIGURE_LOGS: ${CONFIGURE_LOGS:-true} REDIS_URL: ${REDIS_URL:-redis://redis:6379/0} stdin_open: true # -i diff --git a/deployment/docker/sample.env b/deployment/docker/sample.env index 203861a6e1..c189640b6e 100644 --- a/deployment/docker/sample.env +++ b/deployment/docker/sample.env @@ -240,6 +240,7 @@ CUSTOM_SUBMISSION_URL=http://{your-ip-address}:{port} #++++++++++++++++--- formsflow.ai Modules and themeing ENV Variables - STOP ---+++++++++++++++++++++++++# ##Log File Rotation Configuration for API Logs +##CONFIGURE_LOGS: Set to 'false' to disable log file rotation. Default value is true ##API_LOG_ROTATION_WHEN: Specifies the frequency of log file rotation - 'd' for days, 'h' for hours, 'm' for minutes. ##API_LOG_ROTATION_INTERVAL: Sets the time interval for log file rotation - '1' for every day. ##API_LOG_BACKUP_COUNT: Determines the number of backup log files to keep - '7' for logs from the past 7 day. @@ -247,3 +248,4 @@ CUSTOM_SUBMISSION_URL=http://{your-ip-address}:{port} #API_LOG_ROTATION_WHEN=d #API_LOG_ROTATION_INTERVAL=1 #API_LOG_BACKUP_COUNT=7 +#CONFIGURE_LOGS=true diff --git a/forms-flow-api/docker-compose.yml b/forms-flow-api/docker-compose.yml index 8cf213398d..8422b394de 100644 --- a/forms-flow-api/docker-compose.yml +++ b/forms-flow-api/docker-compose.yml @@ -56,6 +56,7 @@ services: API_LOG_ROTATION_WHEN: ${API_LOG_ROTATION_WHEN:-d} API_LOG_ROTATION_INTERVAL: ${API_LOG_ROTATION_INTERVAL:-1} API_LOG_BACKUP_COUNT: ${API_LOG_BACKUP_COUNT:-7} + CONFIGURE_LOGS: ${CONFIGURE_LOGS:-true} REDIS_URL: ${REDIS_URL:-redis://redis:6379/0} stdin_open: true # -i diff --git a/forms-flow-api/sample.env b/forms-flow-api/sample.env index 16ba0656d2..2b24a5a510 100644 --- a/forms-flow-api/sample.env +++ b/forms-flow-api/sample.env @@ -66,6 +66,7 @@ FORMIO_ROOT_PASSWORD=changeme #API_LOG_ROTATION_WHEN=d #API_LOG_ROTATION_INTERVAL=1 #API_LOG_BACKUP_COUNT=7 +#CONFIGURE_LOGS=true #Redis configuration REDIS_URL=redis://{your-ip-address}:6379/0 \ No newline at end of file diff --git a/forms-flow-data-analysis-api/docker-compose.yml b/forms-flow-data-analysis-api/docker-compose.yml index 887972db68..7507651e4c 100644 --- a/forms-flow-data-analysis-api/docker-compose.yml +++ b/forms-flow-data-analysis-api/docker-compose.yml @@ -43,7 +43,7 @@ services: API_LOG_ROTATION_WHEN: ${API_LOG_ROTATION_WHEN:-d} API_LOG_ROTATION_INTERVAL: ${API_LOG_ROTATION_INTERVAL:-1} API_LOG_BACKUP_COUNT: ${API_LOG_BACKUP_COUNT:-7} - CONFIGURE_LOGS: ${CONFIGURE_LOGS:-True} + CONFIGURE_LOGS: ${CONFIGURE_LOGS:-true} stdin_open: true # -i tty: true # -t networks: diff --git a/forms-flow-data-analysis-api/sample.env b/forms-flow-data-analysis-api/sample.env index d66000f774..7c2dd65846 100644 --- a/forms-flow-data-analysis-api/sample.env +++ b/forms-flow-data-analysis-api/sample.env @@ -24,3 +24,4 @@ DATABASE_SUPPORT=DISABLED #API_LOG_BACKUP_COUNT=7 ##CONFIGURE_LOGS: Set to 'false' to disable log file rotation. Default value is true +#CONFIGURE_LOGS=true diff --git a/forms-flow-documents/docker-compose.yml b/forms-flow-documents/docker-compose.yml index 00afc3bbd6..5a0739f3b1 100644 --- a/forms-flow-documents/docker-compose.yml +++ b/forms-flow-documents/docker-compose.yml @@ -34,6 +34,7 @@ services: API_LOG_ROTATION_WHEN: ${API_LOG_ROTATION_WHEN:-d} API_LOG_ROTATION_INTERVAL: ${API_LOG_ROTATION_INTERVAL:-1} API_LOG_BACKUP_COUNT: ${API_LOG_BACKUP_COUNT:-7} + CONFIGURE_LOGS: ${CONFIGURE_LOGS:-true} REDIS_URL: ${REDIS_URL:-redis://redis:6379/0} stdin_open: true # -i tty: true # -t diff --git a/forms-flow-documents/sample.env b/forms-flow-documents/sample.env index 15965cb8aa..0454fd3982 100644 --- a/forms-flow-documents/sample.env +++ b/forms-flow-documents/sample.env @@ -56,3 +56,4 @@ CUSTOM_SUBMISSION_URL=http://{your-ip-address}:6212 #API_LOG_ROTATION_WHEN=d #API_LOG_ROTATION_INTERVAL=1 #API_LOG_BACKUP_COUNT=7 +#CONFIGURE_LOGS=true \ No newline at end of file From 01c6af3e54e0ae367625caddebf81a3af1d371c7 Mon Sep 17 00:00:00 2001 From: auslin-aot Date: Mon, 22 Apr 2024 15:37:27 +0530 Subject: [PATCH 3/4] API CI fix --- .github/workflows/forms-flow-api-ci.yml | 2 +- .github/workflows/forms-flow-data-analysis-api-ci.yml | 2 +- .github/workflows/forms-flow-documents-ci.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/forms-flow-api-ci.yml b/.github/workflows/forms-flow-api-ci.yml index 5a8d271fa4..6c1fdc4298 100644 --- a/.github/workflows/forms-flow-api-ci.yml +++ b/.github/workflows/forms-flow-api-ci.yml @@ -35,7 +35,7 @@ jobs: strategy: matrix: - python-version: [3.12.2] + python-version: [3.12.3] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/forms-flow-data-analysis-api-ci.yml b/.github/workflows/forms-flow-data-analysis-api-ci.yml index 49c8e8c3fb..a96ad5cfa8 100644 --- a/.github/workflows/forms-flow-data-analysis-api-ci.yml +++ b/.github/workflows/forms-flow-data-analysis-api-ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - python-version: [3.11.8] + python-version: [3.11.9] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/forms-flow-documents-ci.yml b/.github/workflows/forms-flow-documents-ci.yml index b35ae77ed1..945095e64d 100644 --- a/.github/workflows/forms-flow-documents-ci.yml +++ b/.github/workflows/forms-flow-documents-ci.yml @@ -34,7 +34,7 @@ jobs: strategy: matrix: - python-version: [3.12.2] + python-version: [3.12.3] steps: - uses: actions/checkout@v2 From 7064e1e7a57a8c15e16857ed66f8ec7b6d524cd6 Mon Sep 17 00:00:00 2001 From: auslin-aot Date: Tue, 23 Apr 2024 12:07:23 +0530 Subject: [PATCH 4/4] Change formlist API to display all active forms --- .../models/form_process_mapper.py | 17 ++++++ .../resources/form_process_mapper.py | 2 + .../schemas/form_process_mapper.py | 1 + .../services/form_process_mapper.py | 61 +++++++++++-------- .../apiManager/services/bpmFormServices.js | 4 +- 5 files changed, 56 insertions(+), 29 deletions(-) diff --git a/forms-flow-api/src/formsflow_api/models/form_process_mapper.py b/forms-flow-api/src/formsflow_api/models/form_process_mapper.py index 9e230f1b43..c80e646466 100644 --- a/forms-flow-api/src/formsflow_api/models/form_process_mapper.py +++ b/forms-flow-api/src/formsflow_api/models/form_process_mapper.py @@ -369,3 +369,20 @@ def tenant_authorization(cls, query: Query, **kwargs): if tenant_key is not None: tenant_auth_query = tenant_auth_query.filter(cls.tenant == tenant_key) return tenant_auth_query + + @classmethod + def find_all_active_forms( + cls, + page_number=None, + limit=None, + ): # pylint: disable=too-many-arguments + """Fetch all active forms.""" + query = cls.access_filter(query=cls.query) + total_count = query.count() + query = query.with_entities( + cls.form_id, + cls.form_name, + ) + limit = total_count if limit is None else limit + query = query.paginate(page=page_number, per_page=limit, error_out=False) + return query.items, total_count diff --git a/forms-flow-api/src/formsflow_api/resources/form_process_mapper.py b/forms-flow-api/src/formsflow_api/resources/form_process_mapper.py index 5b3fe639f7..1cf6c0f8b6 100644 --- a/forms-flow-api/src/formsflow_api/resources/form_process_mapper.py +++ b/forms-flow-api/src/formsflow_api/resources/form_process_mapper.py @@ -217,6 +217,7 @@ def get(): # pylint: disable=too-many-locals sort_order: str = dict_data.get("sort_order", "desc") form_type: str = dict_data.get("form_type", None) is_active = dict_data.get("is_active", None) + active_forms = dict_data.get("active_forms", None) if form_type: form_type = form_type.split(",") @@ -235,6 +236,7 @@ def get(): # pylint: disable=too-many-locals form_type=form_type, is_active=is_active, is_designer=auth.has_role([DESIGNER_GROUP]), + active_forms=active_forms, ) return ( ( diff --git a/forms-flow-api/src/formsflow_api/schemas/form_process_mapper.py b/forms-flow-api/src/formsflow_api/schemas/form_process_mapper.py index 324bbdcde3..1f0f8d9672 100644 --- a/forms-flow-api/src/formsflow_api/schemas/form_process_mapper.py +++ b/forms-flow-api/src/formsflow_api/schemas/form_process_mapper.py @@ -53,3 +53,4 @@ class FormProcessMapperListRequestSchema(FormProcessMapperListReqSchema): sort_order = fields.Str(data_key="sortOrder", required=False) form_type = fields.Str(data_key="formType", required=False) is_active = fields.Bool(data_key="isActive", required=False) + active_forms = fields.Bool(data_key="activeForms", required=False) diff --git a/forms-flow-api/src/formsflow_api/services/form_process_mapper.py b/forms-flow-api/src/formsflow_api/services/form_process_mapper.py index a0f7654092..2004adaba4 100644 --- a/forms-flow-api/src/formsflow_api/services/form_process_mapper.py +++ b/forms-flow-api/src/formsflow_api/services/form_process_mapper.py @@ -32,38 +32,45 @@ def get_all_forms( form_type: str, is_active, is_designer: bool, + active_forms: bool, **kwargs, ): # pylint: disable=too-many-arguments, too-many-locals """Get all forms.""" user: UserContext = kwargs["user"] authorized_form_ids: Set[str] = [] - form_ids = Authorization.find_all_resources_authorized( - auth_type=AuthType.DESIGNER if is_designer else AuthType.FORM, - roles=user.group_or_roles, - user_name=user.user_name, - tenant=user.tenant_key, - include_created_by=is_designer, - ) - for forms in form_ids: - authorized_form_ids.append(forms.resource_id) - designer_filters = { - "is_active": is_active, - "form_type": form_type, - } - list_form_mappers = ( - FormProcessMapper.find_all_forms - if is_designer - else FormProcessMapper.find_all_active_by_formid - ) - mappers, get_all_mappers_count = list_form_mappers( - page_number=page_number, - limit=limit, - form_name=form_name, - sort_by=sort_by, - sort_order=sort_order, - form_ids=authorized_form_ids, - **designer_filters if is_designer else {}, - ) + if active_forms: + mappers, get_all_mappers_count = FormProcessMapper.find_all_active_forms( + page_number=page_number, + limit=limit, + ) + else: + form_ids = Authorization.find_all_resources_authorized( + auth_type=AuthType.DESIGNER if is_designer else AuthType.FORM, + roles=user.group_or_roles, + user_name=user.user_name, + tenant=user.tenant_key, + include_created_by=is_designer, + ) + for forms in form_ids: + authorized_form_ids.append(forms.resource_id) + designer_filters = { + "is_active": is_active, + "form_type": form_type, + } + list_form_mappers = ( + FormProcessMapper.find_all_forms + if is_designer + else FormProcessMapper.find_all_active_by_formid + ) + mappers, get_all_mappers_count = list_form_mappers( + page_number=page_number, + limit=limit, + form_name=form_name, + sort_by=sort_by, + sort_order=sort_order, + form_ids=authorized_form_ids, + **designer_filters if is_designer else {}, + ) mapper_schema = FormProcessMapperSchema() return ( mapper_schema.dump(mappers, many=True), diff --git a/forms-flow-web/src/apiManager/services/bpmFormServices.js b/forms-flow-web/src/apiManager/services/bpmFormServices.js index 0e9a76f6e8..c295e0bea2 100644 --- a/forms-flow-web/src/apiManager/services/bpmFormServices.js +++ b/forms-flow-web/src/apiManager/services/bpmFormServices.js @@ -58,8 +58,8 @@ export const fetchBPMFormList = ( }; export const fetchAllForms = ()=>{ - //isActive means published forms only : status = Active - return RequestService.httpGETRequest(`${API.FORM}?isActive=true`); + //activeForms means published forms only : status = Active + return RequestService.httpGETRequest(`${API.FORM}?activeForms=true`); }; export const fetchFormByAlias = (path, ...rest) => {