Commit eb7cd9e8 by Adarsh K

checker function

parent e99c8bd8
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Forex Delivery Service Provider</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
<span (click)="goToPage('delivery/changepin')">Change PIN</span>
</div>
</div>
</header>
<section>
<div class="provider_content">
<h3>Add Delivery Provider</h3>
<div class="provider_inner_content">
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Provider created successfully.
</div>
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseError}}
</div>
<form [formGroup]="providerForm" (ngSubmit)="regProcess()" autocomplete="off">
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Provider Name</p>
<input class="provider_input" placeholder="" type="text" formControlName="name">
</div>
<div class="s_error" *ngIf="!providerForm.controls['name'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['name'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Pin</p>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin m0" placeholder="" type="password" maxlength="1" value="0" readonly>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Confirm Pin</p>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin m0" placeholder="" type="password" maxlength="1" value="0" readonly>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Location</p>
<input class="provider_input" placeholder="" type="text" formControlName="location">
</div>
<div class="s_error" *ngIf="!providerForm.controls['location'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['location'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>CR ID</p>
<input class="provider_input" placeholder="" type="text" formControlName="cr_id">
</div>
<div class="s_error" *ngIf="!providerForm.controls['cr_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['cr_id'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>CR Manager</p>
<input class="provider_input" placeholder="" type="text" formControlName="cr_manager">
</div>
<div class="s_error" *ngIf="!providerForm.controls['cr_manager'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['cr_manager'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Contact</p>
<input class="provider_input" placeholder="" type="text" formControlName="contact">
</div>
<div class="s_error" *ngIf="!providerForm.controls['contact'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['contact'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Phone</p>
<input class="provider_input" placeholder="" type="number" formControlName="phone">
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('pattern')">{{error_msg.phone}}</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched && !providerForm.controls['phone'].hasError('pattern')">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('maxlength')">{{error_msg.maxLength}} 15</div>
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('minlength')">{{error_msg.minLength}} 8</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Email id</p>
<input class="provider_input" placeholder="" type="mail" formControlName="email_id">
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerForm.controls['email_id'].touched">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('pattern')">{{error_msg.email}} </div>
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('maxlength')">{{error_msg.maxLength}} 50</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Status</p>
<select class="provider_input" formControlName="online_status">
<option disabled hidden>Status</option>
<option value="1">Online</option>
<option value="0">Offline</option>
</select>
</div>
<div class="s_error" *ngIf="!providerForm.controls['online_status'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['online_status'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Delivery Provider</p>
<select class="provider_input" formControlName="deli_provider_id">
<option disabled hidden>Status</option>
<option *ngFor="let provider of providerList" [value]="provider.id">{{provider.name}}</option>
</select>
</div>
<div class="s_error" *ngIf="!providerForm.controls['deli_provider_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['deli_provider_id'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="col">
<div class="add_provider_btn_bay p0">
<button class="edit_btn floatRight" (click)="goToPage('checker/editprovider')">Edit</button>
<div class="clear"></div>
</div>
</div>
</div> -->
<div class="row">
<div class="col">
<div class="add_provider_btn_bay">
<button class="save_btn floatRight">Save</button>
<button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
\ No newline at end of file
.provider_header{
background: #1a5c7c;
padding: 4px;
h4{
margin:0px;
color: #fff;
padding: 20px;
font-weight: 400;
font-size:20px;
}
span{
position: absolute;
bottom:-30px;
right:15px;
font-size: 14px;
cursor: pointer;
z-index: 999;
}
}
.provider_content{
width:100%;
position: relative;
h3{
margin:0px;
padding:0px;
border-bottom: 1px solid #494949;
color: #464646;
font-size: 20px;
font-weight: 400;
padding: 15px;
}
.provider_inner_content{
width:100%;
padding-top: 40px;
padding-left: 20px;
padding-right: 20px;
.row{
padding-bottom: 40px;
.provider_data_content{
width:90%;
margin:0 auto;
p{
color: #464646;
margin:0px;
padding-bottom: 10px;
font-weight: 500;
}
.provider_input{
border:1px solid #b4b4b4;
height:40px;
padding-left: 10px;
padding-right: 10px;
width: 100%;
&:focus{
outline: none;
}
}
.provider_pin{
border:1px solid #b4b4b4;
height:40px;
width: calc(100% - 90%);
margin-right: calc(100% - 92%);
text-align: center;
display: inline-block;
border-radius: 10px;
&:focus{
outline: none;
}
}
}
.edit_btn{
background: #d9d9d9;
color: #1a5d7a;
border-radius:20px;
height:40px;
padding-left: 4%;
padding-right:4%;
font-weight: 500;
margin:1%;
border:none;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
.add_provider_btn_bay{
width:100%;
padding-top:5%;
text-align: right;
.save_btn{
background: #cd3d3d;
color: #fff;
border-radius:20px;
height:40px;
border:none;
padding-left:4%;
padding-right:4%;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
.cancel_btn{
background: #1a5c7c;
color: #fff;
border-radius:20px;
height:40px;
padding-left:4%;
padding-right:4%;
border:none;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AddforexComponent } from './addforex.component';
describe('AddforexComponent', () => {
let component: AddforexComponent;
let fixture: ComponentFixture<AddforexComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AddforexComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AddforexComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { WebService } from './../../providers/web.service';
import { ValidationService } from './../../providers/validation.service';
import { FormControl, FormGroup, FormBuilder, Validators, ValidationErrors } from '@angular/forms';
@Component({
selector: 'app-addforex',
templateUrl: './addforex.component.html',
styleUrls: ['./addforex.component.scss']
})
export class AddforexComponent implements OnInit {
providerForm: FormGroup;
mobnumPattern = '^((\\+?)|0)?[0-9]{8,15}$';
emailPattern = '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$';
providerSubmit: boolean;
lang = 'en';
error_msg: any[];
funcName: any;
loader: boolean;
responseError: any;
error: boolean;
success: boolean;
providerList: any[];
constructor(
private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
private formBuilder: FormBuilder
) {
this.loader = false;
this.error = false;
this.success = false;
this.providerSubmit = false;
this.error_msg = this.vs.errorList[this.lang];
}
ngOnInit() {
this.getProvider();
this.providerForm = this.formBuilder.group({
'name': ['', Validators.compose([Validators.required])],
'cr_manager': ['', Validators.compose([Validators.required])],
'cr_id': ['', Validators.compose([Validators.required])],
'contact': ['', Validators.compose([Validators.required])],
'location': ['', Validators.compose([Validators.required])],
'email_id': ['', Validators.compose([Validators.required, Validators.maxLength(50), Validators.pattern(this.emailPattern)])],
// tslint:disable-next-line:max-line-length
'phone': ['', Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(15), Validators.pattern(this.mobnumPattern)])],
'type': [2],
'online_status': ['', Validators.compose([Validators.required])],
'deli_provider_id': ['', Validators.compose([Validators.required])],
'password': [''],
});
}
goToPage(path, data = null) {
console.log(data);
this.router.navigateByUrl(path, {queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
regProcess() {
const This = this;
this.error = false;
this.success = false;
let pass = Math.round(Math.random() * 1000000);
pass = this.pad(pass, 6, 0);
this.providerForm.controls['password'].setValue(pass);
console.log(this.providerForm.value);
this.providerSubmit = true;
if (this.providerForm.valid) {
this.loader = true;
const providerObj = this.providerForm.value;
this.funcName = 'provider_create';
this.service.post_data(this.funcName, providerObj).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
this.providerSubmit = false;
this.providerForm.reset();
} else {
this.error = true;
this.responseError = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = false;
this.responseError = this.vs.errorCode[this.lang]['ER08'];
});
}
console.log('tested');
}
pad(n: any, width: any, z: any) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
cancelClick() {
this.router.navigate(['/checker/forex']);
}
getProvider() {
this.loader = true;
this.funcName = 'providers';
const post_data = {'type': 3};
this.service.post_data(this.funcName, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.providerList = response.responseResult;
} else {
this.error = true;
this.responseError = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseError = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseError = '';
}, 3000);
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
......@@ -14,33 +18,45 @@
<h3>Add Delivery Provider</h3>
<div class="provider_inner_content">
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Provider created successfully.
</div>
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseError}}
</div>
<form [formGroup]="providerForm" (ngSubmit)="regProcess()" autocomplete="off">
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Provider Name</p>
<input class="provider_input" placeholder="" type="text">
<input class="provider_input" placeholder="" type="text" formControlName="name">
</div>
<div class="s_error" *ngIf="!providerForm.controls['name'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['name'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Pin</p>
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin m0" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin m0" placeholder="" type="password" maxlength="1" value="0" readonly>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Confirm Pin</p>
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1">
<input class="provider_pin m0" placeholder="" type="password" maxlength="1">
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin m0" placeholder="" type="password" maxlength="1" value="0" readonly>
</div>
</div>
</div>
......@@ -48,19 +64,28 @@
<div class="col">
<div class="provider_data_content">
<p>Location</p>
<input class="provider_input" placeholder="" type="text">
<input class="provider_input" placeholder="" type="text" formControlName="location">
</div>
<div class="s_error" *ngIf="!providerForm.controls['location'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['location'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>CR ID</p>
<input class="provider_input" placeholder="" type="text">
<input class="provider_input" placeholder="" type="text" formControlName="cr_id">
</div>
<div class="s_error" *ngIf="!providerForm.controls['cr_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['cr_id'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>CR Manager</p>
<input class="provider_input" placeholder="" type="text">
<input class="provider_input" placeholder="" type="text" formControlName="cr_manager">
</div>
<div class="s_error" *ngIf="!providerForm.controls['cr_manager'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['cr_manager'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
......@@ -68,39 +93,61 @@
<div class="col">
<div class="provider_data_content">
<p>Contact</p>
<input class="provider_input" placeholder="" type="number">
<input class="provider_input" placeholder="" type="text" formControlName="contact">
</div>
<div class="s_error" *ngIf="!providerForm.controls['contact'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['contact'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Phone</p>
<input class="provider_input" placeholder="" type="number">
<input class="provider_input" placeholder="" type="number" formControlName="phone">
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('pattern')">{{error_msg.phone}}</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched && !providerForm.controls['phone'].hasError('pattern')">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('maxlength')">{{error_msg.maxLength}} 15</div>
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('minlength')">{{error_msg.minLength}} 8</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Email id</p>
<input class="provider_input" placeholder="" type="mail">
<input class="provider_input" placeholder="" type="mail" formControlName="email_id">
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerForm.controls['email_id'].touched">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('pattern')">{{error_msg.email}} </div>
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('maxlength')">{{error_msg.maxLength}} 50</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('required')">{{error_msg.required}} </div>
</div>
<div class="row">
</div>
</div>
<!-- <div class="row">
<div class="col">
<div class="add_provider_btn_bay p0">
<button class="edit_btn floatRight" (click)="goToPage('checker/editprovider')">Edit</button>
<div class="clear"></div>
</div>
</div>
</div>
</div> -->
<div class="row">
<div class="col">
<div class="add_provider_btn_bay">
<button class="save_btn floatRight" (click)="goToPage('checker/manageprovider')">Save</button>
<button class="cancel_btn floatRight">Cancel</button>
<button class="save_btn floatRight">Save</button>
<button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
\ No newline at end of file
......@@ -11,9 +11,16 @@ import { FormControl, FormGroup, FormBuilder, Validators, ValidationErrors } fro
})
export class AddproviderComponent implements OnInit {
providerForm: FormGroup;
mobnumPattern = '^((\\+?)|0)?[0-9]{0,20}$';
emailPattern = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$';
mobnumPattern = '^((\\+?)|0)?[0-9]{8,15}$';
emailPattern = '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$';
providerSubmit: boolean;
lang = 'en';
error_msg: any[];
funcName: any;
loader: boolean;
responseError: any;
error: boolean;
success: boolean;
constructor(
private router: Router,
......@@ -22,19 +29,74 @@ export class AddproviderComponent implements OnInit {
public service: WebService,
private formBuilder: FormBuilder
) {
this.loader = false;
this.error = false;
this.success = false;
this.providerSubmit = false;
this.error_msg = this.vs.errorList[this.lang];
}
ngOnInit() {
this.providerForm = this.formBuilder.group({
'name': ['', Validators.compose([Validators.required])],
'cr_manager': ['', Validators.compose([Validators.required])],
'cr_id': ['', Validators.compose([Validators.required])],
'contact': ['', Validators.compose([Validators.required])],
'location': ['', Validators.compose([Validators.required])],
'email_id': ['', Validators.compose([Validators.required, Validators.maxLength(50), Validators.pattern(this.emailPattern)])],
// tslint:disable-next-line:max-line-length
'phone': ['', Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(15), Validators.pattern(this.mobnumPattern)])],
'type': [3],
'password': [''],
});
}
goToPage(path, data = null){
goToPage(path, data = null) {
console.log(data);
this.router.navigateByUrl(path,{queryParams:data});
this.router.navigateByUrl(path, {queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
regProcess() {
const This = this;
this.error = false;
this.success = false;
let pass = Math.round(Math.random() * 1000000);
pass = this.pad(pass, 6, 0);
this.providerForm.controls['password'].setValue(pass);
console.log(this.providerForm.value);
this.providerSubmit = true;
if (this.providerForm.valid) {
this.loader = true;
const providerObj = this.providerForm.value;
this.funcName = 'provider_create';
this.service.post_data(this.funcName, providerObj).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
this.providerSubmit = false;
this.providerForm.reset();
} else {
this.error = true;
this.responseError = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = false;
this.responseError = this.vs.errorCode[this.lang]['ER08'];
});
}
console.log('tested');
}
pad(n: any, width: any, z: any) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
cancelClick() {
this.router.navigate(['/checker/delivery']);
}
}
......@@ -11,46 +11,60 @@
<div class="login_row">
<p>Old PIN</p>
<div class="login_pin">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin m0" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" #old1 (keyup)="processKeyUp($event, old2)">
<input class="log_pin" type="password" maxlength="1" #old2 (keydown.backspace)="processBack($event, old1)" (keyup)="processKeyUp($event, old3)">
<input class="log_pin" type="password" maxlength="1" #old3 (keydown.backspace)="processBack($event, old2)" (keyup)="processKeyUp($event, old4)">
<input class="log_pin" type="password" maxlength="1" #old4 (keydown.backspace)="processBack($event, old3)" (keyup)="processKeyUp($event, old5)">
<input class="log_pin" type="password" maxlength="1" #old5 (keydown.backspace)="processBack($event, old4)" (keyup)="processKeyUp($event, old6)">
<input class="log_pin m0" type="password" maxlength="1" #old6 (keydown.backspace)="processBack($event, old5)">
</div>
<div class="s_error" *ngIf="passwordErr">
<div class="s_validation">{{error_msg.password}} </div>
</div>
</div>
<div class="login_row">
<p>New PIN</p>
<div class="login_pin">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin m0" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" #new1 (keyup)="processKeyUp($event, new2)">
<input class="log_pin" type="password" maxlength="1" #new2 (keydown.backspace)="processBack($event, new1)" (keyup)="processKeyUp($event, new3)">
<input class="log_pin" type="password" maxlength="1" #new3 (keydown.backspace)="processBack($event, new2)" (keyup)="processKeyUp($event, new4)">
<input class="log_pin" type="password" maxlength="1" #new4 (keydown.backspace)="processBack($event, new3)" (keyup)="processKeyUp($event, new5)">
<input class="log_pin" type="password" maxlength="1" #new5 (keydown.backspace)="processBack($event, new4)" (keyup)="processKeyUp($event, new6)">
<input class="log_pin m0" type="password" maxlength="1" #new6 (keydown.backspace)="processBack($event, new5)">
</div>
</div>
<div class="s_error" *ngIf="newpasswordErr">
<div class="s_validation">{{error_msg.password}} </div>
</div>
<div class="login_row">
<p>Confirm PIN</p>
<div class="login_pin">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" value="0">
<input class="log_pin m0" type="password" maxlength="1" value="0">
<input class="log_pin" type="password" maxlength="1" #conf1 (keyup)="processKeyUp($event, conf2)">
<input class="log_pin" type="password" maxlength="1" #conf2 (keydown.backspace)="processBack($event, conf1)" (keyup)="processKeyUp($event, conf3)">
<input class="log_pin" type="password" maxlength="1" #conf3 (keydown.backspace)="processBack($event, conf2)" (keyup)="processKeyUp($event, conf4)">
<input class="log_pin" type="password" maxlength="1" #conf4 (keydown.backspace)="processBack($event, conf3)" (keyup)="processKeyUp($event, conf5)">
<input class="log_pin" type="password" maxlength="1" #conf5 (keydown.backspace)="processBack($event, conf4)" (keyup)="processKeyUp($event, conf6)">
<input class="log_pin m0" type="password" maxlength="1" #conf6 (keydown.backspace)="processBack($event, conf5)">
</div>
</div>
<div class="s_error" *ngIf="confpasswordErr">
<div class="s_validation">{{error_msg.password}} </div>
</div>
<div class="s_error" *ngIf="notMatchErr">
<div class="s_validation">{{error_msg.confirm}} </div>
</div>
</div>
</div>
</div>
<div *ngIf="resetError" class="s_validation">{{resetMsg}}</div>
<div *ngIf="!resetError && !error && loginSubmit" class="s_validation">Passwod Updated Successfully</div>
<div class="login_btn_bay">
<div class="row">
<div class="col-md-6">
<button class="cancel_btn" (click)="goToPage('start/forgot')">Cancel</button>
<button class="cancel_btn" (click)="cancelClick()">Cancel</button>
</div>
<div class="col-md-6">
<button class="login_btn" (click)="goToPage('start/login')">Save</button>
<button class="login_btn" (click)="saveClick()">Save</button>
</div>
</div>
</div>
......
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ValidationService } from './../../providers/validation.service';
import { SubjectService } from './../../providers/subject.service';
import { WebService } from './../../providers/web.service';
import {Location} from '@angular/common';
@Component({
selector: 'app-changepin',
......@@ -6,10 +12,213 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./changepin.component.scss']
})
export class ChangepinComponent implements OnInit {
@ViewChild('old1') old1: ElementRef;
@ViewChild('old2') old2: ElementRef;
@ViewChild('old3') old3: ElementRef;
@ViewChild('old4') old4: ElementRef;
@ViewChild('old5') old5: ElementRef;
@ViewChild('old6') old6: ElementRef;
@ViewChild('new1') new1: ElementRef;
@ViewChild('new2') new2: ElementRef;
@ViewChild('new3') new3: ElementRef;
@ViewChild('new4') new4: ElementRef;
@ViewChild('new5') new5: ElementRef;
@ViewChild('new6') new6: ElementRef;
@ViewChild('conf1') conf1: ElementRef;
@ViewChild('conf2') conf2: ElementRef;
@ViewChild('conf3') conf3: ElementRef;
@ViewChild('conf4') conf4: ElementRef;
@ViewChild('conf5') conf5: ElementRef;
@ViewChild('conf6') conf6: ElementRef;
constructor() { }
error_msg: any[];
lang = 'en';
model: any;
passwordErr: boolean;
newpasswordErr: boolean;
confpasswordErr: boolean;
notMatchErr: boolean;
password: any;
fname: any;
loginSubmit: boolean;
resetError: boolean;
resetMsg: any;
loginDetails: any;
error: boolean;
constructor(
private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
public subjectService: SubjectService,
public location: Location
) {
this.loginDetails = JSON.parse(this.service.getLocalStorageItem('userData'));
this.error = false;
this.passwordErr = false;
this.newpasswordErr = false;
this.confpasswordErr = false;
this.notMatchErr = false;
this.error_msg = this.vs.errorList[this.lang];
}
ngOnInit() {
}
processKeyUp(e: any, el: any) {
el.value = '';
console.log(e);
if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) {
e.target.value = e.key;
el.focus();
} else {
if (e.keyCode !== 8) {
e.target.value = '';
}
}
}
processBack (e: any, el: any) {
if (e.keyCode === 8) {
e.target.value = '';
el.focus();
}
}
saveClick() {
this.loginSubmit = true;
this.passwordErr = false;
this.newpasswordErr = false;
this.confpasswordErr = false;
this.notMatchErr = false;
this.resetError = false;
this.error = false;
const password = [];
const newpassword = [];
const confirm = [];
password[0] = this.old1.nativeElement.value;
password[1] = this.old2.nativeElement.value;
password[2] = this.old3.nativeElement.value;
password[3] = this.old4.nativeElement.value;
password[4] = this.old5.nativeElement.value;
password[5] = this.old6.nativeElement.value;
newpassword[0] = this.new1.nativeElement.value;
newpassword[1] = this.new2.nativeElement.value;
newpassword[2] = this.new3.nativeElement.value;
newpassword[3] = this.new4.nativeElement.value;
newpassword[4] = this.new5.nativeElement.value;
newpassword[5] = this.new6.nativeElement.value;
confirm[0] = this.conf1.nativeElement.value;
confirm[1] = this.conf2.nativeElement.value;
confirm[2] = this.conf3.nativeElement.value;
confirm[3] = this.conf4.nativeElement.value;
confirm[4] = this.conf5.nativeElement.value;
confirm[5] = this.conf6.nativeElement.value;
const oldpass = password.join('');
const newpass = newpassword.join('');
const confirmpass = confirm.join('');
if (oldpass === '') {
this.passwordErr = true;
this.error = true;
} else {
for (const i in password) {
if (password[i] === '') {
this.passwordErr = true;
this.error = true;
}
}
}
if (newpass === '') {
this.newpasswordErr = true;
this.error = true;
} else {
for (const i in newpassword) {
if (newpassword[i] === '') {
this.newpasswordErr = true;
this.error = true;
}
}
}
if (confirmpass === '') {
this.confpasswordErr = true;
this.error = true;
} else {
for (const i in confirm) {
if (confirm[i] === '') {
this.confpasswordErr = true;
this.error = true;
}
}
}
console.log(this.error);
if (this.error === false) {
if (newpass !== confirmpass) {
this.notMatchErr = true;
this.error = true;
}
}
this.fname = 'reset_pin';
const post_data = {'user_id': this.loginDetails.user_id, 'password': oldpass, 'new_password': newpass};
this.service.post_data(this.fname, post_data).subscribe(response => {
console.log(response);
if (response.code === 1) {
const responseData = response.responseResult;
this.reset();
} else {
this.resetError = true;
this.resetMsg = this.vs.errorCode[this.lang][response.errorCode];
console.log(this.resetMsg);
}
}, (error) => {
this.resetError = true;
this.resetMsg = this.vs.errorCode[this.lang]['ER08'];
console.log(this.resetMsg);
});
}
reset() {
this.conf1.nativeElement.value = '';
this.conf2.nativeElement.value = '';
this.conf3.nativeElement.value = '';
this.conf4.nativeElement.value = '';
this.conf5.nativeElement.value = '';
this.conf6.nativeElement.value = '';
this.new1.nativeElement.value = '';
this.new2.nativeElement.value = '';
this.new3.nativeElement.value = '';
this.new4.nativeElement.value = '';
this.new5.nativeElement.value = '';
this.new6.nativeElement.value = '';
this.old1.nativeElement.value = '';
this.old2.nativeElement.value = '';
this.old3.nativeElement.value = '';
this.old4.nativeElement.value = '';
this.old5.nativeElement.value = '';
this.old6.nativeElement.value = '';
}
cancelClick() {
this.location.back();
}
}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { moduleRouting } from './checker.routing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
//IMPORTED-PAGE-COMPONENTS
......@@ -12,12 +13,20 @@ import { HomeComponent } from './home/home.component';
import { CurrencyComponent } from './currency/currency.component';
import { ForexproviderComponent } from './forexprovider/forexprovider.component';
import { ChangepinComponent } from './changepin/changepin.component';
import { CurrencyAddComponent } from './currency-add/currency-add.component';
import { AddforexComponent } from './addforex/addforex.component';
import { EditforexComponent } from './editforex/editforex.component';
import { CurrencyEditComponent } from './currency-edit/currency-edit.component';
import { CurrencyListComponent } from './currency-list/currency-list.component';
@NgModule({
declarations: [IndexComponent, AddproviderComponent, EditproviderComponent, ManageproviderComponent, HomeComponent, CurrencyComponent, ForexproviderComponent, ChangepinComponent],
// tslint:disable-next-line:max-line-length
declarations: [IndexComponent, AddproviderComponent, EditproviderComponent, ManageproviderComponent, HomeComponent, CurrencyComponent, ForexproviderComponent, ChangepinComponent, CurrencyAddComponent, AddforexComponent, EditforexComponent, CurrencyEditComponent, CurrencyListComponent],
imports: [
CommonModule,
moduleRouting
moduleRouting,
FormsModule,
ReactiveFormsModule
]
})
export class CheckerModule { }
......@@ -16,20 +16,30 @@ import { ForexproviderComponent } from './forexprovider/forexprovider.component'
import { HomeComponent } from './home/home.component';
import { CurrencyComponent } from './currency/currency.component';
import { ChangepinComponent } from './changepin/changepin.component';
import { CurrencyAddComponent } from './currency-add/currency-add.component';
import { AuthGuard } from './../providers/auth.guard';
import { AddforexComponent } from './addforex/addforex.component';
import { EditforexComponent } from './editforex/editforex.component';
import { CurrencyEditComponent } from './currency-edit/currency-edit.component';
import { CurrencyListComponent } from './currency-list/currency-list.component';
const ModuleRoutes: Routes = [
{ path: 'checker', component: IndexComponent, canActivate: [AuthGuard],
children: [
{ path: 'addprovider', component: AddproviderComponent },
{ path: 'editprovider', component: EditproviderComponent },
{ path: 'provider_delivery', component: AddproviderComponent },
{ path: 'delivery_edit/:id', component: EditproviderComponent },
{ path: 'delivery', component: ManageproviderComponent },
{ path: 'forex', component: ForexproviderComponent },
{ path: 'provider_forex', component: AddforexComponent },
{ path: 'forex_edit/:id', component: EditforexComponent },
{ path: 'home', component: HomeComponent },
{ path: 'currency', component: CurrencyComponent },
{ path: 'changepin', component: ChangepinComponent }
{ path: 'changepin', component: ChangepinComponent },
{ path: 'currency_add', component: CurrencyAddComponent},
{ path: 'currency_edit/:id', component: CurrencyEditComponent},
{ path: 'currency_list', component: CurrencyListComponent}
]
}
];
......
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Currency Management</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
<span (click)="goToPage('delivery/changepin')">Change PIN</span>
</div>
</div>
</header>
<section>
<div class="provider_content">
<h3>Add Currency</h3>
<div class="provider_inner_content">
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Currency added successfully.
</div>
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseError}}
</div>
<form [formGroup]="currencyForm" (ngSubmit)="currencyProcess()" autocomplete="off">
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Name</p>
<input class="provider_input" placeholder="" type="text" formControlName="name">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['name'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['name'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Symbol</p>
<input class="provider_input" placeholder="" type="text" formControlName="symbol">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['symbol'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['symbol'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>flag</p>
<input class="provider_input" placeholder="" type="file" formControlName="flag" (change)="onFileChange($event)">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['flag'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['flag'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Rate</p>
<input class="provider_input" placeholder="" type="number" formControlName="rate">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['rate'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['rate'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Forex amount Start From</p>
<input class="provider_input" placeholder="" type="number" formControlName="start_from">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['start_from'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['start_from'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="col">
<div class="add_provider_btn_bay p0">
<button class="edit_btn floatRight" (click)="goToPage('checker/editprovider')">Edit</button>
<div class="clear"></div>
</div>
</div>
</div> -->
<div class="row">
<div class="col">
<div class="add_provider_btn_bay">
<button class="save_btn floatRight">Save</button>
<button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
\ No newline at end of file
.provider_header{
background: #1a5c7c;
padding: 4px;
h4{
margin:0px;
color: #fff;
padding: 20px;
font-weight: 400;
font-size:20px;
}
span{
position: absolute;
bottom:-30px;
right:15px;
font-size: 14px;
cursor: pointer;
z-index: 999;
}
}
.provider_content{
width:100%;
position: relative;
h3{
margin:0px;
padding:0px;
border-bottom: 1px solid #494949;
color: #464646;
font-size: 20px;
font-weight: 400;
padding: 15px;
}
.provider_inner_content{
width:100%;
padding-top: 40px;
padding-left: 20px;
padding-right: 20px;
.row{
padding-bottom: 40px;
.provider_data_content{
width:90%;
margin:0 auto;
p{
color: #464646;
margin:0px;
padding-bottom: 10px;
font-weight: 500;
}
.provider_input{
border:1px solid #b4b4b4;
height:40px;
padding-left: 10px;
padding-right: 10px;
width: 100%;
&:focus{
outline: none;
}
}
.provider_pin{
border:1px solid #b4b4b4;
height:40px;
width: calc(100% - 90%);
margin-right: calc(100% - 92%);
text-align: center;
display: inline-block;
border-radius: 10px;
&:focus{
outline: none;
}
}
}
.edit_btn{
background: #d9d9d9;
color: #1a5d7a;
border-radius:20px;
height:40px;
padding-left: 4%;
padding-right:4%;
font-weight: 500;
margin:1%;
border:none;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
.add_provider_btn_bay{
width:100%;
padding-top:5%;
text-align: right;
.save_btn{
background: #cd3d3d;
color: #fff;
border-radius:20px;
height:40px;
border:none;
padding-left:4%;
padding-right:4%;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
.cancel_btn{
background: #1a5c7c;
color: #fff;
border-radius:20px;
height:40px;
padding-left:4%;
padding-right:4%;
border:none;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CurrencyAddComponent } from './currency-add.component';
describe('CurrencyAddComponent', () => {
let component: CurrencyAddComponent;
let fixture: ComponentFixture<CurrencyAddComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CurrencyAddComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CurrencyAddComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { WebService } from './../../providers/web.service';
import { ValidationService } from './../../providers/validation.service';
import { FormControl, FormGroup, FormBuilder, Validators, ValidationErrors } from '@angular/forms';
@Component({
selector: 'app-currency-add',
templateUrl: './currency-add.component.html',
styleUrls: ['./currency-add.component.scss']
})
export class CurrencyAddComponent implements OnInit {
currencyForm: FormGroup;
mobnumPattern = '^((\\+?)|0)?[0-9]{8,15}$';
emailPattern = '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$';
currencySubmit: boolean;
lang = 'en';
error_msg: any[];
funcName: any;
loader: boolean;
responseError: any;
error: boolean;
success: boolean;
file: File;
constructor(
private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
private formBuilder: FormBuilder
) {
this.loader = false;
this.error = false;
this.success = false;
this.currencySubmit = false;
this.error_msg = this.vs.errorList[this.lang];
}
ngOnInit() {
this.currencyForm = this.formBuilder.group({
'name': ['', Validators.compose([Validators.required])],
'symbol': ['', Validators.compose([Validators.required])],
'flag': ['', Validators.compose([Validators.required])],
'rate': ['', Validators.compose([Validators.required])],
'start_from': ['', Validators.compose([Validators.required])]
});
}
onFileChange(event) {
if (event.target.files.length > 0) {
this.file = event.target.files[0];
}
console.log(this.file);
}
currencyProcess() {
const This = this;
this.error = false;
this.success = false;
console.log(this.currencyForm.value);
this.currencySubmit = true;
if (this.currencyForm.valid) {
this.loader = true;
const providerObj = this.currencyForm.value;
const post_data = this.prepareSave(providerObj);
this.funcName = 'currency_create';
this.service.post_data(this.funcName, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
this.currencySubmit = false;
this.currencyForm.reset();
} else {
this.error = true;
this.responseError = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = false;
this.responseError = this.vs.errorCode[this.lang]['ER08'];
});
}
console.log('tested');
}
prepareSave(formHasImage): any {
const input = new FormData();
input.append('flag', this.file);
input.append('name', formHasImage.name);
input.append('symbol', formHasImage.symbol);
input.append('rate', formHasImage.rate);
input.append('start_from', formHasImage.start_from);
console.log(input);
return input;
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Currency Management</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
<span (click)="goToPage('delivery/changepin')">Change PIN</span>
</div>
</div>
</header>
<section>
<div class="provider_content">
<h3>Edit Currency</h3>
<div class="provider_inner_content">
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Currency added successfully.
</div>
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseError}}
</div>
<form [formGroup]="currencyForm" (ngSubmit)="currencyProcess()" autocomplete="off">
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Name</p>
<input class="provider_input" placeholder="" type="text" formControlName="name">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['name'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['name'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Symbol</p>
<input class="provider_input" placeholder="" type="text" formControlName="symbol">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['symbol'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['symbol'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<img [src]="getImage()" width="100" height="100" *ngIf="image_url" />
<div class="provider_data_content">
<p>flag</p>
<input class="provider_input" placeholder="" type="file" formControlName="flag" (change)="onFileChange($event)">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['flag'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['flag'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Rate</p>
<input class="provider_input" placeholder="" type="number" formControlName="rate">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['rate'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['rate'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Forex amount Start From</p>
<input class="provider_input" placeholder="" type="number" formControlName="start_from">
</div>
<div class="s_error" *ngIf="!currencyForm.controls['start_from'].valid && currencySubmit">
<div class="s_validation" *ngIf="currencyForm.controls['start_from'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="col">
<div class="add_provider_btn_bay p0">
<button class="edit_btn floatRight" (click)="goToPage('checker/editprovider')">Edit</button>
<div class="clear"></div>
</div>
</div>
</div> -->
<div class="row">
<div class="col">
<div class="add_provider_btn_bay">
<button class="save_btn floatRight">Save</button>
<button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
\ No newline at end of file
.provider_header{
background: #1a5c7c;
padding: 4px;
h4{
margin:0px;
color: #fff;
padding: 20px;
font-weight: 400;
font-size:20px;
}
span{
position: absolute;
bottom:-30px;
right:15px;
font-size: 14px;
cursor: pointer;
z-index: 999;
}
}
.provider_content{
width:100%;
position: relative;
h3{
margin:0px;
padding:0px;
border-bottom: 1px solid #494949;
color: #464646;
font-size: 20px;
font-weight: 400;
padding: 15px;
}
.provider_inner_content{
width:100%;
padding-top: 40px;
padding-left: 20px;
padding-right: 20px;
.row{
padding-bottom: 40px;
.provider_data_content{
width:90%;
margin:0 auto;
p{
color: #464646;
margin:0px;
padding-bottom: 10px;
font-weight: 500;
}
.provider_input{
border:1px solid #b4b4b4;
height:40px;
padding-left: 10px;
padding-right: 10px;
width: 100%;
&:focus{
outline: none;
}
}
.provider_pin{
border:1px solid #b4b4b4;
height:40px;
width: calc(100% - 90%);
margin-right: calc(100% - 92%);
text-align: center;
display: inline-block;
border-radius: 10px;
&:focus{
outline: none;
}
}
}
.edit_btn{
background: #d9d9d9;
color: #1a5d7a;
border-radius:20px;
height:40px;
padding-left: 4%;
padding-right:4%;
font-weight: 500;
margin:1%;
border:none;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
.add_provider_btn_bay{
width:100%;
padding-top:5%;
text-align: right;
.save_btn{
background: #cd3d3d;
color: #fff;
border-radius:20px;
height:40px;
border:none;
padding-left:4%;
padding-right:4%;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
.cancel_btn{
background: #1a5c7c;
color: #fff;
border-radius:20px;
height:40px;
padding-left:4%;
padding-right:4%;
border:none;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CurrencyEditComponent } from './currency-edit.component';
describe('CurrencyEditComponent', () => {
let component: CurrencyEditComponent;
let fixture: ComponentFixture<CurrencyEditComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CurrencyEditComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CurrencyEditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { WebService } from './../../providers/web.service';
import { ValidationService } from './../../providers/validation.service';
import { FormControl, FormGroup, FormBuilder, Validators, ValidationErrors } from '@angular/forms';
import { ImageStorage } from '../../../environments/server.config';
@Component({
selector: 'app-currency-edit',
templateUrl: './currency-edit.component.html',
styleUrls: ['./currency-edit.component.scss']
})
export class CurrencyEditComponent implements OnInit {
currencyForm: FormGroup;
mobnumPattern = '^((\\+?)|0)?[0-9]{8,15}$';
emailPattern = '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$';
currencySubmit: boolean;
lang = 'en';
error_msg: any[];
funcName: any;
loader: boolean;
responseError: any;
error: boolean;
success: boolean;
file: File;
currency: any;
image_url: any;
constructor(private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
private formBuilder: FormBuilder
) {
this.loader = false;
this.error = false;
this.success = false;
this.currencySubmit = false;
this.error_msg = this.vs.errorList[this.lang];
}
ngOnInit() {
const parm = decodeURIComponent(this.route.snapshot.params['id']);
// tslint:disable-next-line:radix
const id = parseInt(parm);
this.getCurrency(id);
this.currencyForm = this.formBuilder.group({
'name': ['', Validators.compose([Validators.required])],
'symbol': ['', Validators.compose([Validators.required])],
'flag': [''],
'rate': ['', Validators.compose([Validators.required])],
'start_from': ['', Validators.compose([Validators.required])],
'id': [id]
});
}
onFileChange(event) {
if (event.target.files.length > 0) {
this.file = event.target.files[0];
}
console.log(this.file);
}
currencyProcess() {
const This = this;
this.error = false;
this.success = false;
console.log(this.currencyForm.value);
this.currencySubmit = true;
if (this.currencyForm.valid) {
this.loader = true;
const providerObj = this.currencyForm.value;
const post_data = this.prepareSave(providerObj);
this.funcName = 'currency_edit';
this.service.post_data(this.funcName, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
this.currencySubmit = false;
} else {
this.error = true;
this.responseError = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = false;
this.responseError = this.vs.errorCode[this.lang]['ER08'];
});
}
console.log('tested');
}
prepareSave(formHasImage): any {
const input = new FormData();
if(this.file) {
input.append('flag', this.file);
}
input.append('name', formHasImage.name);
input.append('symbol', formHasImage.symbol);
input.append('rate', formHasImage.rate);
input.append('start_from', formHasImage.start_from);
input.append('id', formHasImage.id);
console.log(input);
return input;
}
getCurrency(id) {
this.loader = true;
this.funcName = 'currency_details';
const post_data = {'currency_id': id};
this.service.post_data(this.funcName, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.currency = response.responseResult;
this.image_url = this.currency.flag;
this.currencyForm.patchValue({
name: this.currency.name,
symbol: this.currency.symbol,
rate: this.currency.rate,
start_from: this.currency.start_from,
flag: this.currency.flag
});
} else {
this.error = true;
this.responseError = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseError = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseError = '';
}, 3000);
}
getImage() {
return ImageStorage + this.image_url;
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Forex Provider</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
<span (click)="goToPage('checker/changepin')">Change PIN</span>
</div>
</div>
</header>
<section>
<div class="provider_content">
<h3>Manage Forex Service Provider</h3>
<div class="provider_inner_content">
<div class="table-responsive">
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseMsg}}
</div>
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Forex provider removed successfully
</div>
<table class="table">
<thead>
<tr>
<th>Provider Name</th>
<th>Location</th>
<th>CR Manager</th>
<th>CR ID</th>
<th>Contact</th>
<th>Phone</th>
<th>Email ID</th>
<th class="textRight">
<button class="add" (click)="goToPage('checker/provider_forex')">+</button>
</th>
</tr>
</thead>
<tbody *ngIf="providerList; else noProvider">
<tr *ngFor="let provider of providerList;">
<td>{{provider.name | titlecase}}</td>
<td>{{provider.location | titlecase}}</td>
<td>{{provider.cr_manager | titlecase}}</td>
<td>{{provider.cr_id}}</td>
<td>{{provider.contact | titlecase}}</td>
<td>{{provider.phone}}</td>
<td>{{provider.email_id}}</td>
<td class="textRight">
<button class="edit_btn"(click)="editClick(provider.id)"></button>
<button class="delete_btn" (click)="deleteClick(provider.id)"></button>
</td>
</tr>
</tbody>
</table>
<ng-template #noProvider></ng-template>
</div>
</div>
</div>
</section>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CurrencyListComponent } from './currency-list.component';
describe('CurrencyListComponent', () => {
let component: CurrencyListComponent;
let fixture: ComponentFixture<CurrencyListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CurrencyListComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CurrencyListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-currency-list',
templateUrl: './currency-list.component.html',
styleUrls: ['./currency-list.component.scss']
})
export class CurrencyListComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
......@@ -13,6 +16,14 @@
<div class="provider_content">
<h3>Currency & Rates</h3>
<div class="provider_inner_content">
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseMsg}}
</div>
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Currency assigned successfully
</div>
<div class="row">
<div class="col-md-6">
<div class="row">
......@@ -23,52 +34,47 @@
<div class="row">
<div class="col-md-4">
<div class="currency_div">
<ul>
<li>USD</li>
<li>Pound</li>
<li>Euro</li>
<li>Dirham</li>
<li>USD</li>
<li>Pound</li>
<li>Euro</li>
<li>Dirham</li>
<li>USD</li>
<li>Pound</li>
<li>Euro</li>
<li>Dirham</li>
<ul *ngIf="currencyList">
<li *ngFor="let currency of avaliableList" (click)="currency_add(currency)">{{currency.name}}</li>
</ul>
</div>
</div>
<div class="col-md-4 textCenter">
<button class="add_btn">Add<img src="assets/images/right.png"></button><br>
<button class="add_btn"><img src="assets/images/left.png">Remove</button>
<button class="add_btn" (click)="currency_push()">Add<img src="assets/images/right.png"></button><br>
<button class="add_btn" (click)="currency_pop()"><img src="assets/images/left.png">Remove</button>
</div>
<div class="col-md-4">
<div class="currency_div">
<ul *ngIf="selectedList">
<li *ngFor="let currency of selectedList" (click)="currency_remove(currency)">{{currency.name}}</li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-md-2"></div>
<div class="col-md-4">
<form [formGroup]="currencyForm" novalidate (ngSubmit)="currency_assign()">
<div class="row">
<div class="col-md-12">
<p>Rates</p>
</div>
</div>
<div class="row">
<div formArrayName="currency">
<div class="row" *ngFor="let address of currencyForm.controls.currency.controls; let i=index" [formGroupName]="i">
<div class="col-md-6">
<h6>USD</h6>
<input class="" type="number">
<h6>{{selectedList[i].name}}</h6>
<input class="" type="hidden" formControlName="currency_id">
<input class="" type="number" formControlName="rate">
<div class="s_error" *ngIf="!currencyForm.controls.currency.controls[i].controls.rate.valid && bookSubmit">
<div class="s_validation" *ngIf="currencyForm.controls.currency.controls[i].controls.rate.hasError('required')">{{vs.errorList.required}} </div>
</div>
<div class="col-md-6">
<h6>Pound</h6>
<input class="" type="number">
</div>
</div>
<div class="row">
</div>
<input type="hidden" formControlName="provider_id"/>
<!-- <div class="row">
<div class="col-md-6">
<h6>Euro</h6>
<input class="" type="number">
......@@ -77,18 +83,76 @@
<h6>Dirham</h6>
<input class="" type="number">
</div>
</div>
</div>
</div>
<div class="row">
</div> -->
<div class="row" *ngIf="selectedList.length > 0">
<div class="col">
<div class="add_provider_btn_bay">
<button class="save_btn floatRight" (click)="goToPage('checker/manageprovider')">Save</button>
<button class="save_btn floatRight">Save</button>
<button class="cancel_btn floatRight">Cancel</button>
<div class="clear"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- <form [formGroup]="passengerForm" novalidate (ngSubmit)="booking(passengerForm, payment)">
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="information_div">
<h4>Passenger Details</h4>
<ul formArrayName="passenger">
<li *ngFor="let address of passengerForm.controls.passenger.controls; let i=index" [formGroupName]="i">
<div class="row">
<div class="col-md-6">
<h6>Name</h6>
<input class="input_detail" formControlName="name" placeholder="Enter passenger name" type="text">
<div class="s_error" *ngIf="!passengerForm.controls.passenger.controls[i].controls.name.valid && bookSubmit">
<div class="s_validation" *ngIf="passengerForm.controls.passenger.controls[i].controls.name.hasError('required')">{{vs.errorList.required}} </div>
</div>
</div>
<div class="col-md-6">
<h6>Age</h6>
<input class="input_detail" formControlName="age" placeholder="Enter passenger age" type="number">
<div class="s_error" *ngIf="!passengerForm.controls.passenger.controls[i].controls.age.valid && passengerForm.controls.passenger.controls[i].controls.age.touched">
<div class="s_validation" *ngIf="passengerForm.controls.passenger.controls[i].controls.age.errors?.min">{{vs.errorList.min}} 3</div>
<div class="s_validation" *ngIf="passengerForm.controls.passenger.controls[i].controls.age.errors?.max">{{vs.errorList.max}} 60</div>
</div>
<div class="s_error" *ngIf="!passengerForm.controls.passenger.controls[i].controls.age.valid && bookSubmit">
<div class="s_validation" *ngIf="passengerForm.controls.passenger.controls[i].controls.age.hasError('required')">{{vs.errorList.required}} </div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h6>Gender</h6>
<div class="radio_container clearfix">
<span for="22" class="radio_block" *ngIf="getGender_state(i,'F')">
<input type="radio" id="22_1" class="radio_btn" value="Male" formControlName="gender">
<label for="22_1" class="radio_css " value="Male">Male</label>
</span>
<span for="23" class="radio_block" *ngIf="getGender_state(i,'M')">
<input type="radio" id="23_1" class="radio_btn" value="Female" formControlName="gender">
<label for="23_1" class="radio_css " value="Female">Female</label>
</span>
</div>
</div>
<div class="col-md-6">&nbsp;</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</form> -->
</section>
import { Component, OnInit } from '@angular/core';
import { Router,ActivatedRoute } from '@angular/router';
import { Router, ActivatedRoute } from '@angular/router';
import { WebService } from './../../providers/web.service';
import { ValidationService } from './../../providers/validation.service';
import { FormGroup, FormArray, FormBuilder, Validators } from '@angular/forms';
@Component({
selector: 'app-currency',
templateUrl: './currency.component.html',
styleUrls: ['./currency.component.scss']
})
export class CurrencyComponent implements OnInit {
currencyList: any[];
avaliableList: any[];
fname: any;
lang = 'ar';
responseMsg: any;
error: boolean;
success: boolean;
loader: boolean;
buffer: any[];
packet: any[];
selectedList: any[];
public currencyForm: FormGroup;
loginDetails: any;
currenySubmit: boolean;
constructor(private router: Router,private route: ActivatedRoute) { }
constructor(
private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
private fb: FormBuilder
) {
this.currencyForm = this.fb.group({
'provider_id': [1, Validators.compose([Validators.required])],
'currency': this.fb.array([])
});
this.responseMsg = '';
this.error = false;
this.success = false;
this.loader = false;
this.buffer = [];
this.packet = [];
this.selectedList = [];
this.currenySubmit = false;
this.loginDetails = JSON.parse(this.service.getLocalStorageItem('userData'));
this.providerCurrency();
}
ngOnInit() {
this.getCurrency();
const This = this;
setTimeout(function() {
This.getunique(This.currencyList, This.selectedList);
}, 500);
}
goToPage(path,data=null){
console.log(data)
this.router.navigateByUrl(path,{queryParams:data});
goToPage(path, data = null) {
console.log(data);
this.router.navigateByUrl(path, { queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
getCurrency() {
this.loader = true;
this.fname = 'currency';
this.service.get_data(this.fname).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.currencyList = response.responseResult;
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000);
}
providerCurrency() {
this.loader = true;
this.fname = 'forex_currency';
this.service.get_data(this.fname).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.selectedList = response.responseResult;
this.patchValues();
} else {
this.selectedList = [];
}
}, (error) => {
// this.error = true;
// this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000);
}
currency_add(curr: any) {
this.buffer.push(curr);
console.log(this.buffer);
}
currency_remove(curr: any) {
this.packet.push(curr);
console.log(this.packet);
}
currency_push() {
if (this.selectedList.length === 0) {
this.selectedList = this.buffer;
} else {
Array.prototype.push.apply(this.selectedList, this.buffer);
}
this.buffer = [];
this.patchValues();
this.getunique(this.currencyList, this.selectedList);
}
currency_pop() {
this.selectedList = this.selectedList.filter(this.comparer(this.packet));
this.packet = [];
this.getunique(this.currencyList, this.selectedList);
this.patchValues();
}
getunique(allList, ArrayList) {
this.avaliableList = allList.filter(this.comparer(ArrayList));
console.log(this.avaliableList);
}
comparer(otherArray) {
return function(current) {
return otherArray.filter(function(other){
return other.id === current.id;
}).length === 0;
};
}
patchValues() {
console.log('called');
console.log(this.selectedList);
const currencyCtrl = <FormArray>this.currencyForm.controls.currency;
currencyCtrl.controls = [];
const currencyCount = this.selectedList.length;
console.log(currencyCount);
let currency_details;
for (let i = 0; i < currencyCount; i++) {
console.log();
currency_details = {
'currency_id': this.selectedList[i].id,
'rate': [this.selectedList[i].rate, Validators.compose([Validators.required ])]
};
currencyCtrl.push(this.fb.group(currency_details));
}
}
currency_assign() {
this.currenySubmit = true;
const This = this;
if (this.currencyForm.valid) {
this.loader = true;
const postData = this.currencyForm.value;
console.log(postData);
this.fname = 'currency_assign';
this.service.post_data(this.fname, postData).subscribe(response => {
this.loader = false;
if (response.code === 1) {
this.success = true;
this.currenySubmit = false;
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = false;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
}
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Forex Provider</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
<span (click)="goToPage('checker/changepin')">Change PIN</span>
</div>
</div>
</header>
<section>
<div class="provider_content">
<h3>Edit Forex Provider</h3>
<div class="provider_inner_content">
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Provider updated successfully.
</div>
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseMsg}}
</div>
<form [formGroup]="providerForm" (ngSubmit)="editProcess()" autocomplete="off">
<div class="row">
<div class="col">
<div class="provider_data_content" *ngIf="provider">
<p>Provider Name</p>
<input class="provider_input" placeholder="" type="text" disabled [value]="provider.name">
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Location</p>
<input class="provider_input" placeholder="" type="text" formControlName="location">
</div>
<div class="s_error" *ngIf="!providerForm.controls['location'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['location'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content" *ngIf="provider">
<p>CR ID</p>
<input class="provider_input" placeholder="" type="text" disabled [value]="provider.cr_id">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>CR Manager</p>
<input class="provider_input" placeholder="" type="text" formControlName="cr_manager">
</div>
<div class="s_error" *ngIf="!providerForm.controls['cr_manager'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['cr_manager'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Contact</p>
<input class="provider_input" placeholder="" type="text" formControlName="contact">
</div>
<div class="s_error" *ngIf="!providerForm.controls['contact'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['contact'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Phone</p>
<input class="provider_input" placeholder="" type="number" formControlName="phone">
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('pattern')">{{error_msg.phone}}</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched && !providerForm.controls['phone'].hasError('pattern')">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('maxlength')">{{error_msg.maxLength}} 15</div>
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('minlength')">{{error_msg.minLength}} 8</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="provider_data_content">
<p>Email id</p>
<input class="provider_input" placeholder="" type="mail" formControlName="email_id">
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerForm.controls['email_id'].touched">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('pattern')">{{error_msg.email}} </div>
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('maxlength')">{{error_msg.maxLength}} 50</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Status</p>
<select class="provider_input" formControlName="online_status">
<option value="1">Online</option>
<option value="0">Offline</option>
</select>
</div>
<div class="s_error" *ngIf="!providerForm.controls['online_status'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['online_status'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Delivery Provider</p>
<select class="provider_input" formControlName="deli_provider_id">
<option *ngFor="let provider of providerList" [value]="provider.id">{{provider.name}}</option>
</select>
</div>
<div class="s_error" *ngIf="!providerForm.controls['deli_provider_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['deli_provider_id'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<!-- <div class="col">
<div class="provider_data_content">
<p></p>
<div class="edit_delivery">Edit Delivery Driver</div>
</div>
</div> -->
</div>
<div class="row">
<div class="col">
<div class="add_provider_btn_bay">
<button class="save_btn floatRight">Save</button>
<button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
\ No newline at end of file
.provider_header{
background: #1a5c7c;
padding: 4px;
h4{
margin:0px;
color: #fff;
padding: 20px;
font-weight: 400;
font-size:20px;
}
span{
position: absolute;
bottom:-30px;
right:15px;
font-size: 14px;
cursor: pointer;
z-index: 999;
}
}
.provider_content{
width:100%;
position: relative;
h3{
margin:0px;
padding:0px;
border-bottom: 1px solid #494949;
color: #464646;
font-size: 20px;
font-weight: 400;
padding: 15px;
}
.provider_inner_content{
width:100%;
padding-top: 40px;
padding-left: 20px;
padding-right: 20px;
.row{
padding-bottom: 40px;
.provider_data_content{
width:90%;
margin:0 auto;
.edit_delivery{
color: #195c77;
text-decoration: underline;
cursor: pointer;
font-weight: 500;
position: relative;
top:30px;
}
p{
color: #464646;
margin:0px;
padding-bottom: 10px;
font-weight: 500;
}
.provider_input{
border:1px solid #b4b4b4;
height:40px;
padding-left: 10px;
padding-right: 10px;
width: 100%;
&:focus{
outline: none;
}
}
.provider_pin{
border:1px solid #b4b4b4;
height:40px;
width: calc(100% - 90%);
margin-right: calc(100% - 92%);
text-align: center;
display: inline-block;
border-radius: 10px;
&:focus{
outline: none;
}
}
}
.edit_btn{
background: #d9d9d9;
color: #1a5d7a;
border-radius:20px;
height:40px;
padding-left: 4%;
padding-right:4%;
font-weight: 500;
margin:1%;
border:none;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
.add_provider_btn_bay{
width:100%;
padding-top:5%;
text-align: right;
.save_btn{
background: #cd3d3d;
color: #fff;
border-radius:20px;
height:40px;
border:none;
padding-left:4%;
padding-right:4%;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
.cancel_btn{
background: #1a5c7c;
color: #fff;
border-radius:20px;
height:40px;
padding-left:4%;
padding-right:4%;
border:none;
margin:1%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditforexComponent } from './editforex.component';
describe('EditforexComponent', () => {
let component: EditforexComponent;
let fixture: ComponentFixture<EditforexComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditforexComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditforexComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { WebService } from './../../providers/web.service';
import { ValidationService } from './../../providers/validation.service';
import { FormControl, FormGroup, FormBuilder, Validators, ValidationErrors } from '@angular/forms';
@Component({
selector: 'app-editforex',
templateUrl: './editforex.component.html',
styleUrls: ['./editforex.component.scss']
})
export class EditforexComponent implements OnInit {
provider: any;
funcName: any;
lang = 'ar';
responseMsg: any;
error: boolean;
success: boolean;
loader: boolean;
providerForm: FormGroup;
mobnumPattern = '^((\\+?)|0)?[0-9]{8,15}$';
emailPattern = '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$';
providerSubmit: boolean;
error_msg: any[];
providerList: any[];
constructor(
private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
private formBuilder: FormBuilder
) {
this.loader = false;
this.error = false;
this.success = false;
this.providerSubmit = false;
this.error_msg = this.vs.errorList[this.lang];
}
ngOnInit() {
const parm = decodeURIComponent(this.route.snapshot.params['id']);
// tslint:disable-next-line:radix
const id = parseInt(parm);
this.getProvider(id);
this.getProviderList();
console.log(id);
this.providerForm = this.formBuilder.group({
'cr_manager': ['', Validators.compose([Validators.required])],
'contact': ['', Validators.compose([Validators.required])],
'location': ['', Validators.compose([Validators.required])],
'email_id': ['', Validators.compose([Validators.required, Validators.maxLength(50), Validators.pattern(this.emailPattern)])],
// tslint:disable-next-line:max-line-length
'phone': ['', Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(15), Validators.pattern(this.mobnumPattern)])],
'type': [2],
'provider_id': [id],
'online_status': ['', Validators.compose([Validators.required])],
'deli_provider_id': ['', Validators.compose([Validators.required])],
});
}
getProviderList() {
this.loader = true;
this.funcName = 'providers';
const post_data = {'type': 3};
this.service.post_data(this.funcName, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.providerList = response.responseResult;
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000);
}
getProvider(id: any) {
this.loader = true;
this.funcName = 'providers_details';
const post_data = {'provider_id': id};
this.service.post_data(this.funcName, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.provider = response.responseResult;
this.providerForm.patchValue({
cr_manager: this.provider.cr_manager,
contact: this.provider.contact,
location: this.provider.location,
email_id: this.provider.email_id,
phone: this.provider.phone,
online_status: this.provider.online_status,
deli_provider_id: this.provider.deli_provider_id,
});
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000);
}
cancelClick() {
this.router.navigate(['/checker/forex']);
}
editProcess() {
const This = this;
this.error = false;
this.success = false;
console.log(this.providerForm.value);
this.providerSubmit = true;
if (this.providerForm.valid) {
this.loader = true;
const providerObj = this.providerForm.value;
this.funcName = 'provider_edit';
this.service.post_data(this.funcName, providerObj).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
this.providerSubmit = false;
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = false;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
}
console.log('tested');
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
......@@ -13,23 +16,36 @@
<div class="provider_content">
<h3>Edit Delivery Service Provider</h3>
<div class="provider_inner_content">
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Provider updated successfully.
</div>
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseMsg}}
</div>
<form [formGroup]="providerForm" (ngSubmit)="editProcess()" autocomplete="off">
<div class="row">
<div class="col">
<div class="provider_data_content">
<div class="provider_data_content" *ngIf="provider">
<p>Provider Name</p>
<input class="provider_input" placeholder="" type="text" disabled>
<input class="provider_input" placeholder="" type="text" disabled [value]="provider.name">
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Location</p>
<input class="provider_input" placeholder="" type="text">
<input class="provider_input" placeholder="" type="text" formControlName="location">
</div>
<div class="s_error" *ngIf="!providerForm.controls['location'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['location'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<div class="provider_data_content" *ngIf="provider">
<p>CR ID</p>
<input class="provider_input" placeholder="" type="text" disabled>
<input class="provider_input" placeholder="" type="text" disabled [value]="provider.cr_id">
</div>
</div>
</div>
......@@ -37,19 +53,36 @@
<div class="col">
<div class="provider_data_content">
<p>CR Manager</p>
<input class="provider_input" placeholder="" type="text">
<input class="provider_input" placeholder="" type="text" formControlName="cr_manager">
</div>
<div class="s_error" *ngIf="!providerForm.controls['cr_manager'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['cr_manager'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Contact</p>
<input class="provider_input" placeholder="" type="text">
<input class="provider_input" placeholder="" type="text" formControlName="contact">
</div>
<div class="s_error" *ngIf="!providerForm.controls['contact'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['contact'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
<div class="provider_data_content">
<p>Phone</p>
<input class="provider_input" placeholder="" type="number">
<input class="provider_input" placeholder="" type="number" formControlName="phone">
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('pattern')">{{error_msg.phone}}</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerForm.controls['phone'].touched && !providerForm.controls['phone'].hasError('pattern')">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('maxlength')">{{error_msg.maxLength}} 15</div>
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('minlength')">{{error_msg.minLength}} 8</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['phone'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['phone'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
</div>
......@@ -57,7 +90,14 @@
<div class="col">
<div class="provider_data_content">
<p>Email id</p>
<input class="provider_input" placeholder="" type="mail">
<input class="provider_input" placeholder="" type="mail" formControlName="email_id">
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerForm.controls['email_id'].touched">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('pattern')">{{error_msg.email}} </div>
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('maxlength')">{{error_msg.maxLength}} 50</div>
</div>
<div class="s_error" *ngIf="!providerForm.controls['email_id'].valid && providerSubmit">
<div class="s_validation" *ngIf="providerForm.controls['email_id'].hasError('required')">{{error_msg.required}} </div>
</div>
</div>
<div class="col">
......@@ -65,22 +105,23 @@
</div>
</div>
<div class="col">
<!-- <div class="col">
<div class="provider_data_content">
<p></p>
<div class="edit_delivery">Edit Delivery Driver</div>
</div>
</div>
</div> -->
</div>
<div class="row">
<div class="col">
<div class="add_provider_btn_bay">
<button class="save_btn floatRight" (click)="goToPage('checker/manageprovider')">Save</button>
<button class="cancel_btn floatRight">Cancel</button>
<button class="save_btn floatRight">Save</button>
<button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div>
</div>
</div>
</div>
</form>
</div>
</div>
</section>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { Router,ActivatedRoute } from '@angular/router';
import { Router, ActivatedRoute } from '@angular/router';
import { WebService } from './../../providers/web.service';
import { ValidationService } from './../../providers/validation.service';
import { FormControl, FormGroup, FormBuilder, Validators, ValidationErrors } from '@angular/forms';
@Component({
selector: 'app-editprovider',
templateUrl: './editprovider.component.html',
styleUrls: ['./editprovider.component.scss']
})
export class EditproviderComponent implements OnInit {
provider: any;
funcName: any;
lang = 'ar';
responseMsg: any;
error: boolean;
success: boolean;
loader: boolean;
providerForm: FormGroup;
mobnumPattern = '^((\\+?)|0)?[0-9]{8,15}$';
emailPattern = '^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$';
providerSubmit: boolean;
error_msg: any[];
constructor(private router: Router,private route: ActivatedRoute) { }
constructor(
private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
private formBuilder: FormBuilder
) {
this.loader = false;
this.error = false;
this.success = false;
this.providerSubmit = false;
this.error_msg = this.vs.errorList[this.lang];
}
ngOnInit() {
const parm = decodeURIComponent(this.route.snapshot.params['id']);
// tslint:disable-next-line:radix
const id = parseInt(parm);
this.getProvider(id);
console.log(id);
this.providerForm = this.formBuilder.group({
'cr_manager': ['', Validators.compose([Validators.required])],
'contact': ['', Validators.compose([Validators.required])],
'location': ['', Validators.compose([Validators.required])],
'email_id': ['', Validators.compose([Validators.required, Validators.maxLength(50), Validators.pattern(this.emailPattern)])],
// tslint:disable-next-line:max-line-length
'phone': ['', Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(15), Validators.pattern(this.mobnumPattern)])],
'type': [3],
'provider_id': [id]
});
}
getProvider(id: any) {
this.loader = true;
this.funcName = 'providers_details';
const post_data = {'provider_id': id};
this.service.post_data(this.funcName, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.provider = response.responseResult;
this.providerForm.patchValue({
cr_manager: this.provider.cr_manager,
contact: this.provider.contact,
location: this.provider.location,
email_id: this.provider.email_id,
phone: this.provider.phone
});
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000);
}
goToPage(path,data=null){
console.log(data)
goToPage(path, data = null){
console.log(data);
this.router.navigateByUrl(path,{queryParams:data});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
cancelClick() {
this.router.navigate(['/checker/delivery']);
}
editProcess() {
const This = this;
this.error = false;
this.success = false;
console.log(this.providerForm.value);
this.providerSubmit = true;
if (this.providerForm.valid) {
this.loader = true;
const providerObj = this.providerForm.value;
this.funcName = 'provider_edit';
this.service.post_data(this.funcName, providerObj).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
this.providerSubmit = false;
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = false;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
}
console.log('tested');
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Forex Delivery Service Provider</h4>
<h4>Forex Provider</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
......@@ -11,9 +14,17 @@
</header>
<section>
<div class="provider_content">
<h3>Manage Delivery Service Provider</h3>
<h3>Manage Forex Service Provider</h3>
<div class="provider_inner_content">
<div class="table-responsive">
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseMsg}}
</div>
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Forex provider removed successfully
</div>
<table class="table">
<thead>
<tr>
......@@ -25,104 +36,27 @@
<th>Phone</th>
<th>Email ID</th>
<th class="textRight">
<button class="add" (click)="goToPage('checker/addprovider')">+</button>
<button class="add" (click)="goToPage('checker/provider_forex')">+</button>
</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="textRight">
<button class="edit_btn"(click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="textRight">
<button class="edit_btn" (click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="textRight">
<button class="edit_btn" (click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="textRight">
<button class="edit_btn" (click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="textRight">
<button class="edit_btn" (click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="textRight">
<button class="edit_btn" (click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<tbody *ngIf="providerList; else noProvider">
<tr *ngFor="let provider of providerList;">
<td>{{provider.name | titlecase}}</td>
<td>{{provider.location | titlecase}}</td>
<td>{{provider.cr_manager | titlecase}}</td>
<td>{{provider.cr_id}}</td>
<td>{{provider.contact | titlecase}}</td>
<td>{{provider.phone}}</td>
<td>{{provider.email_id}}</td>
<td class="textRight">
<button class="edit_btn" (click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn"></button>
<button class="edit_btn"(click)="editClick(provider.id)"></button>
<button class="delete_btn" (click)="deleteClick(provider.id)"></button>
</td>
</tr>
</tbody>
</table>
<ng-template #noProvider></ng-template>
</div>
</div>
</div>
......
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { WebService } from './../../providers/web.service';
import { ValidationService } from './../../providers/validation.service';
@Component({
selector: 'app-forexprovider',
......@@ -6,10 +9,91 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./forexprovider.component.scss']
})
export class ForexproviderComponent implements OnInit {
providerList: any[];
fname: any;
lang = 'ar';
responseMsg: any;
error: boolean;
success: boolean;
loader: boolean;
constructor() { }
constructor(private router: Router, private route: ActivatedRoute, public vs: ValidationService, public service: WebService) {
this.responseMsg = '';
this.error = false;
this.success = false;
this.loader = false;
}
ngOnInit() {
this.getProvider();
}
getProvider() {
this.loader = true;
this.fname = 'providers';
const post_data = {'type': 2};
this.service.post_data(this.fname, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.providerList = response.responseResult;
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000);
}
reset() {
this.error = false;
this.success = false;
}
deleteClick(provider_id: any) {
this.reset();
const res = confirm('Do you want to remove this user ?');
if (res === true) {
this.loader = true;
this.fname = 'provider_delete';
const post_data = {'provider_id': provider_id};
this.service.post_data(this.fname, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
console.log(this.success);
this.getProvider();
} else {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
}
/* const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000); */
}
editClick(id: number) {
this.router.navigate(['checker/forex_edit/' + id]);
}
goToPage(path, data = null) {
console.log(data);
this.router.navigateByUrl(path, {queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
}
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header">
<div class="row">
<div class="col-md-6">
......@@ -14,7 +17,14 @@
<h3>Manage Delivery Service Provider</h3>
<div class="provider_inner_content">
<div class="table-responsive">
<div class="message" [innerHTML]="responseMsg" *ngIf="responseMsg!=''"></div>
<div class="alert alert-danger alert-dismissible" *ngIf="error">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Warning!</strong> {{responseMsg}}
</div>
<div class="alert alert-success alert-dismissible" *ngIf="success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Delivery provider removed successfully
</div>
<table class="table">
<thead>
<tr>
......@@ -26,7 +36,7 @@
<th>Phone</th>
<th>Email ID</th>
<th class="textRight">
<button class="add" (click)="goToPage('checker/addprovider')">+</button>
<button class="add" (click)="goToPage('checker/provider_delivery')">+</button>
</th>
</tr>
</thead>
......@@ -40,8 +50,8 @@
<td>{{provider.phone}}</td>
<td>{{provider.email_id}}</td>
<td class="textRight">
<button class="edit_btn"(click)="goToPage('checker/editprovider')"></button>
<button class="delete_btn" (click)="deleteClick(provider.users_id)"></button>
<button class="edit_btn"(click)="editClick(provider.id)"></button>
<button class="delete_btn" (click)="deleteClick(provider.id)"></button>
</td>
</tr>
</tbody>
......
......@@ -13,9 +13,15 @@ export class ManageproviderComponent implements OnInit {
fname: any;
lang = 'ar';
responseMsg: any;
error: boolean;
success: boolean;
loader: boolean;
constructor(private router: Router, private route: ActivatedRoute, public vs: ValidationService, public service: WebService) {
this.responseMsg = '';
this.error = false;
this.success = false;
this.loader = false;
}
ngOnInit() {
......@@ -23,17 +29,21 @@ export class ManageproviderComponent implements OnInit {
}
getProvider() {
this.loader = true;
this.fname = 'providers';
const post_data = {'type': 3};
this.service.post_data(this.fname, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.providerList = response.responseResult;
} else {
this.responseMsg = '<small style="color:red;">' + this.vs.errorCode[this.lang][response.errorCode] + '</smal>';
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.responseMsg = '<small style="color:red;">' + this.vs.errorCode[this.lang]['ER08'] + '</smal>';
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
const This = this;
......@@ -48,31 +58,42 @@ export class ManageproviderComponent implements OnInit {
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
reset() {
this.error = false;
this.success = false;
}
deleteClick(provider_id: any) {
this.reset();
const res = confirm('Do you want to remove this user ?');
if (res === true) {
this.loader = true;
this.fname = 'provider_delete';
const post_data = {'provider_id': provider_id};
this.service.post_data(this.fname, post_data).subscribe(response => {
this.loader = false;
console.log(response);
if (response.code === 1) {
this.success = true;
console.log(this.success);
this.getProvider();
this.responseMsg = '<small style="color:green;">' + this.vs.errorCode[this.lang]['ER08'] + '</smal>';
} else {
this.responseMsg = '<small style="color:red;">' + this.vs.errorCode[this.lang][response.errorCode] + '</smal>';
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang][response.errorCode];
}
}, (error) => {
this.responseMsg = '<small style="color:red;">' + this.vs.errorCode[this.lang]['ER08'] + '</smal>';
this.error = true;
this.responseMsg = this.vs.errorCode[this.lang]['ER08'];
});
}
const This = this;
/* const This = this;
setTimeout(function() {
This.responseMsg = '';
}, 3000);
}, 3000); */
}
changePinClick() {
editClick(id: number) {
this.router.navigate(['checker/delivery_edit/' + id]);
}
}
......@@ -21,7 +21,7 @@ const ModuleRoutes: Routes = [
{ path: 'delivery', component: IndexComponent, canActivate: [AuthGuard],
children: [
{ path: 'addprovider', component: AddproviderComponent },
{ path: 'provider', component: AddproviderComponent },
{ path: 'changepin', component: ChangepinComponent },
{ path: 'editprovider', component: EditproviderComponent },
{ path: 'manageprovider', component: ManageproviderComponent},
......
<!-- <div class="custom_loader_wrapper">
<div class="custom_loader_wrapper">
<div class="custom_loader_ring"></div>
</div> -->
</div>
<div class="alert alert-success alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Indicates a successful or positive action.
......
......@@ -19,7 +19,8 @@ export class ValidationService {
'maxLength': 'الحد الأقصى لطول الحروف هو',
'min': 'العمر الأدنى تبدأ في',
'max': 'العمر القصوى في نهاية',
'confirm': 'عدم تطابق كلمة المرور'
'confirm': 'عدم تطابق كلمة المرور',
'pattern': 'نمط غير صالح'
};
this.errorList['en'] = {
'required': 'This field is required',
......@@ -30,7 +31,8 @@ export class ValidationService {
'maxLength': 'Maximum characters length is',
'min': 'Age min start at ',
'max': 'Age max end at ',
'confirm': 'Password mismatch'
'confirm': 'Password mismatch',
'pattern': 'Invalid Pattern'
};
this.errorCode['en'] = {
......
......@@ -30,7 +30,7 @@ export class WebService {
return this.http.post(`${apiConfig + url}`, data).pipe(map((response: any) => response));
}
get_data(url) {
return this.http.get(`${apiConfig + url}`, httpOptions).pipe(map((response: any) => response));
return this.http.get(`${apiConfig + url}`).pipe(map((response: any) => response));
}
setLocalStorageItem(id: string, data: string) {
localStorage.setItem(id, data);
......@@ -54,4 +54,6 @@ export class WebService {
return data;
}
}
}
export const ImageStorage = 'http://forex.nuvento.com/';
// export const ImageStorage = 'http://forex.nuvento.com/';
export const ImageStorage = 'http://localhost:3000/';
export const apiConfig = 'http://localhost:3000/api/';
// export const apiConfig = 'http://forex.nuvento.com/api/';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment