From dd95c92e04829604caf80e9e2a857d8f70abfbf5 Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Thu, 29 May 2025 10:45:43 +0300 Subject: [PATCH] ci: Rename environment variables in CI/CD - Rename environment variables to use the `CSHR_` prefix for better organization and clarity. This improves maintainability and avoids naming conflicts. - Update `.gitignore` to include the new environment file path. - Update client-side environment variables to use the `CSHR_` prefix, ensuring consistency across the application. - Update the client-side config file to match the new environment variable names. --- .github/workflows/test.yml | 16 +- .gitignore | 2 +- client/env.d.ts | 4 +- client/package.json | 3 +- client/public/config.js | 8 +- client/src/clients/api/vacations.ts | 7 + client/src/clients/index.ts | 6 +- client/src/components/CalenderComponent.vue | 484 ++++++++++++++++-- client/src/components/CshrToolbar.vue | 15 + client/src/components/SideDrawer.vue | 99 +++- client/src/components/calenderRequest.vue | 52 +- client/src/components/cards/vacationCard.vue | 204 ++++++-- .../src/components/dashboard/UpdateUser.vue | 2 +- client/src/components/profileImage.vue | 2 +- client/src/index.ts | 4 +- client/src/stores/WSConnection.ts | 4 +- client/src/utils/add_update_user_form.ts | 2 +- client/tsconfig.node.json | 6 +- config/.env.template | 36 +- docker/backend.Dockerfile | 32 +- docker/docker-compose.yml | 40 +- docker/frontend.Dockerfile | 8 +- docker/scripts/backend/backend.sh | 8 +- docker/scripts/backend/config.sh | 36 +- docker/scripts/frontend/build-env.sh | 4 +- server/celery_app.py | 10 +- .../cshr/consumers/notifications_consumer.py | 78 ++- server/cshr/management/commands/create.py | 2 +- server/cshr/serializers/Image_upload.py | 30 +- server/cshr/utils/redis_functions.py | 4 +- server/cshr/utils/send_email.py | 8 +- server/cshr/views/vacations.py | 3 +- server/poetry.lock | 158 ++++-- server/pyproject.toml | 1 + server/settings.py | 40 +- server/views.py | 12 +- terraform/main.tf | 20 +- terraform/main.tf.template | 18 +- 38 files changed, 1139 insertions(+), 329 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9fdc41180..05bf94a69 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,14 +22,14 @@ jobs: - name: Create env file run: | touch .env - echo DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }} >> .env - echo DJANGO_DEBUG=${{ secrets.DJANGO_DEBUG }} >> .env - echo EMAIL=${{ secrets.EMAIL }} >> .env - echo EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }} >> .env - echo EMAIL_HOST=${{ secrets.EMAIL_HOST }} >> .env - echo REDIS_HOST=${{ secrets.REDIS_HOST}} >> .env - echo SERVER_DOMAIN_NAME=${{ secrets.SERVER_DOMAIN_NAME }} >> .env - echo CLIENT_DOMAIN_NAME=${{ secrets.CLIENT_DOMAIN_NAME }} >> .env + echo CSHR_DJANGO_SECRET_KEY=${{ secrets.CSHR_DJANGO_SECRET_KEY }} >> .env + echo CSHR_DJANGO_DEBUG=${{ secrets.CSHR_DJANGO_DEBUG }} >> .env + echo CSHR_EMAIL=${{ secrets.CSHR_EMAIL }} >> .env + echo CSHR_EMAIL_PASSWORD=${{ secrets.CSHR_EMAIL_PASSWORD }} >> .env + echo CSHR_EMAIL_HOST=${{ secrets.CSHR_EMAIL_HOST }} >> .env + echo CSHR_REDIS_HOST=${{ secrets.CSHR_REDIS_HOST}} >> .env + echo CSHR_SERVER_DOMAIN_NAME=${{ secrets.CSHR_SERVER_DOMAIN_NAME }} >> .env + echo CSHR_CLIENT_DOMAIN_NAME=${{ secrets.CSHR_CLIENT_DOMAIN_NAME }} >> .env cat .env - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 diff --git a/.gitignore b/.gitignore index d24ee920f..d69a8e42f 100644 --- a/.gitignore +++ b/.gitignore @@ -118,7 +118,7 @@ celerybeat.pid .venv env/ venv/ -ENV/ +CSHR_ENV/ env.bak/ venv.bak/ diff --git a/client/env.d.ts b/client/env.d.ts index 0f899a7d5..6a09fbd5e 100644 --- a/client/env.d.ts +++ b/client/env.d.ts @@ -5,6 +5,6 @@ interface ImportMetaEnv { VITE_TITLE: string VITE_FAVICON: string VITE_LOGO: string - SERVER_DOMAIN_NAME_API: string - SERVER_DOMAIN_NAME_WS: string + CSHR_SERVER_DOMAIN_NAME_API: string + CSHR_SERVER_DOMAIN_NAME_WS: string } diff --git a/client/package.json b/client/package.json index e7de5e545..d84b4ab86 100644 --- a/client/package.json +++ b/client/package.json @@ -57,5 +57,6 @@ "vite-plugin-vuetify": "^2.0.1", "vitest": "^1.0.4", "vue-tsc": "^1.8.25" - } + }, + "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977" } diff --git a/client/public/config.js b/client/public/config.js index b1a3eb9ea..f38564bc4 100644 --- a/client/public/config.js +++ b/client/public/config.js @@ -1,6 +1,6 @@ window.env = { - // SERVER_DOMAIN_NAME_API: 'https://cshrserver.gent01.qa.grid.tf/api', // Added for testing, this is a staging API - // SERVER_DOMAIN_NAME_WS: 'wss://cshrserver.gent01.qa.grid.tf/ws/notification', // Added for testing, this is a staging API - SERVER_DOMAIN_NAME_API: 'http://127.0.0.1:8000/api', // Added for testing, this is the local server API - SERVER_DOMAIN_NAME_WS: 'ws://127.0.0.1:8000/ws/notification', // Added for testing, this is the local server API + // CSHR_SERVER_DOMAIN_NAME_API: 'https://cshrserver.gent01.qa.grid.tf/api', // Added for testing, this is a staging API + // CSHR_SERVER_DOMAIN_NAME_WS: 'wss://cshrserver.gent01.qa.grid.tf/ws/notification', // Added for testing, this is a staging API + CSHR_SERVER_DOMAIN_NAME_API: 'http://127.0.0.1:8000/api', // Added for testing, this is the local server API + CSHR_SERVER_DOMAIN_NAME_WS: 'ws://127.0.0.1:8000/ws/notification', // Added for testing, this is the local server API }; \ No newline at end of file diff --git a/client/src/clients/api/vacations.ts b/client/src/clients/api/vacations.ts index be8d4cdba..267253df0 100644 --- a/client/src/clients/api/vacations.ts +++ b/client/src/clients/api/vacations.ts @@ -95,6 +95,13 @@ export class VacationsApi extends ApiClientBase { }) } + async delete(id: number) { + ApiClientBase.assertUser() + return this.unwrap(() => this.$http.delete(this.getUrl(`/${id}`)), { + transform: (d) => d.results + }) + } + async requestToCancel(id: number) { return this.unwrap(() => this.$http.put(this.getUrl(`/request-to-cancel/${id}`)), { transform: (d) => d.results diff --git a/client/src/clients/index.ts b/client/src/clients/index.ts index bb5694e85..e5b28db76 100644 --- a/client/src/clients/index.ts +++ b/client/src/clients/index.ts @@ -2,13 +2,13 @@ import axios from 'axios' import { ApiClient } from './api' -console.log(`API connected on: ${window.env.SERVER_DOMAIN_NAME_API}`); -console.log(`WS connected on: ${window.env.SERVER_DOMAIN_NAME_WS}`); +console.log(`API connected on: ${window.env.CSHR_SERVER_DOMAIN_NAME_API}`); +console.log(`WS connected on: ${window.env.CSHR_SERVER_DOMAIN_NAME_WS}`); const accessToken = localStorage.getItem("access_token") export const $api = new ApiClient({ $http: axios.create({ - baseURL: window.env.SERVER_DOMAIN_NAME_API, + baseURL: window.env.CSHR_SERVER_DOMAIN_NAME_API, headers: { Authorization: `Bearer ${accessToken}`, }, diff --git a/client/src/components/CalenderComponent.vue b/client/src/components/CalenderComponent.vue index f49263fc5..5381c2a06 100644 --- a/client/src/components/CalenderComponent.vue +++ b/client/src/components/CalenderComponent.vue @@ -1,39 +1,108 @@ diff --git a/client/src/components/CshrToolbar.vue b/client/src/components/CshrToolbar.vue index c202f1c68..419696037 100644 --- a/client/src/components/CshrToolbar.vue +++ b/client/src/components/CshrToolbar.vue @@ -1,5 +1,13 @@