No commits in common. '3281fd4055295a0770d3bbe5818cb17c77d6284d' and '31300a03703348f520ac337a16cd6a79f2a76c96' have entirely different histories.

  1. BIN
      .mvn/wrapper/maven-wrapper.jar
  2. 2
      .mvn/wrapper/maven-wrapper.properties
  3. 3
      src/main/java/com/feedback/it_asset/ItAssetApplication.java
  4. 118
      src/main/java/com/feedback/it_asset/component/UserSessionInterceptor.java
  5. 399
      src/main/java/com/feedback/it_asset/controller/APIController.java
  6. 2
      src/main/java/com/feedback/it_asset/controller/AssetController.java
  7. 58
      src/main/java/com/feedback/it_asset/controller/FeedbackController.java
  8. 63
      src/main/java/com/feedback/it_asset/controller/MainController.java
  9. 18
      src/main/java/com/feedback/it_asset/dto/FeedbackCountResponse.java
  10. 6
      src/main/java/com/feedback/it_asset/dto/ItAssetDashboardDto.java
  11. 34
      src/main/java/com/feedback/it_asset/dto/MonthWiseCountsDTO.java
  12. 4
      src/main/java/com/feedback/it_asset/entity/AssetCategory.java
  13. 8
      src/main/java/com/feedback/it_asset/entity/AssetCategoryQuestions.java
  14. 10
      src/main/java/com/feedback/it_asset/entity/GccAssetDetails.java
  15. 4
      src/main/java/com/feedback/it_asset/entity/GccFeedbackData.java
  16. 40
      src/main/java/com/feedback/it_asset/entity/Role.java
  17. 134
      src/main/java/com/feedback/it_asset/entity/User.java
  18. 57
      src/main/java/com/feedback/it_asset/entity/UserRole.java
  19. 6
      src/main/java/com/feedback/it_asset/repository/GccAssetDetailsRep.java
  20. 50
      src/main/java/com/feedback/it_asset/repository/GccFeedbackDataRep.java
  21. 13
      src/main/java/com/feedback/it_asset/repository/GccFeedbackRep.java
  22. 12
      src/main/java/com/feedback/it_asset/repository/UserRepository.java
  23. 78
      src/main/java/com/feedback/it_asset/service/AssetDetailsService.java
  24. 55
      src/main/java/com/feedback/it_asset/service/GccAssetService.java
  25. 3
      src/main/resources/application.properties
  26. 452
      src/main/resources/templates/closedchart.html
  27. 298
      src/main/resources/templates/dashboard.html
  28. 36
      src/main/resources/templates/gcc-asset-list.html
  29. 19
      src/main/resources/templates/gcc-complaint.html
  30. 409
      src/main/resources/templates/old-dashboard.html
  31. 2
      src/main/resources/templates/pending-complaint.html
  32. 455
      src/main/resources/templates/pendingchart.html
  33. 62
      src/main/resources/templates/testdashboard.html
  34. 452
      src/main/resources/templates/totalchart.html

BIN
.mvn/wrapper/maven-wrapper.jar

2
.mvn/wrapper/maven-wrapper.properties

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

3
src/main/java/com/feedback/it_asset/ItAssetApplication.java

@ -11,3 +11,6 @@ public class ItAssetApplication {
}
}

118
src/main/java/com/feedback/it_asset/component/UserSessionInterceptor.java

@ -1,59 +1,59 @@
package com.feedback.it_asset.component;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import com.feedback.it_asset.AppConfig;
import com.feedback.it_asset.UserSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@Component
public class UserSessionInterceptor implements HandlerInterceptor {
@Autowired
private UserSession userSession;
@Autowired
private AppConfig appConfig;
private static final List<String> EXCLUDED_URLS = Arrays.asList("/login", "/", "/api");
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// Get the current request URL
String requestUrl = request.getRequestURI();
// Exclude static resources from the check
if (requestUrl.startsWith("/assets/") || requestUrl.startsWith("/css/") || requestUrl.startsWith("/js/") || requestUrl.startsWith("/images/") || requestUrl.startsWith("/api/")) {
return true; // Allow the request to proceed without checking the login status
}
// Exclude the login page from the check
// Exclude specific URLs from the check
if (EXCLUDED_URLS.contains(requestUrl)) {
return true; // Allow the request to proceed without checking the login status
}
// Check if the user is logged in
// If logged in, add the userSession to the model
// Return true to allow the request to proceed
//if (isLoggedIn()) {
if(userSession.getUserId() != null && userSession.getUserType() != null) {
request.setAttribute("userSession", userSession);
} else {
request.setAttribute("title", "Login");
request.setAttribute("baseURL", appConfig.getBaseUrl());
response.sendRedirect("/login");
return false; // Stop further processing of the request
}
return true; // Allow the request to proceed
}
private boolean isLoggedIn() {
// Implement your login check logic here
// For example, check if the userSession contains the necessary information
return userSession.getUserId() != null && userSession.getUserType() != null;
}
}
//package com.feedback.it_asset.component;
//
//import java.util.Arrays;
//import java.util.List;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import com.feedback.it_asset.AppConfig;
//import com.feedback.it_asset.UserSession;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//
//@Component
//public class UserSessionInterceptor implements HandlerInterceptor {
//
// @Autowired
// private UserSession userSession;
// @Autowired
// private AppConfig appConfig;
//
// private static final List<String> EXCLUDED_URLS = Arrays.asList("/login", "/", "/api");
// @Override
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// // Get the current request URL
// String requestUrl = request.getRequestURI();
//
// // Exclude static resources from the check
// if (requestUrl.startsWith("/assets/") || requestUrl.startsWith("/css/") || requestUrl.startsWith("/js/") || requestUrl.startsWith("/images/") || requestUrl.startsWith("/api/")) {
// return true; // Allow the request to proceed without checking the login status
// }
//
// // Exclude the login page from the check
// // Exclude specific URLs from the check
// if (EXCLUDED_URLS.contains(requestUrl)) {
// return true; // Allow the request to proceed without checking the login status
// }
// // Check if the user is logged in
// // If logged in, add the userSession to the model
// // Return true to allow the request to proceed
// //if (isLoggedIn()) {
// if(userSession.getUserId() != null && userSession.getUserType() != null) {
// request.setAttribute("userSession", userSession);
// } else {
// request.setAttribute("title", "Login");
// request.setAttribute("baseURL", appConfig.getBaseUrl());
// response.sendRedirect("/login");
// return false; // Stop further processing of the request
// }
// return true; // Allow the request to proceed
// }
//
// private boolean isLoggedIn() {
// // Implement your login check logic here
// // For example, check if the userSession contains the necessary information
// return userSession.getUserId() != null && userSession.getUserType() != null;
// }
//}

399
src/main/java/com/feedback/it_asset/controller/APIController.java

