build_app

This commit is contained in:
risadmin_prod 2024-09-23 11:41:41 +00:00
parent e74683075a
commit 342a9fcc0e
8 changed files with 563 additions and 92 deletions

View File

@ -69,6 +69,9 @@ public class BuilderService {
executeDump(true);
// ADD OTHER SERVICE
addCustomMenu( "Forma", "Transcations");
System.out.println("dashboard and menu inserted...");

View File

@ -0,0 +1,82 @@
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<Forma> getall(@RequestParam(value = "page", required = false) Integer page,
@RequestParam(value = "size", required = false) Integer size) {
Pageable paging = PageRequest.of(page, size);
Page<Forma> get = Service.getAllWithPagination(paging);
return get;
}
@GetMapping("/Forma")
public List<Forma> getdetails() {
List<Forma> get = Service.getdetails();
return get;
}
// get all without authentication
@GetMapping("/token/Forma")
public List<Forma> getallwioutsec() {
List<Forma> 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);
}
}

View File

@ -0,0 +1,29 @@
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 namem;
private int decimals;
}

View File

@ -0,0 +1,19 @@
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<Forma, Integer> {
}

View File

@ -0,0 +1,68 @@
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;
public Forma Savedata(Forma data) {
Forma save = Repository.save(data);
return save;
}
// get all with pagination
public Page<Forma> getAllWithPagination(Pageable page) {
return Repository.findAll(page);
}
public List<Forma> getdetails() {
return (List<Forma>) 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.setNamem(data.getNamem());
old.setDecimals(data.getDecimals());
final Forma test = Repository.save(old);
return test;}
public AppUser getUser() {
AppUser user = userService.getLoggedInUser();
return user;
}}

View File

@ -0,0 +1,2 @@
CREATE TABLE db.Forma(id BIGINT NOT NULL AUTO_INCREMENT, Namem VARCHAR(400), Decimals VARCHAR(400), PRIMARY KEY (id));

View File

@ -0,0 +1,263 @@
<template>
<div class="container mt-4">
<button class="btn btn-success mb-3" @click="openAddDialog">
Add New Item
</button>
<table class="table table-striped">
<thead class="table-light">
<tr>
<th scope="col">Namem</th>
<th scope="col">Decimals</th>
</tr>
</thead>
<tbody>
<tr v-for="item in paginatedData" :key="item.id">
<td>{{ item.namem }}</td>
<td>{{ item.decimals }}</td>
<td>
<button class="btn btn-primary btn-sm" @click="openDialog(item)">
Update
</button>
<button
class="btn btn-danger btn-sm ms-2"
@click="deleteItem(item.id)"
>
Delete
</button>
</td>
</tr>
</tbody>
</table>
<!-- Pagination Controls -->
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item" :class="{ disabled: currentPage === 1 }">
<a
class="page-link"
href="#"
@click.prevent="changePage(currentPage - 1)"
>Previous</a
>
</li>
<li
class="page-item"
v-for="page in totalPages"
:key="page"
:class="{ active: page === currentPage }"
>
<a class="page-link" href="#" @click.prevent="changePage(page)">{{
page
}}</a>
</li>
<li class="page-item" :class="{ disabled: currentPage === totalPages }">
<a
class="page-link"
href="#"
@click.prevent="changePage(currentPage + 1)"
>Next</a
>
</li>
</ul>
</nav>
<!-- Form Dialog -->
<div
v-if="dialogVisible"
class="modal fade show"
tabindex="-1"
style="display: block"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
{{ isEditMode ? "Edit Item" : "Add Item" }}
</h5>
<button
type="button"
class="btn-close"
@click="closeDialog"
></button>
</div>
<div class="modal-body">
<form @submit.prevent="submitForm">
<div class="mb-3">
<label for="namem" class="form-label">Namem</label>
<input
v-model="currentItem.namem"
type="text"
class="form-control"
id="namem"
required
/>
</div>
<div class="form-group">
<label for="decimals">Decimals</label>
<input type="number" class="form-control" id="decimals" v-model="currentItem.decimals" required>
</div>
<button type="submit" class="btn btn-primary">
{{ isEditMode ? "Save changes" : "Add Item" }}
</button>
</form>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, computed } from "vue";
const API_URL = `${
import.meta.env.VITE_APP_API_URL
}/Forma/Forma`;
const token = localStorage.getItem("token");
console.log("hii", token);
const data = ref([]);
const currentItem = ref({
namem: "",
decimals: "",
});
const dialogVisible = ref(false);
const isEditMode = ref(false);
const currentPage = ref(1);
const itemsPerPage = 10;
const fetchData = async () => {
try {
const response = await fetch(API_URL, {
headers: {
Authorization: `Bearer ${token}`,
},
});
const result = await response.json();
// Ensure data is an array
if (Array.isArray(result)) {
data.value = result;
} else {
console.error("Error: Fetched data is not an array");
} } catch (error) {
console.error("Error fetching data:", error);
}
};
const paginatedData = computed(() => {
const start = (currentPage.value - 1) * itemsPerPage;
const end = start + itemsPerPage;
return Array.isArray(data.value) ? data.value.slice(start, end) : [];});
const totalPages = computed(() => {
return Array.isArray(data.value)
? Math.ceil(data.value.length / itemsPerPage)
: 0;});
const changePage = (page) => {
if (page > 0 && page <= totalPages.value) {
currentPage.value = page;
}
};
const openDialog = (item) => {
currentItem.value = { ...item };
isEditMode.value = true;
dialogVisible.value = true;
};
const openAddDialog = () => {
currentItem.value = {
namem: "",
decimals: "",
};
isEditMode.value = false;
dialogVisible.value = true;
};
const closeDialog = () => {
dialogVisible.value = false;
};
const submitForm = async () => {
if (isEditMode.value) {
// Update item
try {
await fetch(`${API_URL}/${currentItem.value.id}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify(currentItem.value),
});
closeDialog();
await fetchData();
} catch (error) {
console.error("Error updating item:", error);
}
} else {
// Add new item
try {
await fetch(API_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify(currentItem.value),
});
closeDialog();
await fetchData();
} catch (error) {
console.error("Error adding item:", error);
}
}
};
const deleteItem = async (id) => {
if (confirm("Are you sure you want to delete this item?")) {
try {
await fetch(`${API_URL}/${id}`, {
method: "DELETE",
headers: {
Authorization: `Bearer ${token}`,
},
});
await fetchData();
} catch (error) {
console.error("Error deleting item:", error);
}
}
};
onMounted(fetchData);
</script>
<style scoped>
/* No custom styles, relying on Bootstrap */
</style>

View File

@ -1,92 +1,97 @@
import { createRouter, createWebHistory } from "vue-router";
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: "/home",
component: () => import("../views/Home.vue"),
},
{
path: "/dashboard",
component: () => import("../views/Dashboard.vue"),
},
{
path: "/report",
component: () => import("../views/Report.vue"),
},
{
path: "/setup",
component: () => import("../views/Setup.vue"),
},
{
path: "/login",
component: () => import("../components/Login/LoginComponent.vue"),
},
{
path: "/",
component: () => import("../components/Login/LoginComponent.vue"),
},
{
path: "/createacc",
component: () => import("../components/Login/CreateAccount.vue"),
},
{
path: "/forgetPassword",
component: () => import("../components/Login/ResetPassword.vue"),
},
{
path: "/usermaintenance",
component: () => import("../views/setupTools/UserMaintenance.vue"),
},
{
path: "/userGroupmaintenance",
component: () => import("../views/setupTools/UserGroupMaintenance.vue"),
},
{
path: "/menumaintenance",
component: () => import("../views/setupTools/MenuMaintance.vue"),
},
{
path: "/menuaccesscontrol",
component: () => import("../views/setupTools/MenuAccessControl.vue"),
},
// {
// path: "/systemparameter",
// component: () => import("../views/setupTools/SystemParameter.vue"),
// },
{
path: "/accesstype",
component: () => import("../views/setupTools/AccessType.vue"),
},
{
path: "/documentsequence",
component: () => import("../views/setupTools/DocumentSequence.vue"),
},
// {
// path: "/reports",
// component: () => import("../views/setupTools/Reports.vue"),
// },
{
path: "/dashboardescription",
component: () => import("../views/setupTools/DashboardDescription.vue"),
},
// {
// path: "/reportbuildersql",
// component: () => import("../views/reportbuilder/ReportBuilderSQL.vue"),
// },
// {
// path: "/reportbuilderurl",
// component: () => import("../views/reportbuilder/ReportBuilderURL.vue"),
// },
// buildercomponents
{
path: "/datfolder",
component: () => import("../components/BuilderComponents/Test/DataTable.vue"),
},
],
});
export default router;
import { createRouter, createWebHistory } from "vue-router";
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: "/home",
component: () => import("../views/Home.vue"),
},
{
path: "/dashboard",
component: () => import("../views/Dashboard.vue"),
},
{
path: "/report",
component: () => import("../views/Report.vue"),
},
{
path: "/setup",
component: () => import("../views/Setup.vue"),
},
{
path: "/login",
component: () => import("../components/Login/LoginComponent.vue"),
},
{
path: "/",
component: () => import("../components/Login/LoginComponent.vue"),
},
{
path: "/createacc",
component: () => import("../components/Login/CreateAccount.vue"),
},
{
path: "/forgetPassword",
component: () => import("../components/Login/ResetPassword.vue"),
},
{
path: "/usermaintenance",
component: () => import("../views/setupTools/UserMaintenance.vue"),
},
{
path: "/userGroupmaintenance",
component: () => import("../views/setupTools/UserGroupMaintenance.vue"),
},
{
path: "/menumaintenance",
component: () => import("../views/setupTools/MenuMaintance.vue"),
},
{
path: "/menuaccesscontrol",
component: () => import("../views/setupTools/MenuAccessControl.vue"),
},
// {
// path: "/systemparameter",
// component: () => import("../views/setupTools/SystemParameter.vue"),
// },
{
path: "/accesstype",
component: () => import("../views/setupTools/AccessType.vue"),
},
{
path: "/documentsequence",
component: () => import("../views/setupTools/DocumentSequence.vue"),
},
// {
// path: "/reports",
// component: () => import("../views/setupTools/Reports.vue"),
// },
{
path: "/dashboardescription",
component: () => import("../views/setupTools/DashboardDescription.vue"),
},
// {
// path: "/reportbuildersql",
// component: () => import("../views/reportbuilder/ReportBuilderSQL.vue"),
// },
// {
// path: "/reportbuilderurl",
// component: () => import("../views/reportbuilder/ReportBuilderURL.vue"),
// },
// buildercomponents
{
path: "/Forma",
component: () => import("../components/BuilderComponents/basicp1/Forma/Forma.vue"),
},
{
path: "/datfolder",
component: () => import("../components/BuilderComponents/Test/DataTable.vue"),
},
],
});
export default router;