Skip to content

Commit

Permalink
Fix #9295 added better handling of format in csw service (#9712)
Browse files Browse the repository at this point in the history
* Fix #9295 added better handling of format in csw service
  • Loading branch information
MV88 authored Nov 22, 2023
1 parent 08ca6a9 commit 44b8131
Show file tree
Hide file tree
Showing 22 changed files with 219 additions and 197 deletions.
2 changes: 2 additions & 0 deletions web/client/actions/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const SAVING_SERVICE = 'CATALOG:SAVING_SERVICE';
export const CATALOG_INITED = 'CATALOG:INIT';
export const GET_METADATA_RECORD_BY_ID = 'CATALOG:GET_METADATA_RECORD_BY_ID';
export const SET_LOADING = 'CATALOG:SET_LOADING';
export const SHOW_FORMAT_ERROR = 'CATALOG:SHOW_FORMAT_ERROR';
export const TOGGLE_TEMPLATE = 'CATALOG:TOGGLE_TEMPLATE';
export const TOGGLE_THUMBNAIL = 'CATALOG:TOGGLE_THUMBNAIL';
export const TOGGLE_ADVANCED_SETTINGS = 'CATALOG:TOGGLE_ADVANCED_SETTINGS';
Expand Down Expand Up @@ -285,6 +286,7 @@ export const toggleThumbnail = () => ({type: TOGGLE_THUMBNAIL});
export const formatOptionsFetch = (url, force) => ({type: FORMAT_OPTIONS_FETCH, url, force});
export const formatsLoading = (loading) => ({type: FORMAT_OPTIONS_LOADING, loading});
export const setSupportedFormats = (formats, url) => ({type: SET_FORMAT_OPTIONS, formats, url});
export const showFormatError = (status) => ({type: SHOW_FORMAT_ERROR, status});

import {error} from './notifications';

