-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #886 from geonetwork/wc-figure-md-count
Datasets figure web component
- Loading branch information
Showing
11 changed files
with
141 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
apps/webcomponents/src/app/components/gn-figure-datasets/gn-figure-datasets.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '../../../styles.css'; |
7 changes: 7 additions & 0 deletions
7
apps/webcomponents/src/app/components/gn-figure-datasets/gn-figure-datasets.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<gn-ui-figure | ||
class="" | ||
[figure]="recordsCount$ | async" | ||
[icon]="'folder_open'" | ||
title="catalog.figures.datasets" | ||
[color]="'secondary'" | ||
></gn-ui-figure> |
42 changes: 42 additions & 0 deletions
42
apps/webcomponents/src/app/components/gn-figure-datasets/gn-figure-datasets.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
Component, | ||
Injector, | ||
ViewEncapsulation, | ||
} from '@angular/core' | ||
import { BaseComponent } from '../base.component' | ||
import { RecordsService } from '@geonetwork-ui/feature/catalog' | ||
import { catchError, startWith } from 'rxjs/operators' | ||
import { Observable, of } from 'rxjs' | ||
import { SearchFacade } from '@geonetwork-ui/feature/search' | ||
|
||
@Component({ | ||
selector: 'wc-gn-figure-datasets', | ||
templateUrl: './gn-figure-datasets.component.html', | ||
styleUrls: ['./gn-figure-datasets.component.css'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.ShadowDom, | ||
providers: [SearchFacade], | ||
}) | ||
export class GnFigureDatasetsComponent extends BaseComponent { | ||
catalogRecords: RecordsService | ||
recordsCount$: Observable<string | number> | ||
|
||
constructor(injector: Injector, private changeDetector: ChangeDetectorRef) { | ||
super(injector) | ||
this.catalogRecords = injector.get(RecordsService) | ||
this.recordsCount$ = this.catalogRecords.recordsCount$.pipe( | ||
startWith('-'), | ||
catchError(() => of('-')) | ||
) | ||
} | ||
|
||
init(): void { | ||
super.init() | ||
} | ||
|
||
changes(): void { | ||
super.changes() | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
apps/webcomponents/src/app/components/gn-figure-datasets/gn-figure-datasets.sample.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Web Component Demo - Figure datasets</title> | ||
<base href="./" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@200;300;400;500;600;700&display=swap" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<style> | ||
body { | ||
margin: 0; | ||
font-family: 'Inter', sans-serif; | ||
} | ||
main { | ||
margin: 5rem; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<main> | ||
<h3>Figure - Datasets</h3> | ||
<div> | ||
<script src="gn-wc.js"></script> | ||
|
||
<gn-figure-datasets | ||
api-url="https://demo.georchestra.org/geonetwork/srv/api" | ||
primary-color="#0f4395" | ||
secondary-color="#8bc832" | ||
main-color="#555" | ||
background-color="#fdfbff" | ||
main-font="'Inter', sans-serif" | ||
title-font="'DM Serif Display', serif" | ||
></gn-figure-datasets> | ||
</div> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { Injectable } from '@angular/core' | ||
import { Observable, of } from 'rxjs' | ||
import { catchError, shareReplay } from 'rxjs/operators' | ||
import { Observable, of, switchMap } from 'rxjs' | ||
import { shareReplay } from 'rxjs/operators' | ||
import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class RecordsService { | ||
recordsCount$: Observable<number> = this.recordsRepository | ||
.getMatchesCount({}) | ||
.pipe( | ||
shareReplay(1), | ||
catchError(() => of(0)) | ||
) | ||
recordsCount$: Observable<number> = of(true).pipe( | ||
switchMap(() => this.recordsRepository.getMatchesCount({})), | ||
shareReplay(1) | ||
) | ||
|
||
constructor(private recordsRepository: RecordsRepositoryInterface) {} | ||
} |