Skip to content

Commit

Permalink
docs: add remote debug port to gn, document
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow authored and Romuald Caplier committed Jul 24, 2024
1 parent 829e620 commit 337dee9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface MetadataResourceApiModel {
metadataResourceExternalManagementProperties?: MetadataResourceExternalManagementPropertiesApiModel
lastModification?: string
version?: string
url?: URL
url?: string
filename?: string
id?: string
size?: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ import { RecordsApiService } from '@geonetwork-ui/data-access/gn4'
import { UiInputsModule } from '@geonetwork-ui/ui/inputs'
import { FormControl } from '@angular/forms'
import { GraphicOverview } from '@geonetwork-ui/common/domain/model/record'
import { Subject, takeUntil } from 'rxjs'

const extractFileNameFormUrl = (url: URL, metadataUuid: string): string => {
const pattern = new RegExp(
`records/${metadataUuid}/attachments/([^/?#]+)(?:[/?#]|$)`,
'i'
)
const match = url.href.match(pattern)
import { Subject } from 'rxjs'

const extractFileNameFormUrl = (url: string): string => {
const pattern = new RegExp(`attachments/([^/?#]+)(?:[/?#]|$)`, 'i')
const match = url.match(pattern)
return match ? match[1] : ''
}

Expand All @@ -37,7 +34,8 @@ export class OverviewUploadComponent implements OnInit, OnDestroy {
@Input() formControl!: FormControl
@Output() overviewChange = new EventEmitter<GraphicOverview | null>()

imageAltText: string
imageAltText: string // = ressourceFileName by default
ressourceFileName: string
resourceUrl: URL

private destroy$ = new Subject<void>()
Expand All @@ -48,32 +46,33 @@ export class OverviewUploadComponent implements OnInit, OnDestroy {
) {}

ngOnInit(): void {
this.recordsApiService
.getAllResources(this.metadataUuid)
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (resources) => {
if (resources && resources.length > 0) {
this.resourceUrl = new URL(resources[0]?.url)
this.imageAltText = resources[0].filename
} else if (this.formControl.value[0]) {
this.resourceUrl = new URL(this.formControl.value[0].url.href)
this.imageAltText = this.formControl.value[0].description
} else {
this.resourceUrl = null
this.imageAltText = ''
}

this.cd.markForCheck()
},
error: this.errorHandle,
})
this.recordsApiService.getAllResources(this.metadataUuid).subscribe({
next: (resources) => {
if (resources && resources.length > 0) {
this.resourceUrl = new URL(resources[0]?.url)
this.imageAltText = resources[0].filename
this.ressourceFileName = extractFileNameFormUrl(resources[0]?.url)
} else if (this.formControl.value[0]) {
this.resourceUrl = new URL(this.formControl.value[0].url.href)
this.imageAltText = this.formControl.value[0].description
this.ressourceFileName = extractFileNameFormUrl(
this.formControl.value[0].url.href
)
} else {
this.resourceUrl = null
this.imageAltText = ''
this.ressourceFileName = ''
}

this.cd.markForCheck()
},
error: this.errorHandle,
})
}

handleFileChange(file: File) {
this.recordsApiService
.putResource(this.metadataUuid, file, 'public')
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (resource) => {
this.resourceUrl = new URL(resource.url)
Expand All @@ -93,7 +92,6 @@ export class OverviewUploadComponent implements OnInit, OnDestroy {
handleUrlChange(url: string) {
this.recordsApiService
.putResourceFromURL(this.metadataUuid, url, 'public')
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (resource) => {
this.resourceUrl = new URL(resource.url)
Expand All @@ -111,11 +109,8 @@ export class OverviewUploadComponent implements OnInit, OnDestroy {
}

handleDelete() {
const fileName = extractFileNameFormUrl(this.resourceUrl, this.metadataUuid)

this.recordsApiService
.delResource(this.metadataUuid, fileName)
.pipe(takeUntil(this.destroy$))
.delResource(this.metadataUuid, this.ressourceFileName)
.subscribe({
next: () => {
this.imageAltText = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('FormFieldComponent', () => {
By.directive(FormFieldOverviewsComponent)
).componentInstance
})
it('creates an array form field', () => {
it('creates an overview upload form field', () => {
expect(formField).toBeTruthy()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { FormFieldKeywordsComponent } from './form-field-keywords/form-field-key
import { FormFieldOverviewsComponent } from './form-field-overviews/form-field-overviews.component'
import { map, take } from 'rxjs/operators'
import { EditorFacade } from '../../../+state/editor.facade'
import { FormFieldConfig } from '../../../models'

@Component({
selector: 'gn-ui-form-field',
Expand Down
25 changes: 12 additions & 13 deletions libs/feature/editor/src/lib/fields.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,25 @@ export const RECORD_ABSTRACT_FIELD: EditorField = {
},
}

export const RECORD_GRAPHICAL_OVERVIEW_FIELD: EditorField = {
model: 'overviews',
formFieldConfig: {
labelKey: marker('editor.record.form.field.overviews'),
},
}

/************************************************************
*************** SECTIONS *****************
************************************************************
*/

export const TITLE_SECTION: EditorSection = {
hidden: false,
fields: [RECORD_TITLE_FIELD, RECORD_ABSTRACT_FIELD],
fields: [
RECORD_TITLE_FIELD,
RECORD_ABSTRACT_FIELD,
RECORD_GRAPHICAL_OVERVIEW_FIELD,
],
}

export const ABOUT_SECTION: EditorSection = {
Expand Down Expand Up @@ -167,18 +178,6 @@ export const DEFAULT_CONFIGURATION: EditorConfig = {
{
labelKey: marker('editor.record.form.page.description'),
sections: [TITLE_SECTION, ABOUT_SECTION, GEOGRAPHICAL_COVERAGE_SECTION],
{
model: 'overviews',
formFieldConfig: {
labelKey: marker('editor.record.form.overviews'),
type: 'list',
},
},
{
model: 'keywords',
formFieldConfig: {
labelKey: marker('editor.record.form.keywords'),
type: 'list',
},
{
labelKey: marker('editor.record.form.page.ressources'),
Expand Down

0 comments on commit 337dee9

Please sign in to comment.