merged code

This commit is contained in:
surendar.m@watermelon.us 2023-04-07 10:49:49 +05:30
commit c6937b7d70
10 changed files with 186 additions and 20667 deletions

20599
ng-seed/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,11 @@ export class TokenInterceptor implements HttpInterceptor {
let authReq:any; // get the token from local storage
if(token != '' && token != undefined && token != null){
authReq = req.clone({
headers: req.headers.set('x-access-token', token).set('Content-Type', 'application/json')
setHeaders: {
// 'Authorization': environment.authorization,
'x-access-token': token
}
// headers: req.headers.set('x-access-token', token).set('Content-Type', 'multipart/form-data')
});
}else{
authReq = req;

View File

@ -22,12 +22,17 @@ export class AddBusinessComponent implements OnInit {
local_data:any;
url: string | ArrayBuffer;
imageViewStatus: boolean = false;
formData: any=[];
selectedFiles: any;
currentFileUpload: any;
constructor(private router: Router,private formBuilder: FormBuilder,
public dialogRef: MatDialogRef<AddBusinessComponent>,
@Optional() @Inject(MAT_DIALOG_DATA) public data: UsersData) {
console.log(data);
this.local_data = {...data};
console.log(this.local_data)
this.action = this.local_data.action;
this.formData= new FormData();
}
get f(){
return this.form.controls;
@ -42,6 +47,8 @@ export class AddBusinessComponent implements OnInit {
}
onSelectFile(event) {
console.log(event.target.files[0])
const file = event.target.files[0];
if(event != null){
this.imageViewStatus = true
}
@ -55,6 +62,14 @@ export class AddBusinessComponent implements OnInit {
console.log(this.url)
}
}
// this.formData=[];
this.formData.append('image', file, file.name);
console.log(this.currentFileUpload)
// this.formData.append('file', file, file.name);
}
close() {
this.dialogRef.close();
@ -86,9 +101,25 @@ export class AddBusinessComponent implements OnInit {
submit(){
let tmp = this.form.value
tmp.id = this.local_data.id
this.dialogRef.close({event:this.action,data:tmp});
console.log(this.form.value);
console.log(this.action,this.local_data)
console.log(tmp)
// this.formData.append('image', this.currentFileUpload);
// console.log(this.formData.getAll('image'));
if(this.action == 'Update'){
this.formData.append('id', tmp.id);
this.formData.append('busId', this.local_data.busId);
}
this.formData.append('email', tmp.email);
this.formData.append('contactNo', tmp.contactNo);
this.formData.append('busName', tmp.busName);
this.formData.append('address', tmp.address);
this.formData.append('state', tmp.state);
this.formData.append('city', tmp.city);
console.log(this.formData)
this.dialogRef.close({event:this.action,data:this.formData});
// console.log(this.form.value);
// console.log(this.action,this.local_data)
}
}

View File

@ -17,14 +17,14 @@
<!-- ID Column -->
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef mat-sort-header> ID </mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.id}} </mat-cell>
<mat-header-cell *matHeaderCellDef mat-sort-header> S.No </mat-header-cell>
<mat-cell *matCellDef="let row; let i = index;"> {{i+1}} </mat-cell>
</ng-container>
<!-- Progress Column -->
<ng-container matColumnDef="logo">
<mat-header-cell *matHeaderCellDef mat-sort-header> Logo </mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.logo}} </mat-cell>
<mat-cell *matCellDef="let row"> <img [src]="image_view(row.logo)" /> </mat-cell>
</ng-container>
<!-- Name Column -->

View File

