From b88fde5dae628104164fc2b65e6ce79c6cbb761b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 18 Aug 2021 12:07:09 -0700 Subject: [PATCH 1/4] Nicer comment formatting Signed-off-by: snipe --- app/Http/Controllers/Api/UsersController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 5f6e0ae74c..a7e49898c3 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -282,9 +282,15 @@ class UsersController extends Controller $user = User::findOrFail($id); - // This is a janky hack to prevent people from changing admin demo user data on the public demo. - // The $ids 1 and 2 are special since they are seeded as superadmins in the demo seeder. - // Thanks, jerks. You are why we can't have nice things. - snipe + /** + * This is a janky hack to prevent people from changing admin demo user data on the public demo. + * + * The $ids 1 and 2 are special since they are seeded as superadmins in the demo seeder. + * + * Thanks, jerks. You are why we can't have nice things. - snipe + * + */ + if ((($id == 1) || ($id == 2)) && (config('app.lock_passwords'))) { return response()->json(Helper::formatStandardApiResponse('error', null, 'Permission denied. You cannot update user information via API on the demo.')); From 4207858a14bdad288a1eb5bbdb2f339dbfc42e08 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 18 Aug 2021 14:08:35 -0500 Subject: [PATCH 2/4] Fix the count in StatuslabelsController@getAssetsCountByStatuslabel() function that allows it to pass the correct index Also edit the default color for assets with the Pending label, so it match the color in the docs --- app/Helpers/Helper.php | 2 +- app/Http/Controllers/Api/StatuslabelsController.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index cd712c46ee..0cba900920 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -67,7 +67,7 @@ class Helper { $colors = [ "#008941", - "#FF4A46", + "#FF851B", "#006FA6", "#A30059", "#1CE6FF", diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php index 774fb70014..8d4b29a227 100644 --- a/app/Http/Controllers/Api/StatuslabelsController.php +++ b/app/Http/Controllers/Api/StatuslabelsController.php @@ -182,6 +182,7 @@ class StatuslabelsController extends Controller if ($statuslabel->color!='') { $colors_array[] = $statuslabel->color; + $default_color_count++; } else { $colors_array[] = Helper::defaultChartColors($default_color_count); $default_color_count++; From f04e23cacb0c5508caa39230e26a663901e9ab2f Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 18 Aug 2021 15:22:53 -0500 Subject: [PATCH 3/4] Add a small refactor so we not repeat logic --- app/Http/Controllers/Api/StatuslabelsController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php index 8d4b29a227..464ac5d77a 100644 --- a/app/Http/Controllers/Api/StatuslabelsController.php +++ b/app/Http/Controllers/Api/StatuslabelsController.php @@ -176,17 +176,15 @@ class StatuslabelsController extends Controller foreach ($statuslabels as $statuslabel) { if ($statuslabel->assets_count > 0) { - $labels[]=$statuslabel->name. ' ('.number_format($statuslabel->assets_count).')'; $points[]=$statuslabel->assets_count; if ($statuslabel->color!='') { $colors_array[] = $statuslabel->color; - $default_color_count++; } else { $colors_array[] = Helper::defaultChartColors($default_color_count); - $default_color_count++; } + $default_color_count++; } } From 4519f6e1809ed48c9e14a0289b02d23569e40a54 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Wed, 18 Aug 2021 14:13:31 -0700 Subject: [PATCH 4/4] Fixed sum total calculation on Bootstrap Table pages --- resources/views/partials/bootstrap-table.blade.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 7138ecf804..04f5d4cd74 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -595,11 +595,23 @@ } } + function cleanFloat(number) { + if ("{{$snipeSettings->digit_separator}}" == "1.234,56") { + // yank periods, change commas to periods + periodless = number.toString().replace("\.",""); + decimalfixed = periodless.replace(",","."); + } else { + // yank commas, that's it. + decimalfixed = number.toString().replace(",",""); + } + return parseFloat(decimalfixed); + } + function sumFormatter(data) { if (Array.isArray(data)) { var field = this.field; var total_sum = data.reduce(function(sum, row) { - return (sum) + (parseFloat(row[field]) || 0); + return (sum) + (cleanFloat(row[field]) || 0); }, 0); return numberWithCommas(total_sum.toFixed(2)); }