Commit 79689558 by Adarsh K

Merge branch 'adarsh' into 'master'

Adarsh See merge request !3
parents 14924ae9 eb7cd9e8
...@@ -7975,6 +7975,11 @@ ...@@ -7975,6 +7975,11 @@
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
}, },
"rxjs-compat": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/rxjs-compat/-/rxjs-compat-6.4.0.tgz",
"integrity": "sha512-eo/O8RS83hJdJukCtA+IF6qnqa8FPOuVo+OPCzgVi+dbTle9KCdNv97IcQO0WwNVik7DJLKmf0F8uwzc0q40vw=="
},
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
"ngx-bootstrap": "^3.2.0", "ngx-bootstrap": "^3.2.0",
"node-sass": "^4.11.0", "node-sass": "^4.11.0",
"rxjs": "~6.3.3", "rxjs": "~6.3.3",
"rxjs-compat": "^6.4.0",
"tslib": "^1.9.0", "tslib": "^1.9.0",
"zone.js": "~0.8.26" "zone.js": "~0.8.26"
}, },
......
...@@ -4,7 +4,7 @@ import { Routes, RouterModule } from '@angular/router'; ...@@ -4,7 +4,7 @@ import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [ const routes: Routes = [
{ {
path: '', path: '',
redirectTo: 'checker/currency', redirectTo: 'start/login',
pathMatch: 'full' pathMatch: 'full'
} }
]; ];
......
...@@ -2,6 +2,8 @@ import { BrowserModule } from '@angular/platform-browser'; ...@@ -2,6 +2,8 @@ import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
/* CUSTOM-MODULES */ /* CUSTOM-MODULES */
...@@ -12,6 +14,13 @@ import {DeliveryModule} from './delivery/delivery.module'; ...@@ -12,6 +14,13 @@ import {DeliveryModule} from './delivery/delivery.module';
import {StartModule} from './start/start.module'; import {StartModule} from './start/start.module';
/* Custom Services */
import { AuthService } from './providers/auth.service';
import { AuthGuard } from './providers/auth.guard';
import { WebService } from './providers/web.service';
...@@ -26,9 +35,12 @@ import {StartModule} from './start/start.module'; ...@@ -26,9 +35,12 @@ import {StartModule} from './start/start.module';
CheckerModule, CheckerModule,
ForexModule, ForexModule,
DeliveryModule, DeliveryModule,
ReactiveFormsModule,
FormsModule,
HttpClientModule,
StartModule StartModule
], ],
providers: [], providers: [AuthGuard, AuthService, WebService],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }
<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"> <header class="provider_header">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
...@@ -14,33 +18,45 @@ ...@@ -14,33 +18,45 @@
<h3>Add Delivery Provider</h3> <h3>Add Delivery Provider</h3>
<div class="provider_inner_content"> <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="row">
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Provider Name</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Pin</p> <p>Pin</p>
<input class="provider_pin" 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"> <input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" 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"> <input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1"> <input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin m0" placeholder="" type="password" maxlength="1"> <input class="provider_pin m0" placeholder="" type="password" maxlength="1" value="0" readonly>
</div> </div>
</div> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Confirm Pin</p> <p>Confirm Pin</p>
<input class="provider_pin" 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"> <input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" 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"> <input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin" placeholder="" type="password" maxlength="1"> <input class="provider_pin" placeholder="" type="password" maxlength="1" value="0" readonly>
<input class="provider_pin m0" placeholder="" type="password" maxlength="1"> <input class="provider_pin m0" placeholder="" type="password" maxlength="1" value="0" readonly>
</div> </div>
</div> </div>
</div> </div>
...@@ -48,19 +64,28 @@ ...@@ -48,19 +64,28 @@
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Location</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>CR ID</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>CR Manager</p> <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> </div>
</div> </div>
...@@ -68,39 +93,61 @@ ...@@ -68,39 +93,61 @@
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Contact</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Phone</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Email id</p> <p>Email id</p>
<input class="provider_input" placeholder="" type="mail"> <input class="provider_input" placeholder="" type="mail" formControlName="email_id">
</div> </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>
<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="row"> </div>
</div>
<!-- <div class="row">
<div class="col"> <div class="col">
<div class="add_provider_btn_bay p0"> <div class="add_provider_btn_bay p0">
<button class="edit_btn floatRight" (click)="goToPage('checker/editprovider')">Edit</button> <button class="edit_btn floatRight" (click)="goToPage('checker/editprovider')">Edit</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div> </div>
</div> </div> -->
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div class="add_provider_btn_bay"> <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> <button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div> </div>
</div> </div>
</form>
</div> </div>
</div> </div>
</section> </section>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; 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({ @Component({
selector: 'app-addprovider', selector: 'app-addprovider',
...@@ -7,16 +10,93 @@ import { Router,ActivatedRoute } from '@angular/router'; ...@@ -7,16 +10,93 @@ import { Router,ActivatedRoute } from '@angular/router';
styleUrls: ['./addprovider.component.scss'] styleUrls: ['./addprovider.component.scss']
}) })
export class AddproviderComponent implements OnInit { export class AddproviderComponent 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;
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() { 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) console.log(data);
this.router.navigateByUrl(path,{queryParams:data}); this.router.navigateByUrl(path, {queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0; 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']);
}
} }
<div class="login_wrapper">
<div class="container">
<div class="row">
<div class="login_inner">
<img src="assets/images/asset_logo.png">
<hr>
<h6>Change PIN</h6>
<div class="login_inner_content">
<br>
<div class="login_row">
<p>Old PIN</p>
<div class="login_pin">
<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" #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" #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)="cancelClick()">Cancel</button>
</div>
<div class="col-md-6">
<button class="login_btn" (click)="saveClick()">Save</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
.login_wrapper{
width:100%;
.login_inner{
text-align: center;
width:100%;
padding-top:3%;
img{
margin-bottom: 20px;
}
hr{
border:5px solid #f69d1b;
width: 65%;
margin: 0 auto;
}
h6{
border-bottom: 2px solid #b6b6b6;
padding-bottom: 10px;
font-weight: 600;
width: 65%;
padding-top: 3%;
margin: 0 auto;
}
.login_inner_content{
padding-top:35px;
width:325px;
margin: 0 auto;
.login_row{
margin-bottom:0px;
input{
width:100%;
height:50px;
border:none;
font-weight: 600;
font-size: 18px;
border-bottom: 2px solid #636363;
&::placeholder{
color: #454545;
font-weight: 600;
}
&:focus{
outline: none;
}
}
p{
font-weight: 600;
font-size: 18px;
color: #454545;
text-align: left;
margin:0px;
}
.login_pin{
width:100%;
text-align: left;
padding-top: 15px;
padding-bottom: 10%;
.log_pin{
border:1px solid #d8d8d8;
display: inline-block;
width:30px;
border-radius:8px;
color: #cc3d3f;
font-size: 60px !important;
height: 60px;
text-align: center;
margin-right:8.5%;
&::placeholder{
color: #cc3d3f;
font-size:40px !important;
}
}
}
}
}
}
.login_btn_bay{
width: 65%;
margin: 0 auto;
padding-top:5%;
.login_btn{
background: #cd3d3d;
color: #fff;
border-radius:10px;
height:40px;
border:none;
width: 100%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
.cancel_btn{
background: #1a5c7c;
color: #fff;
border-radius:10px;
height:40px;
border:none;
width: 100%;
&:hover{
outline: none;
}
&:focus{
outline:none;
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangepinComponent } from './changepin.component';
describe('ChangepinComponent', () => {
let component: ChangepinComponent;
let fixture: ComponentFixture<ChangepinComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChangepinComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ChangepinComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
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',
templateUrl: './changepin.component.html',
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;
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 { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { moduleRouting } from './checker.routing'; import { moduleRouting } from './checker.routing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
//IMPORTED-PAGE-COMPONENTS //IMPORTED-PAGE-COMPONENTS
...@@ -10,12 +11,22 @@ import { EditproviderComponent } from './editprovider/editprovider.component'; ...@@ -10,12 +11,22 @@ import { EditproviderComponent } from './editprovider/editprovider.component';
import { ManageproviderComponent } from './manageprovider/manageprovider.component'; import { ManageproviderComponent } from './manageprovider/manageprovider.component';
import { HomeComponent } from './home/home.component'; import { HomeComponent } from './home/home.component';
import { CurrencyComponent } from './currency/currency.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({ @NgModule({
declarations: [IndexComponent, AddproviderComponent, EditproviderComponent, ManageproviderComponent, HomeComponent, CurrencyComponent], // tslint:disable-next-line:max-line-length
declarations: [IndexComponent, AddproviderComponent, EditproviderComponent, ManageproviderComponent, HomeComponent, CurrencyComponent, ForexproviderComponent, ChangepinComponent, CurrencyAddComponent, AddforexComponent, EditforexComponent, CurrencyEditComponent, CurrencyListComponent],
imports: [ imports: [
CommonModule, CommonModule,
moduleRouting moduleRouting,
FormsModule,
ReactiveFormsModule
] ]
}) })
export class CheckerModule { } export class CheckerModule { }
...@@ -12,39 +12,35 @@ import { IndexComponent } from './index/index.component'; ...@@ -12,39 +12,35 @@ import { IndexComponent } from './index/index.component';
import { AddproviderComponent} from './addprovider/addprovider.component'; import { AddproviderComponent} from './addprovider/addprovider.component';
import { EditproviderComponent } from './editprovider/editprovider.component'; import { EditproviderComponent } from './editprovider/editprovider.component';
import { ManageproviderComponent } from './manageprovider/manageprovider.component'; import { ManageproviderComponent } from './manageprovider/manageprovider.component';
import { ForexproviderComponent } from './forexprovider/forexprovider.component';
import { HomeComponent } from './home/home.component'; import { HomeComponent } from './home/home.component';
import { CurrencyComponent } from './currency/currency.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 = [ const ModuleRoutes: Routes = [
{ { path: 'checker', component: IndexComponent, canActivate: [AuthGuard],
path: 'checker', children: [
component:IndexComponent, { path: 'provider_delivery', component: AddproviderComponent },
{ path: 'delivery_edit/:id', component: EditproviderComponent },
children:[ { path: 'delivery', component: ManageproviderComponent },
{ { path: 'forex', component: ForexproviderComponent },
path: "addprovider", { path: 'provider_forex', component: AddforexComponent },
component: AddproviderComponent, { path: 'forex_edit/:id', component: EditforexComponent },
}, { path: 'home', component: HomeComponent },
{ { path: 'currency', component: CurrencyComponent },
path: "editprovider", { path: 'changepin', component: ChangepinComponent },
component: EditproviderComponent { path: 'currency_add', component: CurrencyAddComponent},
}, { path: 'currency_edit/:id', component: CurrencyEditComponent},
{ { path: 'currency_list', component: CurrencyListComponent}
path: "manageprovider",
component: ManageproviderComponent
},
{
path: "home",
component: HomeComponent
},
{
path: "currency",
component: CurrencyComponent
}
] ]
} }
]; ];
......
<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"> <header class="provider_header">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
...@@ -13,6 +16,14 @@ ...@@ -13,6 +16,14 @@
<div class="provider_content"> <div class="provider_content">
<h3>Currency & Rates</h3> <h3>Currency & Rates</h3>
<div class="provider_inner_content"> <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="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="row"> <div class="row">
...@@ -23,52 +34,47 @@ ...@@ -23,52 +34,47 @@
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<div class="currency_div"> <div class="currency_div">
<ul> <ul *ngIf="currencyList">
<li>USD</li> <li *ngFor="let currency of avaliableList" (click)="currency_add(currency)">{{currency.name}}</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> </ul>
</div> </div>
</div> </div>
<div class="col-md-4 textCenter"> <div class="col-md-4 textCenter">
<button class="add_btn">Add<img src="assets/images/right.png"></button><br> <button class="add_btn" (click)="currency_push()">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_pop()"><img src="assets/images/left.png">Remove</button>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="currency_div"> <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> </div>
</div> </div>
<div class="col-md-2"></div> <div class="col-md-2"></div>
<div class="col-md-4"> <div class="col-md-4">
<form [formGroup]="currencyForm" novalidate (ngSubmit)="currency_assign()">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<p>Rates</p> <p>Rates</p>
</div> </div>
</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"> <div class="col-md-6">
<h6>USD</h6> <h6>{{selectedList[i].name}}</h6>
<input class="" type="number"> <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>
<div class="col-md-6">
<h6>Pound</h6>
<input class="" type="number">
</div> </div>
</div> </div>
<div class="row"> </div>
<input type="hidden" formControlName="provider_id"/>
<!-- <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<h6>Euro</h6> <h6>Euro</h6>
<input class="" type="number"> <input class="" type="number">
...@@ -77,18 +83,76 @@ ...@@ -77,18 +83,76 @@
<h6>Dirham</h6> <h6>Dirham</h6>
<input class="" type="number"> <input class="" type="number">
</div> </div>
</div> </div> -->
</div>
</div> <div class="row" *ngIf="selectedList.length > 0">
<div class="row">
<div class="col"> <div class="col">
<div class="add_provider_btn_bay"> <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> <button class="cancel_btn floatRight">Cancel</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</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>
</div> </div>
</form> -->
</section> </section>
import { Component, OnInit } from '@angular/core'; 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({ @Component({
selector: 'app-currency', selector: 'app-currency',
templateUrl: './currency.component.html', templateUrl: './currency.component.html',
styleUrls: ['./currency.component.scss'] styleUrls: ['./currency.component.scss']
}) })
export class CurrencyComponent implements OnInit { 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() { ngOnInit() {
this.getCurrency();
const This = this;
setTimeout(function() {
This.getunique(This.currencyList, This.selectedList);
}, 500);
} }
goToPage(path,data=null){ goToPage(path, data = null) {
console.log(data) console.log(data);
this.router.navigateByUrl(path,{queryParams:data}); this.router.navigateByUrl(path, { queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0; 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"> <header class="provider_header">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
...@@ -13,23 +16,36 @@ ...@@ -13,23 +16,36 @@
<div class="provider_content"> <div class="provider_content">
<h3>Edit Delivery Service Provider</h3> <h3>Edit Delivery Service Provider</h3>
<div class="provider_inner_content"> <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="row">
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content" *ngIf="provider">
<p>Provider Name</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Location</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content" *ngIf="provider">
<p>CR ID</p> <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> </div>
</div> </div>
...@@ -37,19 +53,36 @@ ...@@ -37,19 +53,36 @@
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>CR Manager</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Contact</p> <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> </div>
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Phone</p> <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> </div>
</div> </div>
...@@ -57,7 +90,14 @@ ...@@ -57,7 +90,14 @@
<div class="col"> <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p>Email id</p> <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> </div>
<div class="col"> <div class="col">
...@@ -65,22 +105,23 @@ ...@@ -65,22 +105,23 @@
</div> </div>
</div> </div>
<div class="col"> <!-- <div class="col">
<div class="provider_data_content"> <div class="provider_data_content">
<p></p> <p></p>
<div class="edit_delivery">Edit Delivery Driver</div> <div class="edit_delivery">Edit Delivery Driver</div>
</div> </div>
</div> </div> -->
</div> </div>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div class="add_provider_btn_bay"> <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> <button class="cancel_btn floatRight" (click)="cancelClick()">Cancel</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div> </div>
</div> </div>
</form>
</div> </div>
</div> </div>
</section> </section>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; 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({ @Component({
selector: 'app-editprovider', selector: 'app-editprovider',
templateUrl: './editprovider.component.html', templateUrl: './editprovider.component.html',
styleUrls: ['./editprovider.component.scss'] styleUrls: ['./editprovider.component.scss']
}) })
export class EditproviderComponent implements OnInit { 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() { 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){ goToPage(path, data = null){
console.log(data) console.log(data);
this.router.navigateByUrl(path,{queryParams:data}); this.router.navigateByUrl(path,{queryParams:data});
document.body.scrollTop = document.documentElement.scrollTop = 0; 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 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
.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;
}
}
}
table{
thead{
background: #1ca8cb;
tr{
th{
color: #fff;
padding-left: 25px;
font-weight: 500;
.add{
width:30px;
height:30px;
background: #1a5b77;
color: #fff;
border:1px solid #fff;
border-radius: 50%;
font-size: 18px;
cursor: pointer;
&:focus{
outline: none;
}
}
}
}
}
tbody{
tr{
border-bottom: 2px solid #fff;
td{
.edit_btn{
width:25px;
height:25px;
border:none;
background:url('/assets/images/asset_edit.png');
background-position: center;
background-size: 18px;
background-repeat: no-repeat;
margin: 2px;
&:focus{
outline:none;
}
}
.delete_btn{
width:25px;
height:25px;
border:none;
background:url('/assets/images/asset_delete.png');
background-position: center;
background-size: 20px;
background-repeat: no-repeat;
margin: 2px;
&:focus{
outline:none;
}
}
}
&:nth-child(even) {background: #f3f3f3}
&:nth-child(odd) {background: #f9f9f9}
}
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ForexproviderComponent } from './forexprovider.component';
describe('ForexproviderComponent', () => {
let component: ForexproviderComponent;
let fixture: ComponentFixture<ForexproviderComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ForexproviderComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ForexproviderComponent);
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';
@Component({
selector: 'app-forexprovider',
templateUrl: './forexprovider.component.html',
styleUrls: ['./forexprovider.component.scss']
})
export class ForexproviderComponent implements OnInit {
providerList: any[];
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() {
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;
}
}
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
<div class="forex_wrapper"> <div class="forex_wrapper">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="forex_inner"> <div class="forex_inner" (click)="clickForex()">
<img src="assets/images/asset_forex.png"> <img src="assets/images/asset_forex.png">
<h5>Manage Forex Provider</h5> <h5>Manage Forex Provider</h5>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="forex_inner"> <div class="forex_inner" (click)="clickDelivery()">
<img src="assets/images/asset_manage.png"> <img src="assets/images/asset_manage.png">
<h5>Manage Delivery Provider</h5> <h5>Manage Delivery Provider</h5>
</div> </div>
......
...@@ -8,13 +8,21 @@ import { Router,ActivatedRoute } from '@angular/router'; ...@@ -8,13 +8,21 @@ import { Router,ActivatedRoute } from '@angular/router';
}) })
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
constructor(private router: Router,private route: ActivatedRoute) { } constructor(private router: Router, private route: ActivatedRoute) { }
ngOnInit() { ngOnInit() {
} }
goToPage(path,data=null){ goToPage(path: any, data = null) {
console.log(data) console.log(data);
this.router.navigateByUrl(path,{queryParams:data}); this.router.navigateByUrl(path, {queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
} }
clickForex() {
this.router.navigate(['/checker/forex']);
}
clickDelivery() {
this.router.navigate(['/checker/delivery']);
}
} }
<div class="custom_loader_wrapper" *ngIf="loader">
<div class="custom_loader_ring"></div>
</div>
<header class="provider_header"> <header class="provider_header">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
...@@ -14,6 +17,14 @@ ...@@ -14,6 +17,14 @@
<h3>Manage Delivery Service Provider</h3> <h3>Manage Delivery Service Provider</h3>
<div class="provider_inner_content"> <div class="provider_inner_content">
<div class="table-responsive"> <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> Delivery provider removed successfully
</div>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
...@@ -25,104 +36,27 @@ ...@@ -25,104 +36,27 @@
<th>Phone</th> <th>Phone</th>
<th>Email ID</th> <th>Email ID</th>
<th class="textRight"> <th class="textRight">
<button class="add" (click)="goToPage('checker/addprovider')">+</button> <button class="add" (click)="goToPage('checker/provider_delivery')">+</button>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="providerList; else noProvider">
<tr> <tr *ngFor="let provider of providerList;">
<td></td> <td>{{provider.name | titlecase}}</td>
<td></td> <td>{{provider.location | titlecase}}</td>
<td></td> <td>{{provider.cr_manager | titlecase}}</td>
<td></td> <td>{{provider.cr_id}}</td>
<td></td> <td>{{provider.contact | titlecase}}</td>
<td></td> <td>{{provider.phone}}</td>
<td></td> <td>{{provider.email_id}}</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>
<td class="textRight"> <td class="textRight">
<button class="edit_btn" (click)="goToPage('checker/editprovider')"></button> <button class="edit_btn"(click)="editClick(provider.id)"></button>
<button class="delete_btn"></button> <button class="delete_btn" (click)="deleteClick(provider.id)"></button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<ng-template #noProvider></ng-template>
</div> </div>
</div> </div>
</div> </div>
......
import { Component, OnInit } from '@angular/core'; 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';
@Component({ @Component({
selector: 'app-manageprovider', selector: 'app-manageprovider',
...@@ -7,17 +9,91 @@ import { Router,ActivatedRoute } from '@angular/router'; ...@@ -7,17 +9,91 @@ import { Router,ActivatedRoute } from '@angular/router';
styleUrls: ['./manageprovider.component.scss'] styleUrls: ['./manageprovider.component.scss']
}) })
export class ManageproviderComponent implements OnInit { export class ManageproviderComponent implements OnInit {
providerList: any[];
fname: any;
lang = 'ar';
responseMsg: any;
error: boolean;
success: boolean;
loader: boolean;
constructor(private router: Router,private route: ActivatedRoute) { } 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() { ngOnInit() {
this.getProvider();
}
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.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){ goToPage(path, data = null) {
console.log(data) console.log(data);
this.router.navigateByUrl(path,{queryParams:data}); this.router.navigateByUrl(path, {queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0; 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();
} 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/delivery_edit/' + id]);
}
} }
...@@ -9,9 +9,10 @@ import { AddproviderComponent } from './addprovider/addprovider.component'; ...@@ -9,9 +9,10 @@ import { AddproviderComponent } from './addprovider/addprovider.component';
import { ChangepinComponent } from './changepin/changepin.component'; import { ChangepinComponent } from './changepin/changepin.component';
import { EditproviderComponent } from './editprovider/editprovider.component'; import { EditproviderComponent } from './editprovider/editprovider.component';
import { ManageproviderComponent } from './manageprovider/manageprovider.component'; import { ManageproviderComponent } from './manageprovider/manageprovider.component';
import { TransactionComponent } from './transaction/transaction.component';
@NgModule({ @NgModule({
declarations: [IndexComponent, AddproviderComponent, ChangepinComponent, EditproviderComponent, ManageproviderComponent], declarations: [IndexComponent, AddproviderComponent, ChangepinComponent, EditproviderComponent, ManageproviderComponent, TransactionComponent],
imports: [ imports: [
CommonModule, CommonModule,
moduleRouting moduleRouting
......
...@@ -13,33 +13,20 @@ import { AddproviderComponent} from './addprovider/addprovider.component'; ...@@ -13,33 +13,20 @@ import { AddproviderComponent} from './addprovider/addprovider.component';
import { ChangepinComponent } from './changepin/changepin.component'; import { ChangepinComponent } from './changepin/changepin.component';
import { EditproviderComponent } from './editprovider/editprovider.component'; import { EditproviderComponent } from './editprovider/editprovider.component';
import { ManageproviderComponent } from './manageprovider/manageprovider.component'; import { ManageproviderComponent } from './manageprovider/manageprovider.component';
import { TransactionComponent } from './transaction/transaction.component';
import { AuthGuard } from './../providers/auth.guard';
const ModuleRoutes: Routes = [ const ModuleRoutes: Routes = [
{ { path: 'delivery', component: IndexComponent, canActivate: [AuthGuard],
path: 'delivery', children: [
component:IndexComponent, { path: 'provider', component: AddproviderComponent },
{ path: 'changepin', component: ChangepinComponent },
children:[ { path: 'editprovider', component: EditproviderComponent },
{ { path: 'manageprovider', component: ManageproviderComponent},
path: "addprovider", {path: '', component: TransactionComponent}
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 class="custom_loader_ring"></div>
</div> --> </div>
<div class="alert alert-success alert-dismissible"> <div class="alert alert-success alert-dismissible">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Indicates a successful or positive action. <strong>Success!</strong> Indicates a successful or positive action.
......
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Delivery Transaction List</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
<span (click)="goToPage('forex/changepin')">Change PIN</span>
</div>
</div>
</header>
<section>
<div class="provider_content">
<h3>Manage Transaction</h3>
<div class="provider_inner_content">
<div class="table-responsive">
<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('forex/addprovider')">+</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('forex/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('forex/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('forex/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('forex/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('forex/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('forex/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('forex/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
</tbody>
</table>
</div>
</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;
}
}
}
table{
thead{
background: #1ca8cb;
tr{
th{
color: #fff;
padding-left: 25px;
font-weight: 500;
.add{
width:30px;
height:30px;
background: #1a5b77;
color: #fff;
border:1px solid #fff;
border-radius: 50%;
font-size: 18px;
cursor: pointer;
&:focus{
outline: none;
}
}
}
}
}
tbody{
tr{
border-bottom: 2px solid #fff;
td{
.edit_btn{
width:25px;
height:25px;
border:none;
background:url('/assets/images/asset_edit.png');
background-position: center;
background-size: 18px;
background-repeat: no-repeat;
margin: 2px;
&:focus{
outline:none;
}
}
.delete_btn{
width:25px;
height:25px;
border:none;
background:url('/assets/images/asset_delete.png');
background-position: center;
background-size: 20px;
background-repeat: no-repeat;
margin: 2px;
&:focus{
outline:none;
}
}
}
&:nth-child(even) {background: #f3f3f3}
&:nth-child(odd) {background: #f9f9f9}
}
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TransactionComponent } from './transaction.component';
describe('TransactionComponent', () => {
let component: TransactionComponent;
let fixture: ComponentFixture<TransactionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TransactionComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TransactionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-transaction',
templateUrl: './transaction.component.html',
styleUrls: ['./transaction.component.scss']
})
export class TransactionComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
...@@ -9,10 +9,11 @@ import { AddproviderComponent} from './addprovider/addprovider.component'; ...@@ -9,10 +9,11 @@ import { AddproviderComponent} from './addprovider/addprovider.component';
import { ChangepinComponent } from './changepin/changepin.component'; import { ChangepinComponent } from './changepin/changepin.component';
import { EditproviderComponent } from './editprovider/editprovider.component'; import { EditproviderComponent } from './editprovider/editprovider.component';
import { ManageproviderComponent } from './manageprovider/manageprovider.component'; import { ManageproviderComponent } from './manageprovider/manageprovider.component';
import { TransactionComponent } from './transaction/transaction.component';
@NgModule({ @NgModule({
declarations: [IndexComponent, AddproviderComponent, ChangepinComponent, EditproviderComponent, ManageproviderComponent], declarations: [IndexComponent, AddproviderComponent, ChangepinComponent, EditproviderComponent, ManageproviderComponent, TransactionComponent],
imports: [ imports: [
CommonModule, CommonModule,
moduleRouting moduleRouting
......
...@@ -13,33 +13,18 @@ import { AddproviderComponent} from './addprovider/addprovider.component'; ...@@ -13,33 +13,18 @@ import { AddproviderComponent} from './addprovider/addprovider.component';
import { ChangepinComponent } from './changepin/changepin.component'; import { ChangepinComponent } from './changepin/changepin.component';
import { EditproviderComponent } from './editprovider/editprovider.component'; import { EditproviderComponent } from './editprovider/editprovider.component';
import { ManageproviderComponent } from './manageprovider/manageprovider.component'; import { ManageproviderComponent } from './manageprovider/manageprovider.component';
import { TransactionComponent } from './transaction/transaction.component';
import { AuthGuard } from './../providers/auth.guard';
const ModuleRoutes: Routes = [
const ModuleRoutes: Routes = [{
{ path: 'forex', component: IndexComponent, canActivate: [AuthGuard],
path: 'forex', children: [
component:IndexComponent, {path: 'addprovider', component: AddproviderComponent},
{path: 'changepin', component: ChangepinComponent},
children:[ {path: 'editprovider', component: EditproviderComponent},
{ {path: 'manageprovider', component: ManageproviderComponent },
path: "addprovider", {path: '', component: TransactionComponent }
component: AddproviderComponent,
},
{
path: "changepin",
component: ChangepinComponent,
},
{
path: "editprovider",
component: EditproviderComponent
},
{
path: "manageprovider",
component: ManageproviderComponent
}
] ]
} }
]; ];
......
<header class="provider_header">
<div class="row">
<div class="col-md-6">
<h4>Forex Transaction List</h4>
</div>
<div class="col-md-6 textRight relative">
<img src="assets/images/asset_logo1.png">
<span (click)="goToPage('forex/changepin')">Change PIN</span>
</div>
</div>
</header>
<section>
<div class="provider_content">
<h3>Manage Transaction</h3>
<div class="provider_inner_content">
<div class="table-responsive">
<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('forex/addprovider')">+</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('forex/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('forex/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('forex/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('forex/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('forex/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('forex/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('forex/editprovider')"></button>
<button class="delete_btn"></button>
</td>
</tr>
</tbody>
</table>
</div>
</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;
}
}
}
table{
thead{
background: #1ca8cb;
tr{
th{
color: #fff;
padding-left: 25px;
font-weight: 500;
.add{
width:30px;
height:30px;
background: #1a5b77;
color: #fff;
border:1px solid #fff;
border-radius: 50%;
font-size: 18px;
cursor: pointer;
&:focus{
outline: none;
}
}
}
}
}
tbody{
tr{
border-bottom: 2px solid #fff;
td{
.edit_btn{
width:25px;
height:25px;
border:none;
background:url('/assets/images/asset_edit.png');
background-position: center;
background-size: 18px;
background-repeat: no-repeat;
margin: 2px;
&:focus{
outline:none;
}
}
.delete_btn{
width:25px;
height:25px;
border:none;
background:url('/assets/images/asset_delete.png');
background-position: center;
background-size: 20px;
background-repeat: no-repeat;
margin: 2px;
&:focus{
outline:none;
}
}
}
&:nth-child(even) {background: #f3f3f3}
&:nth-child(odd) {background: #f9f9f9}
}
}
}
}
}
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TransactionComponent } from './transaction.component';
describe('TransactionComponent', () => {
let component: TransactionComponent;
let fixture: ComponentFixture<TransactionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TransactionComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TransactionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-transaction',
templateUrl: './transaction.component.html',
styleUrls: ['./transaction.component.scss']
})
export class TransactionComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthService } from './auth.service';
import {Router} from '@angular/router';
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(private auth: AuthService, private myRoute: Router) {
}
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
if (this.auth.isLoggednIn()) {
return true;
} else {
this.myRoute.navigate(['/start/login']);
return false;
}
}
}
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
@Injectable({
providedIn: 'root'
})
export class AuthService {
constructor(private myRoute: Router) { }
sendToken(token: string) {
localStorage.setItem('LoggedInUser', token);
}
getToken() {
return localStorage.getItem('userData');
}
isLoggednIn() {
return this.getToken() !== null;
}
logout() {
localStorage.removeItem('userData');
this.myRoute.navigate(['/start/login']);
}
}
import { Injectable } from '@angular/core';
import { observable, Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable({
providedIn: 'root'
})
export class SubjectService {
private loginDetails = new BehaviorSubject<any>(null);
private isLoggined = new BehaviorSubject<any>(null);
sendLoginData(loginData: any) {
this.loginDetails.next(loginData);
}
getLoginData(): Observable<any> {
return this.loginDetails.asObservable();
}
sendisLoggined(isLoggined: any) {
this.isLoggined.next(isLoggined);
}
getisLoggined(): Observable<any> {
return this.isLoggined.asObservable();
}
}
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ValidationService {
errorList: any[];
errorCode: any[];
constructor() {
this.errorList = [];
this.errorCode = [];
this.errorList['ar'] = {
'required': 'هذه الخانة مطلوبه',
'email': 'يرجى إدخال البريد الإلكتروني الصحيح',
'phone': 'يرجى إدخال رقم هاتف صالح',
'password': 'الرجاء إدخال كلمة السر الصحيحة',
'minLength': 'الحد الأدنى لطول الحروف هو',
'maxLength': 'الحد الأقصى لطول الحروف هو',
'min': 'العمر الأدنى تبدأ في',
'max': 'العمر القصوى في نهاية',
'confirm': 'عدم تطابق كلمة المرور',
'pattern': 'نمط غير صالح'
};
this.errorList['en'] = {
'required': 'This field is required',
'email': 'Please enter a valid email',
'phone': 'Please enter a valid phone number',
'password': 'Please enter a valid password',
'minLength': 'Minimum characters length is',
'maxLength': 'Maximum characters length is',
'min': 'Age min start at ',
'max': 'Age max end at ',
'confirm': 'Password mismatch',
'pattern': 'Invalid Pattern'
};
this.errorCode['en'] = {
'ER01': 'Authentication Failed',
'ER02': 'Email ID is null or empty',
'ER03': 'Invalid Email ID',
'ER04': 'Password is null or empty',
'ER05': 'Invalid Username / Password',
'ER06': 'Invalid userType',
'ER07': 'No record found',
'ER08': 'Something went wrong',
'ER09': 'Email and Phone are already exists',
'ER10': 'Phone no is null or empty',
'ER11': 'Invalid Phone no',
'ER12': 'Name no is required',
'ER13': 'Location no is required',
'ER14': 'Contact no is required',
'ER15': 'CR Id is required',
'ER16': 'CR Manager is required',
'ER17': 'Provider Id is missing',
'ER18': 'New Password is missing',
'ER19': 'User Id is missing',
'ER20': 'Wrong password',
'ER21': 'Email is already exists',
'ER22': 'Phone is already exists',
'ER23': 'OTP is missing',
'ER24': 'Invalid OTP',
'ER25': 'No Currency found',
'ER26': 'Currency name is missing',
'ER27': 'Currency symbol is missing',
'ER28': 'Currency image Id is missing',
'ER29': 'Currency rate is missing',
'ER30': 'Currency id is missing',
'ER31': 'Amount field is missing',
'ER32': 'SAR amount is missing',
'ER33': 'User information is required',
'ER34': 'User id is missing',
'ER35': 'QR code is required',
'ER36': 'No transactions found',
'ER37': 'Transaction id is missing',
'ER38': 'Driver id is missing',
'ER39': 'Status is required',
'ER40': 'Currency Flag is missing',
'ER41': 'Minimum amount is missing',
'ER42': 'Unknown user found'
};
this.errorCode['ar'] = {
'ER01': 'المصادقة فشلت',
'ER02': 'معرف البريد الإلكتروني فارغ أو فارغ',
'ER03': 'معرف البريد الإلكتروني غير صالح',
'ER04': 'كلمة المرور فارغة أو فارغة',
'ER05': 'اسم المتسخدم / كلمة المرور غير صحيحة',
'ER06': 'نوع المستخدم غير صالح',
'ER07': 'لا يوجد سجلات',
'ER08': 'هناك خطأ ما',
'ER09': 'البريد الإلكتروني والهاتف موجودان بالفعل',
'ER10': 'رقم الهاتف فارغ أو فارغ',
'ER11': 'رقم الهاتف غير صالح',
'ER12': 'الاسم غير مطلوب',
'ER13': 'الموقع لا مطلوب',
'ER14': 'لا الاتصال مطلوب',
'ER15': 'معرف CR مطلوب',
'ER16': 'مطلوب CR مدير',
'ER17': 'معرف الموفر مفقود',
'ER18': 'كلمة المرور الجديدة مفقودة',
'ER19': 'معرف المستخدم مفقود',
'ER20': 'كلمة مرور خاطئة',
'ER21': 'البريد الإلكتروني موجود بالفعل',
'ER22': 'الهاتف موجود بالفعل',
'ER23': 'OTP مفقود',
'ER24': 'غير صالح OTP',
'ER25': 'لا توجد عملة',
'ER26': 'اسم العملة مفقود',
'ER27': 'رمز العملة مفقود',
'ER28': 'رقم تعريف صورة العملة مفقود',
'ER29': 'سعر العملة مفقود',
'ER30': 'معرف العملة مفقود',
'ER31': 'حقل المبلغ مفقود',
'ER32': 'مبلغ SAR مفقود',
'ER33': 'معلومات المستخدم مطلوبة',
'ER34': 'معرف المستخدم مفقود',
'ER35': 'مطلوب رمز الاستجابة السريعة',
'ER36': 'لم يتم العثور على أي معاملات',
'ER37': 'معرف المعاملة مفقود',
'ER38': 'معرف السائق مفقود',
'ER39': 'الحالة مطلوبة',
'ER40': 'علم العملة مفقود',
'ER41': 'الحد الأدنى للمبلغ مفقود',
'ER42': 'تم العثور على مستخدم غير معروف'
};
}
getErrorList() {
return this.errorList;
}
getError(error: any): string {
if (this.errorList.hasOwnProperty(error.code)) { // check whether the error code having our definition
return this.errorList[error.code]; // return our definition
} else {
return error.message;
}
}
}
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { map, catchError } from 'rxjs/operators';
import { apiConfig } from '../../environments/server.config';
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Auth': 'my_key'
})
};
const httplive = {
headers: new HttpHeaders({
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
})
};
@Injectable({
providedIn: 'root'
})
export class WebService {
constructor(private http: HttpClient) {
}
post_data(url: string, data) {
return this.http.post(`${apiConfig + url}`, data).pipe(map((response: any) => response));
}
get_data(url) {
return this.http.get(`${apiConfig + url}`).pipe(map((response: any) => response));
}
setLocalStorageItem(id: string, data: string) {
localStorage.setItem(id, data);
}
getLocalStorageItem(data: string): string {
return localStorage.getItem(data);
}
removeLocalStorageItem(data) {
localStorage.removeItem(data);
localStorage.clear();
}
ObjArray(data: any) {
if (data instanceof Array !== true) {
if (data !== undefined) {
return new Array(data);
} else {
return undefined;
}
} else {
return data;
}
}
}
...@@ -6,27 +6,36 @@ ...@@ -6,27 +6,36 @@
<hr> <hr>
<div class="login_inner_content"> <div class="login_inner_content">
<div class="login_row"> <div class="login_row">
<input class="" placeholder="Email Address"> <input type="email" class="" placeholder="Email Address" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" required #email_id="ngModel" id="email_id" [(ngModel)]="model.email_id">
<div class="md-errors-spacer" [hidden]="email_id.valid || email_id.untouched">
<div class="s_error" *ngIf="email_id.errors && email_id.errors.required">
<div class="s_validation">{{error_msg.required}} </div>
</div>
<div class="s_error" *ngIf="email_id.errors && email_id.errors.pattern">
<div class="s_validation">{{error_msg.email}} </div>
</div>
</div>
<div class="s_error" *ngIf="model.email_id=='' && loginSubmit && email_id.untouched">
<div class="s_validation">{{error_msg.required}} </div>
</div>
</div> </div>
<div class="login_row"> <div class="login_row">
<p>Enter Your 6-Digit PIN</p> <p>Enter Your 6-Digit PIN</p>
<div class="login_pin"> <div class="login_pin">
<input class="log_pin" type="password" maxlength="1" value="0"> <input class="log_pin" type="password" maxlength="1" #focus1 (keyup)="processKeyUp($event, focus2)">
<input class="log_pin" type="password" maxlength="1" value="0"> <input class="log_pin" type="password" maxlength="1" #focus2 (keydown.backspace)="processBack($event, focus1)" (keyup)="processKeyUp($event, focus3)">
<input class="log_pin" type="password" maxlength="1" value="0"> <input class="log_pin" type="password" maxlength="1" #focus3 (keydown.backspace)="processBack($event, focus2)" (keyup)="processKeyUp($event, focus4)">
<input class="log_pin" type="password" maxlength="1" value="0"> <input class="log_pin" type="password" maxlength="1" #focus4 (keydown.backspace)="processBack($event, focus3)" (keyup)="processKeyUp($event, focus5)">
<input class="log_pin" type="password" maxlength="1" value="0"> <input class="log_pin" type="password" maxlength="1" #focus5 (keydown.backspace)="processBack($event, focus4)" (keyup)="processKeyUp($event, focus6)">
<input class="log_pin m0" type="password" maxlength="1" value="0"> <input class="log_pin m0" type="password" maxlength="1" #focus6 (keydown.backspace)="processBack($event, focus5)">
<!-- <input class="log_pin" placeholder="*" type="password" maxlength="1"> </div>
<input class="log_pin" placeholder="*" type="password" maxlength="1"> <div class="s_error" *ngIf="passwordErr">
<input class="log_pin" placeholder="*" type="password" maxlength="1"> <div class="s_validation">{{error_msg.password}} </div>
<input class="log_pin" placeholder="*" type="password" maxlength="1">
<input class="log_pin" placeholder="*" type="password" maxlength="1">
<input class="log_pin" placeholder="*" type="password" maxlength="1"> -->
</div> </div>
</div> </div>
<div *ngIf="loginError" class="s_validation">{{loginMsg}}</div>
<div class="login_row"> <div class="login_row">
<button class="login_btn" (click)="goToPage('forex/addprovider')">Login</button> <button class="login_btn" (click)="loginClick()">Login</button>
</div> </div>
<div class="login_row"> <div class="login_row">
<h6 (click)="goToPage('start/forgot')">Forgot Password</h6> <h6 (click)="goToPage('start/forgot')">Forgot Password</h6>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { Router,ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { ValidationService } from './../../providers/validation.service';
import { SubjectService } from './../../providers/subject.service';
import { WebService } from './../../providers/web.service';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
templateUrl: './login.component.html', templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'] styleUrls: ['./login.component.scss']
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
@ViewChild('focus1') focus1: ElementRef;
@ViewChild('focus2') focus2: ElementRef;
@ViewChild('focus3') focus3: ElementRef;
@ViewChild('focus4') focus4: ElementRef;
@ViewChild('focus5') focus5: ElementRef;
@ViewChild('focus6') focus6: ElementRef;
error_msg: any[];
lang = 'ar';
model: any;
passwordErr: boolean;
password: any;
fname: any;
loginSubmit: boolean;
loginError: boolean;
loginMsg: any;
loginDetails: any;
constructor(
private router: Router,
private route: ActivatedRoute,
public vs: ValidationService,
public service: WebService,
public subjectService: SubjectService
) {
this.error_msg = this.vs.errorList[this.lang];
this.passwordErr = false;
this.loginSubmit = false;
this.loginError = false;
this.subjectService.getLoginData().subscribe(loginData => {
this.loginDetails = JSON.parse(this.service.getLocalStorageItem('userData'));
if (this.loginDetails) {
if (this.loginDetails.user_type === 1) {
this.router.navigate(['checker/home']);
} else if (this.loginDetails.user_type === 2) {
this.router.navigate(['forex']);
} else if (this.loginDetails.user_type === 3) {
this.router.navigate(['delivery']);
} else {
}
}
});
constructor(private router: Router,private route: ActivatedRoute) { } /* this.subjectService.getisLoggined().subscribe(isLoggined => {
console.log(isLoggined);
if (isLoggined != null) {
if (isLoggined === 'not_loggedIn') {
this.router.navigate(['/start/login']);
}
}
}); */
}
ngOnInit() { ngOnInit() {
this.model = {'email_id': '', 'password': ''};
} }
goToPage(path,data=null){ goToPage(path: any, data = null) {
console.log(data) console.log(data);
this.router.navigateByUrl(path,{queryParams:data}); this.router.navigateByUrl(path, {queryParams: data});
document.body.scrollTop = document.documentElement.scrollTop = 0; document.body.scrollTop = document.documentElement.scrollTop = 0;
} }
processKeyUp(e: any, el: any) {
console.log(e.keyCode);
if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) {
el.focus();
} else {
if (e.keyCode !== 8) {
e.target.value = '';
}
}
}
processBack (e: any, el: any) {
console.log(e);
if (e.keyCode === 8) {
e.target.value = '';
el.focus();
}
}
loginClick() {
this.loginSubmit = true;
this.passwordErr = false;
this.loginError = false;
const password = [];
password[0] = this.focus1.nativeElement.value;
password[1] = this.focus2.nativeElement.value;
password[2] = this.focus3.nativeElement.value;
password[3] = this.focus4.nativeElement.value;
password[4] = this.focus5.nativeElement.value;
password[5] = this.focus6.nativeElement.value;
const pass = password.join('');
if (this.model.email_id === '') {
if (pass === '') {
this.passwordErr = true;
}
return false;
}
for (const i in password) {
if (password[i] === '') {
this.passwordErr = true;
return false;
}
}
this.fname = 'admin_login';
const post_data = {'email_id': this.model.email_id, 'password': pass};
this.service.post_data(this.fname, post_data).subscribe(response => {
console.log(response);
if (response.code === 1) {
const responseData = response.responseResult;
this.service.setLocalStorageItem('userData', JSON.stringify(response.responseResult));
this.subjectService.sendLoginData('logged_in');
if (responseData.user_type === 1) {
this.router.navigate(['checker/home']);
} else if (responseData.user_type === 2) {
this.router.navigate(['forex']);
} else if (responseData.user_type === 3) {
this.router.navigate(['delivery']);
} else {
this.loginError = true;
this.loginMsg = this.vs.errorCode['ER42'];
}
} else {
this.loginError = true;
this.loginMsg = this.vs.errorCode[this.lang][response.errorCode];
console.log(this.loginMsg);
}
}, (error) => {
this.loginError = true;
this.loginMsg = this.vs.errorCode[this.lang]['ER08'];
console.log(this.loginMsg);
});
}
} }
...@@ -5,12 +5,15 @@ import { LoginComponent } from './login/login.component'; ...@@ -5,12 +5,15 @@ import { LoginComponent } from './login/login.component';
import { ForgotComponent } from './forgot/forgot.component'; import { ForgotComponent } from './forgot/forgot.component';
import { moduleRouting } from './start.routing'; import { moduleRouting } from './start.routing';
import { NewpinComponent } from './newpin/newpin.component'; import { NewpinComponent } from './newpin/newpin.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({ @NgModule({
declarations: [IndexComponent, LoginComponent, ForgotComponent, NewpinComponent], declarations: [IndexComponent, LoginComponent, ForgotComponent, NewpinComponent],
imports: [ imports: [
CommonModule, CommonModule,
moduleRouting moduleRouting,
ReactiveFormsModule,
FormsModule,
] ]
}) })
export class StartModule { } export class StartModule { }
...@@ -18,12 +18,10 @@ import { NewpinComponent } from './newpin/newpin.component'; ...@@ -18,12 +18,10 @@ import { NewpinComponent } from './newpin/newpin.component';
const ModuleRoutes: Routes = [ const ModuleRoutes: Routes = [
{ {
path: 'start', path: 'start',
component:IndexComponent, component: IndexComponent,
children: [
children:[
{ {
path: "login", path: "login",
component: LoginComponent, component: LoginComponent,
...@@ -37,7 +35,6 @@ const ModuleRoutes: Routes = [ ...@@ -37,7 +35,6 @@ const ModuleRoutes: Routes = [
component: NewpinComponent, component: NewpinComponent,
} }
] ]
} }
]; ];
......
// 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