build_app

This commit is contained in:
risadmin_prod 2024-09-02 07:08:56 +00:00
parent 9bc518c905
commit 67993982b0
18 changed files with 867 additions and 0 deletions

View File

@ -68,6 +68,9 @@ public class BuilderService {
public void callotherService() { public void callotherService() {
// ADD OTHER SERVICE // ADD OTHER SERVICE
addCustomMenu( "Form", "Transcations");
executeDump(true, "dump.sql"); executeDump(true, "dump.sql");

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.Form;
import com.realnet.basicp1.Services.FormService ;
@RequestMapping(value = "/Form")
@CrossOrigin("*")
@RestController
public class FormController {
@Autowired
private FormService Service;
@Value("${projectPath}")
private String projectPath;
@PostMapping("/Form")
public Form Savedata(@RequestBody Form data) {
Form save = Service.Savedata(data) ;
System.out.println("data saved..." + save);
return save;
}
@PutMapping("/Form/{id}")
public Form update(@RequestBody Form data,@PathVariable Integer id ) {
Form update = Service.update(data,id);
System.out.println("data update..." + update);
return update;
}
// get all with pagination
@GetMapping("/Form/getall/page")
public Page<Form> getall(@RequestParam(value = "page", required = false) Integer page,
@RequestParam(value = "size", required = false) Integer size) {
Pageable paging = PageRequest.of(page, size);
Page<Form> get = Service.getAllWithPagination(paging);
return get;
}
@GetMapping("/Form")
public List<Form> getdetails() {
List<Form> get = Service.getdetails();
return get;
}
// get all without authentication
@GetMapping("/token/Form")
public List<Form> getallwioutsec() {
List<Form> get = Service.getdetails();
return get;
}
@GetMapping("/Form/{id}")
public Form getdetailsbyId(@PathVariable Integer id ) {
Form get = Service.getdetailsbyId(id);
return get;
}
@DeleteMapping("/Form/{id}")
public void delete_by_id(@PathVariable Integer id ) {
Service.delete_by_id(id);
}
}

View File

@ -0,0 +1,30 @@
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 Form extends Extension {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nameb;
@Column(length = 2000)
private String descriptionb;
}

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.Form;
@Repository
public interface FormRepository extends JpaRepository<Form, Integer> {
}

View File

@ -0,0 +1,68 @@
package com.realnet.basicp1.Services;
import com.realnet.basicp1.Repository.FormRepository;
import com.realnet.basicp1.Entity.Form;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 FormService {
@Autowired
private FormRepository Repository;
@Autowired
private AppUserServiceImpl userService;
public Form Savedata(Form data) {
Form save = Repository.save(data);
return save;
}
// get all with pagination
public Page<Form> getAllWithPagination(Pageable page) {
return Repository.findAll(page);
}
public List<Form> getdetails() {
return (List<Form>) Repository.findAll();
}
public Form getdetailsbyId(Integer id) {
return Repository.findById(id).get();
}
public void delete_by_id(Integer id) {
Repository.deleteById(id);
}
public Form update(Form data,Integer id) {
Form old = Repository.findById(id).get();
old.setNameb(data.getNameb());
old.setDescriptionb(data.getDescriptionb());
final Form test = Repository.save(old);
return test;}
public AppUser getUser() {
AppUser user = userService.getLoggedInUser();
return user;
}}

View File

@ -0,0 +1,2 @@
CREATE TABLE db.Form(id BIGINT NOT NULL AUTO_INCREMENT, Descriptionb VARCHAR(400), Nameb VARCHAR(400), PRIMARY KEY (id));

View File

@ -0,0 +1,95 @@
<div class="dg-wrapper">
<div class="row">
<div class="col-2">
<h3>Form </h3>&nbsp;
</div>
<div class="col-6">
<div class="input-group " style="width: 40%; margin-bottom: 10px;">
<span class="input-group-text" id="basic-addon2"><i class="bi bi-search"></i></span>
<input placeholder="Search" type="text" name="searchFilter" [(ngModel)]="searchFilter" class="form-control" aria-label="Recipient's username" aria-describedby="basic-addon2">
</div>
</div> <div class="col-4" style="text-align: right;">
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-primary" (click)="goToAdd()">Add</button>
</div>
</div>
</div>
<div style="max-height: 500px; overflow: auto;">
<table class="table">
<thead class="table-primary">
<tr>
<th>Nameb</th>
<th>Descriptionb</th>
<th>Action</th> </tr>
</thead>
<tbody>
<tr *ngFor="let data of givendata?.slice()?.reverse() | filter:searchFilter; let i = index">
<td>{{data.nameb}}</td>
<td (click)="goToReplaceStringdescriptionb(data.descriptionb)" data-bs-toggle="modal" data-bs-target="#descriptionbModal" style="cursor: pointer; align-items: center;"><i class="bi bi-card-text"></i></td>
<td><i class="bi bi-pencil" style="cursor: pointer; padding-right: 10px"(click)="goToEdit(data.id)"></i><i class="bi bi-trash" style="cursor: pointer;" data-bs-toggle="modal" data-bs-target="#deleteModal" (click)="onDelete(data)"></i></td>
</tr>
</tbody>
</table></div>
</div>
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" data-bs-backdrop="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" *ngIf="rowSelected.id">
<h5 class="modal-title" id="exampleModalLabel">Delete</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Are You Sure Want to delete?</p>
<h2 class="heading">{{rowSelected.id}}</h2>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" (click)="delete(rowSelected.id)">Delete</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="descriptionbModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<textarea class="form-control" style="width:100%; height: 400px;" readonly>{{rowSelected}}</textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,4 @@
.delete,.heading{
text-align: center;
color: red;
}

View File

@ -0,0 +1,107 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import * as moment from 'moment';
import * as bootstrap from 'bootstrap';
import { FormService } from './Form.service';
import { ToastrService } from 'ngx-toastr';
@Component({
selector: 'app-Form',
templateUrl: './Form.component.html',
styleUrls: ['./Form.component.scss']
})
export class FormComponent implements OnInit {
loading = false;
loading1=false;
public entryForm: FormGroup;
givendata;
orders;
modalAdd= false;
modaledit=false;
mcreate;
medit;
mdelete;
showdata;
error;
modaldelete=false;
rowSelected :any= {};
searchFilter;
constructor(
private _fb: FormBuilder,
private router: Router, private toastr:ToastrService,
private route: ActivatedRoute,
private mainservice:FormService,
) {this.loading1 = true;
setTimeout(() => {
this.loading1 = false;
}, 1000); }
ngOnInit(): void {
this.getData();
}
getData(){
this.mainservice.getAll().subscribe((data) => {
console.log(data);
this.givendata = data;
if(this.givendata.length==0){
this.error="No data Available";
console.log(this.error)
}
},(error) => {
console.log(error);
if(error){
this.error="Server Error";
}
});
}
goToAdd() {
this.router.navigate(["../Formadd"],{relativeTo:this.route});
}
goToEdit(id: any){
this.router.navigate(["../Formedit/"+ id], { relativeTo: this.route });
}
onDelete(row) {
this.rowSelected = row;
this.modaldelete=true;
}
delete(id)
{
this.modaldelete = false;
console.log("in delete "+id);
this.mainservice.deleteusr(id).subscribe(
(data) => {
console.log(data);
this.ngOnInit();
if (data == null || data) {
this.toastr.success('Deleted successfully');
}
},
(error) => {
console.log('Error in adding data...',+error);
if(error){
this.toastr.error('Not Deleted Data Getting Some Error');
}
}
);
}
goToReplaceStringdescriptionb(row){
this.modalissue.removeAllBackdrops();
this.rowSelected= row; }
}

View File

@ -0,0 +1,34 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiRequestService } from 'src/app/services/api/api-request.service';
import baseUrl from 'src/app/services/api/helper';
@Injectable({
providedIn: 'root'
})
export class FormService {
private baseURL = "Form/Form" ; constructor(private http: HttpClient, private apiRequest:ApiRequestService) { }
getAll(page?: number, size?: number): Observable<any> {
return this.apiRequest.get(this.baseURL);
}
getbyid(id: number): Observable<any> {
const _http = this.baseURL + "/" + id;
return this.apiRequest.get(_http);
}
create(data: any): Observable<any> {
return this.apiRequest.post(this.baseURL, data);
}
updatenew(id: number, data: any): Observable<any> {
const _http = this.baseURL + "/" + id;
return this.apiRequest.put(_http, data);
}
deleteusr(id: number): Observable<any> {
const _http = this.baseURL + "/" + id;
return this.apiRequest.delete(_http);
}
// updateaction
}

View File

@ -0,0 +1,42 @@
<h4 style="font-weight: 500;display: inline;"> Form</h4>
<span class="label label-light-blue" style="display: inline;margin-left: 30px;">Add Mode</span>
<br>
<hr>
<div class="main" >
<form [formGroup]="entryForm">
<div class="row"><div class="col-md-4 col-sm-12">
<label for="name"> nameb </label>
<input type="text" class="input" formControlName="nameb" >
<div *ngIf="submitted && entryForm.controls.nameb.errors" class="error_mess">
<div *ngIf="submitted && entryForm.controls.nameb.errors.required" class="error_mess">*This field is Required</div>
</div>
</div>
<div class="col-md-4 col-sm-12">
<label> descriptionb</label>
<textarea cols="10" rows="2" formControlName="descriptionb" placeholder="Textarea"> </textarea>
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-outline" (click)="goback()">Cancel</button>
<button type="submit" class="btn btn-primary" (click)="onSubmit()">ADD</button>
</div>
</div>

View File

@ -0,0 +1,63 @@
input[type=text],[type=date],[type=password],[type=number],[type=email],[type=url],[type=datetime-local],textarea {
width: 100%;
padding: 5px 20px;
// margin: 3px 0;
background-color:rgb(255, 255, 255);
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.required-field{
color: red;
font-size: 18px;
}
.green{
background-color: rgb(156, 231, 156);
color: black;
}
.blue{
background-color: #57abcf;//rgb(82, 87, 161);
color: black;
}
.td-title {
text-align: center;
width: 150px;
color: white;
font-weight: bold;
background-color: rgba(63, 122, 231, 0.863);
//color: rgb(24, 13, 13);
}
th{
background-color:rgb(170, 169, 169);
font-weight: bold;
}
.td-content{
text-align: left;
}
.delete,.heading{
text-align: center;
color: red;
}
.section p {
background-color: rgb(206, 201, 201);
padding: 10px;
font-size: 18px;
}
select{
width: 100%;
padding: 5px 5px;
border: 1px solid #ccc;
border-radius: 4px;
}
input.ng-invalid.ng-touched {
border-color: red;
}
.error_mess {
color: red;
}

View File

@ -0,0 +1,105 @@
import { Component, OnInit } from '@angular/core';
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { AbstractControl, ValidationErrors } from '@angular/forms';
declare var JsBarcode: any;
import { AccesstypeService } from 'src/app/services/admin/accesstype.service';
import { FormService } from '../Form.service';
@Component({
selector: 'app-Formadd',
templateUrl: './Formadd.component.html',
styleUrls: ['./Formadd.component.scss']
})
export class FormaddComponent implements OnInit {
public entryForm: FormGroup;
loading = false;
tableName = 'Form';
error;
submitted=false;
constructor(private _fb: FormBuilder,
private mainservice:FormService,
private router: Router,private accesstype:AccesstypeService,
private route: ActivatedRoute,
private toastr: ToastrService ) { }
ngOnInit(): void {
this.entryForm = this._fb.group({
nameb :[null],
descriptionb :[null],
});
}
givendata;
getData(){
this.mainservice.getAll().subscribe((data) => {
console.log(data);
this.givendata = data;
},(error) => {
console.log(error);
});
}
onSubmit(){
this.submitted=true
if (this.entryForm.invalid) {
return;
}
console.log(this.entryForm.value);
this.mainservice.create(this.entryForm.value).subscribe(data => {
console.log(data)
if (data || data.status >= 200 && data.status <= 299) {
this.toastr.success("Added Successfully");
}
},
(error) => {
console.log(error);
if (error.status >= 200 && error.status <= 299) {
// this.toastr.success("Added Succesfully");
}
if (error.status >= 400 && error.status <= 499) {
this.toastr.error("Not Added");
}
if (error.status >= 500 && error.status <= 599) {
this.toastr.error("Not Added");
}
});
this.router.navigate(["../Form"], { relativeTo: this.route });
}
goback(){
this.router.navigate(["../Form"], { relativeTo: this.route });
}
}

View File

@ -0,0 +1,38 @@
<h4 style="font-weight: 500;display: inline;">table_name</h4>
<span class="label label-light-blue" style="display: inline;margin-left: 30px;">Edit Mode</span>
<br>
<hr>
<div class="main" >
<form *ngIf="data1">
<div class="row">
<div class="col-md-4 col-sm-12">
<label for="name"> nameb</label>
<input type="text" class="input" name="nameb" [(ngModel)]="data1.nameb" >
</div>
<div class="col-md-4 col-sm-12">
<label> descriptionb</label>
<textarea cols="10" rows="2" [(ngModel)]="data1.descriptionb" name="descriptionb " placeholder="Textarea"> </textarea>
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-outline" (click)="goback()">Close</button>
<button type="button" class="btn btn-primary" (click)="update()">Update</button>
</div>
</div>

View File

@ -0,0 +1,55 @@
input[type=text],[type=date],[type=password],[type=number],[type=email],[type=url],[type=datetime-local],textarea {
width: 100%;
padding: 5px 20px;
// margin: 3px 0;
background-color:rgb(255, 255, 255);
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.required-field{
color: red;
font-size: 18px;
}
.green{
background-color: rgb(156, 231, 156);
color: black;
}
.blue{
background-color: #57abcf;//rgb(82, 87, 161);
color: black;
}
.td-title {
text-align: center;
width: 150px;
color: white;
font-weight: bold;
background-color: rgba(63, 122, 231, 0.863);
//color: rgb(24, 13, 13);
}
th{
background-color:rgb(170, 169, 169);
font-weight: bold;
}
.td-content{
text-align: left;
}
.delete,.heading{
text-align: center;
color: red;
}
.section p {
background-color: rgb(206, 201, 201);
padding: 10px;
font-size: 18px;
}
select{
width: 100%;
padding: 5px 5px;
border: 1px solid #ccc;
border-radius: 4px;
}

View File

@ -0,0 +1,96 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { AbstractControl, ValidationErrors } from '@angular/forms';
declare var JsBarcode: any;
import { FormService } from '../Form.service';
@Component({
selector: 'app-Formedit',
templateUrl: './Formedit.component.html',
styleUrls: ['./Formedit.component.scss']
})
export class FormeditComponent implements OnInit {
id:number;
data1:any={};
loading = false;
tableName = 'Form';
error;
constructor( private route:ActivatedRoute,
private mainservice:FormService,
private router: Router,
private toastr: ToastrService, ) { }
ngOnInit(): void {
this.id = this.route.snapshot.params["id"];
console.log("update with id = ", this.id);
this.getById(this.id);
//
}
givendata;
getData(){
this.mainservice.getAll().subscribe((data) => {
console.log(data);
this.givendata = data;
},(error) => {
console.log(error);
});
}
getById(id:number){
this.mainservice.getbyid(id).subscribe((data)=>{
this.data1=data;
console.log(this.data1);
});
}
update(){
console.log(this.data1);
this.mainservice.updatenew(this.id,this.data1).subscribe((data)=>{
console.log(data); if (data || data.status >= 200 && data.status <= 299) {
this.toastr.success("Update Successfully");
}
this.router.navigate(["../../Form"], { relativeTo: this.route });
},(error)=>{
console.log(error); if (error.status >= 200 && error.status <= 299) {
// this.toastr.success("update Succesfully");
}
if (error.status >= 400 && error.status <= 499) {
this.toastr.error("Not Updated");
}
if (error.status >= 500 && error.status <= 599) {
this.toastr.error("Not Updated");
}
});
}
goback(){
this.router.navigate(["../../Form"], { relativeTo: this.route });
}
}

View File

@ -1,3 +1,6 @@
import { FormeditComponent } from './BuilderComponents/basicp1/Form/Formedit/Formedit.component';
import { FormaddComponent } from './BuilderComponents/basicp1/Form/Formadd/Formadd.component';
import { FormComponent } from './BuilderComponents/basicp1/Form/Form.component';
import { Component, NgModule } from '@angular/core'; import { Component, NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
@ -103,6 +106,15 @@ const routes: Routes = [
}, },
// buildercomponents // buildercomponents
{path:'Formedit/:id',component:FormeditComponent},
{path:'Formadd',component:FormaddComponent},
{path:'Form',component:FormComponent},
{ {

View File

@ -1,3 +1,6 @@
import { FormeditComponent } from './BuilderComponents/basicp1/Form/Formedit/Formedit.component';
import { FormaddComponent } from './BuilderComponents/basicp1/Form/Formadd/Formadd.component';
import { FormComponent } from './BuilderComponents/basicp1/Form/Form.component';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
@ -99,6 +102,15 @@ import { SearchFilterPipe } from 'src/app/pipes/search-filter.pipe';
MenumaintanceComponent, OauthComponent, QueryComponent, SubmenuComponent, AccesstypeComponent, ModulesComponent, SessionloggerComponent, LogreaderComponent, ExceptionComponent, AuditreportComponent, AudithistoryComponent, MenumaintanceComponent, OauthComponent, QueryComponent, SubmenuComponent, AccesstypeComponent, ModulesComponent, SessionloggerComponent, LogreaderComponent, ExceptionComponent, AuditreportComponent, AudithistoryComponent,
// buildercomponents // buildercomponents
FormeditComponent,
FormaddComponent,
FormComponent,