build_app

This commit is contained in:
risadmin_prod 2024-09-18 09:57:37 +00:00
parent bf737eeafb
commit 5cefdff561
8 changed files with 68 additions and 351 deletions

View File

@ -35,6 +35,8 @@ app.use(`${basePath}`, userRouter)
app.use(bodyParser.json())
// buildercomponents
const FormaRouter = require("./routes/basicp1/Forma.routes")
app.use("/Forma/Forma", FormaRouter)

View File

@ -65,11 +65,9 @@ const getUsersByUserId = async (req, res) => {
const createUser = async (req, res) => {
const body = req.body
try {
const params = [ body.namem,
const params = [ body.percentages,
body.filetest,
body.imagtest,
body.recaptchat,
]
@ -81,11 +79,9 @@ body.imagtest,
await executeQuery(
`
INSERT INTO forma
SET namem = ?,
SET percentages = ?,
filetest = ?,
imagtest = ?
recaptchat = ?
`,
sanitizedParams
@ -110,11 +106,9 @@ const updateUsers = async (req, res) => {
try {
// Ensure that required parameters exist and replace undefined with null
const params = [body.namem,
const params = [body.percentages,
body.filetest,
body.imagtest,
body.recaptchat,
id,
];
@ -124,11 +118,9 @@ body.imagtest,
const results = await executeQuery(
`
UPDATE forma
SET namem = ?,
SET percentages = ?,
filetest = ?,
imagtest = ?
recaptchat = ?
WHERE id = ?
`,

View File

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

View File

@ -23,12 +23,12 @@
<div *ngIf="error;else loadingSpinner">{{error}}</div>
</clr-dg-placeholder>
<clr-dg-column [clrDgField]="' namem'"> <ng-container *clrDgHideableColumn="{hidden: false}"> Namem
<clr-dg-column [clrDgField]="' percentages'"> <ng-container *clrDgHideableColumn="{hidden: false}"> Percentages
</ng-container></clr-dg-column>
<clr-dg-column [clrDgField]="' recaptchat'"> <ng-container *clrDgHideableColumn="{hidden: false}"> recaptchat
</ng-container></clr-dg-column>
<!-- who column -->
@ -39,11 +39,10 @@
<clr-dg-row *clrDgItems="let user of product" [clrDgItem]="user">
<clr-dg-cell>{{user. namem }}</clr-dg-cell>
<clr-dg-cell>{{user. percentages }}</clr-dg-cell>
<clr-dg-cell>{{user. recaptchat }}</clr-dg-cell>
<!-- who column -->
@ -201,16 +200,12 @@
<!-- // EDIT DATA......... -->
<clr-modal [(clrModalOpen)]="modalEdit" [clrModalSize]="'lg'" [clrModalStaticBackdrop]="true">
<h3 class="modal-title">Update Forma
</h3>
<div class="modal-body" *ngIf="rowSelected.id">
<h2 class="heading">{{rowSelected.id}}</h2>
@ -218,100 +213,23 @@
<form >
<div class="clr-row">
<div class="clr-col-sm-12">
<label>Namem</label>
<input class="clr-input" type="text" [(ngModel)]="rowSelected.namem" name="namem" />
<label>Percentages</label>
<input id="name" class="clr-input" type="number" [(ngModel)]="rowSelected.percentages" name="percentages" />
</div>
<div class="clr-col-sm-12">
<label> recaptchat</label> <div><b>{{ recaptchatCode }}</b> &nbsp; <button class="btn btn-icon btn-primary btn-sm" (click)="generaterecaptchat()">
<clr-icon shape="refresh"></clr-icon> </button></div>
<input type="text" name="recaptchat" [(ngModel)]="rowSelected.recaptchat" (ngModelChange)="checkrecaptchatEdit()" class="clr-input">
<div *ngIf=" recaptchatMismatch" class="error_mess">
<div class="error_mess"> recaptchat not valid.</div>
</div>
</div>
</div>
<h6> List of filetest</h6>
<div class="clr-row" style="margin-top: 10px;">
<table class="table">
<thead>
<tr>
<th>No</th>
<th> File</th>
<th>File Name</th>
<th>Preview</th>
<th>Cancel</th>
</tr>
</thead>
<tbody >
<tr *ngFor="let attach of FileDatafiletest; let i=index">
<td style="width: 70px;"><input type="text" class="clr-input" value={{i+1}} [readonly]="true"> </td>
<td><input type="file" (change)="onFileChangedfiletest($event, i)" accept = "application/pdf,.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"/>
</td>
<td>{{attach.uploadedfile_name}}</td>
<td > <img [src]="attach.filePreview" alt="File Preview" [ngModelOptions]="{standalone: true}" name="filePreview" width="100px" height="100px"></td>
<td>
<clr-signpost style="padding-right: 10px;">
<clr-icon shape="trash" class="is-error" aria-label="Icon Button Trigger" clrSignpostTrigger></clr-icon>
<clr-signpost-content [clrPosition]="'bottom-middle'" *clrIfOpen>
<div style="text-align: center;"><b >Are you sure?</b></div>
<button class="btn btn-outline" [clrSignpostTrigger]="false">cancel</button>&nbsp;
<button class="btn btn-primary" (click)="deleteRowfiletest(i,attach.id)" >Delete</button>
</clr-signpost-content>
</clr-signpost>
</td>
</tr>
</tbody>
<button type="button" class="btn btn-primary button1" style="margin-left: 20px;" (click)="onAddLinesfiletest()">
<clr-icon shape="plus"></clr-icon>
</button>
</table> </div>
<h6> List of imagtest</h6>
<div class="clr-row" style="margin-top: 10px;">
<table class="table">
<thead>
<tr>
<th>No</th>
<th> File</th>
<th>File Name</th>
<th>Preview</th>
<th>Cancel</th>
</tr>
</thead>
<tbody >
<tr *ngFor="let attach of FileDataimagtest; let i=index">
<td style="width: 70px;"><input type="text" class="clr-input" value={{i+1}} [readonly]="true"> </td>
<td><input type="file" (change)="onFileChangedimagtest($event, i)" accept="image/*" />
</td>
<td>{{attach.uploadedfile_name}}</td>
<td > <img [src]="attach.filePreview" alt="File Preview" [ngModelOptions]="{standalone: true}" name="filePreview" width="100px" height="100px"></td>
<td>
<clr-signpost style="padding-right: 10px;">
<clr-icon shape="trash" class="is-error" aria-label="Icon Button Trigger" clrSignpostTrigger></clr-icon>
<clr-signpost-content [clrPosition]="'bottom-middle'" *clrIfOpen>
<div style="text-align: center;"><b >Are you sure?</b></div>
<button class="btn btn-outline" [clrSignpostTrigger]="false">cancel</button>&nbsp;
<button class="btn btn-primary" (click)="deleteRowimagtest(i,attach.id)" >Delete</button>
</clr-signpost-content>
</clr-signpost>
</td>
</tr>
</tbody>
<button type="button" class="btn btn-primary button1" style="margin-left: 20px;" (click)="onAddLinesimagtest()">
<clr-icon shape="plus"></clr-icon>
</button>
</table> </div>
<!-- form code start -->
<div *ngIf="checkFormCode">
@ -361,8 +279,6 @@
<!-- aeroplane icon -->
&nbsp; &nbsp; &nbsp; &nbsp;
<a *ngIf="userrole.includes('ROLE_ADMIN')" style="float: right;" href="javascript:void(0)" role="tooltip" aria-haspopup="true"
@ -377,87 +293,27 @@
<div class="clr-row" style="height: fit-content;">
<div class="clr-col-sm-12">
<label> Namem</label>
<input class="clr-input" type="text" formControlName="namem" />
<label> Percentages</label>
<input class="clr-input" type="number" formControlName="percentages" />
<div *ngIf="submitted && entryForm.controls.percentages.errors" class="error_mess">
<div *ngIf="submitted && entryForm.controls.percentages.errors.required" class="error_mess">*This field is Required</div>
</div>
</div>
<div class="clr-col-sm-12">
<label> recaptchat</label><div><b>{{ recaptchatCode }}</b> &nbsp; <button class="btn btn-icon btn-primary btn-sm" (click)="generaterecaptchat()"><clr-icon shape="refresh"></clr-icon></button></div>
<input type="text" formControlName="recaptchat" class="clr-input">
<div *ngIf="submitted && entryForm.controls.recaptchat.errors.required" class="error_mess">*This field is Required</div>
<div *ngIf="submitted && entryForm.get('recaptchat').errors && entryForm.get('recaptchat').dirty" class="error_mess">
<div *ngIf="submitted && entryForm.controls['recaptchat'].hasError('recaptchatMismatch')" class="error_mess"> recaptchat not valid.</div>
</div>
</div>
</div>
<h6> List of filetest</h6>
<div class="clr-row" style="margin-top: 10px;">
<table class="table">
<thead>
<tr>
<th>No</th>
<th> File</th>
<th>File Name</th>
<th>Preview</th>
<th>Cancel</th>
</tr>
</thead>
<tbody >
<tr *ngFor="let attach of FileDatafiletest; let i=index">
<td style="width: 70px;"><input type="text" class="clr-input" value={{i+1}} [readonly]="true"> </td>
<td><input type="file" (change)="onFileChangedfiletest($event, i)" accept = "application/pdf,.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" /><!--accept=".pdf,.doc,.docx,.jpg,.msg"-->
</td>
<td>{{attach.uploadedfile_name}}</td>
<td > <img [src]="attach.filePreview" alt="File Preview" [ngModelOptions]="{standalone: true}" name="filePreview" width="100px" height="100px"></td>
<td>
<a (click)="deleteRowfiletest(i)">
<clr-icon shape="trash" class="is-error"></clr-icon>
</a>
</td>
</tr>
</tbody>
<button type="button" class="btn btn-primary button1" style="margin-left: 20px;" (click)="onAddLinesfiletest()">
<clr-icon shape="plus"></clr-icon>
</button>
</table> </div>
<h6> List of imagtest</h6>
<div class="clr-row" style="margin-top: 10px;">
<table class="table">
<thead>
<tr>
<th>No</th>
<th> File</th>
<th>File Name</th>
<th>Preview</th>
<th>Cancel</th>
</tr>
</thead>
<tbody >
<tr *ngFor="let attach of FileDataimagtest; let i=index">
<td style="width: 70px;"><input type="text" class="clr-input" value={{i+1}} [readonly]="true"> </td>
<td><input type="file" (change)="onFileChangedimagtest($event, i)" accept="image/*" /><!--accept=".pdf,.doc,.docx,.jpg,.msg"-->
</td>
<td>{{attach.uploadedfile_name}}</td>
<td > <img [src]="attach.filePreview" alt="File Preview" [ngModelOptions]="{standalone: true}" name="filePreview" width="100px" height="100px"></td>
<td>
<a (click)="deleteRowimagtest(i)">
<clr-icon shape="trash" class="is-error"></clr-icon>
</a>
</td>
</tr>
</tbody>
<button type="button" class="btn btn-primary button1" style="margin-left: 20px;" (click)="onAddLinesimagtest()">
<clr-icon shape="plus"></clr-icon>
</button>
</table> </div>
@ -495,6 +351,4 @@
<!-- htmlpopup -->

View File

@ -63,19 +63,15 @@ private userInfoService:UserInfoService,
this.userrole=this.userInfoService.getRoles();
this.getData();
this.entryForm = this._fb.group({
namem : [null],
percentages : [null,[Validators.required]],
recaptchat : [null, [Validators.required,this.checkrecaptchat.bind(this)]],
}); // component_button200
// form code start
this.extensionService.getJsonObjectsByFormCodeList(this.formcode).subscribe(data => {
@ -100,9 +96,7 @@ namem : [null],
// form code end
this.generaterecaptchat()
}
@ -110,9 +104,6 @@ namem : [null],
FileDataImagtest: any[];
selectedImagtest: any[];
error;
getData() {
this.mainService.getAll().subscribe((data) => {
@ -132,19 +123,7 @@ FileDataImagtest: any[];
this.rowSelected = row;
this.selectedfiletest = [];
this.mainService.uploadfilegetByIdfiletest(row.id,this.tableName).subscribe(uploaddata =>{
console.log(uploaddata);
this.FileDatafiletest = uploaddata;
})
this.selectedimagtest = [];
this.mainService.uploadImagtestgetById(row.id,this.tableName).subscribe(uploaddata =>{
console.log(uploaddata);
this.FileDataimagtest = uploaddata;
})
this.modalEdit = true;
@ -170,8 +149,6 @@ FileDataImagtest: any[];
//console.log("in update");
console.log("id " + id);
console.log(this.rowSelected);
@ -185,19 +162,7 @@ FileDataImagtest: any[];
for (let i = 0; i < this.selectedfiletest.length; i++){
this.mainService.uploadfilefiletest(data.id,this.tableName,this.selectedfiletest[i]).subscribe(uploaddata =>{
console.log(uploaddata);
})
}
for (let i = 0; i < this.selectedimagtest.length; i++){
this.mainService.uploadImagtest(data.id,this.tableName,this.selectedimagtest[i]).subscribe(uploaddata =>{
console.log(uploaddata);
})
}
}, (error) => {
console.log(error);
@ -221,8 +186,6 @@ onCreate() {
this.mainService.create(this.entryForm.value).subscribe(
(data) => {
console.log(data);
@ -231,19 +194,7 @@ onCreate() {
}
for (let i = 0; i < this.selectedfiletest.length; i++){
this.mainService.uploadfilefiletest(data.id,this.tableName,this.selectedfiletest[i]).subscribe(uploaddata =>{
console.log(uploaddata);
})
}
for (let i = 0; i < this.selectedimagtest.length; i++){
this.mainService.uploadImagtest(data.id,this.tableName,this.selectedimagtest[i]).subscribe(uploaddata =>{
console.log(uploaddata);
})
}
}, (error) => {
@ -265,11 +216,7 @@ for (let i = 0; i < this.selectedimagtest.length; i++){
goToAdd(row) {
this.modalAdd = true; this.submitted = false;
this.FileDatafiletest = [];
this.selectedfiletest =[];
this.FileDataImagtest = [];
this.selectedImagtest =[];
}
@ -284,90 +231,34 @@ onSubmit() {
}
filePreviewfiletest: string | ArrayBuffer | null = null;
FileDatafiletest: {uploadedfile_name?:any, filePreview: string | ArrayBuffer | null }[] = []; // Initialize the array
selectedfiletest: File[]=[];
public onFileChangedfiletest(event, index) {
const files = event.target.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
this.FileDatafiletest[index].uploadedfile_name = files[i].name;
this.selectedfiletest.push(files[i]);
if (file.type.startsWith('file/')) {
const reader = new FileReader();
reader.onload = (e) => {
// Set the file preview source
const filePreview = e.target?.result as string;
this.FileDatafiletest[index] = {
...this.FileDatafiletest[index], // Preserve existing properties
filePreview: filePreview // Update only the filePreview property
};
};
reader.readAsDataURL(file);
}
recaptchatCode = '';
generaterecaptchat (): void {
const possibleCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const codeLength = 6; // Change to desired length
let recaptchat= '';
for (let i = 0; i < codeLength; i++) {
const randomIndex = Math.floor(Math.random() * possibleCharacters.length);
recaptchat += possibleCharacters.charAt(randomIndex);
}
this.recaptchatCode = recaptchat;
}
onAddLinesfiletest(){
this.FileDatafiletest.push({
uploadedfile_name: "",
filePreview: "",
// f3: "",
});
}
deleteRowfiletest(index,id) {
this.FileDatafiletest.splice(index, 1);
if(id){
this.mainService.uploadfiledeletefiletest(id).subscribe(data =>{
console.log(data);
})
}
}
filePreviewimagtest: string | ArrayBuffer | null = null;
FileDataimagtest: {uploadedfile_name?:any, filePreview: string | ArrayBuffer | null }[] = []; // Initialize the array
selectedimagtest: File[]=[];
public onFileChangedimagtest(event, index) {
const files = event.target.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
this.FileDataimagtest[index].uploadedfile_name = files[i].name;
this.selectedimagtest.push(files[i]);
if (file.type.startsWith('image/')) {
const reader = new FileReader();
reader.onload = (e) => {
// Set the file preview source
const filePreview = e.target?.result as string;
this.FileDataimagtest[index] = {
...this.FileDataimagtest[index], // Preserve existing properties
filePreview: filePreview // Update only the filePreview property
};
};
reader.readAsDataURL(file);
}
checkrecaptchat(control: AbstractControl): ValidationErrors | null {
if (control.value !== this.recaptchatCode) {
return { recaptchatMismatch: true };
}
}
onAddLinesimagtest(){
this.FileDataimagtest.push({
uploadedfile_name: "",
filePreview: "",
// f3: "",
});
}
deleteRowimagtest(index,id) {
this.FileDataimagtest.splice(index, 1);
return null;
}
if(id){
this.mainService.uploadImagtestdelete(id).subscribe(data =>{
console.log(data);
})
}
}
recaptchatMismatch = false;
checkrecaptchatEdit(): void {
if (this.rowSelected.recaptchat !== this. recaptchatCode) {
this. recaptchatMismatch = true; } else { this.recaptchatMismatch = false; } }
// updateaction
}

View File

@ -31,35 +31,7 @@ export class Formaservice{
}
uploadfilefiletest(ref:any, Forma:any, file:any): Observable<any>{
const formData = new FormData();
formData.append('file', file);
return this.apiRequest.postFormData(`FileUpload/Uploadeddocs/${ref}/${Forma}`, formData);
}
uploadfilegetByIdfiletest(ref:any, Forma:any,): Observable<any> {
return this.apiRequest.get(`FileUpload/Uploadeddocs/${ref}/${Forma}`);
}
uploadfiledeletefiletest(id: number): Observable<any> {
return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
}
uploadImagtest(ref:any, Forma:any, file:any): Observable<any>{
const formData = new FormData();
formData.append('file', file);
return this.apiRequest.postFormData(`FileUpload/Uploadeddocs/${ref}/${Forma}`, formData);
}
uploadImagtestgetById(ref:any, Forma:any,): Observable<any> {
return this.apiRequest.get(`FileUpload/Uploadeddocs/${ref}/${Forma}`);
}
uploadImagtestdelete(id: number): Observable<any> {
return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
}
// updateaction
}

View File

@ -1,3 +1,4 @@
import { FormaComponent } from './BuilderComponents/basicp1/Forma/Forma.component';
@ -241,6 +242,8 @@ children: [
// buildercomponents
{path:'Forma',component:FormaComponent},

View File

@ -1,3 +1,4 @@
import { FormaComponent } from './BuilderComponents/basicp1/Forma/Forma.component';
@ -143,6 +144,8 @@ import { MappingruleeditComponent } from './datamanagement/mappingrule/mappingru
// buildercomponents
FormaComponent,