Skip to content

Commit

Permalink
Merge branch 'fix-home-page-issues'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed Apr 10, 2024
2 parents 26ecc03 + 024f8d0 commit aea6b99
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<ds-configuration-search-page configuration="administrativeView" [context]="context"></ds-configuration-search-page>
<ds-themed-configuration-search-page configuration="administrativeView" [context]="context"></ds-themed-configuration-search-page>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';

import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { AdminSearchPageComponent } from './admin-search-page.component';

Expand All @@ -23,7 +23,7 @@ describe('AdminSearchPageComponent', () => {
schemas: [NO_ERRORS_SCHEMA],
}).overrideComponent(AdminSearchPageComponent, {
remove: {
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
},
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component } from '@angular/core';

import { Context } from '../../core/shared/context.model';
import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';

@Component({
selector: 'ds-admin-search-page',
templateUrl: './admin-search-page.component.html',
styleUrls: ['./admin-search-page.component.scss'],
standalone: true,
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
})

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<ds-configuration-search-page configuration="supervision" [context]="context"></ds-configuration-search-page>
<ds-themed-configuration-search-page configuration="supervision" [context]="context"></ds-themed-configuration-search-page>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
waitForAsync,
} from '@angular/core/testing';

import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';
import { AdminWorkflowPageComponent } from './admin-workflow-page.component';

describe('AdminSearchPageComponent', () => {
describe('AdminWorkflowPageComponent', () => {
let component: AdminWorkflowPageComponent;
let fixture: ComponentFixture<AdminWorkflowPageComponent>;

Expand All @@ -20,7 +20,7 @@ describe('AdminSearchPageComponent', () => {
.overrideComponent(AdminWorkflowPageComponent, {
remove: {
imports: [
ConfigurationSearchPageComponent,
ThemedConfigurationSearchPageComponent,
],
},
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component } from '@angular/core';

import { Context } from '../../core/shared/context.model';
import { ConfigurationSearchPageComponent } from '../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../search-page/themed-configuration-search-page.component';

@Component({
selector: 'ds-admin-workflow-page',
templateUrl: './admin-workflow-page.component.html',
styleUrls: ['./admin-workflow-page.component.scss'],
standalone: true,
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
})

/**
Expand Down
Empty file.
27 changes: 18 additions & 9 deletions src/app/home-page/home-page.component.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
<ds-themed-home-news></ds-themed-home-news>
<div [ngClass]="appConfig.homePage.showDiscoverFilters ? 'container-fluid' : 'container'">
<div class="row m-5">
<div class="col-sm-3" *ngIf="appConfig.homePage.showDiscoverFilters">
<ds-configuration-search-page [sideBarWidth]="12" [showViewModes]="false" [searchEnabled]="false"
[inPlaceSearch]="false" [showScopeSelector]="false"></ds-configuration-search-page>
</div>
<div [ngClass]="appConfig.homePage.showDiscoverFilters ? 'col-sm-9' : 'col-sm-12'">
<div [ngClass]="showDiscoverFilters ? 'container-fluid' : 'container'">
<ds-page-with-sidebar [sidebarContent]="sidebar" [sideBarWidth]="3" [class]="showDiscoverFilters ? 'row mx-3' : ''">
<div [class.col-sm-12]="showDiscoverFilters">
<button *ngIf="(isXsOrSm$ | async) && sidebarService.isCollapsed" (click)="sidebarService.expand()"
class="btn btn-outline-primary d-block ml-auto mb-3">
<i class="fas fa-sliders"></i> {{ 'search.sidebar.open' | translate }}
</button>
<ng-container *ngIf="(site$ | async) as site">
<ds-view-tracker [object]="site"></ds-view-tracker>
</ng-container>
<ds-themed-search-form [inPlaceSearch]="false"
[searchPlaceholder]="'home.search-form.placeholder' | translate"></ds-themed-search-form>
[searchPlaceholder]="'home.search-form.placeholder' | translate">
</ds-themed-search-form>
<ds-themed-top-level-community-list></ds-themed-top-level-community-list>
<ds-recent-item-list *ngIf="recentSubmissionspageSize>0"></ds-recent-item-list>
</div>
</div>
</ds-page-with-sidebar>
</div>
<ds-suggestions-popup></ds-suggestions-popup>

<ng-template #sidebar>
<div *ngIf="showDiscoverFilters">
<ds-themed-configuration-search-page [sideBarWidth]="12" [showViewModes]="false" [searchEnabled]="false"
[inPlaceSearch]="false" [showScopeSelector]="false">
</ds-themed-configuration-search-page>
</div>
</ng-template>
7 changes: 5 additions & 2 deletions src/app/home-page/home-page.component.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
:host {
}
:host ::ng-deep {
.container-fluid .container {
padding: 0;
}
}
53 changes: 30 additions & 23 deletions src/app/home-page/home-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import {
import { ActivatedRoute } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import {
EMPTY,
Observable,
of as observableOf,
Subscription,
} from 'rxjs';
import {
map,
Expand All @@ -26,7 +27,6 @@ import {
AppConfig,
} from 'src/config/app-config.interface';

import { environment } from '../../environments/environment';
import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service';
import {
LinkDefinition,
Expand All @@ -36,8 +36,12 @@ import { ServerResponseService } from '../core/services/server-response.service'
import { Site } from '../core/shared/site.model';
import { SuggestionsPopupComponent } from '../notifications/suggestions-popup/suggestions-popup.component';
import { ConfigurationSearchPageComponent } from '../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../search-page/themed-configuration-search-page.component';
import { isNotEmpty } from '../shared/empty.util';
import { HostWindowService } from '../shared/host-window.service';
import { ThemedSearchFormComponent } from '../shared/search-form/themed-search-form.component';
import { PageWithSidebarComponent } from '../shared/sidebar/page-with-sidebar.component';
import { SidebarService } from '../shared/sidebar/sidebar.service';
import { ViewTrackerComponent } from '../statistics/angulartics/dspace/view-tracker.component';
import { ThemedHomeNewsComponent } from './home-news/themed-home-news.component';
import { RecentItemListComponent } from './recent-item-list/recent-item-list.component';
Expand All @@ -48,47 +52,49 @@ import { ThemedTopLevelCommunityListComponent } from './top-level-community-list
styleUrls: ['./home-page.component.scss'],
templateUrl: './home-page.component.html',
standalone: true,
imports: [ThemedHomeNewsComponent, NgIf, ViewTrackerComponent, ThemedSearchFormComponent, ThemedTopLevelCommunityListComponent, RecentItemListComponent, AsyncPipe, TranslateModule, NgClass, ConfigurationSearchPageComponent, SuggestionsPopupComponent],
imports: [ThemedHomeNewsComponent, NgIf, ViewTrackerComponent, ThemedSearchFormComponent, ThemedTopLevelCommunityListComponent, RecentItemListComponent, AsyncPipe, TranslateModule, NgClass, ConfigurationSearchPageComponent, SuggestionsPopupComponent, ThemedConfigurationSearchPageComponent, PageWithSidebarComponent],
})
export class HomePageComponent implements OnInit, OnDestroy {

site$: Observable<Site>;
isXsOrSm$: Observable<boolean>;
recentSubmissionspageSize: number;
showDiscoverFilters: boolean;
/**
* An array of LinkDefinition objects representing inbox links for the home page.
*/
inboxLinks: LinkDefinition[] = [];

subs: Subscription[] = [];

constructor(
@Inject(APP_CONFIG) protected appConfig: AppConfig,
private route: ActivatedRoute,
private responseService: ServerResponseService,
private notifyInfoService: NotifyInfoService,
protected route: ActivatedRoute,
protected responseService: ServerResponseService,
protected notifyInfoService: NotifyInfoService,
protected linkHeadService: LinkHeadService,
@Inject(PLATFORM_ID) private platformId: string,
protected sidebarService: SidebarService,
protected windowService: HostWindowService,
@Inject(PLATFORM_ID) protected platformId: string,
) {
this.recentSubmissionspageSize = environment.homePage.recentSubmissions.pageSize;
// Get COAR REST API URLs from REST configuration
// only if COAR configuration is enabled
this.notifyInfoService.isCoarConfigEnabled().pipe(
switchMap((coarLdnEnabled: boolean) => coarLdnEnabled ? this.notifyInfoService.getCoarLdnLocalInboxUrls() : EMPTY, /*{
if (coarLdnEnabled) {
return this.notifyInfoService.getCoarLdnLocalInboxUrls();
} else {
return of([]);
}
}*/),
).subscribe((coarRestApiUrls: string[]) => {
if (coarRestApiUrls?.length > 0) {
this.initPageLinks(coarRestApiUrls);
}
});
this.recentSubmissionspageSize = this.appConfig.homePage.recentSubmissions.pageSize;
this.showDiscoverFilters = this.appConfig.homePage.showDiscoverFilters;
}

ngOnInit(): void {
this.isXsOrSm$ = this.windowService.isXsOrSm();
this.site$ = this.route.data.pipe(
map((data) => data.site as Site),
);
// Get COAR REST API URLs from REST configuration
// only if COAR configuration is enabled
this.subs.push(this.notifyInfoService.isCoarConfigEnabled().pipe(
switchMap((coarLdnEnabled: boolean) => coarLdnEnabled ? this.notifyInfoService.getCoarLdnLocalInboxUrls() : observableOf([])),
).subscribe((coarRestApiUrls: string[]) => {
if (coarRestApiUrls.length > 0) {
this.initPageLinks(coarRestApiUrls);
}
}));
}

/**
Expand Down Expand Up @@ -120,6 +126,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
* It removes the inbox links from the head of the html.
*/
ngOnDestroy(): void {
this.subs.forEach((sub: Subscription) => sub.unsubscribe());
this.inboxLinks.forEach((link: LinkDefinition) => {
this.linkHeadService.removeTag(`href='${link.href}'`);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ds-configuration-search-page
<ds-themed-configuration-search-page
[fixedFilterQuery]="fixedFilter"
[configuration]="configuration"
[searchEnabled]="searchEnabled"
[sideBarWidth]="sideBarWidth"
[showCsvExport]="true">
</ds-configuration-search-page>
</ds-themed-configuration-search-page>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateModule } from '@ngx-translate/core';

import { Item } from '../../../../core/shared/item.model';
import { ConfigurationSearchPageComponent } from '../../../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component';
import { RelatedEntitiesSearchComponent } from './related-entities-search.component';

describe('RelatedEntitiesSearchComponent', () => {
Expand All @@ -30,7 +30,7 @@ describe('RelatedEntitiesSearchComponent', () => {
})
.overrideComponent(RelatedEntitiesSearchComponent, {
remove: {
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
},
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {
} from '@angular/core';

import { Item } from '../../../../core/shared/item.model';
import { ConfigurationSearchPageComponent } from '../../../../search-page/configuration-search-page.component';
import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component';
import { isNotEmpty } from '../../../../shared/empty.util';
import { getFilterByRelation } from '../../../../shared/utils/relation-query.utils';

@Component({
selector: 'ds-related-entities-search',
templateUrl: './related-entities-search.component.html',
standalone: true,
imports: [ConfigurationSearchPageComponent],
imports: [ThemedConfigurationSearchPageComponent],
})
/**
* A component to show related items as search results.
Expand Down
4 changes: 4 additions & 0 deletions src/app/notifications/suggestions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
import { WorkspaceItem } from '../core/submission/models/workspaceitem.model';
import { WorkspaceitemDataService } from '../core/submission/workspaceitem-data.service';
import {
hasNoValue,
hasValue,
isNotEmpty,
} from '../shared/empty.util';
Expand Down Expand Up @@ -165,6 +166,9 @@ export class SuggestionsService {
* The EPerson id for which to retrieve suggestion targets
*/
public retrieveCurrentUserSuggestions(userUuid: string): Observable<SuggestionTarget[]> {
if (hasNoValue(userUuid)) {
return of([]);
}
return this.researcherProfileService.findById(userUuid, true).pipe(
getFirstCompletedRemoteData(),
mergeMap((profile: RemoteData<ResearcherProfile> ) => {
Expand Down
Loading

0 comments on commit aea6b99

Please sign in to comment.