• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geonetwork / geonetwork-ui / 15584387607

11 Jun 2025 12:06PM UTC coverage: 83.7% (-0.6%) from 84.332%
15584387607

Pull #1261

github

web-flow
Merge 0edb75069 into 609dd7257
Pull Request #1261: [Bug fix]: Use maxFeatureCount for all WFS links

3478 of 4674 branches covered (74.41%)

Branch coverage included in aggregate %.

26 of 29 new or added lines in 7 files covered. (89.66%)

20 existing lines in 5 files now uncovered.

10032 of 11467 relevant lines covered (87.49%)

261.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.71
/apps/datahub/src/app/record/record-data-preview/record-data-preview.component.ts
1
import { CommonModule } from '@angular/common'
4✔
2
import {
4✔
3
  ChangeDetectionStrategy,
4
  Component,
5
  Inject,
6
  InjectionToken,
7
  OnDestroy,
8
  Optional,
9
} from '@angular/core'
10
import { MatInkBar, MatTabsModule } from '@angular/material/tabs'
4✔
11
import { DatasetOnlineResource } from '@geonetwork-ui/common/domain/model/record'
12
import { DataService } from '@geonetwork-ui/feature/dataviz'
4✔
13
import {
4✔
14
  DataViewComponent,
15
  DataViewShareComponent,
16
  MapViewComponent,
17
  MdViewFacade,
18
} from '@geonetwork-ui/feature/record'
19
import { PopupAlertComponent } from '@geonetwork-ui/ui/widgets'
4✔
20
import { TranslateModule } from '@ngx-translate/core'
4✔
21
import {
4✔
22
  BehaviorSubject,
23
  combineLatest,
24
  map,
25
  of,
26
  startWith,
27
  Subscription,
28
  switchMap,
29
  take,
30
} from 'rxjs'
31

32
export const MAX_FEATURE_COUNT = new InjectionToken<string>('maxFeatureCount')
4✔
33

34
@Component({
35
  selector: 'datahub-record-data-preview',
36
  templateUrl: './record-data-preview.component.html',
37
  styleUrls: ['./record-data-preview.component.css'],
38
  changeDetection: ChangeDetectionStrategy.OnPush,
39
  standalone: true,
40
  imports: [
41
    CommonModule,
42
    MatTabsModule,
43
    TranslateModule,
44
    DataViewShareComponent,
45
    DataViewComponent,
46
    MapViewComponent,
47
    PopupAlertComponent,
48
  ],
49
})
50
export class RecordDataPreviewComponent implements OnDestroy {
4✔
51
  private subscription = new Subscription()
30✔
52

53
  displayMap$ = combineLatest([
30✔
54
    this.metadataViewFacade.mapApiLinks$,
55
    this.metadataViewFacade.geoDataLinksWithGeometry$,
56
  ]).pipe(
57
    map(([mapApiLinks, geoDataLinksWithGeometry]) => {
58
      return mapApiLinks?.length > 0 || geoDataLinksWithGeometry?.length > 0
164✔
59
    }),
60
    startWith(false)
61
  )
62

63
  displayData$ = combineLatest([
30✔
64
    this.metadataViewFacade.dataLinks$,
65
    this.metadataViewFacade.geoDataLinks$,
66
  ]).pipe(
67
    map(
68
      ([dataLinks, geoDataLinks]) =>
69
        dataLinks?.length > 0 || geoDataLinks?.length > 0
176✔
70
    )
71
  )
72

73
  selectedView$ = new BehaviorSubject('map')
30✔
74

75
  exceedsMaxFeatureCount$ = combineLatest([
30✔
76
    this.metadataViewFacade.geoDataLinksWithGeometry$,
77
    this.metadataViewFacade.selectedLinks$,
78
    this.selectedView$,
79
  ]).pipe(
80
    map(([links, selectedLinks, selectedView]) => {
81
      const link = selectedLinks?.find(
96✔
82
        (selected) => selected.view === selectedView
4✔
83
      )?.link
84
      return link && link != null ? link : links[0]
96✔
85
    }),
86
    switchMap((link) => {
87
      return link && link.accessServiceProtocol === 'wfs'
86✔
88
        ? this.dataService
89
            .getWfsFeatureCount(link.url.toString(), link.name)
90
            .pipe(map((count) => count > this.maxFeatureCount))
5✔
91
        : of(false)
92
    })
93
  )
94

95
  displayViewShare$ = combineLatest([
30✔
96
    this.displayMap$,
97
    this.displayData$,
98
    this.selectedView$,
99
    this.exceedsMaxFeatureCount$,
100
  ]).pipe(
101
    map(
102
      ([displayMap, displayData, selectedView, exceedsMaxFeatureCount]) =>
103
        (displayData || displayMap) &&
84✔
104
        !(selectedView === 'chart' && exceedsMaxFeatureCount)
45✔
105
    )
106
  )
107

108
  constructor(
109
    public metadataViewFacade: MdViewFacade,
30!
110
    private dataService: DataService,
30✔
111
    @Inject(MAX_FEATURE_COUNT)
112
    @Optional()
113
    protected maxFeatureCount: number
30✔
114
  ) {}
115

116
  onTabIndexChange(index: number): void {
117
    let view
UNCOV
118
    switch (index) {
×
119
      case 0:
UNCOV
120
        view = 'map'
×
121
        break
×
122
      case 1:
123
        view = 'table'
×
UNCOV
124
        break
×
125
      default:
126
        view = 'chart'
×
127
    }
128
    this.selectedView$.next(view)
×
UNCOV
129
    setTimeout(() => {
×
UNCOV
130
      window.dispatchEvent(new Event('resize'))
×
131
    }, 0)
132
  }
133
  onSelectedLinkChange(link: DatasetOnlineResource) {
134
    this.subscription.add(
1✔
135
      combineLatest(this.metadataViewFacade.selectedLinks$, this.selectedView$)
136
        .pipe(
137
          take(1),
138
          map(([selectedLinks, selectedView]) => {
139
            const filteredLinks = selectedLinks.filter(
1✔
140
              (link) => link.view !== selectedView
1✔
141
            )
142
            this.metadataViewFacade.setSelectedLinks([
1✔
143
              ...filteredLinks,
144
              { view: selectedView, link: link },
145
            ])
146
          })
147
        )
148
        .subscribe()
149
    )
150
  }
151

152
  ngOnDestroy(): void {
153
    this.subscription.unsubscribe()
30✔
154
  }
155
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc