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

geonetwork / geonetwork-ui / 17860518616

19 Sep 2025 02:01PM UTC coverage: 84.469% (+0.07%) from 84.4%
17860518616

push

github

web-flow
Merge pull request #1355 from geonetwork/dh-download-links-forkjoin-inner-errors

[Datahub]: download links fixes on errors

3795 of 5026 branches covered (75.51%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

113 existing lines in 31 files now uncovered.

10824 of 12281 relevant lines covered (88.14%)

353.76 hits per line

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

84.0
/libs/feature/record/src/lib/data-view/data-view.component.ts
1
import {
1✔
2
  ChangeDetectionStrategy,
3
  Component,
4
  EventEmitter,
5
  Input,
6
  Output,
7
} from '@angular/core'
8
import {
1✔
9
  getLinkId,
10
  getLinkLabel,
11
  getLinkPriority,
12
} from '@geonetwork-ui/util/shared'
13
import { BehaviorSubject, combineLatest } from 'rxjs'
1✔
14
import { map, tap } from 'rxjs/operators'
1✔
15
import { MdViewFacade } from '../state'
1✔
16
import { DatavizChartConfigModel } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model'
17
import { DatasetOnlineResource } from '@geonetwork-ui/common/domain/model/record'
18
import { DropdownSelectorComponent } from '@geonetwork-ui/ui/inputs'
1✔
19
import {
1✔
20
  ChartViewComponent,
21
  TableViewComponent,
22
} from '@geonetwork-ui/feature/dataviz'
23
import { CommonModule } from '@angular/common'
1✔
24
import { TranslateDirective, TranslatePipe } from '@ngx-translate/core'
1✔
25
import { PopupAlertComponent } from '@geonetwork-ui/ui/widgets'
1✔
26

27
@Component({
28
  selector: 'gn-ui-data-view',
29
  templateUrl: './data-view.component.html',
30
  styleUrls: ['./data-view.component.css'],
31
  changeDetection: ChangeDetectionStrategy.OnPush,
32
  standalone: true,
33
  imports: [
34
    CommonModule,
35
    DropdownSelectorComponent,
36
    TableViewComponent,
37
    TranslateDirective,
38
    TranslatePipe,
39
    ChartViewComponent,
40
    PopupAlertComponent,
41
  ],
42
})
43
export class DataViewComponent {
1✔
44
  @Input() mode: 'table' | 'chart'
45
  @Input() displaySource = true
12✔
46
  @Input() set exceedsLimit(value: boolean) {
47
    this.excludeWfs$.next(value)
×
48
  }
49
  linkMap: Map<string, DatasetOnlineResource> = new Map()
12✔
50
  _selectedView = ''
12✔
51
  _chartConfig = null
12✔
52
  _selectedChoice = null
12✔
53
  @Input() set selectedView(value: string) {
54
    this._selectedView = value
2✔
55
    if (this.mode === value) {
2!
56
      this.linkSelected.emit(this.selectedLink$.value)
×
57
    }
58
  }
59
  @Input() set datavizConfig(value: any) {
60
    if ((value && value.view === 'table') || value.view === 'chart') {
3✔
61
      this._selectedView = value.view
2✔
62
    }
63
    if (this.mode === value.view) {
3✔
64
      if (!value.source) {
2!
UNCOV
65
        this.linkSelected.emit(this.selectedLink$.value)
×
66
      } else {
67
        this._chartConfig = value.chartConfig
2✔
68
        this._selectedChoice = getLinkId(value.source)
2✔
69
        this.selectedLink$.next(value.source)
2✔
70
      }
71
    }
72
  }
73
  @Output() chartConfig$ = new BehaviorSubject<DatavizChartConfigModel>(null)
12✔
74
  @Output() linkSelected = new EventEmitter<DatasetOnlineResource>()
12✔
75
  cacheActive$ = this.mdViewFacade.isHighUpdateFrequency$.pipe(
12✔
UNCOV
76
    map((highF) => !highF)
×
77
  )
78
  excludeWfs$ = new BehaviorSubject(false)
12✔
79
  compatibleDataLinks$ = combineLatest([
12✔
80
    this.mdViewFacade.dataLinks$,
81
    this.mdViewFacade.geoDataLinks$,
82
  ]).pipe(
83
    map(([dataLinks, geoDataLinks]) => {
84
      const a = [...dataLinks, ...geoDataLinks]
8✔
85
      a.sort((a, b) => getLinkPriority(b) - getLinkPriority(a))
40✔
86
      return a
8✔
87
    })
88
  )
89
  dropdownChoices$ = this.compatibleDataLinks$.pipe(
12✔
90
    tap((links: DatasetOnlineResource[]) => {
91
      this.linkMap.clear()
8✔
92
      links.forEach((link: DatasetOnlineResource) =>
8✔
93
        this.linkMap.set(getLinkId(link), link)
32✔
94
      )
95
      if (!links.some((l) => l.url === this.selectedLink$.value?.url)) {
32!
96
        this.selectLink(getLinkId(links[0]))
8✔
97
      }
98
    }),
99
    map((links) =>
100
      links.map((link: DatasetOnlineResource) => ({
32✔
101
        label: getLinkLabel(link),
102
        value: getLinkId(link),
103
      }))
104
    )
105
  )
106
  selectedLink$ = new BehaviorSubject<DatasetOnlineResource>(null)
12✔
107

108
  hidePreview$ = this.excludeWfs$.pipe(
12✔
109
    map((excludeWfs) => this.mode === 'chart' && excludeWfs)
13✔
110
  )
111

112
  constructor(private mdViewFacade: MdViewFacade) {}
12!
113

114
  setChartConfig(event: DatavizChartConfigModel) {
115
    this.mdViewFacade.setChartConfig(event)
3✔
116
  }
117

118
  selectLink(linkId: string) {
119
    const link = this.linkMap.get(linkId)
10✔
120
    if (this._selectedView && this._selectedView === this.mode) {
10!
UNCOV
121
      this.linkSelected.emit(link)
×
122
    }
123
    this.selectedLink$.next(link)
10✔
124
  }
125
}
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