From 801e93431eb4fdfa1dc843b70b88c7baf1fec104 Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Fri, 5 Oct 2018 17:43:39 +0530 Subject: [PATCH 1/4] entity details master : kdk --- .../entity-add/entity.add.component.html | 180 +++++++++++++ .../entity-add/entity.add.component.scss | 3 + .../entity/entity-add/entity.add.component.ts | 213 +++++++++++++++ .../entity-edit/entity.edit.component.html | 180 +++++++++++++ .../entity-edit/entity.edit.component.ts | 253 ++++++++++++++++++ .../entity-list/entity.list.component.html | 83 ++++++ .../entity-list/entity.list.component.ts | 168 ++++++++++++ .../app/settings/entity/entity.component.ts | 7 + .../src/app/settings/entity/entity.module.ts | 105 ++++++++ .../src/app/settings/entity/entity.routing.ts | 39 +++ .../settings/service/entity/entity.service.ts | 101 +++++++ ng6-seed/src/app/settings/settings.module.ts | 2 + ng6-seed/src/app/settings/settings.routing.ts | 4 + 13 files changed, 1338 insertions(+) create mode 100644 ng6-seed/src/app/settings/entity/entity-add/entity.add.component.html create mode 100644 ng6-seed/src/app/settings/entity/entity-add/entity.add.component.scss create mode 100644 ng6-seed/src/app/settings/entity/entity-add/entity.add.component.ts create mode 100644 ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.html create mode 100644 ng6-seed/src/app/settings/entity/entity-edit/entity.edit.component.ts create mode 100644 ng6-seed/src/app/settings/entity/entity-list/entity.list.component.html create mode 100644 ng6-seed/src/app/settings/entity/entity-list/entity.list.component.ts create mode 100644 ng6-seed/src/app/settings/entity/entity.component.ts create mode 100644 ng6-seed/src/app/settings/entity/entity.module.ts create mode 100644 ng6-seed/src/app/settings/entity/entity.routing.ts create mode 100644 ng6-seed/src/app/settings/service/entity/entity.service.ts 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' } ] }] From bd0372b005245fd6228fca379cd786d7743eb4d4 Mon Sep 17 00:00:00 2001 From: dineshkumarkannan Date: Fri, 5 Oct 2018 18:53:25 +0530 Subject: [PATCH 2/4] entity details changes update: kdk --- .../app/settings/entity/entity-add/entity.add.component.ts | 2 +- .../app/settings/entity/entity-edit/entity.edit.component.ts | 2 +- .../settings/entity/entity-list/entity.list.component.html | 2 +- ng6-seed/src/app/settings/settings.module.ts | 4 ++-- ng6-seed/src/app/shared/menu-items/menu-items.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) 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 index f3d7ebef3..1f5484466 100644 --- 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 @@ -97,7 +97,7 @@ export class EntityAddComponent implements OnInit { initAnswers() { return this._formBuilder.group({ contact_person: ['', Validators.compose([Validators.required])], - contact_email: ['', Validators.compose([Validators.required])], + contact_email: ['', Validators.compose([Validators.required, Validators.email])], contact_mobile_no: ['', Validators.compose([Validators.required])], }); } 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 index d72fe8de7..300fb31a0 100644 --- 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 @@ -123,7 +123,7 @@ public pageTitle: string = "Edit Entity Master Details"; 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_email: [c_email, Validators.compose([Validators.required, Validators.email])], contact_mobile_no: [e_phn, Validators.compose([Validators.required])], entity_child_id: [fk_id], isactive: [isAct] 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 index 7326014cf..1f33e28f2 100644 --- 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 @@ -46,7 +46,7 @@ {{ product.entity_name }}
-
{{ product.full_name }} ({{product.short_name}})
+
{{ product.full_name }} ({{product.short_name}})
{{ product.branch_name }}
{{product.city_name}}, {{product.state_name}}
diff --git a/ng6-seed/src/app/settings/settings.module.ts b/ng6-seed/src/app/settings/settings.module.ts index 1cb445065..14ffb9cdc 100644 --- a/ng6-seed/src/app/settings/settings.module.ts +++ b/ng6-seed/src/app/settings/settings.module.ts @@ -26,7 +26,7 @@ import { RouterModule } from '@angular/router'; import { SettingsRoutes } from './settings.routing'; import { RegisterComponent } from '../session/register/register.component'; import { UserService } from './service/user.service'; -// import { MastersModule } from './masters/masters.module'; +import { MastersModule } from './masters/masters.module'; // import { EntityModule } from './entity/entity.module'; // import { AddEntityComponent } from './entity/add-entity/add-entity.component'; // import { EditEntityComponent } from './entity/edit-entity/edit-entity.component'; @@ -38,7 +38,7 @@ import { EntityModule } from './entity/entity.module'; imports: [ CommonModule, RouterModule.forChild(SettingsRoutes),MatCardModule, - // MastersModule, + MastersModule, EntityModule, MatIconModule, MatInputModule, diff --git a/ng6-seed/src/app/shared/menu-items/menu-items.ts b/ng6-seed/src/app/shared/menu-items/menu-items.ts index 2eec5e065..ac9a52283 100644 --- a/ng6-seed/src/app/shared/menu-items/menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/menu-items.ts @@ -34,7 +34,7 @@ const MENUITEMS : Menu[] = [ children:[ {state:'users',name:'User List'}, {state:'mastermodule',name:'Master Details'}, - // {state:'entitymodule',name:'Entity Type'} + {state:'entity',name:'Entity Details'} ] }, { From 4468a2f28c282af92d5440eb2cc877f335eecdf8 Mon Sep 17 00:00:00 2001 From: venbaSriram Date: Fri, 5 Oct 2018 19:55:43 +0530 Subject: [PATCH 3/4] individual user changes --- ng6-seed/package-lock.json | 28 ++++++++++++---- ng6-seed/src/app/AwsService/aws.service.ts | 6 ++-- .../layouts/admin/admin-layout.component.ts | 4 +-- .../users/register/register.component.html | 2 +- .../users/user-list/user-list.component.ts | 16 ++++++++-- .../user-profile/user-profile-component.html | 32 +++++++++++-------- .../user-profile/user-profile.component.ts | 26 ++++++++++++++- 7 files changed, 84 insertions(+), 30 deletions(-) diff --git a/ng6-seed/package-lock.json b/ng6-seed/package-lock.json index b0f821d27..78ab38287 100644 --- a/ng6-seed/package-lock.json +++ b/ng6-seed/package-lock.json @@ -4294,12 +4294,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4314,17 +4316,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4441,7 +4446,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4453,6 +4459,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4467,6 +4474,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4474,12 +4482,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4498,6 +4508,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4578,7 +4589,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4590,6 +4602,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4711,6 +4724,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/ng6-seed/src/app/AwsService/aws.service.ts b/ng6-seed/src/app/AwsService/aws.service.ts index 3e25469c7..7d7cbe688 100755 --- a/ng6-seed/src/app/AwsService/aws.service.ts +++ b/ng6-seed/src/app/AwsService/aws.service.ts @@ -364,7 +364,7 @@ export class AwsService { err, data ) => { - if (err) { alert(err.stack); } + if (err) { alert(err.message); } // an error occurred @@ -420,7 +420,7 @@ export class AwsService { data ) { if (err) { - alert(err.stack); + alert(err.message); }//(err, err.stack); // an error occurred else {//(data); @@ -461,7 +461,7 @@ export class AwsService { data ) { if (err) { - alert(err.stack); + alert(err.message); }//(err, err.stack); // an error occurred else {//(data); diff --git a/ng6-seed/src/app/layouts/admin/admin-layout.component.ts b/ng6-seed/src/app/layouts/admin/admin-layout.component.ts index a04c747f6..0bd5cd050 100644 --- a/ng6-seed/src/app/layouts/admin/admin-layout.component.ts +++ b/ng6-seed/src/app/layouts/admin/admin-layout.component.ts @@ -50,8 +50,8 @@ export class AdminLayoutComponent implements OnInit, OnDestroy { this.currentUser = res; if(this.currentUser.dataStatus == true){ this.currentUser = this.currentUser.records[0]; - this.fullName = this.currentUser.user_full_name; - console.log(this.currentUser); + this.fullName = this.currentUser.user_first_name +' '+this.currentUser.user_last_name; + //console.log(this.currentUser); if(this.currentUser.fk_entity_id == 1 ){ this.userDep = "SINEEGDE"; }else if(this.currentUser.fk_entity_id ==2){ diff --git a/ng6-seed/src/app/settings/users/register/register.component.html b/ng6-seed/src/app/settings/users/register/register.component.html index 2ae94c7d5..712d939a9 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.html +++ b/ng6-seed/src/app/settings/users/register/register.component.html @@ -33,7 +33,7 @@ - + Account Details

