diff --git a/ng6-seed/src/app/AwsService/aws.service.ts b/ng6-seed/src/app/AwsService/aws.service.ts index a152dc1..cbb795c 100755 --- a/ng6-seed/src/app/AwsService/aws.service.ts +++ b/ng6-seed/src/app/AwsService/aws.service.ts @@ -563,6 +563,9 @@ export class AwsService { getlocale(){ let session:any = this.shared.getAccessToken() || ""; + if(!session || !session.idToken) { + return + } return session.idToken.payload.locale; } diff --git a/ng6-seed/src/app/AwsService/cognito.service.ts b/ng6-seed/src/app/AwsService/cognito.service.ts index 31b2322..80ce36c 100755 --- a/ng6-seed/src/app/AwsService/cognito.service.ts +++ b/ng6-seed/src/app/AwsService/cognito.service.ts @@ -128,6 +128,9 @@ isloggin:boolean = false; // } refresh() { let tokenexp:boolean; + if(!this.getCurrentUser()) { + return; + } this.getCurrentUser().getSession(function (err, session) { if (err) { } diff --git a/ng6-seed/src/app/_guard/auth.guard.ts b/ng6-seed/src/app/_guard/auth.guard.ts index 8b7e970..bb52d8e 100755 --- a/ng6-seed/src/app/_guard/auth.guard.ts +++ b/ng6-seed/src/app/_guard/auth.guard.ts @@ -1,11 +1,11 @@ import { Injectable } from '@angular/core'; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanActivateChild } from '@angular/router'; -import { Observable , of } from 'rxjs'; +import { PdTrigerService } from 'app/personal-discussion/pd-service/pd-triger.service'; import { CognitoService } from '../AwsService/cognito.service'; @Injectable() export class AuthGuard implements CanActivate, CanActivateChild { - constructor(private router: Router,public shared:CognitoService) { } + constructor(private router: Router,public shared:CognitoService,private pdTriggerService:PdTrigerService) { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { if (this.shared.getToken()) { @@ -19,18 +19,37 @@ export class AuthGuard implements CanActivate, CanActivateChild { } } - canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - + canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot,): boolean { + console.log(route.queryParams.str) + let paramCheck = route.queryParams.str + if(paramCheck) { + paramCheck = paramCheck.split('/') + console.log(paramCheck) + if(paramCheck && paramCheck.length > 0 && paramCheck[2] == 'link') { + + + this.pdTriggerService.customer_url_data= {pdid:paramCheck[0],rdmstr:paramCheck[1],from:'link'} + + + } + } + else{ + this.pdTriggerService.customer_url_data={} + } if (this.shared.getToken()) { // alert("if"); return true; } else { + console.log(route); + // debugger; + // else { // alert("else"); setTimeout(() => { this.router.navigate(['authentication/login']); return false; },1000); + // } } } diff --git a/ng6-seed/src/app/_guard/token.interceptor.ts b/ng6-seed/src/app/_guard/token.interceptor.ts index 38e1575..caab7d4 100755 --- a/ng6-seed/src/app/_guard/token.interceptor.ts +++ b/ng6-seed/src/app/_guard/token.interceptor.ts @@ -34,7 +34,7 @@ export class TokenInterceptor implements HttpInterceptor{ headers:new HttpHeaders({ 'Authorization': environment.authorization, - 'Token': token.getIdToken().getJwtToken() + 'Token': token ? token.getIdToken().getJwtToken() : '' }) }); return next.handle(requests).pipe(tap((event:HttpEvent)=>{ 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 bb83d64..287136d 100755 --- a/ng6-seed/src/app/layouts/admin/admin-layout.component.ts +++ b/ng6-seed/src/app/layouts/admin/admin-layout.component.ts @@ -13,6 +13,7 @@ import { UserService } from '../../settings/service/user.service'; import { DashboardService } from '../../dashboard/dashboard.service'; import { AwsService } from '../../AwsService/aws.service'; import { RoleMenuItemsPipe } from './../role-menu-items.pipe'; +import { PdTrigerService } from 'app/personal-discussion/pd-service/pd-triger.service'; @Component({ selector: 'app-layout', @@ -54,7 +55,7 @@ export class AdminLayoutComponent implements OnInit, OnDestroy { alertMsgAllocateType : any[]; alertCount: any; userRoleType: String; - 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 pdTriggerService:PdTrigerService) { const browserLang: string = translate.getBrowserLang(); translate.use(browserLang.match(/en|fr/) ? browserLang : 'en'); this.users.getroles().subscribe(res=>{ @@ -290,7 +291,14 @@ export class AdminLayoutComponent implements OnInit, OnDestroy { menunav(active){ switch(active){ case 'HOME': + if(this.pdTriggerService.customer_url_data && this.pdTriggerService.customer_url_data.pdid && this.pdTriggerService.customer_url_data.rdmstr) { + let data= this.pdTriggerService.customer_url_data + this.router.navigateByUrl('/personal_discussion/pdlist/viewpd?str='+data.pdid+'/'+data.rdmstr+'/link', {replaceUrl: true}); + + } + else { this.router.navigate(['/']); + } break; case 'USERS': this.router.navigate(['/setting/users/userprofile']); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts index 1a4cf91..f1073fd 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/schedule-pd/schedule-pd.component.ts @@ -64,15 +64,15 @@ export class SchedulePdComponent implements OnInit, OnDestroy { } ngOnInit() { - this.validateTime = setInterval(() => { - let currentTime:any = new Date(); - currentTime = currentTime.getFullYear()+'-'+currentTime.getMonth()+'-'+currentTime.getDay()+'-'+currentTime.getHours()+'-'+currentTime.getMinutes(); - let existTime:any = this.selectedMoment.getFullYear()+'-'+this.selectedMoment.getMonth()+'-'+this.selectedMoment.getDay() +'-'+this.selectedMoment.getHours()+'-'+this.selectedMoment.getMinutes(); - if(existTime < currentTime) { - this.selectedMoment = new Date(); - this.min = new Date(); - } - },1000); + // this.validateTime = setInterval(() => { + // let currentTime:any = new Date(); + // currentTime = currentTime.getFullYear()+'-'+currentTime.getMonth()+'-'+currentTime.getDay()+'-'+currentTime.getHours()+'-'+currentTime.getMinutes(); + // let existTime:any = this.selectedMoment.getFullYear()+'-'+this.selectedMoment.getMonth()+'-'+this.selectedMoment.getDay() +'-'+this.selectedMoment.getHours()+'-'+this.selectedMoment.getMinutes(); + // if(existTime < currentTime) { + // this.selectedMoment = new Date(); + // this.min = new Date(); + // } + // },1000); } // close pd schedule pop up diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html index fb5f472..b3bf273 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.html @@ -3,13 +3,17 @@
+ + - +
@@ -155,7 +159,7 @@ - + @@ -196,7 +200,7 @@
- +
@@ -407,7 +411,7 @@ --> - + FI History
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts index 3e769ec..af5b6c3 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/view-pd/view-pd.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewEncapsulation, EventEmitter, Input, Output, OnDestroy, Pipe, PipeTransform } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation, EventEmitter, Input, Output, OnDestroy, Pipe, PipeTransform, ChangeDetectorRef } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { MatDialog } from '@angular/material'; @@ -21,6 +21,7 @@ import { SchedulePdComponent } from '../schedule-pd/schedule-pd.component'; import { CommonQuesComponent } from '../pd-questions/common-ques/common-ques.component'; import { EmployerInfoComponent } from '../pd-questions/employer-info/employer-info.component'; import { InputDialogComponent } from '../input-dialog/input-dialog.component'; +import { CognitoService } from 'app/AwsService/cognito.service'; const currentdate = new Date().toJSON().slice(0,19); @Component({ @@ -33,7 +34,7 @@ export class ViewPdComponent implements OnInit, OnDestroy { pipe = new DatePipe('en-US'); private notifier: NotifierService; public userRoleID = +localStorage.getItem('user_role'); - public VendorRoleID : any = localStorage.getItem('VendorRoleID'); + VendorRoleID : any = 22; errorMessage: any; pdMasterData: any = []; pdAddressesData: any = []; @@ -100,21 +101,45 @@ export class ViewPdComponent implements OnInit, OnDestroy { // @Output() loadParent = new EventEmitter(); public _EditPDtriggerForm: FormGroup; masterRandomString: any; - constructor(notifier: NotifierService, private dialog: MatDialog, private _fb: FormBuilder, - private _pd: PdTrigerService, private route: ActivatedRoute, private router: Router, private ListPdComponent: ListPdComponent) { + is_from_link: boolean = false; + constructor(notifier: NotifierService, private dialog: MatDialog, private _fb: FormBuilder, private changeRef:ChangeDetectorRef, + private _pd: PdTrigerService, private route: ActivatedRoute, private router: Router, private ListPdComponent: ListPdComponent,private cognitoService:CognitoService) { this.notifier = notifier; this.enableStartPD = false; this.roleAccessDetails=this._pd.getRoleAccessDetails(); + setTimeout(()=>{ + this.VendorRoleID = localStorage.getItem('VendorRoleID') + },1000) + console.log(this.VendorRoleID); + // this.changeRef.detectChanges(); } ngOnInit() { + console.log(this.cognitoService.getToken()) + if (!this.cognitoService.getToken()) { + return; + } this.ListPdComponent.showListView(false); this.route.params.subscribe(params => { this.viewID = params['pdid']; this.masterRandomString = params['rdmstr']; }); + if(!this.viewID) { + this.route.queryParams.subscribe(param=>{ + if(param) { + let temp= param['str'].split('/') + console.log(temp) + if(temp && temp.length > 0) { + this.viewID = temp[0] + this.masterRandomString = temp[1] + this.is_from_link = temp[2] == 'link' + } + } + }) + } this.viewPdDetails(this.viewID); } + pd_QC_Rating: Number; viewPdDetails(editID: string) { @@ -573,6 +598,36 @@ export class ViewPdComponent implements OnInit, OnDestroy { this.notifier.notify("error",'Network Error !!') }) } + copyCaseUrl(){ + let url:string='' + if(window.location.origin.includes('localhost')){ + url = window.location.origin+'/#/personal_discussion/pdlist/viewpd?str='+this.viewID+'/'+this.masterRandomString+'/link'; + } + else{ + url = window.location.origin+'/pd/#/personal_discussion/pdlist/viewpd?str='+this.viewID+'/'+this.masterRandomString+'/link'; + } + if(url) { + this.copyToClipBoard(url) + this.notifier.notify("info","Case Url Copied to Clipboard") + } + else{ + this.notifier.notify("info","Unable to Copy Url") + } + } + copyToClipBoard(message) { + + const selBox = document.createElement('textarea'); + selBox.style.position = 'fixed'; + selBox.style.left = '0'; + selBox.style.top = '0'; + selBox.style.opacity = '0'; + selBox.value = message; + document.body.appendChild(selBox); + selBox.focus(); + selBox.select(); + document.execCommand('copy'); + document.body.removeChild(selBox); + } // updateViewComponent(editBack:string) { @@ -593,6 +648,6 @@ export class ViewPdComponent implements OnInit, OnDestroy { } } - + } \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts index 1115efc..48c56a6 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/manage-pd.routing.ts @@ -36,6 +36,10 @@ const routes: Routes = [ path: 'viewpd/:pdid/:rdmstr', component: ViewPdComponent, }, + { + path: 'viewpd', + component: ViewPdComponent, + }, { path: 'pd_report/:pdid/:string', component: PdReportComponent, diff --git a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts index e819bdf..3f527e5 100755 --- a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts @@ -29,6 +29,7 @@ export interface Master { export class PdTrigerService { + customer_url_data:any={} pdQuestionMasterData:any=null // private apiUrl = "http://ssa.sineedge.com/sparqapi/api/"; diff --git a/ng6-seed/src/app/session/login/login.component.ts b/ng6-seed/src/app/session/login/login.component.ts index 3ae130c..a0cc813 100755 --- a/ng6-seed/src/app/session/login/login.component.ts +++ b/ng6-seed/src/app/session/login/login.component.ts @@ -15,6 +15,7 @@ import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material'; import { CognitoService } from '../../AwsService/cognito.service'; import { DashboardService } from 'app/dashboard/dashboard.service'; import { resolve } from 'url'; +import { PdTrigerService } from 'app/personal-discussion/pd-service/pd-triger.service'; @Component({ selector: 'ms-login-session', @@ -44,7 +45,7 @@ export class LoginComponent implements OnInit{ commonDetails: any; constructor( private router: Router, public aws: AwsService, public dialog: MatDialog, - public shared:CognitoService,private dashBoardService:DashboardService) { + public shared:CognitoService,private dashBoardService:DashboardService,private pdTriggerService:PdTrigerService) { } ngOnInit(){ @@ -76,7 +77,14 @@ export class LoginComponent implements OnInit{ this.getCommonSettings().then(()=>{ // local storage for validate user access localStorage.setItem('user_role',res.idToken.payload["custom:role_id"]); - this.router.navigate(['/']); + if(this.pdTriggerService.customer_url_data && this.pdTriggerService.customer_url_data.pdid && this.pdTriggerService.customer_url_data.rdmstr) { + let data= this.pdTriggerService.customer_url_data + this.router.navigateByUrl('/personal_discussion/pdlist/viewpd?str='+data.pdid+'/'+data.rdmstr+'/link', {replaceUrl: true}); + + } + else{ + this.router.navigate(['/']) + } }) } }, err => { @@ -100,7 +108,14 @@ export class LoginComponent implements OnInit{ let auth = { 'Username': this.email, 'Password': this.password, 'newpassword': result }; this.aws.dologin(auth).subscribe(res => { this.getCommonSettings(); + if(this.pdTriggerService.customer_url_data && this.pdTriggerService.customer_url_data.pdid && this.pdTriggerService.customer_url_data.rdmstr) { + let data= this.pdTriggerService.customer_url_data + this.router.navigateByUrl('/personal_discussion/pdlist/viewpd?str='+data.pdid+'/'+data.rdmstr+'/link', {replaceUrl: true}); + + } + else { this.router.navigate(['/']); + } }, err => { // alert(err.message); }) @@ -124,7 +139,13 @@ export class LoginComponent implements OnInit{ //alert(this.shared.isLoggedIn); if(this.shared.isLoggedIn){ // alert("if"); + if(this.pdTriggerService.customer_url_data) { + let data= this.pdTriggerService.customer_url_data + this.router.navigateByUrl('/personal_discussion/pdlist/viewpd?str='+data.pdid+'/'+data.rdmstr+'/link', {replaceUrl: true}); + } + else { this.router.navigate(['/personal_discussion']); + } return false; }else{ //alert("else");