Skip to content

Commit

Permalink
Retrieve the configuration values from the backend...
Browse files Browse the repository at this point in the history
... rather than from a frontend configuration
  • Loading branch information
abelgomez committed Oct 9, 2024
1 parent 0ad309e commit 8f9125c
Showing 1 changed file with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
OnInit,
} from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { map } from 'rxjs';

Check failure on line 12 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'map' is defined but never used

Check failure on line 12 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

'map' is defined but never used
import { ConfigurationDataService } from 'src/app/core/data/configuration-data.service';
import { RemoteData } from 'src/app/core/data/remote-data';

Check failure on line 14 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'RemoteData' is defined but never used

Check failure on line 14 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

'RemoteData' is defined but never used
import { ConfigurationProperty } from 'src/app/core/shared/configuration-property.model';

Check failure on line 15 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'ConfigurationProperty' is defined but never used

Check failure on line 15 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

'ConfigurationProperty' is defined but never used
import { Item } from 'src/app/core/shared/item.model';
import { getFirstCompletedRemoteData, getRemoteDataPayload } from 'src/app/core/shared/operators';

Check failure on line 17 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Imports must be broken into multiple lines if there are more than 1 elements

Check failure on line 17 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Imports must be broken into multiple lines if there are more than 1 elements
import { MetadataFieldWrapperComponent } from 'src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component';

@Component({
Expand All @@ -33,18 +38,6 @@ export class ItemPageCcLicenseFieldComponent implements OnInit {
*/
@Input() variant?: 'small' | 'full' = 'small';

/**
* Filed name containing the CC license URI, as configured in the back-end, in the 'dspace.cfg' file, property
* 'cc.license.uri'
*/
@Input() ccLicenseUriField? = 'dc.rights.uri';

/**
* Filed name containing the CC license name, as configured in the back-end, in the 'dspace.cfg' file, property
* 'cc.license.name'
*/
@Input() ccLicenseNameField? = 'dc.rights';

/**
* Shows the CC license name with the image. Always show if image fails to load
*/
Expand All @@ -55,11 +48,32 @@ export class ItemPageCcLicenseFieldComponent implements OnInit {
*/
@Input() showDisclaimer? = true;

ccLicenseUriField: string;
ccLicenseNameField: string;
uri: string;
name: string;
showImage = true;
imgSrc: string;

constructor(
private configService: ConfigurationDataService,
) {
this.configService.findByPropertyName('cc.license.uri').pipe(
getFirstCompletedRemoteData(),

Check failure on line 62 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected indentation of 6 spaces but found 8

Check failure on line 62 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Expected indentation of 6 spaces but found 8
getRemoteDataPayload()

Check failure on line 63 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected indentation of 6 spaces but found 8

Check failure on line 63 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing trailing comma

Check failure on line 63 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Expected indentation of 6 spaces but found 8

Check failure on line 63 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Missing trailing comma
).subscribe((remoteData) => {

Check failure on line 64 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected indentation of 4 spaces but found 6

Check failure on line 64 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Expected indentation of 4 spaces but found 6
this.ccLicenseNameField = remoteData.values && remoteData.values.length > 0 ? remoteData.values[0] : 'dc.rights.uri';

Check failure on line 65 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected indentation of 6 spaces but found 8

Check failure on line 65 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Expected indentation of 6 spaces but found 8
}

Check failure on line 66 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected indentation of 4 spaces but found 6

Check failure on line 66 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Expected indentation of 4 spaces but found 6
);
this.configService.findByPropertyName('dc.rights').pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload()
).subscribe((remoteData) => {
this.ccLicenseNameField = remoteData.values && remoteData.values.length > 0 ? remoteData.values[0] : 'dc.rights';
}
);
}

ngOnInit() {
this.uri = this.item.firstMetadataValue(this.ccLicenseUriField);
this.name = this.item.firstMetadataValue(this.ccLicenseNameField);
Expand Down

0 comments on commit 8f9125c

Please sign in to comment.