Skip to content

Commit

Permalink
Resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ronitjadhav committed May 21, 2024
2 parents 456281c + 8918855 commit c28a25a
Show file tree
Hide file tree
Showing 51 changed files with 1,060 additions and 334 deletions.
18 changes: 16 additions & 2 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ import {
RECORD_URL_TOKEN,
} from '@geonetwork-ui/feature/search'
import {
LinkCardComponent,
THUMBNAIL_PLACEHOLDER,
UiElementsModule,
} from '@geonetwork-ui/ui/elements'
import { UiInputsModule } from '@geonetwork-ui/ui/inputs'
import { UiLayoutModule } from '@geonetwork-ui/ui/layout'
import {
PreviousNextButtonsComponent,
UiInputsModule,
} from '@geonetwork-ui/ui/inputs'
import {
BlockListComponent,
CarouselComponent,
UiLayoutModule,
} from '@geonetwork-ui/ui/layout'
import { UiSearchModule } from '@geonetwork-ui/ui/search'
import {
getGlobalConfig,
Expand Down Expand Up @@ -83,6 +91,7 @@ import { RecordApisComponent } from './record/record-apis/record-apis.component'
import { MatTabsModule } from '@angular/material/tabs'
import { UiWidgetsModule } from '@geonetwork-ui/ui/widgets'
import { RecordUserFeedbacksComponent } from './record/record-user-feedbacks/record-user-feedbacks.component'
import { LetDirective } from '@ngrx/component'

export const metaReducers: MetaReducer[] = !environment.production ? [] : []

Expand Down Expand Up @@ -150,6 +159,11 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
UiCatalogModule,
MatTabsModule,
UiWidgetsModule,
LinkCardComponent,
CarouselComponent,
BlockListComponent,
PreviousNextButtonsComponent,
LetDirective,
],
providers: [
importProvidersFrom(FeatureAuthModule),
Expand Down
55 changes: 26 additions & 29 deletions apps/datahub/src/app/record/record-apis/record-apis.component.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
<div class="container-lg px-4 lg:mx-auto">
<div class="flex flex-row gap-x-4 items-center justify-center md:justify-start">
<p
class="font-title text-[28px] font-medium mt-8 mb-5 text-title text-center sm:mt-12 sm:mb-[-22px] sm:text-left"
class="font-title text-[28px] font-medium text-title text-center sm:text-left"
translate
>
record.metadata.api
</p>
<gn-ui-carousel
containerClass="gap-4 py-10"
stepsContainerClass="right-[var(--container-outside-width)] bottom-[calc(100%-12px)] top-auto"
>
<gn-ui-api-card
*ngFor="
let link of facade.apiLinks$ | async;
let first = first;
let last = last
"
[title]="link.name"
[link]="link"
[currentLink]="selectedApiLink"
class="w-80"
[ngClass]="{
'mr-[var(--container-outside-width)]': last,
'ml-[var(--container-outside-width)]': first,
'card-shadow': link !== selectedApiLink || !selectedApiLink,
'bg-neutral-100': link === selectedApiLink
}"
(openRecordApiForm)="openRecordApiForm($event)"
>
</gn-ui-api-card>
</gn-ui-carousel>
<gn-ui-previous-next-buttons
*ngIf="hasPagination"
[isFirst]="isFirstStep"
[isLast]="isLastStep"
(directionButtonClicked)="changeStepOrPage($event)"
></gn-ui-previous-next-buttons>
</div>
<gn-ui-carousel (currentStepChange)="updateView()" containerClass="gap-4 py-10">
<gn-ui-api-card
*ngFor="let link of apiLinks$ | async"
[title]="link.name"
[link]="link"
[currentLink]="selectedApiLink"
class="w-[320px]"
[ngClass]="{
'card-shadow': link !== selectedApiLink || !selectedApiLink,
'bg-neutral-100': link === selectedApiLink
}"
(openRecordApiForm)="openRecordApiForm($event)"
>
</gn-ui-api-card>
</gn-ui-carousel>
<div
class="content overflow-hidden transition-all duration-300"
class="content transition-all duration-300 w-screen mx-auto -ml-[calc(50vw-50%)] overflow-hidden"
[ngClass]="selectedApiLink ? 'ease-in' : 'ease-out'"
[style.maxHeight]="maxHeight"
[style.opacity]="opacity"
Expand All @@ -55,8 +52,8 @@
</div>
<mat-icon
class="!w-5 !h-5 text-xl font-bold material-symbols-outlined !flex items-center"
>close</mat-icon
>
>close
</mat-icon>
</button>
</div>
<gn-ui-record-api-form
Expand Down
43 changes: 41 additions & 2 deletions apps/datahub/src/app/record/record-apis/record-apis.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core'
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
OnInit,
ViewChild,
} from '@angular/core'
import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/model/record'
import { MdViewFacade } from '@geonetwork-ui/feature/record'
import { CarouselComponent } from '@geonetwork-ui/ui/layout'

