@@ -15,18 +15,22 @@
- - +
+ + + + - + + + + + @@ -50,7 +54,7 @@ - + diff --git a/ng-seed/src/app/appoinment/appoinments/appoinments-list/appoinments-list.component.ts b/ng-seed/src/app/appoinment/appoinments/appoinments-list/appoinments-list.component.ts index 5283c63..efc1481 100644 --- a/ng-seed/src/app/appoinment/appoinments/appoinments-list/appoinments-list.component.ts +++ b/ng-seed/src/app/appoinment/appoinments/appoinments-list/appoinments-list.component.ts @@ -3,32 +3,34 @@ import { MatDialog } from '@angular/material/dialog'; import { MatPaginator } from '@angular/material/paginator'; import { MatTable, MatTableDataSource } from '@angular/material/table'; import Swal from 'sweetalert2'; +import { AppointmentsService } from '../appointments-service/appointments.service'; import { DialogBoxComponent } from '../dialog-box/dialog-box.component'; export interface UsersData { - // id: number; - time: string; + busId: number; + appoinmentTime: string; booking: string; workspace: string; service: string; staff: string; customer: string; - payment: string; + paymentStatus: string; status: string; - date: string; + appoinmentDate: string; note: string; + appoinmentSlots: string; } const ELEMENT_DATA: UsersData[] = [ - {time: '11:00', booking: '#SA-00001', workspace: 'Sample', service: 'Hospital', staff: 'Kumar.S', customer:'A', payment:'Free', status: 'Pending', date:'01 Mar 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '12:00', booking: '#SA-00002', workspace: 'Test', service: 'School', staff: 'Devi.k', customer:'B', payment:'Paid', status: 'Completed', date:'22 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '13:00', booking: '#SA-00003', workspace: 'Sample', service: 'Sports', staff: 'Kumar.S', customer:'C', payment:'Free', status: 'Pending', date:'21 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '14:00', booking: '#SA-00004', workspace: 'Test', service: 'Hospital', staff: 'Devi.k', customer:'A', payment:'Paid', status: 'Completed', date:'20 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '15:00', booking: '#SA-00005', workspace: 'Sample', service: 'School', staff: 'Kumar.S', customer:'B', payment:'Free', status: 'Pending', date:'17 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '16:00', booking: '#SA-00006', workspace: 'Test', service: 'Sports', staff: 'Devi.k', customer:'C', payment:'Paid', status: 'Completed', date:'16 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '17:00', booking: '#SA-00007', workspace: 'Sample', service: 'Hospital', staff: 'Kumar.S', customer:'A', payment:'Free', status: 'Pending', date:'15 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '18:00', booking: '#SA-00008', workspace: 'Test', service: 'School', staff: 'Devi.k', customer:'B', payment:'Paid', status: 'Completed', date:'14 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '10:00', booking: '#SA-00009', workspace: 'Sample', service: 'Sports', staff: 'Kumar.S', customer:'C', payment:'Free', status: 'Pending', date:'13 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '09:00', booking: '#SA-000010', workspace: 'Test', service: 'Hospital', staff: 'Devi.k', customer:'A', payment:'Paid', status: 'Completed', date:'12 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, - {time: '08:00', booking: '#SA-000011', workspace: 'Sample', service: 'School', staff: 'Kumar.S', customer:'B', payment:'Free', status: 'Pending', date:'11 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 1 , appoinmentSlots: '"start": "09:00",', appoinmentTime: '11:00', booking: '#SA-00001', workspace: 'Sample', service: 'Hospital', staff: 'Kumar.S', customer:'A', paymentStatus:'Free', status: 'Pending', appoinmentDate:'01 Mar 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 2 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '12:00', booking: '#SA-00002', workspace: 'Test', service: 'School', staff: 'Devi.k', customer:'B', paymentStatus:'Paid', status: 'Completed', appoinmentDate:'22 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 3 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '13:00', booking: '#SA-00003', workspace: 'Sample', service: 'Sports', staff: 'Kumar.S', customer:'C', paymentStatus:'Free', status: 'Pending', appoinmentDate:'21 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 4 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '14:00', booking: '#SA-00004', workspace: 'Test', service: 'Hospital', staff: 'Devi.k', customer:'A', paymentStatus:'Paid', status: 'Completed', appoinmentDate:'20 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 5 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '15:00', booking: '#SA-00005', workspace: 'Sample', service: 'School', staff: 'Kumar.S', customer:'B', paymentStatus:'Free', status: 'Pending', appoinmentDate:'17 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 6 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '16:00', booking: '#SA-00006', workspace: 'Test', service: 'Sports', staff: 'Devi.k', customer:'C', paymentStatus:'Paid', status: 'Completed', appoinmentDate:'16 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 7 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '17:00', booking: '#SA-00007', workspace: 'Sample', service: 'Hospital', staff: 'Kumar.S', customer:'A', paymentStatus:'Free', status: 'Pending', appoinmentDate:'15 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 8 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '18:00', booking: '#SA-00008', workspace: 'Test', service: 'School', staff: 'Devi.k', customer:'B', paymentStatus:'Paid', status: 'Completed', appoinmentDate:'14 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 9 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '10:00', booking: '#SA-00009', workspace: 'Sample', service: 'Sports', staff: 'Kumar.S', customer:'C', paymentStatus:'Free', status: 'Pending', appoinmentDate:'13 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 10 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '09:00', booking: '#SA-000010', workspace: 'Test', service: 'Hospital', staff: 'Devi.k', customer:'A', paymentStatus:'Paid', status: 'Completed', appoinmentDate:'12 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, + {busId: 11 ,appoinmentSlots: '"start": "09:00",', appoinmentTime: '08:00', booking: '#SA-000011', workspace: 'Sample', service: 'School', staff: 'Kumar.S', customer:'B', paymentStatus:'Free', status: 'Pending', appoinmentDate:'11 Feb 2023', note: 'Financial statement footnotes are used as additional information by individuals reading financial statements.'}, ]; @Component({ @@ -39,26 +41,64 @@ const ELEMENT_DATA: UsersData[] = [ export class AppoinmentsListComponent implements OnInit { push: any; - displayedColumns: string[] = [ 'time', 'booking', 'workspace', 'service', 'staff', 'customer', 'payment', 'status','action']; - dataSource: any; + displayedColumns: string[] = ['busId', 'time', 'slots', 'action']; + // dataSource: any; + public appoinmentsList:any = new MatTableDataSource(); // dataSource: any = new MatTableDataSource(ELEMENT_DATA); @ViewChild(MatTable,{static:true}) table: MatTable; @ViewChild(MatPaginator) paginator: MatPaginator; + recordStatus: boolean; + addFormData: any; + + + constructor(public dialog: MatDialog, public _app:AppointmentsService) { } + + ngOnInit(): void { + // this.dataSource = new MatTableDataSource(ELEMENT_DATA) + this.getAppoinmentsList() + } + getAppoinmentsList() { + //this._pd.getTabStatusPdDetails(this.tabStatus) + this._app.getAppoinmentsListDetails().subscribe(res => { + if (res.status == 200) { + this.appoinmentsList = res.data; + // console.log(this.appoinmentsList) + // this.dataSource = res.data.length; + // console.log(this.dataSource) + // this.dataSource.data = this.appoinmentsList; + // console.log(this.dataSource.data) + // this.recordStatus=false; + } + else{ + // this.appoinmentsList=[]; + // this.dataSource = null; + // this.recordStatus=true; + } + } + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); + }); + } ngAfterViewInit() { - this.dataSource.paginator = this.paginator; + this.appoinmentsList.paginator = this.paginator; } applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; - this.dataSource.filter = filterValue.trim().toLowerCase(); - if (this.dataSource.paginator) { - this.dataSource.paginator.firstPage(); + this.appoinmentsList.filter = filterValue.trim().toLowerCase(); + if (this.appoinmentsList.paginator) { + this.appoinmentsList.paginator.firstPage(); } } - constructor(public dialog: MatDialog) { } + pageChange(e) { + console.log(e); + } - confirmBox(name,element){ - console.log(name,element) + + confirmBox(event,element){ + console.log(event,element) Swal.fire({ title: 'Are you sure want to remove?', text: 'You will not be able to recover this file!', @@ -68,7 +108,8 @@ export class AppoinmentsListComponent implements OnInit { cancelButtonText: 'No, keep it' }).then((result) => { if (result.value) { - this.deleteRowData(element); + // this.deleteRowData(element); + this.formAddUpdateAndDelete(event,element) Swal.fire( 'Deleted!', 'Your imaginary file has been deleted.', @@ -95,64 +136,117 @@ export class AppoinmentsListComponent implements OnInit { }); dialogRef.afterClosed().subscribe(result => { console.log(result) - if(result.event == 'Add'){ - this.addRowData(result.data); - }else if(result.event == 'Update'){ - this.updateRowData(result.data); - }else if(result.event == 'Delete'){ - this.deleteRowData(result.data); - } + this.formAddUpdateAndDelete(result,result.data) + // if(result.event == 'Add'){ + // this.addRowData(result.data); + // }else if(result.event == 'Update'){ + // this.updateRowData(result.data); + // }else if(result.event == 'Delete'){ + // this.deleteRowData(result.data); + // } }); } - addRowData(row_obj){ - var d = this.dataSource.data.length+1 - console.log(this.dataSource) - console.log(row_obj) - this.dataSource.data.push - ({ - id: d, - time: row_obj.time, + formAddUpdateAndDelete(result,row_obj){ + console.log(result,row_obj) + let formValue = [] + if(result.event == 'Add'){ + console.log('add') + let addFormData = { + busId: row_obj.busId, + appoinmentTime: row_obj.appoinmentTime, booking: row_obj.booking, workspace: row_obj.workspace, service: row_obj.service, staff: row_obj.staff, customer: row_obj.customer, - payment: row_obj.payment, + paymentStatus: row_obj.paymentStatus, status: row_obj.status, - date: row_obj.date, + appoinmentDate: row_obj.appoinmentDate, note: row_obj.note, - - }); - this.table.renderRows(); - } - updateRowData(row_obj){ - console.log(row_obj) - this.dataSource = this.dataSource.data.filter((value,key)=>{ - if(value.id == row_obj.id){ - value.time = row_obj.time; - value.booking = row_obj.booking; - value.workspace = row_obj.workspace; - value.service = row_obj.service; - value.staff = row_obj.staff; - value.customer = row_obj.customer; - value.payment = row_obj.payment; - value.status = row_obj.status; - value.date = row_obj.date; - value.note = row_obj.note; + appoinmentSlots: row_obj.appoinmentSlots, + }; + formValue.push(addFormData); + }else if(result.event == 'Update'){ + console.log('Update') + formValue.push(row_obj); + } + else if(result == 'Delete'){ + console.log('delete') + let val = { + isActive:0, + id: row_obj.id } - return true; + formValue.push(val); + } + + // var d = this.appoinmentsList.length+1 + console.log(formValue[0]) + this._app.addFormDetails(formValue[0]).subscribe(res => { + if (res.status == 200) { + // this.appoinmentsList = res.data; + this.getAppoinmentsList() + } + else{ + // this.appoinmentsList=[]; + // this.dataSource = null; + // this.recordStatus=true; + } + } + // , error => {this.errorMessage = error}); + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); }); } - deleteRowData(row_obj){ - console.log(this.dataSource.data,row_obj) - this.dataSource.data = this.dataSource.data.filter((value,key)=>{ - return value.booking != row_obj.booking - }); - console.log(this.dataSource) - } - ngOnInit(): void { - this.dataSource = new MatTableDataSource(ELEMENT_DATA) - } + // addRowData(row_obj){ + // var d = this.appoinmentsList.data.length+1 + // console.log(this.appoinmentsList) + // console.log(row_obj) + // this.appoinmentsList.data.push + // ({ + // id: d, + // time: row_obj.time, + // booking: row_obj.booking, + // workspace: row_obj.workspace, + // service: row_obj.service, + // staff: row_obj.staff, + // customer: row_obj.customer, + // payment: row_obj.payment, + // status: row_obj.status, + // date: row_obj.date, + // note: row_obj.note, + + // }); + // this.table.renderRows(); + // } + // updateRowData(row_obj){ + // console.log(row_obj) + // this.appoinmentsList = this.appoinmentsList.data.filter((value,key)=>{ + // if(value.id == row_obj.id){ + // value.time = row_obj.time; + // value.booking = row_obj.booking; + // value.workspace = row_obj.workspace; + // value.service = row_obj.service; + // value.staff = row_obj.staff; + // value.customer = row_obj.customer; + // value.payment = row_obj.payment; + // value.status = row_obj.status; + // value.date = row_obj.date; + // value.note = row_obj.note; + // } + // return true; + // }); + // } + // deleteRowData(row_obj){ + // console.log(this.appoinmentsList.data,row_obj) + // this.appoinmentsList.data = this.appoinmentsList.data.filter((value,key)=>{ + // return value.booking != row_obj.booking + // }); + // console.log(this.appoinmentsList) + // } + + } diff --git a/ng-seed/src/app/appoinment/appoinments/appoinments.module.ts b/ng-seed/src/app/appoinment/appoinments/appoinments.module.ts index 2b72485..8fe4dab 100644 --- a/ng-seed/src/app/appoinment/appoinments/appoinments.module.ts +++ b/ng-seed/src/app/appoinment/appoinments/appoinments.module.ts @@ -8,6 +8,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { ScrollingModule } from '@angular/cdk/scrolling'; import { DialogBoxComponent } from './dialog-box/dialog-box.component'; import { DemoMaterialModule } from 'app/shared/demo.module'; +import { NgScrollbarModule } from 'ngx-scrollbar'; // import CalendarTodayIcon from '@material-ui/icons/CalendarToday'; @NgModule({ @@ -21,7 +22,8 @@ import { DemoMaterialModule } from 'app/shared/demo.module'; AppoinmentsRoutingModule, MatSidenavModule, MatFormFieldModule, - ScrollingModule, + // ScrollingModule, + NgScrollbarModule ] }) diff --git a/ng-seed/src/app/appoinment/appoinments/appointments-service/appointments.service.ts b/ng-seed/src/app/appoinment/appoinments/appointments-service/appointments.service.ts index 6909dd3..a05dcb4 100644 --- a/ng-seed/src/app/appoinment/appoinments/appointments-service/appointments.service.ts +++ b/ng-seed/src/app/appoinment/appoinments/appointments-service/appointments.service.ts @@ -1,9 +1,34 @@ +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; +import { Observable } from 'rxjs'; +import { catchError } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class AppointmentsService { + + private apiUrl = environment.apiEndpoint; + constructor(private _http: HttpClient) { } - constructor() { } + getAppoinmentsListDetails(): Observable { + console.log('IN') + return this._http.get(this.apiUrl + "getAppoinmentsDetails") + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } + + addFormDetails(addParams): Observable { + return this._http.post(this.apiUrl + 'CreateAppoinments', addParams) + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } + + + handleError(arg0: string, arg1: undefined[]): (err: any, caught: Observable) => import("rxjs").ObservableInput { + throw new Error('Method not implemented.'); + } } diff --git a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html index af4d889..a451d16 100644 --- a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html +++ b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html @@ -6,6 +6,7 @@ close +
@@ -38,7 +39,7 @@ Please choose any other
-
+ +
+ + + + -- + + {{business.appoinmentSlots}} + + + Please choose an Slots + Please choose any other +
-
+
+ Sure to delete {{local_data.name}}? diff --git a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss index 10033b6..445aa0a 100644 --- a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss +++ b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.scss @@ -69,10 +69,10 @@ width: 175%!important; } .mate{ - width: 18%!important; + width: 15% !important; } .date-marge{ - margin-left: 6rem; + margin-left: 5.5rem; } .field-inline{ display: inline-flex; @@ -82,8 +82,12 @@ } ::ng-deep .mat-dialog-content { max-height: 75vh!important; - overflow: hidden!important; + overflow: unset!important; + // overflow: hidden!important; } ::ng-deep .mat-dialog-container{ overflow: hidden!important; } +.scrollHV { + height: calc(100vh - 190px); +} \ No newline at end of file diff --git a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts index d84c0fd..229ef67 100644 --- a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts +++ b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts @@ -4,7 +4,7 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { Router } from '@angular/router'; export interface UsersData { // id: number; - time: string; + appoinmentTime: string; booking: string; workspace: string; service: string; @@ -12,7 +12,8 @@ export interface UsersData { customer: string; payment: string; status: string; - date: Date; + appoinmentDate: Date; + appoinmentSlots: string; } @Component({ selector: 'app-dialog-box', @@ -44,6 +45,21 @@ export class DialogBoxComponent implements OnInit { {staff: 'Kumar.S'}, {staff: 'Devi.k'}, ]; + appoinmentSlots = new FormControl('', [Validators.required]); + slots = [ + {appoinmentSlots: '9AM - 9.30AM'}, + {appoinmentSlots: '10AM - 10.30AM'}, + {appoinmentSlots: '11AM - 11.30AM'}, + {appoinmentSlots: '12AM - 12.30AM'}, + {appoinmentSlots: '01PM - 01.30PM'}, + {appoinmentSlots: '02PM - 02.30PM'}, + {appoinmentSlots: '03PM - 03.30PM'}, + {appoinmentSlots: '04PM - 04.30PM'}, + {appoinmentSlots: '05PM - 05.30PM'}, + {appoinmentSlots: '06PM - 06.30PM'}, + {appoinmentSlots: '07PM - 07.30PM'}, + ]; + customer = new FormControl('', [Validators.required]); customers = [ {customer: 'A'}, @@ -91,8 +107,10 @@ export class DialogBoxComponent implements OnInit { workspace: new FormControl('', [Validators.required]), service: new FormControl('', [Validators.required]), staff: new FormControl('', [Validators.required]), - date: new FormControl('', [Validators.required]), - time: new FormControl('', [Validators.required]), + slot: new FormControl('', [Validators.required]), + appoinmentDate: new FormControl('', [Validators.required]), + appoinmentTime: new FormControl('', [Validators.required]), + appoinmentSlots: new FormControl('', [Validators.required]), customer: new FormControl('', [Validators.required]), note: new FormControl('', [Validators.required]), }); diff --git a/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.html b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.html new file mode 100644 index 0000000..ac1eff8 --- /dev/null +++ b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.html @@ -0,0 +1,20 @@ +
{{action}} Services +
+
+
+ + + + ServiceName is required + Limit exceed + + + Sure to delete {{local_data.servicesName}}? + +
+
+ + +
+ \ No newline at end of file diff --git a/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.scss b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.scss new file mode 100644 index 0000000..c50ea44 --- /dev/null +++ b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.scss @@ -0,0 +1,11 @@ +.button{ + // float: right; + margin-bottom: 1rem; + background-color: #ffff; + margin-top: -1rem; + // margin-left: 6rem; + float: right; +} +.mat-pane{ + width: 20rem; +} \ No newline at end of file diff --git a/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.spec.ts b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.spec.ts new file mode 100644 index 0000000..ec05663 --- /dev/null +++ b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DialogBoxComponent } from './dialog-box.component'; + +describe('DialogBoxComponent', () => { + let component: DialogBoxComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ DialogBoxComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(DialogBoxComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.ts b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.ts new file mode 100644 index 0000000..deca586 --- /dev/null +++ b/ng-seed/src/app/appoinment/service-list-details/dialog-box/dialog-box.component.ts @@ -0,0 +1,55 @@ +import { Component, Inject, OnInit, Optional } from '@angular/core'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { Router } from '@angular/router'; +export interface UsersData { + servicesName: string; + id: number; +} +@Component({ + selector: 'app-dialog-box', + templateUrl: './dialog-box.component.html', + styleUrls: ['./dialog-box.component.scss'] +}) +export class DialogBoxComponent implements OnInit { + form: FormGroup; + local_data:any; + action:string; + constructor(private router: Router,private formBuilder: FormBuilder, + public dialogRef: MatDialogRef, + @Optional() @Inject(MAT_DIALOG_DATA) public data: UsersData) { + console.log(data); + this.local_data = {...data}; + this.action = this.local_data.action; + } + get f(){ + return this.form.controls; + } + +close() { + this.dialogRef.close(); +} +closeDialog(){ + this.dialogRef.close({event:'Cancel'}); +} + +ngOnInit() { + this.form = new FormGroup({ + servicesName: new FormControl('', [Validators.required, Validators.maxLength(20)]), + }); + this.form.patchValue(this.local_data) + } + + public myError = (controlName: string, errorName: string) =>{ + return this.form.controls[controlName].hasError(errorName); + } + + submit(){ + console.log(this.form.value); + let tmp = this.form.value + tmp.serviceId = this.local_data.serviceId + this.dialogRef.close({event:this.action,data:tmp}); + console.log(this.form.value); + console.log(this.action,this.local_data) + } +} diff --git a/ng-seed/src/app/appoinment/service-list-details/service-api-services/api-service.service.ts b/ng-seed/src/app/appoinment/service-list-details/service-api-services/api-service.service.ts index 6da272b..7a43b7b 100644 --- a/ng-seed/src/app/appoinment/service-list-details/service-api-services/api-service.service.ts +++ b/ng-seed/src/app/appoinment/service-list-details/service-api-services/api-service.service.ts @@ -1,9 +1,34 @@ +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; +import { Observable } from 'rxjs'; +import { catchError } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class ApiServiceService { - constructor() { } + private apiUrl = environment.apiEndpoint; + constructor(private _http: HttpClient) { } + + getServicesListDetails(): Observable { + console.log('IN') + return this._http.get(this.apiUrl + "getServicesDetails ") + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } + + addFormDetails(addParams): Observable { + return this._http.post(this.apiUrl + 'CreateService', addParams) + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } + + + handleError(arg0: string, arg1: undefined[]): (err: any, caught: Observable) => import("rxjs").ObservableInput { + throw new Error('Method not implemented.'); + } } diff --git a/ng-seed/src/app/appoinment/service-list-details/service-list.module.ts b/ng-seed/src/app/appoinment/service-list-details/service-list.module.ts index ddcf23d..9970edb 100644 --- a/ng-seed/src/app/appoinment/service-list-details/service-list.module.ts +++ b/ng-seed/src/app/appoinment/service-list-details/service-list.module.ts @@ -4,11 +4,13 @@ import { CommonModule } from '@angular/common'; import { ServiceListRoutingModule } from './service-list-routing.module'; import { ServiceListComponent } from './service-list/service-list.component'; import { DemoMaterialModule } from 'app/shared/demo.module'; +import { DialogBoxComponent } from './dialog-box/dialog-box.component'; @NgModule({ declarations: [ - ServiceListComponent + ServiceListComponent, + DialogBoxComponent ], imports: [ DemoMaterialModule, diff --git a/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.html b/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.html index c7784ca..1838826 100644 --- a/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.html +++ b/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.html @@ -1,5 +1,6 @@ +
-
+
@@ -10,12 +11,16 @@
- {{serviceListDetails.serviceName}} + {{serviceListDetails.servicesName}} {{serviceListDetails.info}} - Arrow Right - Online Doctor Consultation + edit + delete + {{serviceListDetails.specialties}} - + + +
diff --git a/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.scss b/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.scss index d7ca3a2..b9a7de8 100644 --- a/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.scss +++ b/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.scss @@ -47,11 +47,11 @@ $black_30: rgba(0, 0, 0, 0.3); font-weight: 600; color: #02475b; padding: 10px 0 0; - border-top: 1px solid rgba(2,71,91,.3); + // border-top: 1px solid rgba(2,71,91,.3); } .Specialties-rightArrow{ - top: 1.5rem; + top: 1rem; right: 0; position: absolute; padding-right: 0.5rem; @@ -74,5 +74,26 @@ $black_30: rgba(0, 0, 0, 0.3); ::ng-deep body .mat-card .mat-card-subtitle { padding-left: 0rem!important; } - - +.button{ + float: right; + background-color: #4caf50; + color: #ffff; +} +.edit-color{ + color: rgba(0, 0, 0, 0.54); +} +.edit-color:hover { + color: #4caf50; + } + .delete:hover { + color:#ff0000; + } + .icon-lft{ + margin-left: 6rem; + } + .Specialties-rightUpdate{ + top: 1rem; + right: 0; + position: absolute; + padding-right: 2.5rem; +} diff --git a/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.ts b/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.ts index d144597..d392580 100644 --- a/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.ts +++ b/ng-seed/src/app/appoinment/service-list-details/service-list/service-list.component.ts @@ -1,4 +1,9 @@ import { Component, OnInit } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; +import { MatTableDataSource } from '@angular/material/table'; +import Swal from 'sweetalert2'; +import { DialogBoxComponent } from '../dialog-box/dialog-box.component'; +import { ApiServiceService } from '../service-api-services/api-service.service'; @Component({ selector: 'app-service-list', @@ -7,18 +12,24 @@ import { Component, OnInit } from '@angular/core'; }) export class ServiceListComponent implements OnInit { // doctors = ['Dr. Sanjeev', 'Dr. Gopi', 'Dr. Surendar', 'Dr. Kamali', 'Dr. Venkatadesh', 'Dr.Javeed', 'Dr.Cyril']; - serviceName = ['Allergist and Clinical Immunologist', 'Bariatrics', 'Breast surgery','Cardiology','Cardiothoracic & Vascular Surgery','Cold, Cough and Fever', 'Colorectal Surgery']; + // serviceId = ['1', '2', '3']; + servicesName = ['Allergist and Clinical Immunologist', 'Bariatrics', 'Breast surgery','Cardiology','Cardiothoracic & Vascular Surgery','Cold, Cough and Fever', 'Colorectal Surgery']; info = ['Manage allergies and treat immunity', 'For obesity-related disorders', 'For breast tissue removal', 'For heart and blood pressure problems', 'For surgical treatments of thoracic organs', 'For common health concerns', 'For disorders of rectum, anus, and colon']; specialties = ['Recurring infections, Immunity deficiency', 'Overweight, BMI over 30', 'Breast tissue surgery & removal, Mastectomy', 'Chest pain, Heart Failure, Cholesterol', 'Heart & lung disease, Cardiac transplantation','Fever, Eye Infection, Stomach Ache, Headache', 'Inflammatory bowel disease, Fistula, Intestinal blockage']; serviceData: any = []; - constructor() { } + addFormData: any; + push: any; + id: number; + serviceId: number; + public servicesList:any = new MatTableDataSource(); + constructor(public _api:ApiServiceService, public dialog: MatDialog) { } ngOnInit(): void { for (let i = 0; i < 7; i++) { const random = i % 7; const obj: any = { - serviceName: this.serviceName[random], + servicesName: this.servicesName[random], // isFavourite: i % 5 === 0 ? true : false, // doctors: this.doctors, info: this.info[random], @@ -27,8 +38,130 @@ export class ServiceListComponent implements OnInit { // state: state[i % 4], //version: this.dropdown[0].name, }; - this.serviceData.push(obj); + // this.serviceData.push(obj); } + this.getServicesList() + } + + getServicesList() { + //this._pd.getTabStatusPdDetails(this.tabStatus) + this._api.getServicesListDetails().subscribe(res => { + if (res.status == 200) { + this.servicesList = res.data; + // console.log(this.servicesList) + // this.dataSource = res.data.length; + // console.log(this.dataSource) + // this.dataSource.data = this.servicesList; + // console.log(this.dataSource.data) + // this.recordStatus=false; + } + else{ + // this.servicesList=[]; + // this.dataSource = null; + // this.recordStatus=true; + } + } + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); + }); + } + + confirmBox(event,element){ + console.log(event,element) + Swal.fire({ + title: 'Are you sure want to remove?', + text: 'You will not be able to recover this file!', + icon: 'warning', + showCancelButton: true, + confirmButtonText: 'Yes, delete it!', + cancelButtonText: 'No, keep it' + }).then((result) => { + if (result.value) { + // this.deleteRowData(element); + this.formAddUpdateAndDelete(event,element) + Swal.fire( + 'Deleted!', + 'Your imaginary file has been deleted.', + 'success' + ) + } else if (result.dismiss === Swal.DismissReason.cancel) { + Swal.fire( + 'Cancelled', + 'Your imaginary file is safe :)', + 'error' + ) + } + + }) + } + + openDialog(action,obj) { + obj.action = action; + const dialogRef = this.dialog.open(DialogBoxComponent, { + width: '39%', + height: '100%', + // maxWidth: '38vw', + position: { right: '0' }, + data:obj + }); + dialogRef.afterClosed().subscribe(result => { + if(result != undefined){ + console.log(result) + this.formAddUpdateAndDelete(result,result.data) + } + }); + } + + formAddUpdateAndDelete(result,row_obj){ + console.log(result,row_obj) + let formValue = [] + if(result.event == 'Add'){ + console.log('add') + let addFormData = { + // busId: 'abc123', + // id: row_obj.id, + + serviceId: row_obj.serviceId, + servicesName: row_obj.servicesName + }; + formValue.push(addFormData); + }else if(result.event == 'Update'){ + console.log(row_obj) + console.log('Update') +let updatevalue = { serviceId: row_obj.serviceId, + servicesName: row_obj.servicesName } + formValue.push(updatevalue); + } + else if(result == 'Delete'){ + console.log('delete') + let val = { + isActive:0, + serviceId: row_obj.serviceId + } + formValue.push(val); + } + + // var d = this.customersList.length+1 + console.log(formValue[0]) + this._api.addFormDetails(formValue[0]).subscribe(res => { + if (res.status == 200) { + // this.customersList = res.data; + this.getServicesList() + } + else{ + // this.customersList=[]; + // this.dataSource = null; + // this.recordStatus=true; + } + } + // , error => {this.errorMessage = error}); + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); + }); } } From a4ee4114489c47df4491ebfc5dadcb1f132cbf4a Mon Sep 17 00:00:00 2001 From: Smart Date: Mon, 13 Mar 2023 16:55:39 +0530 Subject: [PATCH 2/2] users --- .../user-dialog-box.component.html | 38 +-- .../user-dialog-box.component.scss | 6 +- .../user-dialog-box.component.ts | 31 ++- .../user/user-list/user-list.component.html | 23 +- .../user/user-list/user-list.component.ts | 241 +++++++++++++----- .../user/user-service/user.service.spec.ts | 16 ++ .../user/user-service/user.service.ts | 34 +++ .../src/app/appoinment/user/user.module.ts | 4 +- 8 files changed, 282 insertions(+), 111 deletions(-) create mode 100644 ng-seed/src/app/appoinment/user/user-service/user.service.spec.ts create mode 100644 ng-seed/src/app/appoinment/user/user-service/user.service.ts diff --git a/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.html b/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.html index b77b5f7..012ad9c 100644 --- a/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.html +++ b/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.html @@ -2,37 +2,44 @@
{{action}} Users
- +
+ + + + role is required + Limit exceed + + - - Username is required - Limit exceed + + Username is required + Limit exceed - - Password is required - Limit exceed + + Password is required + Limit exceed - + - - FirstName is required - Limit exceed + + FirstName is required + Limit exceed - - LastName is required - Limit exceed + + LastName is required + Limit exceed @@ -46,6 +53,7 @@
+
Sure to delete {{local_data.name}}?
diff --git a/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.scss b/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.scss index 9d29136..d25aaa5 100644 --- a/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.scss +++ b/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.scss @@ -26,8 +26,12 @@ } ::ng-deep .mat-dialog-content { max-height: 75vh!important; - overflow: hidden!important; + overflow: unset!important; + // overflow: hidden!important; } ::ng-deep .mat-dialog-container{ overflow: hidden!important; } +.scrollHV { + height: calc(100vh - 190px); +} \ No newline at end of file diff --git a/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.ts b/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.ts index 5e13962..49cae94 100644 --- a/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.ts +++ b/ng-seed/src/app/appoinment/user/user-dialog-box/user-dialog-box.component.ts @@ -3,7 +3,7 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms' import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { Router } from '@angular/router'; export interface UsersData { - name: string; + userName: string; id: number; } @Component({ @@ -29,14 +29,7 @@ export class UserDialogBoxComponent implements OnInit { get f(){ return this.form.controls; } - doAction(){ - let tmp = this.form.value - tmp.id = this.local_data.id - tmp.confirmPassword = this.local_data.confirmPassword - this.dialogRef.close({event:this.action,data:tmp}); - console.log(this.form.value); - console.log(this.action,this.local_data) - } + closeDialog(){ this.dialogRef.close({event:'Cancel'}); @@ -55,21 +48,31 @@ export class UserDialogBoxComponent implements OnInit { } ngOnInit() { this.form = new FormGroup({ - Username: new FormControl('', [Validators.required, Validators.maxLength(20)]), - FirstName: new FormControl('', [Validators.required, Validators.maxLength(20)]), - LastName: new FormControl('', [Validators.required, Validators.maxLength(20)]), + role: new FormControl('', [Validators.required, Validators.maxLength(20)]), + userName: new FormControl('', [Validators.required, Validators.maxLength(20)]), + firstName: new FormControl('', [Validators.required, Validators.maxLength(20)]), + lastName: new FormControl('', [Validators.required, Validators.maxLength(20)]), email: new FormControl('', [Validators.required, Validators.email,Validators.pattern( '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$', ),]), - Password: new FormControl('', [Validators.required, Validators.minLength(6)]), - confirmPassword: new FormControl('', [Validators.required, Validators.minLength(6)]), + password: new FormControl('', [Validators.required, Validators.minLength(6)]), + // confirmPassword: new FormControl('', [Validators.required, Validators.minLength(6)]), }); this.form.patchValue(this.local_data) } public myError = (controlName: string, errorName: string) =>{ return this.form.controls[controlName].hasError(errorName); } + doAction(){ + let tmp = this.form.value + tmp.id = this.local_data.id + // tmp.confirmPassword = this.local_data.confirmPassword + this.dialogRef.close({event:this.action,data:tmp}); + console.log(this.form.value); + console.log(this.action,this.local_data) + } submit(){ console.log(this.form.value); } + } diff --git a/ng-seed/src/app/appoinment/user/user-list/user-list.component.html b/ng-seed/src/app/appoinment/user/user-list/user-list.component.html index e31010e..be75a82 100644 --- a/ng-seed/src/app/appoinment/user/user-list/user-list.component.html +++ b/ng-seed/src/app/appoinment/user/user-list/user-list.component.html @@ -20,13 +20,18 @@
-
BusId {{element.busId}} Time
{{element.date | date:'mediumDate'}}

{{element.time}}
{{element.appoinmentDate | date:'mediumDate'}}

{{element.appoinmentTime}}
Slots
{{element.appoinmentSlots}}
Booking ID Payment
{{element.payment}}

{{element.paymentStatus}}
Status
+
+ + + + + @@ -34,27 +39,27 @@ - + - + - + - + - + @@ -62,10 +67,6 @@ - - - - diff --git a/ng-seed/src/app/appoinment/user/user-list/user-list.component.ts b/ng-seed/src/app/appoinment/user/user-list/user-list.component.ts index 45d0c91..9a4d3e6 100644 --- a/ng-seed/src/app/appoinment/user/user-list/user-list.component.ts +++ b/ng-seed/src/app/appoinment/user/user-list/user-list.component.ts @@ -5,30 +5,32 @@ import { MatSort } from '@angular/material/sort'; import { MatTable, MatTableDataSource } from '@angular/material/table'; import Swal from 'sweetalert2/dist/sweetalert2.js'; import { UserDialogBoxComponent } from '../user-dialog-box/user-dialog-box.component'; +import { UserService } from '../user-service/user.service'; export interface UsersData { id: number; // logo: string; - Username: string; - Password: string; + userName: string; + password: string; confirmPassword: string; - FirstName: string; - LastName: string; + firstName: string; + lastName: string; email: string; + role: string; } const ELEMENT_DATA: UsersData[] = [ - {id: 1, Username: 'school management system ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 2, Username: 'school management ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 3, Username: 'school management system ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 4, Username: 'school management ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 5, Username: 'school management system ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 6, Username: 'school management ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 7, Username: 'school management system ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 8, Username: 'school management ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 9, Username: 'school management system ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 10, Username: 'school management ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, - {id: 11, Username: 'school management system ',Password: '!@Lotus3033', confirmPassword: '!@Lotus3033', FirstName: 'kamali' , LastName: 'sample' , email: 'management@gmail.com'}, + {id: 1, role: 'ADMIN', userName: 'school management system ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 2, role: 'ADMIN', userName: 'school management ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 3, role: 'ADMIN', userName: 'school management system ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 4, role: 'ADMIN', userName: 'school management ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 5, role: 'ADMIN', userName: 'school management system ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 6, role: 'ADMIN', userName: 'school management ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 7, role: 'ADMIN', userName: 'school management system ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 8, role: 'ADMIN', userName: 'school management ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 9, role: 'ADMIN', userName: 'school management system ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 10, role: 'ADMIN',userName: 'school management ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, + {id: 11, role: 'ADMIN', userName: 'school management system ',password: '!@Lotus3033', confirmPassword: '!@Lotus3033', firstName: 'kamali' , lastName: 'sample' , email: 'management@gmail.com'}, ]; @@ -39,23 +41,61 @@ const ELEMENT_DATA: UsersData[] = [ }) export class UserListComponent implements OnInit { push: any; - displayedColumns: string[] = ['id', 'Username', 'Password', 'FirstName', 'LastName', 'email', 'action']; + displayedColumns: string[] = ['id', 'role', 'Username', 'Password', 'FirstName', 'LastName', 'email', 'action']; dataSource: any; + addFormData: any; + public usersList:any = new MatTableDataSource(); @ViewChild(MatTable,{static:true}) table: MatTable; @ViewChild(MatPaginator) paginator: MatPaginator; + + constructor(public dialog: MatDialog, public _use:UserService) { } + + ngOnInit(): void { + // this.dataSource = new MatTableDataSource(ELEMENT_DATA) + this.getUsersList() + } + getUsersList() { + //this._pd.getTabStatusPdDetails(this.tabStatus) + this._use.getUsersListDetails().subscribe(res => { + if (res.status == 200) { + this.usersList = res.data; + // console.log(this.usersList) + // this.dataSource = res.data.length; + // console.log(this.dataSource) + // this.dataSource.data = this.usersList; + // console.log(this.dataSource.data) + // this.recordStatus=false; + } + else{ + // this.usersList=[]; + // this.dataSource = null; + // this.recordStatus=true; + } + } + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); + }); + } + ngAfterViewInit() { - this.dataSource.paginator = this.paginator; + this.usersList.paginator = this.paginator; } applyFilter(event: Event) { const filterValue = (event.target as HTMLInputElement).value; - this.dataSource.filter = filterValue.trim().toLowerCase(); - if (this.dataSource.paginator) { - this.dataSource.paginator.firstPage(); + this.usersList.filter = filterValue.trim().toLowerCase(); + if (this.usersList.paginator) { + this.usersList.paginator.firstPage(); } } - constructor(public dialog: MatDialog) { } + + pageChange(e) { + console.log(e); + } + confirmBox(name,element){ console.log(name,element) Swal.fire({ @@ -67,7 +107,8 @@ export class UserListComponent implements OnInit { cancelButtonText: 'No, keep it' }).then((result) => { if (result.value) { - this.deleteRowData(element); + // this.deleteRowData(element); + this.formAddUpdateAndDelete(name,element) Swal.fire( 'Deleted!', 'Your imaginary file has been deleted.', @@ -94,54 +135,116 @@ export class UserListComponent implements OnInit { data:obj }); dialogRef.afterClosed().subscribe(result => { - console.log(result) - if(result.event == 'Add'){ - this.addRowData(result.data); - }else if(result.event == 'Update'){ - this.updateRowData(result.data); - }else if(result.event == 'Delete'){ - this.deleteRowData(result.data); - } + if(result != undefined){ + console.log(result) + this.formAddUpdateAndDelete(result,result.data) + } + // console.log(result) + // if(result.event == 'Add'){ + // this.addRowData(result.data); + // }else if(result.event == 'Update'){ + // this.updateRowData(result.data); + // }else if(result.event == 'Delete'){ + // this.deleteRowData(result.data); + // } }); } - addRowData(row_obj){ - var d = this.dataSource.data.length+1 - console.log(this.dataSource) - this.dataSource.data.push - ({ - id: d, - // logo: row_obj.logo, - Username: row_obj.Username, - Password: row_obj.Password, - FirstName: row_obj.FirstName, - LastName: row_obj.LastName, - email: row_obj.email, - }); - this.table.renderRows(); - } - updateRowData(row_obj){ - console.log(row_obj) - this.dataSource = this.dataSource.data.filter((value,key)=>{ - if(value.id == row_obj.id){ - // value.logo = row_obj.logo; - value.Username = row_obj.Username; - value.Password = row_obj.Password; - value.FirstName = row_obj.FirstName; - value.LastName = row_obj.LastName; - value.email = row_obj.email; - } - return true; - }); - } - deleteRowData(row_obj){ - console.log(this.dataSource.data,row_obj) - this.dataSource.data = this.dataSource.data.filter((value,key)=>{ - return value.id != row_obj.id - }); - console.log(this.dataSource) - } - ngOnInit(): void { - this.dataSource = new MatTableDataSource(ELEMENT_DATA) - } + + formAddUpdateAndDelete(result,row_obj){ + console.log(result,row_obj) + let formValue = [] + if(result.event == 'Add'){ + console.log('add') + let addFormData = { + // logo: row_obj.logo, + id: row_obj.id, + userName: row_obj.userName, + password: row_obj.password, + firstName: row_obj.firstName, + lastName: row_obj.lastName, + email: row_obj.email, + role: row_obj.role, + }; + formValue.push(addFormData); + }else if(result.event == 'Update'){ + console.log('Update') + let updatevalue = { + id: row_obj.id, + userName: row_obj.userName, + password: row_obj.password, + firstName: row_obj.firstName, + lastName: row_obj.lastName, + email: row_obj.email, + role: row_obj.role, + } + formValue.push(updatevalue); + } + else if(result == 'Delete'){ + console.log('delete') + let val = { + isActive:0, + id: row_obj.id + } + formValue.push(val); + } + + // var d = this.usersList.length+1 + console.log(formValue[0]) + this._use.addFormDetails(formValue[0]).subscribe(res => { + if (res.status == 200) { + // this.usersList = res.data; + this.getUsersList() + } + else{ + // this.usersList=[]; + // this.dataSource = null; + // this.recordStatus=true; + } + } + // , error => {this.errorMessage = error}); + ,error => { + // this.errorMessage.push(error); + // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // alert(error.html_format); + }); + } + + // addRowData(row_obj){ + // var d = this.dataSource.data.length+1 + // console.log(this.dataSource) + // this.dataSource.data.push + // ({ + // id: d, + // // logo: row_obj.logo, + // Username: row_obj.Username, + // Password: row_obj.Password, + // FirstName: row_obj.FirstName, + // LastName: row_obj.LastName, + // email: row_obj.email, + // }); + // this.table.renderRows(); + // } + // updateRowData(row_obj){ + // console.log(row_obj) + // this.dataSource = this.dataSource.data.filter((value,key)=>{ + // if(value.id == row_obj.id){ + // // value.logo = row_obj.logo; + // value.Username = row_obj.Username; + // value.Password = row_obj.Password; + // value.FirstName = row_obj.FirstName; + // value.LastName = row_obj.LastName; + // value.email = row_obj.email; + // } + // return true; + // }); + // } + // deleteRowData(row_obj){ + // console.log(this.dataSource.data,row_obj) + // this.dataSource.data = this.dataSource.data.filter((value,key)=>{ + // return value.id != row_obj.id + // }); + // console.log(this.dataSource) + // } + } diff --git a/ng-seed/src/app/appoinment/user/user-service/user.service.spec.ts b/ng-seed/src/app/appoinment/user/user-service/user.service.spec.ts new file mode 100644 index 0000000..3f804c9 --- /dev/null +++ b/ng-seed/src/app/appoinment/user/user-service/user.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { UserService } from './user.service'; + +describe('UserService', () => { + let service: UserService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(UserService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/ng-seed/src/app/appoinment/user/user-service/user.service.ts b/ng-seed/src/app/appoinment/user/user-service/user.service.ts new file mode 100644 index 0000000..6df9ad4 --- /dev/null +++ b/ng-seed/src/app/appoinment/user/user-service/user.service.ts @@ -0,0 +1,34 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; +import { Observable } from 'rxjs'; +import { catchError } from 'rxjs/operators'; + +@Injectable({ + providedIn: 'root' +}) +export class UserService { + + private apiUrl = environment.apiEndpoint; + constructor(private _http: HttpClient) { } + + getUsersListDetails(): Observable { + console.log('IN') + return this._http.get(this.apiUrl + "getusers") + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } + + addFormDetails(addParams): Observable { + return this._http.post(this.apiUrl + 'createUsers', addParams) + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } + + + handleError(arg0: string, arg1: undefined[]): (err: any, caught: Observable) => import("rxjs").ObservableInput { + throw new Error('Method not implemented.'); + } +} diff --git a/ng-seed/src/app/appoinment/user/user.module.ts b/ng-seed/src/app/appoinment/user/user.module.ts index b3bda6a..0baf597 100644 --- a/ng-seed/src/app/appoinment/user/user.module.ts +++ b/ng-seed/src/app/appoinment/user/user.module.ts @@ -7,6 +7,7 @@ import { MatSidenavModule } from '@angular/material/sidenav'; import { MatFormFieldModule } from '@angular/material/form-field'; import { UserDialogBoxComponent } from './user-dialog-box/user-dialog-box.component'; import { DemoMaterialModule } from 'app/shared/demo.module'; +import { NgScrollbarModule } from 'ngx-scrollbar'; @@ -21,7 +22,8 @@ import { DemoMaterialModule } from 'app/shared/demo.module'; CommonModule, UserRoutingModule, MatSidenavModule, - MatFormFieldModule + MatFormFieldModule, + NgScrollbarModule ] }) export class UserModule { }
S.No {{element.id}} Role {{element.role}} Logo User Name {{element.Username}} {{element.userName}} Password {{element.Password}} {{element.password}} First Name {{element.FirstName}} {{element.firstName}} Last Name {{element.LastName}} {{element.lastName}} {{element.email}} State {{element.state}} City