diff --git a/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html new file mode 100644 index 000000000..5a7d3deef --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html @@ -0,0 +1,180 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+
+ + +
+ + + {{ enti.name }} + + You must Select Entity Type. + +
+
+
+ + + + You must Include Full Name. + + + + + You must Include Short Name. + +
+ +
+ + + {{ reg.region_name }} + + You must Select Region. + + + + + {{ st.state_name }} + + You must Select State. + + + + + {{ ct.city_name }} + + You must Select City. + + + + + {{ brn.branch_name }} + + You must Select Branch. + + +
+ +
+ + + You must Include Address. + + + + You must Include Pincode. + +
+ +
+ + + + You must Include Official Email. + + + + + You must Select Alternet Email. + + + + + You must Include Phone Number. + + + + + You must Include Mobile Number. + +
+ +
+ + + You must Include Remarks. + +
+
+
+ + + You must Include Pan Number. + + + + + You must Include GST Number. + + + + You must Include GST State Code. + + + + + You must Include TAT. + +
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + +
+ +
+
+ + + +
+
+
+
+ +
+
+ + + +
+ + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.scss b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.scss new file mode 100644 index 000000000..6e263adae --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.scss @@ -0,0 +1,3 @@ +.example-full-width{ + width: 100%; +} \ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts new file mode 100644 index 000000000..f3d7ebef3 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts @@ -0,0 +1,213 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject +} from '@angular/core'; + +import { ActivatedRoute, Router, Params } from '@angular/router'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +// import { +// MatDialog, +// MatDialogRef, +// MAT_DIALOG_DATA +// } from '@angular/material'; +/** Service */ +import { MastersService } from './../../service/masters/masters.service'; +import { EntityService } from './../../service/entity/entity.service'; + +/* +* Question master add details +* : kdk +*/ +@Component({ + selector: 'app-entity-add', + templateUrl: './entity.add.component.html', + styleUrls: ['./entity.add.component.scss'] +}) +export class EntityAddComponent implements OnInit { + + public pageTitle: string = "Add Entity Master Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public geoRecords: any = []; + public entityOptions: any = []; + public questionsOptions: any = []; + errorMessage: string; + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private _formBuilder: FormBuilder, + private masterService: MastersService, + private entityService: EntityService, + private router: Router) { + this.notifier = notifier; + } + + + ngOnInit() { + /** Questions Form Datas*/ + this._addQuesFrom = this._formBuilder.group({ + fk_entity_type_id: [null, Validators.compose([Validators.required])], + full_name: [null, Validators.compose([Validators.required])], + short_name: [null, Validators.compose([Validators.required])], + fk_region: [null, Validators.compose([Validators.required])], + fk_state: [null, Validators.compose([Validators.required])], + fk_city: [null, Validators.compose([Validators.required])], + fk_branch: [null, Validators.compose([Validators.required])], + addressline1: [null, Validators.compose([Validators.required])], + pincode: [null, Validators.compose([Validators.required])], + official_email: [null, Validators.compose([Validators.required, Validators.email])], + alt_email: [null, Validators.compose([Validators.required, Validators.email])], + phone_number: [null, Validators.compose([Validators.required])], + mobile_no: [null, Validators.compose([Validators.required])], + remarks: [null, Validators.compose([Validators.required])], + pan: [null, Validators.compose([Validators.required])], + gst_no: [null, Validators.compose([Validators.required])], + gst_state_code: [null, Validators.compose([Validators.required])], + tat: [null, Validators.compose([Validators.required])], + entity_child: this._formBuilder.array([ + this.initAnswers(), + ]) + }); + // OnInit Load Geo Details and Question Type Masters + this.getGeoLocationMaster(); + this.getEntityOptionsMaster(); + } + + // convenience getter for easy access to form fields + get f() { return this._addQuesFrom.controls; } + + // Dynamic Form field creation Functionality : START ===> + initAnswers() { + return this._formBuilder.group({ + contact_person: ['', Validators.compose([Validators.required])], + contact_email: ['', Validators.compose([Validators.required])], + contact_mobile_no: ['', Validators.compose([Validators.required])], + }); + } + addLanguage(e) { + const control = this._addQuesFrom.controls['entity_child']; + control.push(this.initAnswers()); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['entity_child']; + control.removeAt(i); + } + + // END ===> + + public state_m: any = []; + selectGeoRegionChanges(reg){ + this._addQuesFrom.controls.fk_state.reset(); + this._addQuesFrom.controls.fk_city.reset(); + this._addQuesFrom.controls.fk_branch.reset(); + this.state_m = []; + this.city_m = []; + this.branch_m = []; + if(reg){ + this.state_m = reg; + } + } + + public city_m: any = [] + selectGeoStateChanges(city) { + this._addQuesFrom.controls.fk_city.reset(); + this._addQuesFrom.controls.fk_branch.reset(); + this.city_m = []; + this.branch_m = []; + if(city){ + this.city_m = city; + } + } + public branch_m: any = []; + selectGeoCityChanges(brn){ + this._addQuesFrom.controls.fk_branch.reset(); + this.branch_m = []; + if(brn){ + this.branch_m = brn; + } + } + + getGeoLocationMaster() { + this.entityService.getGeoLocationMasterDetails().subscribe( + data => { + this.geoRecords = data.records; + }, + error => { + this.notifier.notify('warning', 'No Geo Location Records Found.!'); + this.errorMessage = "No Category Records Found."; + } + ) + } + getEntityOptionsMaster() { + this.masterService.getAllMasterData('ENTITYTYPE').subscribe( + data => { + this.entityOptions = data.records.filter(data => data.entity_type_id != 1); + }, + error => { + this.notifier.notify('warning', 'No Answer Type Records Found.!'); + this.errorMessage = "No Answer Type Record Found."; + } + ) + } + + /** For Popup Close Button */ + onNoClick(): void { + // this.dialogRef.close(); + this.router.navigate(['/setting/entity/list']); + } + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._addQuesFrom.invalid) { + this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var entityFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(entityFormValues).forEach((key) => (entityFormValues[key] == null) && delete entityFormValues[key]); + + //Add BRANCH data with help Service File + this.entityService.addEntityMasterDetails(entityFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify('success', 'Record Saved Successfully.!'); + this.router.navigate(['/setting/entity/list']); + this._addQuesFrom.reset(); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + } + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Something Wents Wrong Try Again !"; + }); + } + } + + /** To Reset Popup Data */ + onReset() { + this._addQuesFrom.reset(); + } +} diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html new file mode 100644 index 000000000..a002c9080 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html @@ -0,0 +1,180 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+
+ +
+ + + + {{ enti.name }} + + You must Select Entity Type. + +
+
+
+ + + + You must Include Full Name. + + + + + You must Include Short Name. + +
+ +
+ + + {{ reg.region_name }} + + You must Select Region. + + + + + {{ st.state_name }} + + You must Select State. + + + + + {{ ct.city_name }} + + You must Select City. + + + + + {{ brn.branch_name }} + + You must Select Branch. + + +
+ +
+ + + You must Include Address. + + + + You must Include Pincode. + +
+ +
+ + + + You must Include Official Email. + + + + + You must Select Alternet Email. + + + + + You must Include Phone Number. + + + + + You must Include Mobile Number. + +
+ +
+ + + You must Include Remarks. + +
+
+
+ + + You must Include Pan Number. + + + + + You must Include GST Number. + + + + You must Include GST State Code. + + + + + You must Include TAT. + +
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + +
+ +
+
+ + + + + +
+
+
+
+ +
+
+ + + +
+ +
+ +
+
+
diff --git a/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts new file mode 100644 index 000000000..d72fe8de7 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts @@ -0,0 +1,253 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject, + ViewChild, + Input +} from '@angular/core'; + +import { + FormBuilder, + FormGroup, + Validators, + FormArray, +} from '@angular/forms'; + +import { NotifierService } from 'angular-notifier'; + +/** Service */ +import { MastersService } from './../../service/masters/masters.service'; +import { EntityService } from './../../service/entity/entity.service'; +import { EntityListComponent } from './../entity-list/entity.list.component'; +/* +* Question master details edit component +* : kdk +*/ +@Component({ + selector: 'app-entity-edit', + templateUrl: './entity.edit.component.html', +// styleUrls: ['./edit.component.scss'] +}) +export class EntityEditComponent implements OnInit{ + + @Input() public childMessage: any; + +public pageTitle: string = "Edit Entity Master Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public geoRecords: any = []; + public entityOptions: any = []; + public questionsOptions: any = []; + errorMessage: string; + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private _formBuilder: FormBuilder, + private masterService: MastersService, + private entityService: EntityService, + private entityListComponent: EntityListComponent) { + this.notifier = notifier; + } + + + ngOnInit() { + this.loadFormData(); + /** Questions Form Datas*/ + if (this.childMessage["0"].length > 0) { + for (let val of this.childMessage["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['contact_person'], vals['contact_email'], vals['contact_mobile_no'], vals['entity_child_id'], vals['isactive'], null); + } + } + + // OnInit Load Geo Details and Question Type Masters + this.getGeoLocationMaster(); + this.getEntityOptionsMaster(); + } + + // load answer details list + loadAnsData() { + if (this.childMessage["0"].length > 0) { + for (let val of this.childMessage["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['contact_person'], vals['contact_email'], vals['contact_mobile_no'], vals['entity_child_id'], vals['isactive'], null); + } + } + } + + + loadFormData() { + this._addQuesFrom = this._formBuilder.group({ + entity_id: [this.childMessage.entity_id], + fk_entity_type_id: [this.childMessage.fk_entity_type_id, Validators.compose([Validators.required])], + full_name: [this.childMessage.full_name, Validators.compose([Validators.required])], + short_name: [this.childMessage.short_name, Validators.compose([Validators.required])], + fk_region: [this.childMessage.fk_region, Validators.compose([Validators.required])], + fk_state: [this.childMessage.fk_state, Validators.compose([Validators.required])], + fk_city: [this.childMessage.fk_city, Validators.compose([Validators.required])], + fk_branch: [this.childMessage.fk_branch, Validators.compose([Validators.required])], + addressline1: [this.childMessage.addressline1, Validators.compose([Validators.required])], + pincode: [this.childMessage.pincode, Validators.compose([Validators.required])], + official_email: [this.childMessage.official_email, Validators.compose([Validators.required, Validators.email])], + alt_email: [this.childMessage.alt_email, Validators.compose([Validators.required, Validators.email])], + phone_number: [this.childMessage.phone_number, Validators.compose([Validators.required])], + mobile_no: [this.childMessage.mobile_no, Validators.compose([Validators.required])], + remarks: [this.childMessage.remarks, Validators.compose([Validators.required])], + pan: [this.childMessage.pan, Validators.compose([Validators.required])], + gst_no: [this.childMessage.gst_no, Validators.compose([Validators.required])], + gst_state_code: [this.childMessage.gst_state_code, Validators.compose([Validators.required])], + tat: [this.childMessage.tat, Validators.compose([Validators.required])], + entity_child: this._formBuilder.array([ + // this.initAnswers(), + ]) + }); + } + + // convenience getter for easy access to form fields + get f() { return this._addQuesFrom.controls; } + +// form entity_child details access + get f_ans() { return this._addQuesFrom.get('entity_child'); } + + // Dynamic Form field creation Functionality : START ===> + initAnswers(c_person, c_email, e_phn, fk_id, isAct, e) { + isAct = isAct == null ? 1 : isAct; + return this._formBuilder.group({ + contact_person: [c_person, Validators.compose([Validators.required])], + contact_email: [c_email, Validators.compose([Validators.required])], + contact_mobile_no: [e_phn, Validators.compose([Validators.required])], + entity_child_id: [fk_id], + isactive: [isAct] + }); + } + addLanguage(c_person, c_email, e_phn, fk_id, isAct, e) { + const control = this._addQuesFrom.controls['entity_child']; + control.push(this.initAnswers(c_person, c_email, e_phn, fk_id, isAct, e)); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['entity_child']; + control.removeAt(i); + } + + // END ===> + + public state_m: any = []; + selectGeoRegionChanges(reg){ + this._addQuesFrom.controls.fk_state.reset(); + this._addQuesFrom.controls.fk_city.reset(); + this._addQuesFrom.controls.fk_branch.reset(); + this.state_m = []; + this.city_m = []; + this.branch_m = []; + if(reg){ + this.state_m = reg; + } + } + + public city_m: any = [] + selectGeoStateChanges(city) { + this._addQuesFrom.controls.fk_city.reset(); + this._addQuesFrom.controls.fk_branch.reset(); + this.city_m = []; + this.branch_m = []; + if(city){ + this.city_m = city; + } + } + public branch_m: any = []; + selectGeoCityChanges(brn){ + this._addQuesFrom.controls.fk_branch.reset(); + this.branch_m = []; + if(brn){ + this.branch_m = brn; + } + } + + getGeoLocationMaster() { + this.entityService.getGeoLocationMasterDetails().subscribe( + data => { + this.geoRecords = data.records; + this.setGeoEditSelectDetails(); + }, + error => { + this.notifier.notify('warning', 'No Geo Location Records Found.!'); + this.errorMessage = "No Category Records Found."; + } + ) + } + + setGeoEditSelectDetails() { + let state = this.geoRecords.filter(data=>{if(data.region_id === this.childMessage.fk_region){ return data.state_data;}}); + this.state_m = state[0].state_data; + let city = this.state_m.filter(data=>{if(data.state_id === this.childMessage.fk_state){ return data.city_data;}}); + this.city_m = city[0].city_data; + let branch = this.city_m.filter(data=>{if(data.city_id === this.childMessage.fk_city){ return data.branch_data;}}); + // alert(JSON.stringify(branch)); + this.branch_m = branch[0].branch_data; + } + getEntityOptionsMaster() { + this.masterService.getAllMasterData('ENTITYTYPE').subscribe( + data => { + this.entityOptions = data.records.filter(data => data.entity_type_id != 1); + }, + error => { + this.notifier.notify('warning', 'No Answer Type Records Found.!'); + this.errorMessage = "No Answer Type Record Found."; + } + ) + } + + /** For Popup Close Button */ + onNoClick(): void { + this.entityListComponent.changeListView(); + // this.dialogRef.close(); + } + + /** To Save/Edited Popup Data */ + onSubmit() { + this.submitted = true; + // stop here if form is invalid + if (this._addQuesFrom.invalid) { + this.errorMessage = "Please Fill All Mandate Fields."; + return; + } else { + var entityFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(entityFormValues).forEach((key) => (entityFormValues[key] == null) && delete entityFormValues[key]); + + //Add BRANCH data with help Service File + this.entityService.updateEntityMasterDetails(entityFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify('success', 'Record Updated Successfully.!'); + this._addQuesFrom.reset(); + this.entityListComponent.changeListView(); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Some Thing Wents Wrong Try Again !"; + } + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Something Wents Wrong Try Again !"; + }); + } + } + + /** To Reset Popup Data */ + onReset() { + this.loadFormData(); + this.loadAnsData(); + } +} diff --git a/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html new file mode 100644 index 000000000..7326014cf --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html @@ -0,0 +1,83 @@ +
+ + + +
+
Entity Master
+
List of Entity Master Details
+
+
+
+ +
+
+ + + + +
+
+ +
+ + +
+ +
+
+
+
+ {{ product.entity_name }} +
+
+
{{ product.full_name }} ({{product.short_name}})
+
{{ product.branch_name }}
+
{{product.city_name}}, {{product.state_name}}
+
+
+
{{ product.phone_number }}
+
{{ product.official_email }}
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
No Record Found ...
+
+ + +
+
+
+ +
+ + + \ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts new file mode 100644 index 000000000..e34f12324 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts @@ -0,0 +1,168 @@ +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder } from '@angular/forms'; +import { ActivatedRoute, Router, Params } from '@angular/router'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; +import { MastersService } from './../../service/masters/masters.service'; +/** Dialog Component */ +import { EntityAddComponent } from './../entity-add/entity.add.component'; +// import { EditComponent } from './../entity-edit/entity.edit.component'; +import { EntityService } from './../../service/entity/entity.service'; +// import { EntityEditComponent } from "./../entity-edit/entity.edit.component"; +/* +* Questions master List component +* : kdk +*/ +@Component({ + selector: 'app-entity-list', + templateUrl: './entity.list.component.html', +// styleUrls: ['./list.component.scss'] +}) +export class EntityListComponent implements OnInit { + + public listView: any = true; + + public enityList: any[] = []; + public paginationList: any[] = []; + public categories: any = []; + public search_cid: any = null; + public noQuesMasterRecrdFound: boolean = false; + + public filterFormGroupCtrl: FormGroup; + + // @ViewChild(EntityEditComponent) child; + + // pagination variable details + length = 50; + pageIndex = 0; + pageSize = 10; + pageEvent: PageEvent; + + // data source variable details + questionListData = null; + public dataLength: number; + public dataSource = new MatTableDataSource(); + displayedColumns = ['categroy_name', 'question', 'actions']; + + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + + constructor(private dialog: MatDialog, + private masterService: MastersService, + private _formBuilder: FormBuilder, + private router: Router, + private entityService: EntityService) { + // this.filterFormGroupCtrl = this._formBuilder.group({ + // category: [null, ''] + // }); + } + + ngOnInit() { + this.getCategorMaster(); + this.getEntityListMasters(); + } + + // get question master list details + getEntityListMasters() { + this.noQuesMasterRecrdFound = false; + // this.search_cid = this.filterFormGroupCtrl.controls.category.value; + console.log(this.search_cid + ", " + this.filterFormGroupCtrl); + this.entityService.getEntityListMasterDetails().subscribe( + data => { + if (data) { + if (data.records) { + this.enityList = data.records; + this.questionListData = data.records; + this.dataLength = data.records.length; + this.dataSource.data = this.questionListData; + } else { + this.enityList = []; + this.dataLength = null; + this.noQuesMasterRecrdFound = true; + } + } else { + this.enityList = []; + this.dataLength = null; + this.noQuesMasterRecrdFound = true; + } + } + ) + } + + // get category master details + getCategorMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + // this.errorMessage = "No Category Record Found."; + } + ) + } + + ngAfterViewInit() { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + + applyFilter(filterValue: string) { + filterValue = filterValue.trim(); // Remove whitespace + filterValue = filterValue.toLowerCase(); // Datasource defaults to lowercase matches + this.dataSource.filter = filterValue; + } + + // add questions popup model call + addNewQuestion() { + this.router.navigate(['/setting/entity/add']); + + // const dialogRef = this.dialog.open(EntityAddComponent, { + // data: {}, + // disableClose: true + // }); + // dialogRef.afterClosed() + // .subscribe(dataresult => { + // this.getQuestionsMasters(); + // // this.getBranch(); + // // this.isPopupOpened = false; + // }); + } + + public parentMessage: any = []; + editEntity(detail){ + this.parentMessage = detail; + this.listView = false; + } + + changeListView(){ + this.getEntityListMasters(); + this.listView = true; + } + + // edit questions master details popup model +// editQuestion(rowDetails: any) { +// const dialogRef = this.dialog.open(EditComponent, { +// data: rowDetails, +// disableClose: true +// }); +// dialogRef.afterClosed() +// .subscribe(dataresult => { +// this.getQuestionsMasters(); +// // this.getBranch(); +// // this.isPopupOpened = false; +// }); +// } + + // padination page event call + pageChange(e) { + console.log(e); + } + +} + +// {"dataStatus":true,"status":200,"records": +// [ +// {"entity_id":"4","full_name":"chech","short_name":"check","fk_region":"2","region_name":"South India","fk_state":"2","state_name":"Tamil Nadu","fk_city":"2","city_name":"Chennai","fk_branch":"10","branch_name":"Ahmedabad","addressline1":"c","pincode":"c","official_email":"c@gmail.com","alt_email":"c@gmail.com","phone_number":"3423423444","mobile_no":"234234234","remarks":"234234","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":null,"fk_updatedby":null,"updatedby":null,"isactive":"1","pan":"234234","gst_no":"2342","gst_state_code":"dfw","tat":"12","fk_entity_type_id":"2","entity_name":"LENDOR","0":[{"entity_child_id":"1","contact_person":"cc","contact_email":"cc@gmai.com","contact_mobile_no":"23412341234","isactive":"1","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":null,"fk_updatedby":null,"updatedby":null}]}, +// {"entity_id":"1","full_name":"ICICI","short_name":"ICICI","fk_region":"1","region_name":"North India","fk_state":"1","state_name":"Jammu and Kashmir","fk_city":"1","city_name":"Srinagar (summer), Jammu (winter)","fk_branch":"1","branch_name":"Main Branch","addressline1":"add1","pincode":"add2","official_email":null,"alt_email":null,"phone_number":null,"mobile_no":null,"remarks":null,"createdon":"2018-09-28 08:55:56","fk_createdby":"1","createdby":"sriram v","updatedon":"2018-10-03 10:11:28","fk_updatedby":null,"updatedby":null,"isactive":"1","pan":null,"gst_no":null,"gst_state_code":null,"tat":null,"fk_entity_type_id":"2","entity_name":"LENDOR","0":[{"entity_child_id":"2","contact_person":"ccee","contact_email":"ccee@gmai.com","contact_mobile_no":"234123412111","isactive":"1","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":"2018-10-05 05:18:08","fk_updatedby":"1","updatedby":"sriram v"}]}, +// {"entity_id":"8","full_name":"ICICIedited","short_name":"checkee","fk_region":"2","region_name":"South India","fk_state":"2","state_name":"Tamil Nadu","fk_city":"2","city_name":"Chennai","fk_branch":"10","branch_name":"Ahmedabad","addressline1":"cee","pincode":"cee","official_email":"cee@gmail.com","alt_email":"cee@gmail.com","phone_number":"3423423111","mobile_no":"234234111","remarks":"edietd","createdon":"2018-10-05 05:18:08","fk_createdby":"1","createdby":"sriram v","updatedon":"2018-10-05 05:18:08","fk_updatedby":"1","updatedby":"sriram v","isactive":"1","pan":"234111","gst_no":"2111","gst_state_code":"dfwee","tat":"12111","fk_entity_type_id":"2","entity_name":"LENDOR","0":[]}]} \ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity.component.ts b/ng6-seed/src/app/settings/entity/entity.component.ts new file mode 100644 index 000000000..81b196f17 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity.component.ts @@ -0,0 +1,7 @@ +import { Component } from '@angular/core'; +@Component({ + template: `

Entity Master Details List

+ ` +}) +export class EntityComponent { +} \ No newline at end of file diff --git a/ng6-seed/src/app/settings/entity/entity.module.ts b/ng6-seed/src/app/settings/entity/entity.module.ts new file mode 100644 index 000000000..3f69b4893 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity.module.ts @@ -0,0 +1,105 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { NotifierModule, NotifierOptions } from 'angular-notifier'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule, + MatListModule, MatMenuModule, + MatCheckboxModule +} from '@angular/material'; +import {MatSlideToggleModule} from '@angular/material/slide-toggle'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; + +import { RouterModule } from '@angular/router'; +import { EntityRouting } from './entity.routing'; + +import { EntityComponent } from './entity.component'; +import { EntityListComponent } from './entity-list/entity.list.component'; +import { EntityAddComponent } from './entity-add/entity.add.component'; +import { EntityEditComponent } from './entity-edit/entity.edit.component'; + +import { EntityService } from './../service/entity/entity.service'; +/** + * Custom angular notifier options + */ +const customNotifierOptions: NotifierOptions = { + position: { + horizontal: { + position: 'right', + distance: 12 + }, + vertical: { + position: 'top', + distance: 32, + gap: 10 + } + }, + theme: 'material', + behaviour: { + autoHide: 5000, + onClick: 'hide', + onMouseover: 'pauseAutoHide', + showDismissButton: true, + stacking: 4 + }, + animations: { + enabled: true, + show: { + preset: 'slide', + speed: 300, + easing: 'ease' + }, + hide: { + preset: 'fade', + speed: 300, + easing: 'ease', + offset: 50 + }, + shift: { + speed: 300, + easing: 'ease' + }, + overlap: 150 + } +}; +@NgModule({ + imports: [ + CommonModule, + NotifierModule.withConfig(customNotifierOptions), + FlexLayoutModule, + EntityRouting, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule, + MatCheckboxModule, + MatSlideToggleModule, + FormsModule, + ReactiveFormsModule + ], + declarations: [ + EntityComponent, + EntityListComponent, + EntityEditComponent, + EntityAddComponent + ], + entryComponents: [ + // EntityEditComponent + ], + providers : [ +EntityService + ] + + +}) +export class EntityModule { } diff --git a/ng6-seed/src/app/settings/entity/entity.routing.ts b/ng6-seed/src/app/settings/entity/entity.routing.ts new file mode 100644 index 000000000..6d7435820 --- /dev/null +++ b/ng6-seed/src/app/settings/entity/entity.routing.ts @@ -0,0 +1,39 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +// Entity Component +import { EntityComponent } from './entity.component'; +import { EntityListComponent } from './entity-list/entity.list.component'; +import { EntityAddComponent } from './entity-add/entity.add.component'; +import { EntityEditComponent } from './entity-edit/entity.edit.component'; +/* +* Entity Master Router Module details +*/ +const routes: Routes = [ + { + path: '', + redirectTo: 'list', + pathMatch: 'full', + },{ + path: '', + children: [ + { + path: 'list', + component: EntityListComponent, + }, + { + path: 'add', + component: EntityAddComponent, + }, + { + path: 'edit', + component: EntityEditComponent, + } + ] + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class EntityRouting {} diff --git a/ng6-seed/src/app/settings/service/entity/entity.service.ts b/ng6-seed/src/app/settings/service/entity/entity.service.ts new file mode 100644 index 000000000..9993bf8f3 --- /dev/null +++ b/ng6-seed/src/app/settings/service/entity/entity.service.ts @@ -0,0 +1,101 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Observable } from 'rxjs/Observable'; +import { catchError } from 'rxjs/operators'; +import { of } from 'rxjs'; +import 'rxjs/add/operator/map'; + +/** Imported Service Files Are., */ +import { AwsService } from '../../../AwsService/aws.service'; +/** Consant Value For Created Date And Updated Date */ +const currentdate = new Date().toJSON().slice(0, 19).replace('T', ' '); + + +@Injectable({ + providedIn: 'root' +}) + +/* +* Add , Edit, List, Delete Entity Master API service End-point Call Functionality +* Kdk +*/ +export class EntityService { + private apiUrl = "http://ssa.sineedge.com/sparqapi/api/"; + private serviceUrl = 'https://jsonplaceholder.typicode.com/users'; + + constructor(private _http: HttpClient, + private _aws: AwsService) { } + + getUser(): Observable { + return this._http.get(this.serviceUrl); + } + + // get geo location master details list + getGeoLocationMasterDetails(): Observable { + // Add safe, URL encoded search parameter if there is a search term + return this._http.get(this.apiUrl + "getLocationHierarchy"); + } + + // get questions master details list + getEntityListMasterDetails(): Observable { + // Add safe, URL encoded search parameter if there is a search term + return this._http.get(this.apiUrl + "listAllEntites/any"); + } + + // get questions master details list + getQuestionMasterDetails(cid: any): Observable { + // Add safe, URL encoded search parameter if there is a search term + const options = cid ? + { params: new HttpParams().set('cid', cid) } : {}; + return this._http.get(this.apiUrl + "listAllQuestions/get", options); + } + + // add question master + addEntityMasterDetails(Records: any): Observable { + Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record + Records.createdon = currentdate;//to get Current date and Time for when the Record is created + return this._http.post(this.apiUrl + "saveNewEntity", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + // add question master + addQuestionMasterDetails(Records: any): Observable { + Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record + Records.createdon = currentdate;//to get Current date and Time for when the Record is created + return this._http.post(this.apiUrl + "saveNewQuestion", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + updateEntityMasterDetails(Records: any): Observable { + Records.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record + Records.updatedon = currentdate;//to get Current date and Time for when the Record is created + return this._http.post(this.apiUrl + "saveExistEntity", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + updateQuestionMasterDetails(Records: any): Observable { + Records.fk_updatedby = this._aws.getlocale();//to get user id for who is created the Record + Records.updatedon = currentdate;//to get Current date and Time for when the Record is created + return this._http.post(this.apiUrl + "saveExistQuestion", { 'records': Records}) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + /** + * TO Handle The Error + */ + private handleError(operation = 'operation', result?: T) { + + return (error: any): Observable => { + return of(result as T); + }; + } + +} diff --git a/ng6-seed/src/app/settings/settings.module.ts b/ng6-seed/src/app/settings/settings.module.ts index 373b4af7d..b25dba989 100644 --- a/ng6-seed/src/app/settings/settings.module.ts +++ b/ng6-seed/src/app/settings/settings.module.ts @@ -28,12 +28,14 @@ import { RegisterComponent } from '../session/register/register.component'; import { UserService } from './service/user.service'; import { MastersModule } from './masters/masters.module'; +import { EntityModule } from './entity/entity.module'; // import { HttpClientModule } from '@angular/common/http'; @NgModule({ imports: [ CommonModule, RouterModule.forChild(SettingsRoutes),MatCardModule, MastersModule, + EntityModule, MatIconModule, MatInputModule, MatRadioModule, diff --git a/ng6-seed/src/app/settings/settings.routing.ts b/ng6-seed/src/app/settings/settings.routing.ts index aa7e9bcbe..0caa1257c 100644 --- a/ng6-seed/src/app/settings/settings.routing.ts +++ b/ng6-seed/src/app/settings/settings.routing.ts @@ -1,5 +1,6 @@ import { Routes } from '@angular/router'; import { MastersModule } from './masters/masters.module'; +import { EntityModule } from './entity/entity.module'; export const SettingsRoutes: Routes = [{ path: '', @@ -9,6 +10,9 @@ export const SettingsRoutes: Routes = [{ },{ path:'mastermodule', loadChildren:'./masters/masters.module#MastersModule' + },{ + path:'entity', + loadChildren:'./entity/entity.module#EntityModule' } ] }]