Expand Down
2 changes: 2 additions & 0 deletions web/client/components/catalog/CatalogServiceEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const CatalogServiceEditor = ({
formatOptions,
buttonStyle,
saving,
showFormatError,
onChangeServiceFormat = () => {},
onChangeMetadataTemplate = () => {},
onToggleAdvancedSettings = () => { },
Expand Down Expand Up @@ -100,6 +101,7 @@ const CatalogServiceEditor = ({
currentWMSCatalogLayerSize={layerOptions.tileSize ? layerOptions.tileSize : 256}
selectedService={selectedService}
onFormatOptionsFetch={onFormatOptionsFetch}
showFormatError={showFormatError}
formatsLoading={formatsLoading}
infoFormatOptions={infoFormatOptions}
autoSetVisibilityLimits={autoSetVisibilityLimits}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ describe('Test CatalogServiceEditor', () => {
layerOptions={{tileSize: 256}}
/>, document.getElementById("container"));

const formatFormGroups = [...document.querySelectorAll('.form-group')].filter(fg => {
const labels = [...fg.querySelectorAll('label')];
return labels.length === 1 && labels[0].textContent === 'layerProperties.format.title';
});
expect(formatFormGroups.length).toBe(1);
const formatSelect = formatFormGroups[0].querySelector('.Select-value-label');
const formatFormGroups = [...document.querySelectorAll('.form-group-flex')];
expect(formatFormGroups.length).toBe(5);
const formatSelect = formatFormGroups[2].querySelector('.Select-value-label');
expect(formatSelect).toExist();
expect(formatSelect.textContent).toBe('image/png8');
// expect(formatSelect.props.options).toEqual(formatOptions); TODO: test properties are passed to select
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from "react";
import {
Col,
ControlLabel,
FormGroup,
Glyphicon,
Expand Down Expand Up @@ -59,14 +58,14 @@ const FilterCode = ({ type, code, setCode, error }) => {
const filterProp = `${type}Filter`;
return (
<FormGroup>
<Col xs={4}>
<div className="label-pre-textarea">
<ControlLabel>
<Message msgId={`catalog.filter.${type}.label`} />
</ControlLabel>
<FilterInfo tooltip={tooltip(type)} />
{error[type] && renderError}
</Col>
<Col xs={8} style={{ marginBottom: 5 }}>
</div>
<div className="textarea-code">
<CodeMirror
value={code[filterProp]}
options={options}
Expand All @@ -75,7 +74,7 @@ const FilterCode = ({ type, code, setCode, error }) => {
}}
/>
{type === 'dynamic' && renderHelpText}
</Col>
</div>
</FormGroup>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import React from 'react';
import { isNil } from 'lodash';
import { FormGroup, Checkbox, Col } from "react-bootstrap";
import { FormGroup, Checkbox } from "react-bootstrap";

import Message from "../../../I18N/Message";
import InfoPopover from '../../../widgets/widget/InfoPopover';
Expand All @@ -25,44 +25,36 @@ export default ({
onChangeServiceProperty = () => { },
onToggleThumbnail = () => { }
}) => (
<div>
<>
<FormGroup controlId="autoload" key="autoload">
<Col xs={12}>
{service.autoload !== undefined && <Checkbox value="autoload" onChange={(e) => onChangeServiceProperty("autoload", e.target.checked)}
checked={!isNil(service.autoload) ? service.autoload : false}>
<Message msgId="catalog.autoload" />
</Checkbox>}
</Col>
{service.autoload !== undefined && <Checkbox value="autoload" onChange={(e) => onChangeServiceProperty("autoload", e.target.checked)}
checked={!isNil(service.autoload) ? service.autoload : false}>
<Message msgId="catalog.autoload" />
</Checkbox>}
</FormGroup>
<FormGroup controlId="thumbnail" key="thumbnail">
<Col xs={12}>
<Checkbox
onChange={() => onToggleThumbnail()}
checked={!isNil(service.hideThumbnail) ? !service.hideThumbnail : true}>
<Message msgId="catalog.showPreview" />
</Checkbox>
</Col>
<Checkbox
onChange={() => onToggleThumbnail()}
checked={!isNil(service.hideThumbnail) ? !service.hideThumbnail : true}>
<Message msgId="catalog.showPreview" />
</Checkbox>
</FormGroup>
{!isNil(service.type) && service.type === "wfs" &&
<FormGroup controlId="allowUnsecureLayers" key="allowUnsecureLayers">
<Col xs={12}>
<Checkbox
onChange={(e) => onChangeServiceProperty("allowUnsecureLayers", e.target.checked)}
checked={!isNil(service.allowUnsecureLayers) ? service.allowUnsecureLayers : false}>
<Message msgId="catalog.allowUnsecureLayers.label" />&nbsp;<InfoPopover text={<Message msgId="catalog.allowUnsecureLayers.tooltip" />} />
</Checkbox>
</Col>
<Checkbox
onChange={(e) => onChangeServiceProperty("allowUnsecureLayers", e.target.checked)}
checked={!isNil(service.allowUnsecureLayers) ? service.allowUnsecureLayers : false}>
<Message msgId="catalog.allowUnsecureLayers.label" />&nbsp;<InfoPopover text={<Message msgId="catalog.allowUnsecureLayers.tooltip" />} />
</Checkbox>
</FormGroup>}
{!isNil(service.type) && service.type === "cog" &&
<FormGroup controlId="fetchMetadata" key="fetchMetadata">
<Col xs={12}>
<Checkbox
onChange={(e) => onChangeServiceProperty("fetchMetadata", e.target.checked)}
checked={!isNil(service.fetchMetadata) ? service.fetchMetadata : true}>
<Message msgId="catalog.fetchMetadata.label" />&nbsp;<InfoPopover text={<Message msgId="catalog.fetchMetadata.tooltip" />} />
</Checkbox>
</Col>
<Checkbox
onChange={(e) => onChangeServiceProperty("fetchMetadata", e.target.checked)}
checked={!isNil(service.fetchMetadata) ? service.fetchMetadata : true}>
<Message msgId="catalog.fetchMetadata.label" />&nbsp;<InfoPopover text={<Message msgId="catalog.fetchMetadata.tooltip" />} />
</Checkbox>
</FormGroup>}
{children}
</div>
</>
);
Loading

0 comments on commit 44b8131

Please sign in to comment.