@ -1,15 +1,12 @@
package com.feedback.it_asset.controller;
import java.io.IOException;
import java.sql.Blob;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
@ -17,13 +14,12 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.sql.rowset.serial.SerialBlob;
import org.apache.xmlbeans.impl.values.XmlUnsignedLongImpl;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpEntity;
@ -31,28 +27,24 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import com.feedback.it_asset.AppConfig;
import com.feedback.it_asset.QRCodeGenerator;
import com.feedback.it_asset.QRCodeGenerator;
import com.feedback.it_asset.dto.GccAssetDetailsDto;
import com.feedback.it_asset.dto.FeedbackCountResponse;
import com.feedback.it_asset.entity.AssetCategory;
import com.feedback.it_asset.entity.AssetCategoryQuestions;
import com.feedback.it_asset.entity.AssetParameter;
import com.feedback.it_asset.entity.AssetParameterQuestions;
import com.feedback.it_asset.entity.GccAssetDetails;
import com.feedback.it_asset.entity.GccFeedback;
import com.feedback.it_asset.entity.GccFeedbackData;
import com.feedback.it_asset.entity.GccFileData;
import com.feedback.it_asset.repository.AssetCategoryQuestionsRep;
import com.feedback.it_asset.repository.AssetCategoryRep;
import com.feedback.it_asset.repository.AssetParameterQuestionsRep;
@ -61,8 +53,7 @@ import com.feedback.it_asset.repository.GccAssetDetailsRep;
import com.feedback.it_asset.repository.GccFeedbackDataRep;
import com.feedback.it_asset.repository.GccFeedbackRep;
import com.feedback.it_asset.repository.GccFileDataRep;
import com.feedback.it_asset.service.AssetDetailsService;
import com.google.zxing.WriterException;
import com.feedback.it_asset.service.GccAssetService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
@ -89,149 +80,25 @@ public class APIController {
@Autowired
private GccFeedbackDataRep gccFeedbackDataRep;
@Autowired
private AssetDetailsService assetDetailsService;
public APIController(AssetDetailsService assetDetailsService) {
this.assetDetailsService = assetDetailsService;
}
@GetMapping("/migrateData")
public String migrateData() {
try {
// Invoke the migrateData method from YourServiceClass
assetDetailsService.migrateData();
return "Data migration completed successfully.";
} catch (Exception e) {
e.printStackTrace();
return "Error during data migration: " + e.getMessage();
}
}
private GccAssetService gccAssetService;
@GetMapping("/dashboard-summary")
public ResponseEntity<Map<String, Object>> getDashboardSummary() {
Long totalAssets = gccAssetDetailsRep.countActiveAssets();
Long totalAssets = gccAssetDetailsRep.count();
Long totalcomplaint = gccFeedbackRep.count();
Integer totalYesFeedbacks = gccFeedbackDataRep.onlyYesCount();
Integer closedcomp = gccFeedbackDataRep.onlyYesCount();
Integer totalNoFeedbacks = gccFeedbackDataRep.onlyNoCount();
System.out.println("..................."+totalAssets);
Map<String, Object> summary = new HashMap<>();
summary.put("totalAssets", totalAssets);
summary.put("totalFeedbacks", totalcomplaint);
summary.put("totalYesFeedbacks", totalYesFeedbacks);
summary.put("totalYesFeedbacks", closedcomp);
summary.put("totalNoFeedbacks", totalNoFeedbacks);
return ResponseEntity.ok(summary);
}
@GetMapping("/gccAssetList")
public ResponseEntity<List<GccAssetDetailsDto>> viewAssetList() throws IOException, WriterException, SQLException {
List<GccAssetDetails> assetDetailsList = gccAssetDetailsRep.showAll();
List<GccAssetDetailsDto> assetDetailsDtoList = new ArrayList<>();
for (GccAssetDetails assetDetails : assetDetailsList) {
GccAssetDetailsDto assetDetailsDto = new GccAssetDetailsDto();
// Copy the properties from the entity to the DTO
BeanUtils.copyProperties(assetDetails, assetDetailsDto);
// Set the extra field
assetDetailsDto.setQrcodeimg(QRCodeGenerator.generateQRCode(appConfig.getQrcodeUrl() + "/" + assetDetails.getAssetCode()));
List<GccFileData> fileDataList = gccFileDataRep.showFileDataByAssetId(assetDetails.getAssetId());
for (GccFileData fileData : fileDataList) {
Blob imageBlob = fileData.getData();
byte[] imageBytes = imageBlob.getBytes(1, (int) imageBlob.length());
assetDetailsDto.setAssetimg(Base64.getEncoder().encodeToString(imageBytes));
}
assetDetailsDtoList.add(assetDetailsDto);
}
// You can customize the response status and body accordingly
return ResponseEntity.ok(assetDetailsDtoList);
}
@PostMapping("/saveAssets")
public ResponseEntity<String> saveAsset(
@RequestParam("asset_latitude") String assetLatitude,
@RequestParam("asset_longitude") String assetLongitude,
@RequestParam("asset_name") String assetName,
// @RequestParam("asset_code") String assetCode,
@RequestParam("cat_id") int catId,
@RequestParam("department_name") String departmentName,
@RequestParam("position") String position,
@RequestParam("assign_person") String person,
@RequestParam(name = "param_id[]") String[] paramId,
@RequestParam("assetFile") MultipartFile file) {
try {
AssetCategory assetCategory = assetCategoryRep.findById(catId).orElse(null);
if (assetCategory == null) {
// Handle the case where the AssetCategory with the specified catId is not found
return new ResponseEntity<>("Asset category not found", HttpStatus.NOT_FOUND);
}
// Construct your GccAssetDetails object using the retrieved AssetCategory
GccAssetDetails ad = new GccAssetDetails();
ad.setAssetLatitude(assetLatitude);
ad.setAssetLongitude(assetLongitude);
ad.setAssetName(assetName);
ad.setAssetCategory(assetCategory);
ad.setDepartmentName(departmentName);
ad.setPosition(position);
ad.setPerson(person);
// Your existing logic
String paramIdQuery = Arrays.toString(paramId);
// Adjust the existing logic based on your requirements
String assetCode = String.format("%s-%04d", ad.getAssetName(), ad.getAssetCategory().getcId());
System.out.println(assetCode);
Integer productId = gccAssetDetailsRep.insertAsset(
ad.getAssetLatitude(), ad.getAssetLongitude(), ad.getAssetName(),
assetCode, ad.getAssetCategory().getcId(), ad.getDepartmentName(), ad.getPosition(),
ad.getPerson(), paramIdQuery);
Integer lastInId = gccAssetDetailsRep.getLastInsertedId();
System.out.println("Last insert ID: " + lastInId);
GccAssetDetails gccAssetDetails = new GccAssetDetails();
gccAssetDetails.setAssetId(lastInId);
LocalDateTime cdate = LocalDateTime.now();
GccFileData fileData = new GccFileData();
fileData.setFileName(file.getOriginalFilename());
byte[] fileBytes = file.getBytes();
Blob fileBlob = new SerialBlob(fileBytes);
fileData.setData(fileBlob);
fileData.setGccAssetDetails(gccAssetDetails);
fileData.setcDate(cdate);
gccFileDataRep.save(fileData);
return new ResponseEntity<>("Asset saved successfully", HttpStatus.OK);
} catch (IOException | SQLException e) {
e.printStackTrace(); // Handle exceptions appropriately
return new ResponseEntity<>("Failed to save asset", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@PostMapping("/asset/update")
public ResponseEntity<String> updateAsset(
@RequestParam("assetId") Integer assetId,
@RequestParam("assetName") String assetName,
@RequestParam("departmentName") String departmentName,
@RequestParam("person") String person,
@RequestParam("position") String position) {
System.out.println(assetId + " --- ");
gccAssetDetailsRep.updateAsset(assetId, assetName, departmentName, person, position);
// You can customize the response status and body accordingly
return ResponseEntity.ok("Asset updated successfully");
}
@GetMapping("/category")
private List<AssetCategory> categoryList(){
return assetCategoryRep.showAll();
@ -286,42 +153,6 @@ public class APIController {
return assetParameterQuestionRep.deleteParameterQuestion(id);
}
@GetMapping("/gcc-asset-list")
public ResponseEntity<List<GccAssetDetailsDto>> viewAssetList1() {
try {
List<AssetCategory> assetCategoryList = assetCategoryRep.showAll();
List<GccAssetDetails> assetDetailsList = gccAssetDetailsRep.showAll();
List<GccAssetDetailsDto> assetDetailsDtoList = new ArrayList<>();
for (GccAssetDetails assetDetails : assetDetailsList) {
GccAssetDetailsDto assetDetailsDto = new GccAssetDetailsDto();
BeanUtils.copyProperties(assetDetails, assetDetailsDto);
try {
assetDetailsDto.setQrcodeimg(QRCodeGenerator.generateQRCode(appConfig.getQrcodeUrl() + "/" + assetDetails.getAssetCode()));
} catch (WriterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<GccFileData> fileDataList = gccFileDataRep.showFileDataByAssetId(assetDetails.getAssetId());
for (GccFileData fileData : fileDataList) {
Blob imageBlob = fileData.getData();
byte[] imageBytes = imageBlob.getBytes(1, (int) imageBlob.length());
assetDetailsDto.setAssetimg(Base64.getEncoder().encodeToString(imageBytes));
}
assetDetailsDtoList.add(assetDetailsDto);
}
return new ResponseEntity<>(assetDetailsDtoList, HttpStatus.OK);
} catch (IOException | SQLException e) {
e.printStackTrace(); // Handle exceptions appropriately
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@GetMapping("/asset")
private List<GccAssetDetails> assetDetailsList(){
return gccAssetDetailsRep.showAll();
@ -356,11 +187,6 @@ public class APIController {
return gccFeedbackRep.findAll();
}
@GetMapping(value = "/feedbackdata")
public List getFeedbackDataList() {
return gccFeedbackDataRep.findAll();
}
@GetMapping("/feedback/{id}")
private List feedbackWithAsset(@PathVariable("id") int id){
return gccFeedbackRep.findByFeedbackId(id);
@ -516,15 +342,6 @@ public class APIController {
return bodyMessage;
}
@GetMapping(value = "/closedfeedback")
public List getClosedFeedbackList() {
return gccFeedbackRep.findByfeedbackAllYes();
}
@GetMapping(value = "/pendingfeedback")
public List getPendingFeedbackList() {
return gccFeedbackRep.findByfeedbackAllNo();
}
@GetMapping(value = "/getComplaintCategoryById")
public String getComplaintCategoryById(@RequestParam String comGroupId) {
String urlString = appConfig.getErpUrl()+"serviceId=getComplCategory&ComplaintGroupId="+comGroupId;
@ -607,50 +424,32 @@ public class APIController {
}
return "Success";
}
// @GetMapping("/only-yes/count")
// public Integer onlyYesCount() {
// return gccFeedbackDataRep.onlyYesCount();
// }
// @GetMapping("/only-no/count")
// public Integer onlyNoCount() {
// return gccFeedbackDataRep.onlyNoCount();
// }
@GetMapping("/only-yes/counts")
public long[] onlyYesCounts() {
long count = gccFeedbackDataRep.countOnlyYesFeedback();
return new long[]{count};
}
@GetMapping("/only-no/count")
public long[] onlyNoCount() {
long count = gccFeedbackDataRep.onlyNoCount();
return new long[]{count};
}
// @GetMapping("/feedback/counts/{cdate}")
// public long[] getFeedbackCountsByMonth(@PathVariable String cdate) {
// long onlyYesCount = gccFeedbackDataRep.countOnlyYesFeedbackByMonth(cdate);
// long onlyNoCount = gccFeedbackDataRep.countOnlyNoFeedbackByMonth(cdate);
//
// return new long[]{onlyYesCount, onlyNoCount};
// }
@GetMapping("/cou")
public ResponseEntity<List<Map<String, Object>>> getFeedbackAnalysis() {
List<GccFeedbackData> feedbackDataList = gccFeedbackDataRep.findAll();
Map<Object, Map<Object, Long>> result = feedbackDataList.stream()
.filter(feedback -> feedback.getFeedbackAns() != null && feedback.getcDate() != null)
.map(feedback -> new AbstractMap.SimpleEntry<>(feedback.getFeedbackAns(), getMonth(feedback.getcDate())))
.collect(Collectors.groupingBy(
AbstractMap.SimpleEntry::getKey,
Collectors.groupingBy(
AbstractMap.SimpleEntry::getValue,
Collectors.counting()
)
));
// Convert the result to the desired output format
List<Map<String, Object>> output = result.entrySet().stream()
.map(entry -> {
List<Long> counts = Arrays.asList(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
entry.getValue().forEach((month, count) -> counts.set(Integer.parseInt((String) month) - 1, count));
Map<String, Object> outputEntry = new HashMap<>();
outputEntry.put((String) entry.getKey(), counts);
return outputEntry;
})
.collect(Collectors.toList());
System.out.println("................neeed"+output);
return ResponseEntity.ok(output);
}
private static String getMonth(String date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Calendar cal = Calendar.getInstance();
cal.setTime(dateFormat.parse(date));
return String.valueOf(cal.get(Calendar.MONTH) + 1); // Adding 1 because Calendar.MONTH is zero-based
} catch (Exception e) {
e.printStackTrace();
return date;
}
}
}
/*
@GetMapping(value = "/gcc-login")
public String publicLogin(HttpServletRequest request, @RequestParam String ptax, @RequestParam String uname, @RequestParam String upass) {
@ -710,5 +509,125 @@ public class APIController {
// https://erp.chennaicorporation.gov.in/egproftax/external/collectionservice?channelID=3&serviceId=GetDcb&ZONE=10&DIV_CD=134&CATEGORY_CODE=PE&UNIQUE_ID=07885
// @GetMapping("/by-date")
// public ResponseEntity<List<GccFeedback>> getFeedbackByDate(
// @RequestParam("startDate") String startDate,
// @RequestParam("endDate") String endDate) {
//
// List<GccFeedback> feedbackList = gccFeedbackRep.feedbackTotalByDate(startDate, endDate);
//
// return new ResponseEntity<>(feedbackList, HttpStatus.OK);
// }
// @GetMapping("/by-date")
// public List<GccFeedbackData> getFeedbackByDate(@RequestParam("cdate") String cdate) {
// return gccFeedbackDataRep.feedbackByDate(cdate);
// }
// @GetMapping("/byDate/{cDate}")
// public List getFeedbackByDate(@PathVariable String cDate) {
// return gccFeedbackDataRep.getFeedbackByDate(cDate);
// }
@GetMapping("/allFeedback")
public List getAllFeedback() {
return gccFeedbackDataRep.findAllFeedback();
}
@GetMapping("/all")
public List<GccFeedbackData> getAllGccFeedbackData() {
return gccFeedbackDataRep.showAll();
}
@GetMapping("/count/{cDate}")
public long countFeedbackByDate(@PathVariable String cDate) {
return gccFeedbackDataRep.countFeedbackByDate(cDate);
}
@GetMapping("/list/{cDate}")
public List<GccFeedbackData> getFeedbackListByDate(@PathVariable String cDate) {
try (Stream<GccFeedbackData> feedbackStream = gccFeedbackDataRep.findFeedbackByDate(cDate)) {
return feedbackStream.collect(Collectors.toList());
}}
@GetMapping("/counts/{cdate}")
public ResponseEntity<?> countFeedbackByMonth(@PathVariable String cdate,Model model) {
String substring = cdate.substring(0, 7);
model.addAttribute("cdate", substring);
// model.addAttribute("cdate", yes);
System.out.println(substring);
List<GccFeedbackData> countFeedbackByMonth = gccFeedbackDataRep.countFeedbackByMonth(substring);
Map<String, Long> collect = countFeedbackByMonth.stream().collect(Collectors.groupingBy(GccFeedbackData::getFeedbackAns,Collectors.counting()));
Long closedcomp = collect.getOrDefault("[yes]",0L);
Long pendingcomp = collect.getOrDefault("[no]",0L);
System.out.println(closedcomp);
HashMap<String, Long> map=new HashMap<>();
map.put("yes", closedcomp);
map.put("no", pendingcomp);
map.put("total", pendingcomp+closedcomp);
// countFeedbackByMonth.stream()
// .collect(Collectors.groupingBy(
// entry -> ,
// Collectors.groupingBy(DataEntry::getYesNo, Collectors.counting())
// ));
// Do something with feedbackDataList if needed
return ResponseEntity.ok(map);
}
// @GetMapping("/lists/{cDate}")
// public List getFeedbackListByMonth(@PathVariable String cDate) {
// try (List<GccFeedbackData> feedbackStream = gccFeedbackDataRep.findFeedbackByMonth(cDate)) {
// return feedbackStream.collect(Collectors.toList());
// }
//
@GetMapping("/cou/{cdate}")
public ResponseEntity<List<Map<String, Object>>> getFeedbackAnalysis() {
List<GccFeedbackData> feedbackDataList = gccFeedbackDataRep.findAll();
Map<Object, Map<Object, Long>> result = feedbackDataList.stream()
.filter(feedback -> feedback.getFeedbackAns() != null && feedback.getcDate() != null)
.map(feedback -> new AbstractMap.SimpleEntry<>(feedback.getFeedbackAns(), getMonth(feedback.getcDate())))
.collect(Collectors.groupingBy(
AbstractMap.SimpleEntry::getKey,
Collectors.groupingBy(
AbstractMap.SimpleEntry::getValue,
Collectors.counting()
)
));
// Convert the result to the desired output format
List<Map<String, Object>> output = result.entrySet().stream()
.map(entry -> {
List<Long> counts = Arrays.asList(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
entry.getValue().forEach((month, count) -> counts.set(Integer.parseInt((String) month) - 1, count));
Map<String, Object> outputEntry = new HashMap<>();
outputEntry.put((String) entry.getKey(), counts);
return outputEntry;
})
.collect(Collectors.toList());
System.out.println("................neeed"+output);
return ResponseEntity.ok(output);
}
private static String getMonth(String date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Calendar cal = Calendar.getInstance();
cal.setTime(dateFormat.parse(date));
return String.valueOf(cal.get(Calendar.MONTH) + 1); // Adding 1 because Calendar.MONTH is zero-based
} catch (Exception e) {
e.printStackTrace();
return date;
}
}
private static List<GccFeedbackData> getFeedbackData() {
return Arrays.asList(
new GccFeedbackData("[yes]", "2023-11-09 16:26:01"),
new GccFeedbackData("[no]", "2023-11-09 16:28:11")
// Add more data as needed
);
}
}

2
src/main/java/com/feedback/it_asset/controller/AssetController.java

@ -66,7 +66,7 @@ public class AssetController {
assetDetailsDto.setQrcodeimg(QRCodeGenerator.generateQRCode(appConfig.getQrcodeUrl()+"/"+assetDetails.getAssetCode()));
List<GccFileData> fileDataList = gccFileDataRep.showFileDataByAssetId(assetDetails.getAssetId());
for (GccFileData fileData : fileDataList) {
System.out.println(fileData.getFileName() + " Asset Photo");
System.out.println(fileData.getFileName());
Blob imageBlob = fileData.getData();
byte[] imageBytes = imageBlob.getBytes(1, (int) imageBlob.length());
assetDetailsDto.setAssetimg(Base64.getEncoder().encodeToString(imageBytes));

58
src/main/java/com/feedback/it_asset/controller/FeedbackController.java

@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.feedback.it_asset.AppConfig;
import com.feedback.it_asset.entity.AssetCategory;
import com.feedback.it_asset.entity.AssetCategoryQuestions;
import com.feedback.it_asset.entity.AssetParameterQuestions;
import com.feedback.it_asset.entity.GccAssetDetails;
@ -55,70 +54,34 @@ public class FeedbackController {
}
*/
}
// @GetMapping("/gcc-complaint/{qrcode}")
// public String viewPublicFeedbackForm(Model model, @PathVariable String qrcode) {
// String assetId = gccAssetDetailsRep.findByAssetCode(qrcode);
// Integer assetid = 0;
// if (assetId != null) {
// assetid = Integer.valueOf(assetId);
// }
//
// List<GccAssetDetails> assetDetailsList = gccAssetDetailsRep.findByAssetId(assetid);
// List<Integer> paramDbVal = new ArrayList<>();
// for (GccAssetDetails ad : assetDetailsList) {
// //Basic Asset Details
// model.addAttribute("assetId", ad.getAssetId());
// model.addAttribute("assetName", ad.getAssetName());
// /////////////////////
// List<AssetCategoryQuestions> assetCategoryQuestionList = assetCategoryQuestionsRep.findByCatId(ad.getAssetCategory().getcId());
// model.addAttribute("feedbackquestionlist", assetCategoryQuestionList);
// System.out.println(ad.getParamId());
// String paramDbStr = ad.getParamId().replaceAll("[\\[\\]\\s]", "");
// String[] paramIdStr = paramDbStr.split(",");
// for (String a : paramIdStr) {
// paramDbVal.add(Integer.parseInt(a));
// }
// List<AssetParameterQuestions> assetParameterQuestionList = assetParameterQuestionsRep.findByParameterId(paramDbVal);
// model.addAttribute("assetparameterquestionlist", assetParameterQuestionList);
// }
// model.addAttribute("title", "GCC Complaint Form");
// //model.addAttribute("baseurl", appConfig.getBaseUrl());
// return "gcc-complaint";
// }
@GetMapping("/gcc-complaint/{qrcode}")
public String viewPublicFeedbackForm(Model model, @PathVariable String qrcode) {
String assetId = gccAssetDetailsRep.findByAssetCode(qrcode);
Integer assetid = (assetId != null) ? Integer.valueOf(assetId) : null;
Integer assetid = 0;
if (assetId != null) {
assetid = Integer.valueOf(assetId);
}
List<GccAssetDetails> assetDetailsList = gccAssetDetailsRep.findByAssetId(assetid);
List<Integer> paramDbVal = new ArrayList<>();
for (GccAssetDetails ad : assetDetailsList) {
//Basic Asset Details
model.addAttribute("assetId", ad.getAssetId());
model.addAttribute("assetName", ad.getAssetName());
AssetCategory assetCategory = ad.getAssetCategory();
if (assetCategory != null) {
model.addAttribute("assetCategoryId", assetCategory.getcId());
List<AssetCategoryQuestions> assetCategoryQuestionList = assetCategoryQuestionsRep.findByCatId(assetCategory.getcId());
/////////////////////
List<AssetCategoryQuestions> assetCategoryQuestionList = assetCategoryQuestionsRep.findByCatId(ad.getAssetCategory().getcId());
model.addAttribute("feedbackquestionlist", assetCategoryQuestionList);
List<Integer> paramDbVal = new ArrayList<>();
if (ad.getParamId() != null) {
System.out.println(ad.getParamId());
String paramDbStr = ad.getParamId().replaceAll("[\\[\\]\\s]", "");
String[] paramIdStr = paramDbStr.split(",");
for (String a : paramIdStr) {
paramDbVal.add(Integer.parseInt(a));
}
}
List<AssetParameterQuestions> assetParameterQuestionList = assetParameterQuestionsRep.findByParameterId(paramDbVal);
model.addAttribute("assetparameterquestionlist", assetParameterQuestionList);
}
}
model.addAttribute("title", "GCC Complaint Form");
model.addAttribute("title", "GCC Compaint Form");
//model.addAttribute("baseurl", appConfig.getBaseUrl());
return "gcc-complaint";
}
@ -156,7 +119,6 @@ public class FeedbackController {
if (!filteredValues.isEmpty()) {
System.out.println("Field " + key + " has values: " + filteredValues);
String feedback = filteredValues.toString().trim();
System.out.println(feedback + "is the feedback value");
String[] parts = key.split("_");
if (parts.length == 2) {
Integer cmqid = null, apqid = null, aqid = null;

63
src/main/java/com/feedback/it_asset/controller/MainController.java

@ -1,28 +1,29 @@
package com.feedback.it_asset.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.feedback.it_asset.AppConfig;
import com.feedback.it_asset.UserSession;
import com.feedback.it_asset.entity.AssetCategory;
import com.feedback.it_asset.entity.AssetCategoryQuestions;
import com.feedback.it_asset.entity.AssetParameter;
import com.feedback.it_asset.entity.AssetParameterQuestions;
import com.feedback.it_asset.entity.GccAssetDetails;
import com.feedback.it_asset.entity.GccFeedback;
import com.feedback.it_asset.entity.User;
import com.feedback.it_asset.entity.GccFeedbackData;
import com.feedback.it_asset.repository.AssetCategoryQuestionsRep;
import com.feedback.it_asset.repository.AssetCategoryRep;
import com.feedback.it_asset.repository.AssetParameterQuestionsRep;
@ -30,7 +31,6 @@ import com.feedback.it_asset.repository.AssetParameterRep;
import com.feedback.it_asset.repository.GccAssetDetailsRep;
import com.feedback.it_asset.repository.GccFeedbackDataRep;
import com.feedback.it_asset.repository.GccFeedbackRep;
import com.feedback.it_asset.repository.UserRepository;
import com.feedback.it_asset.service.GccAssetService;
@Controller
@ -52,13 +52,8 @@ public class MainController {
@Autowired
private GccFeedbackDataRep gccFeedbackDataRep;
@Autowired
private UserRepository userRepository;
@Autowired
private UserSession userSession;
@Autowired
private GccAssetService gccAssetService;
@RequestMapping("/")
public String viewLogin(Model model){
model.addAttribute("title","Dashboard");
@ -67,23 +62,40 @@ public class MainController {
return "login";
}
@PostMapping("/login")
public String login(Model model,@RequestParam String username,@RequestParam String password) {
System.out.println(username +" "+password);
Optional<User> usr =userRepository.checkUser(username,password);
// Userlogin usrlog = new Userlogin();
if(usr.isPresent()) {
userSession.setUserType(usr.get().getUsername());
userSession.setUserId(1);
return "redirect:/report";
@GetMapping("/pendingchart.html")
public String showPendingChart() {
// Your logic here
return "pendingchart"; // Assuming "pendingchart" is the Thymeleaf template name
}
return "login";
@GetMapping("/closedchart.html")
public String showClosedChart() {
// Your logic here
return "closedchart"; // Assuming "closedchart" is the Thymeleaf template name
}
@GetMapping("/totalchart.html")
public String showTotalChart() {
// Your logic here
return "totalchart"; // Assuming "closedchart" is the Thymeleaf template name
}
// @RestController
// @RequestMapping("/api/feedback")
// public class GccFeedbackController {
//
// @Autowired
// private GccFeedbackRep gccFeedbackRep;
//
// @GetMapping("/all")
// public List<GccFeedbackData> getAllFeedbackData() {
// return GccFeedbackRep.showAll();
// }
// }
@RequestMapping("/dashboard")
public String viewHomePage(Model model){
List<Map<String, Object>> feedbackAnalysis = gccAssetService.getFeedbackAnalysis();
@ -91,9 +103,11 @@ public class MainController {
// model.addAttribute("closedValues", closedValues);
// model.addAttribute("pendingValues", pendingValues);
// model.addAttribute("totalValues", totalValues);
model.addAttribute("dashboard", feedbackAnalysis);
model.addAttribute("title","Dashboard");
model.addAttribute("totalAssets",gccAssetDetailsRep.countActiveAssets());
model.addAttribute("totalAssets",gccAssetDetailsRep.count());
model.addAttribute("totalFeedbacks",gccFeedbackRep.count());
model.addAttribute("totalYesFeedbacks",gccFeedbackDataRep.onlyYesCount());
model.addAttribute("totalNoFeedbacks",gccFeedbackDataRep.onlyNoCount());
@ -257,14 +271,14 @@ public class MainController {
public String viewPositiveFeedbackList(Model model){
List<GccFeedback> gccFeedbackList = gccFeedbackRep.findByfeedbackAllYes();
model.addAttribute("feedbacklist",gccFeedbackList);
model.addAttribute("title","Asset - GCC Closed Complaint List");
model.addAttribute("title","Asset - GCC Closed Complaint ");
return "closed-complaint";
}
@GetMapping("/pending-complaint")
public String viewNegativeFeedbackList(Model model){
List<GccFeedback> gccFeedbackList = gccFeedbackRep.findByfeedbackAllNo();
model.addAttribute("feedbacklist",gccFeedbackList);
model.addAttribute("title","Asset - GCC Pending Complaint List");
model.addAttribute("title","Asset -GCC Pending Complaint");
return "pending-complaint";
}
@GetMapping("/gcc-services-water")
@ -322,4 +336,5 @@ public class MainController {
return "redirect:/login";
}
}

18
src/main/java/com/feedback/it_asset/dto/FeedbackCountResponse.java

@ -0,0 +1,18 @@
package com.feedback.it_asset.dto;
public class FeedbackCountResponse {
private long[] counts;
public long[] getCounts() {
return counts;
}
public void setCounts(long[] counts) {
this.counts = counts;
}
}

6
src/main/java/com/feedback/it_asset/dto/ItAssetDashboardDto.java

@ -0,0 +1,6 @@
package com.feedback.it_asset.dto;
public class ItAssetDashboardDto {
}

34
src/main/java/com/feedback/it_asset/dto/MonthWiseCountsDTO.java

@ -0,0 +1,34 @@
package com.feedback.it_asset.dto;
public class MonthWiseCountsDTO {
private long onlyYesCount;
private long onlyNoCount;
// Constructors, getters, setters, etc.
public MonthWiseCountsDTO() {
// default constructor
}
public MonthWiseCountsDTO(long onlyYesCount, long onlyNoCount) {
this.onlyYesCount = onlyYesCount;
this.onlyNoCount = onlyNoCount;
}
public long getOnlyYesCount() {
return onlyYesCount;
}
public void setOnlyYesCount(long onlyYesCount) {
this.onlyYesCount = onlyYesCount;
}
public long getOnlyNoCount() {
return onlyNoCount;
}
public void setOnlyNoCount(long onlyNoCount) {
this.onlyNoCount = onlyNoCount;
}
}

4
src/main/java/com/feedback/it_asset/entity/AssetCategory.java

@ -15,9 +15,9 @@ import jakarta.persistence.Table;
public class AssetCategory {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "cat_id",nullable = true)
@Column(name = "cat_id",nullable = false)
private Integer cId;
@Column(name = "name",nullable = true)
@Column(name = "name",nullable = false)
private String catName;
@Column(name = "isdelete",nullable = false, columnDefinition = "Boolean default false")
private Boolean isDelete;

8
src/main/java/com/feedback/it_asset/entity/AssetCategoryQuestions.java

@ -16,17 +16,17 @@ import jakarta.persistence.Table;
public class AssetCategoryQuestions {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cmq_id", nullable = true)
@Column(name = "cmq_id", nullable = false)
private Integer cmqId;
@ManyToOne
@JoinColumn(name="cat_id", nullable = true)
@JoinColumn(name="cat_id", nullable = false)
private AssetCategory assetCategory;
@Column(name = "eng_question", nullable = true)
@Column(name = "eng_question", nullable = false)
private String engQuestion;
@Column(name = "tamil_question", nullable = true)
@Column(name = "tamil_question", nullable = false)
private String tamilQuestion;
@Column(name = "com_group_id", nullable = true)

10
src/main/java/com/feedback/it_asset/entity/GccAssetDetails.java

@ -70,6 +70,16 @@ public class GccAssetDetails {
this.assetId = assetId;
}
/*
public Integer getCatId() {
return catId;
}
public void setCatId(Integer catId) {
this.catId = catId;
}
*/
public AssetCategory getAssetCategory() {
return assetCategory;
}

4
src/main/java/com/feedback/it_asset/entity/GccFeedbackData.java

@ -41,6 +41,10 @@ public class GccFeedbackData {
public GccFeedbackData() {
}
public GccFeedbackData(String string, String string2) {
// TODO Auto-generated constructor stub
}
public Integer getFbdId() {

40
src/main/java/com/feedback/it_asset/entity/Role.java

@ -0,0 +1,40 @@
package com.feedback.it_asset.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler"})
@Table(name = "roles")
public class Role {
@Id
@Column(name = "role_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
public Integer getId() {
return id;
}
public Role() {
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

134
src/main/java/com/feedback/it_asset/entity/User.java

@ -1,43 +1,133 @@
package com.feedback.it_asset.entity;
import java.util.HashSet;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.Table;
@Entity
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler"})
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String username;
private String password;
private String usertype;
public int getId() {
@Column(name = "user_id")
private Long id;
@Column(name = "first_name")
private String firstName;
@Column(name = "last_name")
private String lastName;
@Column(name = "display_name")
private String displayName;
@Column(name = "uname")
private String userameTxt;
@Column(name = "pword")
private String passwordTxt;
@Column(name = "isdelete",nullable = false, columnDefinition = "Boolean default false")
private Boolean isDelete;
@Column(name = "isactive",nullable = false, columnDefinition = "Boolean default true")
private Boolean isActive;
@Column(name = "cdate",nullable = false, columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP")
private String cDate;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(
name = "users_roles",
joinColumns = @JoinColumn(name = "user_id"),
inverseJoinColumns = @JoinColumn(name = "role_id")
)
private Set<Role> roles = new HashSet<>();
public User() {
}
public Long getId() {
return id;
}
public void setId(int id) {
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
public String getFirstName() {
return firstName;
}
public void setUsername(String username) {
this.username = username;
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getPassword() {
return password;
public String getLastName() {
return lastName;
}
public void setPassword(String password) {
this.password = password;
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getUsertype() {
return usertype;
public String getDisplayName() {
return displayName;
}
public void setUsertype(String usertype) {
this.usertype = usertype;
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getUserameTxt() {
return userameTxt;
}
public void setUserameTxt(String userameTxt) {
this.userameTxt = userameTxt;
}
public String getPasswordTxt() {
return passwordTxt;
}
public void setPasswordTxt(String passwordTxt) {
this.passwordTxt = passwordTxt;
}
public Boolean getDelete() {
return isDelete;
}
public void setDelete(Boolean delete) {
isDelete = delete;
}
public Boolean getActive() {
return isActive;
}
public void setActive(Boolean active) {
isActive = active;
}
public String getcDate() {
return cDate;
}
public void setcDate(String cDate) {
this.cDate = cDate;
}
public Set<Role> getRoles() {
return roles;
}
public void setRoles(Set<Role> roles) {
this.roles = roles;
}
}

57
src/main/java/com/feedback/it_asset/entity/UserRole.java

@ -0,0 +1,57 @@
package com.feedback.it_asset.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
@Entity
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler"})
@Table(name = "users_roles")
public class UserRole {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "user_id", referencedColumnName = "user_id")
private User user;
@ManyToOne
@JoinColumn(name = "role_id", referencedColumnName = "role_id")
private Role role;
// constructor, getters, and setters
public UserRole() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
}

6
src/main/java/com/feedback/it_asset/repository/GccAssetDetailsRep.java

@ -17,8 +17,6 @@ import jakarta.transaction.Transactional;
public interface GccAssetDetailsRep extends JpaRepository<GccAssetDetails, Integer>{
@Query(value = "SELECT LAST_INSERT_ID()", nativeQuery = true)
Integer getLastInsertedId();
@Query(value = "SELECT COUNT(*) FROM `gcc_asset_details` WHERE `isdelete`=0",nativeQuery = true)
long countActiveAssets();
@Query(value = "SELECT * FROM `gcc_asset_details` WHERE `isdelete`=0",nativeQuery = true)
List<GccAssetDetails> showAll();
@Query(value = "SELECT * FROM `gcc_asset_details` WHERE `asset_id`=:assetId",nativeQuery = true)
@ -43,9 +41,5 @@ public interface GccAssetDetailsRep extends JpaRepository<GccAssetDetails, Integ
@Query(value ="UPDATE `gcc_asset_details` SET `asset_name`= :asset_name, `department_name`= :department_name,`assign_person`= :assign_person, `position`= :position WHERE `asset_id`=:assetid LIMIT 1", nativeQuery = true)
int updateAsset(@Param("assetid") int assetId,@Param("asset_name") String assetName,@Param("department_name") String departmentName,@Param("assign_person") String person,@Param("position") String position);
//test API
//@Query(value ="INSERT INTO `gcc_asset_details`(`asset_latitude`, `asset_longitude`, `asset_name`, `asset_code`, `cat_id`, `department_name`, `position`, `assign_person`, `param_id`) VALUES (:asset_latitude,:asset_longitude,:asset_name,:asset_code,:cat_id,:department_name,:position,:assign_person,:param_id)", nativeQuery = true)
// Integer insertAsset(@Param("asset_latitude") String assetLatitude, @Param("asset_longitude") String assetLongitude, @Param("asset_name") String assetName, @Param("asset_code") String assetCode, @Param("cat_id") int catId, @Param("department_name") String departmentName, @Param("position") String position, @Param("assign_person") String person, @Param("param_id") String paramId);
}

50
src/main/java/com/feedback/it_asset/repository/GccFeedbackDataRep.java

@ -1,6 +1,8 @@
package com.feedback.it_asset.repository;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
@ -40,6 +42,50 @@ public interface GccFeedbackDataRep extends JpaRepository<GccFeedbackData, Integ
" HAVING COUNT(*) = SUM(feedback = '[no]')\n" +
") AS subquery;",nativeQuery = true)
Integer onlyNoCount();
@Query(value = "SELECT COUNT(DISTINCT feedback_id) AS num_rows FROM gcc_feedback_data WHERE feedback IN ('[yes]', '[no]')", nativeQuery = true)
Integer yesAndNoCount();
// @Query(value = "SELECT feedback, cdate FROM `gcc_feedback_data` WHERE YEAR(`cdate`) = 2023", nativeQuery = true)
// List<GccFeedbackData> showAll1();
//
// @Query(value = "SELECT * FROM `gcc_feedback_data` WHERE `isdelete` = 0 AND `cdate` = :cdate", nativeQuery = true)
// List<GccFeedbackData> feedbackByDate(@Param("cdate") String cdate);
// @Query(value = "SELECT feedback, cdate FROM `gcc_feedback_data` WHERE `isdelete` = 0 AND `cdate` = :cDate", nativeQuery = true)
// List feedbackByDate(@Param("cDate") String cDate);
// @Query(value = "SELECT * FROM `gcc_feedback_data` WHERE `cdate` = :cdate", nativeQuery = true)
// List<GccFeedbackData> findByCDate(@Param("cdate") String cdate);
// List getFeedbackByDate(String cDate);
@Query(value = "SELECT feedback,cdate FROM gcc_feedback_data WHERE isdelete = 0", nativeQuery = true)
List findAllFeedback();
@Query(value = "SELECT feedback, cdate FROM `gcc_feedback_data` WHERE `isdelete` = 0 AND YEAR(`cdate`) = YEAR(:cdate) AND MONTH(`cdate`) = MONTH(:cdate)", nativeQuery = true)
Stream<Map<String, Object>> feedbackByMonthStream(@Param("cdate") String cdate);
@Query(value = "SELECT COUNT(*) FROM `gcc_feedback_data` WHERE `isdelete` = 0 AND `cdate` = :cDate", nativeQuery = true)
long countFeedbackByDate(@Param("cDate") String cDate);
@Query(value = "SELECT feedback, cdate FROM `gcc_feedback_data` WHERE `isdelete` = 0 AND `cdate` = :cDate", nativeQuery = true)
Stream<GccFeedbackData> findFeedbackByDate(@Param("cDate") String cDate);
@Query(value = "SELECT * FROM `gcc_feedback_data` WHERE cdate LIKE :substring%", nativeQuery = true)
List<GccFeedbackData> countFeedbackByMonth( @Param("substring") String substring);
@Query(value = "SELECT * FROM `gcc_feedback_data` WHERE `isdelete` = 0 AND MONTH(`cdate`) = MONTH(:cDate) AND YEAR(`cdate`) = YEAR(:cDate)", nativeQuery = true)
List<GccFeedbackData> findFeedbackByMonth(@Param("cDate") String cDate);
// @Query(value = "SELECT COUNT(*) FROM `gcc_feedback_data` WHERE MONTH(`cdate`) = MONTH(:cDate) AND feedback = '[yes]'", nativeQuery = true)
// long countOnlyYesFeedbackByMonth(String cdate);
//
// @Query(value = "SELECT COUNT(*) FROM `gcc_feedback_data` WHERE MONTH(`cdate`) = MONTH(:cDate) AND feedback = '[no]'", nativeQuery = true)
// long countOnlyNoFeedbackByMonth(@Param("cDate") String cDate);
@Query(value = "SELECT COUNT(*) FROM `gcc_feedback_data` WHERE feedback = '[yes]'", nativeQuery = true)
long countOnlyYesFeedback();
}

13
src/main/java/com/feedback/it_asset/repository/GccFeedbackRep.java

@ -9,6 +9,7 @@ import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.feedback.it_asset.entity.GccFeedback;
import com.feedback.it_asset.entity.GccFeedbackData;
import jakarta.transaction.Transactional;
@Repository
@ -56,4 +57,16 @@ public interface GccFeedbackRep extends JpaRepository<GccFeedback, Integer>{
" HAVING COUNT(*) = SUM(feedback = :option)\n" +
");",nativeQuery = true)
List<GccFeedback> feedbackTotalByOptionDate(@Param("option") String option,@Param("startDate") String startDate, @Param("endDate") String endDate);
static List<GccFeedbackData> showAll() {
// TODO Auto-generated method stub
return null;
}
// @Query(value = "SELECT feedback,cdate FROM `gcc_feedback_data` WHERE `isdelete` = 0 AND `cdate` = :cdate", nativeQuery = true)
// List<GccFeedbackData> feedbackByDate(@Param("cdate") String cdate);
// List<GccFeedback> feedbackByDate(String cdate);
}

12
src/main/java/com/feedback/it_asset/repository/UserRepository.java

@ -1,6 +1,6 @@
package com.feedback.it_asset.repository;
import java.util.Optional;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
@ -8,10 +8,10 @@ import org.springframework.stereotype.Repository;
import com.feedback.it_asset.entity.User;
import jakarta.transaction.Transactional;
@Repository
public interface UserRepository extends JpaRepository<User, Integer>{
@Query(value = "SELECT * FROM user WHERE `username`=:username and `password`=:password",nativeQuery = true)
Optional<User> checkUser(String username, String password);
@Transactional
public interface UserRepository extends JpaRepository<User, Long>{
@Query(value = "SELECT * FROM `users` WHERE 1", nativeQuery = true)
List<User> showAll();
}

78
src/main/java/com/feedback/it_asset/service/AssetDetailsService.java

@ -1,78 +0,0 @@
package com.feedback.it_asset.service;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.springframework.stereotype.Service;
@Service
public class AssetDetailsService {
private static final String SOURCE_JDBC_URL = "jdbc:mysql://localhost:3306/gcc_asset_details";
private static final String DESTINATION_JDBC_URL = "jdbc:mysql://localhost:3306/it_assets";
private static final String SOURCE_USERNAME = "root";
private static final String SOURCE_PASSWORD = "root";
private static final String DESTINATION_USERNAME = "root";
private static final String DESTINATION_PASSWORD = "root";
public void migrateData() {
try {
// Load the JDBC driver
Class.forName("com.mysql.cj.jdbc.Driver");
// Establish connections for source and destination databases
try (
Connection sourceConnection = DriverManager.getConnection(SOURCE_JDBC_URL, SOURCE_USERNAME, SOURCE_PASSWORD);
Connection destinationConnection = DriverManager.getConnection(DESTINATION_JDBC_URL, DESTINATION_USERNAME, DESTINATION_PASSWORD)
) {
// SQL query to fetch data from the source schema
String sqlQuery = "SELECT ta.ASSET_ID, ta.ASSET_NO, td.DEPT_NAME, tl.LOC_NAME, tsu.SEC_USER_NAME " +
"FROM tbl_asset ta " +
"JOIN tbl_mas_dept td ON ta.DEPT_ID = td.DEPT_ID " +
"JOIN tbl_mas_loc tl ON ta.LOC_ID = tl.LOC_ID " +
"JOIN tbl_mas_sec_user tsu ON ta.SECUSER_ID = tsu.SEC_USER_ID ";
// Create a prepared statement for the source database
try (PreparedStatement preparedStatementSource = sourceConnection.prepareStatement(sqlQuery)) {
// Execute the query in the source database
try (var resultSet = preparedStatementSource.executeQuery()) {
// SQL query to insert data into the destination schema for asset_data
String insertAssetDataQuery = "INSERT INTO gcc_asset_details (asset_id, asset_code, department_name, position, assign_person) VALUES (?, ?, ?, ?, ?)";
// SQL query to insert data into the destination schema for asset_category
// String insertAssetCategoryQuery = "INSERT INTO asset_category (category_name) VALUES (?)";
// Create prepared statements for the destination database
try (PreparedStatement preparedStatementDestinationAssetData = destinationConnection.prepareStatement(insertAssetDataQuery)) {
// Process the result set and insert data into the destination schema
while (resultSet.next()) {
// Insert data into asset_data table
preparedStatementDestinationAssetData.setString(1, resultSet.getString("ASSET_ID"));
preparedStatementDestinationAssetData.setString(2, resultSet.getString("ASSET_NO"));
preparedStatementDestinationAssetData.setString(3, resultSet.getString("DEPT_NAME"));
preparedStatementDestinationAssetData.setString(4, resultSet.getString("LOC_NAME"));
preparedStatementDestinationAssetData.setString(5, resultSet.getString("SEC_USER_NAME"));
int rowsAffectedAssetData = preparedStatementDestinationAssetData.executeUpdate();
System.out.println("Rows affected for asset_data: " + rowsAffectedAssetData);
// Insert data into asset_category table
// preparedStatementDestinationAssetCategory.setString(1, resultSet.getString("category_name"));
// int rowsAffectedAssetCategory = preparedStatementDestinationAssetCategory.executeUpdate();
// System.out.println("Rows affected for asset_category: " + rowsAffectedAssetCategory);
}
}
}
}
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace(); // Handle the exception appropriately
}
}
}

55
src/main/java/com/feedback/it_asset/service/GccAssetService.java

@ -1,14 +1,18 @@
package com.feedback.it_asset.service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import com.feedback.it_asset.entity.GccFeedbackData;
@ -21,7 +25,6 @@ import jakarta.transaction.Transactional;
public class GccAssetService {
@Autowired
GccAssetDetailsRep gccAssetDetailsRep;
@Autowired
GccFeedbackDataRep gccFeedbackDataRep;
@ -33,36 +36,45 @@ public class GccAssetService {
gccAssetDetailsRep.deleteByAssetId(assetId);
}
// Change the format of the output in getFeedbackAnalysis method
// public List<Object[]> getFeedbackByDate(String cDate) {
// return gccFeedbackDataRep.getFeedbackByDate(cDate);
// }
public List<Map<String, Object>> getFeedbackAnalysis() {
List<GccFeedbackData> feedbackDataList = gccFeedbackDataRep.findAll();
List<Map<String, Object>> output = feedbackDataList.stream()
Map<Object, Map<Object, Long>> result = feedbackDataList.stream()
.filter(feedback -> feedback.getFeedbackAns() != null && feedback.getcDate() != null)
.map(feedback -> {
Map<String, Object> entry = new HashMap<>();
entry.put("label", feedback.getFeedbackAns());
entry.put("data", Arrays.asList(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L));
entry.put("month", getMonth(feedback.getcDate()));
return entry;
.map(feedback -> new AbstractMap.SimpleEntry<>(feedback.getFeedbackAns(), getMonth(feedback.getcDate())))
.collect(Collectors.groupingBy(
AbstractMap.SimpleEntry::getKey,
Collectors.groupingBy(
AbstractMap.SimpleEntry::getValue,
Collectors.counting()
)
));
// Convert the result to the desired output format
List<Map<String, Object>> output = result.entrySet().stream()
.map(entry -> {
List<Long> counts = Arrays.asList(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L);
entry.getValue().forEach((month, count) -> counts.set(Integer.parseInt((String) month) - 1, count));
Map<String, Object> outputEntry = new HashMap<>();
outputEntry.put((String) entry.getKey(), counts);
return outputEntry;
})
.collect(Collectors.toList());
for (Map<String, Object> entry : output) {
int monthIndex = Integer.parseInt((String) entry.get("month")) - 1;
@SuppressWarnings("unchecked")
List<Long> counts = (List<Long>) entry.get("data");
counts.set(monthIndex, counts.get(monthIndex) + 1);
}
System.out.println("................neeed"+output);
return output;
}
// Simplify the getMonth method
private static String getMonth(String date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
return new SimpleDateFormat("MM").format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(date));
} catch (ParseException e) {
Calendar cal = Calendar.getInstance();
cal.setTime(dateFormat.parse(date));
return String.valueOf(cal.get(Calendar.MONTH) + 1); // Adding 1 because Calendar.MONTH is zero-based
} catch (Exception e) {
e.printStackTrace();
return date;
}
@ -70,4 +82,5 @@ public class GccAssetService {
}

3
src/main/resources/application.properties

@ -1,7 +1,8 @@
spring.datasource.url=jdbc:mysql://localhost:3306/it_assets
spring.datasource.url=jdbc:mysql://localhost:3306/it_asset
spring.datasource.username=root
spring.datasource.password=Sha619!@
#spring.datasource.password=gccroot
app.title=GREATER CHENNAI CORPORATION

452
src/main/resources/templates/closedchart.html

@ -0,0 +1,452 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/head :: head"></head>
<body>
<!-- Page Container -->
<div id="page-container" class="sidebar-o sidebar-dark enable-page-overlay side-scroll page-header-fixed page-header-dark">
<!-- Side Overlay aside (right)-->
<aside th:replace="fragments/aside-right :: aside"></aside>
<!-- END Side Overlay (right)-->
<!-- Sidebar Nav-->
<nav th:replace="fragments/nav :: nav"></nav>
<!-- END Sidebar -->
<!-- Header -->
<header th:replace="fragments/header :: header"></header>
<!-- END Header -->
<!-- Main Container -->
<main id="main-container">
<!-- Hero -->
<div class="">
<div class="content content-full">
<div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
<h3 class="flex-grow-1 fs-5 fw-semibold my-2 my-sm-3">Welcome</h3>
<nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item active" aria-current="page">Dashboard</li>
</ol>
</nav>
</div>
</div>
</div>
<!-- END Hero -->
<!-- Page Content -->
<div class="content">
<!-- Overview -->
<div class="row items-push">
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-qrcode fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalAssets}">000</div>
<div class="text-muted mb-1 fs-5">Total Asset</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/gcc-asset-list">
View all Assets
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-comments fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-info" th:utext="${totalFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/complaint-list">
View all Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-up fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalYesFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total closed Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/closed-complaint">
View all Closed Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-down fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-warning" th:utext="${totalNoFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Pending Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/pending-complaint">
View all Pending Complaint
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
</div>
<!-- END Overview -->
<!-- Store Growth -->
<div class="row">
<div class="col-12 col-md-6 col-xl-6">
<div class="p-md-2 p-lg-3 w-100" style="height: 400px;">
<!-- Chart 1 Container -->
<canvas id="myChart1"></canvas>
</div>
</div>
<div class="col-12 col-md-6 col-xl-6">
<div class="p-md-2 p-lg-3 w-100" style="height: 500px;">
<!-- Chart 2 Container -->
<canvas id="myChart"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END Store Growth -->
<!-- Latest Orders + Stats -->
<!-- END Latest Orders + Stats -->
</div>
<!-- END Page Content -->
</main>
<!-- END Main Container -->
<!-- Footer -->
<footer th:replace="fragments/footer :: footer"></footer>
<!-- END Footer -->
</div>
<!-- END Page Container -->
<!-- Scripts -->
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<!-- Your existing script tag follows -->
<script th:replace="fragments/script :: script"></script>
<!-- Page JS Plugins -->
<script src="assets/js/plugins/chart.js/chart.umd.js"></script>
<!-- Include Date Range Picker -->
<script type="text/javascript" src="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.css" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
var dash = {};
function convert() {
// Ensure proper initialization logic for feedbackAnalysisData
dash.feedbackAnalysisData = /*[[${dashboard}]]*/ {};
}
convert();
var pageDashboard = {
chartBars: undefined,
chartLinesBarsData: {
datasets: [
{ data: [] }, // Assuming totalYesFeedbacks is an array
{ data: [] },
{data:[] } // Assuming totalNoFeedbacks is an array
]
},
initChart: function (feedbackAnalysis) {
// Set Global Chart.js configuration
Chart.defaults.color = '#818d96';
Chart.defaults.scale.grid.color = 'transparent';
Chart.defaults.scale.grid.zeroLineColor = 'transparent';
Chart.defaults.scale.beginAtZero = true;
Chart.defaults.elements.line.borderWidth = 1;
Chart.defaults.plugins.legend.labels.boxWidth = 12;
// Get Chart Container
let chartBarsCon = document.getElementById('myChart');
var data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [
{
label: 'Pending Complaint',
data: [],
fill: true,
backgroundColor: '#e74c3c',
borderColor: 'transparent',
pointBackgroundColor: '#c2d7ab',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#c0392b',
pointHoverBorderColor: '#c2d7ab',
},
]
};
var options = {
responsive: true,
scales: {
x: { beginAtZero: true },
y: { beginAtZero: true }
},
plugins: {
datalabels: {
anchor: 'end',
align: 'end',
color: 'black',
formatter: function (value, context) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
this.chartBars = new Chart(chartBarsCon, {
type: 'bar',
data: data,
options: options
});
},
updateChartLinesBarsData: function (newData) {
// Ensure the chart is initialized before updating
if (this.chartBars) {
// Assuming labels for the chart are ['Jan', 'Feb', 'Mar', ..., 'Dec']
var labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// Initialize arrays with values from dataArray
var totalFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalFeedbacksData[${index}]: ${dataArray[index]});
return sum + dataArray[index];
}, 0);
});
var totalYesFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalYesFeedbacksData[${index}]: ${dataArray[index]});
return dataArray[index];
}, 0);
});
// Subtract totalYesFeedbacksData from totalFeedbacksData
var totalNoFeedbacksData = totalFeedbacksData.map((value, index) => value - totalYesFeedbacksData[index]);
// Update the chart data
// this.chartBars.data.datasets[0].data = totalFeedbacksData;
this.chartBars.data.datasets[0].data = totalYesFeedbacksData;
//this.chartBars.data.datasets[0].data = totalNoFeedbacksData;
// Log the updated chart data
// console.log('Updated chart data (totalFeedbacksData):', this.chartBars.data.datasets[0].data);
//console.log('Updated chart data (totalYesFeedbacksData):', this.chartBars.data.datasets[1].data);
//console.log('Updated chart data (totalNoFeedbacksData):', this.chartBars.data.datasets[2].data);
// Update the chart
this.chartBars.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function (cdate) {
// Ensure convert() is called before accessing dash.feedbackAnalysisData
convert();
var self = this;
$.ajax({
url: 'api/cou/' + cdate,
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
self.updateChartLinesBarsData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function with the feedbackAnalysis data
pageDashboard.initChart(dash.feedbackAnalysisData || {});
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
pageDashboard.getAndPushData();
var pageDashboard = {
chartPie: undefined,
chartPieData: {
labels: ['Total Complaints', 'Closed Complaint', 'Pending Complaint'],
datasets: [
{
data: [],
backgroundColor: ['#3498db', '#e74c3c', '#cc6633'],
hoverBackgroundColor: ['#2980b9', '#c0392b', '#A35128']
}
]
},
initChart: function () {
// Get Chart Container
let chartPieCon = document.getElementById('myChart1');
var options = {
responsive: true,
plugins: {
datalabels: {
color: 'black',
formatter: function (value) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
this.chartPie = new Chart(chartPieCon, {
type: 'pie',
data: this.chartPieData,
options: options
});
// Add click event listener to the chart container
chartPieCon.onclick = function (event) {
var elements = pageDashboard.chartPie.getElementsAtEventForMode(event, 'point', pageDashboard.chartPie.options);
if (elements && elements.length > 0) {
var clickedIndex = elements[0].index;
console.log('Clicked Index:', clickedIndex);
console.log('Elements:', elements);
console.log('Labels:', pageDashboard.chartPieData.labels);
} else {
console.error('No elements found at the click event.');
}
if (clickedIndex >= 0 && clickedIndex < pageDashboard.chartPieData.labels.length) {
var clickedLabel = pageDashboard.chartPieData.labels[clickedIndex];
// Log the clicked label for debugging
console.log('Clicked Label:', clickedLabel);
// Navigate based on the clicked label
switch (clickedLabel) {
case 'Total Complaints':
console.log('Navigating to pendingchart.html');
window.location.href = 'pendingchart.html';
break;
case 'Pending Complaint':
console.log('Navigating to nofeedbacks.html');
window.location.href = 'closedchart.html';
break;
case 'Closed Complaint':
console.log('Navigating to yesfeedbacks.html');
window.location.href = 'totalchart.html';
break;
// Add more cases for other labels if needed
default:
console.log('No action defined for clicked label:', clickedLabel);
}
} else {
console.error('Invalid clicked index:', clickedIndex);
}
};
},
updateChartPieData: function (data) {
if (this.chartPie) {
var totalFeedbacks = data.totalFeedbacks || 0;
var totalYesFeedbacks = data.totalYesFeedbacks || 0;
var totalNoFeedbacks = data.totalNoFeedbacks || 0;
// Update the chart data
this.chartPieData.datasets[0].data = [totalFeedbacks, totalYesFeedbacks, totalNoFeedbacks];
// Update the chart
this.chartPie.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function () {
// Assume you have a function named 'convert'
convert();
var self = this;
// Fetch data from the actual API
$.ajax({
url: 'http://localhost:8071/api/dashboard-summary',
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
// Call the function to process the API response
self.updateChartPieData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function
pageDashboard.initChart();
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
</script>
</body>
</html>

298
src/main/resources/templates/dashboard.html

@ -159,7 +159,19 @@
<!-- Bars Chart Container -->
<!-- Chart.js Chart is initialized in js/pages/be_pages_dashboard.min.js which was auto compiled from _js/pages/be_pages_dashboard.js -->
<!-- For more info and examples you can check out http://www.chartjs.org/docs/ -->
<canvas id="myChart1" ></canvas>
</div>
</div>
<div class="col-md-7 col-xl-8 d-md-flex align-items-md-center">
<div class="p-md-2 p-lg-3 w-100" style="height: 450px;">
<!-- Bars Chart Container -->
<!-- Chart.js Chart is initialized in js/pages/be_pages_dashboard.min.js which was auto compiled from _js/pages/be_pages_dashboard.js -->
<!-- For more info and examples you can check out http://www.chartjs.org/docs/ -->
<a href="dashboard.html">
<canvas id="myChart" ></canvas>
</a>
</div>
</div>
</div>
@ -195,59 +207,37 @@
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
var dash = {};
function convert() {
// Ensure proper initialization logic for feedbackAnalysisData
dash.feedbackAnalysisData = /*[[${dashboard}]]*/ {};
}
convert();
var pageDashboard = {
chartBars: undefined,
chartLinesBarsData: {
datasets: [
{ data: [] }, // Assuming totalFeedbacks is an array
{ data: [] }, // Assuming totalYesFeedbacks is an array
{ data: [] },
{data:[] } // Assuming totalNoFeedbacks is an array
]
},
updateChartLinesBarsData: function (newData) {
// Ensure the chart is initialized before updating
if (this.chartBars) {
// Assuming labels for the chart are ['Jan', 'Feb', 'Mar', ..., 'Dec']
var labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// Convert single values to arrays with the same value for each label
var totalFeedbacksData = Array(labels).fill(newData.totalFeedbacks);
var totalYesFeedbacksData = Array(labels).fill(newData.totalYesFeedbacks);
var totalNoFeedbacksData = Array(labels).fill(newData.totalNoFeedbacks);
// Update the chart data
this.chartBars.data.datasets[0].data = totalFeedbacksData;
this.chartBars.data.datasets[1].data = totalYesFeedbacksData;
this.chartBars.data.datasets[2].data = totalNoFeedbacksData;
initChart: function (feedbackAnalysis) {
// Set Global Chart.js configuration
Chart.defaults.color = '#818d96';
Chart.defaults.scale.grid.color = 'transparent';
Chart.defaults.scale.grid.zeroLineColor = 'transparent';
Chart.defaults.scale.beginAtZero = true;
Chart.defaults.elements.line.borderWidth = 1;
Chart.defaults.plugins.legend.labels.boxWidth = 12;
// Update the chart
this.chartBars.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function () {
var self = this;
$.ajax({
url: 'api/dashboard-summary',
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
self.updateChartLinesBarsData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
$(document).ready(function () {
var ctx = document.getElementById('myChart').getContext('2d');
// Get Chart Container
let chartBarsCon = document.getElementById('myChart');
var data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
@ -285,54 +275,238 @@ $(document).ready(function () {
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: '#e9cb91',
},
]
};
var options = {
responsive: true,
scales: {
x: { beginAtZero: true },
y: { beginAtZero: true }
},
plugins: {
datalabels: {
anchor: 'end',
align: 'end',
color: 'black',
formatter: function (value, context) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
pageDashboard.chartBars = new Chart(ctx, {
this.chartBars = new Chart(chartBarsCon, {
type: 'bar',
data: data,
options: options
});
},
updateChartLinesBarsData: function (newData) {
// Ensure the chart is initialized before updating
if (this.chartBars) {
// Assuming labels for the chart are ['Jan', 'Feb', 'Mar', ..., 'Dec']
var labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// Initialize arrays with values from dataArray
var totalFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalFeedbacksData[${index}]: ${dataArray[index]});
return sum + dataArray[index];
}, 0);
});
var totalYesFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalYesFeedbacksData[${index}]: ${dataArray[index]});
return dataArray[index];
}, 0);
});
// Subtract totalYesFeedbacksData from totalFeedbacksData
var totalNoFeedbacksData = totalFeedbacksData.map((value, index) => value - totalYesFeedbacksData[index]);
// Update the chart data
this.chartBars.data.datasets[0].data = totalFeedbacksData;
this.chartBars.data.datasets[1].data = totalYesFeedbacksData;
this.chartBars.data.datasets[2].data = totalNoFeedbacksData;
// Fetch initial data and update the chart
// Log the updated chart data
// console.log('Updated chart data (totalFeedbacksData):', this.chartBars.data.datasets[0].data);
//console.log('Updated chart data (totalYesFeedbacksData):', this.chartBars.data.datasets[1].data);
//console.log('Updated chart data (totalNoFeedbacksData):', this.chartBars.data.datasets[2].data);
// Update the chart
this.chartBars.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function (cdate) {
// Ensure convert() is called before accessing dash.feedbackAnalysisData
convert();
var self = this;
$.ajax({
url: 'api/cou/' + cdate,
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
self.updateChartLinesBarsData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function with the feedbackAnalysis data
pageDashboard.initChart(dash.feedbackAnalysisData || {});
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
var pageDashboard = {
chartPie: undefined,
chartPieData: {
labels: ['Total Complaints', 'Closed Complaint', 'Pending Complaint'],
datasets: [
{
data: [],
backgroundColor: ['#3498db', '#e74c3c', '#cc6633'],
hoverBackgroundColor: ['#2980b9', '#c0392b', '#A35128']
}
]
},
initChart: function () {
// Get Chart Container
let chartPieCon = document.getElementById('myChart1');
var options = {
responsive: true,
plugins: {
datalabels: {
color: 'black',
formatter: function (value) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
this.chartPie = new Chart(chartPieCon, {
type: 'pie',
data: this.chartPieData,
options: options
});
$(function() {
// Add click event listener to the chart container
chartPieCon.onclick = function (event) {
var elements = pageDashboard.chartPie.getElementsAtEventForMode(event, 'point', pageDashboard.chartPie.options);
var start = moment().subtract(29, 'days');
var end = moment();
if (elements && elements.length > 0) {
var clickedIndex = elements[0].index;
console.log('Clicked Index:', clickedIndex);
console.log('Elements:', elements);
console.log('Labels:', pageDashboard.chartPieData.labels);
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
// Continue with the rest of your code...
} else {
console.error('No elements found at the click event.');
}
if (clickedIndex >= 0 && clickedIndex < pageDashboard.chartPieData.labels.length) {
var clickedLabel = pageDashboard.chartPieData.labels[clickedIndex];
// Log the clicked label for debugging
console.log('Clicked Label:', clickedLabel);
// Navigate based on the clicked label
switch (clickedLabel) {
case 'Total Complaints':
console.log('Navigating to pendingchart.html');
window.location.href = 'pendingchart.html';
break;
case 'Pending Complaint':
console.log('Navigating to nofeedbacks.html');
window.location.href = 'closedchart.html.html';
break;
case 'Closed Complaint':
console.log('Navigating to yesfeedbacks.html');
window.location.href = 'totalchart.html';
break;
// Add more cases for other labels if needed
default:
console.log('No action defined for clicked label:', clickedLabel);
}
} else {
console.error('Invalid clicked index:', clickedIndex);
}
};
},
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
updateChartPieData: function (data) {
if (this.chartPie) {
var totalFeedbacks = data.totalFeedbacks || 0;
var totalYesFeedbacks = data.totalYesFeedbacks || 0;
var totalNoFeedbacks = data.totalNoFeedbacks || 0;
// Update the chart data
this.chartPieData.datasets[0].data = [totalFeedbacks, totalYesFeedbacks, totalNoFeedbacks];
// Update the chart
this.chartPie.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
}, cb);
},
cb(start, end);
getAndPushData: function () {
// Assume you have a function named 'convert'
convert();
var self = this;
// Fetch data from the actual API
$.ajax({
url: 'http://localhost:8071/api/dashboard-summary',
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
// Call the function to process the API response
self.updateChartPieData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function
pageDashboard.initChart();
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
</script>
</body>
</html>

36
src/main/resources/templates/gcc-asset-list.html

@ -65,20 +65,18 @@
<tbody>
<tr th:each="assetlist, i : ${assetdetailslist}" class="${assetdetailslist}">
<td th:text="${i.count}">0</td>
<td class="text-center" th:text="${assetlist.assetCategory?.catName}"></td>
<td class="text-center" th:text="${assetlist.assetCategory.catName}"></td>
<td class="text-center" th:text="${assetlist.departmentName}"></td>
<td th:text="${assetlist.person}"></td>
<td th:text="${assetlist.assetId}"></td>
<td th:text="${assetlist.assetName}"></td>
<td th:text="${assetlist.position}"></td>
<td>
<a tabindex="0" class="text-danger" data-bs-toggle="popover" data-bs-trigger="focus" title="" th:attr="data-bs-content=${'&lt;img src=&quot;data:image/png;base64,' + assetlist.qrcodeimg + '&quot; width=&quot;100%&quot; /&gt;'}" data-bs-html="true" th:text="${assetlist.assetCode}" style="font-size:10px;cursor:pointer"></a>
</td>
<td th:if="${assetlist.isActive}"><span class="badge bg-success">Active</span></td>
<td th:unless="${assetlist.isActive}"><span class="badge bg-warning">InActive</span></td>
<td class="text-center">
<a th:onclick="views( [[${assetlist}]] );" data-bs-toggle="tooltip" data-bs-animation="true" data-bs-placement="top" title=""> <i class="fa fa-pen-to-square" id="showModalButton" style="font-size: 18px;"></i></a>
<a th:onclick="views( [[${assetlist}]] );" data-bs-toggle="tooltip" data-bs-animation="true" data-bs-placement="top" title=""> <i class="fa fa-pen-to-square" onclick="openModalWithDefaultData()" id="showModalButton" style="font-size: 18px;"></i></a>
<!-- <a th:href="@{#}" th:onclick="return false;" data-bs-toggle="tooltip" data-bs-animation="true" data-bs-placement="top" title="Edit"><i class="far fa-pen-to-square" style="font-size: 18px;"></i></a>&nbsp;&nbsp; -->
<a th:href="@{#}" th:onclick="return callDelete([[${assetlist.assetName}]], [[${assetlist.assetId}]] );;" data-bs-toggle="tooltip" data-bs-animation="true" data-bs-placement="top" title="Delete"><i class="far fa-trash-can" style="font-size: 18px;"></i></a>
<a tabindex="0" class="text-danger" data-bs-toggle="popover" data-bs-trigger="focus" title="" th:attr="data-bs-content=${'&lt;img src=&quot;data:image/png;base64,' + assetlist.assetimg + '&quot; width=&quot;100%&quot; /&gt;'}" data-bs-html="true" style="font-size:10px;cursor:pointer"><i class="far fa-image" style="font-size: 18px;"></i></a>
@ -220,18 +218,12 @@
<input type="text" class="form-control" name="person" id="person" required>
</div>
</div>
<div class="col-md-3 alert-light border-0">
<div class="mb-3">
<label class="form-check-label" for="assetId">Asset Id</label>
<input type="text" class="form-control" name="assetId" id="assetId" required>
</div>
</div>
<!-- <div class="col-md-6 alert-light border-0">
<div class="col-md-6 alert-light border-0">
<div class="mb-3">
<label class="form-check-label" for="assetName">Asset Id</label>
<label class="form-check-label" for="assetName">Asset Name</label>
<input type="text" class="form-control" name="assetName" id="assetName" required>
</div>
</div>-->
</div>
<div class="col-md-3 alert-light border-0">
<div class="mb-3">
@ -385,7 +377,6 @@
});
function getParameter(){
var catid = $('#assetCategory').val();//$('#catId').find(":selected").val();
var paramHTML=''
if(catid!='' || catid>0){
@ -412,25 +403,28 @@
}
return false;
}
function views (assetlist){
console.log(assetlist)
$('#views').modal({
backdrop: 'static',
keyboard: false
});
$('#views').modal('show');
document.getElementById("PopAssetId").value =assetlist.assetId;
/* document.getElementById("catName").value = assetlist.assetCategory.catName;*/
document.getElementById("catName").value =assetlist.assetCategory.catName;
document.getElementById("departmentName").value =assetlist.departmentName;
document.getElementById("person").value =assetlist.person;
document.getElementById("position").value =assetlist.position;
document.getElementById("assetId").value = assetlist.assetId;
}
document.getElementById("assetName").value =assetlist.assetName;
}
// ERP DATA CALL via API
</script>

19
src/main/resources/templates/gcc-complaint.html

@ -61,19 +61,13 @@
<div class="card-header bg-secondary text-white">
Gcc Asset Details
</div>
<div class="card-body">
<div class="mb-0">
<p class="card-title mb-0 text-center" th:text="${assetName}">Title</p>
<div class="mb-3">
<div class="card-body">
<label for="assetId">Asset Id</label>
<div class="mb-0 text-center">
<!--<p class="card-title mb-0 text-center" th:text="${assetId}">Title</p>-->
<input type="text" class="form-control text-center" name="person" id="person" th:value="${assetId}" readonly />
</div>
<div class="mb-0">
<p class="card-title mb-0 text-center" th:text="${assetAddress}">Address</p>
</div>
@ -87,9 +81,9 @@
<div class="card-body">
<div class="mb-3">
<label for="person">Name (Optional):</label>
<input type="text" class="form-control" name="person" id="person" placeholder="" required />
<p class="card-title mb-0 text-center" th:text="${person}">Address</p>
<label for="uname">Name (Optional):</label>
<input type="text" class="form-control" name="uname" id="uname" placeholder="" required />
<input type="hidden" class="form-control" name="assetId" id="assetId" th:value="${assetId}" required />
</div>
<div class="mb-3">
@ -368,4 +362,3 @@
</script>
</body>
</html>

409
src/main/resources/templates/old-dashboard.html

@ -1,409 +0,0 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/head :: head"></head>
<body>
<!-- Page Container -->
<div id="page-container" class="sidebar-o sidebar-dark enable-page-overlay side-scroll page-header-fixed page-header-dark">
<!-- Side Overlay aside (right)-->
<aside th:replace="fragments/aside-right :: aside"></aside>
<!-- END Side Overlay (right)-->
<!-- Sidebar Nav-->
<nav th:replace="fragments/nav :: nav"></nav>
<!-- END Sidebar -->
<!-- Header -->
<header th:replace="fragments/header :: header"></header>
<!-- END Header -->
<!-- Main Container -->
<main id="main-container">
<!-- Hero -->
<div class="">
<div class="content content-full">
<div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
<h3 class="flex-grow-1 fs-5 fw-semibold my-2 my-sm-3">Welcome</h3>
<nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item active" aria-current="page">Dashboard</li>
</ol>
</nav>
</div>
</div>
</div>
<!-- END Hero -->
<!-- Page Content -->
<div class="content">
<!-- Overview -->
<div class="row items-push">
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-qrcode fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalAssets}">000</div>
<div class="text-muted mb-1 fs-5">Total Asset</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/gcc-asset-list">
View all Assets
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-comments fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-info" th:utext="${totalFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/complaint-list">
View all Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-up fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalYesFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total closed Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/closed-complaint">
View all Closed Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-down fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-warning" th:utext="${totalNoFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Pending Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/pending-complaint">
View all Pending Complaint
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
</div>
<!-- END Overview -->
<!-- Store Growth -->
<div class="block block-rounded">
<div class="block-header block-header-default">
<h3 class="block-title">
Monthly Summary
</h3>
<div class="block-options">
<button type="button" class="btn-block-option" data-toggle="block-option" data-action="state_toggle" data-action-mode="demo">
<i class="si si-refresh"></i>
</button>
<button type="button" class="btn-block-option">
<i class="si si-wrench"></i>
</button>
<button type="button" class="btn-block-option" id="reportrange">
<span></span>
</button>
</div>
</div>
<div class="block-content block-content-full">
<div class="row">
<div class="col-md-5 col-xl-4 d-md-flex align-items-md-center">
<div class="p-md-2 p-lg-3">
<div class="py-3">
<div class="fs-1 fw-bold" th:utext="${totalFeedbacks}">000</div>
<div class="fw-semibold text-info">Total Complaints</div>
</div>
<div class="py-3">
<div class="fs-1 fw-bold" th:utext="${totalYesFeedbacks}">000</div>
<div class="fw-semibold text-success">Closed Complaints</div>
</div>
<div class="py-3">
<div class="fs-1 fw-bold" th:utext="${totalNoFeedbacks}">000</div>
<div class="fw-semibold text-warning">Pending Complaints</div>
</div>
</div>
</div>
<div class="col-md-7 col-xl-8 d-md-flex align-items-md-center">
<div class="p-md-2 p-lg-3 w-100" style="height: 450px;">
<!-- Bars Chart Container -->
<!-- Chart.js Chart is initialized in js/pages/be_pages_dashboard.min.js which was auto compiled from _js/pages/be_pages_dashboard.js -->
<!-- For more info and examples you can check out http://www.chartjs.org/docs/ -->
<canvas id="js-chartjs-analytics-bars"></canvas>
</div>
</div>
</div>
</div>
</div>
<!-- END Store Growth -->
<!-- Latest Orders + Stats -->
<!-- END Latest Orders + Stats -->
</div>
<!-- END Page Content -->
</main>
<!-- END Main Container -->
<!-- Footer -->
<footer th:replace="fragments/footer :: footer"></footer>
<!-- END Footer -->
</div>
<!-- END Page Container -->
<!-- Scripts -->
<script th:replace="fragments/script :: script"></script>
<!-- Page JS Plugins -->
<script src="assets/js/plugins/chart.js/chart.umd.js"></script>
<!-- Include Date Range Picker -->
<script type="text/javascript" src="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.css" />
<script>
var dash;
function convert(){
dash=/*[[${dashboard}]]*/{};
}
convert();
alert("hi board");
console.log(dash);
// Chart.js Charts, for more examples you can check out http://www.chartjs.org/docs
class pageDashboard {
/*
* Init Charts
*
*/
static initChartsBars() {
// Set Global Chart.js configuration
Chart.defaults.color = '#818d96';
Chart.defaults.scale.grid.color = 'transparent';
Chart.defaults.scale.grid.zeroLineColor = 'transparent';
Chart.defaults.scale.beginAtZero = true;
Chart.defaults.elements.line.borderWidth = 1;
Chart.defaults.plugins.legend.labels.boxWidth = 12;
// Get Chart Containers
let chartBarsCon = document.getElementById('js-chartjs-analytics-bars');
// Set Chart and Chart Data variables
let chartBars, chartLinesBarsData;
// Bars Chart Data
chartLinesBarsData = {
//labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'Total Complaints',
fill: true,
backgroundColor: '#c7d7e6',
borderColor: 'transparent',
pointBackgroundColor: '#c7d7e6',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: '#c7d7e6',
data: [0, 0, 0, 1, 0, 0, 2]
},
{
label: 'Closed Complaint',
fill: true,
backgroundColor: '#c2d7ab',
borderColor: 'transparent',
pointBackgroundColor: '#c2d7ab',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: '#c2d7ab',
data: [0, 0, 0, 1, 0, 0, 0]
},
{
label: 'Pending Complaint',
fill: true,
backgroundColor: '#e9cb91',
borderColor: 'transparent',
pointBackgroundColor: '#e9cb91',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: '#e9cb91',
data: [0, 0, 0, 0, 0, 0, 2]
}
]
};
// Init Chart
if (chartBarsCon !== null) {
chartBars = new Chart(chartBarsCon, {
type: 'bar',
data: chartLinesBarsData,
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
tooltip: {
callbacks: {
label: function (context) {
return context.dataset.label + ': ' + context.parsed.y + '';
}
}
}
}
}
});
}
}
/*
* Init functionality
*
*/
static init() {
this.initChartsBars();
}
}
// Initialize when page loads
Dashmix.onLoad(() => pageDashboard.init());
</script>
<script type="text/javascript">
$(function() {
var start = moment().subtract(29, 'days');
var end = moment();
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
}
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
}, cb);
cb(start, end);
});
</script>
<script type="text/javascript">
//Chart Update data
/* static updateChartLinesBarsData(newData) {
// Update the chart data;
pageDashboard.chartLinesBarsData.datasets[0].data = newData.totalFeedbacks;
pageDashboard.chartLinesBarsData.datasets[1].data = newData.positiveFeedbacks;
pageDashboard.chartLinesBarsData.datasets[2].data = newData.negativeFeedbacks;
// Update the chart
if (pageDashboard.chartBars !== undefined) {
pageDashboard.chartBars.data = pageDashboard.chartLinesBarsData;
pageDashboard.chartBars.update();
}
}
function getAndpushdata(){
$.ajax({
url: 'api/dashboard', // Replace with the URL to fetch the updated data
method: 'GET', // Replace with the appropriate HTTP method
dataType: 'json', // Replace with the data type you are expecting
success: function (response) {
// Assuming the response contains the updated chart data in the expected format
pageDashboard.updateChartLinesBarsData(response);
},
error: function (xhr, status, error) {
// Handle the error scenario
console.error('Error:', error);
}
});
} */
// Assuming pageDashboard is an object or class instance
var pageDashboard = {
chartLinesBarsData: {
datasets: [
{ data: [] }, // Assuming totalFeedbacks is an array
{ data: [] }, // Assuming positiveFeedbacks is an array
{ data: [] } // Assuming negativeFeedbacks is an array
]
},
chartBars: undefined, // Assuming chartBars is initially undefined
updateChartLinesBarsData: function(newData) {
// Update the chart data
this.chartLinesBarsData.datasets[0].data = newData.totalFeedbacks;
this.chartLinesBarsData.datasets[1].data = newData.positiveFeedbacks;
this.chartLinesBarsData.datasets[2].data = newData.negativeFeedbacks;
// Update the chart
if (this.chartBars !== undefined) {
this.chartBars.data = this.chartLinesBarsData;
this.chartBars.update();
}
},
getAndPushData: function() {
var self = this; // Store a reference to the current object
$.ajax({
url: 'api/dashboard', // Replace with the URL to fetch the updated data
method: 'GET', // Replace with the appropriate HTTP method
dataType: 'json', // Replace with the data type you are expecting
success: function(response) {
// Assuming the response contains the updated chart data in the expected format
self.updateChartLinesBarsData(response);
},
error: function(xhr, status, error) {
// Handle the error scenario
console.error('Error:', error);
}
});
}
};
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
</script>
</body>
</html>

2
src/main/resources/templates/pending-complaint.html

@ -201,7 +201,7 @@
function viewnegfeedback (feedback) {
console.log(feedback);
//console.log(feedback);
alert("ji");
document.getElementById("assetCode").value =feedback.gccAssetDetails.assetCode;
document.getElementById("assetName").value =feedback.gccAssetDetails.assetName;

455
src/main/resources/templates/pendingchart.html

@ -0,0 +1,455 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/head :: head"></head>
<body>
<!-- Page Container -->
<div id="page-container" class="sidebar-o sidebar-dark enable-page-overlay side-scroll page-header-fixed page-header-dark">
<!-- Side Overlay aside (right)-->
<aside th:replace="fragments/aside-right :: aside"></aside>
<!-- END Side Overlay (right)-->
<!-- Sidebar Nav-->
<nav th:replace="fragments/nav :: nav"></nav>
<!-- END Sidebar -->
<!-- Header -->
<header th:replace="fragments/header :: header"></header>
<!-- END Header -->
<!-- Main Container -->
<main id="main-container">
<!-- Hero -->
<div class="">
<div class="content content-full">
<div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
<h3 class="flex-grow-1 fs-5 fw-semibold my-2 my-sm-3">Welcome</h3>
<nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item active" aria-current="page">Dashboard</li>
</ol>
</nav>
</div>
</div>
</div>
<!-- END Hero -->
<!-- Page Content -->
<div class="content">
<!-- Overview -->
<div class="row items-push">
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-qrcode fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalAssets}">000</div>
<div class="text-muted mb-1 fs-5">Total Asset</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/gcc-asset-list">
View all Assets
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-comments fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-info" th:utext="${totalFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/complaint-list">
View all Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-up fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalYesFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total closed Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/closed-complaint">
View all Closed Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-down fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-warning" th:utext="${totalNoFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Pending Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/pending-complaint">
View all Pending Complaint
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
</div>
<!-- END Overview -->
<!-- Store Growth -->
<div class="row">
<div class="col-12 col-md-6 col-xl-6">
<div class="p-md-2 p-lg-3 w-100" style="height: 400px;">
<!-- Chart 1 Container -->
<canvas id="myChart1"></canvas>
</div>
</div>
<div class="col-12 col-md-6 col-xl-6">
<div class="p-md-2 p-lg-3 w-100" style="height: 500px;">
<!-- Chart 2 Container -->
<canvas id="myChart"></canvas>
</div>
</div>
</div>
</div>
<!-- END Store Growth -->
<!-- Latest Orders + Stats -->
<!-- END Latest Orders + Stats -->
<!-- END Page Content -->
</main>
<!-- END Main Container -->
<!-- Footer -->
<footer th:replace="fragments/footer :: footer"></footer>
<!-- END Footer -->
</div>
<!-- END Page Container -->
<!-- Scripts -->
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<!-- Your existing script tag follows -->
<script th:replace="fragments/script :: script"></script>
<!-- Page JS Plugins -->
<script src="assets/js/plugins/chart.js/chart.umd.js"></script>
<!-- Include Date Range Picker -->
<script type="text/javascript" src="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.css" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
var dash = {};
function convert() {
// Ensure proper initialization logic for feedbackAnalysisData
dash.feedbackAnalysisData = /*[[${dashboard}]]*/ {};
}
convert();
var pageDashboard = {
chartBars: undefined,
chartLinesBarsData: {
datasets: [
{ data: [] }, // Assuming totalYesFeedbacks is an array
{ data: [] },
{data:[] } // Assuming totalNoFeedbacks is an array
]
},
initChart: function (feedbackAnalysis) {
// Set Global Chart.js configuration
Chart.defaults.color = '#818d96';
Chart.defaults.scale.grid.color = 'transparent';
Chart.defaults.scale.grid.zeroLineColor = 'transparent';
Chart.defaults.scale.beginAtZero = true;
Chart.defaults.elements.line.borderWidth = 1;
Chart.defaults.plugins.legend.labels.boxWidth = 12;
// Get Chart Container
let chartBarsCon = document.getElementById('myChart');
var data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [
{
label: 'Total Complaints',
data: [],
fill: true,
backgroundColor: '#3498db',
borderColor: 'transparent',
pointBackgroundColor: '#c7d7e6',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#2980b9',
pointHoverBorderColor: '#c7d7e6',
},
]
};
var options = {
responsive: true,
scales: {
x: { beginAtZero: true },
y: { beginAtZero: true }
},
plugins: {
datalabels: {
anchor: 'end',
align: 'end',
color: 'black',
formatter: function (value, context) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
this.chartBars = new Chart(chartBarsCon, {
type: 'bar',
data: data,
options: options
});
},
updateChartLinesBarsData: function (newData) {
// Ensure the chart is initialized before updating
if (this.chartBars) {
// Assuming labels for the chart are ['Jan', 'Feb', 'Mar', ..., 'Dec']
var labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// Initialize arrays with values from dataArray
var totalFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalFeedbacksData[${index}]: ${dataArray[index]});
return sum + dataArray[index];
}, 0);
});
var totalYesFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalYesFeedbacksData[${index}]: ${dataArray[index]});
return dataArray[index];
}, 0);
});
// Subtract totalYesFeedbacksData from totalFeedbacksData
var totalNoFeedbacksData = totalFeedbacksData.map((value, index) => value - totalYesFeedbacksData[index]);
// Update the chart data
this.chartBars.data.datasets[0].data = totalFeedbacksData;
// this.chartBars.data.datasets[1].data = totalYesFeedbacksData;
// this.chartBars.data.datasets[2].data = totalNoFeedbacksData;
// Log the updated chart data
// console.log('Updated chart data (totalFeedbacksData):', this.chartBars.data.datasets[0].data);
//console.log('Updated chart data (totalYesFeedbacksData):', this.chartBars.data.datasets[1].data);
//console.log('Updated chart data (totalNoFeedbacksData):', this.chartBars.data.datasets[2].data);
// Update the chart
this.chartBars.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function (cdate) {
// Ensure convert() is called before accessing dash.feedbackAnalysisData
convert();
var self = this;
$.ajax({
url: 'api/cou/' + cdate,
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
self.updateChartLinesBarsData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function with the feedbackAnalysis data
pageDashboard.initChart(dash.feedbackAnalysisData || {});
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
pageDashboard.getAndPushData();
var pageDashboard = {
chartPie: undefined,
chartPieData: {
labels: ['Total Complaints', 'Closed Complaint', 'Pending Complaint'],
datasets: [
{
data: [],
backgroundColor: ['#3498db', '#e74c3c', '#cc6633'],
hoverBackgroundColor: ['#2980b9', '#c0392b', '#A35128']
}
]
},
initChart: function () {
// Get Chart Container
let chartPieCon = document.getElementById('myChart1');
var options = {
responsive: true,
plugins: {
datalabels: {
color: 'black',
formatter: function (value) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
this.chartPie = new Chart(chartPieCon, {
type: 'pie',
data: this.chartPieData,
options: options
});
// Add click event listener to the chart container
chartPieCon.onclick = function (event) {
var elements = pageDashboard.chartPie.getElementsAtEventForMode(event, 'point', pageDashboard.chartPie.options);
if (elements && elements.length > 0) {
var clickedIndex = elements[0].index;
console.log('Clicked Index:', clickedIndex);
console.log('Elements:', elements);
console.log('Labels:', pageDashboard.chartPieData.labels);
// Continue with the rest of your code...
} else {
console.error('No elements found at the click event.');
}
if (clickedIndex >= 0 && clickedIndex < pageDashboard.chartPieData.labels.length) {
var clickedLabel = pageDashboard.chartPieData.labels[clickedIndex];
// Log the clicked label for debugging
console.log('Clicked Label:', clickedLabel);
// Navigate based on the clicked label
switch (clickedLabel) {
case 'Total Complaints':
console.log('Navigating to pendingchart.html');
window.location.href = 'pendingchart.html';
break;
case 'Pending Complaint':
console.log('Navigating to nofeedbacks.html');
window.location.href = 'closedchart.html';
break;
case 'Closed Complaint':
console.log('Navigating to yesfeedbacks.html');
window.location.href = 'totalchart.html';
break;
// Add more cases for other labels if needed
default:
console.log('No action defined for clicked label:', clickedLabel);
}
} else {
console.error('Invalid clicked index:', clickedIndex);
}
};
},
updateChartPieData: function (data) {
if (this.chartPie) {
var totalFeedbacks = data.totalFeedbacks || 0;
var totalYesFeedbacks = data.totalYesFeedbacks || 0;
var totalNoFeedbacks = data.totalNoFeedbacks || 0;
// Update the chart data
this.chartPieData.datasets[0].data = [totalFeedbacks, totalYesFeedbacks, totalNoFeedbacks];
// Update the chart
this.chartPie.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function () {
// Assume you have a function named 'convert'
convert();
var self = this;
// Fetch data from the actual API
$.ajax({
url: 'http://localhost:8071/api/dashboard-summary',
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
// Call the function to process the API response
self.updateChartPieData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function
pageDashboard.initChart();
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
</script>
</body>
</html>

62
src/main/resources/templates/testdashboard.html

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feedback Chart</title>
<!-- Include Chart.js from CDN -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<canvas id="feedbackChart" width="400" height="400"></canvas>
<script>
var dash=[[${dashboard}]];
console.log(dash);
// Assume your API endpoint returns a JSON object with the data
// Modify the URL accordingly based on your server setup
const apiUrl = 'api/cou/{cdate}'; // Replace with your actual API endpoint
// Fetch data from the API
fetch(apiUrl)
.then(response => response.json())
.then(data => {
// Extract data for chart
const labels = ['Yes', 'No', 'Total'];
const values = [data.yes, data.no, data.total];
// Create a Chart.js chart
const ctx = document.getElementById('feedbackChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Feedback Data',
data: values,
backgroundColor: [
'rgba(75, 192, 192, 0.2)',
'rgba(255, 99, 132, 0.2)',
'rgba(255, 255, 255, 0.2)'
],
borderColor: [
'rgba(75, 192, 192, 1)',
'rgba(255, 99, 132, 1)',
'rgba(255, 255, 255, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
})
.catch(error => console.error('Error fetching data:', error));
</script>
</body>
</html>

452
src/main/resources/templates/totalchart.html

@ -0,0 +1,452 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/head :: head"></head>
<body>
<!-- Page Container -->
<div id="page-container" class="sidebar-o sidebar-dark enable-page-overlay side-scroll page-header-fixed page-header-dark">
<!-- Side Overlay aside (right)-->
<aside th:replace="fragments/aside-right :: aside"></aside>
<!-- END Side Overlay (right)-->
<!-- Sidebar Nav-->
<nav th:replace="fragments/nav :: nav"></nav>
<!-- END Sidebar -->
<!-- Header -->
<header th:replace="fragments/header :: header"></header>
<!-- END Header -->
<!-- Main Container -->
<main id="main-container">
<!-- Hero -->
<div class="">
<div class="content content-full">
<div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
<h3 class="flex-grow-1 fs-5 fw-semibold my-2 my-sm-3">Welcome</h3>
<nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item active" aria-current="page">Dashboard</li>
</ol>
</nav>
</div>
</div>
</div>
<!-- END Hero -->
<!-- Page Content -->
<div class="content">
<!-- Overview -->
<div class="row items-push">
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-qrcode fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalAssets}">000</div>
<div class="text-muted mb-1 fs-5">Total Asset</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/gcc-asset-list">
View all Assets
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-comments fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-info" th:utext="${totalFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/complaint-list">
View all Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full flex-grow-1">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-up fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-success" th:utext="${totalYesFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total closed Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/closed-complaint">
View all Closed Complaints
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3">
<div class="block block-rounded text-center d-flex flex-column h-100 mb-0">
<div class="block-content block-content-full">
<div class="item rounded-3 bg-body mx-auto my-3">
<i class="fa fa-thumbs-down fa-lg text-primary"></i>
</div>
<div class="fs-2 fw-bold text-warning" th:utext="${totalNoFeedbacks}">000</div>
<div class="text-muted mb-1 fs-5">Total Pending Complaints</div>
</div>
<div class="block-content block-content-full block-content-sm bg-body-light fs-sm">
<a class="fw-medium" href="/pending-complaint">
View all Pending Complaint
<i class="fa fa-arrow-right ms-1 opacity-25"></i>
</a>
</div>
</div>
</div>
</div>
<!-- END Overview -->
<!-- Store Growth -->
<div class="row">
<div class="col-12 col-md-6 col-xl-6">
<div class="p-md-2 p-lg-3 w-100" style="height: 400px;">
<!-- Chart 1 Container -->
<canvas id="myChart1"></canvas>
</div>
</div>
<div class="col-12 col-md-6 col-xl-6">
<div class="p-md-2 p-lg-3 w-100" style="height: 500px;">
<!-- Chart 2 Container -->
<canvas id="myChart"></canvas>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END Store Growth -->
<!-- Latest Orders + Stats -->
<!-- END Latest Orders + Stats -->
</div>
<!-- END Page Content -->
</main>
<!-- END Main Container -->
<!-- Footer -->
<footer th:replace="fragments/footer :: footer"></footer>
<!-- END Footer -->
</div>
<!-- END Page Container -->
<!-- Scripts -->
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<!-- Your existing script tag follows -->
<script th:replace="fragments/script :: script"></script>
<!-- Page JS Plugins -->
<script src="assets/js/plugins/chart.js/chart.umd.js"></script>
<!-- Include Date Range Picker -->
<script type="text/javascript" src="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="assets/js/plugins/bootstrap-daterangepicker/daterangepicker.css" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
var dash = {};
function convert() {
// Ensure proper initialization logic for feedbackAnalysisData
dash.feedbackAnalysisData = /*[[${dashboard}]]*/ {};
}
convert();
var pageDashboard = {
chartBars: undefined,
chartLinesBarsData: {
datasets: [
{ data: [] }, // Assuming totalYesFeedbacks is an array
{ data: [] },
{data:[] } // Assuming totalNoFeedbacks is an array
]
},
initChart: function (feedbackAnalysis) {
// Set Global Chart.js configuration
Chart.defaults.color = '#818d96';
Chart.defaults.scale.grid.color = 'transparent';
Chart.defaults.scale.grid.zeroLineColor = 'transparent';
Chart.defaults.scale.beginAtZero = true;
Chart.defaults.elements.line.borderWidth = 1;
Chart.defaults.plugins.legend.labels.boxWidth = 12;
// Get Chart Container
let chartBarsCon = document.getElementById('myChart');
var data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [
{
label: 'Closed Complaint',
data: [],
fill: true,
backgroundColor: '#cc6633',
borderColor: 'transparent',
pointBackgroundColor: '#e9cb91',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#A35128',
pointHoverBorderColor: '#e9cb91',
},
]
};
var options = {
responsive: true,
scales: {
x: { beginAtZero: true },
y: { beginAtZero: true }
},
plugins: {
datalabels: {
anchor: 'end',
align: 'end',
color: 'black',
formatter: function (value, context) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
this.chartBars = new Chart(chartBarsCon, {
type: 'bar',
data: data,
options: options
});
},
updateChartLinesBarsData: function (newData) {
// Ensure the chart is initialized before updating
if (this.chartBars) {
// Assuming labels for the chart are ['Jan', 'Feb', 'Mar', ..., 'Dec']
var labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// Initialize arrays with values from dataArray
var totalFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalFeedbacksData[${index}]: ${dataArray[index]});
return sum + dataArray[index];
}, 0);
});
var totalYesFeedbacksData = Array.from({ length: labels.length }, (_, index) => {
return newData.reduce((sum, item) => {
const key = Object.keys(item)[0];
const dataArray = item[key];
// console.log(totalYesFeedbacksData[${index}]: ${dataArray[index]});
return dataArray[index];
}, 0);
});
// Subtract totalYesFeedbacksData from totalFeedbacksData
var totalNoFeedbacksData = totalFeedbacksData.map((value, index) => value - totalYesFeedbacksData[index]);
// Update the chart data
// this.chartBars.data.datasets[0].data = totalFeedbacksData;
// this.chartBars.data.datasets[0].data = totalYesFeedbacksData;
this.chartBars.data.datasets[0].data = totalNoFeedbacksData;
// Log the updated chart data
// console.log('Updated chart data (totalFeedbacksData):', this.chartBars.data.datasets[0].data);
//console.log('Updated chart data (totalYesFeedbacksData):', this.chartBars.data.datasets[1].data);
//console.log('Updated chart data (totalNoFeedbacksData):', this.chartBars.data.datasets[2].data);
// Update the chart
this.chartBars.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function (cdate) {
// Ensure convert() is called before accessing dash.feedbackAnalysisData
convert();
var self = this;
$.ajax({
url: 'api/cou/' + cdate,
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
self.updateChartLinesBarsData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function with the feedbackAnalysis data
pageDashboard.initChart(dash.feedbackAnalysisData || {});
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
pageDashboard.getAndPushData();
var pageDashboard = {
chartPie: undefined,
chartPieData: {
labels: ['Total Complaints', 'Closed Complaint', 'Pending Complaint'],
datasets: [
{
data: [],
backgroundColor: ['#3498db', '#e74c3c', '#cc6633'],
hoverBackgroundColor: ['#2980b9', '#c0392b', '#A35128']
}
]
},
initChart: function () {
// Get Chart Container
let chartPieCon = document.getElementById('myChart1');
var options = {
responsive: true,
plugins: {
datalabels: {
color: 'black',
formatter: function (value) {
// Display the value only if it's greater than 0
return value > 0 ? value : '';
}
}
}
};
// Create the chart
this.chartPie = new Chart(chartPieCon, {
type: 'pie',
data: this.chartPieData,
options: options
});
// Add click event listener to the chart container
chartPieCon.onclick = function (event) {
var elements = pageDashboard.chartPie.getElementsAtEventForMode(event, 'point', pageDashboard.chartPie.options);
if (elements && elements.length > 0) {
var clickedIndex = elements[0].index;
console.log('Clicked Index:', clickedIndex);
console.log('Elements:', elements);
console.log('Labels:', pageDashboard.chartPieData.labels);
// Continue with the rest of your code...
} else {
console.error('No elements found at the click event.');
}
if (clickedIndex >= 0 && clickedIndex < pageDashboard.chartPieData.labels.length) {
var clickedLabel = pageDashboard.chartPieData.labels[clickedIndex];
// Log the clicked label for debugging
console.log('Clicked Label:', clickedLabel);
// Navigate based on the clicked label
switch (clickedLabel) {
case 'Total Complaints':
console.log('Navigating to pendingchart.html');
window.location.href = 'pendingchart.html';
break;
case 'Pending Complaint':
console.log('Navigating to nofeedbacks.html');
window.location.href = 'closedchart.html';
break;
case 'Closed Complaint':
console.log('Navigating to yesfeedbacks.html');
window.location.href = 'totalchart.html';
break;
// Add more cases for other labels if needed
default:
console.log('No action defined for clicked label:', clickedLabel);
}
} else {
console.error('Invalid clicked index:', clickedIndex);
}
};
},
updateChartPieData: function (data) {
if (this.chartPie) {
var totalFeedbacks = data.totalFeedbacks || 0;
var totalYesFeedbacks = data.totalYesFeedbacks || 0;
var totalNoFeedbacks = data.totalNoFeedbacks || 0;
// Update the chart data
this.chartPieData.datasets[0].data = [totalFeedbacks, totalYesFeedbacks, totalNoFeedbacks];
// Update the chart
this.chartPie.update();
} else {
console.error('Chart is not initialized. Unable to update data.');
}
},
getAndPushData: function () {
// Assume you have a function named 'convert'
convert();
var self = this;
// Fetch data from the actual API
$.ajax({
url: 'http://localhost:8071/api/dashboard-summary',
method: 'GET',
dataType: 'json',
success: function (response) {
console.log('Data fetched successfully:', response);
// Call the function to process the API response
self.updateChartPieData(response);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
}
};
// Call the initChart function
pageDashboard.initChart();
// Call the getAndPushData method to fetch and update chart data
pageDashboard.getAndPushData();
</script>
</body>
</html>
Loading…
Cancel
Save