forked from geonetwork/geonetwork-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Api_telechargement' into passeplat
- Loading branch information
Showing
18 changed files
with
539 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
libs/feature/record/src/lib/ign-api-dl/ign-api-dl.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
:host ::ng-deep input { | ||
color: black; | ||
opacity: 1; | ||
} | ||
|
||
:host ::ng-deep gn-ui-copy-text-button input[type='text'] { | ||
color: black; | ||
background-color: white; | ||
} | ||
|
||
:host ::ng-deep gn-ui-copy-text-button button, | ||
host ::ng-deep gn-ui-copy-text-button button:hover { | ||
background-color: var(--color-secondary) !important; | ||
} | ||
|
||
:host ::ng-deep gn-ui-copy-text-button button mat-icon { | ||
color: white !important; | ||
opacity: 1 !important; | ||
} | ||
:host ::ng-deep gn-ui-copy-text-button button:hover mat-icon { | ||
color: lightgrey !important; | ||
} |
97 changes: 97 additions & 0 deletions
97
libs/feature/record/src/lib/ign-api-dl/ign-api-dl.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<div class="flex flex-col gap-8"> | ||
<div class="flex flex-col bg-white p-8 ng-star-inserted shadow-xl gap-8"> | ||
<div class="flex flex-row"> | ||
<div class="text-[16px] text-black truncate font-title w-11/12" translate> | ||
record.metadata.api.form.create | ||
</div> | ||
<button | ||
(click)="resetUrl()" | ||
class="bg-primary-opacity-50 inline-flex items-center justify-center px-2 py-1 text-13 font-medium leading-none text-white rounded capitalize text-primary-lightest hover:bg-primary transition-colors" | ||
> | ||
<p class="text-[13px] uppercase" translate> | ||
record.metadata.api.form.reset | ||
</p> | ||
</button> | ||
</div> | ||
<div class="flex flex-row flex-wrap justify-between flex-grow gap-5"> | ||
<div class="flex flex-col gap-3"> | ||
<!--<p class="text-sm" translate>record.metadata.api.form.type</p>--> | ||
<gn-ui-dropdown-selector | ||
#zone | ||
[title]="''" | ||
extraBtnClass="secondary min-w-full !w-40 !text-black" | ||
[showTitle]="false" | ||
class="text-black" | ||
[choices]="bucketPromisesZone" | ||
(selectValue)="setZone($event)" | ||
[selected]="zone$ | async" | ||
> | ||
</gn-ui-dropdown-selector> | ||
</div> | ||
<div class="flex flex-col gap-3"> | ||
<!--<p class="text-sm" translate>record.metadata.api.form.type</p>--> | ||
<gn-ui-dropdown-selector | ||
#format | ||
[title]="''" | ||
extraBtnClass="secondary min-w-full !w-40 !text-black" | ||
[showTitle]="false" | ||
class="text-black" | ||
[choices]="bucketPromisesFormat" | ||
(selectValue)="setFormat($event)" | ||
[selected]="format$ | async" | ||
> | ||
</gn-ui-dropdown-selector> | ||
</div> | ||
<div class="flex flex-col gap-3"> | ||
<!--<p class="text-sm" translate>record.metadata.api.form.type</p>--> | ||
<gn-ui-dropdown-selector | ||
#format | ||
[title]="'CRS'" | ||
[choices]="bucketPromisesCrs" | ||
(selectValue)="setCrs($event)" | ||
[selected]="crs$ | async" | ||
> | ||
</gn-ui-dropdown-selector> | ||
</div> | ||
</div> | ||
<div class="bg-white rounded-lg h-min"> | ||
<div class="overflow-auto h-60 w-65 bg-white-300 m-2"> | ||
<table class="w-full text-left border-collapse"> | ||
<thead> | ||
<tr | ||
class="sticky z-10 top-0 text-sm leading-6 font-semibold text-slate-700 bg-white p-0 dark:bg-slate-900 dark:text-slate-300" | ||
> | ||
<div | ||
class="py-2 pr-2 text-xl border-b border-slate-200 dark:border-slate-400/20" | ||
> | ||
Produits ({{ numberFilteredProduct$ | async }}): | ||
</div> | ||
</tr> | ||
</thead> | ||
<tbody class="align-baseline"> | ||
<tr> | ||
<div *ngFor="let link of listFilteredProduct$ | async"> | ||
<div class="mb-2 sm:mb-3"> | ||
<gn-ui-ign-api-produit | ||
[link]="link" | ||
color="rgb(124 45 18)" | ||
[format]="getLinkFormat(link)" | ||
[isFromWfs]="true" | ||
></gn-ui-ign-api-produit> | ||
</div> | ||
</div> | ||
</tr> | ||
<tr> | ||
<button | ||
(click)="moreResult()" | ||
class="bg-primary-opacity-50 inline-flex items-center justify-center px-2 py-1 text-13 font-medium leading-none text-white rounded capitalize text-primary-lightest hover:bg-primary transition-colors" | ||
> | ||
<p class="text-[13px] uppercase" translate>Plus de résultats</p> | ||
</button> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
90 changes: 90 additions & 0 deletions
90
libs/feature/record/src/lib/ign-api-dl/ign-api-dl.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { TestBed, ComponentFixture } from '@angular/core/testing' | ||
import { RecordApiFormComponent } from './record-api-form.component' | ||
import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/model/record' | ||
import { firstValueFrom } from 'rxjs' | ||
import { UiInputsModule } from '@geonetwork-ui/ui/inputs' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
|
||
const mockDatasetServiceDistribution: DatasetServiceDistribution = { | ||
url: new URL('https://api.example.com/data'), | ||
type: 'service', | ||
accessServiceProtocol: 'ogcFeatures', | ||
} | ||
|
||
describe('RecordApFormComponent', () => { | ||
let component: RecordApiFormComponent | ||
let fixture: ComponentFixture<RecordApiFormComponent> | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [RecordApiFormComponent], | ||
imports: [UiInputsModule, TranslateModule.forRoot()], | ||
}).compileComponents() | ||
|
||
fixture = TestBed.createComponent(RecordApiFormComponent) | ||
component = fixture.componentInstance | ||
component.apiLink = mockDatasetServiceDistribution | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
describe('When panel is opened', () => { | ||
it('should set the links and initial values correctly', async () => { | ||
expect(component.apiBaseUrl).toBe('https://api.example.com/data') | ||
expect(component.offset$.getValue()).toBe('') | ||
expect(component.limit$.getValue()).toBe('') | ||
expect(component.format$.getValue()).toBe('json') | ||
const url = await firstValueFrom(component.apiQueryUrl$) | ||
expect(url).toBe('https://api.example.com/data?f=json') | ||
}) | ||
}) | ||
describe('When URL params are changed', () => { | ||
it('should update query URL correctly when setting offset, limit, and format', async () => { | ||
const mockOffset = '10' | ||
const mockLimit = '20' | ||
const mockFormat = 'json' | ||
component.setOffset(mockOffset) | ||
component.setLimit(mockLimit) | ||
component.setFormat(mockFormat) | ||
const url = await firstValueFrom(component.apiQueryUrl$) | ||
expect(url).toBe( | ||
`https://api.example.com/data?offset=${mockOffset}&limit=${mockLimit}&f=${mockFormat}` | ||
) | ||
}) | ||
it('should remove the param in url if value is null', async () => { | ||
const mockOffset = null | ||
const mockLimit = '20' | ||
const mockFormat = 'json' | ||
component.setOffset(mockOffset) | ||
component.setLimit(mockLimit) | ||
component.setFormat(mockFormat) | ||
const url = await firstValueFrom(component.apiQueryUrl$) | ||
expect(url).toBe( | ||
`https://api.example.com/data?limit=${mockLimit}&f=${mockFormat}` | ||
) | ||
}) | ||
it('should remove the param in url if value is zero', async () => { | ||
const mockOffset = '10' | ||
const mockLimit = '0' | ||
const mockFormat = 'json' | ||
component.setOffset(mockOffset) | ||
component.setLimit(mockLimit) | ||
component.setFormat(mockFormat) | ||
const url = await firstValueFrom(component.apiQueryUrl$) | ||
expect(url).toBe( | ||
`https://api.example.com/data?offset=${mockOffset}&f=${mockFormat}` | ||
) | ||
}) | ||
}) | ||
|
||
describe('#resetUrl', () => { | ||
it('should reset URL to default parameters', () => { | ||
component.resetUrl() | ||
expect(component.offset$.getValue()).toBe('') | ||
expect(component.limit$.getValue()).toBe('') | ||
expect(component.format$.getValue()).toBe('json') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.