Setting crypto params from admin panel pt II

This commit is contained in:
Marcin Łojewski
2018-12-24 14:47:55 +01:00
parent 436c1d930d
commit 5045c7d931
3 changed files with 19 additions and 10 deletions

View File

@@ -56,3 +56,10 @@
background-color: #ff8f00; background-color: #ff8f00;
color: #fff; color: #fff;
} }
#user_sql .loading {
display: inline-block;
height: 32px;
margin: 5px 0;
width: 32px;
}

View File

@@ -62,15 +62,17 @@ user_sql.adminSettingsUI = function () {
var cryptoChanged = function () { var cryptoChanged = function () {
var div = $("#opt-crypto_params"); var div = $("#opt-crypto_params");
div.empty(); div.empty();
div.append("<span class=\"icon loading\"></span>");
var cryptoClass = $("#opt-crypto_class").val(); var cryptoClass = $("#opt-crypto_class").val();
$.get(OC.generateUrl("/apps/user_sql/settings/crypto/params"), cryptoClass, function (data) { $.get(OC.generateUrl("/apps/user_sql/settings/crypto/params"), cryptoClass, function (data) {
div.empty();
if (data.status === "success") { if (data.status === "success") {
for (var index = 0, length = data.data.length; index < length; ++index) { for (var index = 0, length = data.data.length; index < length; ++index) {
div.append("<div><label for=\"opt-crypto_param_" div.append("<div><label for=\"opt-crypto_param_"
+ index + index
+ "\"><span>" + "\"><span>"
+ data.data[index]["visible_name"] + data.data[index]["name"]
+ "</span><input type=\"number\" id=\"opt-crypto_param_" + "</span><input type=\"number\" id=\"opt-crypto_param_"
+ index + index
+ "\" name=\"opt-crypto_param_" + "\" name=\"opt-crypto_param_"
@@ -80,7 +82,7 @@ user_sql.adminSettingsUI = function () {
+ "\" max=\"" + "\" max=\""
+ data.data[index]["max"] + data.data[index]["max"]
+ "\" value=\"" + "\" value=\""
+ data.data[index]["default"] // TODO set current + data.data[index]["value"]
+ "\"></label></div>"); + "\"></label></div>");
} }
} }

View File

@@ -375,25 +375,25 @@ class SettingsController extends Controller
*/ */
public function cryptoParams() public function cryptoParams()
{ {
sleep(3);
// TODO implement // TODO implement
// TODO add current values // TODO add current values
return [ return [
"status" => "success", "status" => "success",
"data" => [ "data" => [
[ [
"name" => "memoryCost", "name" => "Memory cost (KiB)",
"visible_name" => "Memory cost (KiB)", "value" => PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
"default" => PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
"min" => 1, "max" => 1048576 "min" => 1, "max" => 1048576
], ],
[ [
"name" => "timeCost", "visible_name" => "Time cost", "name" => "Time cost",
"default" => PASSWORD_ARGON2_DEFAULT_TIME_COST, "min" => 1, "value" => PASSWORD_ARGON2_DEFAULT_TIME_COST, "min" => 1,
"max" => 1024 "max" => 1024
], ],
[ [
"name" => "threads", "visible_name" => "Threads", "name" => "Threads",
"default" => PASSWORD_ARGON2_DEFAULT_THREADS, "min" => 1, "value" => PASSWORD_ARGON2_DEFAULT_THREADS, "min" => 1,
"max" => 1024 "max" => 1024
] ]
] ]