interceptor,login and customers
This commit is contained in:
parent
74b44ea46f
commit
16c211d28d
20038
ng-seed/package-lock.json
generated
20038
ng-seed/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@
|
||||
"@swimlane/ngx-charts": "^17.0.1",
|
||||
"@swimlane/ngx-datatable": "19.0.0",
|
||||
"angular-calendar": "^0.28.22",
|
||||
"angular-notifier": "^12.0.0",
|
||||
"chart.js": "^2.9.4",
|
||||
"core-js": "^3.9.1",
|
||||
"d3": "^6.6.1",
|
||||
@ -47,6 +48,7 @@
|
||||
"ng2-file-upload": "^1.4.0",
|
||||
"ngx-color-picker": "^11.0.0",
|
||||
"ngx-perfect-scrollbar": "10.1.0",
|
||||
"ngx-scrollbar": "^7.5.6",
|
||||
"ngx-sortablejs": "^3.1.4",
|
||||
"perfect-scrollbar": "^1.5.0",
|
||||
"primeflex": "^3.3.0",
|
||||
|
||||
16
ng-seed/src/app/_guard/token.interceptor.spec.ts
Normal file
16
ng-seed/src/app/_guard/token.interceptor.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TokenInterceptor } from './token.interceptor';
|
||||
|
||||
describe('TokenInterceptor', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({
|
||||
providers: [
|
||||
TokenInterceptor
|
||||
]
|
||||
}));
|
||||
|
||||
it('should be created', () => {
|
||||
const interceptor: TokenInterceptor = TestBed.inject(TokenInterceptor);
|
||||
expect(interceptor).toBeTruthy();
|
||||
});
|
||||
});
|
||||
30
ng-seed/src/app/_guard/token.interceptor.ts
Normal file
30
ng-seed/src/app/_guard/token.interceptor.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
HttpRequest,
|
||||
HttpHandler,
|
||||
HttpEvent,
|
||||
HttpInterceptor
|
||||
} from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class TokenInterceptor implements HttpInterceptor {
|
||||
|
||||
constructor() {}
|
||||
|
||||
// intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
// return next.handle(request);
|
||||
// }
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
// const tokenUrl = 'http://example.com/token'; // replace with your token url
|
||||
const token = localStorage.getItem('user_token'); // get the token from local storage
|
||||
const authReq = req.clone({
|
||||
headers: req.headers.set('x-access-token', token).set('Content-Type', 'application/json')
|
||||
});
|
||||
|
||||
|
||||
return next.handle(authReq);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { NgModule,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClientModule, HttpClient} from '@angular/common/http';
|
||||
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS} from '@angular/common/http';
|
||||
|
||||
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
|
||||
import { PERFECT_SCROLLBAR_CONFIG } from 'ngx-perfect-scrollbar';
|
||||
@ -34,6 +34,7 @@ import { SharedModule } from './shared/shared.module';
|
||||
import { ProgressSpineerDialogComponent } from './shared/progress-spineer-dialog/progress-spineer-dialog.component';
|
||||
import { AppoinmentModule } from './appoinment/appoinment.module';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { TokenInterceptor } from './_guard/token.interceptor';
|
||||
|
||||
|
||||
export function HttpLoaderFactory(http: HttpClient) {
|
||||
@ -89,8 +90,13 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
|
||||
{
|
||||
provide: PERFECT_SCROLLBAR_CONFIG,
|
||||
useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
|
||||
},
|
||||
{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: TokenInterceptor,
|
||||
multi: true
|
||||
}
|
||||
],
|
||||
],
|
||||
entryComponents: [],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
<ng-scrollbar class="scrollHV">
|
||||
<div fxLayout="row wrap" >
|
||||
<div fxFlex.xs="100" fxFlex.sm="50" fxFlex.md="50" fxFlex.lg="33.33" fxFlex.xl="33.33" class="m-gap p-gap" *ngFor="let consultant of consultants">
|
||||
<div class="consultant-list-card">
|
||||
@ -37,4 +38,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-scrollbar>
|
||||
@ -9,6 +9,9 @@ $black_60: rgba(0, 0, 0, 0.6);
|
||||
padding: 1.5rem 1.5rem;
|
||||
padding-bottom: 4rem;
|
||||
}
|
||||
.scrollHV {
|
||||
height: calc(100vh - 410px);
|
||||
}
|
||||
.consultant-list-card {
|
||||
background: $white;
|
||||
box-shadow: 0 2px 6px $black_10;
|
||||
|
||||
@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { ConsultantsRoutingModule } from './consultants-routing.module';
|
||||
import { ConsultantsListComponent } from './consultants-list/consultants-list.component';
|
||||
import { DemoMaterialModule } from 'app/shared/demo.module';
|
||||
|
||||
import { NgScrollbarModule } from 'ngx-scrollbar'
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@ -13,7 +13,11 @@ import { DemoMaterialModule } from 'app/shared/demo.module';
|
||||
imports: [
|
||||
DemoMaterialModule,
|
||||
CommonModule,
|
||||
ConsultantsRoutingModule
|
||||
ConsultantsRoutingModule,
|
||||
NgScrollbarModule
|
||||
],
|
||||
exports: [
|
||||
|
||||
]
|
||||
})
|
||||
export class ConsultantsModule { }
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header >
|
||||
<div class="example-container mat-elevation-z8 ">
|
||||
<table mat-table [dataSource]="dataSource" #mytable class="my-table mat-elevation-z8 len-table">
|
||||
<table mat-table [dataSource]="customersList" #mytable class="my-table mat-elevation-z8 len-table">
|
||||
|
||||
<ng-container matColumnDef="id">
|
||||
<th mat-header-cell *matHeaderCellDef class="font-color"> S.NO </th>
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef class="font-color"> Name </th>
|
||||
<td mat-cell *matCellDef="let element" class="element-spc"> {{element.name}} </td>
|
||||
<td mat-cell *matCellDef="let element" class="element-spc"> {{element.cusName}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="email">
|
||||
@ -36,15 +36,15 @@
|
||||
|
||||
<ng-container matColumnDef="phone">
|
||||
<th mat-header-cell *matHeaderCellDef class="font-color"> Phone </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.phone}} </td>
|
||||
<td mat-cell *matCellDef="let element"> {{element.phoneNo}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="address" >
|
||||
<th mat-header-cell *matHeaderCellDef class="font-color th-mat"> Address </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.address}} <br> {{element.city}} <br> {{element.state}} </td>
|
||||
<td mat-cell *matCellDef="let element"> {{element.address_1}} <br> {{element.city}} <br> {{element.state}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="state">
|
||||
<!-- <ng-container matColumnDef="state">
|
||||
<th mat-header-cell *matHeaderCellDef class="font-color"> State </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.state}} </td>
|
||||
</ng-container>
|
||||
@ -57,7 +57,7 @@
|
||||
<ng-container matColumnDef="pincode">
|
||||
<th mat-header-cell *matHeaderCellDef class="font-color"> Pincode </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.pincode}} </td>
|
||||
</ng-container>
|
||||
</ng-container> -->
|
||||
|
||||
<ng-container matColumnDef="action">
|
||||
<th mat-header-cell *matHeaderCellDef class="font-color"> Action </th>
|
||||
@ -73,6 +73,12 @@
|
||||
</mat-expansion-panel-header>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
<!-- <div [hidden]="recordStatus">
|
||||
<mat-paginator #paginator class="mat-elevation-z1" [length]="customersList.length" [pageIndex]="pageIndex"
|
||||
[pageSize]="pageSize" [pageSizeOptions]="[5, 10, 25,50, 100]" (page)="pageEvent = $event; pageChange($event)" showFirstLastButtons>
|
||||
</mat-paginator>
|
||||
</div> -->
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of users"></mat-paginator>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,31 +1,32 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
||||
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
||||
import Swal from 'sweetalert2';
|
||||
import { CustomersService } from '../customers-service/customers.service';
|
||||
import { DialogBoxComponent } from '../dialog-box/dialog-box.component';
|
||||
|
||||
export interface UsersData {
|
||||
id: number;
|
||||
name: string;
|
||||
cusName: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
address: string;
|
||||
phoneNo: string;
|
||||
address_1: string;
|
||||
city: string;
|
||||
state: string;
|
||||
pincode: string;
|
||||
}
|
||||
const ELEMENT_DATA: UsersData[] = [
|
||||
{id: 1, name: 'school management system ', email: 'management@gmail.com', phone: '8756453456', address:'14-20b/19 Vasantham Colony, Sangakiri.', state: 'Tamil Nadu', city: 'salem', pincode:'637301' },
|
||||
{id: 2, name: 'Sample', email: 'sample@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu' , pincode:'637301'},
|
||||
{id: 3, name: 'Test', email: 'test@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 4, name: 'Sample', email: 'sample@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 5, name: 'Test', email: 'test@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 6, name: 'Sample', email: 'sample@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 7, name: 'Test', email: 'test@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 8, name: 'Sample', email: 'sample@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 9, name: 'Test', email: 'test@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 10,name: 'Sample', email: 'sample@gmail.com', phone: '8756453456', address:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 1, cusName: 'school management system ', email: 'management@gmail.com', phoneNo: '8756453456', address_1:'14-20b/19 Vasantham Colony, Sangakiri.', state: 'Tamil Nadu', city: 'salem', pincode:'637301' },
|
||||
{id: 2, cusName: 'Sample', email: 'sample@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu' , pincode:'637301'},
|
||||
{id: 3, cusName: 'Test', email: 'test@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 4, cusName: 'Sample', email: 'sample@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 5, cusName: 'Test', email: 'test@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 6, cusName: 'Sample', email: 'sample@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 7, cusName: 'Test', email: 'test@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 8, cusName: 'Sample', email: 'sample@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 9, cusName: 'Test', email: 'test@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
{id: 10,cusName: 'Sample', email: 'sample@gmail.com', phoneNo: '8756453456', address_1:'sankagiri', city: 'salem', state: 'Tamil Nadu', pincode:'637301'},
|
||||
];
|
||||
|
||||
@Component({
|
||||
@ -36,26 +37,70 @@ const ELEMENT_DATA: UsersData[] = [
|
||||
export class CustomersListComponent implements OnInit {
|
||||
|
||||
push: any;
|
||||
displayedColumns: string[] = ['id','name', 'email','phone', 'address', 'pincode', 'action'];
|
||||
dataSource: any;
|
||||
displayedColumns: string[] = ['id','name', 'email','phone', 'address', 'action'];
|
||||
// dataSource: any;
|
||||
public customersList:any = new MatTableDataSource();
|
||||
// dataSource: any = new MatTableDataSource(ELEMENT_DATA);
|
||||
@ViewChild(MatTable,{static:true}) table: MatTable<any>;
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
recordStatus: boolean;
|
||||
length = 5;
|
||||
pageIndex = 0;
|
||||
pageSize = 10;
|
||||
pageEvent: PageEvent;
|
||||
addFormData: any;
|
||||
|
||||
constructor(public dialog: MatDialog,public _cus:CustomersService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log('IN')
|
||||
// this.dataSource = new MatTableDataSource(ELEMENT_DATA)
|
||||
this.getCustomersList()
|
||||
}
|
||||
|
||||
getCustomersList() {
|
||||
//this._pd.getTabStatusPdDetails(this.tabStatus)
|
||||
this._cus.getCustomersListDetails().subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
this.customersList = res.data;
|
||||
// console.log(this.customersList)
|
||||
// this.dataSource = res.data.length;
|
||||
// console.log(this.dataSource)
|
||||
// this.dataSource.data = this.customersList;
|
||||
// console.log(this.dataSource.data)
|
||||
// this.recordStatus=false;
|
||||
}
|
||||
else{
|
||||
// this.customersList=[];
|
||||
// this.dataSource = null;
|
||||
// this.recordStatus=true;
|
||||
}
|
||||
}
|
||||
// , error => {this.errorMessage = <any> error});
|
||||
,error => {
|
||||
// this.errorMessage.push(error);
|
||||
// this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
|
||||
// alert(error.html_format);
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.customersList.paginator = this.paginator;
|
||||
}
|
||||
applyFilter(event: Event) {
|
||||
const filterValue = (event.target as HTMLInputElement).value;
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
if (this.dataSource.paginator) {
|
||||
this.dataSource.paginator.firstPage();
|
||||
this.customersList.filter = filterValue.trim().toLowerCase();
|
||||
if (this.customersList.paginator) {
|
||||
this.customersList.paginator.firstPage();
|
||||
}
|
||||
}
|
||||
constructor(public dialog: MatDialog) { }
|
||||
|
||||
confirmBox(name,element){
|
||||
console.log(name,element)
|
||||
pageChange(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
confirmBox(event,element){
|
||||
console.log(event,element)
|
||||
Swal.fire({
|
||||
title: 'Are you sure want to remove?',
|
||||
text: 'You will not be able to recover this file!',
|
||||
@ -65,7 +110,8 @@ export class CustomersListComponent implements OnInit {
|
||||
cancelButtonText: 'No, keep it'
|
||||
}).then((result) => {
|
||||
if (result.value) {
|
||||
this.deleteRowData(element);
|
||||
// this.deleteRowData(element);
|
||||
this.formAddUpdateAndDelete(event,element)
|
||||
Swal.fire(
|
||||
'Deleted!',
|
||||
'Your imaginary file has been deleted.',
|
||||
@ -92,55 +138,87 @@ export class CustomersListComponent implements OnInit {
|
||||
});
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
console.log(result)
|
||||
if(result.event == 'Add'){
|
||||
this.addRowData(result.data);
|
||||
}else if(result.event == 'Update'){
|
||||
this.updateRowData(result.data);
|
||||
}else if(result.event == 'Delete'){
|
||||
this.deleteRowData(result.data);
|
||||
this.formAddUpdateAndDelete(result,result.data)
|
||||
});
|
||||
}
|
||||
|
||||
formAddUpdateAndDelete(result,row_obj){
|
||||
console.log(result,row_obj)
|
||||
let formValue = []
|
||||
if(result.event == 'Add'){
|
||||
console.log('add')
|
||||
let addFormData = {
|
||||
address_1: row_obj.address_1,
|
||||
busId: 'abc123',
|
||||
city: row_obj.city,
|
||||
cusName: row_obj.cusName,
|
||||
email: row_obj.email,
|
||||
phoneNo: row_obj.phoneNo,
|
||||
pincode: row_obj.pincode,
|
||||
state: row_obj.state
|
||||
};
|
||||
formValue.push(addFormData);
|
||||
}else if(result.event == 'Update'){
|
||||
console.log('Update')
|
||||
formValue.push(row_obj);
|
||||
}
|
||||
else if(result == 'Delete'){
|
||||
console.log('delete')
|
||||
let val = {
|
||||
isActive:0,
|
||||
id: row_obj.id
|
||||
}
|
||||
});
|
||||
}
|
||||
addRowData(row_obj){
|
||||
var d = this.dataSource.data.length+1
|
||||
console.log(this.dataSource)
|
||||
this.dataSource.data.push
|
||||
({
|
||||
id: d,
|
||||
name: row_obj.name,
|
||||
email: row_obj.email,
|
||||
phone: row_obj.phone,
|
||||
address: row_obj.address,
|
||||
city: row_obj.city,
|
||||
state: row_obj.state,
|
||||
pincode: row_obj.pincode
|
||||
|
||||
});
|
||||
this.table.renderRows();
|
||||
}
|
||||
updateRowData(row_obj){
|
||||
console.log(row_obj)
|
||||
this.dataSource = this.dataSource.data.filter((value,key)=>{
|
||||
if(value.id == row_obj.id){
|
||||
value.name = row_obj.name;
|
||||
value.email = row_obj.email;
|
||||
value.phone = row_obj.phone;
|
||||
value.address = row_obj.address;
|
||||
value.city = row_obj.city;
|
||||
value.state = row_obj.state;
|
||||
value.pincode = row_obj.pincode;
|
||||
formValue.push(val);
|
||||
}
|
||||
|
||||
// var d = this.customersList.length+1
|
||||
console.log(formValue[0])
|
||||
this._cus.addFormDetails(formValue[0]).subscribe(res => {
|
||||
if (res.status == 200) {
|
||||
// this.customersList = res.data;
|
||||
this.getCustomersList()
|
||||
}
|
||||
return true;
|
||||
else{
|
||||
// this.customersList=[];
|
||||
// this.dataSource = null;
|
||||
// this.recordStatus=true;
|
||||
}
|
||||
}
|
||||
// , error => {this.errorMessage = <any> error});
|
||||
,error => {
|
||||
// this.errorMessage.push(error);
|
||||
// this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
|
||||
// alert(error.html_format);
|
||||
});
|
||||
}
|
||||
deleteRowData(row_obj){
|
||||
console.log(this.dataSource.data,row_obj)
|
||||
this.dataSource.data = this.dataSource.data.filter((value,key)=>{
|
||||
return value.id != row_obj.id
|
||||
});
|
||||
console.log(this.dataSource)
|
||||
}
|
||||
ngOnInit(): void {
|
||||
this.dataSource = new MatTableDataSource(ELEMENT_DATA)
|
||||
}
|
||||
// updateRowData(row_obj){
|
||||
// console.log(row_obj)
|
||||
// this._cus.addFormDetails(row_obj).subscribe(res => {
|
||||
// if (res.status == 200) {
|
||||
// // this.customersList = res.data;
|
||||
// this.getCustomersList()
|
||||
// }
|
||||
// else{
|
||||
// // this.customersList=[];
|
||||
// // this.dataSource = null;
|
||||
// // this.recordStatus=true;
|
||||
// }
|
||||
// }
|
||||
// // , error => {this.errorMessage = <any> error});
|
||||
// ,error => {
|
||||
// // this.errorMessage.push(error);
|
||||
// // this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!');
|
||||
// // alert(error.html_format);
|
||||
// });
|
||||
|
||||
|
||||
// }
|
||||
// deleteRowData(row_obj){
|
||||
// console.log(this.customersList.data,row_obj)
|
||||
// this.customersList.data = this.customersList.data.filter((value,key)=>{
|
||||
// return value.id != row_obj.id
|
||||
// });
|
||||
// console.log(this.customersList)
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,34 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from 'environments/environment';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CustomersService {
|
||||
|
||||
constructor() { }
|
||||
private apiUrl = environment.apiEndpoint;
|
||||
constructor(private _http: HttpClient) { }
|
||||
|
||||
getCustomersListDetails(): Observable<any> {
|
||||
console.log('IN')
|
||||
return this._http.get<any[]>(this.apiUrl + "getCustomersDetails")
|
||||
// .pipe(
|
||||
// catchError(this.handleError('role', []))
|
||||
// )
|
||||
}
|
||||
|
||||
addFormDetails(addParams): Observable<any> {
|
||||
return this._http.post(this.apiUrl + 'CreateCustomers', addParams)
|
||||
// .pipe(
|
||||
// catchError(this.handleError('role', []))
|
||||
// )
|
||||
}
|
||||
|
||||
|
||||
handleError(arg0: string, arg1: undefined[]): (err: any, caught: Observable<any>) => import("rxjs").ObservableInput<any> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,9 +6,9 @@
|
||||
<div mat-dialog-content class="my-table">
|
||||
<form [formGroup]="form" (ngSubmit)="submit()">
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" Name" matInput formControlName="name">
|
||||
<mat-error *ngIf="myError('name', 'required')">Name is required</mat-error>
|
||||
<mat-error *ngIf="myError('name', 'maxlength')">Limit exceed</mat-error>
|
||||
<input placeholder=" Name" matInput formControlName="cusName">
|
||||
<mat-error *ngIf="myError('cusName', 'required')">Name is required</mat-error>
|
||||
<mat-error *ngIf="myError('cusName', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
@ -21,14 +21,14 @@
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" Phone" matInput [(ngModel)]="local_data.phone" formControlName="contact_no">
|
||||
<mat-error *ngIf="myError('contact_no', 'required')">Contact No is required</mat-error>
|
||||
<mat-error *ngIf="myError('contact_no', 'maxlength')">Limit exceed</mat-error>
|
||||
<input placeholder=" Phone" matInput [(ngModel)]="local_data.phoneNo" formControlName="phoneNo">
|
||||
<mat-error *ngIf="myError('phoneNo', 'required')">Contact No is required</mat-error>
|
||||
<mat-error *ngIf="myError('phoneNo', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" Address" matInput [(ngModel)]="local_data.address" formControlName="address">
|
||||
<mat-error *ngIf="myError('address', 'required')">Address is required</mat-error>
|
||||
<mat-error *ngIf="myError('address', 'maxlength')">Limit exceed</mat-error>
|
||||
<input placeholder=" Address" matInput [(ngModel)]="local_data.address_1" formControlName="address_1">
|
||||
<mat-error *ngIf="myError('address_1', 'required')">Address is required</mat-error>
|
||||
<mat-error *ngIf="myError('address_1', 'maxlength')">Limit exceed</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" *ngIf="action != 'Delete'; else elseTemplate" class="mat-pane">
|
||||
<input placeholder=" State" matInput [(ngModel)]="local_data.state" formControlName="state">
|
||||
@ -47,16 +47,17 @@
|
||||
</mat-form-field>
|
||||
<!-- <img class="image" [src]="url" height="50">
|
||||
<input type='file' (change)="onSelectFile($event)" formControlName="image"> -->
|
||||
<ng-template #elseTemplate>
|
||||
Sure to delete <b>{{local_data.cusName}}</b>?
|
||||
</ng-template><br>
|
||||
<div mat-dialog-actions>
|
||||
<button mat-button type="submit" class="mat-green" mat-raised-button >{{action}}</button>
|
||||
<button mat-button (click)="closeDialog()" >Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<ng-template #elseTemplate>
|
||||
Sure to delete <b>{{local_data.name}}</b>?
|
||||
</ng-template><br>
|
||||
<div mat-dialog-actions>
|
||||
<button mat-button (click)="doAction()" class="mat-green" mat-raised-button >{{action}}</button>
|
||||
<button mat-button (click)="closeDialog()" >Cancel</button>
|
||||
</div>
|
||||
|
||||
</mat-card>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { Router } from '@angular/router';
|
||||
export interface UsersData {
|
||||
name: string;
|
||||
cusName: string;
|
||||
id: number;
|
||||
}
|
||||
@Component({
|
||||
@ -28,13 +28,9 @@ export class DialogBoxComponent implements OnInit {
|
||||
get f(){
|
||||
return this.form.controls;
|
||||
}
|
||||
doAction(){
|
||||
let tmp = this.form.value
|
||||
tmp.id = this.local_data.id
|
||||
this.dialogRef.close({event:this.action,data:tmp});
|
||||
console.log(this.form.value);
|
||||
console.log(this.action,this.local_data)
|
||||
}
|
||||
// doAction(){
|
||||
|
||||
// }
|
||||
closeDialog(){
|
||||
this.dialogRef.close({event:'Cancel'});
|
||||
}
|
||||
@ -53,16 +49,16 @@ export class DialogBoxComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.form = new FormGroup({
|
||||
businessselect: new FormControl('', [Validators.required]),
|
||||
image: new FormControl('', null),
|
||||
name: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
address: new FormControl('', [Validators.required, Validators.maxLength(50)]),
|
||||
// image: new FormControl('', null),
|
||||
cusName: new FormControl('', [Validators.required, Validators.maxLength(20)]),
|
||||
address_1: new FormControl('', [Validators.required, Validators.maxLength(50)]),
|
||||
city: new FormControl('', [Validators.required, Validators.maxLength(10)]),
|
||||
state: new FormControl('', [Validators.required, Validators.maxLength(10)]),
|
||||
pincode: new FormControl('', [Validators.required, Validators.maxLength(10)]),
|
||||
email: new FormControl('', [Validators.required, Validators.email,Validators.pattern(
|
||||
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,63}$',
|
||||
),]),
|
||||
contact_no: new FormControl('', [Validators.required, Validators.maxLength(10)]),
|
||||
phoneNo: new FormControl('', [Validators.required, Validators.maxLength(10)]),
|
||||
});
|
||||
this.form.patchValue(this.local_data)
|
||||
}
|
||||
@ -71,5 +67,10 @@ export class DialogBoxComponent implements OnInit {
|
||||
}
|
||||
submit(){
|
||||
console.log(this.form.value);
|
||||
let tmp = this.form.value
|
||||
tmp.id = this.local_data.id
|
||||
this.dialogRef.close({event:this.action,data:tmp});
|
||||
console.log(this.form.value);
|
||||
console.log(this.action,this.local_data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,8 @@ export class SessionService {
|
||||
constructor(private _http: HttpClient) { }
|
||||
|
||||
getLoginToken(params): Observable<any> {
|
||||
return this._http.post(this.apiUrl + 'login', {params})
|
||||
console.log(params.email)
|
||||
return this._http.post(this.apiUrl + 'login', {'email':params.email,'password':params.password})
|
||||
.pipe(
|
||||
catchError(this.handleError('role', []))
|
||||
)
|
||||
|
||||
@ -39,13 +39,17 @@ export class LoginComponent {
|
||||
onSubmit(){
|
||||
console.log(this.loginForm.value);
|
||||
const mailid = this.loginForm['value'].email.split(/\s/).join('');
|
||||
let auth = { 'email': mailid, 'password': this.loginForm['value'].password};
|
||||
localStorage.setItem('email',JSON.stringify(auth))
|
||||
let auth = { 'email': mailid, 'password': this.loginForm['value'].password};
|
||||
this._ser.getLoginToken(auth).subscribe(res => {
|
||||
if (res !== undefined) {
|
||||
localStorage.setItem('user',this.loginForm.value)
|
||||
this.router.navigate(['/home'])
|
||||
console.log(res)
|
||||
if(res.status == 200 || res.status == 'Logged in'){
|
||||
if (res.token !== '') {
|
||||
localStorage.setItem('user_token',res.token);
|
||||
localStorage.setItem('email',JSON.stringify(auth))
|
||||
this.router.navigate(['/home'])
|
||||
}
|
||||
}
|
||||
|
||||
}, err => {
|
||||
|
||||
//alert(err.message);
|
||||
|
||||
@ -42,6 +42,7 @@ import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { FlexModule } from '@angular/flex-layout';
|
||||
|
||||
|
||||
/**
|
||||
* NgModule that includes all Material modules that are required to serve the demo-app.
|
||||
*/
|
||||
|
||||
@ -6,5 +6,5 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
environmentName: 'Testing Environment',//Localhost Environment.
|
||||
apiEndpoint:'http://venbainfotech.com:5000/',
|
||||
apiEndpoint:'http://venbainfotech.com:5000/api/',
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user