diff --git a/service/src/main/inse/projects/logic.py b/service/src/main/inse/projects/logic.py index 5683280a..d224fc7f 100644 --- a/service/src/main/inse/projects/logic.py +++ b/service/src/main/inse/projects/logic.py @@ -36,10 +36,11 @@ async def is_projects_access_forbidden( authors_profile = await author_service.get_author_by_id(raw_oa_author_id) if not authors_profile: return True # Author not found, access forbidden - - authors_last_known_institution_ids = [inst.id.split("/")[-1] for inst in authors_profile.last_known_institutions] - print(f"Author's last known institution IDs: {authors_last_known_institution_ids}") - if effective_institution_id not in authors_last_known_institution_ids: + + authors_last_known_institution_ids = [inst.id.split("/")[-1] for inst in (authors_profile.last_known_institutions)] + authors_affiliation_institution_ids = [aff.institution.id.split("/")[-1] for aff in (authors_profile.affiliations)] + print(f"Author's last known institution IDs: {authors_last_known_institution_ids}, {authors_affiliation_institution_ids}") + if effective_institution_id not in authors_last_known_institution_ids and effective_institution_id not in authors_affiliation_institution_ids: return True # Effective institution ID does not match any of the author's last known institutions return False diff --git a/service/src/main/inse/projects/projects_search_client.py b/service/src/main/inse/projects/projects_search_client.py index f3b2f1e2..454622aa 100644 --- a/service/src/main/inse/projects/projects_search_client.py +++ b/service/src/main/inse/projects/projects_search_client.py @@ -1151,11 +1151,13 @@ async def search_all_projects( page = projects_filtering_properties.page offset = page * size response = await elasticsearch.search( + index=index, size=size, offset=offset, query=query, sort=sort, + track_total_hits=True, ) return _response_to_funding_project_page(response=response, page=page, size=size) diff --git a/service/src/main/inse/projects/router.py b/service/src/main/inse/projects/router.py index 6382f575..d0430d63 100644 --- a/service/src/main/inse/projects/router.py +++ b/service/src/main/inse/projects/router.py @@ -273,7 +273,6 @@ async def search_bund_projects( detail="Access denied for the provided author ID or institution ID", ) return await projects_service.search_bund_projects_with_filters( - access_token_metadata=access_token_metadata, institutions_search_client=institutions_search_client, executing_agency=executing_agency, funding_arts=funding_arts, diff --git a/webapp/src/app/custom-directives/sk-text.directive.ts b/webapp/src/app/custom-directives/sk-text.directive.ts index e7173238..14246539 100644 --- a/webapp/src/app/custom-directives/sk-text.directive.ts +++ b/webapp/src/app/custom-directives/sk-text.directive.ts @@ -1,76 +1,84 @@ import { Directive, - OnChanges, - Input, ElementRef, + Input, + OnChanges, Renderer2, + SimpleChanges, + effect, + inject, } from '@angular/core'; -import { SimpleChanges } from '@angular/core'; -@Directive({ selector: '[skText]', standalone: true }) +import { ResolverStateService } from '../../app/shared/services/resolver-state.service'; + +@Directive({ + selector: 'span, [skText]', + standalone: true, +}) export class SkTextDirective implements OnChanges { + /** + * Optional manual loading state. + * The directive also reacts to global route/resolver loading. + */ @Input() skText = false; - private originalText = ''; - private originalColor = ''; + private readonly el = inject(ElementRef); + private readonly renderer = inject(Renderer2); + private readonly resolverStateService = inject(ResolverStateService); - constructor( - private el: ElementRef, - private renderer: Renderer2, - ) {} + constructor() { + effect(() => { + const loading = this.skText || this.resolverStateService.isResolving(); - ngOnChanges(changes: SimpleChanges) { - const change = changes['skText']; - - // skip if value didn't actually change, or is undefined - if (!change) return; - - this.skText ? this.showSkeleton() : this.hideSkeleton(); + if (loading) { + this.showSkeleton(); + } else { + this.hideSkeleton(); + } + }); } - private showSkeleton() { - const el: HTMLElement = this.el.nativeElement; - this.originalText = el.textContent ?? ''; - this.originalColor = el.style.color; + ngOnChanges(changes: SimpleChanges): void { + if (!changes['skText']) { + return; + } - // measure natural width before blanking text - const width = Math.min(Math.max(this.originalText.length * 7.5, 48), 60); - const height = 20; - this.renderer.addClass(el, 'sk-text-loading'); - this.renderer.setStyle(el, 'color', 'transparent'); - this.renderer.setStyle( - el, - 'background', - 'linear-gradient(90deg, #e2e8f0 25%, #f8fafc 50%, #e2e8f0 75%)', - ); - this.renderer.setStyle(el, 'background-size', '600px 100%'); - this.renderer.setStyle(el, 'animation', 'sk-shimmer 1.6s infinite linear'); - this.renderer.setStyle(el, 'border-radius', '4px'); - this.renderer.setStyle(el, 'min-width', `${width}px`); - this.renderer.setStyle(el, 'max-height', `${height}px`); - this.renderer.setStyle(el, 'display', 'inline-block'); - this.renderer.setStyle(el, 'overflow', 'hidden'); - this.renderer.setStyle(el, 'pointer-events', 'none'); + if (this.skText || this.resolverStateService.isResolving()) { + this.showSkeleton(); + } else { + this.hideSkeleton(); + } + } - Array.from(el.children).forEach((child) => { + private showSkeleton(): void { + const element = this.el.nativeElement; + + if (element.classList.contains('sk-text-loading')) { + return; + } + + const text = element.textContent?.trim() ?? ''; + + // For ordinary text elements only. Table cells use CSS width naturally. + if (element.tagName.toLowerCase() !== 'td') { + this.renderer.setStyle(element, 'min-width', `${20}px`); + this.renderer.setStyle(element, 'height', '20px'); + } + + this.renderer.addClass(element, 'sk-text-loading'); + + Array.from(element.children).forEach((child) => { this.renderer.setStyle(child, 'visibility', 'hidden'); }); } - private hideSkeleton() { - const el: HTMLElement = this.el.nativeElement; - this.renderer.removeClass(el, 'sk-text-loading'); - this.renderer.removeStyle(el, 'color'); - this.renderer.removeStyle(el, 'background'); - this.renderer.removeStyle(el, 'background-size'); - this.renderer.removeStyle(el, 'animation'); - this.renderer.removeStyle(el, 'border-radius'); - this.renderer.removeStyle(el, 'min-width'); - this.renderer.removeStyle(el, 'max-height'); - this.renderer.removeStyle(el, 'display'); - this.renderer.removeStyle(el, 'overflow'); - this.renderer.removeStyle(el, 'pointer-events'); + private hideSkeleton(): void { + const element = this.el.nativeElement; - Array.from(el.children).forEach((child) => { + this.renderer.removeClass(element, 'sk-text-loading'); + this.renderer.removeStyle(element, 'min-width'); + this.renderer.removeStyle(element, 'height'); + + Array.from(element.children).forEach((child) => { this.renderer.removeStyle(child, 'visibility'); }); } diff --git a/webapp/src/styles.scss b/webapp/src/styles.scss index 95a45697..69543f81 100644 --- a/webapp/src/styles.scss +++ b/webapp/src/styles.scss @@ -104,6 +104,7 @@ body { /* Centralized Design Tokens (Semantic CSS Custom Properties) */ :root { /* Light Theme Palette */ + --sg-background: #ffffff; --sg-surface: #ffffff; --sg-surface-muted: #f7f9ff; @@ -146,7 +147,9 @@ body { --sg-banner-warning-text: #9a3412; --sg-option-hover: rgba(0, 0, 0, 0.04); --sg-avatar-gradient: linear-gradient(135deg, #dce8ff, #ffffff); - + /* Skeleton loading */ + --sg-skeleton-base: #e5ebf5; + --sg-skeleton-highlight: #f7f9ff; @include mat.button-toggle-overrides( ( shape: var(--sg-radius-sm), @@ -263,6 +266,9 @@ html.dark-theme { --sg-banner-warning-text: #ffb74d; --sg-option-hover: rgba(255, 255, 255, 0.06); --sg-avatar-gradient: linear-gradient(135deg, #1c2a4a, #131b2e); + /* Skeleton loading */ + --sg-skeleton-base: #202d49; + --sg-skeleton-highlight: #2b3b5d; } /* Theme-Based Scrollbars (W3C Standard & WebKit Engine) */ @@ -462,16 +468,47 @@ html.dark-theme { --mat-icon-button-icon-color: #ffffff; } +/* Theme-aware text skeleton */ +.sk-text-loading { + display: inline-block; + overflow: hidden; + min-height: 1em; + color: transparent !important; + pointer-events: none; + user-select: none; + border-radius: 4px; + vertical-align: middle; + + background: linear-gradient( + 90deg, + var(--sg-skeleton-base) 25%, + var(--sg-skeleton-highlight) 50%, + var(--sg-skeleton-base) 75% + ); + background-size: 600px 100%; + animation: sk-shimmer 1.6s infinite linear; +} + +.sk-text-loading > * { + visibility: hidden; +} + @keyframes sk-shimmer { - 0% { + from { background-position: -600px 0; } - 100% { + + to { background-position: 600px 0; } } -.cdk-overlay-pane { - color: var(--sg-text); + +/* Do not animate for users who request reduced motion */ +@media (prefers-reduced-motion: reduce) { + .sk-text-loading { + animation: none; + background: var(--sg-skeleton-base); + } } .topic-chip-tooltip,