diff --git a/backend/src/main/resources/entity-attributes-filters-ui-schema.json b/backend/src/main/resources/entity-attributes-filters-ui-schema.json index d34412613..1db03af99 100644 --- a/backend/src/main/resources/entity-attributes-filters-ui-schema.json +++ b/backend/src/main/resources/entity-attributes-filters-ui-schema.json @@ -45,13 +45,6 @@ "value": { "title": "label.filter-target-value", "type": "array", - "buttons": [ - { - "id": "preview", - "label": "action.preview", - "widget": "icon-button" - } - ], "minItems": 1, "uniqueItems": true, "items": { diff --git a/ui/src/app/core/utility/download_as_xml.js b/ui/src/app/core/utility/download_as_xml.js index 0ce61cca3..a9256fc63 100644 --- a/ui/src/app/core/utility/download_as_xml.js +++ b/ui/src/app/core/utility/download_as_xml.js @@ -1,7 +1,6 @@ import * as FileSaver from 'file-saver'; -export const downloadAsXml = (entity, xml) => { - const name = entity.name ? entity.name : entity.serviceProviderName; +export const downloadAsXml = (fileName, xml) => { const blob = new Blob([xml], { type: 'text/xml;charset=utf-8' }); - FileSaver.saveAs(blob, `${name}.xml`); + FileSaver.saveAs(blob, `${fileName}.xml`); } \ No newline at end of file diff --git a/ui/src/app/form/component/fields/FilterTargetField.js b/ui/src/app/form/component/fields/FilterTargetField.js index cae1caccc..750792d8e 100644 --- a/ui/src/app/form/component/fields/FilterTargetField.js +++ b/ui/src/app/form/component/fields/FilterTargetField.js @@ -2,7 +2,7 @@ import React from 'react'; import Dropdown from 'react-bootstrap/Dropdown'; import Translate from '../../../i18n/components/translate'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faAsterisk, faCaretDown, faCaretUp, faPlus, faTrash } from '@fortawesome/free-solid-svg-icons'; +import { faAsterisk, faCaretDown, faCaretUp, faEye, faEyeSlash, faPlus, faSpinner, faTrash } from '@fortawesome/free-solid-svg-icons'; import { useTranslator } from '../../../i18n/hooks'; import { InfoIcon } from '../InfoIcon'; import ContentEditable from 'react-contenteditable'; @@ -12,6 +12,8 @@ import queryString from 'query-string'; import API_BASE_PATH from '../../../App.constant'; import isNil from 'lodash/isNil'; +import { FilterTargetPreview } from '../../../metadata/hoc/FilterTargetPreview'; + const ToggleButton = ({ isOpen, onClick, disabled }) => ( - + + {(preview, loading, xml) => ( + + {id} + + {preview && + + } + + + + )} + )} diff --git a/ui/src/app/metadata/component/properties/ArrayProperty.js b/ui/src/app/metadata/component/properties/ArrayProperty.js index 321f8cd7a..87ed2cc25 100644 --- a/ui/src/app/metadata/component/properties/ArrayProperty.js +++ b/ui/src/app/metadata/component/properties/ArrayProperty.js @@ -4,7 +4,7 @@ import React from 'react'; import Translate from '../../../i18n/components/translate'; import { usePropertyWidth } from './hooks'; import { PropertyValue } from './PropertyValue'; - +import { FilterTargetPreview } from '../../hoc/FilterTargetPreview'; const isUri = (value) => { @@ -20,7 +20,7 @@ const isUrl = (str) => { return isUri(str); } -export function ArrayProperty ({ property, columns, onPreview }) { +export function ArrayProperty ({ property, columns, preview }) { const width = usePropertyWidth(columns); @@ -98,15 +98,20 @@ export function ArrayProperty ({ property, columns, onPreview }) { {(v && v.length > 0) && diff --git a/ui/src/app/metadata/component/properties/FilterTargetProperty.js b/ui/src/app/metadata/component/properties/FilterTargetProperty.js index cc7490af8..d58dacbb6 100644 --- a/ui/src/app/metadata/component/properties/FilterTargetProperty.js +++ b/ui/src/app/metadata/component/properties/FilterTargetProperty.js @@ -2,13 +2,14 @@ import React from 'react'; import { ArrayProperty } from './ArrayProperty'; import { PrimitiveProperty } from './PrimitiveProperty'; -export function FilterTargetProperty ({ property, columns, onPreview }) { +export function FilterTargetProperty ({ property, columns }) { + return ( <> {property.properties.map((prop, idx) => { prop.type === 'array' ? - + : } diff --git a/ui/src/app/metadata/component/properties/ObjectProperty.js b/ui/src/app/metadata/component/properties/ObjectProperty.js index d42107161..2afb157ac 100644 --- a/ui/src/app/metadata/component/properties/ObjectProperty.js +++ b/ui/src/app/metadata/component/properties/ObjectProperty.js @@ -3,24 +3,18 @@ import React from 'react'; import { PrimitiveProperty } from './PrimitiveProperty'; import { ArrayProperty } from './ArrayProperty'; import Translate from '../../../i18n/components/translate'; -import { FilterTargetProperty } from './FilterTargetProperty'; export function ObjectProperty ({ property, columns, onPreview }) { const getProperty = (prop, idx) => { switch(prop.type) { case 'array': - return + return case 'object': return - {prop.widget && prop.widget.id && prop.widget.id === 'filter-target' ? - - : - - {prop.name &&
} - -
- } - + + {prop.name &&
} + +
default: return diff --git a/ui/src/app/metadata/component/properties/PropertyValue.js b/ui/src/app/metadata/component/properties/PropertyValue.js index 1797ae4cc..807c86e61 100644 --- a/ui/src/app/metadata/component/properties/PropertyValue.js +++ b/ui/src/app/metadata/component/properties/PropertyValue.js @@ -4,7 +4,7 @@ import OverlayTrigger from 'react-bootstrap/OverlayTrigger'; import { usePropertyWidth } from './hooks'; -export function PropertyValue ({ name, value, columns }) { +export function PropertyValue ({ name, value, columns, className }) { const width = usePropertyWidth(columns); @@ -17,13 +17,13 @@ export function PropertyValue ({ name, value, columns }) { )}> {value !== undefined ? value.toString() : (value === false) ? value.toString() : '-'} - : -} + : -} ); } \ No newline at end of file diff --git a/ui/src/app/metadata/hoc/FilterTargetPreview.js b/ui/src/app/metadata/hoc/FilterTargetPreview.js new file mode 100644 index 000000000..0ddcadc0d --- /dev/null +++ b/ui/src/app/metadata/hoc/FilterTargetPreview.js @@ -0,0 +1,57 @@ +import React from 'react'; +import API_BASE_PATH from '../../App.constant'; +import { useFetch } from 'use-http'; +import Modal from 'react-bootstrap/Modal'; +import Button from 'react-bootstrap/Button'; +import Translate from '../../i18n/components/translate'; +import { downloadAsXml } from '../../core/utility/download_as_xml'; + +export function FilterTargetPreview ({ entityId, children }) { + + const [show, setShow] = React.useState(false); + + const preview = () => { + setShow(true); + }; + + const handleClose = () => { + setShow(false); + }; + + //encodeURIComponent(id) + /*eaders: new HttpHeaders({ + 'Accept': 'application/xml' + }), + responseType: 'text'*/ + + const { data, loading } = useFetch(`${API_BASE_PATH}/entities/${ encodeURIComponent(entityId) }`, { + cachePolicy: 'no-cache', + headers: { + 'Content-Type': 'application/xml', + 'Accept': 'application/xml' + }, + responseType: 'text' + }, [entityId]); + + console.log(data); + + return ( + + {children(preview, loading, data)} + + + Preview XML + +
{data}
+ + + + +
+
+ ); +} \ No newline at end of file diff --git a/ui/src/app/metadata/view/MetadataXml.js b/ui/src/app/metadata/view/MetadataXml.js index 4a39b22f9..c83872eea 100644 --- a/ui/src/app/metadata/view/MetadataXml.js +++ b/ui/src/app/metadata/view/MetadataXml.js @@ -15,7 +15,7 @@ export function MetadataXml () { const entity = React.useContext(MetadataObjectContext); const { type } = useParams(); - const download = () => downloadAsXml(entity, xml); + const download = () => downloadAsXml(entity.name ? entity.name : entity.serviceProviderName, xml); return ( <>