Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ <h2 id="header" class="border-bottom pb-2">{{'clarin.license.agreement.title' |
</div>
<div class="row pt-3">
<div class="col-12">
<button class="btn btn-success max-width" [disabled]="error$.value.length !== 0" (click)="accept()">
<button class="btn btn-success max-width" [disabled]="error$.value.length !== 0 || (isLoading | async)" (click)="accept()">
{{'clarin.license.agreement.button.agree' | translate}}
<span
*ngIf="isLoading | async"
class="ml-1 spinner-border spinner-border-sm"
role="status"
aria-hidden="true"
></span>
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, OnInit } from '@angular/core';
import { Bitstream } from '../../core/shared/bitstream.model';
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
import { switchMap, take } from 'rxjs/operators';
import { finalize, switchMap, take } from 'rxjs/operators';
import { followLink } from '../../shared/utils/follow-link-config.model';
import { ClarinUserRegistration } from '../../core/shared/clarin/clarin-user-registration.model';
import { ClarinUserMetadata } from '../../core/shared/clarin/clarin-user-metadata.model';
Expand Down Expand Up @@ -122,6 +122,11 @@ export class ClarinLicenseAgreementPageComponent implements OnInit {
*/
licenseContentSeznam: BehaviorSubject<string> = new BehaviorSubject<string>('');

/**
* Indicates when the submission is in progress and resets after completion
*/
isLoading: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);

constructor(
protected clarinLicenseResourceMappingService: ClarinLicenseResourceMappingService,
protected configurationDataService: ConfigurationDataService,
Expand Down Expand Up @@ -186,6 +191,8 @@ export class ClarinLicenseAgreementPageComponent implements OnInit {
return;
}

this.isLoading.next(true);

const requestId = this.requestService.generateRequestId();
// Response type must be `text` because it throws response as error byd status code is 200 (Success).
const requestOptions: HttpOptions = Object.create({
Expand Down Expand Up @@ -216,7 +223,7 @@ export class ClarinLicenseAgreementPageComponent implements OnInit {
const response = this.rdbService.buildFromRequestUUID(requestId);
// Process response
response
.pipe(getFirstCompletedRemoteData())
.pipe(getFirstCompletedRemoteData(), finalize(() => this.isLoading.next(false)))
.subscribe(responseRD$ => {
if (hasFailed(responseRD$.state)) {
this.notificationService.error(
Expand Down