From ca0d60b86734390a7c2b4f2327c1f4c268bb55e4 Mon Sep 17 00:00:00 2001 From: Christian de Jonge Date: Tue, 28 Jan 2025 08:18:42 +0100 Subject: [PATCH] Fix SNYK suggestions --- .editorconfig | 510 ------------------ .../MissionSchedulingControllerTests.cs | 2 +- .../MissionSchedulingController.cs | 9 +- .../InspectionFindingEventHandler.cs | 4 +- backend/api/EventHandlers/MqttEventHandler.cs | 5 +- backend/api/Services/EchoService.cs | 40 +- .../api/Services/MissionSchedulingService.cs | 3 +- backend/api/Services/Models/IsarMission.cs | 2 +- backend/api/Services/ReturnToHomeService.cs | 3 +- backend/d1.py | 0 frontend/package-lock.json | 18 +- frontend/src/api/ApiCaller.tsx | 2 +- .../src/components/Contexts/AuthProvider.tsx | 10 +- .../RobotDisplays/BatteryStatusDisplay.tsx | 8 +- .../RobotDisplays/RobotStatusIcon.tsx | 6 +- .../FrontPage/MissionOverview/StopDialogs.tsx | 2 +- .../InspectionPage/InspectionUtilities.tsx | 7 +- .../MissionDefinitionPage.tsx | 2 +- .../MapPosition/MissionMapView.tsx | 33 +- .../Pages/MissionPage/StatusReason.tsx | 4 - frontend/src/utils/InspectionAreaMapView.tsx | 32 +- .../src/utils/IsRobotReadyToRunMissions.tsx | 14 +- 22 files changed, 115 insertions(+), 601 deletions(-) delete mode 100644 .editorconfig delete mode 100644 backend/d1.py diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80e53dcb1..000000000 --- a/.editorconfig +++ /dev/null @@ -1,510 +0,0 @@ -# Docs: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference - -# top-most EditorConfig file -root = true - -# Don't use tabs for indentation. -[*] -indent_style = space -trim_trailing_whitespace = true -insert_final_newline = true - -# Code files -[*.{cs,csx,vb,vbx}] -indent_size = 4 -charset = utf-8-bom - -# Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] -indent_size = 4 - -# Xml config files -[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,xml,stylecop}] -indent_size = 2 - -# JSON files -[*.{json,json5}] -indent_size = 2 - -# YAML Files -[*.{yml,yaml}] -indent_size = 2 - -#### .NET Coding Conventions #### -[*.{cs,csx,cake,vb}] - -# Organize usings -dotnet_separate_import_directive_groups = false -dotnet_sort_system_directives_first = true - -# Avoid "this." and "Me." if not necessary -dotnet_style_qualification_for_event = false : warning -dotnet_style_qualification_for_field = false : warning -dotnet_style_qualification_for_method = false : warning -dotnet_style_qualification_for_property = false : warning - -# Use language keywords instead of framework type names for type references -dotnet_style_predefined_type_for_locals_parameters_members = true : warning -dotnet_style_predefined_type_for_member_access = true : warning - -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning - -# Modifier preferences -dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning - -# Expression-level preferences -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_null_propagation = true:suggestion -dotnet_style_object_initializer = true:suggestion -dotnet_style_operator_placement_when_wrapping = beginning_of_line -dotnet_style_prefer_auto_properties = true:suggestion -dotnet_style_prefer_compound_assignment = true:suggestion -dotnet_style_prefer_conditional_expression_over_assignment = true:silent -dotnet_style_prefer_conditional_expression_over_return = true:silent -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_inferred_tuple_names = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_simplified_boolean_expressions = true:suggestion -dotnet_style_prefer_simplified_interpolation = true:suggestion - -# Field preferences -dotnet_style_readonly_field = true:warning - -# Parameter preferences -dotnet_code_quality_unused_parameters = all:suggestion - -# Suppression preferences -dotnet_remove_unnecessary_suppression_exclusions = none - -#### C# Coding Conventions #### -[*.cs] -# Prefer "var" everywhere (Implicit and explicit types) -csharp_style_var_elsewhere =true:suggestion -csharp_style_var_for_built_in_types = false:suggestion -csharp_style_var_when_type_is_apparent = true:warning - -# Expression-Bodied members -csharp_style_expression_bodied_accessors = true:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_lambdas = true:silent -csharp_style_expression_bodied_local_functions = false:silent -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent - -# Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_prefer_not_pattern = true:suggestion -csharp_style_prefer_pattern_matching = true:silent -csharp_style_prefer_switch_expression = true:suggestion - -# Null-checking preferences -csharp_style_conditional_delegate_call = true:warning - -# Modifier preferences -csharp_prefer_static_local_function = true:suggestion -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion - -# Code-block preferences -csharp_prefer_braces = true:silent -csharp_prefer_simple_using_statement = true:suggestion - -# Expression-level preferences -csharp_prefer_simple_default_expression = true:warning -csharp_style_deconstructed_variable_declaration = true:warning -csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion -csharp_style_inlined_variable_declaration = true:suggestion -csharp_style_pattern_local_over_anonymous_function = true:warning -csharp_style_prefer_index_operator = true:suggestion -csharp_style_prefer_range_operator = true:suggestion -csharp_style_throw_expression = true:suggestion -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:silent - -# 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent - -#### C# Formatting Rules #### - -# New line preferences -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_open_brace = all -csharp_new_line_between_query_expression_clauses = true - -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_case_contents_when_block = true -csharp_indent_labels = one_less_than_current -csharp_indent_switch_labels = true - -# Space preferences -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_call_parameter_list_parentheses = false -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -csharp_space_between_method_declaration_name_and_open_parenthesis = false -csharp_space_between_method_declaration_parameter_list_parentheses = false -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -# Wrapping preferences -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true -csharp_style_namespace_declarations = block_scoped:silent - -## Naming conventions -[*.{cs,vb}] - -# Non-private static fields are PascalCase -dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields -dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style - -dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field -dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected internal, private protected -dotnet_naming_symbols.non_private_static_fields.required_modifiers = static - -dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case - -# Constants are PascalCase -dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants -dotnet_naming_rule.constants_should_be_pascal_case.style = non_private_static_field_style - -dotnet_naming_symbols.constants.applicable_kinds = field, local -dotnet_naming_symbols.constants.required_modifiers = const - -dotnet_naming_style.constant_style.capitalization = pascal_case - -# Public fields are Pascal case -dotnet_naming_symbols.public_fields.applicable_kinds = field -dotnet_naming_symbols.public_fields.applicable_accessibilities = public -dotnet_naming_rule.public_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.public_fields_should_be_pascal_case.symbols = public_fields -dotnet_naming_rule.public_fields_should_be_pascal_case.style = pascal_case - -# Static fields are camelCase and start with -dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion -dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields -dotnet_naming_rule.static_fields_should_be_camel_case.style = camel_case_style -dotnet_naming_symbols.static_fields.applicable_kinds = field -dotnet_naming_symbols.static_fields.required_modifiers = static -dotnet_naming_style.static_field_style.capitalization = camel_case - -# Instance fields are camelCase and start with _ -dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion -dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style -dotnet_naming_symbols.private_internal_fields.applicable_kinds = field -dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal -dotnet_naming_style.camel_case_underscore_style.required_prefix = _ -dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case - -# Locals and parameters are camelCase -dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion -dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters -dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style - -dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local -dotnet_naming_style.camel_case_style.capitalization = camel_case - -# Local functions are PascalCase -dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions -dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style - -dotnet_naming_symbols.local_functions.applicable_kinds = local_function -dotnet_naming_style.local_function_style.capitalization = pascal_case - -# Type Parameters -dotnet_naming_style.type_parameter_style.capitalization = pascal_case -dotnet_naming_style.type_parameter_style.required_prefix = T - -dotnet_naming_rule.type_parameter_naming.symbols = type_parameter_symbol -dotnet_naming_rule.type_parameter_naming.style = type_parameter_style -dotnet_naming_rule.type_parameter_naming.severity = warning -dotnet_naming_symbols.type_parameter_symbol.applicable_kinds = type_parameter -dotnet_naming_symbols.type_parameter_symbol.applicable_accessibilities = * - -# By default, name items with PascalCase -dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members -dotnet_naming_rule.members_should_be_pascal_case.style = non_private_static_field_style - -dotnet_naming_symbols.all_members.applicable_kinds = * - -dotnet_naming_style.pascal_case_style.capitalization = pascal_case - -#### Analyzers #### -dotnet_diagnostic.IDE0001.severity = suggestion -dotnet_diagnostic.IDE0002.severity = suggestion -dotnet_diagnostic.IDE0004.severity = suggestion -dotnet_diagnostic.IDE0005.severity = suggestion -dotnet_diagnostic.IDE0035.severity = warning -dotnet_diagnostic.IDE0051.severity = warning -dotnet_diagnostic.IDE0059.severity = warning -dotnet_diagnostic.IDE1006.severity = suggestion - -dotnet_code_quality.copy_analysis = true -dotnet_diagnostic.CA1000.severity = warning -dotnet_diagnostic.CA1001.severity = warning -dotnet_diagnostic.CA1018.severity = warning -dotnet_diagnostic.CA1019.severity = warning -dotnet_diagnostic.CA1036.severity = warning -dotnet_diagnostic.CA1067.severity = warning -dotnet_diagnostic.CA1068.severity = warning -dotnet_diagnostic.CA1303.severity = none -dotnet_diagnostic.CA1304.severity = warning -dotnet_diagnostic.CA1305.severity = warning -dotnet_diagnostic.CA1307.severity = warning -dotnet_diagnostic.CA1308.severity = warning -dotnet_diagnostic.CA1309.severity = warning -dotnet_diagnostic.CA1310.severity = warning -dotnet_diagnostic.CA1401.severity = warning -dotnet_diagnostic.CA1416.severity = warning -dotnet_diagnostic.CA1417.severity = warning -dotnet_diagnostic.CA1508.severity = none -dotnet_diagnostic.CA1708.severity = warning -dotnet_diagnostic.CA1710.severity = none -dotnet_diagnostic.CA1711.severity = none -dotnet_diagnostic.CA1724.severity = warning -dotnet_diagnostic.CA1805.severity = warning -dotnet_diagnostic.CA1806.severity = warning -dotnet_diagnostic.CA1813.severity = warning -dotnet_diagnostic.CA1821.severity = warning -dotnet_diagnostic.CA1825.severity = warning -dotnet_diagnostic.CA1826.severity = warning -dotnet_diagnostic.CA1827.severity = warning -dotnet_diagnostic.CA1828.severity = warning -dotnet_diagnostic.CA1829.severity = warning -dotnet_diagnostic.CA1830.severity = warning -dotnet_diagnostic.CA1831.severity = warning -dotnet_diagnostic.CA1832.severity = warning -dotnet_diagnostic.CA1833.severity = warning -dotnet_diagnostic.CA1834.severity = warning -dotnet_diagnostic.CA1835.severity = warning -dotnet_diagnostic.CA1836.severity = warning -dotnet_diagnostic.CA1837.severity = warning -dotnet_diagnostic.CA1838.severity = warning -dotnet_diagnostic.CA2002.severity = warning -dotnet_diagnostic.CA2009.severity = warning -dotnet_diagnostic.CA2012.severity = warning -dotnet_diagnostic.CA2013.severity = warning -dotnet_diagnostic.CA2014.severity = warning -dotnet_diagnostic.CA2015.severity = warning -dotnet_diagnostic.CA2016.severity = warning -dotnet_diagnostic.CA2101.severity = warning -dotnet_diagnostic.CA2119.severity = warning -dotnet_diagnostic.CA2200.severity = warning -dotnet_diagnostic.CA2201.severity = warning -dotnet_diagnostic.CA2208.severity = warning -dotnet_diagnostic.CA2215.severity = warning -dotnet_diagnostic.CA2219.severity = warning -dotnet_diagnostic.CA2226.severity = warning -dotnet_diagnostic.CA2242.severity = warning -dotnet_diagnostic.CA2243.severity = warning -dotnet_diagnostic.CA2244.severity = warning -dotnet_diagnostic.CA2245.severity = warning -dotnet_diagnostic.CA2246.severity = warning -dotnet_diagnostic.CA2247.severity = warning -dotnet_diagnostic.CA2248.severity = warning -dotnet_diagnostic.CA2249.severity = warning -dotnet_diagnostic.CA2254.severity = none -dotnet_diagnostic.CA2300.severity = warning -dotnet_diagnostic.CA2301.severity = warning -dotnet_diagnostic.CA2302.severity = warning -dotnet_diagnostic.CA2305.severity = warning -dotnet_diagnostic.CA2310.severity = warning -dotnet_diagnostic.CA2311.severity = warning -dotnet_diagnostic.CA2312.severity = warning -dotnet_diagnostic.CA2315.severity = warning -dotnet_diagnostic.CA2321.severity = warning -dotnet_diagnostic.CA2322.severity = warning -dotnet_diagnostic.CA2326.severity = warning -dotnet_diagnostic.CA2327.severity = warning -dotnet_diagnostic.CA2328.severity = warning -dotnet_diagnostic.CA2329.severity = warning -dotnet_diagnostic.CA2330.severity = warning -dotnet_diagnostic.CA2350.severity = warning -dotnet_diagnostic.CA2351.severity = warning -dotnet_diagnostic.CA2352.severity = warning -dotnet_diagnostic.CA2353.severity = warning -dotnet_diagnostic.CA2354.severity = warning -dotnet_diagnostic.CA2355.severity = warning -dotnet_diagnostic.CA2356.severity = warning -dotnet_diagnostic.CA2361.severity = warning -dotnet_diagnostic.CA2362.severity = warning -dotnet_diagnostic.CA3075.severity = warning -dotnet_diagnostic.CA3076.severity = warning -dotnet_diagnostic.CA5350.severity = warning -dotnet_diagnostic.CA5351.severity = warning -dotnet_diagnostic.CA5359.severity = warning -dotnet_diagnostic.CA5360.severity = warning -dotnet_diagnostic.CA5361.severity = warning -dotnet_diagnostic.CA5362.severity = warning -dotnet_diagnostic.CA5363.severity = warning -dotnet_diagnostic.CA5364.severity = warning -dotnet_diagnostic.CA5365.severity = warning -dotnet_diagnostic.CA5366.severity = warning -dotnet_diagnostic.CA5367.severity = warning -dotnet_diagnostic.CA5368.severity = warning -dotnet_diagnostic.CA5369.severity = warning -dotnet_diagnostic.CA5370.severity = warning -dotnet_diagnostic.CA5371.severity = warning -dotnet_diagnostic.CA5372.severity = warning -dotnet_diagnostic.CA5373.severity = warning -dotnet_diagnostic.CA5374.severity = warning -dotnet_diagnostic.CA5375.severity = warning -dotnet_diagnostic.CA5376.severity = warning -dotnet_diagnostic.CA5377.severity = warning -dotnet_diagnostic.CA5378.severity = warning -dotnet_diagnostic.CA5379.severity = warning -dotnet_diagnostic.CA5380.severity = warning -dotnet_diagnostic.CA5381.severity = warning -dotnet_diagnostic.CA5382.severity = warning -dotnet_diagnostic.CA5383.severity = warning -dotnet_diagnostic.CA5384.severity = warning -dotnet_diagnostic.CA5385.severity = warning -dotnet_diagnostic.CA5386.severity = warning -dotnet_diagnostic.CA5387.severity = warning -dotnet_diagnostic.CA5388.severity = warning -dotnet_diagnostic.CA5389.severity = warning -dotnet_diagnostic.CA5390.severity = warning -dotnet_diagnostic.CA5394.severity = none -dotnet_diagnostic.CA5397.severity = warning -dotnet_diagnostic.CA5398.severity = warning -dotnet_diagnostic.CA5399.severity = warning -dotnet_diagnostic.CA5400.severity = warning -dotnet_diagnostic.CA5401.severity = warning -dotnet_diagnostic.CA5402.severity = warning -dotnet_diagnostic.CA5403.severity = warning - -dotnet_diagnostic.MA0001.severity = warning # MA0001: StringComparison is missing -dotnet_diagnostic.MA0002.severity = warning # MA0002: IEqualityComparer or IComparer is missing -dotnet_diagnostic.MA0003.severity = suggestion # MA0003: Name parameter -dotnet_diagnostic.MA0004.severity = warning # MA0004: Use .ConfigureAwait(false) -dotnet_diagnostic.MA0005.severity = warning # MA0005: Use Array.Empty() -dotnet_diagnostic.MA0006.severity = none # MA0006: use String.Equals -dotnet_diagnostic.MA0007.severity = suggestion # MA0007: Add comma after the last property -dotnet_diagnostic.MA0008.severity = warning # MA0008: Add StructLayoutAttribute -dotnet_diagnostic.MA0009.severity = warning # MA0009: Add timeout parameter -dotnet_diagnostic.MA0010.severity = warning # MA0010: Mark attributes with AttributeUsageAttribute -dotnet_diagnostic.MA0011.severity = warning # MA0011: IFormatProvider is missing -dotnet_diagnostic.MA0012.severity = warning # MA0012: Do not raise reserved exception type -dotnet_diagnostic.MA0013.severity = warning # MA0013: Types should not extend System.ApplicationException -dotnet_diagnostic.MA0014.severity = warning # MA0014: Do not raise System.ApplicationException type -dotnet_diagnostic.MA0015.severity = warning # MA0015: Specify the parameter name -dotnet_diagnostic.MA0016.severity = warning # MA0016: Prefer return collection abstraction instead of implementation -dotnet_diagnostic.MA0017.severity = warning # MA0017: Abstract types should not have public or internal constructors -dotnet_diagnostic.MA0018.severity = warning # MA0018: Do not declare static members on generic types -dotnet_diagnostic.MA0019.severity = warning # MA0019: Use EventArgs.Empty -dotnet_diagnostic.MA0020.severity = suggestion # MA0020: Use direct methods instead of extension methods -dotnet_diagnostic.MA0021.severity = warning # MA0021: Use StringComparer.GetHashCode -dotnet_diagnostic.MA0022.severity = warning # MA0022: Return Task.FromResult instead of returning null -dotnet_diagnostic.MA0023.severity = warning # MA0023: Add RegexOptions.ExplicitCapture -dotnet_diagnostic.MA0024.severity = warning # MA0024: Use StringComparer.Ordinal -dotnet_diagnostic.MA0025.severity = warning # MA0025: TODO Implement the functionality -dotnet_diagnostic.MA0026.severity = warning # MA0026: Fix TODO comment -dotnet_diagnostic.MA0027.severity = warning # MA0027: Do not remove original exception -dotnet_diagnostic.MA0028.severity = suggestion # MA0028: Optimize StringBuilder usage -dotnet_diagnostic.MA0029.severity = suggestion # MA0029: Optimize LINQ usage -dotnet_diagnostic.MA0030.severity = suggestion # MA0030: Optimize LINQ usage -dotnet_diagnostic.MA0031.severity = suggestion # MA0031: Optimize Enumerable.Count usage -dotnet_diagnostic.MA0032.severity = suggestion # MA0032: Use a cancellation token -dotnet_diagnostic.MA0033.severity = warning # MA0033: Don't tag instance fields with ThreadStaticAttribute -dotnet_diagnostic.MA0035.severity = warning # MA0035: Don't use dangerous threading methods -dotnet_diagnostic.MA0036.severity = suggestion # MA0036: Make class static -dotnet_diagnostic.MA0037.severity = error # MA0037: Remove empty statement -dotnet_diagnostic.MA0038.severity = suggestion # MA0038: Make method static -dotnet_diagnostic.MA0039.severity = error # MA0039: Do not write your own certificate validation method -dotnet_diagnostic.MA0040.severity = suggestion # MA0040: Use a cancellation token -dotnet_diagnostic.MA0041.severity = suggestion # MA0041: Make property static -dotnet_diagnostic.MA0042.severity = suggestion # MA0042: Do not use blocking call -dotnet_diagnostic.MA0043.severity = suggestion # MA0043: Use nameof operator -dotnet_diagnostic.MA0044.severity = suggestion # MA0044: Remove ToString call -dotnet_diagnostic.MA0045.severity = none # MA0045: Do not use blocking call (make method async) -dotnet_diagnostic.MA0046.severity = warning # MA0046: Use EventHandler -dotnet_diagnostic.MA0047.severity = warning # MA0047: Declare types in namespaces -dotnet_diagnostic.MA0048.severity = warning # MA0048: File name must match type name -dotnet_diagnostic.MA0049.severity = error # MA0049: Type name should not match namespace -dotnet_diagnostic.MA0050.severity = suggestion # MA0050: Validate arguments correctly -dotnet_diagnostic.MA0051.severity = none # MA0051: Method is too long -dotnet_diagnostic.MA0052.severity = suggestion # MA0052: Replace with nameof -dotnet_diagnostic.MA0053.severity = suggestion # MA0053: Make class sealed -dotnet_diagnostic.MA0054.severity = warning # MA0054: Embed the caught exception as innerException -dotnet_diagnostic.MA0055.severity = warning # MA0055: Do not use destructor -dotnet_diagnostic.MA0056.severity = warning # MA0056: Do not call overridable members in constructor -dotnet_diagnostic.MA0057.severity = suggestion # MA0057: Class name should end with 'Attribute' -dotnet_diagnostic.MA0058.severity = suggestion # MA0058: Class name should end with 'Exception' -dotnet_diagnostic.MA0059.severity = suggestion # MA0059: Class name should end with 'EventArgs' -dotnet_diagnostic.MA0060.severity = warning # MA0060: The value returned by Stream.Read is not used -dotnet_diagnostic.MA0061.severity = warning # MA0061: Method overrides should not change parameter defaults -dotnet_diagnostic.MA0062.severity = warning # MA0062: Non-flags enums should not be marked with "FlagsAttribute" -dotnet_diagnostic.MA0063.severity = suggestion # MA0063: Optimize Enumerable.OrderBy usage -dotnet_diagnostic.MA0064.severity = warning # MA0064: Avoid locking on publicly accessible instance -dotnet_diagnostic.MA0065.severity = warning # MA0065: Default ValueType.Equals or HashCode is used for struct's equality -dotnet_diagnostic.MA0066.severity = warning # MA0066: Hash table unfriendly type is used in a hash table -dotnet_diagnostic.MA0067.severity = suggestion # MA0067: Use Guid.Empty -dotnet_diagnostic.MA0068.severity = warning # MA0068: Invalid parameter name -dotnet_diagnostic.MA0069.severity = warning # MA0069: Non-constant static fields should not be visible -dotnet_diagnostic.MA0070.severity = warning # MA0070: Obsolete attributes should include explanations -dotnet_diagnostic.MA0071.severity = none # MA0071: Avoid using redundant else -dotnet_diagnostic.MA0072.severity = warning # MA0072: Do not throw from a finally block -dotnet_diagnostic.MA0073.severity = suggestion # MA0073: Avoid comparison with bool constant -dotnet_diagnostic.MA0074.severity = warning # MA0074: Avoid implicit culture-sensitive methods -dotnet_diagnostic.MA0075.severity = suggestion # MA0075: Do not use implicit culture-sensitive ToString -dotnet_diagnostic.MA0076.severity = suggestion # MA0076: Do not use implicit culture-sensitive ToString in interpolated strings -dotnet_diagnostic.MA0077.severity = warning # MA0077: A class that provides Equals(T) should implement IEquatable -dotnet_diagnostic.MA0078.severity = suggestion # MA0078: Use 'Cast' instead of 'Select' to cast -dotnet_diagnostic.MA0079.severity = suggestion # MA0079: Use a cancellation token using .WithCancellation() -dotnet_diagnostic.MA0080.severity = suggestion # MA0080: Use a cancellation token using .WithCancellation() -dotnet_diagnostic.MA0081.severity = warning # MA0081: Method overrides should not omit params keyword -dotnet_diagnostic.MA0082.severity = warning # MA0082: NaN should not be used in comparisons -dotnet_diagnostic.MA0083.severity = warning # MA0083: ConstructorArgument parameters should exist in constructors -dotnet_diagnostic.MA0084.severity = warning # MA0084: Local variable should not hide other symbols -dotnet_diagnostic.MA0085.severity = warning # MA0085: Anonymous delegates should not be used to unsubscribe from Events -dotnet_diagnostic.MA0086.severity = warning # MA0086: Do not throw from a destructor -dotnet_diagnostic.MA0087.severity = warning # MA0087: Parameters with [DefaultParameterValue] attributes should also be marked [Optional] -dotnet_diagnostic.MA0088.severity = warning # MA0088: Use [DefaultParameterValue] instead of [DefaultValue] -dotnet_diagnostic.MA0089.severity = suggestion # MA0089: Optimize string method usage -dotnet_diagnostic.MA0090.severity = suggestion # MA0090: Remove empty block -dotnet_diagnostic.MA0091.severity = warning # MA0091: Sender should be 'this' for instance events -dotnet_diagnostic.MA0092.severity = warning # MA0092: Sender should be 'null' for static events -dotnet_diagnostic.MA0093.severity = warning # MA0093: EventArgs should not be null -dotnet_diagnostic.MA0094.severity = warning # MA0094: A class that provides CompareTo(T) should implement IComparable -dotnet_diagnostic.MA0095.severity = warning # MA0095: A class that implements IEquatable should override Equals(object) -dotnet_diagnostic.MA0096.severity = warning # MA0096: A class that implements IComparable should also implement IEquatable -dotnet_diagnostic.MA0097.severity = warning # MA0097: A class that implements IComparable or IComparable should override comparison operators -dotnet_diagnostic.MA0098.severity = suggestion # MA0098: Use indexer instead of extension methods -dotnet_diagnostic.MA0099.severity = warning # MA0099: Use Explicit enum value instead of 0 -MA0053.public_class_should_be_sealed = false -tab_width = 4 -end_of_line = lf diff --git a/backend/api.test/Controllers/MissionSchedulingControllerTests.cs b/backend/api.test/Controllers/MissionSchedulingControllerTests.cs index 109e2d902..0e1cd7488 100644 --- a/backend/api.test/Controllers/MissionSchedulingControllerTests.cs +++ b/backend/api.test/Controllers/MissionSchedulingControllerTests.cs @@ -28,7 +28,7 @@ public class MissionSchedulingControllerTests : IAsyncLifetime public async Task InitializeAsync() { - (Container, string connectionString, var connection) = + (Container, string connectionString, var _) = await TestSetupHelpers.ConfigurePostgreSqlDatabase(); var factory = TestSetupHelpers.ConfigureWebApplicationFactory( postgreSqlConnectionString: connectionString diff --git a/backend/api/Controllers/MissionSchedulingController.cs b/backend/api/Controllers/MissionSchedulingController.cs index 014b9fa88..34174744b 100644 --- a/backend/api/Controllers/MissionSchedulingController.cs +++ b/backend/api/Controllers/MissionSchedulingController.cs @@ -333,7 +333,9 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery [.. missionInspectionAreaNames] ); logger.LogWarning( - $"Mission {missionDefinition.Name} has tags on more than one inspection area. The inspection areas are: {joinedMissionInspectionAreaNames}." + "Mission {missionDefinition} has tags on more than one inspection area. The inspection areas are: {joinedMissionInspectionAreaNames}.", + missionDefinition.Name, + joinedMissionInspectionAreaNames ); } @@ -346,7 +348,8 @@ [.. missionInspectionAreaNames] if (area == null && sortedAreas.Count() > 1) { logger.LogWarning( - $"Most common area in mission {missionDefinition.Name} is null. Will use second most common area." + "Most common area in mission {missionDefinition} is null. Will use second most common area.", + missionDefinition.Name ); area = sortedAreas.Skip(1).First(); } @@ -564,7 +567,7 @@ [FromBody] CustomMissionQuery customMissionQuery }; customMissionDefinition.Map ??= await mapService.ChooseMapFromPositions( - missionTasks.Select(t => t.RobotPose.Position).ToList(), + [.. missionTasks.Select(t => t.RobotPose.Position)], customMissionQuery.InstallationCode ); diff --git a/backend/api/EventHandlers/InspectionFindingEventHandler.cs b/backend/api/EventHandlers/InspectionFindingEventHandler.cs index cf9f17c69..b0a832029 100644 --- a/backend/api/EventHandlers/InspectionFindingEventHandler.cs +++ b/backend/api/EventHandlers/InspectionFindingEventHandler.cs @@ -83,7 +83,9 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) { string errorBody = await response.Content.ReadAsStringAsync(stoppingToken); logger.LogWarning( - $"Webhook request failed with status code {response.StatusCode}. Response body: {errorBody}" + "Webhook request failed with status code {statusCode}. Response body: {errorBody}", + response.StatusCode, + errorBody ); } } diff --git a/backend/api/EventHandlers/MqttEventHandler.cs b/backend/api/EventHandlers/MqttEventHandler.cs index 8d8f0e904..69bf9297f 100644 --- a/backend/api/EventHandlers/MqttEventHandler.cs +++ b/backend/api/EventHandlers/MqttEventHandler.cs @@ -214,7 +214,10 @@ Installation installation } catch (DbUpdateException) { - _logger.LogError($"Failed to add robot {robotQuery.Name} with to the database"); + _logger.LogError( + "Failed to add robot {robotQueryName} with to the database", + robotQuery.Name + ); return; } } diff --git a/backend/api/Services/EchoService.cs b/backend/api/Services/EchoService.cs index 7f1c0ef31..2f5513424 100644 --- a/backend/api/Services/EchoService.cs +++ b/backend/api/Services/EchoService.cs @@ -128,10 +128,14 @@ await sourceService.CheckForExistingSource(echoMission.Id) ?? await sourceService.Create(new Source { SourceId = $"{echoMission.Id}" }); var missionTasks = echoMission.Tags; List missionAreas; - missionAreas = missionTasks - .Where(t => t.TagId != null) - .Select(t => stidService.GetTagArea(t.TagId, echoMission.InstallationCode).Result) - .ToList(); + missionAreas = + [ + .. missionTasks + .Where(t => t.TagId != null) + .Select(t => + stidService.GetTagArea(t.TagId, echoMission.InstallationCode).Result + ), + ]; var missionInspectionAreaNames = missionAreas .Where(a => a != null) @@ -145,7 +149,9 @@ await sourceService.CheckForExistingSource(echoMission.Id) [.. missionInspectionAreaNames] ); logger.LogWarning( - $"Mission {echoMission.Name} has tags on more than one inspection area. The inspection areas are: {joinedMissionInspectionAreaNames}." + "Mission {echoMissionName} has tags on more than one inspection area. The inspection areas are: {joinedMissionInspectionAreaNames}.", + echoMission.Name, + joinedMissionInspectionAreaNames ); } @@ -158,14 +164,16 @@ [.. missionInspectionAreaNames] if (area == null && sortedAreas.Count() > 1) { logger.LogWarning( - $"Most common area in mission {echoMission.Name} is null. Will use second most common area." + "Most common area in mission {echoMissionName} is null. Will use second most common area.", + echoMission.Name ); area = sortedAreas.Skip(1).First(); } if (area == null) { logger.LogError( - $"Mission {echoMission.Name} doesn't have any tags with valid area." + "Mission {echoMissionName} doesn't have any tags with valid area.", + echoMission.Name ); return null; } @@ -242,14 +250,16 @@ string installationCode URL = new Uri( $"https://stid.equinor.com/{installationCode}/tag?tagNo={planItem.Tag}" ), - Inspections = planItem - .SensorTypes.Select(sensor => new EchoInspection( - sensor, - planItem.InspectionPoint.EnuPosition.ToPosition(), - planItem.InspectionPoint.Name - )) - .Distinct(new EchoInspectionComparer()) - .ToList(), + Inspections = + [ + .. planItem + .SensorTypes.Select(sensor => new EchoInspection( + sensor, + planItem.InspectionPoint.EnuPosition.ToPosition(), + planItem.InspectionPoint.Name + )) + .Distinct(new EchoInspectionComparer()), + ], }; if (tag.Inspections.Count < 1) diff --git a/backend/api/Services/MissionSchedulingService.cs b/backend/api/Services/MissionSchedulingService.cs index a0a27ecbd..730fd51b0 100644 --- a/backend/api/Services/MissionSchedulingService.cs +++ b/backend/api/Services/MissionSchedulingService.cs @@ -516,7 +516,8 @@ await missionRunService.Create( catch (UnsupportedRobotCapabilityException) { logger.LogError( - $"Unsupported robot capability detected when restarting interrupted missions for robot {missionRun.Robot.Name}. This should not happen." + "Unsupported robot capability detected when restarting interrupted missions for robot {robotName}. This should not happen.", + missionRun.Robot.Name ); } } diff --git a/backend/api/Services/Models/IsarMission.cs b/backend/api/Services/Models/IsarMission.cs index 5337e6d02..22e080e6a 100644 --- a/backend/api/Services/Models/IsarMission.cs +++ b/backend/api/Services/Models/IsarMission.cs @@ -5,6 +5,6 @@ public class IsarMission(IsarStartMissionResponse missionResponse) public string IsarMissionId { get; } = missionResponse.MissionId; public List Tasks { get; } = - missionResponse.Tasks.Select(task => new IsarTask(task)).ToList(); + [.. missionResponse.Tasks.Select(task => new IsarTask(task))]; } } diff --git a/backend/api/Services/ReturnToHomeService.cs b/backend/api/Services/ReturnToHomeService.cs index 785cef2c0..5ed02ad2a 100644 --- a/backend/api/Services/ReturnToHomeService.cs +++ b/backend/api/Services/ReturnToHomeService.cs @@ -143,7 +143,8 @@ robot.RobotCapabilities is not null if (activeReturnToHomeMissions.Count > 1) { logger.LogError( - $"Two Return home missions should not be queued or ongoing simoultaneously for robot with Id {robotId}." + "Two Return home missions should not be queued or ongoing simoultaneously for robot with Id {robotId}.", + robotId ); } diff --git a/backend/d1.py b/backend/d1.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e33e701b6..87d2758ac 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8194,9 +8194,9 @@ } }, "node_modules/vite": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.7.tgz", - "integrity": "sha512-RDt8r/7qx9940f8FcOIAH9PTViRrghKaK2K1jY3RaAURrEUbm9Du1mJ72G+jlhtG3WwodnfzY8ORQZbBavZEAQ==", + "version": "6.0.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.11.tgz", + "integrity": "sha512-4VL9mQPKoHy4+FE0NnRE/kbY51TOfaknxAjt3fJbGJxhIpBZiqVzlZDEesWWsuREXHwNdAoOFZ9MkPEVXczHwg==", "dependencies": { "esbuild": "^0.24.2", "postcss": "^8.4.49", @@ -8720,9 +8720,9 @@ } }, "node_modules/vite-node/node_modules/vite": { - "version": "5.4.11", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.11.tgz", - "integrity": "sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==", + "version": "5.4.14", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz", + "integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==", "dev": true, "dependencies": { "esbuild": "^0.21.3", @@ -9353,9 +9353,9 @@ } }, "node_modules/vitest/node_modules/vite": { - "version": "5.4.11", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.11.tgz", - "integrity": "sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==", + "version": "5.4.14", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz", + "integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==", "dev": true, "dependencies": { "esbuild": "^0.21.3", diff --git a/frontend/src/api/ApiCaller.tsx b/frontend/src/api/ApiCaller.tsx index 9cf5c97fb..cd09acb85 100644 --- a/frontend/src/api/ApiCaller.tsx +++ b/frontend/src/api/ApiCaller.tsx @@ -386,7 +386,7 @@ export class BackendAPICaller { } static async reRunMission(missionId: string, failedTasksOnly: boolean = false): Promise { - const mission = await this.getMissionRunById(missionId) + const mission = await BackendAPICaller.getMissionRunById(missionId) if (failedTasksOnly) { const path = `missions/rerun/${mission.id}` diff --git a/frontend/src/components/Contexts/AuthProvider.tsx b/frontend/src/components/Contexts/AuthProvider.tsx index 8a7f91535..3a86dee33 100644 --- a/frontend/src/components/Contexts/AuthProvider.tsx +++ b/frontend/src/components/Contexts/AuthProvider.tsx @@ -16,9 +16,13 @@ export const AuthProvider = (props: Props) => { const [accessToken, setAccessToken] = useState('') const VerifyToken = useCallback(() => { - fetchAccessToken(msalContext).then((accessToken) => { - setAccessToken(accessToken) - }) + fetchAccessToken(msalContext) + .then((accessToken) => { + setAccessToken(accessToken) + }) + .catch((error) => { + console.error('Failed to fetch access token:', error) + }) }, [msalContext]) useEffect(() => { diff --git a/frontend/src/components/Displays/RobotDisplays/BatteryStatusDisplay.tsx b/frontend/src/components/Displays/RobotDisplays/BatteryStatusDisplay.tsx index 8f5b96327..77a6564fc 100644 --- a/frontend/src/components/Displays/RobotDisplays/BatteryStatusDisplay.tsx +++ b/frontend/src/components/Displays/RobotDisplays/BatteryStatusDisplay.tsx @@ -32,12 +32,12 @@ export const BatteryStatusDisplay = ({ switch (true) { case batteryState === BatteryStatus.Charging: return Icons.BatteryCharging - case batteryLevel === null || batteryLevel === undefined: - return Icons.BatteryUnknown - case !batteryWarningLimit || batteryLevel! > batteryWarningLimit: + case !batteryWarningLimit: + case batteryWarningLimit !== undefined && batteryLevel! > batteryWarningLimit: return Icons.Battery case batteryWarningLimit && batteryLevel! <= batteryWarningLimit: return Icons.BatteryAlert + case batteryLevel == null: default: return Icons.BatteryUnknown } @@ -52,7 +52,7 @@ export const BatteryStatusDisplay = ({ return ( - + {batteryIcon && } {batteryValue} ) diff --git a/frontend/src/components/Displays/RobotDisplays/RobotStatusIcon.tsx b/frontend/src/components/Displays/RobotDisplays/RobotStatusIcon.tsx index e43c22300..0ff449e0c 100644 --- a/frontend/src/components/Displays/RobotDisplays/RobotStatusIcon.tsx +++ b/frontend/src/components/Displays/RobotDisplays/RobotStatusIcon.tsx @@ -43,11 +43,7 @@ export const RobotStatusChip = ({ status, flotillaStatus, isarConnected, itemSiz iconColor = tokens.colors.text.static_icons__default.hex break } - case RobotStatus.Blocked: { - statusIcon = Icons.Blocked - iconColor = tokens.colors.interactive.danger__resting.hex - break - } + case RobotStatus.Blocked: case RobotStatus.BlockedProtectiveStop: { statusIcon = Icons.Blocked iconColor = tokens.colors.interactive.danger__resting.hex diff --git a/frontend/src/components/Pages/FrontPage/MissionOverview/StopDialogs.tsx b/frontend/src/components/Pages/FrontPage/MissionOverview/StopDialogs.tsx index 1805aa03b..3bbd72f2f 100644 --- a/frontend/src/components/Pages/FrontPage/MissionOverview/StopDialogs.tsx +++ b/frontend/src/components/Pages/FrontPage/MissionOverview/StopDialogs.tsx @@ -113,7 +113,7 @@ export const StopMissionDialog = ({ {missionName ? TranslateText('Stop mission:') : TranslateText('No mission running')}{' '} - {missionName && missionName} + {missionName} diff --git a/frontend/src/components/Pages/InspectionPage/InspectionUtilities.tsx b/frontend/src/components/Pages/InspectionPage/InspectionUtilities.tsx index d16673af2..ce204aaec 100644 --- a/frontend/src/components/Pages/InspectionPage/InspectionUtilities.tsx +++ b/frontend/src/components/Pages/InspectionPage/InspectionUtilities.tsx @@ -106,12 +106,11 @@ export const getDeadlineInspection = (deadline: Date): InspectionAreaCardColors const deadlineDays = getDeadlineInDays(deadline) switch (true) { case deadlineDays <= 1: + case 1 < deadlineDays && deadlineDays <= 7: return InspectionAreaCardColors.Red - case deadlineDays > 1 && deadlineDays <= 7: - return InspectionAreaCardColors.Red - case deadlineDays > 7 && deadlineDays <= 14: + case 7 < deadlineDays && deadlineDays <= 14: return InspectionAreaCardColors.Orange - case deadlineDays > 7 && deadlineDays <= 30: + case 7 < deadlineDays && deadlineDays <= 30: return InspectionAreaCardColors.Green } return InspectionAreaCardColors.Green diff --git a/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx b/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx index c2430bfb4..63607452a 100644 --- a/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx +++ b/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx @@ -208,7 +208,7 @@ const MissionDefinitionEditDialog = ({ unit={TranslateText('days')} value={inspectionFrequencyDays} onChange={(changes: ChangeEvent) => { - if (!isNaN(+changes.target.value)) + if (!Number.isNaN(+changes.target.value)) updateInspectionFrequencyFormDays(changes.target.value) }} /> diff --git a/frontend/src/components/Pages/MissionPage/MapPosition/MissionMapView.tsx b/frontend/src/components/Pages/MissionPage/MapPosition/MissionMapView.tsx index 7b21c3f19..6c7b6c211 100644 --- a/frontend/src/components/Pages/MissionPage/MapPosition/MissionMapView.tsx +++ b/frontend/src/components/Pages/MissionPage/MapPosition/MissionMapView.tsx @@ -93,20 +93,27 @@ export const MissionMapView = ({ mission }: MissionProps) => { imageObjectURL.current = NoMap }) .then(() => { - getMeta(imageObjectURL.current).then((img) => { - const mapCanvas = document.getElementById('mapCanvas') as HTMLCanvasElement - if (mapCanvas) { - mapCanvas.width = img.width - mapCanvas.height = img.height - const context = mapCanvas?.getContext('2d') - if (context) { - setMapContext(context) - context.drawImage(img, 0, 0) + getMeta(imageObjectURL.current) + .then((img) => { + const mapCanvas = document.getElementById('mapCanvas') as HTMLCanvasElement + if (mapCanvas) { + mapCanvas.width = img.width + mapCanvas.height = img.height + const context = mapCanvas?.getContext('2d') + if (context) { + setMapContext(context) + context.drawImage(img, 0, 0) + } + setMapCanvas(mapCanvas) } - setMapCanvas(mapCanvas) - } - setMapImage(img) - }) + setMapImage(img) + }) + .catch((error) => { + console.error('Failed to get image metadata:', error) + }) + }) + .catch((error) => { + console.error('Failed to process map image:', error) }) } else { imageObjectURL.current = NoMap diff --git a/frontend/src/components/Pages/MissionPage/StatusReason.tsx b/frontend/src/components/Pages/MissionPage/StatusReason.tsx index 3850af5a5..847a6a584 100644 --- a/frontend/src/components/Pages/MissionPage/StatusReason.tsx +++ b/frontend/src/components/Pages/MissionPage/StatusReason.tsx @@ -20,14 +20,10 @@ export const StatusReason = ({ statusReason, status }: MissionProps) => { let warningLevel: 'default' | 'info' | 'warning' | 'danger' = 'info' switch (status) { case MissionStatus.Failed: - warningLevel = 'danger' - break case MissionStatus.Aborted: warningLevel = 'danger' break case MissionStatus.Cancelled: - warningLevel = 'warning' - break case MissionStatus.PartiallySuccessful: warningLevel = 'warning' break diff --git a/frontend/src/utils/InspectionAreaMapView.tsx b/frontend/src/utils/InspectionAreaMapView.tsx index c1fa25c7c..58d5b7775 100644 --- a/frontend/src/utils/InspectionAreaMapView.tsx +++ b/frontend/src/utils/InspectionAreaMapView.tsx @@ -63,7 +63,7 @@ export const InspectionAreaMapView = ({ inspectionArea, markedRobotPosition }: I } }, [mapCanvas, mapImage, mapMetadata, markedRobotPosition]) - let mapName = mapMetadata?.mapName.split('.')[0].replace(/[^0-9a-z-A-Z ]/g, ' ') + let mapName = mapMetadata?.mapName.split('.')[0].replace(/[^0-9a-zA-Z ]/g, ' ') mapName = mapName ? mapName.charAt(0).toUpperCase() + mapName.slice(1) : ' ' useEffect(() => { @@ -71,19 +71,23 @@ export const InspectionAreaMapView = ({ inspectionArea, markedRobotPosition }: I const imageObjectURL = typeof imageBlob === 'string' ? imageBlob : URL.createObjectURL(imageBlob as Blob) if (!imageObjectURL) return - getMeta(imageObjectURL as string).then((img) => { - const mapCanvas = document.getElementById('inspectionAreaMapCanvas') as HTMLCanvasElement - if (!mapCanvas) return - mapCanvas.width = img.width - mapCanvas.height = img.height - const context = mapCanvas?.getContext('2d') - if (context) { - setMapContext(context) - context.drawImage(img, 0, 0) - } - setMapCanvas(mapCanvas) - setMapImage(img) - }) + getMeta(imageObjectURL as string) + .then((img) => { + const mapCanvas = document.getElementById('inspectionAreaMapCanvas') as HTMLCanvasElement + if (!mapCanvas) return + mapCanvas.width = img.width + mapCanvas.height = img.height + const context = mapCanvas?.getContext('2d') + if (context) { + setMapContext(context) + context.drawImage(img, 0, 0) + } + setMapCanvas(mapCanvas) + setMapImage(img) + }) + .catch((error) => { + console.error('Failed to get image metadata:', error) + }) setIsLoading(false) } diff --git a/frontend/src/utils/IsRobotReadyToRunMissions.tsx b/frontend/src/utils/IsRobotReadyToRunMissions.tsx index 9d8bf8c91..234c6da61 100644 --- a/frontend/src/utils/IsRobotReadyToRunMissions.tsx +++ b/frontend/src/utils/IsRobotReadyToRunMissions.tsx @@ -3,14 +3,12 @@ import { useLanguageContext } from 'components/Contexts/LanguageContext' import { Robot, RobotFlotillaStatus } from 'models/Robot' const isBatteryTooLow = (robot: Robot): boolean => { - if (robot.batteryLevel === undefined || robot.batteryLevel === null) return false - - if (robot.model.batteryWarningThreshold && robot.batteryLevel < robot.model.batteryWarningThreshold) { - return true - } else if ( - robot.model.batteryMissionStartThreshold && - robot.batteryLevel < robot.model.batteryMissionStartThreshold && - robot.flotillaStatus === RobotFlotillaStatus.Recharging + if (robot.batteryLevel == null) return false + if ( + (robot.model.batteryWarningThreshold && robot.batteryLevel < robot.model.batteryWarningThreshold) || + (robot.model.batteryMissionStartThreshold && + robot.batteryLevel < robot.model.batteryMissionStartThreshold && + robot.flotillaStatus === RobotFlotillaStatus.Recharging) ) { return true }