diff --git a/ng6-seed/package-lock.json b/ng6-seed/package-lock.json
index fd852ba76..91fb0fa6a 100755
--- a/ng6-seed/package-lock.json
+++ b/ng6-seed/package-lock.json
@@ -692,9 +692,9 @@
}
},
"@angular/fire": {
- "version": "5.3.0",
- "resolved": "https://registry.npmjs.org/@angular/fire/-/fire-5.3.0.tgz",
- "integrity": "sha512-Z/dywnrQiuz6Hfq0MncDvwB0obirWdCetrd//OkHsWKLKi1deFrb6ChuTBTGj+kN/cjHUEwI9pD4uoDvU7jyAg=="
+ "version": "5.4.0",
+ "resolved": "https://registry.npmjs.org/@angular/fire/-/fire-5.4.0.tgz",
+ "integrity": "sha512-067oatMtDbNKEWNdZoMWqKOzPpp0r8XZvpL1bcH6PO+q62ceJ2ig46ne1UqJP2nHRyXNAtIyJp7VhVoG4gRPiA=="
},
"@angular/flex-layout": {
"version": "6.0.0-beta.18",
diff --git a/ng6-seed/package.json b/ng6-seed/package.json
index d5bf40831..2713e1e27 100755
--- a/ng6-seed/package.json
+++ b/ng6-seed/package.json
@@ -20,7 +20,7 @@
"@angular/common": "^6.1.10",
"@angular/compiler": "^6.1.10",
"@angular/core": "^6.1.10",
- "@angular/fire": "^5.3.0",
+ "@angular/fire": "^5.4.0",
"@angular/flex-layout": "^6.0.0-beta.18",
"@angular/forms": "^6.1.10",
"@angular/http": "^6.0.0-rc.6",
diff --git a/ng6-seed/src/app/app.component.ts b/ng6-seed/src/app/app.component.ts
index dd3403763..0c930c6d7 100755
--- a/ng6-seed/src/app/app.component.ts
+++ b/ng6-seed/src/app/app.component.ts
@@ -5,6 +5,7 @@ import { AwsService } from './AwsService/aws.service';
import { DashboardService } from './dashboard/dashboard.service';
import 'rxjs/add/observable/interval';
import { Observable,interval, Subscription } from 'rxjs';
+import { PushNotifyService } from './shared/push-notify.service';
@Component({
selector: 'app-root',
@@ -16,7 +17,7 @@ export class AppComponent {
// public timer
constructor(translate: TranslateService,
private messagingService: MessagingService,
- public aws: AwsService,private dashBoardService:DashboardService) {
+ public aws: AwsService,private dashBoardService:DashboardService,private pushNotify:PushNotifyService) {
translate.addLangs(['en', 'fr']);
translate.setDefaultLang('en');
@@ -30,6 +31,7 @@ export class AppComponent {
this.messagingService.receiveMessage()
this.message = this.messagingService.currentMessage
// this.alertForTAT()
+ this.pushNotify.requestPermission();
}
// alertForTAT(){
diff --git a/ng6-seed/src/app/layouts/admin/admin-layout.component.ts b/ng6-seed/src/app/layouts/admin/admin-layout.component.ts
index b2c6f805c..6c06c0086 100755
--- a/ng6-seed/src/app/layouts/admin/admin-layout.component.ts
+++ b/ng6-seed/src/app/layouts/admin/admin-layout.component.ts
@@ -14,6 +14,7 @@ import { DashboardService } from '../../dashboard/dashboard.service';
import { AwsService } from '../../AwsService/aws.service';
import { RoleMenuItemsPipe } from './../role-menu-items.pipe';
import 'rxjs/add/observable/interval';
+import { MessagingService } from 'app/shared/messaging.service';
@@ -59,7 +60,7 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
alertTAT: any;
countTAT: number;
- constructor(private router: Router, public menuItems: MenuItems, public horizontalMenuItems : HorizontalMenuItems, public translate: TranslateService,public aws:AwsService,public users:UserService,private _dashboardService: DashboardService) {
+ constructor(private router: Router, public menuItems: MenuItems, public horizontalMenuItems : HorizontalMenuItems, public translate: TranslateService,public aws:AwsService,public users:UserService,private _dashboardService: DashboardService,private messagingService:MessagingService) {
const browserLang: string = translate.getBrowserLang();
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
@@ -292,7 +293,10 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
this.aws.logout().subscribe(res=>{
//alert("res");
localStorage.removeItem('user_role');
+ this.messagingService.unsubscribeNotification()
+ setTimeout(()=>{
this.router.navigate(['/authentication/login']);
+ })
})
}
menunav(active){
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html
index b452c903f..fb7efd380 100755
--- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html
+++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.html
@@ -518,6 +518,256 @@
+
+ Turnover validated during PD
+
+
+
+ Yes
+ No
+
+ Is Turnover validated is required
+
+
+
+
+
+
+ Select
+ {{val.name}}
+
+ How was the Turnover validated is required
+
+
+
+
+
+
+
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts
index f1c0c8d00..38b13f46e 100755
--- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts
+++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts
@@ -31,6 +31,7 @@ import { ImageCropComponent } from '../dialogue/image-crop/image-crop.component'
styleUrls: ['./financial-info.component.scss']
})
export class FinancialInfoComponent implements OnInit {
+
customer_segment_abbr: any;
subproduct_abbr: any;
product_abbr: any;
@@ -85,6 +86,20 @@ export class FinancialInfoComponent implements OnInit {
documentsAndFilesList: any = [];
image_doc_params: { pdid: string; form_id: number; company_id: string; };
prod_catagory: any;
+ turnover_validate_list:any=[{
+ id:2,
+ name:'Validated from Bills/Records'
+ },{
+ id:3,
+ name:'Validated from Business activities seen'
+ },{
+ id:4,
+ name:'Validated from Stock/Inventory seen'
+ },{
+ id:1,
+ name:'Others'
+ },
+]
constructor(notifier: NotifierService,
private fb: FormBuilder,
@@ -148,6 +163,13 @@ export class FinancialInfoComponent implements OnInit {
this.financialForm.addControl('customer_declared_turnover',new FormControl())
this.financialForm.addControl('kuccha_bill_allowed',new FormControl())
}
+ if(this.lender_short_name == 'CHFPL'){
+ this.financialForm.addControl('is_turnover_validated',new FormControl('yes',Validators.compose([Validators.required])))
+ this.financialForm.addControl('how_turnover_validated',new FormControl('',Validators.compose([Validators.required])))
+ this.financialForm.addControl('turnover_validated_others',new FormControl(''))
+ this.financialForm.addControl('turnover_values',this.fb.array([]))
+ this.turnoverValidatedValues('yes')
+ }
this._pd.getTypeofActivityForSuppliedInfoForm(this.pdid, this.company_id).subscribe(data => {
if (data.dataStatus) {
@@ -299,6 +321,9 @@ export class FinancialInfoComponent implements OnInit {
retriveData.formid = this.form_id;
retriveData.company_id = this.company_id;
retriveData.fk_createdby = this.pdid;
+ if(this.lender_short_name == 'CHFPL'){
+ this.turnoverValidatedValues(retriveData.is_turnover_validated);
+ }
retriveData.hasOwnProperty('latest_year_financials_as_per_applicant_met') ? retriveData.latest_year_financials_as_per_applicant_met : retriveData.latest_year_financials_as_per_applicant_met=''
if(this.lender_short_name == "IIB"){
@@ -312,7 +337,7 @@ export class FinancialInfoComponent implements OnInit {
retriveData.hasOwnProperty('customer_declared_turnover') ? retriveData.customer_declared_turnover : retriveData.customer_declared_turnover=''
retriveData.hasOwnProperty('kuccha_bill_allowed') ? retriveData.kuccha_bill_allowed : retriveData.kuccha_bill_allowed=''
}
- this.financialForm.setValue(retriveData);
+ this.financialForm.patchValue(retriveData);
if(this.ServiceDataAvailability == false && retriveData.unsold_stock_lies_in_days == 'NA'){
this.financialForm.controls['unsold_stock_lies_in_days'].setValue('');
@@ -412,11 +437,11 @@ export class FinancialInfoComponent implements OnInit {
/** CREATING financial Statement ( financial_year AutoGenerate ) */
createDate(date) {
return this.fb.group({
- financial_year: [date, Validators.compose([Validators.pattern(/^[0-9]{4}-[0-9]{2}$/)])],
+ financial_year: [date],
financial_annual_sale: ['', Validators.compose([Validators.pattern(/^[0-9\(\)]+$/)])],
finanical_profit_or_loss:[''],
- financial_net_profit: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])],
- financial_net_loss: ['', Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])],
+ financial_net_profit: [''],//, Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])
+ financial_net_loss: [''],//, Validators.compose([Validators.pattern(/^-?[1-9]\d*|0$/)])
financial_margin_of_profit: [''],
financial_margin_of_loss: [''],
financial_variation: [''],
@@ -735,6 +760,21 @@ export class FinancialInfoComponent implements OnInit {
control.push(this.createValue(''));
}
}
+ turnoverValidatedValues(e:string){
+ const control =
this.financialForm.controls['turnover_values'];
+ if(e == 'no'){
+ while (control.length !== 0) {
+ control.removeAt(0);
+ }
+ this.financialForm.controls['how_turnover_validated'].clearValidators()
+ }
+ else if (e == 'yes' && control.length === 0){
+ control.push(this.createValue(''));
+ this.financialForm.controls['how_turnover_validated'].setValidators(Validators.required)
+ }
+ this.financialForm.controls['how_turnover_validated'].updateValueAndValidity();
+ }
+
/** old code Without foreach loop
* calculating Annual Sale for financial Statement
@@ -1968,10 +2008,10 @@ export class FinancialInfoComponent implements OnInit {
this.financialForm.value.date_per_financial['financial_margin_of_loss'].updateValueAndValidity();
}
- // if (!this.financialForm.valid) {
- // this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
- // return;
- // }
+ if (!this.financialForm.valid) {
+ this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
+ return;
+ }
let records = this.financialForm.value;
diff --git a/ng6-seed/src/app/session/login/login.component.ts b/ng6-seed/src/app/session/login/login.component.ts
index 8461ede20..b5efe4102 100755
--- a/ng6-seed/src/app/session/login/login.component.ts
+++ b/ng6-seed/src/app/session/login/login.component.ts
@@ -13,6 +13,7 @@ import { CustomValidators } from 'ng2-validation';
import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material';
import { CognitoService } from '../../AwsService/cognito.service';
+import { MessagingService } from 'app/shared/messaging.service';
@Component({
selector: 'ms-login-session',
@@ -41,7 +42,7 @@ export class LoginComponent implements OnInit{
};
constructor(
private router: Router, public aws: AwsService, public dialog: MatDialog,
- public shared:CognitoService,) {
+ public shared:CognitoService,private messagingService:MessagingService) {
}
ngOnInit(){
@@ -59,6 +60,7 @@ export class LoginComponent implements OnInit{
if (res !== undefined) {
// local storage for validate user access
localStorage.setItem('user_role',res.idToken.payload["custom:role_id"]);
+ this.initializeNotification()
this.router.navigate(['/home']);
}
}, err => {
@@ -82,6 +84,7 @@ export class LoginComponent implements OnInit{
let auth = { 'Username': this.email, 'Password': this.password, 'newpassword': result };
this.aws.dologin(auth).subscribe(res => {
localStorage.setItem('user_role',res.idToken.payload["custom:role_id"]);
+ this.initializeNotification()
this.router.navigate(['/home']);
}, err => {
alert(err.message);
@@ -113,6 +116,13 @@ export class LoginComponent implements OnInit{
return true;
}
}
+ initializeNotification(){
+ const userId = this.aws.getlocale();
+ this.messagingService.requestPermission(userId)
+ this.messagingService.receiveMessage()
+ let msg = this.messagingService.currentMessage
+ console.log("From Login",msg)
+ }
}
diff --git a/ng6-seed/src/app/shared/messaging.service.ts b/ng6-seed/src/app/shared/messaging.service.ts
index e8ee5ee0a..1a442a975 100644
--- a/ng6-seed/src/app/shared/messaging.service.ts
+++ b/ng6-seed/src/app/shared/messaging.service.ts
@@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
-import { AngularFireDatabase } from '@angular/fire/database';
+import { AngularFireDatabase, AngularFireList } from '@angular/fire/database';
import { AngularFireAuth } from '@angular/fire/auth';
import { AngularFireMessaging } from '@angular/fire/messaging';
-import { mergeMapTo,catchError } from 'rxjs/operators';
+import { mergeMapTo,catchError, mergeMap } from 'rxjs/operators';
import { take } from 'rxjs/operators';
import { BehaviorSubject, Observable, of } from 'rxjs'
import { HttpClient } from '@angular/common/http';
@@ -10,18 +10,20 @@ import { HttpClient } from '@angular/common/http';
/** Environment */
import { environment } from 'environments/environment'
import { Router } from '@angular/router';
+import { PushNotifyService } from './push-notify.service';
@Injectable()
export class MessagingService {
currentMessage = new BehaviorSubject(null);
-
+public curr: AngularFireList;
constructor(
private angularFireDB: AngularFireDatabase,
private angularFireAuth: AngularFireAuth,
private angularFireMessaging: AngularFireMessaging,
private http: HttpClient,
- private router:Router) {
+ private router:Router,
+ private notify_service:PushNotifyService) {
this.angularFireMessaging.messaging.subscribe(
(_messaging) => {
_messaging.onMessage = _messaging.onMessage.bind(_messaging);
@@ -85,8 +87,51 @@ export class MessagingService {
this.angularFireMessaging.messages.subscribe(
(payload) => {
console.log("new message received. ", payload);
+ let notify_param:any=[]
+ notify_param.push(payload['notification'])
+ this.notify_service.generateNotification(notify_param)
this.currentMessage.next(payload);
//this.router.navigate([''])
})
}
+ unsubscribeNotification1() {
+ this.angularFireMessaging.getToken.subscribe(res=>{
+ console.log("Deleting Token",res);
+ // console.log(this.angularFireDB.object('fcmTokens/'));
+ // console.log( this.angularFireDB.object('fcmTokens/'+res).remove())
+ // this.angularFireDB.object('fcmTokens/').remove().then(res=>{
+ // console.log("Token del",res)
+ // },err=>{
+ // console.log("new error",err);
+ // })
+ let subscribe=this.angularFireDB.object('/fcmTokens').snapshotChanges().subscribe()
+ subscribe.unsubscribe()
+ // this.curr=this.angularFireDB.list('/groups/');
+ // this.curr.snapshotChanges().subscribe(data=>{
+ // console.log(data);
+ // })
+ // // this.curr.unsubscribe();
+ // })
+// const ll=this.angularFireDB.object('fcmTokens/')
+// ll.unsubscribe
+ this.angularFireMessaging.deleteToken(res).subscribe(del=>{
+ console.log("Token Deleted",del)
+ },err=>{
+ console.log("Error Deleting the FCM Token",err)
+ })
+ },err=>{
+ console.log("Error getting the Token from FCM",err)
+ })
+
+ }
+ unsubscribeNotification() {
+ this.angularFireMessaging.getToken
+ .pipe(mergeMap(token => this.angularFireMessaging.deleteToken(token)))
+ .subscribe(
+ (token) => { console.log('Deleted!',token); },err=>{
+ console.log("Error while deleting token",err)
+ window.location.reload()
+ }
+ );
+ }
}
diff --git a/ng6-seed/src/app/shared/push-notify.service.spec.ts b/ng6-seed/src/app/shared/push-notify.service.spec.ts
new file mode 100644
index 000000000..5b7c4084e
--- /dev/null
+++ b/ng6-seed/src/app/shared/push-notify.service.spec.ts
@@ -0,0 +1,12 @@
+import { TestBed } from '@angular/core/testing';
+
+import { PushNotifyService } from './push-notify.service';
+
+describe('PushNotifyService', () => {
+ beforeEach(() => TestBed.configureTestingModule({}));
+
+ it('should be created', () => {
+ const service: PushNotifyService = TestBed.get(PushNotifyService);
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/ng6-seed/src/app/shared/push-notify.service.ts b/ng6-seed/src/app/shared/push-notify.service.ts
new file mode 100644
index 000000000..1cdcf47e5
--- /dev/null
+++ b/ng6-seed/src/app/shared/push-notify.service.ts
@@ -0,0 +1,87 @@
+import { Injectable } from '@angular/core';
+import {
+ Observable
+} from 'rxjs/Observable';
+
+
+@Injectable({
+ providedIn: 'root'
+})
+export class PushNotifyService {
+ public permission: Permission;
+ constructor() {
+ this.permission = this.isSupported() ? 'default' : 'denied';
+ }
+ public isSupported(): boolean {
+ return 'Notification' in window;
+ }
+ requestPermission(): void {
+ let self = this;
+ if ('Notification' in window) {
+ Notification.requestPermission(function(status) {
+ return self.permission = status;
+ });
+ }
+ }
+ create(title: string, options ? : PushNotification): any {
+ let self = this;
+ return new Observable(function(obs) {
+ if (!('Notification' in window)) {
+ console.log('Notifications are not available in this environment');
+ obs.complete();
+ }
+ if (self.permission !== 'granted') {
+ console.log("The user hasn't granted you permission to send push notifications");
+ obs.complete();
+ }
+ let _notify = new Notification(title, options);
+ _notify.onshow = function(e) {
+ return obs.next({
+ notification: _notify,
+ event: e
+ });
+ };
+ _notify.onclick = function(e) {
+ return obs.next({
+ notification: _notify,
+ event: e
+ });
+ };
+ _notify.onerror = function(e) {
+ return obs.error({
+ notification: _notify,
+ event: e
+ });
+ };
+ _notify.onclose = function() {
+ return obs.complete();
+ };
+ });
+ }
+ generateNotification(source: Array < any > ): void {
+ let self = this;
+ source.forEach((item) => {
+ let options = {
+ body: item.body,
+ icon: item.icon
+ };
+ let notify = self.create('', options).subscribe();
+ })
+ }
+}
+export declare type Permission = 'denied' | 'granted' | 'default';
+export interface PushNotification {
+ body ? : string;
+ icon ? : string;
+ tag ? : string;
+ data ? : any;
+ renotify ? : boolean;
+ silent ? : boolean;
+ sound ? : string;
+ noscreen ? : boolean;
+ sticky ? : boolean;
+ dir ? : 'auto' | 'ltr' | 'rtl';
+ lang ? : string;
+ vibrate ? : number[];
+}
+
diff --git a/ng6-seed/src/environments/environment.stage.ts b/ng6-seed/src/environments/environment.stage.ts
index b44ad3c03..0eaeb99d1 100644
--- a/ng6-seed/src/environments/environment.stage.ts
+++ b/ng6-seed/src/environments/environment.stage.ts
@@ -3,7 +3,7 @@ export const environment = {
map_api_key:'AIzaSyA3lYDYxwtn5vLSl45SOKbtK7G6cEyXGr0',
environmentName: 'Testing Environment',//Test Environment.
- apiEndpoint: 'https://demo.pdgenie.com/sparqtest/api/',
+ apiEndpoint: 'https://apitest.pdgenie.com/sparqtest/api/',
authorization: 'sparqvenba2018',
login_string: "cognito-idp.ap-south-1.amazonaws.com/ap-south-1_qQ85yQZJO",
diff --git a/ng6-seed/src/environments/environment.ts b/ng6-seed/src/environments/environment.ts
index a430f3e1e..33b0922d5 100755
--- a/ng6-seed/src/environments/environment.ts
+++ b/ng6-seed/src/environments/environment.ts
@@ -11,7 +11,8 @@ export const environment = {
environmentName: 'Development Environment',//Localhost Environment.
// apiEndpoint: 'https://demo.pdgenie.com/sparqtest/api/',
- apiEndpoint: 'https://demo.pdgenie.com/sparqapi/api/',
+ // apiEndpoint: 'https://demo.pdgenie.com/sparqapi/api/',
+ apiEndpoint:'https://apitest.pdgenie.com/sparqapi/api/',
authorization: 'sparqvenba2018',