uploading zip in restore

This commit is contained in:
sanjayk03-dev
2024-06-07 05:44:09 +05:30
parent 4a526e0012
commit facc1eb700
2 changed files with 27 additions and 25 deletions

View File

@@ -61,32 +61,34 @@ module.exports = {
return;
}
const fileReader = new FileReader();
fileReader.onload = async ({ target }) => {
let config;
try {
config = JSON.parse(target.result);
} catch (error) {
console.error("Invalid config file:", error);
alert("Invalid config file");
return;
}
console.log(files);
try {
await api.put("config/save", config);
this.$dispatch("update");
SvelteComponents.showDialog("Message", {
title: "Success",
message: "Configuration restored"
});
this.confirmReset= false
} catch (error) {
console.error("Restore failed:", error);
alert("Restore failed");
}
};
// const fileReader = new FileReader();
// fileReader.onload = async ({ target }) => {
// let config;
// try {
// config = JSON.parse(target.result);
// } catch (error) {
// console.error("Invalid config file:", error);
// alert("Invalid config file");
// return;
// }
fileReader.readAsText(files[0]);
// try {
// await api.put("config/save", config);
// this.$dispatch("update");
// SvelteComponents.showDialog("Message", {
// title: "Success",
// message: "Configuration restored"
// });
// this.confirmReset= false
// } catch (error) {
// console.error("Restore failed:", error);
// alert("Restore failed");
// }
// };
// fileReader.readAsText(files[0]);
},
next: async function() {

View File

@@ -17,7 +17,7 @@ script#admin-general-view-template(type="text/x-template")
label.pure-button.pure-button-primary(@click="restore_config") Restore
form.restore-config.file-upload
input(type="file", accept=".json", @change="restore")
input(type="file", accept=".zip", @change="restore")
button.pure-button.pure-button-primary(@click="confirmReset = true") Reset
message(:show.sync="confirmReset")