[+] Implement upload and download backup

This commit is contained in:
Hykilpikonna
2021-01-25 23:00:53 -05:00
parent f1b8b794d3
commit b263824429
3 changed files with 45 additions and 5 deletions
+26
View File
@@ -177,6 +177,32 @@ class ManageVC: UIViewController
}
}
/**
Called when the user clicks the upload backup button
*/
@IBAction func uploadBackup(_ sender: Any)
{
sendReq(APIs.uploadConfig, title: "Uploading...", params: ["config": localStorage.string(forKey: "alarms")!])
{ it in self.msg("Success!", "You're backed up.") }
}
/**
Called when the user clicks the download backup button
*/
@IBAction func downloadBackup(_ sender: Any)
{
sendReq(APIs.downloadConfig, title: "Downloading...")
{
// Save backup
localStorage.setValue($0, forKey: "alarms")
// Update UI
AlarmViewController.staticTable?.reloadData()
self.msg("Success!", "You're restored your backup.")
}
}
/**
Called when the user clicks the logout button
*/