diff --git a/ProjectClock/AccountViewController.swift b/ProjectClock/AccountViewController.swift index d39ece2..d5a8327 100644 --- a/ProjectClock/AccountViewController.swift +++ b/ProjectClock/AccountViewController.swift @@ -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 */ diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard index 01b2e90..e47a0aa 100644 --- a/ProjectClock/Base.lproj/Main.storyboard +++ b/ProjectClock/Base.lproj/Main.storyboard @@ -874,7 +874,7 @@ - + @@ -948,8 +948,22 @@ - + +