62530: fixed loading issue

This commit is contained in:
lotte
2019-05-23 16:15:40 +02:00
parent c3bd151cc3
commit 24fdbaf0bd
7 changed files with 12 additions and 18 deletions

View File

@@ -9,9 +9,7 @@ import { SearchConfigurationService } from './search-service/search-configuratio
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { PaginatedSearchOptions } from './paginated-search-options.model'; import { PaginatedSearchOptions } from './paginated-search-options.model';
import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component'; import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
import { map, switchMap } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { getSucceededRemoteData } from '../core/shared/operators';
import { isNotEmpty } from '../shared/empty.util';
/** /**
* This component renders a simple item page. * This component renders a simple item page.
@@ -33,7 +31,6 @@ import { isNotEmpty } from '../shared/empty.util';
}) })
export class FilteredSearchPageComponent extends SearchPageComponent implements OnInit { export class FilteredSearchPageComponent extends SearchPageComponent implements OnInit {
/** /**
* The actual query for the fixed filter. * The actual query for the fixed filter.
* If empty, the query will be determined by the route parameter called 'filter' * If empty, the query will be determined by the route parameter called 'filter'
@@ -59,7 +56,6 @@ export class FilteredSearchPageComponent extends SearchPageComponent implements
super.ngOnInit(); super.ngOnInit();
} }
/** /**
* Get the current paginated search options after updating the fixed filter using the fixedFilterQuery input * Get the current paginated search options after updating the fixed filter using the fixedFilterQuery input
* This is to make sure the fixed filter is included in the paginated search options, as it is not part of any * This is to make sure the fixed filter is included in the paginated search options, as it is not part of any

View File

@@ -2,7 +2,7 @@
<div class="search-page row"> <div class="search-page row">
<ds-search-sidebar *ngIf="!(isXsOrSm$ | async)" class="col-{{sideBarWidth}} sidebar-md-sticky" <ds-search-sidebar *ngIf="!(isXsOrSm$ | async)" class="col-{{sideBarWidth}} sidebar-md-sticky"
id="search-sidebar" id="search-sidebar"
[resultCount]="(resultsRD$ | async)?.payload.totalElements" [inPlaceSearch]="inPlaceSearch"></ds-search-sidebar> [resultCount]="(resultsRD$ | async)?.payload?.totalElements" [inPlaceSearch]="inPlaceSearch"></ds-search-sidebar>
<div class="col-12 col-md-{{12 - sideBarWidth}}"> <div class="col-12 col-md-{{12 - sideBarWidth}}">
<ds-search-form *ngIf="searchEnabled" id="search-form" <ds-search-form *ngIf="searchEnabled" id="search-form"
[query]="(searchOptions$ | async)?.query" [query]="(searchOptions$ | async)?.query"

View File

@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, Component, Inject, Input, OnInit } from '@angular/core';
import { Observable , Subscription , BehaviorSubject } from 'rxjs'; import { BehaviorSubject, Observable, of as observableOf, Subscription } from 'rxjs';
import { switchMap, } from 'rxjs/operators'; import { startWith, switchMap, } from 'rxjs/operators';
import { PaginatedList } from '../core/data/paginated-list'; import { PaginatedList } from '../core/data/paginated-list';
import { RemoteData } from '../core/data/remote-data'; import { RemoteData } from '../core/data/remote-data';
import { DSpaceObject } from '../core/shared/dspace-object.model'; import { DSpaceObject } from '../core/shared/dspace-object.model';
@@ -43,7 +43,6 @@ export const SEARCH_ROUTE = '/search';
* It renders search results depending on the current search options * It renders search results depending on the current search options
*/ */
export class SearchPageComponent implements OnInit { export class SearchPageComponent implements OnInit {
/** /**
* The current search results * The current search results
*/ */
@@ -110,7 +109,7 @@ export class SearchPageComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.searchOptions$ = this.getSearchOptions(); this.searchOptions$ = this.getSearchOptions();
this.sub = this.searchOptions$.pipe( this.sub = this.searchOptions$.pipe(
switchMap((options) => this.service.search(options).pipe(getSucceededRemoteData()))) switchMap((options) => this.service.search(options).pipe(getSucceededRemoteData(), startWith(observableOf(undefined)))))
.subscribe((results) => { .subscribe((results) => {
this.resultsRD$.next(results); this.resultsRD$.next(results);
}); });

View File

@@ -6,7 +6,7 @@
[objects]="searchResults" [objects]="searchResults"
[hideGear]="true"> [hideGear]="true">
</ds-viewable-collection></div> </ds-viewable-collection></div>
<ds-loading *ngIf="!searchResults || searchResults?.isLoading" message="{{'loading.search-results' | translate}}"></ds-loading> <ds-loading *ngIf="hasNoValue(searchResults) || hasNoValue(searchResults.payload) || searchResults.isLoading" message="{{'loading.search-results' | translate}}"></ds-loading>
<ds-error *ngIf="searchResults?.hasFailed && (!searchResults?.error || searchResults?.error?.statusCode != 400)" message="{{'error.search-results' | translate}}"></ds-error> <ds-error *ngIf="searchResults?.hasFailed && (!searchResults?.error || searchResults?.error?.statusCode != 400)" message="{{'error.search-results' | translate}}"></ds-error>
<div *ngIf="searchResults?.payload?.page.length == 0 || searchResults?.error?.statusCode == 400"> <div *ngIf="searchResults?.payload?.page.length == 0 || searchResults?.error?.statusCode == 400">
{{ 'search.results.no-results' | translate }} {{ 'search.results.no-results' | translate }}

View File

@@ -6,7 +6,7 @@ import { SetViewMode } from '../../shared/view-mode';
import { SearchOptions } from '../search-options.model'; import { SearchOptions } from '../search-options.model';
import { SearchResult } from '../search-result.model'; import { SearchResult } from '../search-result.model';
import { PaginatedList } from '../../core/data/paginated-list'; import { PaginatedList } from '../../core/data/paginated-list';
import { isNotEmpty } from '../../shared/empty.util'; import { hasNoValue, isNotEmpty } from '../../shared/empty.util';
import { SortOptions } from '../../core/cache/models/sort-options.model'; import { SortOptions } from '../../core/cache/models/sort-options.model';
@Component({ @Component({
@@ -22,6 +22,8 @@ import { SortOptions } from '../../core/cache/models/sort-options.model';
* Component that represents all results from a search * Component that represents all results from a search
*/ */
export class SearchResultsComponent { export class SearchResultsComponent {
hasNoValue = hasNoValue;
/** /**
* The actual search result objects * The actual search result objects
*/ */

View File

@@ -229,7 +229,6 @@ export class SearchConfigurationService implements OnDestroy {
this.getFiltersPart(), this.getFiltersPart(),
this.getFixedFilterPart() this.getFixedFilterPart()
).subscribe((update) => { ).subscribe((update) => {
console.log(update);
const currentValue: SearchOptions = this.searchOptions.getValue(); const currentValue: SearchOptions = this.searchOptions.getValue();
const updatedValue: SearchOptions = Object.assign(currentValue, update); const updatedValue: SearchOptions = Object.assign(currentValue, update);
this.searchOptions.next(updatedValue); this.searchOptions.next(updatedValue);

View File

@@ -21,11 +21,11 @@ import { coreSelector } from '../../core/core.selectors';
export const routeParametersSelector = createSelector( export const routeParametersSelector = createSelector(
coreSelector, coreSelector,
(state: CoreState) => state['route'].params (state: CoreState) => state.route.params
); );
export const queryParametersSelector = createSelector( export const queryParametersSelector = createSelector(
coreSelector, coreSelector,
(state: CoreState) => state['route'].queryParams (state: CoreState) => state.route.queryParams
); );
export const routeParameterSelector = (key: string) => parameterSelector(key, routeParametersSelector); export const routeParameterSelector = (key: string) => parameterSelector(key, routeParametersSelector);
@@ -96,9 +96,7 @@ export class RouteService {
} }
getRouteParameterValue(paramName: string): Observable<string> { getRouteParameterValue(paramName: string): Observable<string> {
const test = this.store.pipe(select(routeParameterSelector(paramName))); return this.store.pipe(select(routeParameterSelector(paramName)));
test.subscribe((t) => {console.log('test', t)});
return test;
} }
getRouteDataValue(datafield: string): Observable<any> { getRouteDataValue(datafield: string): Observable<any> {