@ -9,6 +9,7 @@ import { DialogBoxComponent } from 'app/appoinment/appoinments/dialog-box/dialog
import Swal from 'sweetalert2/dist/sweetalert2.js';
import { AddBusinessComponent } from '../add-business/add-business.component';
import { BusinessService } from '../business-service/business.service';
import { environment } from 'environments/environment';
@Component({
selector: 'app-business-list',
@ -30,7 +31,7 @@ export class BusinessListComponent implements OnInit {
pageSize = 5;
pageEvent: PageEvent;
businessList: any[] = [];
private apiUrl = environment.apiEndpoint;
constructor(private notifierService: NotifierService,private router:Router,public dialog: MatDialog,public _bus:BusinessService) {
@ -123,6 +124,7 @@ export class BusinessListComponent implements OnInit {
})
}
openDialog(action,obj) {
console.log(obj)
obj.action = action;
const dialogRef = this.dialog.open(AddBusinessComponent, {
width: '30%',
@ -144,20 +146,20 @@ export class BusinessListComponent implements OnInit {
let formValue = []
if(result.event == 'Add'){
console.log('add')
let addFormData = {
address: row_obj.address,
image:row_obj.logo,
// busId: 'abc123',
city: row_obj.city,
busName: row_obj.busName,
email: row_obj.email,
contactNo: row_obj.contactNo,
// pincode: row_obj.pincode,
state: row_obj.state ,
createdBy:row_obj.createdBy
// workingHrsJson: row_obj.workingHrsJson
};
formValue.push(addFormData);
// let addFormData = {
// address: row_obj.address,
// image:row_obj.logo,
// // busId: 'abc123',
// city: row_obj.city,
// busName: row_obj.busName,
// email: row_obj.email,
// contactNo: row_obj.contactNo,
// // pincode: row_obj.pincode,
// state: row_obj.state ,
// createdBy:row_obj.createdBy
// // workingHrsJson: row_obj.workingHrsJson
// };
formValue.push(row_obj);
}else if(result.event == 'Update'){
console.log('Update',row_obj)
row_obj.image = row_obj.logo
@ -239,4 +241,9 @@ export class BusinessListComponent implements OnInit {
// console.log(this.dataSource)
// }
image_view(image){
return this.apiUrl+'imageViewer?img_name='+image;
}
}

View File

@ -20,12 +20,20 @@ export class BusinessService {
}
addFormDetails(addParams:any): Observable<any> {
return this._http.post(this.apiUrl + 'createBusinessDetails', addParams)
// .pipe(
// catchError(this.handleError('role', []))
// )
}
img_name(img_name:any): Observable<any> {
return this._http.get(this.apiUrl + 'imageViewer?img_name=', img_name)
// .pipe(
// catchError(this.handleError('role', []))
// )
}
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);

View File

@ -7,7 +7,7 @@
<form [formGroup]="form" (ngSubmit)="submit()">
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
<mat-label>Business</mat-label>
<input placeholder="Name" matInput formControlName="businessselect" readonly>
<input placeholder="Name" matInput formControlName="businessselect" >
<mat-error *ngIf="myError('businessselect', 'required')">Username is required</mat-error>
<mat-error *ngIf="myError('businessselect', 'maxlength')">Limit exceed</mat-error>
</mat-form-field>
@ -61,22 +61,25 @@
<mat-error *ngIf="myError('password', 'required')">Password is required</mat-error>
<mat-error *ngIf="myError('password', 'maxlength')">Limit exceed</mat-error>
</mat-form-field>
<img *ngIf="imageViewStatus == true" class="image mb-2" [src]="url" height="50" width="50">
<input type='file' (change)="onSelectFile($event)" formControlName="logo">
<!-- <mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
<input placeholder="ConfirmPassword" matInput formControlName="confirmPassword">
<mat-error *ngIf="myError('confirmPassword', 'required')">confirmPassword is required</mat-error>
<mat-error *ngIf="myError('confirmPassword', 'maxlength')">Limit exceed</mat-error>
</mat-form-field> -->
<div mat-dialog-actions>
<button mat-button type="submit" class="mat-green" mat-raised-button >{{action}}</button>
<button mat-button (click)="closeDialog()" >Cancel</button>
</div>
</form>
</div>
</ng-scrollbar>
<ng-template #elseTemplate>
Sure to delete <b>{{local_data.name}}</b>?
</ng-template><br>
<div mat-dialog-actions>
<button mat-button (click)="doAction()" class="mat-green" mat-raised-button >{{action}}</button>
<button mat-button (click)="closeDialog()" >Cancel</button>
</div>
</mat-card>

View File

@ -24,12 +24,15 @@ export class AddUserComponent implements OnInit {
url: string | ArrayBuffer;
businessList: any;
public role = [{'name':'BADMIN'},{'name':'PRACTITIONER'},{'name':'FRONTDESK'}]
imageViewStatus: boolean;
formData:any=[];
constructor(private router: Router,private formBuilder: FormBuilder,
public dialogRef: MatDialogRef<AddUserComponent>,
@Optional() @Inject(MAT_DIALOG_DATA) public data: UsersData,public _bus:BusinessService) {
console.log(data);
this.local_data = {...data};
this.action = this.local_data.action;
this.formData= new FormData();
this.getBusinessList()
}
@ -61,15 +64,7 @@ export class AddUserComponent implements OnInit {
closeDialog(){
this.dialogRef.close({event:'Cancel'});
}
onSelectFile(event) {
if (event.target.files && event.target.files[0]) {
var reader = new FileReader();
reader.readAsDataURL(event.target.files[0]);
reader.onload = (event) => {
this.url = event.target.result;
}
}
}
close() {
this.dialogRef.close();
}
@ -85,6 +80,7 @@ export class AddUserComponent implements OnInit {
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$',
),]),
password: new FormControl('', [Validators.required, Validators.minLength(6)]),
logo: new FormControl('', null),
// confirmPassword: new FormControl('', [Validators.required, Validators.minLength(6)]),
createdBy:new FormControl(userrole,[Validators.required]),
});
@ -96,13 +92,75 @@ export class AddUserComponent implements OnInit {
doAction(){
let tmp = this.form.value
tmp.id = this.local_data.id
console.log(this.formData.getAll('image'));
if(this.action == 'Update'){
this.formData.append('id', tmp.id);
this.formData.append('busId', this.local_data.busId);
}
this.formData.append('userName', tmp.userName);
this.formData.append('password', tmp.password);
this.formData.append('role', tmp.role);
this.formData.append('email', tmp.email);
this.formData.append('contactNo', tmp.contactNo);
this.formData.append('confirmPassword', tmp.password);
// tmp.confirmPassword = this.local_data.confirmPassword
this.dialogRef.close({event:this.action,data:tmp});
console.log(this.form.value);
this.dialogRef.close({event:this.action,data: this.formData});
console.log( this.formData,this.form.value);
console.log(this.action,this.local_data)
}
submit(){
console.log(this.form.value);
let tmp = this.form.value
tmp.id = this.local_data.id
console.log(this.formData.getAll('image'));
if(this.action == 'Update'){
this.formData.append('id', tmp.id);
this.formData.append('busId', this.local_data.busId);
}
this.formData.append('userName', tmp.userName);
this.formData.append('password', tmp.password);
this.formData.append('role', tmp.role);
this.formData.append('email', tmp.email);
this.formData.append('contactNo', tmp.contactNo);
this.formData.append('confirmPassword', tmp.password);
// tmp.confirmPassword = this.local_data.confirmPassword
this.dialogRef.close({event:this.action,data: this.formData});
console.log( this.formData,this.form.value);
console.log(this.action,this.local_data)
}
onSelectFile(event) {
console.log(event.target.files[0])
const file = event.target.files[0];
if(event != null){
this.imageViewStatus = true
}
if (event.target.files && event.target.files[0]) {
var reader = new FileReader();
reader.readAsDataURL(event.target.files[0]);
reader.onload = (event) => {
this.url = event.target.result;
console.log(this.url)
}
}
// this.formData= new FormData();
// this.formData=[];
this.formData.append('image', file, file.name);
// this.formData.append('file', file, file.name);
}
}

View File

@ -26,17 +26,20 @@
<th mat-header-cell *matHeaderCellDef class="font-color"> S.No</th>
<td mat-cell *matCellDef="let element" class="element-spc"> {{element.id}} </td>
</ng-container>
<ng-container matColumnDef="logo">
<th mat-header-cell *matHeaderCellDef class="font-color"> Logo </th>
<td mat-cell *matCellDef="let element"> <img [src]="image_view(element.logo)" /> </td>
</ng-container>
<ng-container matColumnDef="role">
<th mat-header-cell *matHeaderCellDef class="font-color"> Role </th>
<td mat-cell *matCellDef="let element"> {{element.role}} </td>
</ng-container>
<ng-container matColumnDef="logo">
<!-- <ng-container matColumnDef="logo">
<th mat-header-cell *matHeaderCellDef class="font-color"> Logo </th>
<td mat-cell *matCellDef="let element"> <img [src]="element.logo" /> </td>
</ng-container>
-->
<ng-container matColumnDef="Username">
<th mat-header-cell *matHeaderCellDef class="font-color"> User Name </th>
<td mat-cell *matCellDef="let element" class="element-spc"> {{element.userName}} </td>

View File

@ -7,6 +7,7 @@ import { NotifierService } from 'angular-notifier';
import Swal from 'sweetalert2/dist/sweetalert2.js';
import { AddUserComponent } from '../add-user/add-user.component';
import { UserService } from '../user-service/user.service';
import { environment } from 'environments/environment';
export interface UsersData {
id: number;
@ -42,13 +43,13 @@ const ELEMENT_DATA: UsersData[] = [
})
export class UserListComponent implements OnInit {
push: any;
displayedColumns: string[] = ['id', 'role', 'Username', 'Password', 'mobile_no', 'email', 'action'];
displayedColumns: string[] = ['id','logo', 'role', 'Username', 'Password', 'mobile_no', 'email', 'action'];
dataSource: any;
addFormData: any;
public usersList:any = new MatTableDataSource();
@ViewChild(MatTable,{static:true}) table: MatTable<any>;
@ViewChild(MatPaginator) paginator: MatPaginator;
private apiUrl = environment.apiEndpoint;
constructor(private notifierService: NotifierService,public dialog: MatDialog, public _use:UserService) {
let open_go_admin = localStorage.getItem('go_admin')
if(open_go_admin == '0'){
@ -161,31 +162,31 @@ export class UserListComponent implements OnInit {
let formValue = []
if(result.event == 'Add'){
console.log('add')
let addFormData = {
// logo: row_obj.logo,
// id: row_obj.id,
busId:row_obj.businessselect,
userName: row_obj.userName,
contactNo: row_obj.contactNo,
password: row_obj.password,
email: row_obj.email,
role: row_obj.role,
createdBy:row_obj.createdBy
};
formValue.push(addFormData);
// let addFormData = {
// // logo: row_obj.logo,
// // id: row_obj.id,
// busId:row_obj.businessselect,
// userName: row_obj.userName,
// contactNo: row_obj.contactNo,
// password: row_obj.password,
// email: row_obj.email,
// role: row_obj.role,
// createdBy:row_obj.createdBy
// };
formValue.push(row_obj);
}else if(result.event == 'Update'){
console.log('Update')
let updatevalue = {
id: row_obj.id,
busId:row_obj.businessselect,
userName: row_obj.userName,
contactNo: row_obj.contactNo,
password: row_obj.password,
email: row_obj.email,
role: row_obj.role,
createdBy:row_obj.createdBy
}
formValue.push(updatevalue);
// let updatevalue = {
// id: row_obj.id,
// busId:row_obj.businessselect,
// userName: row_obj.userName,
// contactNo: row_obj.contactNo,
// password: row_obj.password,
// email: row_obj.email,
// role: row_obj.role,
// createdBy:row_obj.createdBy
// }
formValue.push(row_obj);
}
else if(result == 'Delete'){
console.log('delete')
@ -259,5 +260,8 @@ export class UserListComponent implements OnInit {
// console.log(this.dataSource)
// }
image_view(image){
return this.apiUrl+'imageViewer?img_name='+image;
}
}