diff --git a/ng6-seed/package-lock.json b/ng6-seed/package-lock.json index acab22cae..656543677 100644 --- a/ng6-seed/package-lock.json +++ b/ng6-seed/package-lock.json @@ -950,6 +950,11 @@ "resolved": "https://registry.npmjs.org/angular-draggable-droppable/-/angular-draggable-droppable-2.0.0.tgz", "integrity": "sha512-/b8LIGamjOKnDI2uG1jRUErTIHeQ3w2WqHn4cbeiUTy+6eNHjkQI32DNhvxl0nVxr2gF5QluECNB4uWjMMyzQg==" }, + "angular-notifier": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/angular-notifier/-/angular-notifier-4.1.1.tgz", + "integrity": "sha512-QrL5cW3GDjONy6Ack+HIgd3tUf93ztkPT6C551/pqOaE69Ad2YDem+JyBLnlLKBnCFUxhKkSVnv/Ak2HsOrBxQ==" + }, "angular-resizable-element": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/angular-resizable-element/-/angular-resizable-element-2.0.0.tgz", @@ -7203,6 +7208,11 @@ "resolved": "https://registry.npmjs.org/ng2-file-upload/-/ng2-file-upload-1.2.1.tgz", "integrity": "sha1-VWPF39b0P7++gVwgbjQ0ZKCmoZc=" }, + "ng2-toastr": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/ng2-toastr/-/ng2-toastr-4.1.2.tgz", + "integrity": "sha1-G0UvBxOZYcOPhmxuJKBiR++iGxE=" + }, "ng2-validation": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/ng2-validation/-/ng2-validation-4.2.0.tgz", diff --git a/ng6-seed/package.json b/ng6-seed/package.json index 7dca4c1b4..299250298 100644 --- a/ng6-seed/package.json +++ b/ng6-seed/package.json @@ -31,6 +31,7 @@ "@swimlane/ngx-datatable": "11.1.5", "amazon-cognito-identity-js": "^2.0.27", "angular-calendar": "0.23.3", + "angular-notifier": "^4.1.1", "angular-sortablejs": "^2.0.6", "angular-tree-component": "6.1.0", "chart.js": "2.6.0", @@ -47,6 +48,7 @@ "ng2-charts": "1.6.0", "ng2-dragula": "1.3.1", "ng2-file-upload": "1.2.1", + "ng2-toastr": "^4.1.2", "ng2-validation": "4.2.0", "ngx-color-picker": "^4.0.3", "ngx-mat-select-search": "^1.3.1", diff --git a/ng6-seed/src/app/app.routing.ts b/ng6-seed/src/app/app.routing.ts index a4d27b61d..deeef0a53 100644 --- a/ng6-seed/src/app/app.routing.ts +++ b/ng6-seed/src/app/app.routing.ts @@ -22,6 +22,9 @@ export const AppRoutes: Routes = [{ ,{ path:'pdtrigger', loadChildren:'./pd-triger/pd-triger.module#PdTrigerModule' + },{ + path:'template', + loadChildren:'./template/template.module#TemplateModule' } ] }, { diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html index ce7513af8..a30235d64 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html @@ -1,164 +1,198 @@ -
- -
-
-
- -
PD Details
- -
- - - - - - {{LL.lender_hierarchy}} - - You must include a Pick up Lender Name. - - - - - - - - You must include Lender Applicant Id. - - - - - - {{PL.name}} - - - - - - - - - {{SPL.name}} - - - - - - - {{CSL.name}} - - - - - - - {{PDL.type_name}} - - - - - - - - - - + + +
+
+
+ +
PD Details
+ +
+ - - - + + + + {{LL.lender_hierarchy}} + + You must include a Pick up Lender Name. + + + + + + + + You must include Lender Applicant Id. + + + + + + {{PL.name}} + + + - - - - - - ` - {{CL.name}} - - - - - - - - {{SL.name}} - - - - - - - -
- -
-
-
-
-
- -
Main Applicant Details
- - - - - - - - - - - - - - - - - - -
-
-
-
-
- - -
{{PDtriggerForm.controls.items.controls[i].controls.label.value}} {{i+1}}
-
- - - - - - + + + + + {{SPL.name}} + + + + + + + {{CSL.name}} + + + + + + + {{PDL.type_name}} + + + + + + + + + + + + + + + + + + + + + ` + {{CL.name}} + + + + + + + + {{SL.name}} + + + + + + +
-
-
+ + +
+
+
+
+ +
Main Applicant Details
+ + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + +
{{PDtriggerForm.controls.items.controls[i].controls.label.value}} {{i+1}}
+
+ + + + + + +
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ + -
- - - - -
-
- - - - - - - - - + + + + + \ No newline at end of file diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts index ffc9a5490..cabd1804f 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts @@ -1,7 +1,8 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation, Output, EventEmitter } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms'; import { CustomValidators } from 'ng2-validation'; import { PdTrigerService } from '../pd-service/pd-triger.service'; +import { AwsService } from '../../AwsService/aws.service'; @Component({ selector: 'app-add-pd', @@ -10,6 +11,8 @@ import { PdTrigerService } from '../pd-service/pd-triger.service'; encapsulation: ViewEncapsulation.None }) export class AddPdComponent implements OnInit { + @Output() loadParent = new EventEmitter(); + public PDtriggerForm: FormGroup; items: FormArray; CityList: any; @@ -25,10 +28,14 @@ export class AddPdComponent implements OnInit { // Dynamic co applicant createWithLongContent = false; dynamicCoApplicant = []; - constructor(private _fb: FormBuilder, - private _pd: PdTrigerService) { } + constructor(private _fb: FormBuilder, + private _pd: PdTrigerService, private _aws:AwsService) { } + public totalfiles: Array =[]; + public totalFileName = []; + public lengthCheckToaddMore =0; ngOnInit() { + this.PDtriggerForm = this._fb.group({ fk_lender_id: [null, Validators.compose([Validators.required])], lender_applicant_id: [null, Validators.compose([Validators.required])], @@ -36,7 +43,7 @@ export class AddPdComponent implements OnInit { fk_subproduct_id: [null, Validators.compose([Validators.required])], fk_pd_type: [null, Validators.compose([Validators.required])], fk_customer_segment: [null, Validators.compose([Validators.required])], - loan_amount: [null], + loan_amount: [null, Validators.compose([Validators.required])], applicant_name: [null, Validators.compose([Validators.required])], mobile_no: [null, Validators.compose([Validators.required])], email: [null, Validators.compose([Validators.required, CustomValidators.email])], @@ -45,8 +52,9 @@ export class AddPdComponent implements OnInit { addressline3: [null], fk_city: [null, Validators.compose([Validators.required])], fk_state: [null, Validators.compose([Validators.required])], -   pincode : [null], - items: this._fb.array([]) +   pincode : [null, Validators.compose([Validators.required])], + items: this._fb.array([]), + documents: this._fb.array([]) }); this._pd.getAllMasterDatas('CITY') @@ -142,11 +150,135 @@ this._pd.getAllMasterDatas('PDTYPE') this.items.push(this.createItem()); } } - submitPdDetails() { - if(this.PDtriggerForm.valid){ - var my_array = this.PDtriggerForm.value; - Object.keys(my_array).forEach((key) => ( my_array[key] == null) && delete my_array[key]); + + addMoreDocs() { + if(this.totalfiles.length!=0){ + + + if( this.documents.value[0].doc_name != "" && ((this.lengthCheckToaddMore) === (this.totalfiles.length)) ) + { + this.documents.insert(0, this.generateDocuments()) + this.lengthCheckToaddMore=this.lengthCheckToaddMore+1; } } + else if(this.totalfiles.length===0 && this.lengthCheckToaddMore===0){ + this.documents.insert(0, this.generateDocuments()) + this.lengthCheckToaddMore=this.lengthCheckToaddMore+1; + } + } + generateDocuments(): FormGroup { + return this._fb.group({ + doc_name: [null, Validators.compose([Validators.required])], + documentFile : [null, Validators.compose([Validators.required])], + }); + } + get documents(): FormArray { + return this.PDtriggerForm.get('documents') as FormArray; + }; + + removeItem(index: number) { + this.totalfiles.splice(index,1); + this.totalFileName.splice(index,1); + this.documents.removeAt(index); + this.lengthCheckToaddMore=this.lengthCheckToaddMore-1; + } + + public fileSelectionEvent(fileInput: any,oldIndex:number) { + + + if (fileInput.target.files && fileInput.target.files[0]) { + var reader = new FileReader(); + reader.onload = (event: any) => { + } + + if(oldIndex==0) + { + this.totalfiles.unshift((fileInput.target.files[0])) + this.totalFileName.unshift(fileInput.target.files[0].name) + } + else + { + this.totalfiles[oldIndex]=(fileInput.target.files[0]); + this.totalFileName[oldIndex]=fileInput.target.files[0].name + } + + reader.readAsDataURL(fileInput.target.files[0]); + } + + if(this.totalfiles.length == 1) + { + this.lengthCheckToaddMore=1; + } + } + submitPdDetails(formValue: any) { + if(this.PDtriggerForm.valid){ + // let my_array = this.PDtriggerForm.value; + // Object.keys(my_array).forEach((key) => ( my_array[key] == null) && delete my_array[key]); + let pd_details:any={ + "fk_lender_id":formValue.fk_lender_id, + "lender_applicant_id":formValue.lender_applicant_id, + "fk_product_id":formValue.fk_product_id.product_id, + "fk_subproduct_id":formValue.fk_subproduct_id.subproduct_id, + "fk_pd_type":formValue.fk_pd_type, + "fk_customer_segment":formValue.fk_customer_segment, + "loan_amount":formValue.loan_amount, + "addressline1":formValue.addressline1, + "addressline2":formValue.addressline2, + "addressline3":formValue.addressline3, + "fk_city":formValue.fk_city.city_id, + "fk_state":formValue.fk_state.state_id, + "pincode ":formValue.pincode , + "fk_createdby" : this._aws.getlocale(), + "createdon": new Date().toJSON().slice(0,19).replace('T',' ') + }; + let pd_applicant_details : any=[{ + "applicant_name":formValue.applicant_name, + "email":formValue.email, + "mobile_no":formValue.mobile_no, + "applicant_type":1, + "relationship":"", + }]; + formValue.items.forEach((itemElement, itemIndex) => { + let obj1 = { + "applicant_name":itemElement.coapplicantName, + "relationship":itemElement.relationship, + "email":"", + "mobile_no":"", + "applicant_type":0, + } + pd_applicant_details.push(obj1) + }); + + // docs details + let pd_form: FormData = new FormData(); + + for(let j=0;jthis.totalfiles[j]) + } + + //reverseFileNames=this.totalFileName.reverse(); + + let AllFilesObj= [] + + formValue.documents.forEach((element, index) => { + // let eachObj= + // { + // 'doc_name' : element.doc_name, + // 'file_name' : this.totalFileName[index] + // } + AllFilesObj.push(element.doc_name); + }); + pd_form.append("pd_details",JSON.stringify(pd_details)) + pd_form.append("pd_applicant_details",JSON.stringify(pd_applicant_details)) + pd_form.append("pd_document_titles",JSON.stringify(AllFilesObj)) + + this._pd.addPdDetails(pd_form).subscribe(); + } + } + loadPdListCompoent() { + this.loadParent.emit('1') + } } diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html new file mode 100644 index 000000000..cb6987e03 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.html @@ -0,0 +1,11 @@ + + + + {{ childData }} + +
+ + + +
+ diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.scss b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts new file mode 100644 index 000000000..ad598b308 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditPdComponent } from './edit-pd.component'; + +describe('EditPdComponent', () => { + let component: EditPdComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditPdComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditPdComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts new file mode 100644 index 000000000..b9c660080 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/edit-pd/edit-pd.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit,ViewEncapsulation, EventEmitter, Input, Output } from '@angular/core'; +import { ListPdComponent } from '../list-pd/list-pd.component'; + +@Component({ + selector: 'app-edit-pd', + templateUrl: './edit-pd.component.html', + styleUrls: ['./edit-pd.component.scss'], + encapsulation: ViewEncapsulation.None +}) +export class EditPdComponent implements OnInit { + @Input() childData: string; + @Output() loadParent = new EventEmitter(); + constructor() { + + } + + ngOnInit() { + } + loadPdListCompoent() { + this.loadParent.emit('2') + } + +} diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html new file mode 100644 index 000000000..ee96ba06a --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.html @@ -0,0 +1,171 @@ +
+ +
+ + + + All PD Details + +
+ + + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +

{{details.applicat_details[0].applicant_name}}

+ +

{{details.lender_applicant_id}}   {{details.pd_date_of_initiation}}

+

{{details.product_abbr}}/{{details.subproduct_abbr}}/{{details.customer_segment_abbr}}   {{details.loan_amount}}    {{details.state_name}}/{{details.city_name}}

+ + +
+ + + +
+
+ + + + +
+
+
+ + +
+ +
+
+ + + +
+ + Confirmed PD Details + + + + {{tile.text}} + + +
+ + + +
+
+
+ + In Progress PD Details + + + + {{tile.text}} + + +
+ + + + + + +
+
+
+ +
+
+ + + diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.scss b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.scss new file mode 100644 index 000000000..b1e122b24 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.scss @@ -0,0 +1,5 @@ +.ic-change:hover { + transform: scale(1.1); + color: green; +} + diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts new file mode 100644 index 000000000..e91599347 --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ListPdComponent } from './list-pd.component'; + +describe('ListPdComponent', () => { + let component: ListPdComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListPdComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListPdComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts new file mode 100644 index 000000000..e64b9d67e --- /dev/null +++ b/ng6-seed/src/app/pd-triger/list-pd/list-pd.component.ts @@ -0,0 +1,115 @@ +import { Component, OnInit, ViewEncapsulation, EventEmitter, Output } from '@angular/core'; +import { PdTrigerService } from '../pd-service/pd-triger.service'; + +@Component({ + selector: 'app-list-pd', + templateUrl: './list-pd.component.html', + styleUrls: ['./list-pd.component.scss'], + encapsulation: ViewEncapsulation.None +}) +export class ListPdComponent implements OnInit { + parentEditData :string; + showParentComponent:boolean; + showAddComponent:boolean; + showEditComponent:boolean; + errorMessage: any; + pdList:any[]; + tiles: any[] = [{ + text: 'One', + cols: 3, + rows: 1, + color: 'lightblue' + }, { + text: 'Two', + cols: 1, + rows: 1, + color: 'lightgreen' + }, { + text: 'Three', + cols: 1, + rows: 1, + color: 'lightpink' + }, { + text: 'Four', + cols: 2, + rows: 1, + color: '#DDBDF1' + }]; + + dogs: Object[] = [{ + name: 'Porter', + human: 'Kara' + }, { + name: 'Mal', + human: 'Jeremy' + }, { + name: 'Koby', + human: 'Igor' + }, { + name: 'Razzle', + human: 'Ward' + }, { + name: 'Molly', + human: 'Rob' + }, { + name: 'Husi', + human: 'Matias' + }]; + + basicRowHeight = 80; + fixedCols = 4; + fixedRowHeight = 50; + ratioGutter = 1; + fitListHeight = '400px'; + ratio = '8:1'; + + addTileCols() { + this.tiles[2].cols++; + } + constructor(private _pd: PdTrigerService) { + } + + ngOnInit() { + this.showParentComponent=true + this.showAddComponent=false + this.showEditComponent=false + this._pd.getPdDetails() + .subscribe( + data => { + if (data.status == 200) { + this.pdList = data.records; + } + }, error => this.errorMessage = error); + } + addPdDetails(){ + this.showParentComponent=false + this.showEditComponent=false + this.showAddComponent=!this.showAddComponent + + + } + + editPdDetails(editID:string){ + this.showParentComponent=false + this.showAddComponent=false + this.showEditComponent=!this.showEditComponent + this.parentEditData=editID + } + updateParentComponent(event:string) { + this.showParentComponent=!this.showParentComponent + if(event=='1'){ + this.showAddComponent=!this.showAddComponent + } + else if(event=='2'){ + this.showEditComponent=!this.showEditComponent + } + this._pd.getPdDetails() + .subscribe( + data => { + if (data.status == 200) { + this.pdList = data.records; + } + }, error => this.errorMessage = error); +} + +} diff --git a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts index e0139e295..1babea421 100644 --- a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts @@ -32,6 +32,18 @@ export class PdTrigerService { catchError(this.handleError('role', [])) ) } + addPdDetails(pdForm: any): Observable { + return this._http.post(this.apiUrl+"triggerNewPD", pdForm) + .pipe( + catchError(this.handleError('operation', [])) + ) + } + getPdDetails(): Observable { + return this._http.get(this.apiUrl+"listLessPDDetails/get") + .pipe( + catchError(this.handleError('operation', [])) + ) + } private handleError(operation = 'operation', result?: T) { return (error: any): Observable => { diff --git a/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts b/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts index 68107874b..cf23e2a3d 100644 --- a/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts +++ b/ng6-seed/src/app/pd-triger/pd-triger-routing.module.ts @@ -1,11 +1,12 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; +import { ListPdComponent } from './list-pd/list-pd.component'; import { AddPdComponent } from './add-pd/add-pd.component'; export const PdTrigerRoutes: Routes = [ { path: '', - component: AddPdComponent + component: ListPdComponent // children: // [{ // path: 'pdtriggerlist', diff --git a/ng6-seed/src/app/pd-triger/pd-triger.module.ts b/ng6-seed/src/app/pd-triger/pd-triger.module.ts index 2e161ca0a..0dab02906 100644 --- a/ng6-seed/src/app/pd-triger/pd-triger.module.ts +++ b/ng6-seed/src/app/pd-triger/pd-triger.module.ts @@ -8,7 +8,7 @@ import { MatRadioModule, MatButtonModule,MatTableModule,MatPaginatorModule, MatProgressBarModule,MatDialogModule, MatSortModule, - MatToolbarModule,MatSelectModule } from '@angular/material'; + MatToolbarModule,MatSelectModule, MatListModule, MatGridListModule, MatTabsModule } from '@angular/material'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; @@ -22,6 +22,8 @@ import 'hammerjs'; import { PdTrigerRoutes } from './pd-triger-routing.module'; import { AddPdComponent } from './add-pd/add-pd.component'; import { PdTrigerService } from './pd-service/pd-triger.service'; +import { ListPdComponent } from './list-pd/list-pd.component'; +import { EditPdComponent } from './edit-pd/edit-pd.component'; @NgModule({ imports: [ @@ -39,14 +41,14 @@ import { PdTrigerService } from './pd-service/pd-triger.service'; FlexLayoutModule, NgxDatatableModule, FormsModule,MatSlideToggleModule, - MatSelectModule, + MatSelectModule, MatListModule,MatGridListModule, MatTabsModule, ReactiveFormsModule, FileUploadModule, TreeModule, MatDialogModule, NgxMatSelectSearchModule ], - declarations: [AddPdComponent], + declarations: [AddPdComponent, ListPdComponent, EditPdComponent], providers: [PdTrigerService] }) export class PdTrigerModule { } 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 3b3c21b44..2eec5e065 100644 --- a/ng6-seed/src/app/shared/menu-items/menu-items.ts +++ b/ng6-seed/src/app/shared/menu-items/menu-items.ts @@ -45,6 +45,14 @@ const MENUITEMS : Menu[] = [ // children:[ // {state:'pdtriggerlist',name:'Pd Trigger Listing'} // ] + },{ + state: 'template', + name: 'Template', + type: 'sub', + icon: 'art_track', + children: [ + {state: 'questions', name: 'Questions'} + ] }, { state: 'authentication', diff --git a/ng6-seed/src/app/template/questions/add/add.component.html b/ng6-seed/src/app/template/questions/add/add.component.html new file mode 100644 index 000000000..c088d4150 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.html @@ -0,0 +1,77 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+
+ +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + +
+
+
+
+ + +
+
+ + +
+ + +
+ +
+
+
\ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/add/add.component.scss b/ng6-seed/src/app/template/questions/add/add.component.scss new file mode 100644 index 000000000..6e263adae --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/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/template/questions/add/add.component.spec.ts b/ng6-seed/src/app/template/questions/add/add.component.spec.ts new file mode 100644 index 000000000..fdcddf4c8 --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AddComponent } from './add.component'; + +describe('AddComponent', () => { + let component: AddComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AddComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AddComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/add/add.component.ts b/ng6-seed/src/app/template/questions/add/add.component.ts new file mode 100644 index 000000000..c8824cd9e --- /dev/null +++ b/ng6-seed/src/app/template/questions/add/add.component.ts @@ -0,0 +1,163 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject +} from '@angular/core'; + +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 { QuestionsService } from './../../service/questions/questions.service'; + +/* +* Question master add details +* : kdk +*/ +@Component({ + selector: 'app-add', + templateUrl: './add.component.html', + styleUrls: ['./add.component.scss'] +}) +export class AddComponent implements OnInit { + + public pageTitle: string = "Add Question Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public questionsOptions: any = []; + errorMessage: string; + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private _formBuilder: FormBuilder, + private dialogRef: MatDialogRef, + private masterService: MastersService, + private questionsService: QuestionsService) { + this.notifier = notifier; + } + + + ngOnInit() { + /** Questions Form Datas*/ + this._addQuesFrom = this._formBuilder.group({ + question: [null, Validators.compose([Validators.required])], + description: [null, Validators.compose([Validators.required])], + fk_question_catagory: [null, Validators.compose([Validators.required])], + fk_question_answertype: [null, Validators.compose([Validators.required])], + answers: this._formBuilder.array([ + this.initAnswers(), + ]) + }); + // OnInit Load Category and Question Type Masters + this.getCategoryListMaster(); + this.getQuestionOptionsMaster(); + } + + // 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({ + answer: ['', Validators.compose([Validators.required])] + }); + } + addLanguage(e) { + const control = this._addQuesFrom.controls['answers']; + control.push(this.initAnswers()); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['answers']; + control.removeAt(i); + } + + // END ===> + + getCategoryListMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + this.notifier.notify('warning', 'No Category Records Found.!'); + this.errorMessage = "No Category Records Found."; + } + ) + } + getQuestionOptionsMaster() { + this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe( + data => { + this.questionsOptions = data.records; + }, + 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(); + } + + /** 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 answerFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + //Add BRANCH data with help Service File + this.questionsService.addQuestionMasterDetails(answerFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify('success', 'Record Saved Successfully.!'); + this.dialogRef.close(); + // alert("sample alert for Saving"); + } + 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 !"; + this.dialogRef.close(); + }); + //After Saving the BRANCH data then popup close + // this.dialogRef.close(); + } + } + + /** To Reset Popup Data */ + onReset() { + this._addQuesFrom.reset(); + } +} diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.html b/ng6-seed/src/app/template/questions/edit/edit.component.html new file mode 100644 index 000000000..159e706ca --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.html @@ -0,0 +1,87 @@ +
+ +
+

{{pageTitle}}

+
+
+ +
+
+ +
+ +
+ + + {{ ct.categroy_name }} + + You must Select Category. + +
+
+ + + You must Include Question. + +
+
+ + + You must Include Description. + +
+
+ + + {{ ans.answer_type_name }} + + You must Select Answer Type. + +
+
+
+
+
+
+
+ + + + + +
+
+ + + + +
+
+
+
+ + +
+
+
+ Active/InActive +
+ + +
+ + +
+ +
+
+
+ + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.scss b/ng6-seed/src/app/template/questions/edit/edit.component.scss new file mode 100644 index 000000000..6e263adae --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.scss @@ -0,0 +1,3 @@ +.example-full-width{ + width: 100%; +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts b/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts new file mode 100644 index 000000000..34ef921a1 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditComponent } from './edit.component'; + +describe('EditComponent', () => { + let component: EditComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/edit/edit.component.ts b/ng6-seed/src/app/template/questions/edit/edit.component.ts new file mode 100644 index 000000000..20dd63a40 --- /dev/null +++ b/ng6-seed/src/app/template/questions/edit/edit.component.ts @@ -0,0 +1,201 @@ +/** Common Imports */ +import { + Component, + OnInit, + Inject +} from '@angular/core'; + +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 { QuestionsService } from './../../service/questions/questions.service'; + +/* +* Question master details edit component +* : kdk +*/ +@Component({ + selector: 'app-edit', + templateUrl: './edit.component.html', + styleUrls: ['./edit.component.scss'] +}) +export class EditComponent implements OnInit { + + + public pageTitle: string = "Edit Question Details"; + public _addQuesFrom: FormGroup; + public submitted = false; + public categories: any = []; + public questionsOptions: any = []; + errorMessage: string; + + + /** + * Notifier service + */ + private notifier: NotifierService; + + constructor( + notifier: NotifierService, + private _formBuilder: FormBuilder, + private dialogRef: MatDialogRef, + private masterService: MastersService, + private questionsService: QuestionsService, + @Inject(MAT_DIALOG_DATA) public data: any) { + this.notifier = notifier; + } + + ngOnInit() { + this.loadFormData(); + if (this.data["0"].length > 0) { + for (let val of this.data["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); + } + } + // OnInit Load Category and Question Type Masters + this.getCategoryListMaster(); + this.getQuestionOptionsMaster(); + } + + // load answer details list + loadAnsData() { + if (this.data["0"].length > 0) { + for (let val of this.data["0"]) { + // alert(JSON.stringify(val)); + let vals = val; + this.addLanguage(vals['answer'], vals['question_answer_id'], vals['isactive'], null); + } + } + } + + // load form data form the master + loadFormData() { + /** Questions Form Datas*/ + this._addQuesFrom = this._formBuilder.group({ + question_id: [this.data.question_id], + question: [this.data.question, Validators.compose([Validators.required])], + description: [this.data.description, Validators.compose([Validators.required])], + fk_question_catagory: [this.data.fk_question_catagory, Validators.compose([Validators.required])], + fk_question_answertype: [this.data.fk_question_answertype, Validators.compose([Validators.required])], + isactive: [this.data.isactive], + answers: this._formBuilder.array([ + // this.initAnswers(null, null), + ]) + }); + } + + // convenience getter for easy access to form fields + get f() { return this._addQuesFrom.controls; } + + // form answer details access + get f_ans() { return this._addQuesFrom.get('answers'); } + + + // Dynamic Form field creation Functionality : START ===> + initAnswers(ans, fk_id, isAct) { + isAct = isAct == null ? 1 : isAct; + return this._formBuilder.group({ + answer: [ans, Validators.compose([Validators.required])], + question_answer_id: [fk_id], + isactive: [isAct] + }); + } + addLanguage(ans, fk_id, isAct, e) { + const control = this._addQuesFrom.controls['answers']; + control.push(this.initAnswers(ans, fk_id, isAct)); + } + removeLanguage(i: number) { + const control = this._addQuesFrom.controls['answers']; + control.removeAt(i); + } + + // END ===> + + getCategoryListMaster() { + this.masterService.getAllMasterData('QUESTIONCATEGORY').subscribe( + data => { + this.categories = data.records.filter(category => category.isactive == 1); + }, + error => { + this.notifier.notify('warning', 'No Category Records Found.!'); + this.errorMessage = "No Category Record Found."; + } + ) + } + getQuestionOptionsMaster() { + this.masterService.getAllMasterData('QUESTIONANSWERTYPE').subscribe( + data => { + this.questionsOptions = data.records; + }, + 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(); + } + + /** 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 answerFormValues = this._addQuesFrom.value; + + //To Remove The "Null" With Key also + Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); + + //Add BRANCH data with help Service File + this.questionsService.updateQuestionMasterDetails(answerFormValues).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.notifier.notify('success', 'Your Changes Updated.!'); + this.dialogRef.close(); + // this.notifierService('success', 'You are awesome! I mean it!'); + // alert("sample alert for Saving"); + } + else { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Something Wents Wrong Try Again.!"; + } + }, error => { + this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); + this.errorMessage = "Some Thing Wents Wrong Try Again.!"; + this.dialogRef.close(); + }); + //After Saving the BRANCH data then popup close + // this.dialogRef.close(); + } + } + + /** To Reset Popup Data */ + onReset() { + // this._addQuesFrom.reset(); + this.loadFormData(); + this.loadAnsData(); + } + +} diff --git a/ng6-seed/src/app/template/questions/list/list.component.html b/ng6-seed/src/app/template/questions/list/list.component.html new file mode 100644 index 000000000..d4f6ed730 --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.html @@ -0,0 +1,119 @@ +
+ + +
+
Questions Master
+
List of Questions
+
+
+
+
+
+ + + + + {{cat.categroy_name}} + + +
+
+
+
+ +
+
+ +
+ + +
+ +
+ +
+ +
+
+ {{ product.categroy_name }} +
+
+
{{ product.question }} +
+
+
+
+
+ + +
+
+ +
+
+
+ +
No Record Found ...
+
+ + + + +
+
+ + + + \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/list/list.component.scss b/ng6-seed/src/app/template/questions/list/list.component.scss new file mode 100644 index 000000000..fa863a272 --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.scss @@ -0,0 +1,52 @@ +// mat table css + +.example-container { + display: flex; + flex-direction: column; + min-width: 300px; +} + +.example-header { + min-height: 64px; + padding: 8px 24px 0; +} + +.mat-form-field { + font-size: 14px; +// width: 100%; +} + +.mat-table { + overflow: auto; + max-height: 500px; +} + +.text-line-limit { + text-overflow: ellipsis; + overflow: hidden; + // white-space: nowrap; + display: -webkit-box; + line-height: 16px; /* fallback */ + max-height: 32px; /* fallback */ + -webkit-line-clamp: 2; /* number of lines to show */ + -webkit-box-orient: vertical; + + // text-overflow: ellipsis; + // overflow: hidden; + // width: 160px; + // height: 1.2em; + // white-space: nowrap; +} + +.category-label { + padding: 2px 6px; + background: #629cff; + color: #fff; + box-shadow: 0 2px 3px #c8bbbb; +} + +.no-record-found { + font-size: 18px; + color: #03a9f4; + padding : 12px 8px; +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/questions/list/list.component.spec.ts b/ng6-seed/src/app/template/questions/list/list.component.spec.ts new file mode 100644 index 000000000..beacd156f --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ListComponent } from './list.component'; + +describe('ListComponent', () => { + let component: ListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/questions/list/list.component.ts b/ng6-seed/src/app/template/questions/list/list.component.ts new file mode 100644 index 000000000..4ef7238db --- /dev/null +++ b/ng6-seed/src/app/template/questions/list/list.component.ts @@ -0,0 +1,142 @@ +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder } from '@angular/forms'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; +import { QuestionsService } from './../../service/questions/questions.service'; +import { MastersService } from './../../service/masters/masters.service'; +/** Dialog Component */ +import { AddComponent } from './../add/add.component'; +import { EditComponent } from './../edit/edit.component'; + +/* +* Questions master List component +* : kdk +*/ +@Component({ + selector: 'app-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'] +}) +export class ListComponent implements OnInit { + + public productList: any[] = []; + public paginationList: any[] = []; + public categories: any = []; + public search_cid: any = null; + public noQuesMasterRecrdFound: boolean = false; + + public filterFormGroupCtrl: FormGroup; + + // 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 questionsService: QuestionsService, + private masterService: MastersService, + private _formBuilder: FormBuilder) { + this.filterFormGroupCtrl = this._formBuilder.group({ + category: [null, ''] + }); + } + + ngOnInit() { + this.getCategorMaster(); + this.getQuestionsMasters(); + } + + // get question master list details + getQuestionsMasters() { + this.noQuesMasterRecrdFound = false; + this.search_cid = this.filterFormGroupCtrl.controls.category.value; + console.log(this.search_cid + ", " + this.filterFormGroupCtrl); + this.questionsService.getQuestionMasterDetails(this.search_cid).subscribe( + data => { + if (data) { + if (data.records) { + this.productList = data.records; + this.questionListData = data.records; + this.dataLength = data.records.length; + this.dataSource.data = this.questionListData; + } else { + this.productList = []; + this.dataLength = null; + this.noQuesMasterRecrdFound = true; + } + } else { + this.productList = []; + 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() { + const dialogRef = this.dialog.open(AddComponent, { + data: {}, + disableClose: true + }); + dialogRef.afterClosed() + .subscribe(dataresult => { + this.getQuestionsMasters(); + // this.getBranch(); + // this.isPopupOpened = false; + }); + } + + // 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); + } + +} diff --git a/ng6-seed/src/app/template/questions/questions.module.ts b/ng6-seed/src/app/template/questions/questions.module.ts new file mode 100644 index 000000000..e5e6301fb --- /dev/null +++ b/ng6-seed/src/app/template/questions/questions.module.ts @@ -0,0 +1,108 @@ +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'; + +// Questions Routing import +import { QuestionsRouting } from './questions.routing'; +// Questions List +import { ListComponent } from './list/list.component'; + +import { QuestionsService } from './../service/questions/questions.service'; +import { AddComponent } from './add/add.component'; +import { EditComponent } from './edit/edit.component'; +/* +* Question Master Module details +* : kdk +*/ +/** + * 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, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule, + MatSlideToggleModule, + MatCheckboxModule, + FormsModule, + ReactiveFormsModule, + QuestionsRouting + ], + declarations: [ + ListComponent, + AddComponent, + EditComponent + ], + entryComponents: [ + AddComponent, + EditComponent + ], + providers: [ + QuestionsService + ] +}) +export class QuestionsModule { } diff --git a/ng6-seed/src/app/template/questions/questions.routing.ts b/ng6-seed/src/app/template/questions/questions.routing.ts new file mode 100644 index 000000000..0f07ea048 --- /dev/null +++ b/ng6-seed/src/app/template/questions/questions.routing.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +// Questions List +import { ListComponent } from './list/list.component'; +/* +* Question Master Router Module details +*/ +const routes: Routes = [ + { + path: '', + component: ListComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class QuestionsRouting {} diff --git a/ng6-seed/src/app/template/service/masters/masters.service.spec.ts b/ng6-seed/src/app/template/service/masters/masters.service.spec.ts new file mode 100644 index 000000000..2550bd5a4 --- /dev/null +++ b/ng6-seed/src/app/template/service/masters/masters.service.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { MastersService } from './masters.service'; + +describe('MastersService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [MastersService] + }); + }); + + it('should be created', inject([MastersService], (service: MastersService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/ng6-seed/src/app/template/service/masters/masters.service.ts b/ng6-seed/src/app/template/service/masters/masters.service.ts new file mode 100644 index 000000000..0448504d2 --- /dev/null +++ b/ng6-seed/src/app/template/service/masters/masters.service.ts @@ -0,0 +1,223 @@ +/** Common Import Section */ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs';//for Datatables +import { HttpClient } from '@angular/common/http'; +import { catchError } from 'rxjs/operators'; +import { of } from 'rxjs'; + +/** Imported Service Files Are., */ +import { AwsService } from '../../../AwsService/aws.service'; +//import { environment } from 'environments/environment'; + + +/** Consant Value For Created Date And Updated Date */ +const currentdate = new Date().toJSON().slice(0,19).replace('T',' '); + +/** Master Interface */ +export interface Master { + master_id:number; + master_name:string; + constant_name:string; +} + +@Injectable() + +export class MastersService { + + + private apiUrl = "http://ssa.sineedge.com/sparqapi/api/"; + + + constructor(private _http: HttpClient, + private _aws:AwsService) { } + + //headers:any = this._shared.headercofig(''); + + /** + * TO Add Master Datas using API Call + * 1st argument is "Records": any - Set of Data To Adding to database + * 2nd argument is "MasterName" :string - Table Name To Store the Records + */ + addMasterDetails(Records: any,MasterName:string): Observable { + Records.fk_createdby = this._aws.getlocale();//to get user id for who is created the Record + if(MasterName == 'COMPANY'){ + Records.company_master_createdon = currentdate;//to get Current date and Time for when the Record is created + } + else{ + Records.createdon = currentdate;//to get Current date and Time for when the Record is created + } + var ArrayData = { "master_name":MasterName, + "records": Records } + +// var data = this._http.post(this.apiUrl+'saveMaster',ArrayData); +// console.log('from service',data); + +return this._http.post(this.apiUrl+"saveMaster", ArrayData) +.pipe( + catchError(this.handleError('role', [])) + ) + + // return data; + } + + /** + * TO Edit Master Datas using API Call + * 1st argument is "Records": any - Set of Updated Data + * 2nd argument is "MasterName" :string - Table Name + */ + editMasterDetails(Records: any,MasterName:string): Observable { + + Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record + Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated + + var ArrayData = { "master_name":MasterName, + "records": Records } + + var data = this._http.post(this.apiUrl+'saveMaster',ArrayData); + + return data; + + } + + + /** + * TO Inactive the Master Datas using API Call + * Note : Which means To delete The records + * 1st argument is "PrimaryKeyWithValue" : any - Primarykey and its value + * 2nd argument is "MasterName" :string - Table Name + */ + deleteMasterDetails(PrimaryKeyWithValue:any,MasterName:string): Observable { + + //This "otherDatas" Array is common Argument For All Master + let otherDatas:any = {isactive:0, + fk_updatedby:this._aws.getlocale(), + updatedon:currentdate} + + //This "dataWithPrimaryKey" Array is Mergeing The 'PrimaryKeyWithValue' argument with otherDatas + let dataWithPrimaryKey = Object.assign(otherDatas,PrimaryKeyWithValue); + + var ArrayData = { "master_name":MasterName, + "records":JSON.parse(JSON.stringify(dataWithPrimaryKey)) + } + + return this._http.post(this.apiUrl+'saveMaster',ArrayData).pipe( + catchError(this.handleError('role', [])) + ); + // alert(data); + // return data; + } + + /** + * TO Get the Master Datas using API Call + * 1st argument is "TableName" :string - Table Name + */ + getAllMasterData(TableName:string): Observable { + return this._http.post(this.apiUrl+"getListOfMaster", { "master_name":TableName }) + .pipe( + catchError(this.handleError('role', [])) + ) + } + + /** + * TO get Branch Data For Listing Screen + */ + getAllBranch(): Observable { + return this._http.get(this.apiUrl+'getListOfBranches') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + + + /** + * TO get Subproduct Data For Listing Screen + */ + getAllSubProduct(): Observable { + + return this._http.get(this.apiUrl+'getListOfSubProduct') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + + /** + * TO get State Data For Listing Screen + */ + getAllState(): Observable { + + return this._http.get(this.apiUrl+'getListOfState') + .pipe( + catchError(this.handleError('role', [])) + ) + + + } + + /** + * TO get Company Data For Listing Screen + */ + getAllCompany(): Observable { + + return this._http.get(this.apiUrl+'getListOfCompany') + .pipe( + catchError(this.handleError('role', [])) + ) + + } + + /** + * TO get City Data For Listing Screen + */ + getAllCity(): Observable { + + return this._http.get(this.apiUrl+'getListOfCity') + .pipe( + catchError(this.handleError('role', [])) + ) + +} + + + /** Get All EntityType Data using API call With master Keyword */ + // getAllEntityType(): Observable { + // var EntityTypeArr = { + // "master_name":"ENTITYTYPE", + // } + // return this._http.post(this.apiUrl+'getListOfMaster',EntityTypeArr,{headers:this.headers}) + // .pipe( + // catchError(this.handleError('role', [])) + // ) + // } + + + + /** + * Seperated Records from the res + * argument 'res' : Response + */ + private extractData(res : Response) { + + let Response = res['_body']; + Response = JSON.parse(Response); + + return Response['dataStatus'] === true + ? Response['records'] + : []; + + } + + /** + * TO Handle The Error + */ + private handleError(operation = 'operation', result?: T) { + + return (error: any): Observable => { + return of(result as T); + }; +} +addCompanyDetails +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/service/questions/questions.service.spec.ts b/ng6-seed/src/app/template/service/questions/questions.service.spec.ts new file mode 100644 index 000000000..831ec17b2 --- /dev/null +++ b/ng6-seed/src/app/template/service/questions/questions.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { QuestionsService } from './questions.service'; + +describe('QuestionsService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: QuestionsService = TestBed.get(QuestionsService); + expect(service).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/template/service/questions/questions.service.ts b/ng6-seed/src/app/template/service/questions/questions.service.ts new file mode 100644 index 000000000..1b532635c --- /dev/null +++ b/ng6-seed/src/app/template/service/questions/questions.service.ts @@ -0,0 +1,70 @@ +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 Question Master API service End-point Call Functionality +* Kdk +*/ +export class QuestionsService { + 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 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 + 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', [])) + ) + } + + 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/template/template.module.ts b/ng6-seed/src/app/template/template.module.ts new file mode 100644 index 000000000..732349611 --- /dev/null +++ b/ng6-seed/src/app/template/template.module.ts @@ -0,0 +1,55 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule } from '@angular/material'; +import {MatSlideToggleModule} from '@angular/material/slide-toggle'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; +import { TreeModule } from 'angular-tree-component'; +import { NgxDatatableModule } from '@swimlane/ngx-datatable'; +import { FlexLayoutModule } from '@angular/flex-layout'; + +import { DemoMaterialModule } from '../shared/demo.module'; +// import { NgxMatSelectSearchModule } from 'ngx-mat-select-search'; +import 'hammerjs'; +import { RouterModule } from '@angular/router'; + +import { TemplatesModule } from './templates/templates.module'; +import { QuestionsModule } from './questions/questions.module'; +/** Template Routes */ +import { TemplateRoutes } from './template.routing'; + +/** Master Service */ +import { MastersService } from './service/masters/masters.service'; + + +// import { HttpClientModule } from '@angular/common/http'; +@NgModule({ + imports: [ + CommonModule, + RouterModule.forChild(TemplateRoutes), + TemplatesModule, + QuestionsModule, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule, + FormsModule,ReactiveFormsModule, + // HttpClientModule, + ], + + providers:[ + MastersService + ] +}) +export class TemplateModule { } diff --git a/ng6-seed/src/app/template/template.routing.ts b/ng6-seed/src/app/template/template.routing.ts new file mode 100644 index 000000000..0872de9b2 --- /dev/null +++ b/ng6-seed/src/app/template/template.routing.ts @@ -0,0 +1,15 @@ +import { Routes } from '@angular/router'; +import { QuestionsModule } from './questions/questions.module'; + +export const TemplateRoutes: Routes = [{ + path: '', + children:[{ + path:'questions', + loadChildren:'./questions/questions.module#QuestionsModule' + }, + // { + // path:'templates', + // loadChildren:'./templates/templates.module#TemplatesModule' + // } +] +}] diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.html b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.html new file mode 100644 index 000000000..57f5a2657 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.html @@ -0,0 +1,2 @@ + +

Template Edit Component

diff --git a/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.ts b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.ts new file mode 100644 index 000000000..f9fbfe5b9 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/edit/templates.edit.component.ts @@ -0,0 +1,24 @@ +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder } from '@angular/forms'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; + +/* +* Template Edit component +* : kdk +*/ +@Component({ + selector: 'app-list', + templateUrl: './templates.edit.component.html' +}) +export class TemplateEditComponent implements OnInit { + + + constructor() { + } + + ngOnInit() { + } + +} diff --git a/ng6-seed/src/app/template/templates/templates-list/templates.list.component.html b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.html new file mode 100644 index 000000000..44ad3e64f --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.html @@ -0,0 +1,7 @@ +
+

Template List Component

+ +
+
+ +
\ No newline at end of file diff --git a/ng6-seed/src/app/template/templates/templates-list/templates.list.component.ts b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.ts new file mode 100644 index 000000000..0c9bdd767 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates-list/templates.list.component.ts @@ -0,0 +1,32 @@ +import { Component, ViewChild, OnInit } from '@angular/core'; +import { MatPaginator, MatSort, MatTableDataSource, MatDialog, PageEvent } from '@angular/material'; +import { FormGroup, FormControl, FormBuilder } from '@angular/forms'; +import { DataSource } from '@angular/cdk/table'; +import { Observable } from 'rxjs/Observable'; + +/* +* Template List component +* : kdk +*/ +@Component({ + selector: 'app-list', + templateUrl: './templates.list.component.html' +}) +export class TemplateListComponent implements OnInit { + public listView: boolean = true; + constructor() { + } + + ngOnInit() { + // alert(1); + } + + goToEdit(){ + this.listView = false; + } + + ngAfterViewInit(){ + // alert(2); + } + +} diff --git a/ng6-seed/src/app/template/templates/templates.component.ts b/ng6-seed/src/app/template/templates/templates.component.ts new file mode 100644 index 000000000..ace2651e4 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; +@Component({ + template: `

Templates Master Details List

+
+ +
+ ` +}) +export class TemplatesComponent { +} \ No newline at end of file diff --git a/ng6-seed/src/app/template/templates/templates.module.ts b/ng6-seed/src/app/template/templates/templates.module.ts new file mode 100644 index 000000000..2da2ac707 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates.module.ts @@ -0,0 +1,106 @@ +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'; + +// Questions Routing import +import { TemplatesRouting } from './templates.routing'; + +import { TemplatesComponent } from './templates.component'; +import { TemplateListComponent } from './templates-list/templates.list.component'; +import { TemplateEditComponent } from './templates-list/edit/templates.edit.component'; + +// import { QuestionsService } from './../service/questions/questions.service'; +/* +* Question Master Module details +* : kdk +*/ +/** + * 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, + MatCardModule, + MatIconModule, + MatInputModule, + MatRadioModule, + MatButtonModule,MatTableModule,MatPaginatorModule, + MatProgressBarModule,MatDialogModule, MatSortModule, + MatToolbarModule,MatSelectModule,MatListModule, MatMenuModule, + MatSlideToggleModule, + MatCheckboxModule, + FormsModule, + ReactiveFormsModule, + TemplatesRouting + ], + declarations: [ + TemplatesComponent, + TemplateListComponent, + TemplateEditComponent + ], + entryComponents: [ + ], + providers: [ + // QuestionsService + ] +}) +export class TemplatesModule { } diff --git a/ng6-seed/src/app/template/templates/templates.routing.ts b/ng6-seed/src/app/template/templates/templates.routing.ts new file mode 100644 index 000000000..6afa2b2f0 --- /dev/null +++ b/ng6-seed/src/app/template/templates/templates.routing.ts @@ -0,0 +1,32 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +// Templates Component +import { TemplatesComponent } from './templates.component'; +import { TemplateListComponent } from './templates-list/templates.list.component'; +import { TemplateEditComponent } from './templates-list/edit/templates.edit.component'; + +/* +* Templates Master Router Module details +*/ +const routes: Routes = [ + { + path: 'templates', + component: TemplatesComponent, + children: [ + { + path: 'list', + component: TemplateListComponent, + children: [{ + path: 'edit', + component: TemplateEditComponent, + }] + } + ] + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class TemplatesRouting {} diff --git a/ng6-seed/src/assets/styles/app.scss b/ng6-seed/src/assets/styles/app.scss index d966db745..a5b6d83cc 100644 --- a/ng6-seed/src/assets/styles/app.scss +++ b/ng6-seed/src/assets/styles/app.scss @@ -45,3 +45,6 @@ Author: TrendSetter Themes @import "scss/material"; @import "scss/utilities/utilities"; + +/* Add application styles & imports to this file! */ +@import "~angular-notifier/styles"; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..48e341a09 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +}