Make sure (1) config is updated before exporting; (2) plaintext config is exported correctly

This commit is contained in:
Shreya 2021-06-01 12:52:37 +05:30 committed by VakarisZ
parent f4b5d341cf
commit d67e84a6a7
2 changed files with 8 additions and 4 deletions

View File

@ -38,7 +38,8 @@ const ConfigExportModal = (props: Props) => {
.then(res => {
let configToExport = res['to_export'];
if (res['is_plaintext'] === true) {
const configAsBinary = new Blob([configToExport], {type: 'text/plain;charset=utf-8'});
const configAsBinary = new Blob([JSON.stringify(configToExport, null, 2)],
{type: 'text/plain;charset=utf-8'});
FileSaver.saveAs(configAsBinary, 'monkey.conf');
}
else {

View File

@ -369,6 +369,11 @@ class ConfigurePageComponent extends AuthComponent {
this.authFetch(apiEndpoint, request_options);
}
exportConfig = () => {
this.updateConfigSection();
this.setState({showConfigExportModal: true});
};
sendConfig() {
return (
this.authFetch('/api/configuration/island',
@ -500,9 +505,7 @@ class ConfigurePageComponent extends AuthComponent {
Import config
</button>
<button type='button'
onClick={() => {
this.setState({showConfigExportModal: true})
}}
onClick={this.exportConfig}
className='btn btn-info btn-lg' style={{margin: '5px'}}>
Export config
</button>