diff --git a/src/app/modules/data/detail/data-detail.html b/src/app/modules/data/detail/data-detail.html index eea8dd8f..05aae029 100644 --- a/src/app/modules/data/detail/data-detail.html +++ b/src/app/modules/data/detail/data-detail.html @@ -24,7 +24,7 @@
-
+
{{ 'data.detail.COULD_NOT_CONNECT' | translate }} @@ -32,7 +32,7 @@
-
+
{{ 'data.detail.NOT_FOUND' | translate }} diff --git a/src/app/modules/data/list/data-list.component.ts b/src/app/modules/data/list/data-list.component.ts index d6085eb4..46ed10a1 100644 --- a/src/app/modules/data/list/data-list.component.ts +++ b/src/app/modules/data/list/data-list.component.ts @@ -80,6 +80,11 @@ export class DataListComponent implements OnChanges, OnInit, OnDestroy { @ViewChild(CdkVirtualScrollViewport) viewPort: CdkVirtualScrollViewport; + /** + * Signalizes that the data is being loaded + */ + @Input() loading = true; + /** * Calculate how many items would fill the screen */ @@ -130,10 +135,10 @@ export class DataListComponent implements OnChanges, OnInit, OnDestroy { /** * Function to call whenever scroll view visible range changed */ - scrolled(_index: number) { + scrolled(index: number) { if ( - // first condition prevents "load more" to be executed before event having initial items - this.items && + // first condition prevents "load more" to be executed even before scrolling + index > 0 && (this.items?.length ?? 0) - this.viewPort.getRenderedRange().end <= (this.items?.length ?? 0) * this.reloadThreshold ) { diff --git a/src/app/modules/data/list/data-list.html b/src/app/modules/data/list/data-list.html index 77493385..bd871310 100644 --- a/src/app/modules/data/list/data-list.html +++ b/src/app/modules/data/list/data-list.html @@ -15,12 +15,14 @@ -
- +
+ {{ 'search.nothing_found' | translate | titlecase }}
- + { - this.singleTypeResponse = - result.facets.find(facet => facet.field === 'type')?.buckets - .length === 1; - if (append) { - let items = await this.items; - // append results - items = [...items, ...result.data]; - this.items = (async () => items)(); - } else { - // override items with results - this.items = (async () => { - this.updateContextFilter(result.facets); + this.loading = !append; - return result.data; - })(); - } - }, - async error => { - const alert: HTMLIonAlertElement = await this.alertController.create({ - buttons: ['Dismiss'], - header: 'Error', - subHeader: error.message, - }); + try { + const result = await this.dataProvider.search(searchOptions); + this.singleTypeResponse = + result.facets.find(facet => facet.field === 'type')?.buckets.length === + 1; + if (append) { + let items = await this.items; + // append results + items = [...items, ...result.data]; + this.items = (async () => items)(); + } else { + // override items with results + this.items = (async () => { + this.updateContextFilter(result.facets); - await alert.present(); - }, - ); + return result.data; + })(); + } + } catch (error) { + const alert: HTMLIonAlertElement = await this.alertController.create({ + buttons: ['Dismiss'], + header: 'Error', + subHeader: error.message, + }); + + await alert.present(); + } finally { + this.loading = false; + } } /** @@ -268,8 +280,14 @@ export class SearchPageComponent implements OnInit, OnDestroy { this.filterQuery = query[1]; this.sortQuery = query[2]; this.from = 0; - await this.fetchAndUpdateItems(); - this.queryChanged.next(); + if ( + typeof this.filterQuery !== 'undefined' || + this.queryText?.length > 0 || + this.showDefaultData + ) { + await this.fetchAndUpdateItems(); + this.queryChanged.next(); + } }), this.settingsProvider.settingsActionChanged$.subscribe( ({type, payload}) => { diff --git a/src/app/modules/data/list/search-page.html b/src/app/modules/data/list/search-page.html index 72aaeda0..b43db7f0 100644 --- a/src/app/modules/data/list/search-page.html +++ b/src/app/modules/data/list/search-page.html @@ -14,17 +14,26 @@ (ngModelChange)="searchStringChanged($event)" [(ngModel)]="queryText" showClearButton="always" + placeholder="{{ 'search.search_bar.placeholder' | translate }}" > +
+ + {{ 'search.instruction' | translate }} + +
diff --git a/src/app/modules/data/types/catalog/catalog-detail-content.component.ts b/src/app/modules/data/types/catalog/catalog-detail-content.component.ts index f2c9ba1a..797c1528 100644 --- a/src/app/modules/data/types/catalog/catalog-detail-content.component.ts +++ b/src/app/modules/data/types/catalog/catalog-detail-content.component.ts @@ -35,6 +35,7 @@ export class CatalogDetailContentComponent } initialize() { + this.showDefaultData = true; this.pageSize = 100; const nameSort: SCDucetSort = { diff --git a/src/app/modules/favorites/favorites-page.component.ts b/src/app/modules/favorites/favorites-page.component.ts index 419d0249..739a4199 100644 --- a/src/app/modules/favorites/favorites-page.component.ts +++ b/src/app/modules/favorites/favorites-page.component.ts @@ -12,7 +12,7 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {FavoritesService} from './favorites.service'; import {DataRoutingService} from '../data/data-routing.service'; import {Router} from '@angular/router'; @@ -33,7 +33,10 @@ import {take} from 'rxjs/operators'; providers: [ContextMenuService], styleUrls: ['./favorites-page.component.scss'], }) -export class FavoritesPageComponent extends SearchPageComponent { +export class FavoritesPageComponent + extends SearchPageComponent + implements OnInit +{ constructor( alertController: AlertController, dataProvider: DataProvider, @@ -57,7 +60,8 @@ export class FavoritesPageComponent extends SearchPageComponent { ); } - ionViewWillEnter() { + ngOnInit() { + super.ngOnInit(); this.subscriptions.push( this.favoritesService.favoritesChanged$.subscribe(_favoritesMap => { this.fetchAndUpdateItems(); @@ -77,4 +81,8 @@ export class FavoritesPageComponent extends SearchPageComponent { this.updateContextFilter(result.facets); }); } + + initialize() { + this.showDefaultData = true; + } } diff --git a/src/app/modules/map/page/map-page.html b/src/app/modules/map/page/map-page.html index c3e0170b..c461a67e 100644 --- a/src/app/modules/map/page/map-page.html +++ b/src/app/modules/map/page/map-page.html @@ -14,7 +14,7 @@ (keyup)="searchKeyUp($event)" [(ngModel)]="queryText" (ionClear)="searchStringChanged()" - placeholder="{{ 'map.page.search.PLACEHOLDER' | translate }}" + placeholder="{{ 'map.page.search_bar.placeholder' | translate }}" showClearButton="always" > diff --git a/src/app/modules/news/page/news-page.html b/src/app/modules/news/page/news-page.html index 38f1e7df..414a5352 100644 --- a/src/app/modules/news/page/news-page.html +++ b/src/app/modules/news/page/news-page.html @@ -39,7 +39,7 @@ - + {{ 'search.nothing_found' | translate | titlecase }}