[DEV] update back with archidata and upgrade
This commit is contained in:
parent
b4819532d8
commit
645fcfb3d2
401
Formatter.xml
Normal file
401
Formatter.xml
Normal file
@ -0,0 +1,401 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<profiles version="23">
|
||||
<profile kind="CodeFormatterProfile" name="EWOL" version="23">
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="preserve_positions"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="200"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_if_empty"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="33"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="48"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
</profile>
|
||||
</profiles>
|
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>kangaroo-and-rabbit</groupId>
|
||||
<artifactId>archidata</artifactId>
|
||||
<version>0.6.2</version>
|
||||
<version>0.8.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
181
back/src/org/kar/karso/WebLauncher.java
Executable file
181
back/src/org/kar/karso/WebLauncher.java
Executable file
@ -0,0 +1,181 @@
|
||||
package org.kar.karso;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.glassfish.grizzly.http.server.HttpServer;
|
||||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.UpdateJwtPublicKey;
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.backup.BackupEngine;
|
||||
import org.kar.archidata.backup.BackupEngine.StoreMode;
|
||||
import org.kar.archidata.catcher.ExceptionCatcher;
|
||||
import org.kar.archidata.catcher.FailException404API;
|
||||
import org.kar.archidata.catcher.FailExceptionCatcher;
|
||||
import org.kar.archidata.catcher.InputExceptionCatcher;
|
||||
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
||||
import org.kar.archidata.db.DBConfig;
|
||||
import org.kar.archidata.filter.CORSFilter;
|
||||
import org.kar.archidata.filter.OptionFilter;
|
||||
import org.kar.archidata.migration.MigrationEngine;
|
||||
import org.kar.archidata.migration.model.Migration;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.archidata.tools.JWTWrapper;
|
||||
import org.kar.karso.api.ApplicationResource;
|
||||
import org.kar.karso.api.ApplicationTokenResource;
|
||||
import org.kar.karso.api.Front;
|
||||
import org.kar.karso.api.HealthCheck;
|
||||
import org.kar.karso.api.PublicKeyResource;
|
||||
import org.kar.karso.api.RightResource;
|
||||
import org.kar.karso.api.SystemConfigResource;
|
||||
import org.kar.karso.api.UserResource;
|
||||
import org.kar.karso.filter.KarsoAuthenticationFilter;
|
||||
import org.kar.karso.migration.Initialization;
|
||||
import org.kar.karso.migration.Migration20231015;
|
||||
import org.kar.karso.migration.Migration20231126;
|
||||
import org.kar.karso.model.Application;
|
||||
import org.kar.karso.model.ApplicationToken;
|
||||
import org.kar.karso.model.Right;
|
||||
import org.kar.karso.model.RightDescription;
|
||||
import org.kar.karso.model.Settings;
|
||||
import org.kar.karso.model.UserAuth;
|
||||
import org.kar.karso.util.ConfigVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jakarta.ws.rs.core.UriBuilder;
|
||||
|
||||
public class WebLauncher {
|
||||
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
||||
public static DBConfig dbConfig;
|
||||
protected UpdateJwtPublicKey keyUpdater = null;
|
||||
protected HttpServer server = null;
|
||||
protected BackupEngine backupEngine = new BackupEngine("./backup", StoreMode.JSON);
|
||||
|
||||
public WebLauncher() {
|
||||
ConfigBaseVariable.bdDatabase = "karso";
|
||||
|
||||
this.backupEngine.addClass(Migration.class);
|
||||
this.backupEngine.addClass(Settings.class);
|
||||
this.backupEngine.addClass(UserAuth.class);
|
||||
this.backupEngine.addClass(Application.class);
|
||||
this.backupEngine.addClass(ApplicationToken.class);
|
||||
this.backupEngine.addClass(RightDescription.class);
|
||||
this.backupEngine.addClass(Right.class);
|
||||
}
|
||||
|
||||
private static URI getBaseURI() {
|
||||
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
|
||||
}
|
||||
|
||||
public void migrateDB() throws Exception {
|
||||
WebLauncher.LOGGER.info("Create migration engine");
|
||||
final MigrationEngine migrationEngine = new MigrationEngine();
|
||||
WebLauncher.LOGGER.info("Add initialization");
|
||||
migrationEngine.setInit(new Initialization());
|
||||
WebLauncher.LOGGER.info("Add migration since last version");
|
||||
migrationEngine.add(new Migration20231015());
|
||||
migrationEngine.add(new Migration20231126());
|
||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
WebLauncher.LOGGER.info("[START] application wake UP");
|
||||
final WebLauncher launcher = new WebLauncher();
|
||||
launcher.migrateDB();
|
||||
launcher.process();
|
||||
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
|
||||
Thread.currentThread().join();
|
||||
WebLauncher.LOGGER.info("STOP the REST server");
|
||||
}
|
||||
|
||||
public void process() throws InterruptedException {
|
||||
try {
|
||||
JWTWrapper.initLocalToken(ConfigVariable.getUUIDKeyRoot());
|
||||
} catch (final Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
LOGGER.info("Wait 10 seconds ....");
|
||||
Thread.sleep(10000);
|
||||
return;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// Configure resources
|
||||
// ===================================================================
|
||||
final ResourceConfig rc = new ResourceConfig();
|
||||
|
||||
// add multi-part models ..
|
||||
rc.register(MultiPartFeature.class);
|
||||
// global authentication system
|
||||
rc.register(OptionFilter.class);
|
||||
// remove cors ==> all time called by an other system...
|
||||
rc.register(CORSFilter.class);
|
||||
// global authentication system
|
||||
rc.register(KarsoAuthenticationFilter.class);
|
||||
// register exception catcher
|
||||
rc.register(InputExceptionCatcher.class);
|
||||
rc.register(SystemExceptionCatcher.class);
|
||||
rc.register(FailExceptionCatcher.class);
|
||||
rc.register(FailException404API.class);
|
||||
rc.register(ExceptionCatcher.class);
|
||||
// add default resource:
|
||||
rc.register(DataResource.class);
|
||||
rc.register(ApplicationResource.class);
|
||||
rc.register(ApplicationTokenResource.class);
|
||||
rc.register(PublicKeyResource.class);
|
||||
rc.register(RightResource.class);
|
||||
rc.register(SystemConfigResource.class);
|
||||
rc.register(UserResource.class);
|
||||
|
||||
rc.register(HealthCheck.class);
|
||||
rc.register(Front.class);
|
||||
|
||||
// add jackson to be discover when we are ins stand-alone server
|
||||
rc.register(JacksonFeature.class);
|
||||
// enable this to show low level request
|
||||
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
||||
|
||||
this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
|
||||
final HttpServer serverLink = this.server;
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Stopping server..");
|
||||
serverLink.shutdownNow();
|
||||
}
|
||||
}, "shutdownHook"));
|
||||
|
||||
// ===================================================================
|
||||
// run JERSEY
|
||||
// ===================================================================
|
||||
try {
|
||||
this.server.start();
|
||||
LOGGER.info("Jersey app started at {}", getBaseURI());
|
||||
} catch (final Exception e) {
|
||||
LOGGER.error("There was an error while starting Grizzly HTTP server.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.server != null) {
|
||||
this.server.shutdownNow();
|
||||
while (this.server.isStarted()) {
|
||||
LOGGER.info("wait stop");
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.server = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,19 @@
|
||||
|
||||
package org.kar.karso;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.dataAccess.DataFactoryTsApi;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.karso.api.ApplicationResource;
|
||||
import org.kar.karso.api.ApplicationTokenResource;
|
||||
import org.kar.karso.api.Front;
|
||||
import org.kar.karso.api.PublicKeyResource;
|
||||
import org.kar.karso.api.RightResource;
|
||||
import org.kar.karso.api.SystemConfigResource;
|
||||
import org.kar.karso.api.UserResource;
|
||||
import org.kar.karso.migration.Initialization;
|
||||
import org.kar.karso.util.ConfigVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -11,7 +23,11 @@ public class WebLauncherLocal extends WebLauncher {
|
||||
|
||||
private WebLauncherLocal() {}
|
||||
|
||||
public static void main(final String[] args) throws InterruptedException {
|
||||
public static void main(final String[] args) throws Exception {
|
||||
DataFactoryTsApi.generatePackage(
|
||||
List.of(Front.class, DataResource.class, ApplicationResource.class, ApplicationTokenResource.class,
|
||||
PublicKeyResource.class, RightResource.class, UserResource.class, SystemConfigResource.class),
|
||||
Initialization.CLASSES_BASE, "../front/src/back-api/");
|
||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||
launcher.process();
|
||||
LOGGER.info("end-configure the server & wait finish process:");
|
||||
@ -22,14 +38,10 @@ public class WebLauncherLocal extends WebLauncher {
|
||||
@Override
|
||||
public void process() throws InterruptedException {
|
||||
if (true) {
|
||||
// for local test:
|
||||
ConfigBaseVariable.apiAdress = "http://0.0.0.0:15080/karso/api/";
|
||||
ConfigBaseVariable.dbPort = "3906";
|
||||
// create a unique key for test ==> not retrieve the token every load...
|
||||
ConfigVariable.uuid_for_key_generation = "lkjlkjlkjlmkjqmwlsdkjqfsdlkf88QJSDMLQKSndmLQKZNERMAL";
|
||||
//ConfigBaseVariable.dbType = "sqlite";
|
||||
//ConfigBaseVariable.dbHost = "./bdd_base.sqlite";
|
||||
|
||||
}
|
||||
try {
|
||||
super.migrateDB();
|
||||
|
@ -5,12 +5,14 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryAnd;
|
||||
import org.kar.archidata.dataAccess.QueryCondition;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||
import org.kar.archidata.dataAccess.options.Condition;
|
||||
import org.kar.archidata.exception.InputException;
|
||||
import org.kar.archidata.exception.SystemException;
|
||||
import org.kar.archidata.filter.GenericContext;
|
||||
import org.kar.archidata.tools.JWTWrapper;
|
||||
import org.kar.karso.model.Application;
|
||||
@ -33,7 +35,6 @@ import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
|
||||
@Path("/application")
|
||||
@ -47,7 +48,8 @@ public class ApplicationResource {
|
||||
final List<Long> out = new ArrayList<>();
|
||||
List<UserLinkApplication> links = null;
|
||||
try {
|
||||
links = DataAccess.getsWhere(UserLinkApplication.class, new Condition(new QueryCondition("object1id", "=", userId)));
|
||||
links = DataAccess.getsWhere(UserLinkApplication.class,
|
||||
new Condition(new QueryCondition("object1id", "=", userId)));
|
||||
} catch (final Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@ -65,7 +67,8 @@ public class ApplicationResource {
|
||||
final List<Long> out = new ArrayList<>();
|
||||
List<UserLinkApplication> links = null;
|
||||
try {
|
||||
links = DataAccess.getsWhere(UserLinkApplication.class, new Condition(new QueryCondition("object2id", "=", applicationId)));
|
||||
links = DataAccess.getsWhere(UserLinkApplication.class,
|
||||
new Condition(new QueryCondition("object2id", "=", applicationId)));
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
final String result = "SERVER Internal error";
|
||||
@ -86,7 +89,7 @@ public class ApplicationResource {
|
||||
|
||||
@GET
|
||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||
public List<Application> getApplications(@Context final SecurityContext sc) throws Exception {
|
||||
public List<Application> gets(@Context final SecurityContext sc) throws Exception {
|
||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||
this.logger.debug("getApplications");
|
||||
// TODO filter with the list of element available in his authorizations ...
|
||||
@ -113,7 +116,8 @@ public class ApplicationResource {
|
||||
throw new InputException("name", "create application (name too small: '" + application.name + "')");
|
||||
}
|
||||
if (application.redirect == null || application.redirect.length() < 6) {
|
||||
throw new InputException("redirect", "create application (redirect too small: '" + application.redirect + "')");
|
||||
throw new InputException("redirect",
|
||||
"create application (redirect too small: '" + application.redirect + "')");
|
||||
}
|
||||
application.id = null;
|
||||
application.createdAt = null;
|
||||
@ -139,7 +143,8 @@ public class ApplicationResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Application put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
||||
public Application patch(@PathParam("id") final Long id, @AsyncType(Application.class) final String jsonRequest)
|
||||
throws Exception {
|
||||
DataAccess.updateWithJson(Application.class, id, jsonRequest);
|
||||
return DataAccess.get(Application.class, id);
|
||||
}
|
||||
@ -191,50 +196,64 @@ public class ApplicationResource {
|
||||
return out;
|
||||
}
|
||||
|
||||
public record AddUserData(
|
||||
long userId) {}
|
||||
public class AddUserData {
|
||||
public long userId;
|
||||
|
||||
public AddUserData(final long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO : review the function to correct admin only access...
|
||||
@POST
|
||||
@Path("{id}/users")
|
||||
@RolesAllowed(value = { "ADMIN" })
|
||||
public boolean addUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
|
||||
public void addUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
|
||||
this.logger.debug("getApplications");
|
||||
AddOnManyToMany.addLink(UserAuth.class, data.userId, "application", applicationId);
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO : review the function to correct admin only access...
|
||||
@DELETE
|
||||
@Path("{id}/users")
|
||||
@Path("{id}/users/${userId}")
|
||||
@RolesAllowed(value = { "ADMIN" })
|
||||
public boolean rmUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
|
||||
public void removeUser(@PathParam("id") final Long applicationId, @PathParam("userId") final Long userId)
|
||||
throws Exception {
|
||||
this.logger.debug("getApplications");
|
||||
AddOnManyToMany.removeLink(UserAuth.class, data.userId, "application", applicationId);
|
||||
return true;
|
||||
AddOnManyToMany.removeLink(UserAuth.class, userId, "application", applicationId);
|
||||
}
|
||||
|
||||
// TODO : review the function to correct admin only access...
|
||||
@GET
|
||||
@Path("{id}/rights")
|
||||
@RolesAllowed(value = { "ADMIN" })
|
||||
public List<RightDescription> getRightsDescription(@PathParam("id") final Long applicationId) throws Exception {
|
||||
this.logger.debug("getApplications rights");
|
||||
return DataAccess.getsWhere(RightDescription.class, new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
||||
return DataAccess.getsWhere(RightDescription.class,
|
||||
new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
||||
}
|
||||
|
||||
public class ClientToken {
|
||||
public String url;
|
||||
public String jwt;
|
||||
|
||||
public ClientToken(final String url, final String jwt) {
|
||||
this.url = url;
|
||||
this.jwt = jwt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("get_token")
|
||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||
public Response getClientToken(@Context final SecurityContext sc, @QueryParam("application") final String application) throws Exception {
|
||||
public ClientToken getClientToken(
|
||||
@Context final SecurityContext sc,
|
||||
@QueryParam("application") final String application) throws Exception {
|
||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||
this.logger.info("get application TOKEN application name='{}'", application);
|
||||
this.logger.debug("== USER ? {}", gc.userByToken.name);
|
||||
|
||||
if (application == null) {
|
||||
final String result = "Input error missing parameter: 'application'";
|
||||
this.logger.debug(" result: {}", result);
|
||||
return Response.status(406).entity(result).build();
|
||||
throw new InputException("application", "Input error missing parameter");
|
||||
}
|
||||
String applicationName = application;
|
||||
boolean isDev = false;
|
||||
@ -246,35 +265,33 @@ public class ApplicationResource {
|
||||
|
||||
Application appl = null;
|
||||
try {
|
||||
appl = DataAccess.getWhere(Application.class, new Condition(new QueryCondition("name", "=", applicationName)));
|
||||
appl = DataAccess.getWhere(Application.class,
|
||||
new Condition(new QueryCondition("name", "=", applicationName)));
|
||||
} catch (final Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
final String result = "SERVER Internal error";
|
||||
this.logger.debug(" result: {}", result);
|
||||
return Response.status(500).entity(result).build();
|
||||
throw new SystemException("Internal fail request");
|
||||
}
|
||||
|
||||
if (appl == null) {
|
||||
final String result = "Authentiocate-wrong email/login '" + applicationName + "')";
|
||||
this.logger.error(" result: {}", result);
|
||||
return Response.status(401).entity(result).build();
|
||||
throw new InputException("email/login", "Authentiocate-wrong email/login '" + applicationName + "'");
|
||||
}
|
||||
UserLinkApplication links = null;
|
||||
try {
|
||||
links = DataAccess.getWhere(UserLinkApplication.class,
|
||||
new Condition(new QueryAnd(new QueryCondition("object1id", "=", gc.userByToken.id), new QueryCondition("deleted", "=", 0), new QueryCondition("object2id", "=", appl.id))));
|
||||
new Condition(new QueryAnd(new QueryCondition("object1id", "=", gc.userByToken.id),
|
||||
new QueryCondition("deleted", "=", 0), new QueryCondition("object2id", "=", appl.id))));
|
||||
} catch (final Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
final String result = "SERVER Internal error";
|
||||
this.logger.error(" result: {}", result);
|
||||
return Response.status(500).entity(result).build();
|
||||
throw new SystemException("Fail to insert Link");
|
||||
}
|
||||
if (links == null) {
|
||||
final String result = "Authenticate impossible ==> application not accessible '" + applicationName + "'";
|
||||
this.logger.error(" result: {}", result);
|
||||
return Response.status(401).entity(result).build();
|
||||
throw new SystemException(
|
||||
"Authenticate impossible ==> application not accessible '" + applicationName + "'");
|
||||
}
|
||||
// Get the USER Right
|
||||
final Map<String, Object> applicationRight = RightResource.getUserRight(gc.userByToken.id, appl.id);
|
||||
@ -287,19 +304,21 @@ public class ApplicationResource {
|
||||
// and in some application user can see other user or all user of the
|
||||
// application
|
||||
outRight.put(applicationName, applicationRight);
|
||||
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth", applicationName, outRight, -appl.ttl);
|
||||
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth",
|
||||
applicationName, outRight, -appl.ttl);
|
||||
// logger.debug(" ==> generate token: {}", ret);
|
||||
String returnAdress = appl.redirect;
|
||||
if (isDev) {
|
||||
returnAdress = appl.redirectDev;
|
||||
}
|
||||
return Response.status(201).entity("{ \"url\":\"" + returnAdress + "\", \"jwt\":\"" + ret + "\"}").build();
|
||||
return new ClientToken(returnAdress, ret);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("return")
|
||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||
public Response logOut(@Context final SecurityContext sc, @QueryParam("application") final String application) {
|
||||
public String logOut(@Context final SecurityContext sc, @QueryParam("application") final String application)
|
||||
throws SystemException, InputException {
|
||||
this.logger.debug("=====================================");
|
||||
this.logger.debug("Get log_out()");
|
||||
this.logger.debug("=====================================");
|
||||
@ -307,9 +326,7 @@ public class ApplicationResource {
|
||||
this.logger.debug("== USER ? {}", gc.userByToken);
|
||||
|
||||
if (application == null) {
|
||||
final String result = "Input error missing parameter: 'application'";
|
||||
this.logger.error(" result: {}", result);
|
||||
return Response.status(406).entity(result).build();
|
||||
throw new InputException("application", "Input error missing parameter");
|
||||
}
|
||||
String applicationName = application;
|
||||
boolean isDev = false;
|
||||
@ -321,25 +338,20 @@ public class ApplicationResource {
|
||||
|
||||
Application appl = null;
|
||||
try {
|
||||
appl = DataAccess.getWhere(Application.class, new Condition(new QueryCondition("name", "=", applicationName)));
|
||||
appl = DataAccess.getWhere(Application.class,
|
||||
new Condition(new QueryCondition("name", "=", applicationName)));
|
||||
} catch (final Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
final String result = "SERVER Internal error";
|
||||
this.logger.error(" result: {}", result);
|
||||
return Response.status(500).entity(result).build();
|
||||
throw new SystemException("Fail to log-Out...");
|
||||
}
|
||||
|
||||
if (appl == null) {
|
||||
final String result = "Authentiocate-wrong email/login '" + applicationName + "')";
|
||||
this.logger.error(" result: {}", result);
|
||||
return Response.status(404).entity(result).build();
|
||||
throw new SystemException("Authentiocate-wrong email/login '" + applicationName + "'");
|
||||
}
|
||||
String returnAdress = appl.redirect;
|
||||
if (isDev) {
|
||||
returnAdress = appl.redirectDev;
|
||||
}
|
||||
return Response.status(201).entity("{ \"url\":\"" + returnAdress + "\"}").build();
|
||||
return returnAdress;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryAnd;
|
||||
import org.kar.archidata.dataAccess.QueryCondition;
|
||||
import org.kar.archidata.dataAccess.options.Condition;
|
||||
import org.kar.archidata.exception.DataAccessException;
|
||||
import org.kar.archidata.exception.InputException;
|
||||
import org.kar.karso.model.ApplicationToken;
|
||||
import org.slf4j.Logger;
|
||||
@ -23,7 +24,6 @@ import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
|
||||
@Path("/application_token")
|
||||
@ -42,8 +42,11 @@ public class ApplicationTokenResource {
|
||||
@GET
|
||||
@Path("{applicationId}")
|
||||
@RolesAllowed(value = { "ADMIN" })
|
||||
public List<ApplicationToken> gets(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId) throws Exception {
|
||||
final List<ApplicationToken> values = DataAccess.getsWhere(ApplicationToken.class, new Condition(new QueryCondition("parentId", "=", applicationId)));
|
||||
public List<ApplicationToken> gets(
|
||||
@Context final SecurityContext sc,
|
||||
@PathParam("applicationId") final Long applicationId) throws Exception {
|
||||
final List<ApplicationToken> values = DataAccess.getsWhere(ApplicationToken.class,
|
||||
new Condition(new QueryCondition("parentId", "=", applicationId)));
|
||||
// clean all tokens this is a secret:
|
||||
for (final ApplicationToken elem : values) {
|
||||
elem.token = null;
|
||||
@ -54,15 +57,16 @@ public class ApplicationTokenResource {
|
||||
@DELETE
|
||||
@Path("{applicationId}/{tokenId}")
|
||||
@RolesAllowed(value = { "ADMIN" })
|
||||
public Response delete(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId, @PathParam("tokenId") final Integer tokenId) throws Exception {
|
||||
final int nbRemoved = DataAccess.deleteWhere(ApplicationToken.class, new Condition(new QueryAnd(new QueryCondition("parentId", "=", applicationId), new QueryCondition("id", "=", tokenId))));
|
||||
public void remove(
|
||||
@Context final SecurityContext sc,
|
||||
@PathParam("applicationId") final Long applicationId,
|
||||
@PathParam("tokenId") final Integer tokenId) throws Exception {
|
||||
final int nbRemoved = DataAccess.deleteWhere(ApplicationToken.class,
|
||||
new Condition(new QueryAnd(new QueryCondition("parentId", "=", applicationId),
|
||||
new QueryCondition("id", "=", tokenId))));
|
||||
if (nbRemoved == 0) {
|
||||
return Response.notModified("{}").build();
|
||||
throw new DataAccessException("Fail to remove token");
|
||||
}
|
||||
if (nbRemoved == 0) {
|
||||
return Response.serverError().build();
|
||||
}
|
||||
return Response.ok("{}").build();
|
||||
}
|
||||
|
||||
private String multipartCorrection(final String data) {
|
||||
@ -93,24 +97,33 @@ public class ApplicationTokenResource {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public record CreateRequest(
|
||||
String name,
|
||||
Integer validity) {};
|
||||
public class CreateRequest {
|
||||
public CreateRequest(final String name, final Integer validity) {
|
||||
this.name = name;
|
||||
this.validity = validity;
|
||||
}
|
||||
|
||||
public String name;
|
||||
public Integer validity;
|
||||
};
|
||||
|
||||
@POST
|
||||
@Path("/{applicationId}/create")
|
||||
@RolesAllowed("ADMIN")
|
||||
public ApplicationToken createToken(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId, final CreateRequest request) throws Exception {
|
||||
public ApplicationToken create(
|
||||
@Context final SecurityContext sc,
|
||||
@PathParam("applicationId") final Long applicationId,
|
||||
final CreateRequest request) throws Exception {
|
||||
this.logger.info("get user application TOKEN: app='{}' user='???'", applicationId);
|
||||
// correct input string stream :
|
||||
final String name = multipartCorrection(request.name());
|
||||
final String name = multipartCorrection(request.name);
|
||||
//validity = multipartCorrection(validity);
|
||||
this.logger.debug("create a new token...");
|
||||
if (applicationId == null) {
|
||||
throw new InputException("applicationId", "can not be null");
|
||||
}
|
||||
final int maximum = 365 * 5;
|
||||
Integer validity = request.validity();
|
||||
Integer validity = request.validity;
|
||||
if (validity == null || validity < 0 || validity > maximum) {
|
||||
validity = maximum;
|
||||
}
|
||||
@ -134,5 +147,5 @@ public class ApplicationTokenResource {
|
||||
/*
|
||||
Cannot find a deserializer for non-concrete Map type [map type; class jakarta.ws.rs.core.MultivaluedMap, [simple type, class java.lang.String] -> [collection type; class java.util.List, contains [simple type, class java.lang.String]]]
|
||||
at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1]
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryAnd;
|
||||
import org.kar.archidata.dataAccess.QueryCondition;
|
||||
@ -24,7 +25,6 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/right")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@ -32,17 +32,15 @@ public class RightResource {
|
||||
final static Logger logger = LoggerFactory.getLogger(RightResource.class);
|
||||
|
||||
public static List<RightDescription> getApplicationRightDecription(final long applicationId) throws Exception {
|
||||
return DataAccess.getsWhere(RightDescription.class, new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
||||
return DataAccess.getsWhere(RightDescription.class,
|
||||
new Condition(new QueryCondition("applicationId", "=", applicationId)));
|
||||
}
|
||||
|
||||
public static List<Right> getRawUserRight(final long userId, final long applicationId) throws Exception {
|
||||
// Formatter:off
|
||||
return DataAccess.getsWhere(Right.class,
|
||||
new Condition(
|
||||
new QueryAnd(
|
||||
new QueryCondition("applicationId", "=", applicationId),
|
||||
new QueryCondition("userId", "=", userId)
|
||||
)));
|
||||
new Condition(new QueryAnd(new QueryCondition("applicationId", "=", applicationId),
|
||||
new QueryCondition("userId", "=", userId))));
|
||||
// Formatter:on
|
||||
}
|
||||
|
||||
@ -52,23 +50,27 @@ public class RightResource {
|
||||
logger.trace("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
||||
if (rightsDescriptions != null && rightsDescriptions.size() != 0) {
|
||||
final List<Right> rights = getRawUserRight(userId, applicationId);
|
||||
logger.trace("Get some user right: count={} userID={} applicationId={}", rights.size(), userId, applicationId);
|
||||
logger.trace("Get some user right: count={} userID={} applicationId={}", rights.size(), userId,
|
||||
applicationId);
|
||||
logger.trace("Rights:");
|
||||
for (final Right elem : rights) {
|
||||
logger.trace(" - applId={} rightDescriptionId={} value={}", elem.applicationId, elem.rightDescriptionId, elem.value);
|
||||
logger.trace(" - applId={} rightDescriptionId={} value={}", elem.applicationId,
|
||||
elem.rightDescriptionId, elem.value);
|
||||
}
|
||||
logger.trace("RightDescription:");
|
||||
for (final RightDescription description : rightsDescriptions) {
|
||||
if (description == null) {
|
||||
continue;
|
||||
}
|
||||
logger.trace(" - id={} key={} type={} default={}", description.id, description.key, description.type, description.defaultValue);
|
||||
logger.trace(" - id={} key={} type={} default={}", description.id, description.key, description.type,
|
||||
description.defaultValue);
|
||||
}
|
||||
for (final RightDescription description : rightsDescriptions) {
|
||||
if (description == null) {
|
||||
continue;
|
||||
}
|
||||
final Right right = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id)).findAny().orElse(null);
|
||||
final Right right = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id))
|
||||
.findAny().orElse(null);
|
||||
if (right != null) {
|
||||
out.put(description.key, Transform.convertToType(description.type, right.value));
|
||||
} else if (description.defaultValue != null) {
|
||||
@ -84,7 +86,8 @@ public class RightResource {
|
||||
return out;
|
||||
}
|
||||
|
||||
public static void updateUserRight(final long userId, final long applicationId, final Map<String, Object> delta) throws Exception {
|
||||
public static void updateUserRight(final long userId, final long applicationId, final Map<String, Object> delta)
|
||||
throws Exception {
|
||||
final List<RightDescription> rightsDescriptions = getApplicationRightDecription(applicationId);
|
||||
logger.debug("Get some descriptions: {} applicationId={}", rightsDescriptions.size(), applicationId);
|
||||
if (rightsDescriptions == null || rightsDescriptions.size() == 0) {
|
||||
@ -106,16 +109,17 @@ public class RightResource {
|
||||
if (convertedValue == null) {
|
||||
throw new IllegalArgumentException("Uncompatible value:'" + description.type + "'");
|
||||
}
|
||||
List<Right> allRights = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id)).toList();
|
||||
final List<Right> allRights = rights.stream().filter(elem -> elem.rightDescriptionId.equals(description.id))
|
||||
.toList();
|
||||
if (allRights.size() > 1) {
|
||||
// special case of error somewhere else ... ==> remove all elements (except the first)
|
||||
for (int iii=1; iii<allRights.size(); iii++) {
|
||||
for (int iii = 1; iii < allRights.size(); iii++) {
|
||||
logger.error("Remove starnge element in Right id={} ", allRights.get(iii).id);
|
||||
DataAccess.delete(Right.class, allRights.get(iii).id);
|
||||
}
|
||||
}
|
||||
if (allRights.size() == 1 ) {
|
||||
Right right = allRights.get(0);
|
||||
if (allRights.size() == 1) {
|
||||
final Right right = allRights.get(0);
|
||||
// The value exist, we need to update it
|
||||
logger.debug("Request update a knonwn parameter: {} with {}", description.key, newValue);
|
||||
right.value = convertedValue;
|
||||
@ -123,7 +127,7 @@ public class RightResource {
|
||||
} else {
|
||||
// we need to create it
|
||||
logger.debug("Request create parameter: {} with {}", description.key, newValue);
|
||||
Right right = new Right();
|
||||
final Right right = new Right();
|
||||
right.applicationId = applicationId;
|
||||
right.userId = userId;
|
||||
right.rightDescriptionId = description.id;
|
||||
@ -135,21 +139,21 @@ public class RightResource {
|
||||
|
||||
@GET
|
||||
@RolesAllowed("ADMIN")
|
||||
public List<Right> get() throws Exception {
|
||||
public List<Right> gets() throws Exception {
|
||||
return DataAccess.gets(Right.class);
|
||||
}
|
||||
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Right post(final String jsonRequest) throws Exception {
|
||||
return DataAccess.insertWithJson(Right.class, jsonRequest);
|
||||
public Right post(final Right request) throws Exception {
|
||||
return DataAccess.insert(request);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public static Right getWithId(@PathParam("id") final Long id) throws Exception {
|
||||
public static Right get(@PathParam("id") final Long id) throws Exception {
|
||||
return DataAccess.get(Right.class, id);
|
||||
}
|
||||
|
||||
@ -157,7 +161,8 @@ public class RightResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Right put(@PathParam("id") final Long id, final String jsonRequest) throws Exception {
|
||||
public Right patch(@PathParam("id") final Long id, @AsyncType(Right.class) final String jsonRequest)
|
||||
throws Exception {
|
||||
DataAccess.updateWithJson(Right.class, id, jsonRequest);
|
||||
return DataAccess.get(Right.class, id);
|
||||
}
|
||||
@ -165,9 +170,8 @@ public class RightResource {
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response delete(@PathParam("id") final Long id) throws Exception {
|
||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||
DataAccess.delete(Right.class, id);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.kar.karso.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryCondition;
|
||||
@ -23,7 +25,6 @@ import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
|
||||
@Path("/system_config")
|
||||
@ -31,14 +32,14 @@ import jakarta.ws.rs.core.SecurityContext;
|
||||
public class SystemConfigResource {
|
||||
final Logger logger = LoggerFactory.getLogger(SystemConfigResource.class);
|
||||
|
||||
public static class GetSignUpAvaillable {
|
||||
public static class GetSignUpAvailable {
|
||||
public boolean signup;
|
||||
|
||||
public GetSignUpAvaillable(final boolean availlable) {
|
||||
public GetSignUpAvailable(final boolean availlable) {
|
||||
this.signup = availlable;
|
||||
}
|
||||
|
||||
public GetSignUpAvaillable() {
|
||||
public GetSignUpAvailable() {
|
||||
this.signup = false;
|
||||
}
|
||||
}
|
||||
@ -48,13 +49,14 @@ public class SystemConfigResource {
|
||||
@GET
|
||||
@Path("is_sign_up_availlable")
|
||||
@PermitAll
|
||||
public GetSignUpAvaillable isSignUpAvaillable() throws Exception {
|
||||
final Settings set = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", "SIGN_UP_ENABLE")));
|
||||
public GetSignUpAvailable isSignUpAvailable() throws Exception {
|
||||
final Settings set = DataAccess.getWhere(Settings.class,
|
||||
new Condition(new QueryCondition("key", "=", "SIGN_UP_ENABLE")));
|
||||
if (set == null) {
|
||||
throw new NotFoundException("Value does not exist");
|
||||
}
|
||||
final boolean availlable = "true".equalsIgnoreCase(set.value);
|
||||
final GetSignUpAvaillable tmp = new GetSignUpAvaillable(availlable);
|
||||
final GetSignUpAvailable tmp = new GetSignUpAvailable(availlable);
|
||||
this.logger.debug("mlkmlk {}", tmp.signup);
|
||||
return tmp;
|
||||
}
|
||||
@ -62,35 +64,39 @@ public class SystemConfigResource {
|
||||
@GET
|
||||
@Path("key/{key}")
|
||||
@RolesAllowed(value = { "USER", "ADMIN" })
|
||||
public Response getKey(@Context final SecurityContext sc, @PathParam("key") final String key) throws Exception {
|
||||
public Map<String, Object> getKey(@Context final SecurityContext sc, @PathParam("key") final String key)
|
||||
throws Exception {
|
||||
final Settings set = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
||||
if (set == null) {
|
||||
throw new NotFoundException("Value does not exist");
|
||||
}
|
||||
final Map<String, Object> out = new HashMap<>();
|
||||
if ("BOOLEAN".equals(set.type)) {
|
||||
final boolean availlable = "true".equalsIgnoreCase(set.value);
|
||||
return Response.status(200).entity("{ \"value\":" + availlable + "}").build();
|
||||
}
|
||||
if ("NUMBER".equals(set.type)) {
|
||||
final boolean available = "true".equalsIgnoreCase(set.value);
|
||||
out.put("value", available);
|
||||
} else if ("NUMBER".equals(set.type)) {
|
||||
final double value = Double.parseDouble(set.value);
|
||||
return Response.status(200).entity("{ \"value\":" + value + "}").build();
|
||||
out.put("value", value);
|
||||
} else {
|
||||
out.put("value", set.value);
|
||||
}
|
||||
return Response.status(200).entity("{ \"value\":\"" + set.value + "\"}").build();
|
||||
return out;
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("key/{key}")
|
||||
@RolesAllowed(value = { "ADMIN" })
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Response setKey(@Context final SecurityContext sc, @PathParam("key") final String key, final String jsonRequest) throws Exception {
|
||||
public void setKey(@Context final SecurityContext sc, @PathParam("key") final String key, final String jsonRequest)
|
||||
throws Exception {
|
||||
Settings res = null;
|
||||
try {
|
||||
res = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
||||
} catch (final Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
final String result = "Can not find the Key";
|
||||
return Response.status(404).entity(result).build();
|
||||
final String result = "Can not find the Key: '" + key + "'";
|
||||
throw new NotFoundException(result);
|
||||
}
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
// Read the tree to filter injection of data:
|
||||
@ -100,7 +106,6 @@ public class SystemConfigResource {
|
||||
res.value = value.asText();
|
||||
this.logger.debug("Update value : {}", res.value);
|
||||
DataAccess.update(res, res.id, List.of("value"));
|
||||
return Response.status(201).entity("{ \"value\":\"" + res.value + "\"}").build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import jakarta.ws.rs.PATCH;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
@ -82,8 +81,11 @@ public class UserResource {
|
||||
@POST
|
||||
@Path("{userId}/application/{applicationId}/link")
|
||||
@RolesAllowed("ADMIN")
|
||||
public UserAuth linkApplication(@Context final SecurityContext sc, @PathParam("userId") final long userId, @PathParam("applicationId") final long applicationId, final boolean data)
|
||||
throws Exception {
|
||||
public UserAuth linkApplication(
|
||||
@Context final SecurityContext sc,
|
||||
@PathParam("userId") final long userId,
|
||||
@PathParam("applicationId") final long applicationId,
|
||||
final boolean data) throws Exception {
|
||||
this.logger.debug("Find typeNode");
|
||||
if (data) {
|
||||
AddOnManyToMany.addLink(UserAuth.class, userId, "application", applicationId);
|
||||
@ -96,14 +98,21 @@ public class UserResource {
|
||||
@GET
|
||||
@Path("{userId}/application/{applicationId}/rights")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Map<String, Object> getApplicationRight(@Context final SecurityContext sc, @PathParam("userId") final long userId, @PathParam("applicationId") final long applicationId) throws Exception {
|
||||
public Map<String, Object> getApplicationRight(
|
||||
@Context final SecurityContext sc,
|
||||
@PathParam("userId") final long userId,
|
||||
@PathParam("applicationId") final long applicationId) throws Exception {
|
||||
return RightResource.getUserRight(userId, applicationId);
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("{userId}/application/{applicationId}/rights")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Map<String, Object> patchApplicationRight(@Context final SecurityContext sc, @PathParam("userId") final long userId, @PathParam("applicationId") final long applicationId,
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Object> patchApplicationRight(
|
||||
@Context final SecurityContext sc,
|
||||
@PathParam("userId") final long userId,
|
||||
@PathParam("applicationId") final long applicationId,
|
||||
final Map<String, Object> data) throws Exception {
|
||||
this.logger.info("Patch data from FRONT: {}", data);
|
||||
RightResource.updateUserRight(userId, applicationId, data);
|
||||
@ -114,33 +123,35 @@ public class UserResource {
|
||||
@POST
|
||||
@Path("{id}/set_admin")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response setAdmin(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data) throws Exception {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public void setAdmin(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data)
|
||||
throws Exception {
|
||||
final UserAuth user = new UserAuth();
|
||||
user.admin = data;
|
||||
final int ret = DataAccess.update(user, userId, List.of("admin"));
|
||||
if (ret == 0) {
|
||||
return Response.notModified("{}").build();
|
||||
throw new FailException(Response.Status.NOT_MODIFIED, "Fail to modify user as an admin.");
|
||||
}
|
||||
return Response.ok("{}").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{id}/set_blocked")
|
||||
@RolesAllowed("ADMIN")
|
||||
public Response setBlocked(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data) throws Exception {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public void setBlocked(@Context final SecurityContext sc, @PathParam("id") final long userId, final boolean data)
|
||||
throws Exception {
|
||||
final UserAuth user = new UserAuth();
|
||||
user.blocked = data;
|
||||
final int ret = DataAccess.update(user, userId, List.of("blocked"));
|
||||
if (ret == 0) {
|
||||
return Response.notModified("{}").build();
|
||||
throw new FailException(Response.Status.NOT_MODIFIED, "Fail to block the User.");
|
||||
}
|
||||
return Response.ok("{}").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("create_new_user")
|
||||
@RolesAllowed("ADMIN")
|
||||
public UserAuthGet createUser(final UserCreate user) throws Exception {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public UserAuthGet create(final UserCreate user) throws Exception {
|
||||
this.logger.debug("create new User email={} login={}", user.email, user.login);
|
||||
// verify login or email is correct:
|
||||
if (user.login == null || user.login.length() < 6) {
|
||||
@ -159,7 +170,8 @@ public class UserResource {
|
||||
// TODO: verify if the data are a hash ...
|
||||
|
||||
// Check login does not exist
|
||||
List<UserAuth> out = DataAccess.getsWhere(UserAuth.class, new Condition(new QueryCondition("login", "=", user.login)));
|
||||
List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
||||
new Condition(new QueryCondition("login", "=", user.login)));
|
||||
if (out.size() >= 1) {
|
||||
throw new FailException(Response.Status.BAD_REQUEST, "Login already used !!!");
|
||||
}
|
||||
@ -169,7 +181,7 @@ public class UserResource {
|
||||
throw new FailException(Response.Status.BAD_REQUEST, "e-mail already used !!!");
|
||||
}
|
||||
|
||||
// Add new user and return formated dat.
|
||||
// Add new user and return formated data.
|
||||
final UserAuth newUser = new UserAuth();
|
||||
newUser.admin = false;
|
||||
newUser.removed = false;
|
||||
@ -197,7 +209,8 @@ public class UserResource {
|
||||
@POST
|
||||
@Path("password")
|
||||
@RolesAllowed("USER")
|
||||
public Response changePassword(@Context final SecurityContext sc, final ChangePassword data) throws Exception {
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public void changePassword(@Context final SecurityContext sc, final ChangePassword data) throws Exception {
|
||||
this.logger.debug("ChangePassword()");
|
||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||
this.logger.debug("== USER ? {}", gc.userByToken);
|
||||
@ -215,52 +228,31 @@ public class UserResource {
|
||||
// Process the update:
|
||||
user.password = data.newPassword;
|
||||
DataAccess.update(user, user.id, List.of("password"));
|
||||
return Response.status(Response.Status.OK).build();
|
||||
}
|
||||
|
||||
/*
|
||||
@GET
|
||||
@Path("validipass")
|
||||
@Path("is_login_exist")
|
||||
@PermitAll
|
||||
public Response validatePasswordFromEMail(@QueryParam("uuid") String uuid, @QueryParam("securityId") String securityId) {
|
||||
|
||||
// Validate new password if OK
|
||||
|
||||
// clear the passwordChange, passwordValidation fields
|
||||
|
||||
// send an e-mail to confirm the new password has been set.
|
||||
|
||||
|
||||
return Response.status(500).build();
|
||||
}
|
||||
*/
|
||||
|
||||
@GET
|
||||
@Path("/check_login")
|
||||
@PermitAll
|
||||
public Response checkLogin(@QueryParam("login") final String login) throws Exception {
|
||||
public Boolean isLoginExist(@QueryParam("login") final String login) throws Exception {
|
||||
this.logger.debug("checkLogin: '{}'", login);
|
||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class, new Condition(new QueryCondition("login", "=", login)));
|
||||
if (out.size() >= 1) {
|
||||
return Response.ok().build();
|
||||
}
|
||||
throw new NotFoundException("User does not exist: '" + login + "'");
|
||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
||||
new Condition(new QueryCondition("login", "=", login)));
|
||||
return out.size() >= 1;
|
||||
}
|
||||
|
||||
// TODO: add an application TOKEN and permit only 50 requested (maybe add an option to disable it).
|
||||
@GET
|
||||
@Path("/check_email")
|
||||
@Path("is_email_exist")
|
||||
@PermitAll
|
||||
public Response checkEmail(@QueryParam("email") final String email) throws Exception {
|
||||
public Boolean isEmailExist(@QueryParam("email") final String email) throws Exception {
|
||||
this.logger.debug("checkEmail: {}", email);
|
||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class, new Condition(new QueryCondition("email", "=", email)));
|
||||
if (out.size() >= 1) {
|
||||
return Response.ok().build();
|
||||
}
|
||||
throw new NotFoundException("emain does not exist: '" + email + "'");
|
||||
final List<UserAuth> out = DataAccess.getsWhere(UserAuth.class,
|
||||
new Condition(new QueryCondition("email", "=", email)));
|
||||
return out.size() >= 1;
|
||||
}
|
||||
|
||||
private UserAuth checkAuthUser(final String method, final String login, final String time, final String password) throws Exception {
|
||||
private UserAuth checkAuthUser(final String method, final String login, final String time, final String password)
|
||||
throws Exception {
|
||||
// check good version:
|
||||
if (!"v1".contentEquals(method)) {
|
||||
throw new InputException("method", "Authentiocate-method-error (wrong version: '" + method + "')");
|
||||
@ -280,14 +272,16 @@ public class UserResource {
|
||||
final UserAuth user = DataAccess.getWhere(UserAuth.class, new Condition(new QueryCondition(query, "=", login)));
|
||||
|
||||
if (user == null) {
|
||||
throw new FailException(Response.Status.PRECONDITION_FAILED, "FAIL Authentiocate-wrong email/login '" + login + "')");
|
||||
throw new FailException(Response.Status.PRECONDITION_FAILED,
|
||||
"FAIL Authentiocate-wrong email/login '" + login + "')");
|
||||
}
|
||||
// Check the password:
|
||||
final String passwodCheck = getSHA512("login='" + login + "';pass='" + user.password + "';date='" + time + "'");
|
||||
if (!passwodCheck.contentEquals(password)) {
|
||||
throw new FailException(Response.Status.PRECONDITION_FAILED, "Password error ...");
|
||||
}
|
||||
this.logger.debug(" ==> pass nearly all test : admin={} blocked={} removed={}", user.admin, user.blocked, user.removed);
|
||||
this.logger.debug(" ==> pass nearly all test : admin={} blocked={} removed={}", user.admin, user.blocked,
|
||||
user.removed);
|
||||
if (user.blocked || user.removed) {
|
||||
throw new FailException(Response.Status.UNAUTHORIZED, "FAIL Authentiocate");
|
||||
}
|
||||
@ -295,7 +289,7 @@ public class UserResource {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/get_token")
|
||||
@Path("get_token")
|
||||
@PermitAll
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public GetToken getToken(final DataGetToken data) throws Exception {
|
||||
@ -306,7 +300,8 @@ public class UserResource {
|
||||
final int expirationTimeInMinutes = ConfigVariable.getAuthExpirationTime();
|
||||
|
||||
// Get the USER Right (Note: by construction KARSO have application ID = KARSO_INITIALISATION_ID
|
||||
final Map<String, Object> ssoRight = RightResource.getUserRight(user.id, Initialization.KARSO_INITIALISATION_ID);
|
||||
final Map<String, Object> ssoRight = RightResource.getUserRight(user.id,
|
||||
Initialization.KARSO_INITIALISATION_ID);
|
||||
if (!ssoRight.containsKey("USER")) {
|
||||
// If the USER is not override, the system add by default USER
|
||||
ssoRight.put("USER", true);
|
||||
@ -317,8 +312,11 @@ public class UserResource {
|
||||
// we set the right in the under map to manage multiple application group right. and in some application user can see other user or all user of the application
|
||||
outRight.put(applicationName, ssoRight);
|
||||
// TODO: maybe correct this get of TTL...
|
||||
final String ret = JWTWrapper.generateJWToken(user.id, user.login, "KarAuth", applicationName, outRight, expirationTimeInMinutes);
|
||||
|
||||
final String ret = JWTWrapper.generateJWToken(user.id, user.login, "KarAuth", applicationName, outRight,
|
||||
expirationTimeInMinutes);
|
||||
if (ret == null) {
|
||||
throw new SystemException("Missing internal JWT system ==> can not sign anything ...");
|
||||
}
|
||||
// Update last connection:
|
||||
final UserAuth newUser = new UserAuth();
|
||||
newUser.lastConnection = Timestamp.valueOf(LocalDateTime.now());
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.kar.karso.migration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.migration.MigrationSqlStep;
|
||||
import org.kar.karso.model.Application;
|
||||
import org.kar.karso.model.ApplicationToken;
|
||||
@ -12,6 +14,8 @@ public class Initialization extends MigrationSqlStep {
|
||||
|
||||
public static final int KARSO_INITIALISATION_ID = 1;
|
||||
|
||||
public static final List<Class<?>> CLASSES_BASE = List.of(Settings.class, UserAuth.class,Application.class,ApplicationToken.class,RightDescription.class,Right.class);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Initialization";
|
||||
@ -23,12 +27,9 @@ public class Initialization extends MigrationSqlStep {
|
||||
|
||||
@Override
|
||||
public void generateStep() throws Exception {
|
||||
addClass(Settings.class);
|
||||
addClass(UserAuth.class);
|
||||
addClass(Application.class);
|
||||
addClass(ApplicationToken.class);
|
||||
addClass(RightDescription.class);
|
||||
addClass(Right.class);
|
||||
for(final Class<?> clazz : CLASSES_BASE) {
|
||||
addClass(clazz);
|
||||
}
|
||||
|
||||
addAction("""
|
||||
INSERT INTO `application` (`id`, `name`, `description`, `redirect`, `redirectDev`, `notification`, `ttl`) VALUES
|
||||
|
@ -8,10 +8,9 @@ CREATE TABLE `application` (
|
||||
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
|
||||
) AUTO_INCREMENT=10;
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
import org.kar.archidata.annotation.DataComment;
|
||||
import org.kar.archidata.annotation.DataDefault;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
|
||||
@ -19,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
|
||||
@Table(name = "application")
|
||||
@DataIfNotExists
|
||||
@ -31,18 +31,18 @@ public class Application extends GenericDataSoftDelete {
|
||||
@Column(length = 2048, nullable = false)
|
||||
public String redirect;
|
||||
@Column(length = 2048)
|
||||
@DataDefault("'http://localhost:4200/sso/'")
|
||||
@DefaultValue("'http://localhost:4200/sso/'")
|
||||
public String redirectDev;
|
||||
@Column(length = 2048)
|
||||
@DataDefault("'http://localhost:4200/sso/notification'")
|
||||
@DefaultValue("'http://localhost:4200/sso/notification'")
|
||||
public String notification;
|
||||
@Column(nullable = false)
|
||||
@DataComment("Expiration time ")
|
||||
@DataDefault("666")
|
||||
@DefaultValue("666")
|
||||
public Integer ttl;
|
||||
@Column(nullable = false)
|
||||
@DataComment("Right is manage with Karso")
|
||||
@DataDefault("0")
|
||||
@DefaultValue("0")
|
||||
public Boolean manageRight;
|
||||
|
||||
public Application() {}
|
||||
|
@ -1,9 +1,16 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
public class ChangePassword {
|
||||
@Column(length = 32)
|
||||
public String method;
|
||||
@Column(length = 512)
|
||||
public String login;
|
||||
@Column(length = 64)
|
||||
public String time;
|
||||
public String password;
|
||||
public String newPassword;
|
||||
@Column(length = 128)
|
||||
public String password;
|
||||
@Column(length = 128)
|
||||
public String newPassword;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import org.kar.archidata.annotation.DataComment;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@ -17,18 +17,18 @@ import jakarta.persistence.Table;
|
||||
public class Right extends GenericDataSoftDelete {
|
||||
|
||||
@Column(nullable = false)
|
||||
@DataComment("application-ID that have the reference of the right")
|
||||
@Schema(description ="application-ID that have the reference of the right")
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
||||
public Long applicationId;
|
||||
@Column(nullable = false)
|
||||
@DataComment("user-ID ")
|
||||
@Schema(description ="user-ID ")
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserAuth.class)
|
||||
public Long userId;
|
||||
@Column(nullable = false)
|
||||
@DataComment("rightDescription-ID of the right description")
|
||||
@Schema(description ="rightDescription-ID of the right description")
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = RightDescription.class)
|
||||
public Long rightDescriptionId;
|
||||
@Column(length = 1024, nullable = false)
|
||||
@DataComment("Value of the right")
|
||||
@Schema(description ="Value of the right")
|
||||
public String value;
|
||||
}
|
||||
|
@ -1,39 +1,39 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import org.kar.archidata.annotation.DataComment;
|
||||
import org.kar.archidata.annotation.DataDefault;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
|
||||
@Table(name = "rightDescription")
|
||||
@DataIfNotExists
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RightDescription extends GenericDataSoftDelete {
|
||||
@Column(nullable = false)
|
||||
@DataComment("Application id that have the reference of the right")
|
||||
@Schema(description ="Application id that have the reference of the right")
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
|
||||
public Long applicationId;
|
||||
@Column(length = 64, nullable = false)
|
||||
@DataComment("Key of the property")
|
||||
@Schema(description ="Key of the property")
|
||||
public String key;
|
||||
@Column(length = 1024, nullable = false)
|
||||
@DataComment("Title of the right")
|
||||
@Schema(description ="Title of the right")
|
||||
public String title;
|
||||
@Column(length = 1024, nullable = false)
|
||||
@DataComment("Description of the right")
|
||||
@Schema(description ="Description of the right")
|
||||
public String description;
|
||||
@Column(length = 1024)
|
||||
@DataComment("default value if Never set")
|
||||
@Schema(description ="default value if Never set")
|
||||
public String defaultValue;
|
||||
@Column(length = 16, nullable = false)
|
||||
@DataComment("Type of the property")
|
||||
@DataDefault("\"BOOLEAN\"")
|
||||
@Schema(description ="Type of the property")
|
||||
@DefaultValue("\"BOOLEAN\"")
|
||||
public String type = "BOOLEAN"; // this is a place-holder (current type supported BOOLEAN)
|
||||
}
|
@ -1,24 +1,14 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
/*
|
||||
|
||||
CREATE TABLE `application` (
|
||||
`id` bigint NOT NULL COMMENT 'Unique ID of the application' AUTO_INCREMENT PRIMARY KEY,
|
||||
`description` text COMMENT 'description of the application',
|
||||
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
|
||||
) AUTO_INCREMENT=10;
|
||||
|
||||
*/
|
||||
|
||||
import org.kar.archidata.annotation.DataComment;
|
||||
import org.kar.archidata.annotation.DataDefault;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
|
||||
enum PropertyType {
|
||||
STRING, NUMBER, BOOLEAN,
|
||||
@ -30,14 +20,14 @@ enum PropertyType {
|
||||
public class Settings extends GenericDataSoftDelete {
|
||||
@Column(length = 512, nullable = false)
|
||||
public String key;
|
||||
@DataComment("Right for the specific element(ADMIN [rw] USER [rw] other [rw])")
|
||||
@Schema(description ="Right for the specific element(ADMIN [rw] USER [rw] other [rw])")
|
||||
@Column(length = 6, nullable = false)
|
||||
@DataDefault("\"rw----\"")
|
||||
@DefaultValue("\"rw----\"")
|
||||
public String right;
|
||||
@DataComment("Type Of the data")
|
||||
@Schema(description ="Type Of the data")
|
||||
@Column(length = 10, nullable = false)
|
||||
public String type;
|
||||
@DataComment("Value of the configuration")
|
||||
@Schema(description ="Value of the configuration")
|
||||
@Column(nullable = false)
|
||||
public String value;
|
||||
|
||||
|
@ -3,16 +3,16 @@ package org.kar.karso.model;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.annotation.DataComment;
|
||||
import org.kar.archidata.annotation.DataDefault;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.model.User;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
|
||||
@Table(name = "user")
|
||||
@DataIfNotExists
|
||||
@ -25,16 +25,16 @@ public class UserAuth extends User {
|
||||
public String passwordChange; //!< When change a password, the new password is set in temporary area and wait the email validation
|
||||
@Column(length = 128)
|
||||
public String passwordValidation; //!< UniqueId to validate the new password
|
||||
*/
|
||||
*/
|
||||
@Column(length = 512, nullable = false)
|
||||
public String email;
|
||||
public Timestamp emailValidate; // time of validation
|
||||
@Column(length = 512)
|
||||
public String newEmail;
|
||||
@DataDefault("'0'")
|
||||
@DefaultValue("'0'")
|
||||
@Column(nullable = false)
|
||||
public Boolean avatar = false;
|
||||
@DataComment("List of accessible application (if not set the application is not available)")
|
||||
@Schema(description ="List of accessible application (if not set the application is not available)")
|
||||
@ManyToMany(targetEntity = Application.class)
|
||||
public List<Long> applications = null;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import org.kar.archidata.annotation.DataDefault;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.model.User;
|
||||
|
||||
@ -8,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
|
||||
@Table(name = "user")
|
||||
@DataIfNotExists
|
||||
@ -15,7 +15,7 @@ import jakarta.persistence.Table;
|
||||
public class UserAuthGet extends User {
|
||||
@Column(length = 512, nullable = false)
|
||||
public String email;
|
||||
@DataDefault("'0'")
|
||||
@DefaultValue("'0'")
|
||||
@Column(nullable = false)
|
||||
public Boolean avatar = false;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
"index": "src/index.html",
|
||||
"main": "src/app-root/main.ts",
|
||||
"tsConfig": "src/tsconfig.app-root.json",
|
||||
"preserveSymlinks": true,
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
@ -51,33 +52,38 @@
|
||||
"develop": {
|
||||
"optimization": false,
|
||||
"outputHashing": "none",
|
||||
"sourceMap": true,
|
||||
"namedChunks": true,
|
||||
"aot": true,
|
||||
"aot": false,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": true,
|
||||
"buildOptimizer": false
|
||||
"buildOptimizer": false,
|
||||
"sourceMap": {
|
||||
"scripts": true,
|
||||
"styles": true,
|
||||
"hidden": false,
|
||||
"vendor": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "karso:build"
|
||||
"buildTarget": "karso:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "karso:build:production"
|
||||
"buildTarget": "karso:build:production"
|
||||
},
|
||||
"develop": {
|
||||
"browserTarget": "karso:build:develop"
|
||||
"buildTarget": "karso:build:develop"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "karso:build"
|
||||
"buildTarget": "karso:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
@ -165,6 +171,7 @@
|
||||
"index": "src/index.html",
|
||||
"main": "src/app-edge/main.ts",
|
||||
"tsConfig": "src/tsconfig.app-edge.json",
|
||||
"preserveSymlinks": true,
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
@ -201,12 +208,17 @@
|
||||
"develop": {
|
||||
"optimization": false,
|
||||
"outputHashing": "none",
|
||||
"sourceMap": true,
|
||||
"namedChunks": true,
|
||||
"aot": true,
|
||||
"aot": false,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": true,
|
||||
"buildOptimizer": false,
|
||||
"sourceMap": {
|
||||
"scripts": true,
|
||||
"styles": true,
|
||||
"hidden": false,
|
||||
"vendor": true
|
||||
},
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
@ -219,14 +231,14 @@
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "karso:build"
|
||||
"buildTarget": "karso:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "karso-edge:build:production"
|
||||
"buildTarget": "karso-edge:build:production"
|
||||
},
|
||||
"develop": {
|
||||
"browserTarget": "karso-edge:build:develop"
|
||||
"buildTarget": "karso-edge:build:develop"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18611
front/package-lock.json
generated
18611
front/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,46 +14,50 @@
|
||||
"style": "prettier --write .",
|
||||
"e2e": "ng e2e",
|
||||
"update_packages": "ncu --upgrade",
|
||||
"install_dependency": "npm install"
|
||||
"install_dependency": "pnpm install --force",
|
||||
"link_kar_cw": "pnpm link ../../kar-cw/dist/kar-cw/",
|
||||
"unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.2.2",
|
||||
"@angular/cdk": "^17.2.1",
|
||||
"@angular/common": "^17.2.2",
|
||||
"@angular/compiler": "^17.2.2",
|
||||
"@angular/core": "^17.2.2",
|
||||
"@angular/forms": "^17.2.2",
|
||||
"@angular/material": "^17.2.1",
|
||||
"@angular/platform-browser": "^17.2.2",
|
||||
"@angular/platform-browser-dynamic": "^17.2.2",
|
||||
"@angular/router": "^17.2.2",
|
||||
"@angular/animations": "^17.3.6",
|
||||
"@angular/cdk": "^17.3.6",
|
||||
"@angular/common": "^17.3.6",
|
||||
"@angular/compiler": "^17.3.6",
|
||||
"@angular/core": "^17.3.6",
|
||||
"@angular/forms": "^17.3.6",
|
||||
"@angular/material": "^17.3.6",
|
||||
"@angular/platform-browser": "^17.3.6",
|
||||
"@angular/platform-browser-dynamic": "^17.3.6",
|
||||
"@angular/router": "^17.3.6",
|
||||
"rxjs": "^7.8.1",
|
||||
"zone.js": "^0.14.4",
|
||||
"zod": "3.22.4"
|
||||
"zone.js": "^0.14.5",
|
||||
"zod": "3.23.5",
|
||||
"@kangaroo-and-rabbit/kar-cw": "^0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^17.2.1",
|
||||
"@angular-eslint/builder": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin-template": "17.2.1",
|
||||
"@angular-eslint/schematics": "17.2.1",
|
||||
"@angular-eslint/template-parser": "17.2.1",
|
||||
"@angular/cli": "^17.2.1",
|
||||
"@angular/compiler-cli": "^17.2.2",
|
||||
"@angular/language-service": "^17.2.2",
|
||||
"@playwright/test": "^1.41.2",
|
||||
"@angular-devkit/build-angular": "^17.3.6",
|
||||
"@angular-eslint/builder": "17.3.0",
|
||||
"@angular-eslint/eslint-plugin": "17.3.0",
|
||||
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
||||
"@angular-eslint/schematics": "17.3.0",
|
||||
"@angular-eslint/template-parser": "17.3.0",
|
||||
"@angular/cli": "^17.3.6",
|
||||
"@angular/compiler-cli": "^17.3.6",
|
||||
"@angular/language-service": "^17.3.6",
|
||||
"@playwright/test": "^1.43.1",
|
||||
"@types/jest": "^29.5.12",
|
||||
"jasmine": "^5.1.0",
|
||||
"jasmine-core": "^5.1.2",
|
||||
"karma": "^6.4.2",
|
||||
"karma": "^6.4.3",
|
||||
"karma-coverage": "^2.2.1",
|
||||
"karma-coverage-istanbul-reporter": "^3.0.3",
|
||||
"karma-firefox-launcher": "^2.1.2",
|
||||
"karma-firefox-launcher": "^2.1.3",
|
||||
"karma-jasmine": "^5.1.0",
|
||||
"karma-jasmine-html-reporter": "^2.1.0",
|
||||
"karma-spec-reporter": "^0.0.36",
|
||||
"prettier": "^3.2.5",
|
||||
"npm-check-updates": "^16.14.15"
|
||||
"npm-check-updates": "^16.14.20",
|
||||
"tslib": "^2.6.2"
|
||||
}
|
||||
}
|
10417
front/pnpm-lock.yaml
Normal file
10417
front/pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,8 +20,7 @@ import {
|
||||
ApplicationsScene,
|
||||
ApplicationEditScene,
|
||||
} from '../base/scene';
|
||||
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session';
|
||||
import { ForbiddenScene, NotFound404Scene } from 'common/scene';
|
||||
import { ForbiddenScene, NotFound404Scene, OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!-- Generig global menu -->
|
||||
<app-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"></app-top-menu>
|
||||
<karcw-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"/>
|
||||
<!-- all interfaced pages -->
|
||||
<div class="main-content">
|
||||
@if(autoConnectedDone) {
|
||||
|
@ -5,11 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { EventOnMenu } from 'common/component/top-menu/top-menu';
|
||||
import { UserService } from 'common/service/user';
|
||||
import { SessionService } from 'common/service/session';
|
||||
import { MenuItem, MenuPosition } from 'common/model/menu-item';
|
||||
import { SSOService } from 'common/service';
|
||||
import { MenuItem, UserService, SessionService, SSOService, MenuPosition, EventOnMenu } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
enum MenuEventType {
|
||||
|
@ -26,49 +26,14 @@ import {
|
||||
ApplicationsScene,
|
||||
ApplicationEditScene,
|
||||
} from 'base/scene';
|
||||
import {
|
||||
BddService,
|
||||
CookiesService,
|
||||
HttpWrapperService,
|
||||
NotificationService,
|
||||
OnlyAdminGuard,
|
||||
OnlyUnregisteredGuardHome,
|
||||
OnlyUsersGuard,
|
||||
OnlyUsersGuardHome,
|
||||
PopInService,
|
||||
SessionService,
|
||||
SSOService,
|
||||
StorageService,
|
||||
UserService,
|
||||
} from 'common/service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ErrorComponent, PopInComponent, SpinerComponent, TopMenuComponent, UploadFileComponent, PasswordEntryComponent, EntryComponent, AsyncActionStatusComponent, ErrorMessageStateComponent, CheckboxComponent, BurgerPropertyComponent, EntryValidatorComponent, RenderSettingsComponent, RenderFormComponent, EntryNumberComponent } from 'common/component';
|
||||
import { ForbiddenScene } from 'common/scene';
|
||||
import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
|
||||
import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
||||
import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
|
||||
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
TopMenuComponent,
|
||||
UploadFileComponent,
|
||||
ErrorComponent,
|
||||
PasswordEntryComponent,
|
||||
EntryComponent,
|
||||
EntryValidatorComponent,
|
||||
SpinerComponent,
|
||||
AsyncActionStatusComponent,
|
||||
ErrorMessageStateComponent,
|
||||
CheckboxComponent,
|
||||
BurgerPropertyComponent,
|
||||
RenderSettingsComponent,
|
||||
RenderFormComponent,
|
||||
EntryNumberComponent,
|
||||
|
||||
PopInComponent,
|
||||
PopInUploadProgress,
|
||||
PopInDeleteConfirm,
|
||||
|
||||
SignInScene,
|
||||
SignUpScene,
|
||||
SignOutScene,
|
||||
@ -78,7 +43,6 @@ import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
||||
HelpScene,
|
||||
ForgotPasswordScene,
|
||||
SettingsScene,
|
||||
ForbiddenScene,
|
||||
ChangePasswordScene,
|
||||
HomeUnregisteredScene,
|
||||
ManageAccountsScene,
|
||||
@ -93,42 +57,19 @@ import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
CommonModule,
|
||||
KarCWModule,
|
||||
],
|
||||
// injectable element
|
||||
providers: [
|
||||
{ provide: 'ENVIRONMENT', useValue: environment },
|
||||
// application
|
||||
AdminUserService,
|
||||
ApplicationService,
|
||||
ApplicationTokenService,
|
||||
|
||||
// common
|
||||
BddService,
|
||||
CookiesService,
|
||||
HttpWrapperService,
|
||||
StorageService,
|
||||
PopInService,
|
||||
SessionService,
|
||||
UserService,
|
||||
SSOService,
|
||||
NotificationService,
|
||||
SettingsService,
|
||||
OnlyUsersGuard,
|
||||
OnlyAdminGuard,
|
||||
OnlyUsersGuardHome,
|
||||
OnlyUnregisteredGuardHome,
|
||||
],
|
||||
exports: [
|
||||
AppComponent,
|
||||
TopMenuComponent,
|
||||
PasswordEntryComponent,
|
||||
UploadFileComponent,
|
||||
ErrorComponent,
|
||||
BurgerPropertyComponent,
|
||||
|
||||
BurgerPropertyComponent,
|
||||
PopInComponent,
|
||||
PopInUploadProgress,
|
||||
PopInDeleteConfirm,
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
||||
|
@ -22,8 +22,7 @@ import {
|
||||
ApplicationUserEditScene,
|
||||
applicationUserRightEditScene,
|
||||
} from '../base/scene';
|
||||
import { OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from 'common/service/session';
|
||||
import { ForbiddenScene, NotFound404Scene } from 'common/scene';
|
||||
import { ForbiddenScene, NotFound404Scene, OnlyAdminGuard, OnlyUnregisteredGuardHome, OnlyUsersGuard, OnlyUsersGuardHome } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!-- Generig global menu -->
|
||||
<app-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"></app-top-menu>
|
||||
<karcw-top-menu [menu]="currentMenu" (callback)="eventOnMenu($event)"/>
|
||||
<!-- all interfaced pages -->
|
||||
<div class="main-content">
|
||||
@if(autoConnectedDone) {
|
||||
|
@ -5,12 +5,8 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { EventOnMenu } from 'common/component/top-menu/top-menu';
|
||||
import { UserService } from 'common/service/user';
|
||||
import { SessionService, UserRoles222 } from 'common/service/session';
|
||||
import { MenuItem, MenuPosition } from 'common/model/menu-item';
|
||||
import { SSOService } from 'common/service';
|
||||
import { environment } from 'environments/environment';
|
||||
import { EventOnMenu, MenuItem, MenuPosition, SSOService, SessionService, UserRoles222, UserService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { environmentKarso } from 'environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -18,7 +14,7 @@ import { environment } from 'environments/environment';
|
||||
styleUrls: ['./app.component.less'],
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title: string = environment.edgeMode ? 'Karso-edge' : 'Karso';
|
||||
title: string = environmentKarso.edgeMode ? 'Karso-edge' : 'Karso';
|
||||
autoConnectedDone: boolean = false;
|
||||
isConnected: boolean = false;
|
||||
signUpEnable: boolean = true;
|
||||
|
@ -28,65 +28,15 @@ import {
|
||||
ApplicationUserEditScene,
|
||||
applicationUserRightEditScene,
|
||||
} from 'base/scene';
|
||||
import {
|
||||
BddService,
|
||||
CookiesService,
|
||||
HttpWrapperService,
|
||||
NotificationService,
|
||||
OnlyAdminGuard,
|
||||
OnlyUnregisteredGuardHome,
|
||||
OnlyUsersGuard,
|
||||
OnlyUsersGuardHome,
|
||||
PopInService,
|
||||
SessionService,
|
||||
SSOService,
|
||||
StorageService,
|
||||
UserService,
|
||||
} from 'common/service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
ErrorComponent,
|
||||
PopInComponent,
|
||||
SpinerComponent,
|
||||
TopMenuComponent,
|
||||
UploadFileComponent,
|
||||
PasswordEntryComponent,
|
||||
EntryComponent,
|
||||
AsyncActionStatusComponent,
|
||||
ErrorMessageStateComponent,
|
||||
CheckboxComponent,
|
||||
BurgerPropertyComponent,
|
||||
EntryValidatorComponent,
|
||||
RenderSettingsComponent,
|
||||
RenderFormComponent,
|
||||
EntryNumberComponent,
|
||||
} from 'common/component';
|
||||
import { ForbiddenScene } from 'common/scene';
|
||||
import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
|
||||
import { PopInUploadProgress, PopInDeleteConfirm } from 'common/popin';
|
||||
|
||||
import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
|
||||
import { environment } from 'environments/environment';
|
||||
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
TopMenuComponent,
|
||||
UploadFileComponent,
|
||||
ErrorComponent,
|
||||
PasswordEntryComponent,
|
||||
EntryComponent,
|
||||
EntryValidatorComponent,
|
||||
SpinerComponent,
|
||||
AsyncActionStatusComponent,
|
||||
ErrorMessageStateComponent,
|
||||
CheckboxComponent,
|
||||
BurgerPropertyComponent,
|
||||
RenderSettingsComponent,
|
||||
RenderFormComponent,
|
||||
EntryNumberComponent,
|
||||
|
||||
PopInComponent,
|
||||
PopInUploadProgress,
|
||||
PopInDeleteConfirm,
|
||||
|
||||
SignInScene,
|
||||
SignUpScene,
|
||||
@ -97,7 +47,6 @@ import { environment } from 'environments/environment';
|
||||
HelpScene,
|
||||
ForgotPasswordScene,
|
||||
SettingsScene,
|
||||
ForbiddenScene,
|
||||
ChangePasswordScene,
|
||||
HomeUnregisteredScene,
|
||||
ManageAccountsScene,
|
||||
@ -114,42 +63,19 @@ import { environment } from 'environments/environment';
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
CommonModule,
|
||||
KarCWModule,
|
||||
],
|
||||
// injectable element
|
||||
providers: [
|
||||
{ provide: 'ENVIRONMENT', useValue: environment },
|
||||
// application
|
||||
AdminUserService,
|
||||
ApplicationService,
|
||||
ApplicationTokenService,
|
||||
|
||||
// common
|
||||
BddService,
|
||||
CookiesService,
|
||||
HttpWrapperService,
|
||||
StorageService,
|
||||
PopInService,
|
||||
SessionService,
|
||||
UserService,
|
||||
SSOService,
|
||||
NotificationService,
|
||||
SettingsService,
|
||||
OnlyUsersGuard,
|
||||
OnlyAdminGuard,
|
||||
OnlyUsersGuardHome,
|
||||
OnlyUnregisteredGuardHome,
|
||||
],
|
||||
exports: [
|
||||
AppComponent,
|
||||
TopMenuComponent,
|
||||
PasswordEntryComponent,
|
||||
UploadFileComponent,
|
||||
ErrorComponent,
|
||||
BurgerPropertyComponent,
|
||||
|
||||
BurgerPropertyComponent,
|
||||
PopInComponent,
|
||||
PopInUploadProgress,
|
||||
PopInDeleteConfirm,
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
||||
|
252
front/src/back-api/application-resource.ts
Normal file
252
front/src/back-api/application-resource.ts
Normal file
@ -0,0 +1,252 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
Application,
|
||||
RightDescription,
|
||||
Long,
|
||||
ClientToken,
|
||||
ApplicationSmall,
|
||||
AddUserData,
|
||||
isApplication,
|
||||
isRightDescription,
|
||||
isLong,
|
||||
isClientToken,
|
||||
isApplicationSmall,
|
||||
} from "./model"
|
||||
export namespace ApplicationResource {
|
||||
|
||||
export function remove({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
});
|
||||
};
|
||||
export function get({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Application> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isApplication);
|
||||
};
|
||||
export function create({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: Application,
|
||||
}): Promise<Application> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
}, isApplication);
|
||||
};
|
||||
export function patch({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: Application,
|
||||
}): Promise<Application> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}",
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isApplication);
|
||||
};
|
||||
export function gets({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Application[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/application",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isApplication);
|
||||
};
|
||||
export function getApplicationUsers({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Long[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}/users",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isLong);
|
||||
};
|
||||
export function getApplicationsSmall({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<ApplicationSmall[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/application/small",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isApplicationSmall);
|
||||
};
|
||||
export function addUser({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: AddUserData,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}/users",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
});
|
||||
};
|
||||
export function removeUser({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
userId: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}/users/${userId}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
});
|
||||
};
|
||||
export function getRightsDescription({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<RightDescription[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}/rights",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isRightDescription);
|
||||
};
|
||||
export function getClientToken({
|
||||
restConfig,
|
||||
queries,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
application?: string,
|
||||
},
|
||||
}): Promise<ClientToken> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application/get_token",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
queries,
|
||||
}, isClientToken);
|
||||
};
|
||||
export function logOut({
|
||||
restConfig,
|
||||
queries,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
application?: string,
|
||||
},
|
||||
}): Promise<string> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application/return",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
queries,
|
||||
}, null);
|
||||
};
|
||||
}
|
84
front/src/back-api/application-token-resource.ts
Normal file
84
front/src/back-api/application-token-resource.ts
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
ApplicationToken,
|
||||
Integer,
|
||||
Long,
|
||||
CreateRequest,
|
||||
isApplicationToken,
|
||||
} from "./model"
|
||||
export namespace ApplicationTokenResource {
|
||||
|
||||
export function remove({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
tokenId: Integer,
|
||||
applicationId: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/application_token/{applicationId}/{tokenId}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
});
|
||||
};
|
||||
export function create({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
applicationId: Long,
|
||||
},
|
||||
data: CreateRequest,
|
||||
}): Promise<ApplicationToken> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application_token//{applicationId}/create",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isApplicationToken);
|
||||
};
|
||||
export function gets({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
applicationId: Long,
|
||||
},
|
||||
}): Promise<ApplicationToken[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/application_token/{applicationId}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isApplicationToken);
|
||||
};
|
||||
}
|
132
front/src/back-api/data-resource.ts
Normal file
132
front/src/back-api/data-resource.ts
Normal file
@ -0,0 +1,132 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
UUID,
|
||||
} from "./model"
|
||||
export namespace DataResource {
|
||||
|
||||
/**
|
||||
* Get a thumbnail of from the data environment (if resize is possible)
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataThumbnailId({
|
||||
restConfig,
|
||||
queries,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
Authorization?: string,
|
||||
},
|
||||
params: {
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data/thumbnail/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
queries,
|
||||
data,
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataFull({
|
||||
restConfig,
|
||||
queries,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
Authorization?: string,
|
||||
},
|
||||
params: {
|
||||
name: string,
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data/{uuid}/{name}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
queries,
|
||||
data,
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Insert a new data in the data environment
|
||||
*/
|
||||
export function uploadFile({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: {
|
||||
file: File,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data//upload/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Get back some data from the data environment
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataId({
|
||||
restConfig,
|
||||
queries,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
Authorization?: string,
|
||||
},
|
||||
params: {
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
queries,
|
||||
data,
|
||||
});
|
||||
};
|
||||
}
|
18
front/src/back-api/front.ts
Normal file
18
front/src/back-api/front.ts
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
} from "./model"
|
||||
export namespace Front {
|
||||
|
||||
}
|
12
front/src/back-api/index.ts
Normal file
12
front/src/back-api/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Global import of the package
|
||||
*/
|
||||
export * from "./model";
|
||||
export * from "./front";
|
||||
export * from "./data-resource";
|
||||
export * from "./application-resource";
|
||||
export * from "./application-token-resource";
|
||||
export * from "./public-key-resource";
|
||||
export * from "./right-resource";
|
||||
export * from "./user-resource";
|
||||
export * from "./system-config-resource";
|
549
front/src/back-api/model.ts
Normal file
549
front/src/back-api/model.ts
Normal file
@ -0,0 +1,549 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
export const ZodUUID = zod.string().uuid();
|
||||
export type UUID = zod.infer<typeof ZodUUID>;
|
||||
export function isUUID(data: any): data is UUID {
|
||||
try {
|
||||
ZodUUID.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodLong = zod.number();
|
||||
export type Long = zod.infer<typeof ZodLong>;
|
||||
export function isLong(data: any): data is Long {
|
||||
try {
|
||||
ZodLong.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodInteger = zod.number().safe();
|
||||
export type Integer = zod.infer<typeof ZodInteger>;
|
||||
export function isInteger(data: any): data is Integer {
|
||||
try {
|
||||
ZodInteger.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodFloat = zod.number();
|
||||
export type Float = zod.infer<typeof ZodFloat>;
|
||||
export function isFloat(data: any): data is Float {
|
||||
try {
|
||||
ZodFloat.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodInstant = zod.string();
|
||||
export type Instant = zod.infer<typeof ZodInstant>;
|
||||
export function isInstant(data: any): data is Instant {
|
||||
try {
|
||||
ZodInstant.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodDate = zod.date();
|
||||
export type Date = zod.infer<typeof ZodDate>;
|
||||
export function isDate(data: any): data is Date {
|
||||
try {
|
||||
ZodDate.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodTimestamp = zod.date();
|
||||
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
||||
export function isTimestamp(data: any): data is Timestamp {
|
||||
try {
|
||||
ZodTimestamp.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodLocalDate = zod.date();
|
||||
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
||||
export function isLocalDate(data: any): data is LocalDate {
|
||||
try {
|
||||
ZodLocalDate.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodLocalTime = zod.date();
|
||||
export type LocalTime = zod.infer<typeof ZodLocalTime>;
|
||||
export function isLocalTime(data: any): data is LocalTime {
|
||||
try {
|
||||
ZodLocalTime.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodRestErrorResponse = zod.object({
|
||||
uuid: ZodUUID.optional(),
|
||||
name: zod.string().max(255).optional(),
|
||||
message: zod.string().max(255).optional(),
|
||||
time: zod.string().max(255).optional(),
|
||||
status: ZodInteger,
|
||||
statusMessage: zod.string().max(255).optional()
|
||||
});
|
||||
export type RestErrorResponse = zod.infer<typeof ZodRestErrorResponse>;
|
||||
export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
||||
try {
|
||||
ZodRestErrorResponse.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericTiming = zod.object({
|
||||
// Create time of the object
|
||||
createdAt: ZodDate.readonly().optional(),
|
||||
// When update the object
|
||||
updatedAt: ZodDate.readonly().optional()
|
||||
});
|
||||
export type GenericTiming = zod.infer<typeof ZodGenericTiming>;
|
||||
export function isGenericTiming(data: any): data is GenericTiming {
|
||||
try {
|
||||
ZodGenericTiming.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericData = ZodGenericTiming.extend({
|
||||
// Unique Id of the object
|
||||
id: ZodLong.readonly().optional()
|
||||
});
|
||||
export type GenericData = zod.infer<typeof ZodGenericData>;
|
||||
export function isGenericData(data: any): data is GenericData {
|
||||
try {
|
||||
ZodGenericData.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||
// Deleted state
|
||||
deleted: zod.boolean().readonly().optional()
|
||||
});
|
||||
export type GenericDataSoftDelete = zod.infer<typeof ZodGenericDataSoftDelete>;
|
||||
export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
|
||||
try {
|
||||
ZodGenericDataSoftDelete.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
||||
name: zod.string().max(256).optional(),
|
||||
description: zod.string().max(2048).optional(),
|
||||
redirect: zod.string().max(2048).optional(),
|
||||
redirectDev: zod.string().max(2048).optional(),
|
||||
notification: zod.string().max(2048).optional(),
|
||||
// Expiration time
|
||||
ttl: ZodInteger.optional(),
|
||||
// Right is manage with Karso
|
||||
manageRight: zod.boolean().optional()
|
||||
});
|
||||
export type Application = zod.infer<typeof ZodApplication>;
|
||||
export function isApplication(data: any): data is Application {
|
||||
try {
|
||||
ZodApplication.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodApplicationSmall = zod.object({
|
||||
id: ZodLong.optional(),
|
||||
name: zod.string().max(255).optional(),
|
||||
description: zod.string().max(255).optional(),
|
||||
redirect: zod.string().max(255).optional()
|
||||
});
|
||||
export type ApplicationSmall = zod.infer<typeof ZodApplicationSmall>;
|
||||
export function isApplicationSmall(data: any): data is ApplicationSmall {
|
||||
try {
|
||||
ZodApplicationSmall.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodAddUserData = zod.object({
|
||||
userId: ZodLong
|
||||
});
|
||||
export type AddUserData = zod.infer<typeof ZodAddUserData>;
|
||||
export function isAddUserData(data: any): data is AddUserData {
|
||||
try {
|
||||
ZodAddUserData.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
||||
// Application id that have the reference of the right
|
||||
applicationId: ZodLong.optional(),
|
||||
// Key of the property
|
||||
key: zod.string().max(64).optional(),
|
||||
// Title of the right
|
||||
title: zod.string().max(1024).optional(),
|
||||
// Description of the right
|
||||
description: zod.string().max(1024).optional(),
|
||||
// default value if Never set
|
||||
defaultValue: zod.string().max(1024).optional(),
|
||||
// Type of the property
|
||||
type: zod.string().max(16).optional()
|
||||
});
|
||||
export type RightDescription = zod.infer<typeof ZodRightDescription>;
|
||||
export function isRightDescription(data: any): data is RightDescription {
|
||||
try {
|
||||
ZodRightDescription.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodClientToken = zod.object({
|
||||
url: zod.string().max(255).optional(),
|
||||
jwt: zod.string().max(255).optional()
|
||||
});
|
||||
export type ClientToken = zod.infer<typeof ZodClientToken>;
|
||||
export function isClientToken(data: any): data is ClientToken {
|
||||
try {
|
||||
ZodClientToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
||||
parentId: ZodLong.optional(),
|
||||
name: zod.string().optional(),
|
||||
endValidityTime: ZodTimestamp.optional(),
|
||||
token: zod.string().optional()
|
||||
});
|
||||
export type GenericToken = zod.infer<typeof ZodGenericToken>;
|
||||
export function isGenericToken(data: any): data is GenericToken {
|
||||
try {
|
||||
ZodGenericToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodApplicationToken = ZodGenericToken.extend({
|
||||
});
|
||||
export type ApplicationToken = zod.infer<typeof ZodApplicationToken>;
|
||||
export function isApplicationToken(data: any): data is ApplicationToken {
|
||||
try {
|
||||
ZodApplicationToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodCreateRequest = zod.object({
|
||||
name: zod.string().max(255).optional(),
|
||||
validity: ZodInteger.optional()
|
||||
});
|
||||
export type CreateRequest = zod.infer<typeof ZodCreateRequest>;
|
||||
export function isCreateRequest(data: any): data is CreateRequest {
|
||||
try {
|
||||
ZodCreateRequest.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodPublicKey = zod.object({
|
||||
key: zod.string().max(255).optional()
|
||||
});
|
||||
export type PublicKey = zod.infer<typeof ZodPublicKey>;
|
||||
export function isPublicKey(data: any): data is PublicKey {
|
||||
try {
|
||||
ZodPublicKey.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
||||
// application-ID that have the reference of the right
|
||||
applicationId: ZodLong.optional(),
|
||||
// user-ID
|
||||
userId: ZodLong.optional(),
|
||||
// rightDescription-ID of the right description
|
||||
rightDescriptionId: ZodLong.optional(),
|
||||
// Value of the right
|
||||
value: zod.string().max(1024).optional()
|
||||
});
|
||||
export type Right = zod.infer<typeof ZodRight>;
|
||||
export function isRight(data: any): data is Right {
|
||||
try {
|
||||
ZodRight.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||
login: zod.string().max(128).optional(),
|
||||
lastConnection: ZodTimestamp.optional(),
|
||||
admin: zod.boolean(),
|
||||
blocked: zod.boolean(),
|
||||
removed: zod.boolean(),
|
||||
covers: zod.array(ZodLong).optional()
|
||||
});
|
||||
export type User = zod.infer<typeof ZodUser>;
|
||||
export function isUser(data: any): data is User {
|
||||
try {
|
||||
ZodUser.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserAuthGet = ZodUser.extend({
|
||||
email: zod.string().max(512).optional(),
|
||||
avatar: zod.boolean().optional()
|
||||
});
|
||||
export type UserAuthGet = zod.infer<typeof ZodUserAuthGet>;
|
||||
export function isUserAuthGet(data: any): data is UserAuthGet {
|
||||
try {
|
||||
ZodUserAuthGet.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserCreate = zod.object({
|
||||
login: zod.string().max(255).optional(),
|
||||
email: zod.string().max(255).optional(),
|
||||
password: zod.string().max(255).optional()
|
||||
});
|
||||
export type UserCreate = zod.infer<typeof ZodUserCreate>;
|
||||
export function isUserCreate(data: any): data is UserCreate {
|
||||
try {
|
||||
ZodUserCreate.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserAuth = ZodUser.extend({
|
||||
password: zod.string().max(128).optional(),
|
||||
email: zod.string().max(512).optional(),
|
||||
emailValidate: ZodTimestamp.optional(),
|
||||
newEmail: zod.string().max(512).optional(),
|
||||
avatar: zod.boolean().optional(),
|
||||
// List of accessible application (if not set the application is not available)
|
||||
applications: zod.array(ZodLong).optional()
|
||||
});
|
||||
export type UserAuth = zod.infer<typeof ZodUserAuth>;
|
||||
export function isUserAuth(data: any): data is UserAuth {
|
||||
try {
|
||||
ZodUserAuth.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserOut = zod.object({
|
||||
id: ZodLong,
|
||||
login: zod.string().max(255).optional()
|
||||
});
|
||||
export type UserOut = zod.infer<typeof ZodUserOut>;
|
||||
export function isUserOut(data: any): data is UserOut {
|
||||
try {
|
||||
ZodUserOut.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodChangePassword = zod.object({
|
||||
method: zod.string().max(32).optional(),
|
||||
login: zod.string().max(512).optional(),
|
||||
time: zod.string().max(64).optional(),
|
||||
password: zod.string().max(128).optional(),
|
||||
newPassword: zod.string().max(128).optional()
|
||||
});
|
||||
export type ChangePassword = zod.infer<typeof ZodChangePassword>;
|
||||
export function isChangePassword(data: any): data is ChangePassword {
|
||||
try {
|
||||
ZodChangePassword.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGetToken = zod.object({
|
||||
jwt: zod.string().optional()
|
||||
});
|
||||
export type GetToken = zod.infer<typeof ZodGetToken>;
|
||||
export function isGetToken(data: any): data is GetToken {
|
||||
try {
|
||||
ZodGetToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodDataGetToken = zod.object({
|
||||
});
|
||||
export type DataGetToken = zod.infer<typeof ZodDataGetToken>;
|
||||
export function isDataGetToken(data: any): data is DataGetToken {
|
||||
try {
|
||||
ZodDataGetToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGetSignUpAvailable = zod.object({
|
||||
signup: zod.boolean()
|
||||
});
|
||||
export type GetSignUpAvailable = zod.infer<typeof ZodGetSignUpAvailable>;
|
||||
export function isGetSignUpAvailable(data: any): data is GetSignUpAvailable {
|
||||
try {
|
||||
ZodGetSignUpAvailable.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodSettings = ZodGenericDataSoftDelete.extend({
|
||||
key: zod.string().max(512).optional(),
|
||||
// Right for the specific element(ADMIN [rw] USER [rw] other [rw])
|
||||
right: zod.string().max(6).optional(),
|
||||
// Type Of the data
|
||||
type: zod.string().max(10).optional(),
|
||||
// Value of the configuration
|
||||
value: zod.string().max(255).optional()
|
||||
});
|
||||
export type Settings = zod.infer<typeof ZodSettings>;
|
||||
export function isSettings(data: any): data is Settings {
|
||||
try {
|
||||
ZodSettings.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
48
front/src/back-api/public-key-resource.ts
Normal file
48
front/src/back-api/public-key-resource.ts
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
PublicKey,
|
||||
isPublicKey,
|
||||
} from "./model"
|
||||
export namespace PublicKeyResource {
|
||||
|
||||
export function getKey({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<PublicKey> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/public_key",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isPublicKey);
|
||||
};
|
||||
export function getKeyPem({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<string> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/public_key//pem",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, null);
|
||||
};
|
||||
}
|
373
front/src/back-api/rest-tools.ts
Normal file
373
front/src/back-api/rest-tools.ts
Normal file
@ -0,0 +1,373 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2024, Edouard DUPIN, all right reserved
|
||||
* @license MPL-2
|
||||
*/
|
||||
|
||||
import { RestErrorResponse } from "./model"
|
||||
|
||||
export enum HTTPRequestModel {
|
||||
DELETE = 'DELETE',
|
||||
GET = 'GET',
|
||||
PATCH = 'PATCH',
|
||||
POST = 'POST',
|
||||
PUT = 'PUT',
|
||||
}
|
||||
export enum HTTPMimeType {
|
||||
ALL = '*/*',
|
||||
CSV = 'text/csv',
|
||||
IMAGE = 'image/*',
|
||||
IMAGE_JPEG = 'image/jpeg',
|
||||
IMAGE_PNG = 'image/png',
|
||||
JSON = 'application/json',
|
||||
MULTIPART = 'multipart/form-data',
|
||||
OCTET_STREAM = 'application/octet-stream',
|
||||
TEXT_PLAIN = 'text/plain',
|
||||
}
|
||||
|
||||
export interface RESTConfig {
|
||||
// base of the server: http(s)://my.server.org/plop/api/
|
||||
server: string;
|
||||
// Token to access of the data.
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export interface RESTModel {
|
||||
// base of the local API request: "sheep/{id}".
|
||||
endPoint: string;
|
||||
// Type of the request.
|
||||
requestType?: HTTPRequestModel;
|
||||
// Input type requested.
|
||||
accept?: HTTPMimeType;
|
||||
// Content of the local data.
|
||||
contentType?: HTTPMimeType;
|
||||
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
||||
tokenInUrl?: boolean;
|
||||
}
|
||||
|
||||
export interface ModelResponseHttp {
|
||||
status: number;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export function isArrayOf<TYPE>(
|
||||
data: any,
|
||||
typeChecker: (subData: any) => subData is TYPE,
|
||||
length?: number
|
||||
): data is TYPE[] {
|
||||
if (!Array.isArray(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.every(typeChecker)) {
|
||||
return false;
|
||||
}
|
||||
if (length !== undefined && data.length != length) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isNullOrUndefined(data: any): data is undefined | null {
|
||||
return data === undefined || data === null;
|
||||
}
|
||||
|
||||
// generic progression callback
|
||||
export type ProgressCallback = (count: number, total: number) => void;
|
||||
|
||||
export interface RESTAbort {
|
||||
abort?: () => boolean
|
||||
}
|
||||
|
||||
|
||||
// Rest generic callback have a basic model to upload and download advancement.
|
||||
export interface RESTCallbacks {
|
||||
progressUpload?: ProgressCallback,
|
||||
progressDownload?: ProgressCallback,
|
||||
abortHandle?: RESTAbort,
|
||||
};
|
||||
|
||||
export interface RESTRequestType {
|
||||
restModel: RESTModel,
|
||||
restConfig: RESTConfig,
|
||||
data?: any,
|
||||
params?: object,
|
||||
queries?: object,
|
||||
callback?: RESTCallbacks,
|
||||
};
|
||||
|
||||
function removeTrailingSlashes(input: string): string {
|
||||
if (isNullOrUndefined(input)) {
|
||||
return "undefined";
|
||||
}
|
||||
return input.replace(/\/+$/, '');
|
||||
}
|
||||
function removeLeadingSlashes(input: string): string {
|
||||
if (isNullOrUndefined(input)) {
|
||||
return "";
|
||||
}
|
||||
return input.replace(/^\/+/, '');
|
||||
}
|
||||
|
||||
export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestType): string {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||
if (params !== undefined) {
|
||||
for (let key of Object.keys(params)) {
|
||||
generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
|
||||
}
|
||||
}
|
||||
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
||||
return generateUrl;
|
||||
}
|
||||
const searchParams = new URLSearchParams();
|
||||
if (queries !== undefined) {
|
||||
for (let key of Object.keys(queries)) {
|
||||
const value = queries[key];
|
||||
if (Array.isArray(value)) {
|
||||
for (let iii = 0; iii < value.length; iii++) {
|
||||
searchParams.append(`${key}`, `${value[iii]}`);
|
||||
}
|
||||
} else {
|
||||
searchParams.append(`${key}`, `${value}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
||||
searchParams.append('Authorization', `Bearer ${restConfig.token}`);
|
||||
}
|
||||
return generateUrl + "?" + searchParams.toString();
|
||||
}
|
||||
|
||||
|
||||
export function fetchProgress(generateUrl: string, { method, headers, body }: {
|
||||
method: HTTPRequestModel,
|
||||
headers: any,
|
||||
body: any,
|
||||
}, { progressUpload, progressDownload, abortHandle }: RESTCallbacks): Promise<Response> {
|
||||
const xhr = {
|
||||
io: new XMLHttpRequest()
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
// Stream the upload progress
|
||||
if (progressUpload) {
|
||||
xhr.io.upload.addEventListener("progress", (dataEvent) => {
|
||||
if (dataEvent.lengthComputable) {
|
||||
//console.log(` ==> has a progress event: ${dataEvent.loaded} / ${dataEvent.total}`);
|
||||
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Stream the download progress
|
||||
if (progressDownload) {
|
||||
xhr.io.addEventListener("progress", (dataEvent) => {
|
||||
if (dataEvent.lengthComputable) {
|
||||
//console.log(` ==> download progress:: ${dataEvent.loaded} / ${dataEvent.total}`);
|
||||
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (abortHandle) {
|
||||
abortHandle.abort = () => {
|
||||
if (xhr.io) {
|
||||
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
||||
xhr.io.abort();
|
||||
return true;
|
||||
}
|
||||
console.log(`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check if we have an internal Fail:
|
||||
xhr.io.addEventListener('error', () => {
|
||||
xhr.io = undefined;
|
||||
reject(new TypeError('Failed to fetch'))
|
||||
});
|
||||
|
||||
// Capture the end of the stream
|
||||
xhr.io.addEventListener("loadend", () => {
|
||||
if (xhr.io.readyState !== XMLHttpRequest.DONE) {
|
||||
//console.log(` ==> READY state`);
|
||||
return;
|
||||
}
|
||||
if (xhr.io.status === 0) {
|
||||
//the stream has been aborted
|
||||
reject(new TypeError('Fetch has been aborted'));
|
||||
return;
|
||||
}
|
||||
// Stream is ended, transform in a generic response:
|
||||
const response = new Response(xhr.io.response, {
|
||||
status: xhr.io.status,
|
||||
statusText: xhr.io.statusText
|
||||
});
|
||||
const headersArray = xhr.io.getAllResponseHeaders().trim().replaceAll("\r\n", "\n").split('\n');
|
||||
headersArray.forEach(function (header) {
|
||||
const firstColonIndex = header.indexOf(':');
|
||||
if (firstColonIndex !== -1) {
|
||||
var key = header.substring(0, firstColonIndex).trim();
|
||||
var value = header.substring(firstColonIndex + 1).trim();
|
||||
response.headers.set(key, value);
|
||||
} else {
|
||||
response.headers.set(header, "");
|
||||
}
|
||||
});
|
||||
xhr.io = undefined;
|
||||
resolve(response);
|
||||
});
|
||||
xhr.io.open(method, generateUrl, true);
|
||||
if (!isNullOrUndefined(headers)) {
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
xhr.io.setRequestHeader(key, value as string);
|
||||
}
|
||||
}
|
||||
xhr.io.send(body);
|
||||
});
|
||||
}
|
||||
|
||||
export function RESTRequest({ restModel, restConfig, data, params, queries, callback }: RESTRequestType): Promise<ModelResponseHttp> {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||
let headers: any = {};
|
||||
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
||||
headers['Authorization'] = `Bearer ${restConfig.token}`;
|
||||
}
|
||||
if (restModel.accept !== undefined) {
|
||||
headers['Accept'] = restModel.accept;
|
||||
}
|
||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||
// if Get we have not a content type, the body is empty
|
||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||
headers['Content-Type'] = restModel.contentType;
|
||||
}
|
||||
}
|
||||
let body = data;
|
||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||
body = JSON.stringify(data);
|
||||
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
||||
const formData = new FormData();
|
||||
for (const name in data) {
|
||||
formData.append(name, data[name]);
|
||||
}
|
||||
body = formData
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let action: undefined | Promise<Response> = undefined;
|
||||
if (isNullOrUndefined(callback)
|
||||
|| (isNullOrUndefined(callback.progressDownload)
|
||||
&& isNullOrUndefined(callback.progressUpload)
|
||||
&& isNullOrUndefined(callback.abortHandle))) {
|
||||
// No information needed: call the generic fetch interface
|
||||
action = fetch(generateUrl, {
|
||||
method: restModel.requestType,
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
} else {
|
||||
// need progression information: call old fetch model (XMLHttpRequest) that permit to keep % upload and % download for HTTP1.x
|
||||
action = fetchProgress(generateUrl, {
|
||||
method: restModel.requestType ?? HTTPRequestModel.GET,
|
||||
headers,
|
||||
body,
|
||||
}, callback);
|
||||
}
|
||||
action.then((response: Response) => {
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (restModel.accept !== contentType) {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 901,
|
||||
error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
|
||||
statusMessage: "Fetch error",
|
||||
message: "rest-tools.ts Wrong type in the message return type"
|
||||
} as RestErrorResponse);
|
||||
} else if (contentType === HTTPMimeType.JSON) {
|
||||
response
|
||||
.json()
|
||||
.then((value: any) => {
|
||||
//console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
|
||||
resolve({ status: response.status, data: value });
|
||||
})
|
||||
.catch((reason: any) => {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 902,
|
||||
error: `REST parse json fail: ${reason}`,
|
||||
statusMessage: "Fetch parse error",
|
||||
message: "rest-tools.ts Wrong message model to parse"
|
||||
} as RestErrorResponse);
|
||||
});
|
||||
} else {
|
||||
resolve({ status: response.status, data: response.body });
|
||||
}
|
||||
} else {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: response.status,
|
||||
error: `${response.body}`,
|
||||
statusMessage: "Fetch code error",
|
||||
message: "rest-tools.ts Wrong return code"
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
}).catch((error: any) => {
|
||||
reject({
|
||||
time: Date(),
|
||||
status: 999,
|
||||
error: error,
|
||||
statusMessage: "Fetch catch error",
|
||||
message: "rest-tools.ts detect an error in the fetch request"
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
if (checker(value.data)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 950,
|
||||
error: "REST Fail to verify the data",
|
||||
statusMessage: "API cast ERROR",
|
||||
message: "api.ts Check type as fail"
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
}).catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
if (isArrayOf(value.data, checker)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 950,
|
||||
error: "REST Fail to verify the data",
|
||||
statusMessage: "API cast ERROR",
|
||||
message: "api.ts Check type as fail"
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
}).catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
resolve();
|
||||
}).catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
114
front/src/back-api/right-resource.ts
Normal file
114
front/src/back-api/right-resource.ts
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
Right,
|
||||
Long,
|
||||
isRight,
|
||||
} from "./model"
|
||||
export namespace RightResource {
|
||||
|
||||
export function remove({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/right/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
});
|
||||
};
|
||||
export function get({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Right> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/right/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isRight);
|
||||
};
|
||||
export function patch({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: Right,
|
||||
}): Promise<Right> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/right/{id}",
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isRight);
|
||||
};
|
||||
export function post({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: Right,
|
||||
}): Promise<Right> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/right",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
}, isRight);
|
||||
};
|
||||
export function gets({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Right[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/right",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isRight);
|
||||
};
|
||||
}
|
75
front/src/back-api/system-config-resource.ts
Normal file
75
front/src/back-api/system-config-resource.ts
Normal file
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
GetSignUpAvailable,
|
||||
isGetSignUpAvailable,
|
||||
} from "./model"
|
||||
export namespace SystemConfigResource {
|
||||
|
||||
export function getKey({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
key: string,
|
||||
},
|
||||
}): Promise<any> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/system_config/key/{key}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, null);
|
||||
};
|
||||
export function isSignUpAvailable({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<GetSignUpAvailable> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/system_config/is_sign_up_availlable",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isGetSignUpAvailable);
|
||||
};
|
||||
export function setKey({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
key: string,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/system_config/key/{key}",
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
});
|
||||
};
|
||||
}
|
279
front/src/back-api/user-resource.ts
Normal file
279
front/src/back-api/user-resource.ts
Normal file
@ -0,0 +1,279 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
GetToken,
|
||||
Long,
|
||||
UserOut,
|
||||
UserAuthGet,
|
||||
DataGetToken,
|
||||
UserCreate,
|
||||
ChangePassword,
|
||||
UserAuth,
|
||||
isGetToken,
|
||||
isUserOut,
|
||||
isUserAuthGet,
|
||||
isUserAuth,
|
||||
} from "./model"
|
||||
export namespace UserResource {
|
||||
|
||||
export function create({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: UserCreate,
|
||||
}): Promise<UserAuthGet> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
}, isUserAuthGet);
|
||||
};
|
||||
export function getUsers({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<UserAuthGet[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/users",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isUserAuthGet);
|
||||
};
|
||||
export function getUser({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<UserAuthGet> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isUserAuthGet);
|
||||
};
|
||||
export function linkApplication({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
applicationId: Long,
|
||||
userId: Long,
|
||||
},
|
||||
data: boolean,
|
||||
}): Promise<UserAuth> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/{userId}/application/{applicationId}/link",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isUserAuth);
|
||||
};
|
||||
export function getApplicationRight({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
applicationId: Long,
|
||||
userId: Long,
|
||||
},
|
||||
}): Promise<any> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, null);
|
||||
};
|
||||
export function patchApplicationRight({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
applicationId: Long,
|
||||
userId: Long,
|
||||
},
|
||||
data: any,
|
||||
}): Promise<any> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, null);
|
||||
};
|
||||
export function setAdmin({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: boolean,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/users/{id}/set_admin",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
});
|
||||
};
|
||||
export function setBlocked({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: boolean,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/users/{id}/set_blocked",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
});
|
||||
};
|
||||
export function getMe({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<UserOut> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/me",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isUserOut);
|
||||
};
|
||||
export function changePassword({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: ChangePassword,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/users/password",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
});
|
||||
};
|
||||
export function isLoginExist({
|
||||
restConfig,
|
||||
queries,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
login?: string,
|
||||
},
|
||||
}): Promise<boolean> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/is_login_exist",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
queries,
|
||||
}, null);
|
||||
};
|
||||
export function isEmailExist({
|
||||
restConfig,
|
||||
queries,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
email?: string,
|
||||
},
|
||||
}): Promise<boolean> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/is_email_exist",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
queries,
|
||||
}, null);
|
||||
};
|
||||
export function getToken({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: DataGetToken,
|
||||
}): Promise<GetToken> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/get_token",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
}, isGetToken);
|
||||
};
|
||||
}
|
@ -4,14 +4,11 @@
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ApplicationService, ApplicationModel, ApplicationTokenService } from 'base/service';
|
||||
import { ApplicationTokenModel } from 'base/service/application-token';
|
||||
import { AsyncActionState } from 'common/component';
|
||||
import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
||||
import { NotificationService, PopInService } from 'common/service';
|
||||
import { isNumber, isNumeric, isString } from 'common/utils';
|
||||
import { PopInService, NotificationService, isString, AsyncActionState, isNumber, SettingsItem, CheckerParameterType, SettingType } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Application, ApplicationToken } from 'back-api';
|
||||
import { ApplicationService, ApplicationTokenService } from 'base/service';
|
||||
|
||||
@Component({
|
||||
selector: 'application-setting-edit',
|
||||
@ -21,9 +18,9 @@ import { isNumber, isNumeric, isString } from 'common/utils';
|
||||
})
|
||||
export class ApplicationEditScene implements OnInit {
|
||||
id: number = undefined
|
||||
application: ApplicationModel = undefined;
|
||||
applicationRef: ApplicationModel = undefined;
|
||||
tokens: ApplicationTokenModel[] = [];
|
||||
application: Application = undefined;
|
||||
applicationRef: Application = undefined;
|
||||
tokens: ApplicationToken[] = [];
|
||||
|
||||
constructor(
|
||||
private applicationService: ApplicationService,
|
||||
@ -39,7 +36,7 @@ export class ApplicationEditScene implements OnInit {
|
||||
let self = this;
|
||||
this.applicationService
|
||||
.get(this.id)
|
||||
.then((response: ApplicationModel) => {
|
||||
.then((response: Application) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.application = response;
|
||||
self.checkName(self.application.name);
|
||||
@ -51,7 +48,7 @@ export class ApplicationEditScene implements OnInit {
|
||||
});
|
||||
this.applicationTokenService
|
||||
.gets(this.id)
|
||||
.then((response: ApplicationTokenModel[]) => {
|
||||
.then((response: ApplicationToken[]) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.tokens = response;
|
||||
})
|
||||
@ -170,7 +167,7 @@ export class ApplicationEditScene implements OnInit {
|
||||
let self = this;
|
||||
this.applicationService.update(this.id, this.dataUpdate)
|
||||
.then(
|
||||
(data: ApplicationModel) => {
|
||||
(data: Application) => {
|
||||
self.updateState = AsyncActionState.DONE;
|
||||
console.log(`Get new application data: ${JSON.stringify(data, null, 2)}`);
|
||||
self.application = data;
|
||||
@ -193,7 +190,7 @@ export class ApplicationEditScene implements OnInit {
|
||||
let self = this;
|
||||
this.applicationTokenService
|
||||
.create(this.id, this.dataCreateApplication["name"], this.dataCreateApplication["ttl"])
|
||||
.then((response: ApplicationTokenModel) => {
|
||||
.then((response: ApplicationToken) => {
|
||||
//console.log(`??? get fullllllll response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.tokens.push(response);
|
||||
response.token = `"${response.id}:${response.token}"`
|
||||
@ -204,13 +201,13 @@ export class ApplicationEditScene implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onRemoveApplicationToken(_event: any, token: ApplicationTokenModel) {
|
||||
onRemoveApplicationToken(_event: any, token: ApplicationToken) {
|
||||
this.confirmDeleteComment = `Delete the application token ID: [${this.application.id}/${token.id}] ${token.name}`;
|
||||
this.confirmDeleteApplicationToken = token;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
|
||||
removeApplicationConfirm(token: ApplicationTokenModel) {
|
||||
removeApplicationConfirm(token: ApplicationToken) {
|
||||
let self = this;
|
||||
this.applicationTokenService.remove(self.application.id, token.id)
|
||||
.then(
|
||||
@ -227,8 +224,8 @@ export class ApplicationEditScene implements OnInit {
|
||||
}
|
||||
);
|
||||
}
|
||||
confirmDeleteComment: string = undefined;
|
||||
confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
|
||||
confirmDeleteComment?: string;
|
||||
confirmDeleteApplicationToken?: ApplicationToken;
|
||||
|
||||
deleteConfirmed() {
|
||||
if (this.confirmDeleteApplicationToken !== undefined) {
|
||||
|
@ -6,12 +6,9 @@
|
||||
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ApplicationService, ApplicationModel, ApplicationTokenService, AdminUserService } from 'base/service';
|
||||
import { ApplicationTokenModel } from 'base/service/application-token';
|
||||
import { AsyncActionState } from 'common/component';
|
||||
import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
||||
import { ModelResponseHttp, NotificationService, PopInService } from 'common/service';
|
||||
import { isNumber, isNumeric, isString } from 'common/utils';
|
||||
import { PopInService, NotificationService, isString, isNumber, CheckerParameterType, SettingType, SettingsItem } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Application, ApplicationToken } from 'back-api';
|
||||
import { ApplicationService, ApplicationTokenService, AdminUserService } from 'base/service';
|
||||
|
||||
@Component({
|
||||
selector: 'application-setting-user-edit',
|
||||
@ -24,8 +21,8 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
users: any[] = undefined;
|
||||
notUsers: any[] = undefined;
|
||||
applicationName: string = undefined;
|
||||
applicationRef: ApplicationModel = undefined;
|
||||
tokens: ApplicationTokenModel[] = [];
|
||||
applicationRef: Application = undefined;
|
||||
tokens: ApplicationToken[] = [];
|
||||
|
||||
constructor(
|
||||
private adminUserService: AdminUserService,
|
||||
@ -44,7 +41,7 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
// get local information of the application
|
||||
this.applicationService
|
||||
.get(this.id)
|
||||
.then((response: ApplicationModel) => {
|
||||
.then((response: Application) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.applicationName = response.name;
|
||||
self.applicationRef = response;
|
||||
@ -86,16 +83,12 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
onRemoveApplicationUser(value: boolean, user: any) {
|
||||
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
||||
const self = this;
|
||||
this.applicationService.rmUser(this.id, user.id)
|
||||
.then((response: boolean) => {
|
||||
if (response === true) {
|
||||
self.notUsers.push(user);
|
||||
const index = self.users.indexOf(user, 0);
|
||||
if (index > -1) {
|
||||
self.users.splice(index, 1);
|
||||
}
|
||||
} else {
|
||||
// TODO: manage error
|
||||
this.applicationService.removeUser(this.id, user.id)
|
||||
.then(() => {
|
||||
self.notUsers.push(user);
|
||||
const index = self.users.indexOf(user, 0);
|
||||
if (index > -1) {
|
||||
self.users.splice(index, 1);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
@ -106,15 +99,11 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
||||
const self = this;
|
||||
this.applicationService.addUser(this.id, user.id)
|
||||
.then((response: boolean) => {
|
||||
if (response === true) {
|
||||
self.users.push(user);
|
||||
const index = self.notUsers.indexOf(user, 0);
|
||||
if (index > -1) {
|
||||
self.notUsers.splice(index, 1);
|
||||
}
|
||||
} else {
|
||||
// TODO: manage error
|
||||
.then(() => {
|
||||
self.users.push(user);
|
||||
const index = self.notUsers.indexOf(user, 0);
|
||||
if (index > -1) {
|
||||
self.notUsers.splice(index, 1);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
@ -128,7 +117,7 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
|
||||
|
||||
|
||||
removeApplicationConfirm(token: ApplicationTokenModel) {
|
||||
removeApplicationConfirm(token: ApplicationToken) {
|
||||
let self = this;
|
||||
/*
|
||||
this.applicationTokenService.remove(self.application.id, token.id)
|
||||
@ -148,7 +137,7 @@ export class ApplicationUserEditScene implements OnInit {
|
||||
*/
|
||||
}
|
||||
confirmDeleteComment: string = undefined;
|
||||
confirmDeleteApplicationToken: ApplicationTokenModel = undefined;
|
||||
confirmDeleteApplicationToken: ApplicationToken = undefined;
|
||||
|
||||
deleteConfirmed() {
|
||||
if (this.confirmDeleteApplicationToken !== undefined) {
|
||||
|
@ -6,14 +6,9 @@
|
||||
|
||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { AdminUserService, ApplicationModel, ApplicationService, ApplicationUserRight, SettingsService } from 'base/service';
|
||||
import { ApplicationRightModel } from 'base/service/application';
|
||||
import { SettingType, SettingsItem } from '../manage-accounts/manage-accounts';
|
||||
import { UserService } from 'common/service';
|
||||
import { isNullOrUndefined, isUndefined } from 'common/utils';
|
||||
import { AsyncActionState } from 'common/component';
|
||||
|
||||
|
||||
import { AdminUserService, ApplicationService } from 'base/service';
|
||||
import { isNullOrUndefined, AsyncActionState, SettingsItem, SettingType } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Application, RightDescription } from 'back-api';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -25,17 +20,15 @@ export class applicationUserRightEditScene implements OnInit {
|
||||
page = '';
|
||||
applicationId: number = undefined;
|
||||
userId: number = undefined;
|
||||
application: ApplicationModel;
|
||||
rowRight: ApplicationRightModel[] = [];
|
||||
application: Application;
|
||||
rowRight: RightDescription[] = [];
|
||||
applicationName: string;
|
||||
userName: string;
|
||||
userRights: ApplicationUserRight = {};
|
||||
userRights: any = {};
|
||||
|
||||
constructor(
|
||||
private settingService: SettingsService,
|
||||
private applicationService: ApplicationService,
|
||||
private userService: UserService,
|
||||
private userAdminService: AdminUserService,
|
||||
private adminUserService: AdminUserService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private cdr: ChangeDetectorRef,
|
||||
) { }
|
||||
@ -47,7 +40,7 @@ export class applicationUserRightEditScene implements OnInit {
|
||||
let self = this;
|
||||
this.applicationService
|
||||
.get(this.applicationId)
|
||||
.then((response: ApplicationModel) => {
|
||||
.then((response: Application) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.applicationName = response.name;
|
||||
self.application = response;
|
||||
@ -70,7 +63,7 @@ export class applicationUserRightEditScene implements OnInit {
|
||||
*/
|
||||
this.applicationService
|
||||
.getRights(this.applicationId)
|
||||
.then((response: ApplicationRightModel[]) => {
|
||||
.then((response: RightDescription[]) => {
|
||||
console.log(`getRights OK response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.rowRight = response;
|
||||
self.configureEditInput();
|
||||
@ -79,9 +72,9 @@ export class applicationUserRightEditScene implements OnInit {
|
||||
console.log(`getRights ERROR response: ${JSON.stringify(error, null, 4)}`);
|
||||
});
|
||||
|
||||
this.userAdminService
|
||||
this.adminUserService
|
||||
.getApplicationRights(this.userId, this.applicationId)
|
||||
.then((userRights: ApplicationUserRight) => {
|
||||
.then((userRights: any) => {
|
||||
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
|
||||
self.userRights = userRights;
|
||||
self.configureEditInput();
|
||||
@ -168,9 +161,9 @@ export class applicationUserRightEditScene implements OnInit {
|
||||
this.updateState = AsyncActionState.LOADING;
|
||||
let self = this;
|
||||
console.log(`update requested: : ${JSON.stringify(this.dataUpdate, null, 2)}`);
|
||||
this.userAdminService
|
||||
this.adminUserService
|
||||
.updateApplicationRights(this.userId, this.applicationId, this.dataUpdate)
|
||||
.then((userRights: ApplicationUserRight[]) => {
|
||||
.then((userRights: any[]) => {
|
||||
console.log(`getApplicationRights OK response: ${JSON.stringify(userRights, null, 4)}`);
|
||||
self.userRights = userRights;
|
||||
self.updateState = AsyncActionState.DONE;
|
||||
|
@ -6,11 +6,9 @@
|
||||
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ApplicationService, ApplicationModel } from 'base/service';
|
||||
import { AsyncActionState } from 'common/component';
|
||||
import { CheckerParameterType, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
||||
import { NotificationService, PopInService } from 'common/service';
|
||||
import { isString } from 'common/utils';
|
||||
import { AsyncActionState, CheckerParameterType, NotificationService, PopInService, SettingType, SettingsItem, isString } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { Application } from 'back-api';
|
||||
import { ApplicationService } from 'base/service';
|
||||
|
||||
@Component({
|
||||
selector: 'application-setting',
|
||||
@ -19,7 +17,7 @@ import { isString } from 'common/utils';
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
})
|
||||
export class ApplicationsScene implements OnInit {
|
||||
applications: ApplicationModel[] = [];
|
||||
applications: Application[] = [];
|
||||
|
||||
constructor(
|
||||
private applicationService: ApplicationService,
|
||||
@ -34,7 +32,7 @@ export class ApplicationsScene implements OnInit {
|
||||
this.configureInput();
|
||||
this.applicationService
|
||||
.gets()
|
||||
.then((response: ApplicationModel[]) => {
|
||||
.then((response: Application[]) => {
|
||||
console.log(`??? get full response: ${JSON.stringify(response, null, 4)}`);
|
||||
self.applications = response;
|
||||
})
|
||||
@ -43,13 +41,13 @@ export class ApplicationsScene implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onRemoveApplication(_event: any, application: ApplicationModel) {
|
||||
onRemoveApplication(_event: any, application: Application) {
|
||||
this.confirmDeleteComment = `Delete the application ID: [${application.id}] ${application.name}`;
|
||||
this.confirmDeleteApplication = application;
|
||||
this.popInService.open('popin-delete-confirm');
|
||||
}
|
||||
|
||||
removeApplicationConfirm(application: ApplicationModel) {
|
||||
removeApplicationConfirm(application: Application) {
|
||||
const self = this;
|
||||
this.applicationService.remove(application.id)
|
||||
.then(
|
||||
@ -67,7 +65,7 @@ export class ApplicationsScene implements OnInit {
|
||||
);
|
||||
}
|
||||
confirmDeleteComment: string = undefined;
|
||||
confirmDeleteApplication: ApplicationModel = undefined;
|
||||
confirmDeleteApplication: Application = undefined;
|
||||
|
||||
deleteConfirmed() {
|
||||
if (this.confirmDeleteApplication !== undefined) {
|
||||
@ -77,10 +75,10 @@ export class ApplicationsScene implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
onEditApplication(_event: any, application: ApplicationModel) {
|
||||
onEditApplication(_event: any, application: Application) {
|
||||
this.router.navigate(['application-edit', application.id]);
|
||||
}
|
||||
onEditRightApplication(_event: any, application: ApplicationModel) {
|
||||
onEditRightApplication(_event: any, application: Application) {
|
||||
this.router.navigate(['application-user-edit', application.id]);
|
||||
}
|
||||
|
||||
@ -157,7 +155,7 @@ export class ApplicationsScene implements OnInit {
|
||||
const self = this;
|
||||
this.applicationService.create(this.dataCreateApplication['name'], this.dataCreateApplication['redirect'])
|
||||
.then(
|
||||
(data: ApplicationModel) => {
|
||||
(data: Application) => {
|
||||
self.createState = AsyncActionState.DONE;
|
||||
console.log(`Get new user: ${JSON.stringify(data, null, 2)}`);
|
||||
self.applications.push(data);
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { createPasswordState } from 'common/utils';
|
||||
import { AdminUserService } from 'base/service';
|
||||
import { createPasswordState } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
export enum PasswordState {
|
||||
FILLING = "filling",
|
||||
@ -104,6 +104,7 @@ export class ChangePasswordScene {
|
||||
this.updateState = PasswordState.DONE;
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(`Catch error: ${JSON.stringify(error, null, 2)}`);
|
||||
this.updateState = PasswordState.ERROR;
|
||||
this.error = error;
|
||||
});
|
||||
|
@ -7,8 +7,8 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { UserService } from 'common/service';
|
||||
import { AdminUserService } from 'base/service';
|
||||
import { UserService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
export function checkLoginValidity(value: string): boolean {
|
||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
||||
@ -108,7 +108,7 @@ export class ForgotPasswordScene implements OnInit {
|
||||
onRetreive(): void {
|
||||
let self = this;
|
||||
this.adminUserService
|
||||
.retreivePassword(this.login)
|
||||
.retrievePassword(this.login)
|
||||
.then(() => {
|
||||
// go to the retreive page
|
||||
self.router.navigate(['retreive']);
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { UserService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { ApplicationSmall, ClientToken } from 'back-api';
|
||||
import { ApplicationService } from 'base/service';
|
||||
import { GetApplicationSmallResponse, SpecificTokenResponse } from 'base/service/application';
|
||||
import { UserService } from 'common/service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@ -16,26 +16,27 @@ import { UserService } from 'common/service';
|
||||
})
|
||||
export class HomeScene implements OnInit {
|
||||
error = '';
|
||||
dataList: GetApplicationSmallResponse[];
|
||||
constructor(private applicationService: ApplicationService, private userService: UserService) { }
|
||||
dataList: ApplicationSmall[];
|
||||
constructor(private applicationService: ApplicationService,
|
||||
private userService: UserService) { }
|
||||
|
||||
ngOnInit() {
|
||||
let self = this;
|
||||
this.applicationService
|
||||
.getApplicationsSmall()
|
||||
.then((data: GetApplicationSmallResponse[]) => {
|
||||
.then((data: ApplicationSmall[]) => {
|
||||
self.dataList = data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(`fail to keep data : ${error}`);
|
||||
});
|
||||
}
|
||||
onClick(_event: any, data: GetApplicationSmallResponse): void {
|
||||
onClick(_event: any, data: ApplicationSmall): void {
|
||||
//window.location.href = data.redirect;
|
||||
let self = this;
|
||||
this.applicationService
|
||||
.getApplicationSpecificToken(data.name)
|
||||
.then((result: SpecificTokenResponse) => {
|
||||
.then((result: ClientToken) => {
|
||||
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
|
@ -5,97 +5,9 @@
|
||||
*/
|
||||
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { SessionService, AsyncActionState, createPasswordState, createLoginState, checkEmailValidity } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { AdminUserService } from 'base/service';
|
||||
import { AsyncActionState } from 'common/component';
|
||||
import { SessionService } from 'common/service';
|
||||
import {
|
||||
checkEmailValidity,
|
||||
checkLoginValidity,
|
||||
createLoginState,
|
||||
createPasswordState,
|
||||
isBoolean,
|
||||
isInArray,
|
||||
isNullOrUndefined,
|
||||
isNumber,
|
||||
isObject,
|
||||
isOptionalArrayOf,
|
||||
isOptionalOf,
|
||||
isString,
|
||||
} from 'common/utils';
|
||||
|
||||
export enum SettingType {
|
||||
TITLE = 'TITLE',
|
||||
GROUP = 'GROUP',
|
||||
LINE = 'LINE',
|
||||
BOOLEAN = 'BOOLEAN',
|
||||
STRING = 'STRING',
|
||||
PASSWORD = 'PASSWORD',
|
||||
}
|
||||
export function isSettingType(data: any): data is SettingType {
|
||||
return isInArray(data, ['TITLE', 'GROUP', 'LINE', 'BOOLEAN', 'STRING', 'PASSWORD']);
|
||||
}
|
||||
|
||||
export interface SettingsItem {
|
||||
// Type of the menu Node
|
||||
type: SettingType;
|
||||
// Displayed Title
|
||||
title?: string;
|
||||
// Description of the parameter
|
||||
description?: string;
|
||||
// Image to dsplay that describe the parameter
|
||||
image?: string;
|
||||
// If true the parameter is applied directly to the backend
|
||||
directApply?: boolean;
|
||||
// Parameter key to SET/GET
|
||||
key?: string;
|
||||
// Parameter key to SET/GET or the sub-menu
|
||||
value?: SettingsItem[] | boolean | string | Number;
|
||||
// whendata is change the value is set here:
|
||||
newValue?: boolean | string | Number;
|
||||
}
|
||||
|
||||
export function isSettingsItem(data: any): data is SettingsItem {
|
||||
if (isNullOrUndefined(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!isObject(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!isSettingType(data.type)) {
|
||||
return false;
|
||||
}
|
||||
if (!isOptionalOf(data.title, isString)) {
|
||||
return false;
|
||||
}
|
||||
if (!isOptionalOf(data.description, isString)) {
|
||||
return false;
|
||||
}
|
||||
if (!isOptionalOf(data.image, isString)) {
|
||||
return false;
|
||||
}
|
||||
if (!isOptionalOf(data.directApply, isBoolean)) {
|
||||
return false;
|
||||
}
|
||||
if (!isOptionalOf(data.key, isString)) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
!isOptionalOf(data.value, isBoolean) &&
|
||||
!isOptionalOf(data.value, isString) &&
|
||||
!isOptionalOf(data.value, isNumber) &&
|
||||
!isOptionalArrayOf(data.value, isSettingsItem)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
!isOptionalOf(data.newValue, isBoolean) &&
|
||||
!isOptionalOf(data.newValue, isString) &&
|
||||
!isOptionalOf(data.newValue, isNumber)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
@ -226,7 +138,7 @@ export class ManageAccountsScene implements OnInit {
|
||||
console.log(`create user:`);
|
||||
this.createState = AsyncActionState.LOADING;
|
||||
const self = this;
|
||||
this.adminUserService.createUsers(this.email, this.login, this.password)
|
||||
this.adminUserService.createUser(this.email, this.login, this.password)
|
||||
.then(
|
||||
(user_data: any) => {
|
||||
self.createState = AsyncActionState.DONE;
|
||||
|
@ -5,16 +5,8 @@
|
||||
*/
|
||||
|
||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { SettingType, SettingsItem, isNullOrUndefined, isObject, isOptionalArrayOf, isOptionalOf, isSettingsItem, isString } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { SettingsService } from 'base/service';
|
||||
import { isSettingsItem, SettingsItem, SettingType } from 'common/component/render-settings/render-settings';
|
||||
import {
|
||||
isNullOrUndefined,
|
||||
isObject,
|
||||
isOptionalArrayOf,
|
||||
isOptionalOf,
|
||||
isString,
|
||||
} from 'common/utils';
|
||||
|
||||
|
||||
export interface SettingsItem222 {
|
||||
|
@ -7,10 +7,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { SessionService } from 'common/service';
|
||||
import { createLoginState, createPasswordState, getLoginType, isNullOrUndefined } from 'common/utils';
|
||||
import { AdminUserService, ApplicationService } from 'base/service';
|
||||
import { SpecificTokenResponse } from 'base/service/application';
|
||||
import { SessionService, isNullOrUndefined, createLoginState, getLoginType, createPasswordState } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { ClientToken } from 'back-api';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -62,7 +61,7 @@ export class SignInScene implements OnInit {
|
||||
}
|
||||
// TODO: check auto-reconnection !!!
|
||||
let self = this;
|
||||
if (this.sessionService.islogged() == true && self.loginButtonIsClicked === false) {
|
||||
if (this.sessionService.isLogged() == true && self.loginButtonIsClicked === false) {
|
||||
// in theory it is the inly one case possible, the system loading page after retreiving session ....
|
||||
if (!isNullOrUndefined(self.ssoApplicationId)) {
|
||||
// detect an auto-relog...
|
||||
@ -137,7 +136,7 @@ export class SignInScene implements OnInit {
|
||||
let self = this;
|
||||
this.applicationService
|
||||
.getApplicationSpecificToken(this.ssoApplicationId)
|
||||
.then((result: SpecificTokenResponse) => {
|
||||
.then((result: ClientToken) => {
|
||||
self.transferToApplicationThatRequiredTheSSO2(result.url, result.jwt);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
|
@ -7,10 +7,8 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { UserService } from 'common/service/user';
|
||||
import { isNullOrUndefined } from 'common/utils';
|
||||
import { AdminUserService, ApplicationService } from 'base/service';
|
||||
import { SpecificReturnResponse } from 'base/service/application';
|
||||
import { UserService, isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
export function checkLoginValidity(value: string): boolean {
|
||||
let regexCheck = new RegExp('^[a-zA-Z0-9_\\.-]+$');
|
||||
@ -85,8 +83,8 @@ export class SignOutScene implements OnInit {
|
||||
} else {
|
||||
this.applicationService
|
||||
.getApplicationReturn(this.ssoApplicationId)
|
||||
.then((result: SpecificReturnResponse) => {
|
||||
self.transferToApplicationThatRequiredTheSSO2(result.url);
|
||||
.then((url: string) => {
|
||||
self.transferToApplicationThatRequiredTheSSO2(url);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
// TODO: self.error = `Can not retreive the application interface`;
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { SSOService, UserService } from 'common/service';
|
||||
import { AdminUserService } from 'base/service';
|
||||
import { checkLoginValidity, checkEmailValidity, checkPasswordValidity } from '../forgot-password/forgot-password';
|
||||
import { UserService, SSOService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sign-up',
|
||||
|
@ -5,49 +5,30 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import {
|
||||
SessionService,
|
||||
StorageService,
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
HttpWrapperService,
|
||||
ModelResponseHttp,
|
||||
UserService,
|
||||
} from 'common/service';
|
||||
import { sha512 } from 'common/utils';
|
||||
|
||||
interface MessageLogIn {
|
||||
login: string;
|
||||
method: string;
|
||||
time: string;
|
||||
password: string;
|
||||
}
|
||||
/*
|
||||
interface MessageAnswer_USER_CONNECT {
|
||||
sessionId: string;
|
||||
login: string;
|
||||
eMail: string;
|
||||
role: string;
|
||||
avatar: string;
|
||||
}
|
||||
*/
|
||||
export type ApplicationUserRight = Object;
|
||||
import { UserService, SessionService, sha512 } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { DataGetToken, GetToken, Long, UserAuthGet, UserResource } from 'back-api';
|
||||
import { RESTConfig } from 'back-api/rest-tools';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class AdminUserService {
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karso,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
// 0: Not hide password; 1 hide password;
|
||||
private identificationVersion: number = 1;
|
||||
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private sessionService: SessionService,
|
||||
private http: HttpWrapperService) {
|
||||
private session: SessionService) {
|
||||
console.log('Start AdminUserService');
|
||||
}
|
||||
/**
|
||||
* Log-in with a clear password
|
||||
* @param _login Loggin of the user (or e-mail)
|
||||
* @param _login Login of the user (or e-mail)
|
||||
* @param _password clear password to send at the Oauth server
|
||||
* @returns promise on connection
|
||||
*/
|
||||
@ -59,7 +40,7 @@ export class AdminUserService {
|
||||
this.userService.removeSession();
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.getTocken(login, password)
|
||||
self.getToken(login, password)
|
||||
.then((value: any) => {
|
||||
console.log(' =====> We connect on the system...');
|
||||
self.userService
|
||||
@ -78,14 +59,14 @@ export class AdminUserService {
|
||||
});
|
||||
}
|
||||
|
||||
getTocken(login: string, password: string): Promise<any> {
|
||||
getToken(login: string, password: string): Promise<GetToken> {
|
||||
console.log(`AuthService.getToken ... '${login}':'${password}'`);
|
||||
|
||||
// TODO: skip this part if the token is valid !!!
|
||||
// this is here we need to route to the SSO on external system.
|
||||
|
||||
const currentDate: string = new Date().toISOString();
|
||||
let data: MessageLogIn;
|
||||
let data: DataGetToken;
|
||||
// create request:
|
||||
if (this.identificationVersion === 1) {
|
||||
data = {
|
||||
@ -101,215 +82,111 @@ export class AdminUserService {
|
||||
|
||||
console.log(`call users/connect data=${JSON.stringify(data, null, 2)}`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'users/get_token',
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: data,
|
||||
disableTocken: true,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return UserResource.getToken({
|
||||
restConfig: this.getRestConfig(),
|
||||
data
|
||||
});
|
||||
}
|
||||
getUsers(): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'users',
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
getUsers(): Promise<UserAuthGet[]> {
|
||||
return UserResource.getUsers({
|
||||
restConfig: this.getRestConfig(),
|
||||
});
|
||||
}
|
||||
|
||||
setAdmin(userId: number, state: boolean): Promise<void> {
|
||||
const body = state;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `users/${userId}/set_admin`,
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return UserResource.setAdmin({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id: userId
|
||||
},
|
||||
data: state,
|
||||
});
|
||||
}
|
||||
|
||||
setBlocked(userId: number, state: boolean): Promise<void> {
|
||||
const body = state;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `users/${userId}/set_blocked`,
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return UserResource.setBlocked({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id: userId
|
||||
},
|
||||
data: state,
|
||||
});
|
||||
}
|
||||
|
||||
createUsers(email: string, login: string, password: string): Promise<any> {
|
||||
const body = {
|
||||
email,
|
||||
login,
|
||||
password: sha512(password)
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'users/create_new_user',
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
createUser(email: string, login: string, password: string): Promise<UserAuthGet> {
|
||||
return UserResource.create({
|
||||
restConfig: this.getRestConfig(),
|
||||
data: {
|
||||
login,
|
||||
email,
|
||||
password: sha512(password)
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
create(login: string, email: string, password: string) {
|
||||
return this.createSha(login, email, sha512(password));
|
||||
}
|
||||
createSha(login: string, email: string, password: string) {
|
||||
const data = {
|
||||
method: 'v?',
|
||||
login: login,
|
||||
email: email,
|
||||
password: password,
|
||||
};
|
||||
console.log(`call users data=${JSON.stringify(data, null, 2)}`);
|
||||
|
||||
if (this.identificationVersion === 1) {
|
||||
data.method = 'v1';
|
||||
/*
|
||||
create(login: string, email: string, password: string) {
|
||||
return this.createSha(login, email, sha512(password));
|
||||
}
|
||||
createSha(login: string, email: string, password: string) {
|
||||
const data = {
|
||||
method: 'v?',
|
||||
login: login,
|
||||
email: email,
|
||||
password: password,
|
||||
};
|
||||
console.log(`call users data=${JSON.stringify(data, null, 2)}`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'users',
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: data,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (this.identificationVersion === 1) {
|
||||
data.method = 'v1';
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'users',
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: data,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(`createSha : get some data to check: ${JSON.stringify(response.data)}`);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
checkLogin(login: string): Promise<boolean> {
|
||||
const params = {
|
||||
login: login,
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.request({
|
||||
server: 'karso',
|
||||
endPoint: 'users/check_login',
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
params,
|
||||
})
|
||||
.then((response: Response) => {
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
console.log(`checkLogin : The login already exist`);
|
||||
resolve(false);
|
||||
} else if (response.status >= 404) {
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(`return ERROR fail in verifiing the login`);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return UserResource.isLoginExist({
|
||||
restConfig: this.getRestConfig(),
|
||||
queries: {
|
||||
login
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
checkEMail(email: string): Promise<boolean> {
|
||||
const params = {
|
||||
email: email,
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.request({
|
||||
server: 'karso',
|
||||
endPoint: 'users/check_email',
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
params,
|
||||
})
|
||||
.then((response: Response) => {
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
console.log(`check_email : The login already exist`);
|
||||
resolve(false);
|
||||
} else if (response.status >= 404) {
|
||||
resolve(true);
|
||||
} else {
|
||||
reject(`return ERROR fail in verifiing the email`);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return UserResource.isEmailExist({
|
||||
restConfig: this.getRestConfig(),
|
||||
queries: {
|
||||
email
|
||||
},
|
||||
});
|
||||
}
|
||||
retreivePassword(login: string): Promise<void> {
|
||||
throw new Error('retreivePassword: Method not implemented.');
|
||||
retrievePassword(login: string): Promise<void> {
|
||||
throw new Error('retrievePassword: Method not implemented.');
|
||||
}
|
||||
|
||||
changePassword(oldPassword: string, newPassword: string): Promise<void> {
|
||||
const time: string = new Date().toISOString();
|
||||
const login: string = this.sessionService.getLogin();
|
||||
const login: string = this.session.getLogin();
|
||||
let method = null;
|
||||
let password = null;
|
||||
if (this.identificationVersion === 1) {
|
||||
@ -320,82 +197,36 @@ export class AdminUserService {
|
||||
reject(`Internal Fail (contact administrator).`);
|
||||
});
|
||||
}
|
||||
const body = {
|
||||
method,
|
||||
time,
|
||||
login,
|
||||
password,
|
||||
newPassword: sha512(newPassword),
|
||||
};
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
self.http
|
||||
.request({
|
||||
server: 'karso',
|
||||
endPoint: 'users/password',
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body,
|
||||
})
|
||||
.then((response: Response) => {
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
console.log(`Update password done with sucess`);
|
||||
resolve();
|
||||
} else {
|
||||
reject(`return ERROR to change password: ${response.status}`);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return UserResource.changePassword({
|
||||
restConfig: this.getRestConfig(),
|
||||
data: {
|
||||
method,
|
||||
time,
|
||||
login,
|
||||
password,
|
||||
newPassword: sha512(newPassword),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getApplicationRights(userId: number, applicationId: number): Promise<ApplicationUserRight> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `users/${userId}/application/${applicationId}/rights`,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
console.log(
|
||||
`Get user Rights: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(error);
|
||||
});
|
||||
getApplicationRights(userId: Long, applicationId: Long): Promise<any> {
|
||||
return UserResource.getApplicationRight({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
applicationId,
|
||||
userId,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateApplicationRights(userId: number, applicationId: number, dataUpdate: object): Promise<ApplicationUserRight> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `users/${userId}/application/${applicationId}/rights`,
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: dataUpdate
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
console.log(
|
||||
`Get user Rights: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
updateApplicationRights(userId: number, applicationId: number, dataUpdate: object): Promise<any> {
|
||||
return UserResource.patchApplicationRight({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
applicationId,
|
||||
userId,
|
||||
},
|
||||
data: dataUpdate
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -5,92 +5,53 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import {
|
||||
SessionService,
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
HttpWrapperService,
|
||||
ModelResponseHttp,
|
||||
} from 'common/service';
|
||||
|
||||
export interface ApplicationTokenModel {
|
||||
id: number;
|
||||
name: string;
|
||||
endValidityTime: string;
|
||||
token?: string;
|
||||
}
|
||||
import { SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { ApplicationToken, ApplicationTokenResource, Long } from 'back-api';
|
||||
import { RESTConfig } from 'back-api/rest-tools';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationTokenService {
|
||||
constructor(private http: HttpWrapperService) {
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karso,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
|
||||
constructor(
|
||||
private session: SessionService) {
|
||||
console.log('Start ApplicationTokenService');
|
||||
}
|
||||
|
||||
gets(applicationId: number): Promise<ApplicationTokenModel[]> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application_token/${applicationId}`,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retreive Token for application : get some data to check: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
// tODO: check the format...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
gets(applicationId: Long): Promise<ApplicationToken[]> {
|
||||
return ApplicationTokenResource.gets({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
applicationId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
create(applicationId: number, name: string, validity: number): Promise<ApplicationTokenModel> {
|
||||
let body = {
|
||||
name,
|
||||
validity,
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application_token/${applicationId}/create`,
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
create(applicationId: number, name: string, validity: number): Promise<ApplicationToken> {
|
||||
return ApplicationTokenResource.create({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
applicationId
|
||||
},
|
||||
data: {
|
||||
name,
|
||||
validity
|
||||
}
|
||||
});
|
||||
}
|
||||
remove(applicationId: number, tokenId: number): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.request({
|
||||
server: 'karso',
|
||||
endPoint: `application_token/${applicationId}/${tokenId}`,
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
accept: HTTPMimeType.ALL,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return ApplicationTokenResource.remove({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
applicationId,
|
||||
tokenId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -5,342 +5,123 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import {
|
||||
SessionService,
|
||||
StorageService,
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
HttpWrapperService,
|
||||
ModelResponseHttp,
|
||||
} from 'common/service';
|
||||
|
||||
interface MessageLogIn {
|
||||
login: string;
|
||||
method: string;
|
||||
time: number;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface SpecificTokenResponse {
|
||||
jwt: string;
|
||||
url: string;
|
||||
}
|
||||
export interface SpecificReturnResponse {
|
||||
url: string;
|
||||
}
|
||||
export interface GetApplicationSmallResponse {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
redirect: string;
|
||||
}
|
||||
|
||||
export interface ApplicationModel {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
redirect: string;
|
||||
redirectDev: string;
|
||||
notification: string;
|
||||
ttl: number;
|
||||
}
|
||||
export interface ApplicationRightModel {
|
||||
id: number;
|
||||
applicationId: number;
|
||||
title: string;
|
||||
description: string;
|
||||
key: string;
|
||||
type: string;
|
||||
}
|
||||
import { SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { RightDescription, ApplicationSmall, Application, ApplicationResource, ClientToken, Long } from 'back-api';
|
||||
import { RESTConfig } from 'back-api/rest-tools';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationService {
|
||||
constructor(private http: HttpWrapperService, private sessionService: SessionService) {
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karso,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
|
||||
constructor(private session: SessionService) {
|
||||
console.log('Start ApplicationService');
|
||||
}
|
||||
|
||||
getRights(applicationId: number): Promise<ApplicationRightModel[]> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application/${applicationId}/rights`,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retrieve Token for application : get some data to check: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
// tODO: check the format...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
getRights(id: Long): Promise<RightDescription[]> {
|
||||
return ApplicationResource.getRightsDescription({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id
|
||||
}
|
||||
});
|
||||
}
|
||||
getApplicationSpecificToken(applicationId: string): Promise<SpecificTokenResponse> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'application/get_token',
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
params: {
|
||||
application: applicationId,
|
||||
},
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retrieve Token for application : get some data to check: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
// tODO: check the format...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
getApplicationSpecificToken(application: string): Promise<ClientToken> {
|
||||
return ApplicationResource.getClientToken({
|
||||
restConfig: this.getRestConfig(),
|
||||
queries: {
|
||||
application
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addUser(applicationId: number, userId: number): Promise<boolean> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application/${applicationId}/users`,
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: {
|
||||
userId,
|
||||
},
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
console.log(
|
||||
`User has been added: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
addUser(id: Long, userId: Long): Promise<void> {
|
||||
return ApplicationResource.addUser({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id
|
||||
},
|
||||
data: {
|
||||
userId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
rmUser(applicationId: number, userId: number): Promise<boolean> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application/${applicationId}/users`,
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: {
|
||||
userId,
|
||||
},
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
console.log(
|
||||
`User has been added: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
removeUser(id: Long, userId: Long): Promise<void> {
|
||||
return ApplicationResource.removeUser({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
userId
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getApplicationReturn(applicationId: string): Promise<SpecificReturnResponse> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'application/return',
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
params: {
|
||||
application: applicationId,
|
||||
},
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retreive return for application : get some data to check: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
// tODO: check the format...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
getApplicationReturn(application: string): Promise<string> {
|
||||
return ApplicationResource.logOut({
|
||||
restConfig: this.getRestConfig(),
|
||||
queries: {
|
||||
application
|
||||
},
|
||||
});
|
||||
}
|
||||
getApplicationsSmall(): Promise<GetApplicationSmallResponse[]> {
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'application/small',
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retrieve return for application : get some data to check: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
// tODO: check the format...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
getApplicationsSmall(): Promise<ApplicationSmall[]> {
|
||||
return ApplicationResource.getApplicationsSmall({
|
||||
restConfig: this.getRestConfig(),
|
||||
});
|
||||
}
|
||||
|
||||
getUsers(id: number): Promise<number[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application/${id}/users`,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retrieve return for application : get some data to check: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
// TODO: check the format...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
getUsers(id: number): Promise<Long[]> {
|
||||
return ApplicationResource.getApplicationUsers({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
}
|
||||
});
|
||||
}
|
||||
gets(): Promise<ApplicationModel[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'application',
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
console.log(
|
||||
`retreive return for application : get some data to check: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
// tODO: check the format...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
gets(): Promise<Application[]> {
|
||||
return ApplicationResource.gets({
|
||||
restConfig: this.getRestConfig(),
|
||||
});
|
||||
}
|
||||
get(id: number): Promise<ApplicationModel> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application/${id}`,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
get(id: number): Promise<Application> {
|
||||
return ApplicationResource.get({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
}
|
||||
});
|
||||
}
|
||||
update(id: number, updateState: object): Promise<ApplicationModel> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: `application/${id}`,
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: updateState,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
// TODO: check type ...
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
update(id: number, updateState: Application): Promise<Application> {
|
||||
return ApplicationResource.patch({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
data: updateState
|
||||
});
|
||||
}
|
||||
|
||||
create(name: string, redirect: string): Promise<ApplicationModel> {
|
||||
let body = {
|
||||
name,
|
||||
redirect,
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
server: 'karso',
|
||||
endPoint: 'application',
|
||||
requestType: HTTPRequestModel.POST,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body,
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve(response.data);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
create(name: string, redirect: string): Promise<Application> {
|
||||
return ApplicationResource.create({
|
||||
restConfig: this.getRestConfig(),
|
||||
data: {
|
||||
name,
|
||||
redirect,
|
||||
}
|
||||
});
|
||||
}
|
||||
remove(id: number): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.request({
|
||||
server: 'karso',
|
||||
endPoint: `application/${id}`,
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
accept: HTTPMimeType.ALL,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
})
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return ApplicationResource.remove({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { AdminUserService, ApplicationUserRight } from './admin-user';
|
||||
import { ApplicationModel, ApplicationService } from './application';
|
||||
import { ApplicationTokenService } from './application-token';
|
||||
import { SettingsService } from './settings';
|
||||
export { AdminUserService } from './admin-user';
|
||||
export { ApplicationService } from './application';
|
||||
export { ApplicationTokenService } from './application-token';
|
||||
export { SettingsService } from './settings';
|
||||
|
||||
export { AdminUserService, ApplicationService, SettingsService, ApplicationModel, ApplicationTokenService, ApplicationUserRight };
|
||||
|
@ -5,8 +5,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from 'common/service';
|
||||
import { isUndefined } from 'common/utils';
|
||||
import { isUndefined, SessionService } from '@kangaroo-and-rabbit/kar-cw';
|
||||
import { SystemConfigResource } from 'back-api';
|
||||
import { RESTConfig } from 'back-api/rest-tools';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
|
||||
class MultipleRequest {
|
||||
requestDone: number = 0;
|
||||
@ -44,52 +47,45 @@ class MultipleRequest {
|
||||
|
||||
@Injectable()
|
||||
export class SettingsService {
|
||||
constructor(private http: HttpWrapperService) { }
|
||||
getRestConfig(): RESTConfig {
|
||||
return {
|
||||
server: environment.server.karso,
|
||||
token: this.session.getToken()
|
||||
}
|
||||
}
|
||||
constructor(private session: SessionService) { }
|
||||
/**
|
||||
* Get a generic setting (Key value)
|
||||
* @returns a promise of the data value
|
||||
*/
|
||||
get(key: string): Promise<string | Number | boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
endPoint: `system_config/key/${key}`,
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
SystemConfigResource.getKey(
|
||||
{
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
key
|
||||
}
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve(response.data.value);
|
||||
.then((response: any) => {
|
||||
resolve(response.value);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Set a generic setting (Key value)
|
||||
* @returns a promise when set is done
|
||||
*/
|
||||
set(key: string, value: string | Number | boolean): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http
|
||||
.requestJson({
|
||||
endPoint: `system_config/key/${key}`,
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
accept: HTTPMimeType.JSON,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
body: {
|
||||
value,
|
||||
},
|
||||
})
|
||||
.then((response: ModelResponseHttp) => {
|
||||
resolve(true);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
reject(`return ERROR ${JSON.stringify(error, null, 2)}`);
|
||||
});
|
||||
return;
|
||||
set(key: string, value: string | Number | boolean): Promise<void> {
|
||||
return SystemConfigResource.setKey({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
key
|
||||
},
|
||||
data: `${value}`
|
||||
});
|
||||
}
|
||||
/**
|
||||
@ -121,8 +117,8 @@ export class SettingsService {
|
||||
let multipleResponse = new MultipleRequest(resolve, reject, keys.length);
|
||||
for (let key of keys) {
|
||||
this.set(key, data[key])
|
||||
.then((result: boolean) => {
|
||||
multipleResponse.add(key, result);
|
||||
.then(() => {
|
||||
multipleResponse.add(key, true);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
multipleResponse.fail(key, error);
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 147a955b195eb7c90e445d404f043d9a363087ca
|
@ -3,7 +3,9 @@
|
||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||
|
||||
export const environment: Environment = {
|
||||
production: true,
|
||||
// URL of development API
|
||||
applName: 'karso',
|
||||
@ -11,7 +13,6 @@ export const environment = {
|
||||
server: {
|
||||
karso: `${location.origin}/karso/api`,
|
||||
},
|
||||
edgeMode: true,
|
||||
// set to undefined sso* in case of internal authentication model
|
||||
ssoSite: `${location.origin}/karso-edge`,
|
||||
ssoSignIn: undefined,
|
||||
@ -19,3 +20,7 @@ export const environment = {
|
||||
ssoSignUp: undefined,
|
||||
tokenStoredInPermanentStorage: true,
|
||||
};
|
||||
|
||||
export const environmentKarso = {
|
||||
edgeMode: true,
|
||||
};
|
||||
|
@ -3,7 +3,9 @@
|
||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||
|
||||
export const environment: Environment = {
|
||||
production: false,
|
||||
// URL of development API
|
||||
applName: 'karso-edge',
|
||||
@ -11,7 +13,6 @@ export const environment = {
|
||||
server: {
|
||||
karso: 'http://localhost:15080/karso-edge/api',
|
||||
},
|
||||
edgeMode: true,
|
||||
// set to undefined sso* in case of internal authentication model
|
||||
ssoSite: 'http://localhost:15080/karso',
|
||||
ssoSignIn: undefined,
|
||||
@ -19,3 +20,7 @@ export const environment = {
|
||||
ssoSignUp: undefined,
|
||||
tokenStoredInPermanentStorage: true,
|
||||
};
|
||||
|
||||
export const environmentKarso = {
|
||||
edgeMode: true,
|
||||
};
|
@ -3,7 +3,9 @@
|
||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||
|
||||
export const environment: Environment = {
|
||||
production: true,
|
||||
// URL of development API
|
||||
applName: 'karso',
|
||||
@ -11,7 +13,6 @@ export const environment = {
|
||||
server: {
|
||||
karso: `${location.origin}/karso/api`,
|
||||
},
|
||||
edgeMode: false,
|
||||
// set to undefined sso* in case of internal authentication model
|
||||
ssoSite: undefined,
|
||||
ssoSignIn: undefined,
|
||||
@ -19,3 +20,7 @@ export const environment = {
|
||||
ssoSignUp: undefined,
|
||||
tokenStoredInPermanentStorage: true,
|
||||
};
|
||||
|
||||
export const environmentKarso = {
|
||||
edgeMode: false,
|
||||
};
|
||||
|
@ -3,7 +3,9 @@
|
||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||
|
||||
export const environment = {
|
||||
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||
|
||||
export const environment: Environment = {
|
||||
production: false,
|
||||
// URL of development API
|
||||
applName: 'karso',
|
||||
@ -11,7 +13,6 @@ export const environment = {
|
||||
server: {
|
||||
karso: 'http://localhost:15080/karso/api',
|
||||
},
|
||||
edgeMode: false,
|
||||
// set to undefined sso* in case of internal authentication model
|
||||
ssoSite: undefined,
|
||||
ssoSignIn: undefined,
|
||||
@ -19,3 +20,7 @@ export const environment = {
|
||||
ssoSignUp: undefined,
|
||||
tokenStoredInPermanentStorage: true,
|
||||
};
|
||||
|
||||
export const environmentKarso = {
|
||||
edgeMode: false,
|
||||
};
|
||||
|
@ -9,12 +9,12 @@
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es2018",
|
||||
"target": "ES2022",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"lib": [
|
||||
"es2018",
|
||||
"ES2022",
|
||||
"dom"
|
||||
],
|
||||
"module": "es2020",
|
||||
@ -33,5 +33,13 @@
|
||||
"./src/common/"
|
||||
]
|
||||
}
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"_enabledBlockTypes": [
|
||||
"if",
|
||||
"switch",
|
||||
"for",
|
||||
"defer"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user