@@ -85,7 +85,7 @@
{{'bitstream-request-a-copy.header' | translate}}
{{'bitstream-request-a-copy.return' | translate}}
diff --git a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
index 384b6986fa6..bd627e1274c 100644
--- a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
+++ b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input, OnDestroy, OnInit } from '@angular/core';
+import { ChangeDetectorRef, Component, Input, OnDestroy, OnInit } from '@angular/core';
import { filter, map, startWith, switchMap, take } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
@@ -60,12 +60,18 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
* Return true if the user completed the reCaptcha verification (checkbox mode)
*/
checkboxCheckedSubject$ = new BehaviorSubject
(false);
+ disableUntilChecked = true;
captchaVersion(): Observable {
+ this.cdRef.detectChanges();
+ console.log(this.googleRecaptchaService.captchaVersion())
return this.googleRecaptchaService.captchaVersion();
+
}
captchaMode(): Observable {
+ this.cdRef.detectChanges();
+ console.log(this.googleRecaptchaService.captchaMode())
return this.googleRecaptchaService.captchaMode();
}
@@ -82,6 +88,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
private bitstreamService: BitstreamDataService,
public cookieService: CookieService,
public googleRecaptchaService: GoogleRecaptchaService,
+ private cdRef:ChangeDetectorRef
) {
}
@@ -133,6 +140,11 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
}
}));
this.initValues();
+
+ this.subscriptions.push(this.disableUntilCheckedFcn().subscribe((res) => {
+ this.disableUntilChecked = res;
+ this.cdRef.detectChanges();
+ }));
}
get name() {
@@ -224,6 +236,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
* Navigates back to the user's previous location
*/
navigateBack() {
+ this.resetForm();
this.location.back();
}
@@ -249,6 +262,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
* Register an email address
*/
register(tokenV2?) {
+ debugger;
console.log('1',this.registrationVerification)
if (!this.requestCopyForm.invalid) {
if (!this.registrationVerification) {
@@ -276,6 +290,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
// this.onSubmit();
this.registrationVerification = true;
+
console.log('7',this.registrationVerification)
} else {
console.log('8',this.registrationVerification)
@@ -315,6 +330,13 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
onCheckboxChecked(checked: boolean) {
this.checkboxCheckedSubject$.next(checked);
+ if(!!checked) {
+ console.log(this.requestCopyForm.invalid);
+ if (!this.requestCopyForm.invalid) {
+ this.registrationVerification = true;
+ this.cdRef.detectChanges();
+ }
+ }
}
/**
@@ -336,5 +358,16 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
console.warn(`Unimplemented notification '${key}' from reCaptcha service`);
}
}
+
+ resetForm() {
+ this.requestCopyForm.reset();
+ }
+
+ changeCatch() {
+ if (!this.requestCopyForm.invalid) {
+ this.registrationVerification = true;
+ this.cdRef.detectChanges();
+ }
+ }
}
diff --git a/src/app/register-email-form/register-email-form.component.ts b/src/app/register-email-form/register-email-form.component.ts
index df7e9bea5ef..bbda00035d9 100644
--- a/src/app/register-email-form/register-email-form.component.ts
+++ b/src/app/register-email-form/register-email-form.component.ts
@@ -148,6 +148,7 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
* Register an email address
*/
register(tokenV2?) {
+ debugger;
if (!this.form.invalid) {
if (this.registrationVerification) {
this.subscriptions.push(combineLatest([this.captchaVersion(), this.captchaMode()]).pipe(
@@ -225,6 +226,7 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
}
onCheckboxChecked(checked: boolean) {
+ debugger;
this.checkboxCheckedSubject$.next(checked);
}
From 5e08706386c7f9e90b6048e06f5b525049b0ae1b Mon Sep 17 00:00:00 2001
From: gaurav patel <100828173+GauravD2t@users.noreply.github.com>
Date: Mon, 11 Dec 2023 14:20:18 +0530
Subject: [PATCH 04/12] with some changes
with some changes
---
.../bitstream-request-a-copy-page.component.ts | 4 +---
.../register-email-form/register-email-form.component.ts | 6 ++----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
index bd627e1274c..c9980628e05 100644
--- a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
+++ b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
@@ -64,14 +64,12 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
captchaVersion(): Observable {
this.cdRef.detectChanges();
- console.log(this.googleRecaptchaService.captchaVersion())
return this.googleRecaptchaService.captchaVersion();
}
captchaMode(): Observable {
this.cdRef.detectChanges();
- console.log(this.googleRecaptchaService.captchaMode())
return this.googleRecaptchaService.captchaMode();
}
@@ -88,7 +86,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
private bitstreamService: BitstreamDataService,
public cookieService: CookieService,
public googleRecaptchaService: GoogleRecaptchaService,
- private cdRef:ChangeDetectorRef
+ private cdRef: ChangeDetectorRef
) {
}
diff --git a/src/app/register-email-form/register-email-form.component.ts b/src/app/register-email-form/register-email-form.component.ts
index bbda00035d9..dbebe678d90 100644
--- a/src/app/register-email-form/register-email-form.component.ts
+++ b/src/app/register-email-form/register-email-form.component.ts
@@ -66,11 +66,11 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
subscriptions: Subscription[] = [];
- captchaVersion(): Observable {
+captchaVersion(): Observable {
return this.googleRecaptchaService.captchaVersion();
}
- captchaMode(): Observable {
+captchaMode(): Observable {
return this.googleRecaptchaService.captchaMode();
}
@@ -148,7 +148,6 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
* Register an email address
*/
register(tokenV2?) {
- debugger;
if (!this.form.invalid) {
if (this.registrationVerification) {
this.subscriptions.push(combineLatest([this.captchaVersion(), this.captchaMode()]).pipe(
@@ -226,7 +225,6 @@ export class RegisterEmailFormComponent implements OnDestroy, OnInit {
}
onCheckboxChecked(checked: boolean) {
- debugger;
this.checkboxCheckedSubject$.next(checked);
}
From a5c7eb240f21d6796ca0434cba4a7a9b22baf465 Mon Sep 17 00:00:00 2001
From: gaurav patel <100828173+GauravD2t@users.noreply.github.com>
Date: Mon, 11 Dec 2023 14:44:01 +0530
Subject: [PATCH 05/12] with chnages
with changes
---
...bitstream-request-a-copy-page.component.ts | 138 ++++++++----------
1 file changed, 63 insertions(+), 75 deletions(-)
diff --git a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
index c9980628e05..53c364389ba 100644
--- a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
+++ b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts
@@ -51,21 +51,21 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
*/
registrationVerification = false;
subscriptions: Subscription[] = [];
- /**
- * The message prefix
- */
- @Input()
- MESSAGE_PREFIX: string;
- /**
- * Return true if the user completed the reCaptcha verification (checkbox mode)
- */
+ /**
+ * The message prefix
+ */
+ @Input()
+ MESSAGE_PREFIX: string;
+ /**
+ * Return true if the user completed the reCaptcha verification (checkbox mode)
+ */
checkboxCheckedSubject$ = new BehaviorSubject(false);
disableUntilChecked = true;
captchaVersion(): Observable {
this.cdRef.detectChanges();
return this.googleRecaptchaService.captchaVersion();
-
+
}
captchaMode(): Observable {
@@ -74,19 +74,19 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
}
constructor(private location: Location,
- private translateService: TranslateService,
- private route: ActivatedRoute,
- protected router: Router,
- private authorizationService: AuthorizationDataService,
- private auth: AuthService,
- private formBuilder: UntypedFormBuilder,
- private itemRequestDataService: ItemRequestDataService,
- private notificationsService: NotificationsService,
- private dsoNameService: DSONameService,
- private bitstreamService: BitstreamDataService,
- public cookieService: CookieService,
- public googleRecaptchaService: GoogleRecaptchaService,
- private cdRef: ChangeDetectorRef
+ private translateService: TranslateService,
+ private route: ActivatedRoute,
+ protected router: Router,
+ private authorizationService: AuthorizationDataService,
+ private auth: AuthService,
+ private formBuilder: UntypedFormBuilder,
+ private itemRequestDataService: ItemRequestDataService,
+ private notificationsService: NotificationsService,
+ private dsoNameService: DSONameService,
+ private bitstreamService: BitstreamDataService,
+ public cookieService: CookieService,
+ public googleRecaptchaService: GoogleRecaptchaService,
+ private cdRef: ChangeDetectorRef
) {
}
@@ -134,7 +134,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
this.subs.push(observableCombineLatest([this.canDownload$, canRequestCopy$]).subscribe(([canDownload, canRequestCopy]) => {
if (!canDownload && !canRequestCopy) {
- this.router.navigateByUrl(getForbiddenRoute(), {skipLocationChange: true});
+ this.router.navigateByUrl(getForbiddenRoute(), { skipLocationChange: true });
}
}));
this.initValues();
@@ -166,13 +166,13 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
*/
private initValues() {
this.getCurrentUser().pipe(take(1)).subscribe((user) => {
- this.requestCopyForm.patchValue({allfiles: 'true'});
+ this.requestCopyForm.patchValue({ allfiles: 'true' });
if (hasValue(user)) {
- this.requestCopyForm.patchValue({name: user.name, email: user.email});
+ this.requestCopyForm.patchValue({ name: user.name, email: user.email });
}
});
this.bitstream$.pipe(take(1)).subscribe((bitstream) => {
- this.requestCopyForm.patchValue({allfiles: 'false'});
+ this.requestCopyForm.patchValue({ allfiles: 'false' });
});
}
@@ -260,22 +260,15 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
* Register an email address
*/
register(tokenV2?) {
- debugger;
- console.log('1',this.registrationVerification)
if (!this.requestCopyForm.invalid) {
if (!this.registrationVerification) {
- console.log('2',this.registrationVerification)
this.subscriptions.push(combineLatest([this.captchaVersion(), this.captchaMode()]).pipe(
- switchMap(([captchaVersion, captchaMode]) => {
- console.log('3',this.registrationVerification)
+ switchMap(([captchaVersion, captchaMode]) => {
if (captchaVersion === 'v3') {
- console.log('4',this.registrationVerification)
return this.googleRecaptchaService.getRecaptchaToken('register_email');
} else if (captchaVersion === 'v2' && captchaMode === 'checkbox') {
- console.log('5',this.registrationVerification)
return of(this.googleRecaptchaService.getRecaptchaTokenResponse());
} else if (captchaVersion === 'v2' && captchaMode === 'invisible') {
- console.log('6',this.registrationVerification)
return of(tokenV2);
} else {
console.error(`Invalid reCaptcha configuration: version = ${captchaVersion}, mode = ${captchaMode}`);
@@ -284,24 +277,20 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
}),
take(1),
).subscribe((token) => {
- if (isNotEmpty(token)) {
- // this.onSubmit();
-
- this.registrationVerification = true;
+ if (isNotEmpty(token)) {
+ // this.onSubmit();
- console.log('7',this.registrationVerification)
- } else {
- console.log('8',this.registrationVerification)
- console.error('reCaptcha error');
- this.showNotification('error');
- }
+ this.registrationVerification = true;
+
+ } else {
+ this.showNotification('error');
}
+ }
));
} else {
-
+
// this.onSubmit();
this.registrationVerification = true;
- console.log('3',this.registrationVerification)
}
}
}
@@ -321,14 +310,14 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
const checked$ = this.checkboxCheckedSubject$.asObservable();
return combineLatest([this.captchaVersion(), this.captchaMode(), checked$]).pipe(
// disable if checkbox is not checked or if reCaptcha is not in v2 checkbox mode
- switchMap(([captchaVersion, captchaMode, checked]) => captchaVersion === 'v2' && captchaMode === 'checkbox' ? of(!checked) : of(false)),
+ switchMap(([captchaVersion, captchaMode, checked]) => captchaVersion === 'v2' && captchaMode === 'checkbox' ? of(!checked) : of(false)),
startWith(true),
);
}
onCheckboxChecked(checked: boolean) {
this.checkboxCheckedSubject$.next(checked);
- if(!!checked) {
+ if (!!checked) {
console.log(this.requestCopyForm.invalid);
if (!this.requestCopyForm.invalid) {
this.registrationVerification = true;
@@ -337,35 +326,34 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
}
}
- /**
- * Show a notification to the user
- * @param key
- */
- showNotification(key) {
- const notificationTitle = this.translateService.get(this.MESSAGE_PREFIX + '.google-recaptcha.notification.title');
- const notificationErrorMsg = this.translateService.get(this.MESSAGE_PREFIX + '.google-recaptcha.notification.message.error');
- const notificationExpiredMsg = this.translateService.get(this.MESSAGE_PREFIX + '.google-recaptcha.notification.message.expired');
- switch (key) {
- case 'expired':
- this.notificationsService.warning(notificationTitle, notificationExpiredMsg);
- break;
- case 'error':
- this.notificationsService.error(notificationTitle, notificationErrorMsg);
- break;
- default:
- console.warn(`Unimplemented notification '${key}' from reCaptcha service`);
- }
+ /**
+ * Show a notification to the user
+ * @param key
+ */
+ showNotification(key) {
+ const notificationTitle = this.translateService.get(this.MESSAGE_PREFIX + '.google-recaptcha.notification.title');
+ const notificationErrorMsg = this.translateService.get(this.MESSAGE_PREFIX + '.google-recaptcha.notification.message.error');
+ const notificationExpiredMsg = this.translateService.get(this.MESSAGE_PREFIX + '.google-recaptcha.notification.message.expired');
+ switch (key) {
+ case 'expired':
+ this.notificationsService.warning(notificationTitle, notificationExpiredMsg);
+ break;
+ case 'error':
+ this.notificationsService.error(notificationTitle, notificationErrorMsg);
+ break;
+ default:
+ console.warn(`Unimplemented notification '${key}' from reCaptcha service`);
}
+ }
- resetForm() {
- this.requestCopyForm.reset();
- }
+ resetForm() {
+ this.requestCopyForm.reset();
+ }
- changeCatch() {
- if (!this.requestCopyForm.invalid) {
- this.registrationVerification = true;
- this.cdRef.detectChanges();
- }
+ changeCatch() {
+ if (!this.requestCopyForm.invalid) {
+ this.registrationVerification = true;
+ this.cdRef.detectChanges();
}
-
+ }
}
From e69918ab4bafd7877644506710596a7f268e7560 Mon Sep 17 00:00:00 2001
From: gaurav patel <100828173+GauravD2t@users.noreply.github.com>
Date: Wed, 13 Dec 2023 10:54:48 +0530
Subject: [PATCH 06/12] with somechanges
---
.../request-a-copy/bitstream-request-a-copy-page.component.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.html b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.html
index 95563bb7093..bc968b6ee2a 100644
--- a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.html
+++ b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.html
@@ -87,7 +87,7 @@ {{'bitstream-request-a-copy.header' | translate}}
+ (click)="onSubmit()">{{'bitstream-request-a-copy.submit' | translate}}
From 262975b2e5fd0f8e6b3cb060eb5f2beb47fc0445 Mon Sep 17 00:00:00 2001
From: gaurav patel <100828173+GauravD2t@users.noreply.github.com>
Date: Mon, 18 Dec 2023 17:55:10 +0530
Subject: [PATCH 07/12] Addea TOken TO header
---
src/app/core/data/item-request-data.service.ts | 11 +++++++++--
.../bitstream-request-a-copy-page.component.ts | 6 +++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/app/core/data/item-request-data.service.ts b/src/app/core/data/item-request-data.service.ts
index ff6025f7ac8..b14921a66e8 100644
--- a/src/app/core/data/item-request-data.service.ts
+++ b/src/app/core/data/item-request-data.service.ts
@@ -50,15 +50,22 @@ export class ItemRequestDataService extends IdentifiableDataService