From 7d70c4d8cdff782613c12b4c96a36f878b6e9051 Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Thu, 2 Sep 2021 16:13:31 +0200 Subject: [PATCH] Code optimizations --- server/server.js | 10 ++++------ src/pages/Settings.vue | 7 +++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/server/server.js b/server/server.js index a795e2187..e1f24ae1f 100644 --- a/server/server.js +++ b/server/server.js @@ -556,14 +556,12 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString(); try { checkLogin(socket) - console.log(`Importing Backup, User ID: ${socket.userID}, Version: ${uploadedJSON[0]}`) + let backupData = JSON.parse(uploadedJSON); - let notificationList = uploadedJSON[1]; - let monitorList = uploadedJSON[2]; + console.log(`Importing Backup, User ID: ${socket.userID}, Version: ${backupData.version}`) - monitorList = JSON.stringify(monitorList); - monitorList = JSON.parse(monitorList); - monitorList = Object.values(monitorList); + let notificationList = backupData.notificationList; + let monitorList = backupData.monitorList; if (notificationList.length >= 1) { for (let i = 0; i < notificationList.length; i++) { diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue index c82a170c5..ff6920cba 100644 --- a/src/pages/Settings.vue +++ b/src/pages/Settings.vue @@ -304,10 +304,11 @@ export default { downloadBackup() { let time = dayjs().format("YYYY_MM_DD-hh_mm_ss"); let fileName = `Uptime_Kuma_Backup_${time}.json`; + let monitorList = Object.values(this.$root.monitorList); let exportData = { version: this.$root.info.version, notificationList: this.$root.notificationList, - monitorList: this.$root.monitorList, + monitorList: monitorList, } exportData = JSON.stringify(exportData); let downloadItem = document.createElement("a"); @@ -326,9 +327,7 @@ export default { fileReader.readAsText(uploadItem.item(0)); fileReader.onload = item => { - let resultParse = JSON.parse(item.target.result); - let result = Object.values(resultParse); - this.$root.uploadBackup(result, (res) => { + this.$root.uploadBackup(item.target.result, (res) => { if (res.ok) { toast.success(res.msg); } else {