From 9f2b475ff380bbdc185e790d71216e02b2a8386b Mon Sep 17 00:00:00 2001 From: John Pinto Date: Tue, 29 Oct 2024 14:05:57 +0000 Subject: [PATCH] Several changes: - Changed the body background_color to white (#ffffff). - Updated full-file-section.component.ts to be consistent with use of options. - Started work on introducing links to End-User License and Depositor Agreement to Simple Item View page. --- .../full-file-section.component.ts | 8 +- .../file-section/file-section.component.html | 27 ++++++ .../file-section/file-section.component.ts | 93 ++++++++++++++++++- .../datashare/styles/_global-styles.scss | 2 +- 4 files changed, 124 insertions(+), 6 deletions(-) diff --git a/src/themes/datashare/app/item-page/full/field-components/file-section/full-file-section.component.ts b/src/themes/datashare/app/item-page/full/field-components/file-section/full-file-section.component.ts index 7df422f5957..45d878fce4b 100644 --- a/src/themes/datashare/app/item-page/full/field-components/file-section/full-file-section.component.ts +++ b/src/themes/datashare/app/item-page/full/field-components/file-section/full-file-section.component.ts @@ -45,9 +45,15 @@ import { hasValue } from '../../../../../../../app/shared/empty.util'; export class FullFileSectionComponent extends BaseComponent { cclicenses$: Observable>>; + cclicenseOptions = Object.assign(new PaginationComponentOptions(), { + id: 'cclbo', + currentPage: 1, + pageSize: this.appConfig.item.bitstream.pageSize, + }); + initialize(): void { super.initialize(); - this.cclicenses$ = this.paginationService.getCurrentPagination(this.licenseOptions.id, this.licenseOptions).pipe( + this.cclicenses$ = this.paginationService.getCurrentPagination(this.cclicenseOptions.id, this.cclicenseOptions).pipe( switchMap((options: PaginationComponentOptions) => this.bitstreamDataService.findAllByItemAndBundleName( this.item, 'CC-LICENSE', diff --git a/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.html b/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.html index 8b137891791..7ca9b59f83a 100644 --- a/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.html +++ b/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.html @@ -1 +1,28 @@ + + +
+ + + {{ 'item.page.bitstreams.primary' | translate }} + {{ dsoNameService.getName(file) }} + + ({{(file?.sizeBytes) | dsFileSize }}) + + + +
+ +
+
+ +
+
+
+
+ The licence files associated with this item: +
End-user License
+
Depositor Agreement
+ +
+
\ No newline at end of file diff --git a/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.ts b/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.ts index e39f7536eb0..d0f8097ce78 100644 --- a/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.ts +++ b/src/themes/datashare/app/item-page/simple/field-components/file-section/file-section.component.ts @@ -1,6 +1,6 @@ import { CommonModule } from '@angular/common'; -import { Component } from '@angular/core'; -import { TranslateModule } from '@ngx-translate/core'; +import { Component, Inject } from '@angular/core'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { FileSectionComponent as BaseComponent } from '../../../../../../../app/item-page/simple/field-components/file-section/file-section.component'; import { slideSidebarPadding } from '../../../../../../../app/shared/animations/slide'; @@ -9,11 +9,24 @@ import { ThemedLoadingComponent } from '../../../../../../../app/shared/loading/ import { MetadataFieldWrapperComponent } from '../../../../../../../app/shared/metadata-field-wrapper/metadata-field-wrapper.component'; import { FileSizePipe } from '../../../../../../../app/shared/utils/file-size-pipe'; import { VarDirective } from '../../../../../../../app/shared/utils/var.directive'; +import { getFirstCompletedRemoteData } from '../../../../../../../app/core/shared/operators'; +import { map, Observable, switchMap, tap } from 'rxjs'; +import { RemoteData } from '../../../../../../../app/core/data/remote-data'; +import { PaginatedList } from '../../../../../../../app/core/data/paginated-list.model'; +import { Bitstream } from '../../../../../../../app/core/shared/bitstream.model'; +import { hasValue } from '../../../../../../../app/shared/empty.util'; +import { PaginationComponentOptions } from '../../../../../../../app/shared/pagination/pagination-component-options.model'; +import { followLink } from '../../../../../../../app/shared/utils/follow-link-config.model'; +import { BitstreamDataService } from '../../../../../../../app/core/data/bitstream-data.service'; +import { NotificationsService } from '../../../../../../../app/shared/notifications/notifications.service'; +import { DSONameService } from '../../../../../../../app/core/breadcrumbs/dso-name.service'; +import { APP_CONFIG, AppConfig } from 'src/config/app-config.interface'; +import { PaginationService } from '../../../../../../../app/core/pagination/pagination.service'; @Component({ selector: 'ds-themed-item-page-file-section', - // templateUrl: './file-section.component.html', - templateUrl: '../../../../../../../app/item-page/simple/field-components/file-section/file-section.component.html', + templateUrl: './file-section.component.html', + // templateUrl: '../../../../../../../app/item-page/simple/field-components/file-section/file-section.component.html', animations: [slideSidebarPadding], standalone: true, imports: [ @@ -28,4 +41,76 @@ import { VarDirective } from '../../../../../../../app/shared/utils/var.directiv }) export class FileSectionComponent extends BaseComponent { + cclicenses$: Observable>>; + licenses$: Observable>>; + + cclicenseOptions = Object.assign(new PaginationComponentOptions(), { + id: 'cclbo', + currentPage: 1, + pageSize: 1, + }); + + licenseOptions = Object.assign(new PaginationComponentOptions(), { + id: 'lbo', + currentPage: 1, + pageSize: 1, + }); + + + constructor( + protected bitstreamDataService: BitstreamDataService, + protected notificationsService: NotificationsService, + protected translateService: TranslateService, + protected paginationService: PaginationService, + public dsoNameService: DSONameService, + @Inject(APP_CONFIG) protected appConfig: AppConfig, + ) { + super(bitstreamDataService, notificationsService, translateService, dsoNameService, appConfig); + + } + + ngOnInit(): void { + super.ngOnInit(); + this.initialize(); + } + + initialize(): void { + this.cclicenses$ = this.paginationService.getCurrentPagination(this.cclicenseOptions.id, this.cclicenseOptions).pipe( + switchMap((options: PaginationComponentOptions) => this.bitstreamDataService.findAllByItemAndBundleName( + this.item, + 'CC-LICENSE', + { elementsPerPage: options.pageSize, currentPage: options.currentPage }, + true, + true, + followLink('format'), + followLink('thumbnail'), + )), + tap((rd: RemoteData>) => { + if (hasValue(rd.errorMessage)) { + this.notificationsService.error(this.translateService.get('file-section.error.header'), `${rd.statusCode} ${rd.errorMessage}`); + } + }, + ), + ); + + this.licenses$ = this.paginationService.getCurrentPagination(this.licenseOptions.id, this.licenseOptions).pipe( + switchMap((options: PaginationComponentOptions) => this.bitstreamDataService.findAllByItemAndBundleName( + this.item, + 'LICENSE', + { elementsPerPage: options.pageSize, currentPage: options.currentPage }, + true, + true, + followLink('format'), + followLink('thumbnail'), + )), + tap((rd: RemoteData>) => { + if (hasValue(rd.errorMessage)) { + this.notificationsService.error(this.translateService.get('file-section.error.header'), `${rd.statusCode} ${rd.errorMessage}`); + } + }, + ), + ); + + } + } diff --git a/src/themes/datashare/styles/_global-styles.scss b/src/themes/datashare/styles/_global-styles.scss index f7995c9d12d..2657701cf17 100644 --- a/src/themes/datashare/styles/_global-styles.scss +++ b/src/themes/datashare/styles/_global-styles.scss @@ -52,7 +52,7 @@ body { line-height: 1.5; color: #212529; text-align: left; - background-color: #f0f0f0; + background-color: #ffffff; } .lead {