From c9f9b0e6fb96ec149e99241a5c291a80139c0e22 Mon Sep 17 00:00:00 2001 From: soletsdev Date: Wed, 4 Sep 2024 11:00:03 -0700 Subject: [PATCH 1/3] renable deploy to test --- .../deploy-to.openshift-dev-and-test.yml | 192 +++++++++--------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/.github/workflows/deploy-to.openshift-dev-and-test.yml b/.github/workflows/deploy-to.openshift-dev-and-test.yml index 25ed1d74..932725df 100644 --- a/.github/workflows/deploy-to.openshift-dev-and-test.yml +++ b/.github/workflows/deploy-to.openshift-dev-and-test.yml @@ -212,99 +212,99 @@ jobs: with: target: 'https://${{ env.HOST_ROUTE }}' -# deploy-test: -# name: Deploy to TEST -# needs: build-and-deploy-dev -# runs-on: ubuntu-22.04 -# environment: test -# -# outputs: -# ROUTE: ${{ steps.deploy-and-expose.outputs.route }} -# SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} -# -# steps: -# - name: Check for required secrets -# uses: actions/github-script@v6 -# with: -# script: | -# const secrets = { -# OPENSHIFT_SERVER: `${{ secrets.OPENSHIFT_SERVER }}`, -# OPENSHIFT_TOKEN: `${{ secrets.OPENSHIFT_TOKEN }}`, -# }; -# -# const GHCR = "ghcr.io"; -# if (`${{ env.IMAGE_REGISTRY }}`.startsWith(GHCR)) { -# core.info(`Image registry is ${GHCR} - no registry password required`); -# } -# else { -# core.info("A registry password is required"); -# secrets["IMAGE_REGISTRY_PASSWORD"] = `${{ secrets.IMAGE_REGISTRY_PASSWORD }}`; -# } -# -# const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => { -# if (value.length === 0) { -# core.error(`Secret "${name}" is not set`); -# return true; -# } -# core.info(`✔️ Secret "${name}" is set`); -# return false; -# }); -# -# if (missingSecrets.length > 0) { -# core.setFailed(`❌ At least one required secret is not set in the repository. \n` + -# "You can add it using:\n" + -# "GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + -# "GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" + -# "Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example"); -# } -# else { -# core.info(`✅ All the required secrets are set`); -# } -# -# - name: Check out repository -# uses: actions/checkout@v3 -# -# - name: Install oc -# uses: redhat-actions/openshift-tools-installer@v1 -# with: -# oc: 4 -# -# # https://github.com/redhat-actions/oc-login#readme -# - uses: actions/checkout@v3 -# - name: Deploy -# run: | -# set -eux -# # Login to OpenShift and select project -# oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} -# oc project ${{ env.OPENSHIFT_NAMESPACE_TEST }} -# # Cancel any rollouts in progress -# oc rollout cancel dc/${{ env.IMAGE_NAME }} 2> /dev/null \ -# || true && echo "No rollout in progress" -# -# oc tag ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-frontend-static:latest ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-frontend-static:latest -# oc tag ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-backend-${{ env.BRANCH }}:latest ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-backend-${{ env.BRANCH }}:latest -# -# # Process and apply deployment template -# oc process -f tools/openshift/backend.dc.yaml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p BRANCH=${{ env.BRANCH }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_TEST }} -p TAG=${{ env.TAG }} -p MIN_REPLICAS=${{ env.MIN_REPLICAS_TEST }} -p MAX_REPLICAS=${{ env.MAX_REPLICAS_TEST }} -p MIN_CPU=${{ env.MIN_CPU }} -p MAX_CPU=${{ env.MAX_CPU }} -p MIN_MEM=${{ env.MIN_MEM }} -p MAX_MEM=${{ env.MAX_MEM }} -p HOST_ROUTE=${{ env.HOST_ROUTE }}\ -# | oc apply -f - -# -# # Process and apply deployment template -# oc process -f tools/openshift/frontend-static.dc.yaml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p BRANCH=${{ env.BRANCH }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_TEST }} -p TAG=${{ env.TAG }} -p MIN_REPLICAS=${{ env.MIN_REPLICAS_TEST }} -p MAX_REPLICAS=${{ env.MAX_REPLICAS_TEST }} -p MIN_CPU=${{ env.MIN_CPU }} -p MAX_CPU=${{ env.MAX_CPU }} -p MIN_MEM=${{ env.MIN_MEM }} -p MAX_MEM=${{ env.MAX_MEM }} -p HOST_ROUTE=${{ env.HOST_ROUTE }}\ -# | oc apply -f - -# -# curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/master/tools/config/update-configmap.sh | bash /dev/stdin test ${{ env.APP_NAME }} ${{ env.NAMESPACE }} ${{ env.COMMON_NAMESPACE }} ${{ env.EDX_NAMESPACE }} ${{ env.SPLUNK_TOKEN }} -# -# # Start rollout (if necessary) and follow it -# oc rollout latest dc/${{ env.IMAGE_NAME }} 2> /dev/null \ -# || true && echo "Rollout in progress" -# -# oc rollout latest dc/${{ env.APP_NAME_FRONTEND_MASTER }} 2> /dev/null \ -# || true && echo "Rollout in progress" -# oc logs -f dc/${{ env.IMAGE_NAME }} -# # Get status, returns 0 if rollout is successful -# oc rollout status dc/${{ env.IMAGE_NAME }} -# -# - name: ZAP Scan -# uses: zaproxy/action-full-scan@v0.7.0 -# with: -# target: 'https://${{ env.HOST_ROUTE }}' + deploy-test: + name: Deploy to TEST + needs: build-and-deploy-dev + runs-on: ubuntu-22.04 + environment: test + + outputs: + ROUTE: ${{ steps.deploy-and-expose.outputs.route }} + SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} + + steps: + - name: Check for required secrets + uses: actions/github-script@v6 + with: + script: | + const secrets = { + OPENSHIFT_SERVER: `${{ secrets.OPENSHIFT_SERVER }}`, + OPENSHIFT_TOKEN: `${{ secrets.OPENSHIFT_TOKEN }}`, + }; + + const GHCR = "ghcr.io"; + if (`${{ env.IMAGE_REGISTRY }}`.startsWith(GHCR)) { + core.info(`Image registry is ${GHCR} - no registry password required`); + } + else { + core.info("A registry password is required"); + secrets["IMAGE_REGISTRY_PASSWORD"] = `${{ secrets.IMAGE_REGISTRY_PASSWORD }}`; + } + + const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => { + if (value.length === 0) { + core.error(`Secret "${name}" is not set`); + return true; + } + core.info(`✔️ Secret "${name}" is set`); + return false; + }); + + if (missingSecrets.length > 0) { + core.setFailed(`❌ At least one required secret is not set in the repository. \n` + + "You can add it using:\n" + + "GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + + "GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" + + "Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example"); + } + else { + core.info(`✅ All the required secrets are set`); + } + + - name: Check out repository + uses: actions/checkout@v3 + + - name: Install oc + uses: redhat-actions/openshift-tools-installer@v1 + with: + oc: 4 + + # https://github.com/redhat-actions/oc-login#readme + - uses: actions/checkout@v3 + - name: Deploy + run: | + set -eux + # Login to OpenShift and select project + oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} + oc project ${{ env.OPENSHIFT_NAMESPACE_TEST }} + # Cancel any rollouts in progress + oc rollout cancel dc/${{ env.IMAGE_NAME }} 2> /dev/null \ + || true && echo "No rollout in progress" + + oc tag ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-frontend-static:latest ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-frontend-static:latest + oc tag ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-backend-${{ env.BRANCH }}:latest ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-backend-${{ env.BRANCH }}:latest + + # Process and apply deployment template + oc process -f tools/openshift/backend.dc.yaml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p BRANCH=${{ env.BRANCH }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_TEST }} -p TAG=${{ env.TAG }} -p MIN_REPLICAS=${{ env.MIN_REPLICAS_TEST }} -p MAX_REPLICAS=${{ env.MAX_REPLICAS_TEST }} -p MIN_CPU=${{ env.MIN_CPU }} -p MAX_CPU=${{ env.MAX_CPU }} -p MIN_MEM=${{ env.MIN_MEM }} -p MAX_MEM=${{ env.MAX_MEM }} -p HOST_ROUTE=${{ env.HOST_ROUTE }}\ + | oc apply -f - + + # Process and apply deployment template + oc process -f tools/openshift/frontend-static.dc.yaml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p BRANCH=${{ env.BRANCH }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_TEST }} -p TAG=${{ env.TAG }} -p MIN_REPLICAS=${{ env.MIN_REPLICAS_TEST }} -p MAX_REPLICAS=${{ env.MAX_REPLICAS_TEST }} -p MIN_CPU=${{ env.MIN_CPU }} -p MAX_CPU=${{ env.MAX_CPU }} -p MIN_MEM=${{ env.MIN_MEM }} -p MAX_MEM=${{ env.MAX_MEM }} -p HOST_ROUTE=${{ env.HOST_ROUTE }}\ + | oc apply -f - + + curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/master/tools/config/update-configmap.sh | bash /dev/stdin test ${{ env.APP_NAME }} ${{ env.NAMESPACE }} ${{ env.COMMON_NAMESPACE }} ${{ env.EDX_NAMESPACE }} ${{ env.SPLUNK_TOKEN }} + + # Start rollout (if necessary) and follow it + oc rollout latest dc/${{ env.IMAGE_NAME }} 2> /dev/null \ + || true && echo "Rollout in progress" + + oc rollout latest dc/${{ env.APP_NAME_FRONTEND_MASTER }} 2> /dev/null \ + || true && echo "Rollout in progress" + oc logs -f dc/${{ env.IMAGE_NAME }} + # Get status, returns 0 if rollout is successful + oc rollout status dc/${{ env.IMAGE_NAME }} + + - name: ZAP Scan + uses: zaproxy/action-full-scan@v0.7.0 + with: + target: 'https://${{ env.HOST_ROUTE }}' From 1567b56a55f8623bb810625e0af233b413a1c849 Mon Sep 17 00:00:00 2001 From: mightycox Date: Thu, 5 Sep 2024 11:12:00 -0700 Subject: [PATCH 2/3] Properly stringifies sort and searchCriteriaList for axios upgrade --- backend/src/components/edx/exchange.js | 2 +- backend/src/components/institute/institute.js | 8 ++++---- backend/src/components/penRequests.js | 15 +++++++++++++-- backend/src/components/requests.js | 2 +- backend/src/components/studentSearch.js | 4 ++-- backend/src/components/utils.js | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/backend/src/components/edx/exchange.js b/backend/src/components/edx/exchange.js index 3819beff..5f213d29 100644 --- a/backend/src/components/edx/exchange.js +++ b/backend/src/components/edx/exchange.js @@ -113,7 +113,7 @@ async function getExchangesPaginated(req, res) { params: { pageNumber: req.query.pageNumber, pageSize: req.query.pageSize, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(criteria), } }; diff --git a/backend/src/components/institute/institute.js b/backend/src/components/institute/institute.js index 63032ed3..9e3cda48 100644 --- a/backend/src/components/institute/institute.js +++ b/backend/src/components/institute/institute.js @@ -829,7 +829,7 @@ async function getStudentRegistrationContactByMincode(req, res) { params: { pageNumber: req.query.pageNumber, pageSize: req.query.pageSize, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(schoolSearchCriteria) } }; @@ -958,7 +958,7 @@ async function getSchoolsPaginated(req, res){ params: { pageNumber: req.query.pageNumber, pageSize: req.query.pageSize, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(schoolSearchCriteria) } }; @@ -1060,7 +1060,7 @@ async function getSchoolHistoryPaginated(req, res) { params: { pageNumber: req.query.pageNumber, pageSize: req.query.pageSize, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(historySearchCriteria) } }; @@ -1262,7 +1262,7 @@ async function getAuthoritiesPaginated(req, res){ params: { pageNumber: req.query.pageNumber, pageSize: req.query.pageSize, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(authoritySearchCriteria) } }; diff --git a/backend/src/components/penRequests.js b/backend/src/components/penRequests.js index 75179c19..f2f02a93 100644 --- a/backend/src/components/penRequests.js +++ b/backend/src/components/penRequests.js @@ -24,9 +24,20 @@ async function findPenRequestsByPen(req, res) { try { let yearAgo = LocalDateTime.now().minus(1, ChronoUnit.YEARS); let now = LocalDateTime.now(); - const url = `${config.get('server:penRequest:rootURL')}/paginated?pageNumber=0&pageSize=200&searchCriteriaList=[{"key":"initialSubmitDate","operation":"btn","value":"${yearAgo},${now}","valueType":"DATE_TIME"},{"key":"pen","operation":"eq","value":"${req.query.pen}","valueType":"STRING"}]}]` + let searchCriteriaList = []; + searchCriteriaList.push({key:'initialSubmitDate',operation:'btn',value:`${yearAgo},${now}`,valueType:'DATE_TIME'}); + searchCriteriaList.push({key:'pen',operation:'eq',value:`${req.query.pen}`,valueType:'STRING'}); + const params = { + params: { + pageNumber: req.query.pageNumber, + pageSize: req.query.pageSize, + sort: JSON.stringify(req.query.sort), + searchCriteriaList: JSON.stringify(searchCriteriaList) + } + }; + const url = `${config.get('server:penRequest:rootURL')}/paginated`; - const response = await getData(url); + const response = await getData(url, params); return res.status(200).json(response.numberOfElements); } catch (e) { logApiError(e, 'findPenRequestsByPen', 'Failed to get pen requests for the given pen.'); diff --git a/backend/src/components/requests.js b/backend/src/components/requests.js index db299283..13749885 100644 --- a/backend/src/components/requests.js +++ b/backend/src/components/requests.js @@ -56,7 +56,7 @@ function getAllRequests(requestType) { params: { pageNumber: req.query.pageNumber, pageSize: req.query.pageSize, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(searchListCriteria) } }; diff --git a/backend/src/components/studentSearch.js b/backend/src/components/studentSearch.js index 4309cc68..02f1022b 100644 --- a/backend/src/components/studentSearch.js +++ b/backend/src/components/studentSearch.js @@ -98,7 +98,7 @@ async function searchStudent(req, res) { const params = { params: { pageNumber: req.query.pageNumber, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(search) } }; @@ -137,7 +137,7 @@ async function getStudentHistoryByStudentID(req, res) { params: { pageSize: req.query.pageSize <= 20 ? req.query.pageSize : 20, pageNumber: req.query.pageNumber, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), } }; diff --git a/backend/src/components/utils.js b/backend/src/components/utils.js index 581ba12f..d69825f9 100644 --- a/backend/src/components/utils.js +++ b/backend/src/components/utils.js @@ -319,7 +319,7 @@ function getPaginatedListForSCGroups(apiName, url, handleResponse) { params: { pageNumber: req.query.pageNumber, pageSize, - sort: req.query.sort, + sort: JSON.stringify(req.query.sort), searchCriteriaList: JSON.stringify(req.query.searchQueries) } }; From fcaac006e5d00a79d812f4745c51492b64a14232 Mon Sep 17 00:00:00 2001 From: Marco Villeneuve Date: Fri, 6 Sep 2024 16:23:12 -0700 Subject: [PATCH 3/3] Added finance report for indy schools --- backend/src/components/ministrySDCReports.js | 3 ++- .../src/components/data-collection/Reports.vue | 17 ++++++++++++++--- frontend/src/utils/constants.js | 6 ++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/backend/src/components/ministrySDCReports.js b/backend/src/components/ministrySDCReports.js index 4caeae3e..32a6d8c0 100644 --- a/backend/src/components/ministrySDCReports.js +++ b/backend/src/components/ministrySDCReports.js @@ -3,7 +3,7 @@ const { logApiError, errorResponse, getData } = require('./utils'); const config = require('../config/index'); const HttpStatus = require('http-status-codes'); let reportTypes = ['indy-inclusive-ed-enrollment-headcounts', 'school-enrollment-headcounts', 'indy-school-enrollment-headcounts', 'school-address-report', 'fsa-registration-report', - 'offshore-enrollment-headcounts', 'offshore-languages-headcounts']; + 'offshore-enrollment-headcounts', 'offshore-languages-headcounts', 'indy-inclusive-ed-funding-headcounts']; async function getMinistrySDCReport(req, res) { try { @@ -49,6 +49,7 @@ function getFileDetails(reportType) { 'fsa-registration-report': { filename: 'FsaRegistrationReport.csv', contentType: 'text/csv' }, 'offshore-enrollment-headcounts': { filename: 'OffshoreSchoolsHeadcounts.csv', contentType: 'text/csv' }, 'offshore-languages-headcounts': { filename: 'OffshoreSpokenLanguageHeadcounts.csv', contentType: 'text/csv' }, + 'indy-inclusive-ed-funding-headcounts': { filename: 'IndependentSchoolsInclusiveEdFundingHeadcounts.csv', contentType: 'text/csv' }, 'DEFAULT': { filename: 'download.pdf', contentType: 'application/pdf' } }; return mappings[reportType] || mappings['DEFAULT']; diff --git a/frontend/src/components/data-collection/Reports.vue b/frontend/src/components/data-collection/Reports.vue index fba1856f..58ec614a 100644 --- a/frontend/src/components/data-collection/Reports.vue +++ b/frontend/src/components/data-collection/Reports.vue @@ -84,9 +84,9 @@ export default { data() { return { reportView: null, - publicReports: SDC_REPORTS.publicReports, - independentReports: SDC_REPORTS.independentReports, - headcountsReports: SDC_REPORTS.headcountReports + publicReports: [], + independentReports: [], + headcountsReports: [] }; }, computed: { @@ -94,8 +94,19 @@ export default { }, created() { this.setOriginalReportTab(); + this.publicReports = this.getActiveReports(SDC_REPORTS.publicReports); + this.independentReports = this.getActiveReports(SDC_REPORTS.independentReports); + this.headcountsReports = this.getActiveReports(SDC_REPORTS.headcountReports); }, methods: { + getActiveReports(reports){ + return reports.filter(report => { + if(report.onlyForCollection && !report.onlyForCollection.includes(this.collectionObject.collectionTypeCode)){ + return false; + } + return true; + }); + }, setOriginalReportTab(){ if(this.hasAccessToPublicReports()){ this.reportView = 'publicReports'; diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index b65bd702..fb032487 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -420,6 +420,12 @@ export const SDC_REPORTS = Object.freeze( url: object.SDC_MINISTRY_REPORTS + '/headcount/indy-inclusive-ed-enrollment-headcounts/', csvDownloadURL: object.SDC_MINISTRY_REPORTS + '/download/headcount/indy-inclusive-ed-enrollment-headcounts/' }, + { + label: 'Independent School Inclusive Education Funding Headcounts', + url: object.SDC_MINISTRY_REPORTS + '/headcount/indy-inclusive-ed-funding-headcounts/', + csvDownloadURL: object.SDC_MINISTRY_REPORTS + '/download/headcount/indy-inclusive-ed-funding-headcounts/', + onlyForCollection: ['FEBRUARY'] + }, { label: 'Offshore School Enrolment Headcounts', url: object.SDC_MINISTRY_REPORTS + '/headcount/offshore-enrollment-headcounts/',