diff --git a/ng6-seed/src/app/settings/users/user-list/user-list.component.ts b/ng6-seed/src/app/settings/users/user-list/user-list.component.ts index 89f858604..522565dd9 100644 --- a/ng6-seed/src/app/settings/users/user-list/user-list.component.ts +++ b/ng6-seed/src/app/settings/users/user-list/user-list.component.ts @@ -4,7 +4,7 @@ import { AwsService } from '../../../AwsService/aws.service'; import { MatPaginator, MatTableDataSource,MatSort } from '@angular/material'; import { UserService } from '../../service/user.service'; import { DataSource } from '@angular/cdk/table'; - +import { CognitoService } from '../../../AwsService/cognito.service'; @Component({ selector: 'app-user-list', templateUrl: './user-list.component.html', @@ -23,8 +23,20 @@ export class UserListComponent implements OnInit { - constructor(public aws: AwsService, public route: Router,public users:UserService) { + constructor(public aws: AwsService, public route: Router,public users:UserService,public shared:CognitoService) { + let session:any = this.shared.getAccessToken(); + //console.log(session.idToken.payload["cognito:groups"]); + let userGroup = session.idToken.payload["cognito:groups"].filter( + usergroup => usergroup == "ADMIN" + )[0]; + + if(userGroup == "ADMIN" ){ + }else{ + alert('Admin Only Access Page'); + this.route.navigate(['home']); + + } this.getusers(); } diff --git a/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html b/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html index 0d1c48bad..6b56b830c 100755 --- a/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html +++ b/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html @@ -22,11 +22,12 @@ -->
-
- user +
+ + user
-
-

{{userDetails.user_full_name}}

+
+ +
-

Tweets

-
+ +
+

@@ -53,12 +57,12 @@
  • -
    user +
    user
    {{userDetails.user_full_name}} - +
    {{userDetails.createdon | date:'dd MMM yyyy'}}

    {{userDetails.mobile_no}}

    {{userDetails.addressline1}} {{userDetails.addressline2}}
    @@ -66,11 +70,11 @@

    -
    +
  • -
  • +
diff --git a/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts b/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts index 4e68a0823..5f361917d 100755 --- a/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts +++ b/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts @@ -4,6 +4,7 @@ import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { CustomValidators } from 'ng2-validation'; import { UserService } from '../../service/user.service'; +import { Router} from '@angular/router'; @Component({ selector: 'ms-user-profile', templateUrl:'./user-profile-component.html', @@ -11,6 +12,7 @@ import { UserService } from '../../service/user.service'; encapsulation: ViewEncapsulation.None }) export class UserProfileComponent implements OnInit { + profileurl: any; config: MatDialogConfig = { disableClose: false, width: '', @@ -23,8 +25,9 @@ export class UserProfileComponent implements OnInit { } }; userDetails:any=[]; - constructor(public AWS:AwsService,public dialog: MatDialog,public users:UserService ) { + constructor(public AWS:AwsService,public dialog: MatDialog,public users:UserService,public router:Router ) { this.getuser(); + } ngOnInit() { @@ -38,6 +41,7 @@ export class UserProfileComponent implements OnInit { this.users.getroles().subscribe(res=>{ this.userDetails = res; this.userDetails = this.userDetails.records[0]; + this.getprofilepic(); }); } changePassword(){ @@ -52,10 +56,30 @@ export class UserProfileComponent implements OnInit { }) } } + //console.log(ChangePasswordDialog.prototype.pass); }); } + editprofile(){ + this.users.adminGetUsers(this.userDetails); + this.router.navigate(['setting/users/register']); + } + getprofilepic(){ + let users= { + 'userid':this.userDetails.userid, + 'entityid':this.userDetails.fk_entity_id, + 'profilepic':this.userDetails.profilepic + } + this.users.getprofilepic(users).subscribe(res=>{ + this.profileurl = res; + if(this.profileurl.dataStatus == true){ + + this.profileurl = this.profileurl.records; + + } + }) + } } @Component({ From b0e2c4ad9b4d7ab3c623800af722dacf3839993d Mon Sep 17 00:00:00 2001 From: venbaSriram Date: Fri, 5 Oct 2018 19:59:16 +0530 Subject: [PATCH 4/4] individual userprofile issues fixed --- ng6-seed/src/app/AwsService/aws.service.ts | 2 +- ng6-seed/src/app/layouts/admin/admin-layout.component.html | 2 +- .../src/app/settings/users/register/register.component.html | 2 +- ng6-seed/src/app/settings/users/register/register.component.ts | 2 +- .../src/app/settings/users/user-list/user-list.component.ts | 2 +- .../app/settings/users/user-profile/user-profile-component.html | 2 +- .../app/settings/users/user-profile/user-profile.component.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ng6-seed/src/app/AwsService/aws.service.ts b/ng6-seed/src/app/AwsService/aws.service.ts index 7d7cbe688..6cd0f2298 100755 --- a/ng6-seed/src/app/AwsService/aws.service.ts +++ b/ng6-seed/src/app/AwsService/aws.service.ts @@ -362,7 +362,7 @@ export class AwsService { cognitoidentityserviceprovider.adminCreateUser(params, ( err, - data + data ) => { if (err) { alert(err.message); } // an error occurred diff --git a/ng6-seed/src/app/layouts/admin/admin-layout.component.html b/ng6-seed/src/app/layouts/admin/admin-layout.component.html index 6a685a1d1..b52f6dd0f 100644 --- a/ng6-seed/src/app/layouts/admin/admin-layout.component.html +++ b/ng6-seed/src/app/layouts/admin/admin-layout.component.html @@ -5,7 +5,7 @@ - + Account Details

diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts b/ng6-seed/src/app/settings/users/register/register.component.ts index 61a56b0c4..a2f1bf862 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.ts +++ b/ng6-seed/src/app/settings/users/register/register.component.ts @@ -262,7 +262,7 @@ this.loader = true; if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) { this.usersData = this.users.localUserId; - + this.users.entityType().subscribe(res => { this.types = res; if (this.types.status == 200) { diff --git a/ng6-seed/src/app/settings/users/user-list/user-list.component.ts b/ng6-seed/src/app/settings/users/user-list/user-list.component.ts index 522565dd9..99448064f 100644 --- a/ng6-seed/src/app/settings/users/user-list/user-list.component.ts +++ b/ng6-seed/src/app/settings/users/user-list/user-list.component.ts @@ -28,7 +28,7 @@ export class UserListComponent implements OnInit { //console.log(session.idToken.payload["cognito:groups"]); let userGroup = session.idToken.payload["cognito:groups"].filter( usergroup => usergroup == "ADMIN" - )[0]; + )[0]; if(userGroup == "ADMIN" ){ diff --git a/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html b/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html index 6b56b830c..2998114c9 100755 --- a/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html +++ b/ng6-seed/src/app/settings/users/user-profile/user-profile-component.html @@ -38,7 +38,7 @@ {{userDetails.addressline3}} {{userDetails.state_name}} - {{userDetails.pincode}} {{userDetails.createdon | date:'dd MMM yyyy'}} -->
-
+
diff --git a/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts b/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts index 5f361917d..fb19559e7 100755 --- a/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts +++ b/ng6-seed/src/app/settings/users/user-profile/user-profile.component.ts @@ -76,7 +76,7 @@ export class UserProfileComponent implements OnInit { if(this.profileurl.dataStatus == true){ this.profileurl = this.profileurl.records; - + } }) }