mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-06 21:42:49 +00:00
refactor: avoid errors in daia availability UI
This commit is contained in:
@@ -35,7 +35,7 @@ export class DaiaAvailabilityComponent
|
||||
extends DataDetailComponent
|
||||
implements OnInit
|
||||
{
|
||||
holdings: SCDaiaHoldings[];
|
||||
holdings: SCDaiaHoldings[] | undefined;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -68,8 +68,10 @@ export class DaiaAvailabilityComponent
|
||||
* Initialize
|
||||
*/
|
||||
async ngOnInit() {
|
||||
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||
await this.getAvailability(uid ?? '');
|
||||
const uid = this.route.snapshot.paramMap.get('uid');
|
||||
if (uid) {
|
||||
await this.getAvailability(uid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<ion-card>
|
||||
<ion-card-header>{{
|
||||
'hebisSearch.daia.availability' | translate
|
||||
}}</ion-card-header>
|
||||
<ion-card-header>
|
||||
{{ 'hebisSearch.daia.availability' | translate }}
|
||||
</ion-card-header>
|
||||
<ion-card-content>
|
||||
<ng-container *ngFor="let holding of holdings">
|
||||
<ion-label
|
||||
><a [href]="holding.href" target="_blank">{{
|
||||
holding.label
|
||||
}}</a></ion-label
|
||||
>
|
||||
<ion-label>
|
||||
<a [href]="holding.href" target="_blank">
|
||||
{{ holding.label }}
|
||||
</a>
|
||||
</ion-label>
|
||||
<ion-grid>
|
||||
<ion-row *ngIf="holding.signature">
|
||||
<ion-col size="3">{{
|
||||
@@ -23,7 +23,7 @@
|
||||
"
|
||||
>{{ holding.signature }}</ion-col
|
||||
>
|
||||
<ion-col size="9" *ngIf="holding.available.service === 'openaccess'">
|
||||
<ion-col size="9" *ngIf="holding.available?.service === 'openaccess'">
|
||||
<a [href]="holding.available.href" target="_blank">{{
|
||||
'hebisSearch.daia.ejournal' | translate
|
||||
}}</a>
|
||||
@@ -59,5 +59,11 @@
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ng-container>
|
||||
<ion-label *ngIf="!holdings">
|
||||
{{ 'hebisSearch.daia.unavailableAvailability' | translate }}
|
||||
</ion-label>
|
||||
<ion-label *ngIf="holdings?.length === 0">
|
||||
{{ 'hebisSearch.daia.unknownAvailability' | translate }}
|
||||
</ion-label>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
@@ -51,7 +51,8 @@ export class DaiaDataProvider extends DataProvider {
|
||||
* @param stAppsWebHttpClient TODO
|
||||
* @param storageProvider TODO
|
||||
* @param httpClient TODO
|
||||
* @param ConfigProvider TODO
|
||||
* @param configProvider TODO
|
||||
* @param logger TODO
|
||||
*/
|
||||
constructor(
|
||||
stAppsWebHttpClient: StAppsWebHttpClient,
|
||||
@@ -71,7 +72,7 @@ export class DaiaDataProvider extends DataProvider {
|
||||
);
|
||||
}
|
||||
|
||||
async getAvailability(id: string): Promise<SCDaiaHoldings[]> {
|
||||
async getAvailability(id: string): Promise<SCDaiaHoldings[] | undefined> {
|
||||
if (this.backendUrl === environment.backend_url) {
|
||||
try {
|
||||
const features = (await this.configProvider.getValue(
|
||||
@@ -81,11 +82,11 @@ export class DaiaDataProvider extends DataProvider {
|
||||
this.backendUrl = features.extern?.daia?.url;
|
||||
} else {
|
||||
this.logger.error('Daia service url undefined');
|
||||
return [];
|
||||
return undefined;
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
return [];
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return new Promise(resolve =>
|
||||
@@ -143,7 +144,8 @@ export class DaiaDataProvider extends DataProvider {
|
||||
},
|
||||
error => {
|
||||
this.logger.error(error);
|
||||
resolve([]);
|
||||
// eslint-disable-next-line unicorn/no-useless-undefined
|
||||
resolve(undefined);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -274,7 +274,9 @@
|
||||
"comment": "Kommentar",
|
||||
"order": "Bestellen",
|
||||
"issn": "ISSN",
|
||||
"ejournal": "ejournal"
|
||||
"ejournal": "ejournal",
|
||||
"unknownAvailability": "Keine Information vorhanden",
|
||||
"unavailableAvailability": "System nicht erreichbar"
|
||||
}
|
||||
},
|
||||
"schedule": {
|
||||
|
||||
@@ -274,7 +274,9 @@
|
||||
"comment": "Remark",
|
||||
"order": "Request",
|
||||
"issn": "ISSN",
|
||||
"ejournal": "ejournal"
|
||||
"ejournal": "ejournal",
|
||||
"unknownAvailability": "No information available",
|
||||
"unavailableAvailability": "System unreachable"
|
||||
}
|
||||
},
|
||||
"schedule": {
|
||||
|
||||
Reference in New Issue
Block a user