Skip to content

Commit

Permalink
feat: make changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Jul 2, 2024
1 parent 0225bdf commit 498ed25
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('dataset pages', () => {
})
})

describe.only('PREVIEW SECTION : display & functions', () => {
describe('PREVIEW SECTION : display & functions', () => {
beforeEach(() => {
cy.get('datahub-record-metadata')
.find('[id="preview"]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</div>
</div>
<gn-ui-data-view-share
[tabIndex]="selectedTabIndex$ | async"
[viewType]="selectedView$ | async"
></gn-ui-data-view-share>
<div
id="access"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class RecordMetadataComponent {

errorTypes = ErrorType

selectedTabIndex$ = new BehaviorSubject(0)
selectedView$ = new BehaviorSubject('map')

thumbnailUrl$ = this.metadataViewFacade.metadata$.pipe(
map((metadata) => {
Expand All @@ -108,7 +108,18 @@ export class RecordMetadataComponent {
) {}

onTabIndexChange(index: number): void {
this.selectedTabIndex$.next(index)
let view
switch (index) {
case 0:
view = 'map'
break
case 1:
view = 'table'
break
default:
view = 'chart'
}
this.selectedView$.next(view)
setTimeout(() => {
window.dispatchEvent(new Event('resize'))
}, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ export const WEB_COMPONENT_EMBEDDER_URL = new InjectionToken<string>(
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DataViewPermalinkComponent {
tabIndex$ = new BehaviorSubject<number>(0)
viewType$ = new BehaviorSubject<string>('map')
@Input()
set tabIndex(value: number) {
this.tabIndex$.next(value)
set viewType(value: string) {
this.viewType$.next(value)
}

permalinkUrl$ = combineLatest([
this.tabIndex$,
this.viewType$,
this.facade.chartConfig$,
this.facade.metadata$,
]).pipe(
map(([tabIndex, config, metadata]) => {
map(([viewType, config, metadata]) => {
const url = new URL(`${this.wcEmbedderBaseUrl}`, window.location.origin)
url.searchParams.set('v', `${this.version}`)
if (tabIndex === 2) {
if (viewType === 'chart') {
if (config) {
const { aggregation, xProperty, yProperty, chartType } = config
url.searchParams.append('e', `gn-dataset-view-chart`)
Expand All @@ -47,7 +47,7 @@ export class DataViewPermalinkComponent {
} else {
return ''
}
} else if (tabIndex === 1) {
} else if (viewType === 'table') {
// table
url.searchParams.append('e', `gn-dataset-view-table`)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<span class="tab-header-label-gray" translate>share.tab.permalink</span>
</ng-template>
<gn-ui-data-view-permalink
[tabIndex]="tabIndex"
[viewType]="viewType"
></gn-ui-data-view-permalink>
</mat-tab>
<mat-tab>
Expand All @@ -27,7 +27,7 @@
>
</ng-template>
<gn-ui-data-view-web-component
[tabIndex]="tabIndex"
[viewType]="viewType"
></gn-ui-data-view-web-component>
</mat-tab>
</mat-tab-group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ import { WEB_COMPONENT_EMBEDDER_URL } from '../data-view-permalink/data-view-per
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DataViewShareComponent {
@Input() tabIndex: number
private _viewType: string

@Input()
set viewType(value: string) {
this._viewType = value
}

get viewType(): string {
return this._viewType
}
constructor(
@Optional()
@Inject(WEB_COMPONENT_EMBEDDER_URL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ import { GN_UI_VERSION } from '../gn-ui-version.token'
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DataViewWebComponentComponent {
tabIndex$ = new BehaviorSubject<number>(0)
viewType$ = new BehaviorSubject<string>('map')
@Input()
set tabIndex(value: number) {
this.tabIndex$.next(value)
set viewType(value: string) {
this.viewType$.next(value)
}
webComponentHtml$ = combineLatest(
this.tabIndex$,
this.viewType$,
this.facade.chartConfig$,
this.facade.metadata$
).pipe(
map(([tabIndex, config, metadata]) => {
if (tabIndex === 2) {
map(([viewType, config, metadata]) => {
if (viewType === 'chart') {
if (config) {
const { aggregation, xProperty, yProperty, chartType } = config
return `<script src="https://cdn.jsdelivr.net/gh/geonetwork/geonetwork-ui@wc-dist-${
Expand All @@ -52,7 +52,7 @@ export class DataViewWebComponentComponent {
></gn-dataset-view-chart>`
}
return ''
} else if (tabIndex === 1) {
} else if (viewType === 'table') {
return `<script src="https://cdn.jsdelivr.net/gh/geonetwork/geonetwork-ui@wc-dist-${
this.version
}/gn-wc.js"></script>
Expand Down

0 comments on commit 498ed25

Please sign in to comment.