Skip to content

Commit

Permalink
Merge pull request #605 from geonetwork/ME/search-bar
Browse files Browse the repository at this point in the history
Editor / Implement search bar and associated route
  • Loading branch information
jahow authored Sep 6, 2023
2 parents cce34a5 + ebf6b36 commit e3fc6af
Show file tree
Hide file tree
Showing 63 changed files with 1,153 additions and 630 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
UploadJobStatusApiModel,
} from '@geonetwork-ui/data-access/datafeeder'
import { delay, of } from 'rxjs'
import { TestScheduler } from 'rxjs/testing'
import { DatafeederFacade } from '../../../store/datafeeder.facade'
import { AnalysisProgressPageComponent } from './analysis-progress.page'
import advanceTimersByTime = jest.advanceTimersByTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RouterFacade } from '@geonetwork-ui/feature/router'
class SearchFacadeMock {
init = jest.fn()
results$ = of(summaryHits)
setPagination = jest.fn(() => this)
setPageSize = jest.fn(() => this)
setSortBy = jest.fn(() => this)
setConfigRequestFields = jest.fn(() => this)
setResultsLayout = jest.fn(() => this)
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('LastCreatedComponent', () => {
})

it('Should set the correct params in the facade', () => {
expect(facade.setPagination).toHaveBeenCalledWith(0, 10)
expect(facade.setPageSize).toHaveBeenCalledWith(10)
expect(facade.setSortBy).toHaveBeenCalledWith(['desc', 'createDate'])
expect(facade.setConfigRequestFields).toHaveBeenCalledWith(
expect.arrayContaining([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class LastCreatedComponent implements OnInit {
ngOnInit() {
this.searchFacade
.setConfigRequestFields([...FIELDS_BRIEF, 'createDate', 'changeDate'])
.setPagination(0, 10)
.setPageSize(10)
.setSortBy(['desc', 'createDate'])
.setResultsLayout('FEED')
}
Expand Down
50 changes: 0 additions & 50 deletions apps/metadata-editor/src/app/app.common.module.ts

This file was deleted.

4 changes: 3 additions & 1 deletion apps/metadata-editor/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<router-outlet></router-outlet>
<div gnUiSearchRouterContainer="editor">
<router-outlet></router-outlet>
</div>
65 changes: 54 additions & 11 deletions apps/metadata-editor/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,83 @@
import { importProvidersFrom, NgModule } from '@angular/core'
import { RouterModule } from '@angular/router'
import { TranslateModule } from '@ngx-translate/core'
import { StoreModule } from '@ngrx/store'
import { EffectsModule } from '@ngrx/effects'
import { FeatureSearchModule } from '@geonetwork-ui/feature/search'
import { FeatureRecordModule } from '@geonetwork-ui/feature/record'
import { FeatureCatalogModule } from '@geonetwork-ui/feature/catalog'
import {
FeatureSearchModule,
SearchFacade,
} from '@geonetwork-ui/feature/search'
DefaultRouterModule,
RouterService,
} from '@geonetwork-ui/feature/router'
import { Configuration } from '@geonetwork-ui/data-access/gn4'
import { getGlobalConfig, getThemeConfig } from '@geonetwork-ui/util/app-config'
import { ThemeService } from '@geonetwork-ui/util/shared'
import {
TRANSLATE_DEFAULT_CONFIG,
UtilI18nModule,
} from '@geonetwork-ui/util/i18n'
import { TranslateModule } from '@ngx-translate/core'
import { AppCommonModule } from './app.common.module'
import { AppComponent } from './app.component'
import { appRoutes } from './app.routes'
import { FeatureCatalogModule } from '@geonetwork-ui/feature/catalog'
import { DashboardSearchService } from './dashboard/dashboard-search.service'
import { FeatureAuthModule } from '@geonetwork-ui/feature/auth'
import { BrowserModule } from '@angular/platform-browser'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { extModules } from './build-specifics'
import { DashboardPageComponent } from './dashboard/dashboard-page.component'
import { EditorRouterService } from './router.service'

@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
BrowserAnimationsModule,
StoreModule.forRoot(
{},
{
runtimeChecks: {
strictStateImmutability: false,
strictActionImmutability: false,
},
}
),
RouterModule.forRoot(appRoutes, { initialNavigation: 'enabledBlocking' }),
DefaultRouterModule.forRoot({
searchStateId: 'editor',
searchRouteComponent: DashboardPageComponent,
recordRouteComponent: null,
}),
...extModules,
],
providers: [
SearchFacade,
DashboardSearchService,
{ provide: RouterService, useClass: EditorRouterService },
importProvidersFrom(FeatureAuthModule),
importProvidersFrom(FeatureSearchModule),
importProvidersFrom(FeatureCatalogModule),
importProvidersFrom(FeatureRecordModule),
importProvidersFrom(UtilI18nModule),
importProvidersFrom(TranslateModule.forRoot(TRANSLATE_DEFAULT_CONFIG)),
importProvidersFrom(AppCommonModule),
{
provide: Configuration,
useFactory: () =>
new Configuration({
basePath: getGlobalConfig().GN4_API_URL,
}),
},
importProvidersFrom(EffectsModule.forRoot()),
],
bootstrap: [AppComponent],
})
export class AppModule {}
export class AppModule {
constructor() {
ThemeService.applyCssVariables(
getThemeConfig().PRIMARY_COLOR,
getThemeConfig().SECONDARY_COLOR,
getThemeConfig().MAIN_COLOR || '#475569',
getThemeConfig().BACKGROUND_COLOR,
getThemeConfig().MAIN_FONT || "'Rubik', sans-serif",
getThemeConfig().TITLE_FONT || "'Readex Pro', sans-serif",
getThemeConfig().FONTS_STYLESHEET_URL ||
'https://fonts.googleapis.com/css2?family=Readex+Pro&family=Rubik&display=swap'
)
}
}
7 changes: 7 additions & 0 deletions apps/metadata-editor/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MyOrgRecordsComponent } from './records/my-org-records/my-org-records.c
import { MyRecordsComponent } from './records/my-records/my-records.component'
import { MyDraftComponent } from './records/my-draft/my-draft.component'
import { MyLibraryComponent } from './records/my-library/my-library.component'
import { SearchRecordsComponent } from './records/search-records/search-records-list.component'

export const appRoutes: Route[] = [
{ path: '', component: DashboardPageComponent, pathMatch: 'prefix' },
Expand Down Expand Up @@ -52,6 +53,12 @@ export const appRoutes: Route[] = [
component: MyLibraryComponent,
pathMatch: 'prefix',
},
{
path: 'search',
title: 'Search Records',
component: SearchRecordsComponent,
pathMatch: 'prefix',
},
],
},
{ path: 'sign-in', component: SignInPageComponent },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#rlaMyOrg="routerLinkActive"
>
<mat-icon class="material-icons-outlined">home</mat-icon>
<span translate="">editor.dashboard.myOrg</span>
<span translate="">dashboard.records.myOrg</span>
</a>
<a
class="menu-item"
Expand All @@ -15,17 +15,17 @@
#rlaAll="routerLinkActive"
>
<mat-icon class="material-icons-outlined">work_outline</mat-icon>
<span translate="">editor.dashboard.catalog</span>
<span translate="">dashboard.records.all</span>
</a>
<div class="menu-title" translate="">editor.dashboard.mySpace</div>
<div class="menu-title" translate="">dashboard.labels.mySpace</div>
<a
class="menu-item"
routerLink="/records/my-records"
routerLinkActive
#rlaMyRecords="routerLinkActive"
>
<mat-icon class="material-icons-outlined">post_add</mat-icon>
<span translate="">editor.dashboard.myRecords</span>
<span translate="">dashboard.records.myRecords</span>
</a>
<a
class="menu-item"
Expand All @@ -34,7 +34,7 @@
#rlaMyDraft="routerLinkActive"
>
<mat-icon class="material-icons-outlined">edit_note</mat-icon>
<span translate="">editor.dashboard.myDraft</span>
<span translate="">dashboard.records.myDraft</span>
</a>
<a
class="menu-item"
Expand All @@ -43,6 +43,6 @@
#rlaMyLibrary="routerLinkActive"
>
<mat-icon class="material-icons-outlined">bookmark_border</mat-icon>
<span translate="">editor.dashboard.myLibrary</span>
<span translate="">dashboard.records.myLibrary</span>
</a>
</div>
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
import { NO_ERRORS_SCHEMA } from '@angular/core'
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { SearchFacade } from '@geonetwork-ui/feature/search'
import { DashboardPageComponent } from './dashboard-page.component'
import { CommonModule } from '@angular/common'
import {
PaginationButtonsComponent,
RecordTableComponent,
} from '../records/all-records/all-records-list.component.spec'

class SearchFacadeMock {}

describe('DashboardPageComponent', () => {
let component: DashboardPageComponent
let fixture: ComponentFixture<DashboardPageComponent>

beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [NO_ERRORS_SCHEMA],
imports: [DashboardPageComponent],
providers: [
{
provide: SearchFacade,
useClass: SearchFacadeMock,
},
],
})
.overrideComponent(DashboardPageComponent, {
set: {
imports: [
CommonModule,
RecordTableComponent,
PaginationButtonsComponent,
],
providers: [],
},
})
.compileComponents()
await TestBed.overrideComponent(DashboardPageComponent, {
set: {
imports: [CommonModule],
providers: [],
},
}).compileComponents()

fixture = TestBed.createComponent(DashboardPageComponent)
component = fixture.componentInstance
fixture.detectChanges()
})
afterEach(() => {
jest.clearAllMocks()
})

it('should create', () => {
expect(component).toBeTruthy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'
import { SearchFacade, SearchService } from '@geonetwork-ui/feature/search'
import { RouterOutlet } from '@angular/router'
import { SidebarComponent } from './sidebar/sidebar.component'
import { SearchHeaderComponent } from './search-header/search-header.component'
Expand All @@ -9,10 +8,7 @@ import { SearchHeaderComponent } from './search-header/search-header.component'
templateUrl: './dashboard-page.component.html',
styleUrls: ['./dashboard-page.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [SearchFacade, SearchService],
imports: [RouterOutlet, SidebarComponent, SearchHeaderComponent],
standalone: true,
})
export class DashboardPageComponent {
constructor(public searchFacade: SearchFacade) {}
}
export class DashboardPageComponent {}
48 changes: 0 additions & 48 deletions apps/metadata-editor/src/app/dashboard/dashboard-search.service.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:host ::ng-deep gn-ui-autocomplete input {
@apply bg-blue-50 rounded-3xl shadow-none !py-2 !px-8 hover:shadow-none focus:outline-4 focus:outline-offset-1 focus:outline-blue-100 focus:outline-dotted;
@apply bg-blue-50 rounded-3xl shadow-none !py-2 !px-8 !pl-14 hover:shadow-none focus:outline-4 focus:outline-offset-1 focus:outline-blue-100 focus:outline-dotted;
}
:host ::ng-deep gn-ui-autocomplete button {
display: none;
@apply bg-blue-50 hover:bg-blue-50 border-none shadow-none hover:shadow-none text-gray-500 hover:text-gray-600 left-0 right-auto rounded-3xl;
}

::ng-deep .mdc-menu-surface.mat-mdc-autocomplete-panel {
Expand Down
Loading

0 comments on commit e3fc6af

Please sign in to comment.