mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
support info downloaded as txt
This commit is contained in:
@@ -71,27 +71,26 @@ const UploadFileForm: FC = () => {
|
|||||||
type: 'text/plain'
|
type: 'text/plain'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
anchor.download = 'emsesp_' + endpoint + '.json';
|
anchor.download = 'emsesp_' + endpoint;
|
||||||
anchor.click();
|
anchor.click();
|
||||||
URL.revokeObjectURL(anchor.href);
|
URL.revokeObjectURL(anchor.href);
|
||||||
toast.info(LL.DOWNLOAD_SUCCESSFUL());
|
toast.info(LL.DOWNLOAD_SUCCESSFUL());
|
||||||
};
|
};
|
||||||
|
|
||||||
onSuccessGetSettings((event) => {
|
onSuccessGetSettings((event) => {
|
||||||
saveFile(event.data, 'settings');
|
saveFile(event.data, 'settings.json');
|
||||||
});
|
});
|
||||||
onSuccessgetCustomizations((event) => {
|
onSuccessgetCustomizations((event) => {
|
||||||
saveFile(event.data, 'customizations');
|
saveFile(event.data, 'customizations.json');
|
||||||
});
|
});
|
||||||
onSuccessGetEntities((event) => {
|
onSuccessGetEntities((event) => {
|
||||||
saveFile(event.data, 'entities');
|
saveFile(event.data, 'entities.json');
|
||||||
});
|
});
|
||||||
onSuccessGetSchedule((event) => {
|
onSuccessGetSchedule((event) => {
|
||||||
saveFile(event.data, 'schedule');
|
saveFile(event.data, 'schedule.json');
|
||||||
});
|
});
|
||||||
onGetAPI((event) => {
|
onGetAPI((event) => {
|
||||||
const filename = event.sendArgs[0].device + '_' + event.sendArgs[0].entity;
|
saveFile(event.data, event.sendArgs[0].device + '_' + event.sendArgs[0].entity + '.txt');
|
||||||
saveFile(event.data, filename);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const downloadSettings = async () => {
|
const downloadSettings = async () => {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const Help: FC = () => {
|
|||||||
const { send: getAPI, onSuccess: onGetAPI } = useRequest((data) => EMSESP.API(data), {
|
const { send: getAPI, onSuccess: onGetAPI } = useRequest((data) => EMSESP.API(data), {
|
||||||
immediate: false
|
immediate: false
|
||||||
});
|
});
|
||||||
|
|
||||||
onGetAPI((event) => {
|
onGetAPI((event) => {
|
||||||
const anchor = document.createElement('a');
|
const anchor = document.createElement('a');
|
||||||
anchor.href = URL.createObjectURL(
|
anchor.href = URL.createObjectURL(
|
||||||
@@ -25,11 +26,12 @@ const Help: FC = () => {
|
|||||||
type: 'text/plain'
|
type: 'text/plain'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
anchor.download = 'emsesp_' + event.sendArgs[0].device + '_' + event.sendArgs[0].entity + '.json';
|
anchor.download = 'emsesp_' + event.sendArgs[0].device + '_' + event.sendArgs[0].entity + '.txt';
|
||||||
anchor.click();
|
anchor.click();
|
||||||
URL.revokeObjectURL(anchor.href);
|
URL.revokeObjectURL(anchor.href);
|
||||||
toast.info(LL.DOWNLOAD_SUCCESSFUL());
|
toast.info(LL.DOWNLOAD_SUCCESSFUL());
|
||||||
});
|
});
|
||||||
|
|
||||||
const callAPI = async (device: string, entity: string) => {
|
const callAPI = async (device: string, entity: string) => {
|
||||||
await getAPI({ device, entity, id: 0 }).catch((error) => {
|
await getAPI({ device, entity, id: 0 }).catch((error) => {
|
||||||
toast.error(error.message);
|
toast.error(error.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user