Skip to content

Commit

Permalink
batch-of-fixes-29-aug
Browse files Browse the repository at this point in the history
  • Loading branch information
leomendoza123 committed Aug 30, 2024
1 parent 8b42b0c commit 5383430
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 55 deletions.
3 changes: 1 addition & 2 deletions src/app/cdk/platform-info/browserlist.regexp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// tslint:disable-next-line: max-line-length
export const BROWSERLIST_REGEXP =
/((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/
export const BROWSERLIST_REGEXP = /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h2 class="orc-font-body" i18n="@@institutional.suggestedOrg">
>
<div class="col l12 m8 s4 institutional-logo">
<mat-progress-spinner
*ngIf="!imageLoadingFinish"
*ngIf="institution?.Logos?.[0]?.value && !imageLoadingFinish"
mode="indeterminate"
diameter="50"
>
Expand All @@ -66,17 +66,16 @@ <h2 class="orc-font-body" i18n="@@institutional.suggestedOrg">
src="assets/vectors/organization-no-logo.svg"
alt="institution logo"
*ngIf="
imageLoadingFinish && imageLoadingTimeOut;
!(institution?.Logos?.[0]?.value) || imageLoadingTimeOut || displayDefaultImage ;
else elseBlock
"
el
/>

<ng-template #elseBlock>
<img
src="{{ institution.Logos[0].value }}"
src="{{ institution?.Logos[0]?.value }}"
alt="institution logo"
(click)="selectInstitution(institution)"
(error)="handleImgError($event)"
(load)="imgLoading($event)"
/>
Expand Down Expand Up @@ -150,6 +149,7 @@ <h2 class="orc-font-body" i18n="@@institutional.suggestedOrg">
mat-button
matSuffix
mat-icon-button
*ngIf="institutionFormControl.value"
[attr.aria-label]="labelClear"
class="remove-border"
(click)="clear()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ img {
margin: 0;
}
img {
cursor: pointer;
margin: 12px 0 0px 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {
ChangeDetectorRef,
Component,
HostBinding,
Inject,
OnInit,
Renderer2,
ViewChild,
} from '@angular/core'
import {
Expand Down Expand Up @@ -69,7 +71,8 @@ export class InstitutionalComponent implements OnInit {
private _disco: DiscoService,
private _router: Router,
private _platformInfo: PlatformInfoService,
private _cookie: CookieService
private _cookie: CookieService,
private _changeDet: ChangeDetectorRef
) {
this.loading = true
this._disco.getDiscoFeed().subscribe((res) => {
Expand All @@ -96,12 +99,11 @@ export class InstitutionalComponent implements OnInit {
: institutionsFiltered
}),
tap(() => {
if (!this.institutionFormControl.valid) {
this.logoInstitution = undefined
if (!this.institutionFormControl.valid && !this.institutionFormControl.pristine) {
this.userSelectedInstitutions = []
}
})
)
this.clear()
})
}

Expand All @@ -119,6 +121,8 @@ export class InstitutionalComponent implements OnInit {
ngOnInit() {}

onSubmit() {
this.institutionFormControl.markAllAsTouched()
this.institutionFormControl.markAsDirty()
if (this.institutionalForm.valid || this.entityID) {
this.loading = true

Expand All @@ -138,13 +142,12 @@ export class InstitutionalComponent implements OnInit {
}

clear() {
this.logoInstitution = undefined
this.userSelectedInstitutions = []
this.institutionalForm.controls['institution'].setValue('')
}

selected(institutionName) {
this.loading = true
this.logoInstitution = undefined
const institutionSelected = this._disco.getInstitutionBaseOnName(
institutionName,
this.institutions
Expand All @@ -154,12 +157,14 @@ export class InstitutionalComponent implements OnInit {
this.institution = institutionSelected
this.entityID = this.institution.entityID

if (
this.institution?.Logos &&
!this.isInstitutionLogoDisplayed(this.institution.Logos[0].value)
) {
this.logoInstitution = this.institution.Logos[0].value
}
this.displayDefaultImage = false
this.imageLoadingTimeOut= false
this.imageLoadingFinish= false

this.userSelectedInstitutions = []
this.userSelectedInstitutions.push(institutionSelected)


}

getNameInstitution(institution: Institutional): DisplayName {
Expand Down Expand Up @@ -200,7 +205,8 @@ export class InstitutionalComponent implements OnInit {
const institutions = cookieValues.split('%20')
for (const inst of institutions) {
this._disco.getInstitutionBaseOnID(atob(inst)).subscribe((res) => {
this.userSelectedInstitutions.push(res)
this.userSelectedInstitutions = [res]
this._changeDet.markForCheck()
setTimeout(() => {
if (!this.imageLoadingFinish) {
this.imageLoadingFinish = true
Expand All @@ -217,12 +223,6 @@ export class InstitutionalComponent implements OnInit {
this.onSubmit()
}

isInstitutionLogoDisplayed(logo): boolean {
return this.userSelectedInstitutions.some((institution) =>
institution?.Logos?.some((lo) => lo.value === logo)
)
}

navigateTo(val) {
this.window.location.href = val
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/link-account/link-account.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { MatLegacyButtonModule as MatButtonModule } from '@angular/material/lega
import { MatLegacyProgressBarModule as MatProgressBarModule } from '@angular/material/legacy-progress-bar'
import { LinkAccountRoutingModule } from './link-account-routing.module'
import { SignInModule } from '../sign-in/sign-in.module'
import { SharedModule } from '../shared/shared.module'
import { A11yLinkModule } from '../cdk/a11y-link/a11y-link.module'

@NgModule({
declarations: [LinkAccountComponent],
Expand All @@ -21,6 +23,7 @@ import { SignInModule } from '../sign-in/sign-in.module'
MatProgressBarModule,
LinkAccountRoutingModule,
SignInModule,
A11yLinkModule
],
})
export class LinkAccountModule {}
73 changes: 46 additions & 27 deletions src/app/link-account/pages/link-account/link-account.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1 class="orc-font-heading-small">
</ng-container>
{{ entityDisplayName }}
<ng-container i18n="@@linking.title.2">
account to your ORCID record
account
</ng-container>
</h1>
<p class="mat-body-1">
Expand Down Expand Up @@ -66,6 +66,8 @@ <h1 class="orc-font-heading-small">
class="mat-button-font underline orc-font-body-small"
i18n="@@linking.knowledgebase"
href="https://support.orcid.org/hc/en-us/articles/360006972693"
target="_blank"
rel="noopener noreferrer"
>
please visit the ORCID help centre
</a>
Expand All @@ -77,35 +79,52 @@ <h1 class="orc-font-heading-small">
#formSignInComponent
[signInData]="signInData"
[signInUpdatesV1Togglz]="true"
[showForgotYourPassword]="false"
(show2FAEmitter)="show2FAEmitter($event)"
>
<div class="button-group center-content">
<button
mat-raised-button
(click)="formSignInComponent.onSubmit()"
class="mat-elevation-z0 mat-button-wrap-text"
type="submit"
[disabled]="loading || signingLoading"
*ngIf="!show2FA"
>
<ng-container i18n="@@linking.button.1">
Sign in and link your
</ng-container>
{{ entityDisplayName }}
<ng-container i18n="@@linking.button.2">
account
</ng-container>
</button>

<a
class="mat-button-font institution-name-link underline"
i18n="@@linking.cancelLinking"
(click)="cancel()"
>
Cancel linking
</a>
</div>
</app-form-sign-in>
<div class="button-group center-content">
<button
mat-raised-button
(click)="formSignInComponent.onSubmit()"
class="mat-elevation-z0 mat-button-wrap-text"
type="submit"
[disabled]="loading || signingLoading"
*ngIf="!show2FA"
>
<ng-container i18n="@@linking.button.1">
Sign in and link your
</ng-container>
{{ entityDisplayName }}
<ng-container i18n="@@linking.button.2">
account
</ng-container>
</button>

<a
class="mat-button-font institution-name-link underline"
i18n="@@linking.cancelLinking"
(click)="cancel()"
>
Cancel linking
</a>

<a
class="mat-button-font institution-name-link underline"
i18n="@@ngOrcid.signin.forgotYourPassword"
(click)="forgotPassword()"
>
Forgot your password or ORCID ID?
</a>

<a
class="mat-button-font institution-name-link underline"
i18n="@@ngOrcid.signin.registerNow"
(click)="register()"
>
Register now
</a>
</div>
</div>
</mat-card-content>
</mat-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Router } from '@angular/router'
import { ApplicationRoutes } from 'src/app/constants'
import { first } from 'rxjs/operators'
import { UserService } from 'src/app/core'
import { ErrorHandlerService } from 'src/app/core/error-handler/error-handler.service'

@Component({
selector: 'app-link-account',
Expand All @@ -33,7 +34,8 @@ export class LinkAccountComponent implements OnInit {
private _user: UserService,
private _disco: DiscoService,
private _oauthService: OauthService,
private _router: Router
private _router: Router,
private _errorHandler: ErrorHandlerService
) {
this._user
.getUserSession()
Expand Down Expand Up @@ -74,4 +76,60 @@ export class LinkAccountComponent implements OnInit {
})
})
}
forgotPassword() {
this._platformInfo
.get()
.pipe(first())
.subscribe((platform) => {
this._router.navigate(['/reset-password'], {
queryParams: platform.queryParameters,
})
})
}


register() {
// always send the user with all query parameters
this._platformInfo
.get()
.pipe(first())
.subscribe((platform) => {
if (platform.social || platform.institutional) {
if (this.signInData) {
const { providerId, linkType } = this.signInData
this._user
.getUserSession()
.pipe(first())
.subscribe((userSession) => {
const params = platform.queryParameters
this._router.navigate(['/register'], {
/// TODO @leomendoza123 depend only on the user session thirty party login data
/// avoid taking data from the the parameters.

queryParams: {
...params,
providerId,
linkType,
},
})
}, (error) => {
this._router.navigate(['/register'], {
queryParams: platform.queryParameters,
})
})
} else {
this._router.navigate(['/register'], {
queryParams: platform.queryParameters,
})
this._errorHandler.handleError(new Error('signingMissingData'))
}
} else {
this._router.navigate(['/register'], {
queryParams: platform.queryParameters,
})
}
})
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
>
</app-two-factor-authentication-form>
<a
*ngIf="showForgotYourPassword"
class="row forgot"
i18n="@@ngOrcid.signin.forgotYourPassword"
(click)="forgotPassword()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class FormSignInComponent implements OnInit, AfterViewInit, OnDestroy {
@Output() show2FAEmitter = new EventEmitter<object>()
@Output() loading = new EventEmitter<boolean>()
@Output() errorDescription = new EventEmitter<string>()
@Input() showForgotYourPassword = true

badCredentials = false
printError = false
Expand Down
2 changes: 1 addition & 1 deletion src/locale/properties/linking/linking.en.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
linking.title.1=Link your
linking.title.2=account to your ORCID record
linking.title.2=account
linking.signed=You are signed into
linking.as=as
linking.finish=To link your
Expand Down

0 comments on commit 5383430

Please sign in to comment.