This commit is contained in:
venbatechnologies@gmail.com 2018-10-05 20:53:12 +05:30
commit 1ded485ee0
22 changed files with 1412 additions and 31 deletions

View File

@ -362,9 +362,9 @@ export class AwsService {
cognitoidentityserviceprovider.adminCreateUser(params, ( cognitoidentityserviceprovider.adminCreateUser(params, (
err, err,
data data
) => { ) => {
if (err) { alert(err.stack); } if (err) { alert(err.message); }
// an error occurred // an error occurred
@ -420,7 +420,7 @@ export class AwsService {
data data
) { ) {
if (err) { if (err) {
alert(err.stack); alert(err.message);
}//(err, err.stack); }//(err, err.stack);
// an error occurred // an error occurred
else {//(data); else {//(data);
@ -461,7 +461,7 @@ export class AwsService {
data data
) { ) {
if (err) { if (err) {
alert(err.stack); alert(err.message);
}//(err, err.stack); }//(err, err.stack);
// an error occurred // an error occurred
else {//(data); else {//(data);

View File

@ -5,7 +5,7 @@
<div class="sidebar-container "> <div class="sidebar-container ">
<div class="branding text-center"> <div class="branding text-center">
<!-- <h2><i class="fa fa-superpowers" aria-hidden="true"></i> <span> OPTIMA</span> <!-- <h2><i class="fa fa-superpowers" aria-hidden="true"></i> <span> OPTIMA</span>
</h2> --> </h2> -->
<h2><i class="fa fa-superpowers" aria-hidden="true"></i> <span> {{userDep}} </span> <h2><i class="fa fa-superpowers" aria-hidden="true"></i> <span> {{userDep}} </span>
</h2> </h2>
</div> </div>

View File

@ -50,8 +50,8 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
this.currentUser = res; this.currentUser = res;
if(this.currentUser.dataStatus == true){ if(this.currentUser.dataStatus == true){
this.currentUser = this.currentUser.records[0]; this.currentUser = this.currentUser.records[0];
this.fullName = this.currentUser.user_full_name; this.fullName = this.currentUser.user_first_name +' '+this.currentUser.user_last_name;
console.log(this.currentUser); //console.log(this.currentUser);
if(this.currentUser.fk_entity_id == 1 ){ if(this.currentUser.fk_entity_id == 1 ){
this.userDep = "SINEEGDE"; this.userDep = "SINEEGDE";
}else if(this.currentUser.fk_entity_id ==2){ }else if(this.currentUser.fk_entity_id ==2){

View File

@ -0,0 +1,180 @@
<div style="max-height: 580px;">
<mat-card style="padding: 6px;">
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center">
<h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2>
<div style="width: 20%;"></div>
<div style="width: 30%;text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
</div>
</div>
<form [formGroup]="_addQuesFrom" (submit)="onSubmit()">
<!--<div class="form-group">-->
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select Entity Type" formControlName="fk_entity_type_id">
<mat-option *ngFor="let enti of entityOptions" [value]="enti.entity_type_id">{{ enti.name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_entity_type_id.hasError('required')" class="mat-text-warn">You must Select Entity Type.</mat-error>
</mat-form-field>
</div>
<hr>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Full Name" formControlName="full_name">
<mat-error *ngIf="submitted && f.full_name.hasError('required')" class="mat-text-warn">You must Include Full Name.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Short Name" formControlName="short_name">
<mat-error *ngIf="submitted && f.short_name.hasError('required')" class="mat-text-warn">You must Include Short Name.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select Region" formControlName="fk_region">
<mat-option *ngFor="let reg of geoRecords" [value]="reg.region_id" (click)="selectGeoRegionChanges(reg.state_data)">{{ reg.region_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_region.hasError('required')" class="mat-text-warn">You must Select Region.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select State" formControlName="fk_state">
<mat-option *ngFor="let st of state_m" [value]="st.state_id" (click)="selectGeoStateChanges(st.city_data)">{{ st.state_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_state.hasError('required')" class="mat-text-warn">You must Select State.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select City" formControlName="fk_city">
<mat-option *ngFor="let ct of city_m" [value]="ct.city_id" (click)="selectGeoCityChanges(ct.branch_data)">{{ ct.city_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select City.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select Branch" formControlName="fk_branch">
<mat-option *ngFor="let brn of branch_m" [value]="brn.branch_id">{{ brn.branch_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_branch.hasError('required')" class="mat-text-warn">You must Select Branch.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Address" formControlName="addressline1">
<mat-error *ngIf="submitted && f.addressline1.hasError('required')" class="mat-text-warn">You must Include Address.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Pincode" formControlName="pincode">
<mat-error *ngIf="submitted && f.pincode.hasError('required')" class="mat-text-warn">You must Include Pincode.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Official Email" formControlName="official_email">
<mat-error *ngIf="submitted && f.official_email.hasError('required')" class="mat-text-warn">You must Include Official Email.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Alternet Email" formControlName="alt_email">
<mat-error *ngIf="submitted && f.alt_email.hasError('required')" class="mat-text-warn">You must Select Alternet Email.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Phone Number" formControlName="phone_number">
<mat-error *ngIf="submitted && f.phone_number.hasError('required')" class="mat-text-warn">You must Include Phone Number.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Mobile Number" formControlName="mobile_no">
<mat-error *ngIf="submitted && f.mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 calc(33.3% - 32px)" class="ml-xs">
<textarea matInput placeholder="Remarks" formControlName="remarks"></textarea>
<mat-error *ngIf="submitted && f.remarks.hasError('required')" class="mat-text-warn">You must Include Remarks.</mat-error>
</mat-form-field>
</div>
<hr>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Pan Number" formControlName="pan">
<mat-error *ngIf="submitted && f.pan.hasError('required')" class="mat-text-warn">You must Include Pan Number.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="GST Number" formControlName="gst_no">
<mat-error *ngIf="submitted && f.gst_no.hasError('required')" class="mat-text-warn">You must Include GST Number.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="GST State Code" formControlName="gst_state_code">
<mat-error *ngIf="submitted && f.gst_state_code.hasError('required')" class="mat-text-warn">You must Include GST State Code.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="TAT" formControlName="tat">
<mat-error *ngIf="submitted && f.tat.hasError('required')" class="mat-text-warn">You must Include TAT.</mat-error>
</mat-form-field>
</div>
<hr>
<div fxLayout="row wrap" fxLayoutAlign="start none">
<div formArrayName="entity_child" class="example-full-width">
<div *ngFor="let answ of _addQuesFrom.controls.entity_child['controls']; let i=index">
<div [formGroupName]="i">
<div fxLayout="row wrap" style="width: 100%">
<div style="width: 90%">
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Contact Person" formControlName="contact_person">
<!--<mat-error *ngIf="submitted && f.contact_person.hasError('required')" class="mat-text-warn">You must Include Contact Person.</mat-error>-->
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Email" formControlName="contact_email">
<!--<mat-error *ngIf="submitted && f.contact_email.hasError('required')" class="mat-text-warn">You must Include Email.</mat-error>-->
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Mobile Number" formControlName="contact_mobile_no">
<!--<mat-error *ngIf="submitted && f.contact_mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>-->
</mat-form-field>
</div>
</div>
<div style="width:10%">
<span *ngIf="_addQuesFrom.controls.entity_child.controls.length > 1" (click)="removeLanguage(i)">
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
</span>
</div>
</div>
</div>
</div>
<button mat-button color="primary" matTooltip="Add More Answer" matTooltipPosition="above" (click)="addLanguage($event); false">Add More</button>
</div>
</div>
<!--Error List Shown Here-->
<!--<ul>
<li *ngFor="let err of errorMessage">
<mat-error>{{err.err}}</mat-error>
</li>
</ul>-->
<div class="row" style="text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button>
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
</div>
<!--</div>-->
</form>
</mat-card>
</div>
<notifier-container></notifier-container>

View File

@ -0,0 +1,3 @@
.example-full-width{
width: 100%;
}

View File

@ -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, Validators.email])],
contact_mobile_no: ['', Validators.compose([Validators.required])],
});
}
addLanguage(e) {
const control = <FormArray>this._addQuesFrom.controls['entity_child'];
control.push(this.initAnswers());
}
removeLanguage(i: number) {
const control = <FormArray>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();
}
}

View File

@ -0,0 +1,180 @@
<div style="max-height: 580px;">
<mat-card style="padding: 6px;">
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="center">
<h2 mat-dialog-title style="width: 50%;">{{pageTitle}}</h2>
<div style="width: 20%;"></div>
<div style="width: 30%;text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
</div>
</div>
<form [formGroup]="_addQuesFrom" (submit)="onSubmit()">
<!--<div class="form-group">-->
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select Entity Type" formControlName="fk_entity_type_id">
<mat-option *ngFor="let enti of entityOptions" [value]="enti.entity_type_id">{{ enti.name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_entity_type_id.hasError('required')" class="mat-text-warn">You must Select Entity Type.</mat-error>
</mat-form-field>
</div>
<hr>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Full Name" formControlName="full_name">
<mat-error *ngIf="submitted && f.full_name.hasError('required')" class="mat-text-warn">You must Include Full Name.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Short Name" formControlName="short_name">
<mat-error *ngIf="submitted && f.short_name.hasError('required')" class="mat-text-warn">You must Include Short Name.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select Region" formControlName="fk_region">
<mat-option *ngFor="let reg of geoRecords" [value]="reg.region_id" (click)="selectGeoRegionChanges(reg.state_data)">{{ reg.region_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_region.hasError('required')" class="mat-text-warn">You must Select Region.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select State" formControlName="fk_state">
<mat-option *ngFor="let st of state_m" [value]="st.state_id" (click)="selectGeoStateChanges(st.city_data)">{{ st.state_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_state.hasError('required')" class="mat-text-warn">You must Select State.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select City" formControlName="fk_city">
<mat-option *ngFor="let ct of city_m" [value]="ct.city_id" (click)="selectGeoCityChanges(ct.branch_data)">{{ ct.city_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select City.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Select Branch" formControlName="fk_branch">
<mat-option *ngFor="let brn of branch_m" [value]="brn.branch_id">{{ brn.branch_name }}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.fk_branch.hasError('required')" class="mat-text-warn">You must Select Branch.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Address" formControlName="addressline1">
<mat-error *ngIf="submitted && f.addressline1.hasError('required')" class="mat-text-warn">You must Include Address.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Pincode" formControlName="pincode">
<mat-error *ngIf="submitted && f.pincode.hasError('required')" class="mat-text-warn">You must Include Pincode.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Official Email" formControlName="official_email">
<mat-error *ngIf="submitted && f.official_email.hasError('required')" class="mat-text-warn">You must Include Official Email.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Alternet Email" formControlName="alt_email">
<mat-error *ngIf="submitted && f.alt_email.hasError('required')" class="mat-text-warn">You must Select Alternet Email.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Phone Number" formControlName="phone_number">
<mat-error *ngIf="submitted && f.phone_number.hasError('required')" class="mat-text-warn">You must Include Phone Number.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Mobile Number" formControlName="mobile_no">
<mat-error *ngIf="submitted && f.mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
<mat-form-field fxFlex="0 1 calc(33.3% - 32px)" class="ml-xs">
<textarea matInput placeholder="Remarks" formControlName="remarks"></textarea>
<mat-error *ngIf="submitted && f.remarks.hasError('required')" class="mat-text-warn">You must Include Remarks.</mat-error>
</mat-form-field>
</div>
<hr>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start" style="padding: 6px 4px;">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Pan Number" formControlName="pan">
<mat-error *ngIf="submitted && f.pan.hasError('required')" class="mat-text-warn">You must Include Pan Number.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="GST Number" formControlName="gst_no">
<mat-error *ngIf="submitted && f.gst_no.hasError('required')" class="mat-text-warn">You must Include GST Number.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="GST State Code" formControlName="gst_state_code">
<mat-error *ngIf="submitted && f.gst_state_code.hasError('required')" class="mat-text-warn">You must Include GST State Code.</mat-error>
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="TAT" formControlName="tat">
<mat-error *ngIf="submitted && f.tat.hasError('required')" class="mat-text-warn">You must Include TAT.</mat-error>
</mat-form-field>
</div>
<hr>
<div fxLayout="row wrap" fxLayoutAlign="start none" style="padding: 6px 4px;">
<div formArrayName="entity_child" class="example-full-width">
<div *ngFor="let answ of _addQuesFrom.controls.entity_child['controls']; let i=index">
<div [formGroupName]="i">
<div fxLayout="row wrap">
<div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Contact Person" formControlName="contact_person">
<!--<mat-error *ngIf="submitted && f.contact_person.hasError('required')" class="mat-text-warn">You must Include Contact Person.</mat-error>-->
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Email" formControlName="contact_email">
<!--<mat-error *ngIf="submitted && f.contact_email.hasError('required')" class="mat-text-warn">You must Include Email.</mat-error>-->
</mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput placeholder="Mobile Number" formControlName="contact_mobile_no">
<!--<mat-error *ngIf="submitted && f.contact_mobile_no.hasError('required')" class="mat-text-warn">You must Include Mobile Number.</mat-error>-->
</mat-form-field>
</div>
</div>
<div>
<mat-checkbox *ngIf="answ.get('entity_child_id').value != null" formControlName="isactive" [ngModel]="answ.get('isactive').value == 1 ? true : answ.get('isactive').value == 0 ? false : null"
(ngModelChange)="answ.get('isactive').value = $event ? 1 : 0"></mat-checkbox>
<span *ngIf="_addQuesFrom.controls.entity_child.controls.length > 1" (click)="removeLanguage(i)">
<button *ngIf="answ.get('entity_child_id').value == null" mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
</span>
</div>
</div>
</div>
</div>
<button mat-button color="primary" matTooltip="Add More" matTooltipPosition="above" (click)="addLanguage(null, null, null, null, null, $event); false">Add More</button>
</div>
</div>
<!--Error List Shown Here-->
<!--<ul>
<li *ngFor="let err of errorMessage">
<mat-error>{{err.err}}</mat-error>
</li>
</ul>-->
<div class="row" style="text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="button"
(click)="onReset()"><mat-icon>settings_backup_restore</mat-icon></button><button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
</div>
<!--</div>-->
</form>
</mat-card>
</div>

View File

@ -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 <FormArray>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, Validators.email])],
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 = <FormArray>this._addQuesFrom.controls['entity_child'];
control.push(this.initAnswers(c_person, c_email, e_phn, fk_id, isAct, e));
}
removeLanguage(i: number) {
const control = <FormArray>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();
}
}

View File

@ -0,0 +1,83 @@
<div *ngIf="listView">
<mat-card>
<mat-card class="mat-elevation-z1">
<div style="margin: 6px; padding: 4px;">
<div class="p_title" style="font-size: 16px; font-style: bold;">Entity Master</div>
<div class="sub_title" style="font-size: 11px;">List of Entity Master Details</div>
</div>
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="center none">
<div fxFlex="80%">
<!--<form [formGroup]="filterFormGroupCtrl">
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutGap="0.5px" fxLayoutAlign="start none" style="padding: 6px;">
<mat-select placeholder="Category" formControlName="category">
<mat-option *ngFor="let cat of categories" [value]="cat.question_categroy_id" (click)="getQuestionsMasters()">
{{cat.categroy_name}}
</mat-option>
</mat-select>
</div>
</form>-->
</div>
<div fxFlex="20%">
<!--<a [routerLink]="['/'+'setting/entity/add' ]">-->
<button mat-stroked-button color="primary" (click)="addNewQuestion()">
Add New Entity</button>
<!--</a>-->
</div>
</div>
<!--</mat-card-content>-->
</mat-card>
<!--
<mat-card class="mat-elevation-z1">
<div style="margin: 6px; padding: 4px;">
<div class="p_title" style="font-size: 16px; font-style: bold;">Entity Master</div>
<div class="sub_title" style="font-size: 11px;">List of Entity Master Details</div>
</div>
</mat-card>-->
<ng-container *ngIf="enityList.length > 0">
<div style="padding: 0 12px;">
<mat-card class="product-card" *ngFor="let product of dataSource.connect() | async">
<div fxLayout="row" fxLayoutAlign="start start" style="padding: 6px 2px;">
<div fxFlex="90%" style="padding: 12px 8px;">
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="10%">
{{ product.entity_name }}
</div>
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="30%">
<div><b>{{ product.full_name }} ({{product.short_name}})</b></div>
<div> {{ product.branch_name }} </div>
<div> {{product.city_name}}, {{product.state_name}} </div>
</div>
<div fxFlex="0 1 auto" class="ml-xs" fxFlex="30%">
<div> {{ product.phone_number }}</div>
<div> {{ product.official_email }}</div>
</div>
</div>
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<div fxFlex="0 1 auto" class="ml-xs">
</div>
</div>
</div>
<div fxFlex="10%">
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="editEntity(product)"><mat-icon>edit</mat-icon></button>
</div>
</div>
</mat-card>
</div>
</ng-container>
<mat-card *ngIf="noQuesMasterRecrdFound">
<div class="no-record-found">No Record Found ... </div>
</mat-card>
<mat-paginator #paginator class="mat-elevation-z1" [length]="enityList.length" [pageIndex]="pageIndex" [pageSize]="pageSize"
[pageSizeOptions]="[5, 10, 25, 100]" (page)="pageEvent = $event; pageChange($event)">
</mat-paginator>
</mat-card>
</div>
<div *ngIf="!listView">
<app-entity-edit [childMessage]="parentMessage"></app-entity-edit>
</div>
<notifier-container></notifier-container>

View File

@ -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":[]}]}

View File

@ -0,0 +1,7 @@
import { Component } from '@angular/core';
@Component({
template: `<h2>Entity Master Details List</h2>
`
})
export class EntityComponent {
}

View File

@ -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 { }

View File

@ -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 {}

View File

@ -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<any> {
return this._http.get<any[]>(this.serviceUrl);
}
// get geo location master details list
getGeoLocationMasterDetails(): Observable<any> {
// Add safe, URL encoded search parameter if there is a search term
return this._http.get<any[]>(this.apiUrl + "getLocationHierarchy");
}
// get questions master details list
getEntityListMasterDetails(): Observable<any> {
// Add safe, URL encoded search parameter if there is a search term
return this._http.get<any[]>(this.apiUrl + "listAllEntites/any");
}
// get questions master details list
getQuestionMasterDetails(cid: any): Observable<any> {
// 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<any[]>(this.apiUrl + "listAllQuestions/get", options);
}
// add question master
addEntityMasterDetails(Records: any): Observable<any> {
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<any>(this.apiUrl + "saveNewEntity", { 'records': Records})
.pipe(
catchError(this.handleError('role', []))
)
}
// add question master
addQuestionMasterDetails(Records: any): Observable<any> {
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<any>(this.apiUrl + "saveNewQuestion", { 'records': Records})
.pipe(
catchError(this.handleError('role', []))
)
}
updateEntityMasterDetails(Records: any): Observable<any> {
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<any>(this.apiUrl + "saveExistEntity", { 'records': Records})
.pipe(
catchError(this.handleError('role', []))
)
}
updateQuestionMasterDetails(Records: any): Observable<any> {
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<any>(this.apiUrl + "saveExistQuestion", { 'records': Records})
.pipe(
catchError(this.handleError('role', []))
)
}
/**
* TO Handle The Error
*/
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
return of(result as T);
};
}
}

View File

@ -26,17 +26,20 @@ import { RouterModule } from '@angular/router';
import { SettingsRoutes } from './settings.routing'; import { SettingsRoutes } from './settings.routing';
import { RegisterComponent } from '../session/register/register.component'; import { RegisterComponent } from '../session/register/register.component';
import { UserService } from './service/user.service'; 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 { EntityModule } from './entity/entity.module';
// import { AddEntityComponent } from './entity/add-entity/add-entity.component'; // import { AddEntityComponent } from './entity/add-entity/add-entity.component';
// import { EditEntityComponent } from './entity/edit-entity/edit-entity.component'; // import { EditEntityComponent } from './entity/edit-entity/edit-entity.component';
// import { EntityListComponent } from './entity/entity-list/entity-list.component'; // import { EntityListComponent } from './entity/entity-list/entity-list.component';
import { EntityModule } from './entity/entity.module';
// import { HttpClientModule } from '@angular/common/http'; // import { HttpClientModule } from '@angular/common/http';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
RouterModule.forChild(SettingsRoutes),MatCardModule, RouterModule.forChild(SettingsRoutes),MatCardModule,
MastersModule,
EntityModule,
MatIconModule, MatIconModule,
MatInputModule, MatInputModule,
MatRadioModule, MatRadioModule,

View File

@ -1,5 +1,8 @@
import { Routes } from '@angular/router'; import { Routes } from '@angular/router';
import { MastersModule } from './masters/masters.module'; import { MastersModule } from './masters/masters.module';
import { EntityModule } from './entity/entity.module';
//import { EntityModule } from './entity/entity.module'; //import { EntityModule } from './entity/entity.module';
export const SettingsRoutes: Routes = [{ export const SettingsRoutes: Routes = [{
@ -10,7 +13,10 @@ export const SettingsRoutes: Routes = [{
},{ },{
path:'mastermodule', path:'mastermodule',
loadChildren:'./masters/masters.module#MastersModule' loadChildren:'./masters/masters.module#MastersModule'
}, },{
path:'entity',
loadChildren:'./entity/entity.module#EntityModule'
}
// { // {
// path:'entitymodule', // path:'entitymodule',
// loadChildren:'./entity/entity.module#EntityModule' // loadChildren:'./entity/entity.module#EntityModule'

View File

@ -33,9 +33,9 @@
<input matInput placeholder="User Id" [formControl]="regForm.controls['userid']"> <input matInput placeholder="User Id" [formControl]="regForm.controls['userid']">
</mat-form-field> </mat-form-field>
<span dividerColor="primary" class="ml-xs mr-xs" *ngIf="profileaccess"> <span dividerColor="primary" class="ml-xs mr-xs" *ngIf="profileaccess">
<img [src]="profileurl" style="width: 30%;height: 50%;"></span> <img [src]="profileurl" style="width: 17%;height: 50%;border-radius: 50%;"></span>
</div> </div>
<mat-card-title>Account Details</mat-card-title><hr/><br/> <mat-card-title>Account Details</mat-card-title><hr/><br/>
<div fxLayout="row" fxLayoutAlign="start center" class="mb-2"> <div fxLayout="row" fxLayoutAlign="start center" class="mb-2">
<mat-form-field dividerColor="primary" class="ml-xs mr-xs"> <mat-form-field dividerColor="primary" class="ml-xs mr-xs">

View File

@ -262,7 +262,7 @@ this.loader = true;
if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) { if (this.users.localUserId != '' && this.users.localUserId != null && this.users.localUserId !== undefined) {
this.usersData = this.users.localUserId; this.usersData = this.users.localUserId;
this.users.entityType().subscribe(res => { this.users.entityType().subscribe(res => {
this.types = res; this.types = res;
if (this.types.status == 200) { if (this.types.status == 200) {

View File

@ -4,7 +4,7 @@ import { AwsService } from '../../../AwsService/aws.service';
import { MatPaginator, MatTableDataSource,MatSort } from '@angular/material'; import { MatPaginator, MatTableDataSource,MatSort } from '@angular/material';
import { UserService } from '../../service/user.service'; import { UserService } from '../../service/user.service';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { CognitoService } from '../../../AwsService/cognito.service';
@Component({ @Component({
selector: 'app-user-list', selector: 'app-user-list',
templateUrl: './user-list.component.html', 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(); this.getusers();
} }

View File

@ -22,11 +22,12 @@
</div> --> </div> -->
<div fxLayout="row" fxLayoutWrap="wrap"> <div fxLayout="row" fxLayoutWrap="wrap">
<div fxFlex.gt-sm="25" fxFlex.gt-xs="50" fxFlex="100" class="relative"> <div fxFlex.gt-sm="25" fxFlex.gt-xs="50" fxFlex="100" class="relative">
<div class="profile-avatar"> <div class="profile-avatar" style="margin-left: 39%;margin-top:-12%;">
<img src="../../../assets/images/test3.jpg" width="200" height="200" alt="user">
<img [src]="profileurl ||''" width="200" height="200" alt="user">
</div> </div>
<div class="profile-info"> <div class="profile-info">
<h3 class="profile-name"><strong>{{userDetails.user_full_name}}</strong></h3> <!-- <h3 class="profile-name"><strong>{{userDetails.user_full_name}}</strong></h3>
<span class="user-name">{{userDetails.email}}</span> <span class="user-name">{{userDetails.email}}</span>
<span class="user-name">{{userDetails.mobile_no}}</span> <span class="user-name">{{userDetails.mobile_no}}</span>
@ -35,17 +36,20 @@
</span> </span>
<span><i class="fa fa-map-marker"></i> {{userDetails.addressline1}} {{userDetails.addressline2}}</span> <span><i class="fa fa-map-marker"></i> {{userDetails.addressline1}} {{userDetails.addressline2}}</span>
<span><i class="fa fa-calendar"></i>{{userDetails.addressline3}} {{userDetails.state_name}} - {{userDetails.pincode}}</span> <span><i class="fa fa-calendar"></i>{{userDetails.addressline3}} {{userDetails.state_name}} - {{userDetails.pincode}}</span>
<span>{{userDetails.createdon | date:'dd MMM yyyy'}}</span> <span>{{userDetails.createdon | date:'dd MMM yyyy'}}</span> -->
</div> </div>
</div> </div>
<div fxFlex.gt-sm="50" fxFlex.gt-xs="50" fxFlex="100" class="mt-1"> <div fxFlex.gt-sm="50" fxFlex.gt-xs="50" fxFlex="100" class="mt-1">
<div class="profile-content"> <div class="profile-content">
<div class="profile-head"> <div class="profile-head">
<h4>Tweets</h4>
<div fxFlex.gt-sm="25" fxFlex.gt-xs="25" fxFlexOffset="50" fxFlex="100" class="align-self-center"> <div fxFlex.gt-sm="25" fxFlex.gt-xs="25" fxFlexOffset="100" fxFlex="100" class="align-self-center">
<button type="button" class="UserActions-editButton edit-button EdgeButton EdgeButton--tertiary" data-scribe-element="profile_edit_button" (click)="changePassword()"> <button type="button" class="UserActions-editButton edit-button EdgeButton EdgeButton--tertiary" data-scribe-element="profile_edit_button" (click)="changePassword()">
<span class="button-text">Edit profile</span> <span class="button-text">Change Password</span>
</button> </button>
<button type="button" class="UserActions-editButton edit-button EdgeButton EdgeButton--tertiary" data-scribe-element="profile_edit_button" (click)="editprofile()">
<span class="button-text">Edit profile</span>
</button>
</div> </div>
<hr> <hr>
</div> </div>
@ -53,12 +57,12 @@
<ul class="pl-0"> <ul class="pl-0">
<li> <li>
<div fxLayout="row"> <div fxLayout="row">
<div fxFlex.xs="15" fxFlex.sm="15" fxFlex.md="15" fxFlex.lg="15" fxFlex.xl="15"> <img class="profile-thumb" src="../../../assets/images/test3.jpg" width="80" height="80" alt="user"> <div fxFlex.xs="15" fxFlex.sm="15" fxFlex.md="15" fxFlex.lg="15" fxFlex.xl="15"> <img class="profile-thumb" [src]="profileurl ||''" width="80" height="80" alt="user">
</div> </div>
<div class="pl-1 pr-1 profile-i" fxFlex.xs="85" fxFlex.sm="85" fxFlex.md="85" fxFlex.lg="85" fxFlex.xl="85"> <div class="pl-1 pr-1 profile-i" fxFlex.xs="85" fxFlex.sm="85" fxFlex.md="85" fxFlex.lg="85" fxFlex.xl="85">
<div> <div>
<span class="post-profile-head">{{userDetails.user_full_name}}</span> <span class="post-profile-head">{{userDetails.user_full_name}}</span>
<span class="twitter-uname"><i class="fa fa-email"></i> {{userDetails.email}}</span> <span class="twitter-uname"><i class="fa fa-email"></i> {{userDetails.email}}</span><br/>
<span class="time">{{userDetails.createdon | date:'dd MMM yyyy'}}</span> <span class="time">{{userDetails.createdon | date:'dd MMM yyyy'}}</span>
<p><i class="fa fa-mobile"></i> {{userDetails.mobile_no}}</p> <p><i class="fa fa-mobile"></i> {{userDetails.mobile_no}}</p>
<p>{{userDetails.addressline1}} {{userDetails.addressline2}} <br/> <p>{{userDetails.addressline1}} {{userDetails.addressline2}} <br/>
@ -66,11 +70,11 @@
</p> </p>
</div> </div>
<div class="profile-action"><a href=""><i class="fa fa-retweet"></i></a><a href=""><i class="fa fa-comment-o"></i></a><a href=""><i class="fa fa-heart-o"></i></a></div> <!-- <div class="profile-action"><a href=""><i class="fa fa-retweet"></i></a><a href=""><i class="fa fa-comment-o"></i></a><a href=""><i class="fa fa-heart-o"></i></a></div> -->
</div> </div>
</div> </div>
</li> </li>
<li> <!-- <li>
<div fxLayout="row"> <div fxLayout="row">
<div fxFlex.xs="15" fxFlex.sm="15" fxFlex.md="15" fxFlex.lg="15" fxFlex.xl="15"> <img class="profile-thumb" src="../../../assets/images/test3.jpg" width="80" height="80" alt="user"> <div fxFlex.xs="15" fxFlex.sm="15" fxFlex.md="15" fxFlex.lg="15" fxFlex.xl="15"> <img class="profile-thumb" src="../../../assets/images/test3.jpg" width="80" height="80" alt="user">
</div> </div>
@ -113,7 +117,7 @@
<div class="profile-action"><a href=""><i class="fa fa-retweet"></i></a><a href=""><i class="fa fa-comment-o"></i></a><a href=""><i class="fa fa-heart-o"></i></a></div> <div class="profile-action"><a href=""><i class="fa fa-retweet"></i></a><a href=""><i class="fa fa-comment-o"></i></a><a href=""><i class="fa fa-heart-o"></i></a></div>
</div> </div>
</div> </div>
</li> </li> -->
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -4,6 +4,7 @@ import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { CustomValidators } from 'ng2-validation'; import { CustomValidators } from 'ng2-validation';
import { UserService } from '../../service/user.service'; import { UserService } from '../../service/user.service';
import { Router} from '@angular/router';
@Component({ @Component({
selector: 'ms-user-profile', selector: 'ms-user-profile',
templateUrl:'./user-profile-component.html', templateUrl:'./user-profile-component.html',
@ -11,6 +12,7 @@ import { UserService } from '../../service/user.service';
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class UserProfileComponent implements OnInit { export class UserProfileComponent implements OnInit {
profileurl: any;
config: MatDialogConfig = { config: MatDialogConfig = {
disableClose: false, disableClose: false,
width: '', width: '',
@ -23,8 +25,9 @@ export class UserProfileComponent implements OnInit {
} }
}; };
userDetails:any=[]; 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(); this.getuser();
} }
ngOnInit() { ngOnInit() {
@ -38,6 +41,7 @@ export class UserProfileComponent implements OnInit {
this.users.getroles().subscribe(res=>{ this.users.getroles().subscribe(res=>{
this.userDetails = res; this.userDetails = res;
this.userDetails = this.userDetails.records[0]; this.userDetails = this.userDetails.records[0];
this.getprofilepic();
}); });
} }
changePassword(){ changePassword(){
@ -52,10 +56,30 @@ export class UserProfileComponent implements OnInit {
}) })
} }
} }
//console.log(ChangePasswordDialog.prototype.pass); //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({ @Component({

View File

@ -34,7 +34,7 @@ const MENUITEMS : Menu[] = [
children:[ children:[
{state:'users',name:'User List'}, {state:'users',name:'User List'},
{state:'mastermodule',name:'Master Details'}, {state:'mastermodule',name:'Master Details'},
// {state:'entitymodule',name:'Entity Type'} {state:'entity',name:'Entity Details'}
] ]
}, },
{ {