From 31a22ce9d592e1397ae6fcfeaf2faa8e9b8b7219 Mon Sep 17 00:00:00 2001 From: risadmin_prod Date: Mon, 23 Sep 2024 04:03:27 +0000 Subject: [PATCH] build_app --- .../Builders/Services/BuilderService.java | 3 + .../basicp1/Controllers/FormaController.java | 90 +++ .../com/realnet/basicp1/Entity/Forma.java | 37 ++ .../basicp1/Repository/FormaRepository.java | 23 + .../basicp1/Services/FormaService.java | 85 +++ .../authsec_mysql/mysql/wf_table/wf_table.sql | 2 + .../authsec_react_materail_ui/src/App.js | 7 +- .../BuilderComponents/basicp1/Forma/Forma.js | 581 ++++++++++++++++++ 8 files changed, 827 insertions(+), 1 deletion(-) create mode 100644 prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/FormaController.java create mode 100644 prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Forma.java create mode 100644 prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/FormaRepository.java create mode 100644 prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/FormaService.java create mode 100755 prod128rm-db-d/authsec_mysql/mysql/wf_table/wf_table.sql create mode 100644 prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/components/BuilderComponents/basicp1/Forma/Forma.js diff --git a/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java index df685fd..f294100 100644 --- a/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java +++ b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java @@ -69,6 +69,9 @@ public class BuilderService { executeDump(true); // ADD OTHER SERVICE +addCustomMenu( "Forma", "Transcations"); + + System.out.println("dashboard and menu inserted..."); diff --git a/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/FormaController.java b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/FormaController.java new file mode 100644 index 0000000..05f94b9 --- /dev/null +++ b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/FormaController.java @@ -0,0 +1,90 @@ +package com.realnet.basicp1.Controllers; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.springframework.web.bind.annotation.CrossOrigin; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.realnet.config.EmailService; +import com.realnet.users.entity1.AppUser; +import com.realnet.users.service1.AppUserServiceImpl; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.beans.factory.annotation.*; +import com.realnet.basicp1.Entity.Forma; +import com.realnet.basicp1.Services.FormaService ; +@RequestMapping(value = "/Forma") + @CrossOrigin("*") +@RestController +public class FormaController { + @Autowired + private FormaService Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + + + @PostMapping("/Forma") + public Forma Savedata(@RequestBody Forma data) { + Forma save = Service.Savedata(data) ; + + + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Forma/{id}") + public Forma update(@RequestBody Forma data,@PathVariable Integer id ) { + Forma update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Forma/getall/page") + public Page getall(@RequestParam(value = "page", required = false) Integer page, + @RequestParam(value = "size", required = false) Integer size) { + Pageable paging = PageRequest.of(page, size); + Page get = Service.getAllWithPagination(paging); + + return get; + + } + @GetMapping("/Forma") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Forma") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Forma/{id}") + public Forma getdetailsbyId(@PathVariable Integer id ) { + Forma get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Forma/{id}") + public void delete_by_id(@PathVariable Integer id ) { + Service.delete_by_id(id); + + } + +} \ No newline at end of file diff --git a/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Forma.java b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Forma.java new file mode 100644 index 0000000..5bd2da1 --- /dev/null +++ b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Forma.java @@ -0,0 +1,37 @@ +package com.realnet.basicp1.Entity; + import lombok.*; +import com.realnet.WhoColumn.Extension; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + + + + + + + + + @Entity + @Data + public class Forma extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + +private String namemm; + +private int percentagemm; + +private String recaptchamm; + +private String documentss; + + +} diff --git a/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/FormaRepository.java b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/FormaRepository.java new file mode 100644 index 0000000..6a69400 --- /dev/null +++ b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/FormaRepository.java @@ -0,0 +1,23 @@ +package com.realnet.basicp1.Repository; + + +import org.springframework.data.jpa.repository.JpaRepository; + +import org.springframework.stereotype.Repository; +import java.util.*; + + + + + + + + + + + +import com.realnet.basicp1.Entity.Forma; + +@Repository +public interface FormaRepository extends JpaRepository { +} \ No newline at end of file diff --git a/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/FormaService.java b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/FormaService.java new file mode 100644 index 0000000..5c2219b --- /dev/null +++ b/prod128rm-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/FormaService.java @@ -0,0 +1,85 @@ +package com.realnet.basicp1.Services; +import com.realnet.basicp1.Repository.FormaRepository; +import com.realnet.basicp1.Entity.Forma;import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import com.realnet.SequenceGenerator.Service.SequenceService; +import com.realnet.Notification.Entity.NotificationService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import com.realnet.users.service1.AppUserServiceImpl; +import com.realnet.users.entity1.AppUser; + + + + + + + + + import org.springframework.stereotype.Service; + +@Service + public class FormaService { +@Autowired +private FormaRepository Repository; + @Autowired + private AppUserServiceImpl userService; + + + + + +@Autowired + private SequenceService documentsssequenceService; + +public Forma Savedata(Forma data) { + + + + + + +data.setDocumentss (documentsssequenceService.GenerateSequence("kk")); + +Forma save = Repository.save(data); + return save; + } + + +// get all with pagination + public Page getAllWithPagination(Pageable page) { + return Repository.findAll(page); + } +public List getdetails() { + return (List) Repository.findAll(); + } + + +public Forma getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + + public void delete_by_id(Integer id) { + Repository.deleteById(id); +} + + +public Forma update(Forma data,Integer id) { + Forma old = Repository.findById(id).get(); +old.setNamemm(data.getNamemm()); + +old.setPercentagemm(data.getPercentagemm()); + +old.setRecaptchamm(data.getRecaptchamm()); + +old.setDocumentss(data.getDocumentss()); + +final Forma test = Repository.save(old); + return test;} + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + }} diff --git a/prod128rm-db-d/authsec_mysql/mysql/wf_table/wf_table.sql b/prod128rm-db-d/authsec_mysql/mysql/wf_table/wf_table.sql new file mode 100755 index 0000000..41224b2 --- /dev/null +++ b/prod128rm-db-d/authsec_mysql/mysql/wf_table/wf_table.sql @@ -0,0 +1,2 @@ +CREATE TABLE db.Forma(id BIGINT NOT NULL AUTO_INCREMENT, documentss VARCHAR(400), Namemm VARCHAR(400), Percentagemm VARCHAR(400), recaptchamm VARCHAR(400), PRIMARY KEY (id)); + diff --git a/prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/App.js b/prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/App.js index 5b63a92..301ea7a 100644 --- a/prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/App.js +++ b/prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/App.js @@ -1,3 +1,5 @@ +import Forma from "./components/BuilderComponents/basicp1/Forma/Forma"; + import React from "react"; import { Routes, Route } from "react-router-dom"; import { BrowserRouter as Router } from 'react-router-dom'; @@ -41,6 +43,9 @@ const App = () => { {/* buildercomponents */} + } /> + + @@ -50,4 +55,4 @@ const App = () => { ); }; -export default App; +export default App; \ No newline at end of file diff --git a/prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/components/BuilderComponents/basicp1/Forma/Forma.js b/prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/components/BuilderComponents/basicp1/Forma/Forma.js new file mode 100644 index 0000000..33cc23b --- /dev/null +++ b/prod128rm-front-f/authsec_react_materail_ui/authsec_react_materail_ui/src/components/BuilderComponents/basicp1/Forma/Forma.js @@ -0,0 +1,581 @@ +import React, { useEffect, useState ,useRef } from "react"; +import axios from "axios"; +import { + Button, + Dialog, + Autocomplete, + DialogActions, + DialogContent, + DialogTitle, + Snackbar, + Alert, + Typography, + TextField, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + CardMedia, + Card, + LinearProgress, +Grid, +Container, + TablePagination, + Paper, + IconButton, + InputAdornment +} from "@mui/material"; +import Radio from '@mui/material/Radio'; +import RadioGroup from '@mui/material/RadioGroup'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import FormControl from '@mui/material/FormControl'; +import FormLabel from '@mui/material/FormLabel'; + +import FormGroup from '@mui/material/FormGroup'; +import Checkbox from '@mui/material/Checkbox'; + +import InputLabel from '@mui/material/InputLabel'; +import MenuItem from '@mui/material/MenuItem'; +import Select from '@mui/material/Select'; + +import Box from '@mui/material/Box'; +import OutlinedInput from '@mui/material/OutlinedInput'; +import Chip from '@mui/material/Chip'; + +import { makeStyles } from '@mui/styles'; +import { QRCode } from "react-qrcode-logo"; +import Barcode from "react-barcode"; + import { ToastContainer, toast } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; +import ReCAPTCHA from 'react-google-recaptcha'; +import SearchIcon from '@mui/icons-material/Search'; + +const API_URL = `${process.env.REACT_APP_API_BASE_URL}/Forma/Forma`; +const token = localStorage.getItem("authToken"); +// Custom styles using makeStyles +const useStyles = makeStyles((theme) => ({ + tableHeader: { + backgroundColor: "#000000", + color: "#ffffff", + }, + searchContainer: { + display: 'flex', + alignItems: 'center', + marginBottom: theme.spacing(2), + }, + searchInput: { + marginRight: theme.spacing(2), + flex: 1, + }, + tableContainer: { + marginTop: theme.spacing(2), + }, + dialogContent: { + display: 'flex', + flexDirection: 'column', + gap: theme.spacing(2), + }, + formControl: { + marginBottom: theme.spacing(2), + }, + button: { + margin: theme.spacing(1), + }, +})); + + + + + + + + + + +const EntityTable = () => { + const classes = useStyles(); + const [data, setData] = useState([]); + const [filteredData, setFilteredData] = useState([]); + + + + + + + + + const [newEntity, setNewEntity] = useState({ + namemm: "", + + percentagemm: "", + + recaptchamm: "", + + documentss: "", + + }); + const [editEntity, setEditEntity] = useState(null); + const [showEditModal, setShowEditModal] = useState(false); + const [showAddModal, setShowAddModal] = useState(false); + const [showDeleteModal, setShowDeleteModal] = useState(false); + const [deleteEntityId, setDeleteEntityId] = useState(null); + const [currentPage, setCurrentPage] = useState(0); + const [itemsPerPage] = useState(5); // Adjust this value as needed + const [searchQuery, setSearchQuery] = useState(""); + const [openSnackbar, setOpenSnackbar] = useState(false); + const [snackbarMessage, setSnackbarMessage] = useState(""); + const [qrText, setQrText] = useState(""); + const [showQrCode, setShowQrCode] = useState(false); + const qrCodeRef = useRef(); + const [barcodeText, setBarcodeText] = useState(""); + const barcodeRef = useRef(); + const [showBarcode, setShowBarcode] = useState(false); + const [captchaValue, setCaptchaValue] = useState(null); + const [alertMessage, setAlertMessage] = useState(""); + const [showPaymentOptions, setShowPaymentOptions] = useState(false); + const [uploadProgress, setUploadProgress] = useState(0); + const [serverData, setServerData] = useState([]); + const [showValulistModal, setShowValulistModal] = useState(false); + const [snackbarSeverity, setSnackbarSeverity] = useState("success"); + + const handlePageChange = (event, newPage) => { + setCurrentPage(newPage); + }; + + useEffect(() => { + fetchData(); + }, []); + + useEffect(() => { + handleSearch(); + }, [searchQuery, data]); + + const fetchData = async () => { + try { + const response = await axios.get(API_URL, { + headers: { Authorization: `Bearer ${token}` }, + }); + setData(response.data); + } catch (error) { + console.error("Error fetching data:", error); + } + }; + + const handleDelete = async () => { + try { + await axios.delete(`${API_URL}/${deleteEntityId}`, { + headers: { Authorization: `Bearer ${token}` }, + }); + fetchData(); + setSnackbarMessage("Successfully deleted!"); + setSnackbarSeverity("success"); + setOpenSnackbar(true); + setShowDeleteModal(false); + } catch (error) { + console.error("Error deleting data:", error); + setSnackbarMessage("Failed to delete!"); + setSnackbarSeverity("error"); + setOpenSnackbar(true); + } + }; + + const handleAdd = async () => { + + + + + + + + + try { + await axios.post(API_URL, newEntity, { + headers: { Authorization: `Bearer ${token}` }, + }); + fetchData(); + setNewEntity({ + namemm: "", + + percentagemm: "", + + recaptchamm: "", + + documentss: "", + + }); + setShowAddModal(false); + setSnackbarMessage("Successfully added!"); + setSnackbarSeverity("success"); + setOpenSnackbar(true); + } catch (error) { + console.error("Error adding data:", error); + setSnackbarMessage("Failed to add!"); + setSnackbarSeverity("error"); + setOpenSnackbar(true); + } + }; + + const handleChange = (e) => { + const { name, value } = e.target; + setNewEntity({ ...newEntity, [name]: value }); + }; + + const handleChangeCheckbox = (e) => { + const { name, value, checked } = e.target; + setNewEntity({ ...newEntity, [value]: checked }); + }; + +const handleChangeSelectMulti = (e) => { + const { name, value } = e.target; + setNewEntity({ ...newEntity, [name]: String(value) }); + }; + + const handleEditChange = (e) => { + const { name, value } = e.target; + setEditEntity({ ...editEntity, [name]: value }); + }; + + const handleEdit = (entity) => { + let requiredKeys = Object.keys(newEntity); + let newObj = {}; + requiredKeys.forEach((key) => { + newObj[key] = entity[key]; + }); + setEditEntity(entity); + setNewEntity(newObj); + setShowEditModal(true); + }; + + const handleUpdate = async () => { + + + + + + + + + try { + await axios.put(`${API_URL}/${editEntity.id}`, newEntity, { + headers: { Authorization: `Bearer ${token}` }, + }); + fetchData(); + setShowEditModal(false); + setSnackbarMessage("Successfully updated!"); + setSnackbarSeverity("success"); + setOpenSnackbar(true); + } catch (error) { + console.error("Error updating data:", error); + setSnackbarMessage("Failed to update!"); + setSnackbarSeverity("error"); + setOpenSnackbar(true); + } + }; + + const handleSearch = () => { + const filtered = data; + setFilteredData(filtered); + }; + + + + + + const handleCaptchaChange = (value) => { + console.log("Captcha value:", value); + setCaptchaValue(value); // Set the captcha value +}; + + + + + return ( +
+ + Entity Table + +
+ + + + + + + + + + setSearchQuery(e.target.value)} + InputProps={{ + endAdornment: ( + + + + + + ), + }} + /> +
+ + + + + + + + + + + + + + + + {filteredData.slice(currentPage * itemsPerPage, (currentPage + 1) * itemsPerPage).map((entity) => ( + + + + + + + + + + + + + + + + + + + + + + + ))} + +
namemmpercentagemmrecaptchammdocumentss{entity.namemm}{entity.percentagemm}{entity.recaptchamm}{entity.documentss}
+
+ + + + + + + + + + setShowEditModal(false)}> + Edit Entity + + + + + + + + + + + + + + + + + + + + + + + + + setShowAddModal(false)}> + Add Entity + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + setShowDeleteModal(false)}> + Confirm Delete + + Are you sure you want to delete this entity? + + + + + + + setOpenSnackbar(false)} + > + setOpenSnackbar(false)} severity={snackbarSeverity}> + {snackbarMessage} + + +
+ ); +}; + +export default EntityTable;