-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1162 from ORCID/homeComponent
Home component
- Loading branch information
Showing
13 changed files
with
421 additions
and
22 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div> | ||
<H1 class="mb-4">Something has gone wrong...</H1> | ||
<p class="mb-4"> | ||
We can't display your member details at the moment. Please try refreshing your browser window to see if that fixes | ||
the problem. | ||
</p> | ||
<p> | ||
If your member details are still not being displayed please contact | ||
<a href="mailto:membership@orcid.org?subject=Member Portal - Member details not displayed" | ||
>membership@orcid.org</a | ||
> | ||
for more help. | ||
</p> | ||
</div> |
Empty file.
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,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { GenericLandingComponent } from './generic-landing.component'; | ||
|
||
describe('GenericLandingComponent', () => { | ||
let component: GenericLandingComponent; | ||
let fixture: ComponentFixture<GenericLandingComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [GenericLandingComponent] | ||
}); | ||
fixture = TestBed.createComponent(GenericLandingComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
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,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-generic-landing', | ||
templateUrl: './generic-landing.component.html', | ||
styleUrls: ['./generic-landing.component.scss'] | ||
}) | ||
export class GenericLandingComponent { | ||
|
||
} |
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 +1,13 @@ | ||
<p>home works!</p> | ||
<div class="row h-100"> | ||
<div class="col-md-12"> | ||
<div class="h-100"> | ||
<div class="d-flex flex-column h-100"> | ||
<div class="alert alert-success mt-3">{{ loggedInMessage }}</div> | ||
<div *ngIf="memberData || memberData === null" class="h-100 home-container mb-3"> | ||
<router-outlet *ngIf="memberData"></router-outlet> | ||
<app-generic-landing *ngIf="memberData === null" class="p-4 d-flex"></app-generic-landing> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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,12 @@ | ||
:host { | ||
max-width: 1250px; | ||
display: block; | ||
margin: auto; | ||
height: 100%; | ||
} | ||
|
||
.home-container { | ||
border: 2px solid #eeeeee; | ||
border-radius: 5px 0px 0px 5px; | ||
} | ||
|
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,21 +1,69 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
|
||
import { HomeComponent } from './home.component' | ||
import { MemberService } from '../member/service/member.service' | ||
import { AccountService } from '../account' | ||
import { of } from 'rxjs' | ||
|
||
describe('HomeComponent', () => { | ||
let component: HomeComponent | ||
let fixture: ComponentFixture<HomeComponent> | ||
let memberServiceSpy: jasmine.SpyObj<MemberService> | ||
let accountServiceSpy: jasmine.SpyObj<AccountService> | ||
|
||
beforeEach(() => { | ||
accountServiceSpy = jasmine.createSpyObj('AccountService', ['getAccountData']) | ||
memberServiceSpy = jasmine.createSpyObj('MemberService', ['getMemberData']) | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [HomeComponent], | ||
providers: [ | ||
{ provide: MemberService, useValue: memberServiceSpy }, | ||
{ provide: AccountService, useValue: accountServiceSpy }, | ||
], | ||
}) | ||
fixture = TestBed.createComponent(HomeComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
|
||
accountServiceSpy = TestBed.inject(AccountService) as jasmine.SpyObj<AccountService> | ||
memberServiceSpy = TestBed.inject(MemberService) as jasmine.SpyObj<MemberService> | ||
}) | ||
|
||
it('should create', () => { | ||
it('should call getAccountData but not getMemberData', () => { | ||
accountServiceSpy.getAccountData.and.returnValue(of(null)) | ||
|
||
expect(component).toBeTruthy() | ||
|
||
component.ngOnInit() | ||
|
||
expect(accountServiceSpy.getAccountData).toHaveBeenCalled() | ||
expect(memberServiceSpy.getMemberData).toHaveBeenCalledTimes(0) | ||
}) | ||
|
||
it('should call getMemberData if account data is not null', () => { | ||
accountServiceSpy.getAccountData.and.returnValue( | ||
of({ | ||
activated: true, | ||
authorities: ['test', 'test'], | ||
email: 'email@email.com', | ||
firstName: 'name', | ||
langKey: 'en', | ||
lastName: 'surname', | ||
imageUrl: 'url', | ||
salesforceId: 'sfid', | ||
loggedAs: false, | ||
loginAs: 'sfid', | ||
mainContact: false, | ||
mfaEnabled: false, | ||
}) | ||
) | ||
memberServiceSpy.getMemberData.and.returnValue(of({})) | ||
|
||
expect(component).toBeTruthy() | ||
|
||
component.ngOnInit() | ||
|
||
expect(accountServiceSpy.getAccountData).toHaveBeenCalled() | ||
expect(memberServiceSpy.getMemberData).toHaveBeenCalled() | ||
}) | ||
}) |
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,8 +1,50 @@ | ||
import { Component } from '@angular/core' | ||
import { Component, OnDestroy, OnInit } from '@angular/core' | ||
import { AccountService } from '../account' | ||
import { MemberService } from '../member/service/member.service' | ||
import { Subscription } from 'rxjs/internal/Subscription' | ||
import { ISFMemberData } from '../member/model/salesforce-member-data.model' | ||
import { IAccount } from '../account/model/account.model' | ||
|
||
@Component({ | ||
selector: 'app-home', | ||
templateUrl: './home.component.html', | ||
styleUrls: ['./home.component.scss'], | ||
}) | ||
export class HomeComponent {} | ||
export class HomeComponent implements OnInit, OnDestroy { | ||
account: IAccount | undefined | null | ||
memberData: ISFMemberData | undefined | null | ||
authenticationStateSubscription: Subscription | undefined | ||
memberDataSubscription: Subscription | undefined | ||
manageMemberSubscription: Subscription | undefined | ||
salesforceId: string | undefined | ||
loggedInMessage: string | undefined | ||
|
||
constructor( | ||
private accountService: AccountService, | ||
private memberService: MemberService | ||
) {} | ||
|
||
ngOnInit() { | ||
this.accountService.getAccountData().subscribe((account) => { | ||
this.account = account | ||
if (account) { | ||
this.memberDataSubscription = this.memberService.getMemberData(account.salesforceId).subscribe((data) => { | ||
this.memberData = data | ||
}) | ||
this.loggedInMessage = $localize`:@@home.loggedIn.message.string:You are logged in as user ${account.email}` | ||
} | ||
}) | ||
} | ||
|
||
ngOnDestroy() { | ||
if (this.authenticationStateSubscription) { | ||
this.authenticationStateSubscription.unsubscribe() | ||
} | ||
if (this.memberDataSubscription) { | ||
this.memberDataSubscription.unsubscribe() | ||
} | ||
if (this.manageMemberSubscription) { | ||
this.manageMemberSubscription.unsubscribe() | ||
} | ||
} | ||
} |
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.