This repository has been archived by the owner on Jul 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Custom directive added for authChecking #302
Open
Kajol-Kumari
wants to merge
9
commits into
Cloud-CV:master
Choose a base branch
from
Kajol-Kumari:custom_directive_for_authChecking
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
de03b5f
custom_directive_added_for_auth_checking
Kajol-Kumari 52b314e
custom_directive_added
Kajol-Kumari c5b84d7
build_fix
Kajol-Kumari 79b569c
test_for_directive_added
Kajol-Kumari 7de59bf
buuild_fix
Kajol-Kumari 9a75649
test_for_authCheckDirective_added
Kajol-Kumari cbe76e0
resolve conflicts
Kajol-Kumari 961459a
Merge branch 'master' into custom_directive_for_authChecking
RishabhJain2018 5a8083f
Merge branch 'master' into custom_directive_for_authChecking
RishabhJain2018 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { TemplateRef, ViewContainerRef, Component, ViewChild } from '@angular/core'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { async, TestBed, ComponentFixture } from '@angular/core/testing'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
|
||
// import Directive | ||
import { AuthcheckDirective } from './authcheck.directive'; | ||
|
||
// import services | ||
import { AuthService } from '../services/auth.service'; | ||
import { GlobalService } from '../services/global.service'; | ||
import { ApiService } from '../services/api.service'; | ||
import { EndpointsService } from '../services/endpoints.service'; | ||
|
||
@Component({ | ||
selector: 'app-authcheck', | ||
template: `<p *appAuthcheck="true">AuthChecking Directive</p>`, | ||
}) | ||
class TestAuthDirectiveComponent { | ||
@ViewChild(AuthcheckDirective) authchcekDirective: AuthcheckDirective; | ||
} | ||
describe('AuthcheckDirective', () => { | ||
let component: TestAuthDirectiveComponent; | ||
let fixture: ComponentFixture<TestAuthDirectiveComponent>; | ||
let authServive: AuthService; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
AuthcheckDirective, | ||
TestAuthDirectiveComponent | ||
], | ||
imports: [ | ||
RouterTestingModule, | ||
HttpClientModule | ||
], | ||
providers: [ | ||
AuthService, | ||
GlobalService, | ||
ApiService, | ||
EndpointsService | ||
] | ||
}).compileComponents(); | ||
fixture = TestBed.createComponent(TestAuthDirectiveComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
authServive = TestBed.get(AuthService); | ||
})); | ||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Directive, OnInit, Input, ViewContainerRef, TemplateRef } from '@angular/core'; | ||
import { AuthService } from '../services/auth.service'; | ||
|
||
@Directive({ | ||
selector: '[appAuthcheck]' | ||
}) | ||
export class AuthcheckDirective implements OnInit { | ||
|
||
constructor( | ||
private authService: AuthService, | ||
private templateRef: TemplateRef<any>, | ||
private viewContainer: ViewContainerRef | ||
) { } | ||
|
||
isAuthCondition: boolean; | ||
|
||
@Input() set appAuthcheck(isAuthCondition: boolean) { | ||
this.isAuthCondition = isAuthCondition; | ||
} | ||
|
||
ngOnInit() { | ||
const authVal = this.authService.isAuth; | ||
if (authVal && this.isAuthCondition || !authVal && !this.isAuthCondition) { | ||
this.viewContainer.createEmbeddedView(this.templateRef); | ||
} else { | ||
this.viewContainer.clear(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<app-side-bar *ngIf="authService.isAuth"></app-side-bar> | ||
<app-side-bar *appAuthcheck ="true"></app-side-bar> | ||
<app-header-static></app-header-static> | ||
<div class="web-container"> | ||
<div class="dashboard-flex"> | ||
<div class="dashboard-content"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
<app-footer [isDash]="true" *ngIf="authService.isAuth"></app-footer> | ||
<app-footer [isDash]="true" *appAuthcheck ="true"></app-footer> | ||
</div> | ||
</div> | ||
<div class="clearfix"></div> | ||
|
||
<app-footer *ngIf="!authService.isAuth"></app-footer> | ||
<app-footer *appAuthcheck ="false"></app-footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<app-side-bar *ngIf="authService.isAuth"></app-side-bar> | ||
<app-side-bar *appAuthcheck ="true"></app-side-bar> | ||
<app-header-static></app-header-static> | ||
<div class="web-container"> | ||
<div class="dashboard-flex"> | ||
<div class="dashboard-content"> | ||
<app-dashboard-content></app-dashboard-content> | ||
</div> | ||
<!--Dashboard-Footer--> | ||
<app-footer [isDash]="true" *ngIf="authService.isAuth"></app-footer> | ||
<app-footer [isDash]="true" *appAuthcheck ="true"></app-footer> | ||
</div> | ||
</div> | ||
<div class="clearfix"></div> | ||
|
||
<app-footer *ngIf="!authService.isAuth"></app-footer> | ||
<app-footer *appAuthcheck ="false"></app-footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better selector name - a generic one