-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
108 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<React.Fragment> | ||
{children(preview, loading, data)} | ||
<Modal show={show} onHide={handleClose} dialogClassName="modal-xl"> | ||
<Modal.Header closeButton> | ||
<Modal.Title><Translate value="label.preview-provider">Preview XML</Translate></Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body><pre className="border p-2 bg-light rounded"><code>{data}</code></pre></Modal.Body> | ||
<Modal.Footer> | ||
<Button variant="secondary" onClick={() => downloadAsXml('metadata', data)}> | ||
<Translate value="action.download-file">Download File</Translate> | ||
</Button> | ||
<Button variant="primary" onClick={handleClose}> | ||
<Translate value="action.close">Close</Translate> | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
</React.Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters