From a5ad26ae1bdd1a856db7bbb0b463d979172fcbec Mon Sep 17 00:00:00 2001 From: kavi castelo <85213722+kavicastelo@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:03:10 +0530 Subject: [PATCH 1/7] Create ci.yml --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..63111050 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: + - '*' + +jobs: + build-frontend: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install dependencies + run: npm install + + - name: Build frontend + run: npm run build -- --prod + + build-backend: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '15' + + - name: Build backend + run: ./mvnw clean package From 753dcd22665117099a1de8c6d784b7ea2aba8a94 Mon Sep 17 00:00:00 2001 From: kavi castelo <85213722+kavicastelo@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:12:13 +0530 Subject: [PATCH 2/7] Update ci.yml --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63111050..3125bd8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,9 @@ jobs: uses: actions/checkout@v2 - name: Install dependencies - run: npm install + run: | + cd client + npm install - name: Build frontend run: npm run build -- --prod @@ -31,4 +33,6 @@ jobs: java-version: '15' - name: Build backend - run: ./mvnw clean package + run: | + chmod +x mvnw + ./mvnw clean package From 87912a9d82268cbf0fd5b652be9b31161c7b907c Mon Sep 17 00:00:00 2001 From: kavi castelo <85213722+kavicastelo@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:14:52 +0530 Subject: [PATCH 3/7] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3125bd8c..2eb055c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - name: Install dependencies run: | cd client - npm install + npm install --force - name: Build frontend run: npm run build -- --prod From c544f9e2d34b7cc2d95303b376e21006580271fe Mon Sep 17 00:00:00 2001 From: kavi castelo <85213722+kavicastelo@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:23:42 +0530 Subject: [PATCH 4/7] Update ci.yml --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2eb055c0..ee7579df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,9 @@ jobs: npm install --force - name: Build frontend - run: npm run build -- --prod + run: | + cd client + npm run build -- --prod build-backend: runs-on: ubuntu-latest @@ -30,9 +32,9 @@ jobs: uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: '15' + java-version: '17' - name: Build backend run: | - chmod +x mvnw + ./chmod +x mvnw ./mvnw clean package From 48b02de92f03d7bc32ce1c7d9ea893473679877c Mon Sep 17 00:00:00 2001 From: kavi castelo <85213722+kavicastelo@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:26:15 +0530 Subject: [PATCH 5/7] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee7579df..a06b5bc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - name: Build frontend run: | cd client - npm run build -- --prod + npm run build build-backend: runs-on: ubuntu-latest @@ -36,5 +36,5 @@ jobs: - name: Build backend run: | - ./chmod +x mvnw + chmod +x ./mvnw ./mvnw clean package From 2d13f87f80a621a1ada758cab4309720b404982b Mon Sep 17 00:00:00 2001 From: kavi castelo Date: Sat, 27 Apr 2024 22:29:23 +0530 Subject: [PATCH 6/7] contact controls --- .idea/codestream.xml | 1 + .../controller/ContactController.java | 38 +++++++++++++++++++ .../api/air_quality/model/ContactModel.java | 16 ++++++++ .../repository/ContactRepository.java | 5 ++- 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/.idea/codestream.xml b/.idea/codestream.xml index 63c45d05..b3b049e9 100644 --- a/.idea/codestream.xml +++ b/.idea/codestream.xml @@ -3,5 +3,6 @@ \ No newline at end of file diff --git a/src/main/java/com/api/air_quality/controller/ContactController.java b/src/main/java/com/api/air_quality/controller/ContactController.java index 8b0d60a1..4e25243f 100644 --- a/src/main/java/com/api/air_quality/controller/ContactController.java +++ b/src/main/java/com/api/air_quality/controller/ContactController.java @@ -1,4 +1,42 @@ package com.api.air_quality.controller; +import com.api.air_quality.dto.ApiResponse; +import com.api.air_quality.model.ContactModel; +import com.api.air_quality.repository.ContactRepository; +import com.api.air_quality.service.EmailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController public class ContactController { + + @Autowired + ContactRepository contactRepository; + + @Autowired + EmailService emailService; + + @PostMapping("/api/v1/contact") + public ResponseEntity sendMail(@RequestBody ContactModel contactModel){ + emailService.sendSimpleEmail("kavindu.kokila.info@gmail.com","Urban air quality platform - contact","" + + "Dear Administration,"+"\n" + + "You got an contact email from: "+contactModel.getSender()+"\n" + + "Email Address: "+contactModel.getSenderEmail()+"\n\n" + + ""+contactModel.getMessage()+"\n\n" + + "Client is waiting for your response. Reply ASAP\n\n\n" + + "System Automated Email - Urban Air Quality Platform"); + + emailService.sendSimpleEmail(contactModel.getSenderEmail(),"Urban air quality platform - contact","" + + "Dear "+contactModel.getSender()+","+"\n" + + "We got your contact message. Our agent will be contact you ASAP. Thank you for contacting with us! \n\n" + + "Sincerely,\n" + + "Urban Air Quality Platform.\n\n" + + "Note:- Don't reply to this email. This is system automated email."); + + ApiResponse response = new ApiResponse("Contact message sent successfully!"); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/api/air_quality/model/ContactModel.java b/src/main/java/com/api/air_quality/model/ContactModel.java index d43d8a51..af966939 100644 --- a/src/main/java/com/api/air_quality/model/ContactModel.java +++ b/src/main/java/com/api/air_quality/model/ContactModel.java @@ -1,4 +1,20 @@ package com.api.air_quality.model; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; + +@Getter +@Setter +@ToString + +@Document(collection = "contact") public class ContactModel { + @Id + private String id; + private String sender; + private String senderEmail; + private String message; } diff --git a/src/main/java/com/api/air_quality/repository/ContactRepository.java b/src/main/java/com/api/air_quality/repository/ContactRepository.java index d57726b0..2e98fc72 100644 --- a/src/main/java/com/api/air_quality/repository/ContactRepository.java +++ b/src/main/java/com/api/air_quality/repository/ContactRepository.java @@ -1,4 +1,7 @@ package com.api.air_quality.repository; -public interface ContactRepository { +import com.api.air_quality.model.ContactModel; +import org.springframework.data.mongodb.repository.MongoRepository; + +public interface ContactRepository extends MongoRepository { } From f6e5d609812549bb381b49ee616b3374c5a855e7 Mon Sep 17 00:00:00 2001 From: kavi castelo Date: Sat, 27 Apr 2024 23:19:55 +0530 Subject: [PATCH 7/7] Fixed fixed null pointer bug --- .idea/workspace.xml | 53 +++++++++++-------- .../controller/ContactController.java | 8 +-- .../api/air_quality/model/ContactModel.java | 4 +- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 6278a44d..6377e09d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,7 +5,6 @@ -<<<<<<< HEAD @@ -15,15 +14,19 @@ -======= - + + ->>>>>>> cbcae96abf9c046e3883394b4a83b21886fc237e + + + + + - { - "keyToString": { - "ASKED_ADD_EXTERNAL_FILES": "true", - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "WebServerToolWindowFactoryState": "false", - "last_opened_file_path": "E:/PROJECTS/HTML/Ethical-AI-driven-Geographic-Analytics-Platform/client/src/docs", - "nodejs_package_manager_path": "npm", - "spring.configuration.checksum": "d5f73674f4485e14aac5b80b81aca5c3", - "ts.external.directory.path": "E:\\PROJECTS\\HTML\\Ethical-AI-driven-Geographic-Analytics-Platform\\client\\node_modules\\typescript\\lib" + +}]]> @@ -83,7 +90,14 @@ - + + + + - - - diff --git a/src/main/java/com/api/air_quality/controller/ContactController.java b/src/main/java/com/api/air_quality/controller/ContactController.java index 4e25243f..65ae3395 100644 --- a/src/main/java/com/api/air_quality/controller/ContactController.java +++ b/src/main/java/com/api/air_quality/controller/ContactController.java @@ -23,14 +23,14 @@ public class ContactController { public ResponseEntity sendMail(@RequestBody ContactModel contactModel){ emailService.sendSimpleEmail("kavindu.kokila.info@gmail.com","Urban air quality platform - contact","" + "Dear Administration,"+"\n" + - "You got an contact email from: "+contactModel.getSender()+"\n" + - "Email Address: "+contactModel.getSenderEmail()+"\n\n" + + "You got an contact email from: "+contactModel.getName()+"\n" + + "Email Address: "+contactModel.getEmail()+"\n\n" + ""+contactModel.getMessage()+"\n\n" + "Client is waiting for your response. Reply ASAP\n\n\n" + "System Automated Email - Urban Air Quality Platform"); - emailService.sendSimpleEmail(contactModel.getSenderEmail(),"Urban air quality platform - contact","" + - "Dear "+contactModel.getSender()+","+"\n" + + emailService.sendSimpleEmail(contactModel.getEmail(),"Urban air quality platform - contact","" + + "Dear "+contactModel.getName()+","+"\n" + "We got your contact message. Our agent will be contact you ASAP. Thank you for contacting with us! \n\n" + "Sincerely,\n" + "Urban Air Quality Platform.\n\n" + diff --git a/src/main/java/com/api/air_quality/model/ContactModel.java b/src/main/java/com/api/air_quality/model/ContactModel.java index af966939..b792cfd3 100644 --- a/src/main/java/com/api/air_quality/model/ContactModel.java +++ b/src/main/java/com/api/air_quality/model/ContactModel.java @@ -14,7 +14,7 @@ public class ContactModel { @Id private String id; - private String sender; - private String senderEmail; + private String name; + private String email; private String message; }