Skip to content

Commit

Permalink
Merge pull request #42 from IGNF/hotfix
Browse files Browse the repository at this point in the history
fix(filters): fix pagination #41
  • Loading branch information
mmohadIGN authored Jun 26, 2024
2 parents 3d3ee70 + 7c07b48 commit d6107de
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
41 changes: 34 additions & 7 deletions libs/feature/record/src/lib/ign-api-dl/ign-api-dl.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class IgnApiDlComponent implements OnInit {
pageSize$ = new BehaviorSubject(this.initialPageSize)
page$ = new BehaviorSubject('0')
size$ = new BehaviorSubject(this.initialPageSize)

// a passer en config
url =
'https://data.geopf.fr/telechargement/capabilities?outputFormat=application/json'
choices: any
Expand Down Expand Up @@ -125,7 +125,6 @@ export class IgnApiDlComponent implements OnInit {
}
}
outputUrl = url.toString()
console.log(outputUrl)
}
return outputUrl
})
Expand All @@ -134,8 +133,7 @@ export class IgnApiDlComponent implements OnInit {
listFilteredProduct$ = this.apiQueryUrl$.pipe(
mergeMap((url) => {
return this.getFilteredProduct$(url).pipe(
map((response) => response['entry']),
tap((el) => console.log(el))
map((response) => response['entry'])
)
})
)
Expand Down Expand Up @@ -193,11 +191,38 @@ export class IgnApiDlComponent implements OnInit {
this.page$.next('0')
}

async getFields() {
const [firstResponse] = await Promise.all([axios.get(this.url)])
this.choices = firstResponse.data.entry.filter(
async getCapabilities() {
let page = 0
let choicesTest = null
let [response] = await Promise.all([
axios.get(this.url.concat(`&pageSize=200&page=${page}`)),
])
choicesTest = response.data.entry.filter(
(element) => element['id'] == this.apiBaseUrl
)[0]
console.log(choicesTest)

if (choicesTest) {
return choicesTest
} else {
console.log('avant while')

while (choicesTest === undefined || response.data.pageCount > page) {
console.log('hello')
;[response] = await Promise.all([
axios.get(this.url.concat(`&pageSize=200&page=${page}`)),
])
choicesTest = response.data.entry.filter(
(element) => element['id'] == this.apiBaseUrl
)[0]
page += 1
}
}
return choicesTest
}
async getFields() {
this.choices = await this.getCapabilities()

this.bucketPromisesZone = this.choices.zone.map((bucket) => ({
value: bucket.label,
label: bucket.term,
Expand All @@ -218,5 +243,7 @@ export class IgnApiDlComponent implements OnInit {
}))
this.bucketPromisesCrs.sort((a, b) => (a.label > b.label ? 1 : -1))
this.bucketPromisesCrs.unshift({ value: 'null', label: 'CRS' })

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ export class IgnApiProduitComponent implements OnInit {
liste$: Observable<any>

ngOnInit(): void {
this.liste$ = this.http.get(this.link['id']).pipe(
map(
(response) => response['entry']
// tap(el=> console.log(el)),
)
)
this.liste$ = this.http
.get(this.link['id'])
.pipe(map((response) => response['entry']))
}

downloadListe(): void {
Expand All @@ -44,7 +41,6 @@ export class IgnApiProduitComponent implements OnInit {
}

download(url): void {
console.log(url)
this.http.get(url).subscribe()
}
}

0 comments on commit d6107de

Please sign in to comment.