More buttons
This commit is contained in:
parent
7d833e48e1
commit
2ac02688ab
@ -50,10 +50,16 @@ class SettingsController(
|
||||
}
|
||||
|
||||
fun export(request: Request, jwtPayload: JwtPayload): Response {
|
||||
val isDownload = request.form("download") != null
|
||||
val json = userService.export(jwtPayload.userId)
|
||||
return Response(Status.OK).body(json).header("Content-Type", "application/json")
|
||||
val res = Response(Status.OK).body(json).header("Content-Type", "application/json")
|
||||
return if (isDownload) res.header("Content-Disposition",
|
||||
"attachment; filename=\"simplenotes-export-${sanitizeFilename(jwtPayload.username)}.json\"")
|
||||
else res
|
||||
}
|
||||
|
||||
private fun sanitizeFilename(inputName: String): String = inputName.replace("[^a-zA-Z0-9-_.]".toRegex(), "_")
|
||||
|
||||
private fun Request.deleteForm(jwtPayload: JwtPayload) =
|
||||
DeleteForm(jwtPayload.username, form("password"), form("checked") != null)
|
||||
}
|
||||
|
||||
@ -32,7 +32,8 @@ class SettingView(staticFileResolver: StaticFileResolver) : View(staticFileResol
|
||||
}
|
||||
|
||||
form(method = FormMethod.post, action = "/export") {
|
||||
button(classes = "btn btn-teal block", type = submit) { +"Export my data" }
|
||||
button(name = "display", classes = "btn btn-teal block", type = submit) { +"Display my data" }
|
||||
button(name = "download", classes = "btn btn-green block mt-2", type = submit) { +"Download my data" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user