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

geonetwork / geonetwork-ui / 16344326661

17 Jul 2025 11:50AM UTC coverage: 83.441% (-0.3%) from 83.756%
16344326661

Pull #1278

github

web-flow
Merge 8a0fac427 into d500b08cc
Pull Request #1278: (wip) Read config viz

3497 of 4711 branches covered (74.23%)

Branch coverage included in aggregate %.

58 of 105 new or added lines in 6 files covered. (55.24%)

2 existing lines in 2 files now uncovered.

10013 of 11480 relevant lines covered (87.22%)

272.35 hits per line

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

68.57
/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
8✔
46
  @Input() set exceedsLimit(value: boolean) {
47
    this.excludeWfs$.next(value)
×
48
  }
49
  linkMap: Map<string, DatasetOnlineResource> = new Map()
8✔
50
  _selectedView = ''
8✔
51
  _chartConfig = null
8✔
52
  _selectedChoice = null
8✔
53
  @Input() set selectedView(value: string) {
54
    this._selectedView = value
×
NEW
55
    if (this.mode === value) {
×
56
      this.linkSelected.emit(this.selectedLink$.value)
×
57
    }
58
  }
59
  @Input() set datavizConfig(value: any) {
NEW
60
    this._selectedView = value.view
×
NEW
61
    if (this.mode === value.view) {
×
NEW
62
      if (!value.source) {
×
NEW
63
        this.linkSelected.emit(this.selectedLink$.value)
×
64
      } else {
NEW
65
        this._chartConfig = value.chartConfig
×
NEW
66
        this._selectedChoice = getLinkId(value.source)
×
NEW
67
        this.selectedLink$.next(value.source)
×
68
      }
69
    }
70
  }
71
  @Output() chartConfig$ = new BehaviorSubject<DatavizChartConfigModel>(null)
8✔
72
  @Output() linkSelected = new EventEmitter<DatasetOnlineResource>()
8✔
73
  cacheActive$ = this.mdViewFacade.isHighUpdateFrequency$.pipe(
8✔
74
    map((highF) => !highF)
×
75
  )
76
  excludeWfs$ = new BehaviorSubject(false)
8✔
77
  compatibleDataLinks$ = combineLatest([
8✔
78
    this.mdViewFacade.dataLinks$,
79
    this.mdViewFacade.geoDataLinks$,
80
  ]).pipe(
81
    map(([dataLinks, geoDataLinks]) => {
82
      const a = [...dataLinks, ...geoDataLinks]
4✔
83
      a.sort((a, b) => getLinkPriority(b) - getLinkPriority(a))
20✔
84
      return a
4✔
85
    })
86
  )
87
  dropdownChoices$ = this.compatibleDataLinks$.pipe(
8✔
88
    tap((links: DatasetOnlineResource[]) => {
89
      this.linkMap.clear()
4✔
90
      links.forEach((link: DatasetOnlineResource) =>
4✔
91
        this.linkMap.set(getLinkId(link), link)
16✔
92
      )
93
      if (!links.some((l) => l.url === this.selectedLink$.value?.url)) {
16!
94
        this.selectLink(getLinkId(links[0]))
4✔
95
      }
96
    }),
97
    map((links) =>
98
      links.map((link: DatasetOnlineResource) => ({
16✔
99
        label: getLinkLabel(link),
100
        value: getLinkId(link),
101
      }))
102
    )
103
  )
104
  selectedLink$ = new BehaviorSubject<DatasetOnlineResource>(null)
8✔
105

106
  hidePreview$ = this.excludeWfs$.pipe(
8✔
107
    map((excludeWfs) => this.mode === 'chart' && excludeWfs)
9✔
108
  )
109

110
  constructor(private mdViewFacade: MdViewFacade) {}
8!
111

112
  setChartConfig(event: DatavizChartConfigModel) {
113
    this.mdViewFacade.setChartConfig(event)
3✔
114
  }
115

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