@Component({
selector: 'datahub-record-apis',
Expand All @@ -9,16 +16,40 @@ import { MdViewFacade } from '@geonetwork-ui/feature/record'
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RecordApisComponent implements OnInit {
@ViewChild(CarouselComponent) carousel: CarouselComponent

maxHeight = '0px'
opacity = 0
selectedApiLink: DatasetServiceDistribution
constructor(public facade: MdViewFacade) {}

apiLinks$ = this.facade.apiLinks$

constructor(
private facade: MdViewFacade,
private changeDetector: ChangeDetectorRef
) {}

ngOnInit(): void {
this.setStyle(undefined)
this.selectedApiLink = undefined
}

get hasPagination() {
return this.carousel?.stepsCount > 1
}

updateView() {
this.changeDetector.detectChanges()
}

get isFirstStep() {
return this.carousel?.isFirstStep
}

get isLastStep() {
return this.carousel?.isLastStep
}

openRecordApiForm(link: DatasetServiceDistribution) {
this.selectedApiLink = link
this.setStyle(link)
Expand All @@ -33,4 +64,12 @@ export class RecordApisComponent implements OnInit {
this.maxHeight = link === undefined ? '0px' : '500px'
this.opacity = link === undefined ? 0 : 1
}

changeStepOrPage(direction: string) {
if (direction === 'next') {
this.carousel?.slideToNext()
} else {
this.carousel?.slideToPrevious()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class DataServiceMock {
])
getDownloadLinksFromOgcApiFeatures = jest.fn((link) =>
link.url.toString().indexOf('error') > -1
? throwError(() => new Error('would not fetch links'))
: of([
? Promise.reject(new Error('ogc.unreachable.unknown'))
: Promise.resolve([
{
...link,
mimeType: 'application/geo+json',
Expand Down Expand Up @@ -233,6 +233,13 @@ describe('DataDownloadsComponent', () => {
type: 'service',
accessServiceProtocol: 'ogcFeatures',
},
{
name: 'Some erroneous OGC API service',
description: 'OGC API service',
url: newUrl('https://error.org/collections/airports/items'),
type: 'service',
accessServiceProtocol: 'ogcFeatures',
},
])
fixture.detectChanges()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,26 @@ export class RecordDownloadsComponent {
return combineLatest([
...(wfsLinks.length > 0
? wfsLinks.map((link) =>
this.dataService.getDownloadLinksFromWfs(
link as DatasetServiceDistribution
)
this.dataService
.getDownloadLinksFromWfs(link as DatasetServiceDistribution)
.pipe(
catchError((e) => {
this.error = e.message
return [of([] as DatasetDistribution[])]
})
)
)
: [of([] as DatasetDistribution[])]),
...(ogcLinks.length > 0
? ogcLinks.map((link) =>
this.dataService.getDownloadLinksFromOgcApiFeatures(
link as DatasetServiceDistribution
)
this.dataService
.getDownloadLinksFromOgcApiFeatures(
link as DatasetServiceDistribution
)
.catch((e) => {
this.error = e.message
return Promise.resolve([])
})
)
: [of([] as DatasetDistribution[])]),
]).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,3 @@
.tab-header-label {
@apply uppercase text-sm text-primary opacity-75 hover:text-primary-darker;
}

:host {
--container-outside-width: calc(50vw - 1024px / 2);
}
@media (max-width: 1024px) {
:host {
--container-outside-width: 1rem;
}
}

:host ::ng-deep gn-ui-carousel {
display: block;
margin-left: calc(-1 * var(--container-outside-width));
margin-right: calc(-1 * var(--container-outside-width));
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,20 @@
class="container-lg px-4 lg:mx-auto"
*ngIf="displayDownload$ | async"
>
<datahub-record-downloads class="block mt-5"></datahub-record-downloads>
<datahub-record-downloads
class="block mt-[72px]"
></datahub-record-downloads>
</div>

<div id="links" class="lg:mx-auto">
<div class="container-lg px-4 lg:mx-auto" *ngIf="displayOtherLinks | async">
<datahub-record-otherlinks class="block mt-5"></datahub-record-otherlinks>
<datahub-record-otherlinks
class="block mt-[72px]"
></datahub-record-otherlinks>
</div>

<div *ngIf="displayApi$ | async">
<datahub-record-apis
[isPanelOpen]="isPanelOpen"
class="block mt-6"
></datahub-record-apis>
<div class="container-lg px-4 lg:mx-auto" *ngIf="displayApi$ | async">
<datahub-record-apis class="block mt-[32px]"></datahub-record-apis>
</div>
</div>

Expand All @@ -148,7 +149,7 @@
</div>
</div>
</div>
<div id="userFeedbacks" class="bg-primary-opacity-10 py-16">
<div id="userFeedbacks" class="bg-primary-opacity-10 py-16 mt-[32px]">
<div class="container-lg px-4 lg:mx-auto">
<datahub-record-user-feedbacks
[organisationName$]="organisationName$"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
<p
class="font-title text-[28px] font-medium mt-8 mb-5 text-title text-center sm:mt-12 sm:mb-[-22px] sm:text-left"
translate
>
record.metadata.links
</p>
<gn-ui-carousel
containerClass="gap-4 py-10"
stepsContainerClass="right-[var(--container-outside-width)] bottom-[calc(100%-12px)] top-auto"
>
<gn-ui-link-card
*ngFor="
let link of facade.otherLinks$ | async;
let first = first;
let last = last
"
[title]="link.name"
[link]="link"
class="w-80"
[ngClass]="{
'mr-[var(--container-outside-width)]': last,
'ml-[var(--container-outside-width)]': first
}"
<div class="flex flex-row gap-x-4 items-center justify-center md:justify-start">
<p
class="font-title text-[28px] font-medium text-title text-center sm:text-left"
translate
>
</gn-ui-link-card>
</gn-ui-carousel>
record.metadata.links
</p>
<gn-ui-previous-next-buttons
*ngIf="hasPagination"
[isFirst]="isFirstStepOrPage"
[isLast]="isLastStepOrPage"
(directionButtonClicked)="changeStepOrPage($event)"
></gn-ui-previous-next-buttons>
</div>
<ng-container *ngrxLet="otherLinks$ as otherLinks">
<gn-ui-block-list
containerClass="gap-4 py-10"
*ngIf="otherLinks.length >= 10; else carouselTemplate"
>
<gn-ui-link-card
#block
*ngFor="let otherLink of otherLinks"
[link]="otherLink"
[compact]="true"
></gn-ui-link-card>
</gn-ui-block-list>
<ng-template #carouselTemplate>
<gn-ui-carousel
containerClass="gap-4 pt-[26px] pb-[38px]"
(currentStepChange)="updateView()"
>
<gn-ui-link-card
*ngFor="let otherLink of otherLinks; let first = first; let last = last"
[link]="otherLink"
class="w-80"
></gn-ui-link-card>
</gn-ui-carousel>
</ng-template>
</ng-container>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { Subject } from 'rxjs'
import { BehaviorSubject } from 'rxjs'
import { RecordOtherlinksComponent } from './record-otherlinks.component'
import { MdViewFacade } from '@geonetwork-ui/feature/record'

class MdViewFacadeMock {
otherLinks$ = new Subject()
otherLinks$ = new BehaviorSubject([])
}
describe('DataOtherlinksComponent', () => {
describe('RecordOtherlinksComponent', () => {
let component: RecordOtherlinksComponent
let fixture: ComponentFixture<RecordOtherlinksComponent>

Expand Down
Loading

0 comments on commit c28a25a

Please sign in to comment.