From c24673fefaff0d25896b5605c7604b2eb9865311 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 4 Jan 2023 16:49:47 +0100 Subject: [PATCH] (quality) log errors to the JS console --- .../components/reservations/reservations-summary.tsx | 2 +- .../src/javascript/controllers/admin/authentications.js | 2 ++ app/frontend/src/javascript/controllers/admin/events.js | 2 ++ app/frontend/src/javascript/controllers/admin/invoices.js | 1 + app/frontend/src/javascript/controllers/admin/machines.js | 1 + app/frontend/src/javascript/controllers/admin/members.js | 2 ++ app/frontend/src/javascript/controllers/admin/orders.js | 1 + app/frontend/src/javascript/controllers/admin/plans.js | 3 +++ app/frontend/src/javascript/controllers/admin/pricing.js | 1 + app/frontend/src/javascript/controllers/admin/projects.js | 1 + app/frontend/src/javascript/controllers/admin/settings.js | 2 ++ app/frontend/src/javascript/controllers/admin/store.js | 1 + .../src/javascript/controllers/admin/store_products.js | 1 + app/frontend/src/javascript/controllers/admin/trainings.js | 2 ++ app/frontend/src/javascript/controllers/cart.js | 1 + app/frontend/src/javascript/controllers/dashboard.js | 1 + app/frontend/src/javascript/controllers/machines.js.erb | 5 +++++ app/frontend/src/javascript/controllers/members.js | 1 + app/frontend/src/javascript/controllers/orders.js | 1 + app/frontend/src/javascript/controllers/plans.js | 1 + app/frontend/src/javascript/controllers/products.js | 1 + app/frontend/src/javascript/controllers/profile.js | 1 + app/frontend/src/javascript/controllers/spaces.js.erb | 2 ++ app/frontend/src/javascript/controllers/store.js | 1 + app/services/availabilities/availabilities_service.rb | 3 ++- 25 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/frontend/src/javascript/components/reservations/reservations-summary.tsx b/app/frontend/src/javascript/components/reservations/reservations-summary.tsx index b49c386fc..8d9db7685 100644 --- a/app/frontend/src/javascript/components/reservations/reservations-summary.tsx +++ b/app/frontend/src/javascript/components/reservations/reservations-summary.tsx @@ -50,7 +50,7 @@ const ReservationsSummary: React.FC = ({ slot, custome }, [slot]); useEffect(() => { - if (customer) { + if (customer && cart) { CartAPI.setCustomer(cart, customer.id).then(setCart).catch(onError); } }, [customer]); diff --git a/app/frontend/src/javascript/controllers/admin/authentications.js b/app/frontend/src/javascript/controllers/admin/authentications.js index c62229b03..8dcab8592 100644 --- a/app/frontend/src/javascript/controllers/admin/authentications.js +++ b/app/frontend/src/javascript/controllers/admin/authentications.js @@ -121,6 +121,7 @@ Application.Controllers.controller('NewAuthenticationController', ['$scope', '$s * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -147,6 +148,7 @@ Application.Controllers.controller('EditAuthenticationController', ['$scope', '$ * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/events.js b/app/frontend/src/javascript/controllers/admin/events.js index f04ba3a61..61688a2e6 100644 --- a/app/frontend/src/javascript/controllers/admin/events.js +++ b/app/frontend/src/javascript/controllers/admin/events.js @@ -454,6 +454,7 @@ Application.Controllers.controller('NewEventController', ['$scope', '$state', 'C * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -483,6 +484,7 @@ Application.Controllers.controller('EditEventController', ['$scope', '$state', ' * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/invoices.js b/app/frontend/src/javascript/controllers/admin/invoices.js index 6e94f0667..5cd67caa2 100644 --- a/app/frontend/src/javascript/controllers/admin/invoices.js +++ b/app/frontend/src/javascript/controllers/admin/invoices.js @@ -125,6 +125,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/machines.js b/app/frontend/src/javascript/controllers/admin/machines.js index c60686e5b..f3a3e4d01 100644 --- a/app/frontend/src/javascript/controllers/admin/machines.js +++ b/app/frontend/src/javascript/controllers/admin/machines.js @@ -23,6 +23,7 @@ Application.Controllers.controller('AdminMachinesController', ['$scope', 'CSRF', * Shows an error message forwarded from a child component */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/members.js b/app/frontend/src/javascript/controllers/admin/members.js index 6d6408f59..e690d908e 100644 --- a/app/frontend/src/javascript/controllers/admin/members.js +++ b/app/frontend/src/javascript/controllers/admin/members.js @@ -869,6 +869,7 @@ Application.Controllers.controller('EditMemberController', ['$scope', '$state', * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; @@ -1055,6 +1056,7 @@ Application.Controllers.controller('NewMemberController', ['$scope', '$state', ' * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/orders.js b/app/frontend/src/javascript/controllers/admin/orders.js index 3c6bc077f..b1783638c 100644 --- a/app/frontend/src/javascript/controllers/admin/orders.js +++ b/app/frontend/src/javascript/controllers/admin/orders.js @@ -15,6 +15,7 @@ Application.Controllers.controller('AdminShowOrdersController', ['$rootScope', ' * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/plans.js b/app/frontend/src/javascript/controllers/admin/plans.js index a413b9ebc..ab80d0824 100644 --- a/app/frontend/src/javascript/controllers/admin/plans.js +++ b/app/frontend/src/javascript/controllers/admin/plans.js @@ -30,6 +30,7 @@ Application.Controllers.controller('NewPlanController', ['$scope', '$uibModal', * Shows an error message forwarded from a child component */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -56,6 +57,7 @@ Application.Controllers.controller('EditPlanController', ['$scope', 'groups', 'p * Shows an error message forwarded from a child component */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -87,6 +89,7 @@ Application.Controllers.controller('PlanCategoriesController', ['$scope', 'growl }; $scope.onError = function (message) { + console.error(message); growl.error(message); }; } diff --git a/app/frontend/src/javascript/controllers/admin/pricing.js b/app/frontend/src/javascript/controllers/admin/pricing.js index 4891e921a..6d2995a54 100644 --- a/app/frontend/src/javascript/controllers/admin/pricing.js +++ b/app/frontend/src/javascript/controllers/admin/pricing.js @@ -652,6 +652,7 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state', * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/projects.js b/app/frontend/src/javascript/controllers/admin/projects.js index e721bda34..c184a67f9 100644 --- a/app/frontend/src/javascript/controllers/admin/projects.js +++ b/app/frontend/src/javascript/controllers/admin/projects.js @@ -276,6 +276,7 @@ Application.Controllers.controller('AdminProjectsController', ['$scope', '$state * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/settings.js b/app/frontend/src/javascript/controllers/admin/settings.js index cff1dfcc1..4e07dcc30 100644 --- a/app/frontend/src/javascript/controllers/admin/settings.js +++ b/app/frontend/src/javascript/controllers/admin/settings.js @@ -325,6 +325,7 @@ Application.Controllers.controller('SettingsController', ['$scope', '$rootScope' * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -471,6 +472,7 @@ Application.Controllers.controller('SettingsController', ['$scope', '$rootScope' }; $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/store.js b/app/frontend/src/javascript/controllers/admin/store.js index d4500246a..e106355b8 100644 --- a/app/frontend/src/javascript/controllers/admin/store.js +++ b/app/frontend/src/javascript/controllers/admin/store.js @@ -40,6 +40,7 @@ Application.Controllers.controller('AdminStoreController', ['$scope', 'CSRF', 'g * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/store_products.js b/app/frontend/src/javascript/controllers/admin/store_products.js index dc72476a4..b6565e537 100644 --- a/app/frontend/src/javascript/controllers/admin/store_products.js +++ b/app/frontend/src/javascript/controllers/admin/store_products.js @@ -16,6 +16,7 @@ Application.Controllers.controller('AdminStoreProductController', ['$scope', 'CS * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/admin/trainings.js b/app/frontend/src/javascript/controllers/admin/trainings.js index a69d22c97..ebd172e90 100644 --- a/app/frontend/src/javascript/controllers/admin/trainings.js +++ b/app/frontend/src/javascript/controllers/admin/trainings.js @@ -96,6 +96,7 @@ Application.Controllers.controller('NewTrainingController', ['$scope', '$state', * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -137,6 +138,7 @@ Application.Controllers.controller('EditTrainingController', ['$scope', '$state' * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/cart.js b/app/frontend/src/javascript/controllers/cart.js index 2d5a0005d..382980a7f 100644 --- a/app/frontend/src/javascript/controllers/cart.js +++ b/app/frontend/src/javascript/controllers/cart.js @@ -39,6 +39,7 @@ Application.Controllers.controller('CartController', ['$scope', 'CSRF', 'growl', * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/dashboard.js b/app/frontend/src/javascript/controllers/dashboard.js index bf33f6f91..19e2f6459 100644 --- a/app/frontend/src/javascript/controllers/dashboard.js +++ b/app/frontend/src/javascript/controllers/dashboard.js @@ -47,6 +47,7 @@ Application.Controllers.controller('DashboardController', ['$scope', 'memberProm * Callback used in PaymentScheduleDashboard, in case of error */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/machines.js.erb b/app/frontend/src/javascript/controllers/machines.js.erb index de25fed88..0a43b0661 100644 --- a/app/frontend/src/javascript/controllers/machines.js.erb +++ b/app/frontend/src/javascript/controllers/machines.js.erb @@ -114,6 +114,7 @@ Application.Controllers.controller('MachinesController', ['$scope', '$state', '_ * Shows an error message forwarded from a child component */ $scope.onError = function (message) { + console.error(message); growl.error(message); } @@ -238,6 +239,7 @@ Application.Controllers.controller('NewMachineController', ['$scope', '$state', * Shows an error message forwarded from a child component */ $scope.onError = function (message) { + console.error(message); growl.error(message); } @@ -270,6 +272,7 @@ Application.Controllers.controller('EditMachineController', ['$scope', '$state', * Shows an error message forwarded from a child component */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -344,6 +347,7 @@ Application.Controllers.controller('ShowMachineController', ['$scope', '$state', * Shows an error message forwarded from a child component */ $scope.onError = function (message) { + console.error(message); growl.error(message); } @@ -643,6 +647,7 @@ Application.Controllers.controller('ReserveMachineController', ['$scope', '$tran * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/members.js b/app/frontend/src/javascript/controllers/members.js index 0f40d51f1..5667c7ce1 100644 --- a/app/frontend/src/javascript/controllers/members.js +++ b/app/frontend/src/javascript/controllers/members.js @@ -289,6 +289,7 @@ Application.Controllers.controller('EditProfileController', ['$scope', '$rootSco * @param message {string} */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/orders.js b/app/frontend/src/javascript/controllers/orders.js index badec5b50..0a73f3fe9 100644 --- a/app/frontend/src/javascript/controllers/orders.js +++ b/app/frontend/src/javascript/controllers/orders.js @@ -15,6 +15,7 @@ Application.Controllers.controller('ShowOrdersController', ['$rootScope', '$scop * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/plans.js b/app/frontend/src/javascript/controllers/plans.js index 3431ef582..0425e7967 100644 --- a/app/frontend/src/javascript/controllers/plans.js +++ b/app/frontend/src/javascript/controllers/plans.js @@ -99,6 +99,7 @@ Application.Controllers.controller('PlansIndexController', ['$scope', '$rootScop * @param message {string} */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/products.js b/app/frontend/src/javascript/controllers/products.js index 401a1a75c..077fe0f54 100644 --- a/app/frontend/src/javascript/controllers/products.js +++ b/app/frontend/src/javascript/controllers/products.js @@ -28,6 +28,7 @@ Application.Controllers.controller('ShowProductController', ['$scope', 'CSRF', ' * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/profile.js b/app/frontend/src/javascript/controllers/profile.js index dbdea73da..9a23dea42 100644 --- a/app/frontend/src/javascript/controllers/profile.js +++ b/app/frontend/src/javascript/controllers/profile.js @@ -216,6 +216,7 @@ Application.Controllers.controller('CompleteProfileController', ['$scope', '$roo * @param message {string} */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/spaces.js.erb b/app/frontend/src/javascript/controllers/spaces.js.erb index 2fc4de648..13899c7c2 100644 --- a/app/frontend/src/javascript/controllers/spaces.js.erb +++ b/app/frontend/src/javascript/controllers/spaces.js.erb @@ -228,6 +228,7 @@ Application.Controllers.controller('NewSpaceController', ['$scope', '$state', 'C * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; @@ -256,6 +257,7 @@ Application.Controllers.controller('EditSpaceController', ['$scope', '$state', ' * Callback triggered by react components */ $scope.onError = function (message) { + console.error(message); growl.error(message); }; diff --git a/app/frontend/src/javascript/controllers/store.js b/app/frontend/src/javascript/controllers/store.js index e5a6fd3dd..a7a6f5e81 100644 --- a/app/frontend/src/javascript/controllers/store.js +++ b/app/frontend/src/javascript/controllers/store.js @@ -11,6 +11,7 @@ Application.Controllers.controller('StoreController', ['$scope', 'CSRF', 'growl' * Callback triggered in case of error */ $scope.onError = (message) => { + console.error(message); growl.error(message); }; diff --git a/app/services/availabilities/availabilities_service.rb b/app/services/availabilities/availabilities_service.rb index 4b0bb1460..ed4c790ae 100644 --- a/app/services/availabilities/availabilities_service.rb +++ b/app/services/availabilities/availabilities_service.rb @@ -28,7 +28,8 @@ class Availabilities::AvailabilitiesService # list all slots for the given machines, with visibility relative to the given user def machines(machines, user, window) - ma_availabilities = Availability.includes('machines_availabilities') + ma_availabilities = Availability.includes(:machines_availabilities, :availability_tags, :machines, :slots_reservations, + slots: [:slots_reservations]) .where('machines_availabilities.machine_id': machines.map(&:id)) availabilities = availabilities(ma_availabilities, 'machines', user, window[:start], window[:end])