forked from simrail/simrail.pro
Compare commits
200 Commits
Author | SHA1 | Date | |
---|---|---|---|
996f16a313 | |||
0f8b1a4729 | |||
badefb0f7f | |||
2ba037fab5 | |||
637134081a | |||
96c17ffe85 | |||
8db158afe9 | |||
6015349c6f | |||
cd191a6f61 | |||
08bfe767bb | |||
6a4ebf56c4 | |||
1e4cafc07f | |||
623bdd8d42 | |||
51b3ff2e22 | |||
816ee5c454 | |||
9a3f004c72 | |||
f528da171b | |||
b23921a28c | |||
e045ded046 | |||
859b7ab3cc | |||
34432e9622 | |||
3af371703b | |||
fcef4e428e | |||
ca8e270c5e | |||
a9d35c604e | |||
8c24a29de2 | |||
e079a1177e | |||
7bf053e452 | |||
328f665c5c | |||
05fe82eff1 | |||
3143ce1058 | |||
85d18190a7 | |||
45434f5a2d | |||
922b7ea633 | |||
f0f01ccda1 | |||
947bd5dedc | |||
a2a9fd25b5 | |||
afdc700a64 | |||
f5ba173b24 | |||
7459649829 | |||
31c1f3fc40 | |||
df1d9df212 | |||
680a18d15a | |||
40f31ba723 | |||
f9974a3430 | |||
c5249da57e | |||
85e00e8d52 | |||
5841c77913 | |||
84d2972869 | |||
94407bc7c4 | |||
47695d7e4f | |||
529d8b8020 | |||
3db6ced4d2 | |||
e5614da846 | |||
71a5b77235 | |||
7617738ab2 | |||
9c3d3e0767 | |||
294068ee97 | |||
29a7ab3a6b | |||
b4cee2447d | |||
a4091c92e4 | |||
77a9540be4 | |||
f8f5a38add | |||
4c7482b919 | |||
f10c623aa8 | |||
4e090ed281 | |||
1b9c616e16 | |||
7fe575a651 | |||
f33c54ba26 | |||
a9094fd1ed | |||
47d98aba82 | |||
c8efbb92f5 | |||
e460fdefe8 | |||
7ed9df1e9d | |||
094e00842a | |||
608894ee1e | |||
895725dc66 | |||
0275d3e0d1 | |||
a46b2237cf | |||
70eced72d2 | |||
0004148cbf | |||
cfcf5cdaaf | |||
b7667304d2 | |||
7e29802f8e | |||
17473db3b5 | |||
990bb8b552 | |||
3f3e369fb7 | |||
e84afd359a | |||
3ce2d4501a | |||
bb1245e528 | |||
fe0d59cad3 | |||
a57b5efb80 | |||
9f8308fe93 | |||
046d6071fd | |||
545dbe993c | |||
afa492952e | |||
8e7806cdb9 | |||
6c43ff7209 | |||
687fa01983 | |||
e2732c2008 | |||
9c84989063 | |||
36bdfef25a | |||
eb1a89b69d | |||
6a951a5da6 | |||
49ebada082 | |||
01c5fe21c2 | |||
67e12b8179 | |||
10acf8860d | |||
7da84d766e | |||
5cb22c0241 | |||
905cf0e622 | |||
1fc526bd43 | |||
0d949833d6 | |||
daed28fa91 | |||
29569a0cb1 | |||
efd51344f0 | |||
e0bee51d20 | |||
61761138f9 | |||
4ec78b998d | |||
0a3c70b108 | |||
24105e92ef | |||
f85252461f | |||
7d564ebbfc | |||
c8d5d4afc8 | |||
6c7b2a70eb | |||
6c0bd324ee | |||
6b5df79088 | |||
e87c9982d8 | |||
479b2c27fd | |||
14be22c46f | |||
12a9b38631 | |||
8f8cbfd6ec | |||
10a5fa7556 | |||
810b6d7bc8 | |||
68b1166b79 | |||
f8b08bc2a9 | |||
df77a343fc | |||
d86f477434 | |||
35ed4dd877 | |||
929e1e7ac0 | |||
8df1c1f6e4 | |||
003d27f8e6 | |||
8b6f7d858b | |||
ff5b81b531 | |||
6398f795b2 | |||
cc87c6eed6 | |||
3ed0b8dbb9 | |||
85f28115cf | |||
14ab862b7d | |||
801b6a1473 | |||
ef86986b56 | |||
ed134e51ad | |||
9dc4d8cd65 | |||
1e1db50ac8 | |||
8a596d3c3a | |||
8cf2d553ab | |||
706642d111 | |||
05c767b521 | |||
f2d56bb602 | |||
eb5e581995 | |||
bca728414b | |||
6f7f2dad52 | |||
3a21491e8b | |||
6075d26ad8 | |||
cc72fee712 | |||
2ad1e61c6a | |||
9dc9cad460 | |||
b60294d0db | |||
b892f63d3d | |||
2ae01ac42d | |||
6daf06971b | |||
14db43c67c | |||
3bd900c1fd | |||
4c68e8f4f4 | |||
ddb3d67329 | |||
f29c310cd3 | |||
ff82fc4479 | |||
ada66d4165 | |||
cb2e5ee557 | |||
59e6bcfa8e | |||
b934f21134 | |||
19b1dbc0d3 | |||
00d10a1649 | |||
37226f5d77 | |||
4c95d7eae5 | |||
12ebea50e7 | |||
899ca6422b | |||
aad78c7519 | |||
b0a0dd082f | |||
ed2ea9dc38 | |||
7203b614d5 | |||
9ac3f56e11 | |||
42f2bb3ff3 | |||
65d5314401 | |||
1cf76e5392 | |||
b879999ff0 | |||
d0cf152e09 | |||
74994e95a8 | |||
055e27928b | |||
5f793aea4b |
31
.drone.yml
Normal file
31
.drone.yml
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build
|
||||
|
||||
steps:
|
||||
- name: build-backend
|
||||
image: plugins/docker
|
||||
settings:
|
||||
insecure: true
|
||||
repo: 10.5.0.103:1222/simrail-backend
|
||||
registry: 10.5.0.103:1222
|
||||
context: './packages/backend'
|
||||
dockerfile: './packages/backend/Dockerfile'
|
||||
tags:
|
||||
- latest
|
||||
|
||||
- name: build-frontend
|
||||
image: plugins/docker
|
||||
settings:
|
||||
insecure: true
|
||||
repo: 10.5.0.103:1222/simrail-frontend
|
||||
registry: 10.5.0.103:1222
|
||||
context: './packages/frontend'
|
||||
dockerfile: './packages/frontend/Dockerfile'
|
||||
tags:
|
||||
- latest
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
546
.editorconfig
Normal file
546
.editorconfig
Normal file
@ -0,0 +1,546 @@
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = crlf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = false
|
||||
max_line_length = 120
|
||||
tab_width = 4
|
||||
ij_continuation_indent_size = 8
|
||||
ij_formatter_off_tag = @formatter:off
|
||||
ij_formatter_on_tag = @formatter:on
|
||||
ij_formatter_tags_enabled = true
|
||||
ij_smart_tabs = false
|
||||
ij_visual_guides =
|
||||
ij_wrap_on_typing = false
|
||||
|
||||
[*.css]
|
||||
ij_css_align_closing_brace_with_properties = false
|
||||
ij_css_blank_lines_around_nested_selector = 1
|
||||
ij_css_blank_lines_between_blocks = 1
|
||||
ij_css_block_comment_add_space = false
|
||||
ij_css_brace_placement = end_of_line
|
||||
ij_css_enforce_quotes_on_format = false
|
||||
ij_css_hex_color_long_format = false
|
||||
ij_css_hex_color_lower_case = false
|
||||
ij_css_hex_color_short_format = false
|
||||
ij_css_hex_color_upper_case = false
|
||||
ij_css_keep_blank_lines_in_code = 2
|
||||
ij_css_keep_indents_on_empty_lines = false
|
||||
ij_css_keep_single_line_blocks = false
|
||||
ij_css_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow
|
||||
ij_css_space_after_colon = true
|
||||
ij_css_space_before_opening_brace = true
|
||||
ij_css_use_double_quotes = true
|
||||
ij_css_value_alignment = do_not_align
|
||||
|
||||
[*.sass]
|
||||
indent_size = 2
|
||||
ij_sass_align_closing_brace_with_properties = false
|
||||
ij_sass_blank_lines_around_nested_selector = 1
|
||||
ij_sass_blank_lines_between_blocks = 1
|
||||
ij_sass_brace_placement = 0
|
||||
ij_sass_enforce_quotes_on_format = false
|
||||
ij_sass_hex_color_long_format = false
|
||||
ij_sass_hex_color_lower_case = false
|
||||
ij_sass_hex_color_short_format = false
|
||||
ij_sass_hex_color_upper_case = false
|
||||
ij_sass_keep_blank_lines_in_code = 2
|
||||
ij_sass_keep_indents_on_empty_lines = false
|
||||
ij_sass_keep_single_line_blocks = false
|
||||
ij_sass_line_comment_add_space = false
|
||||
ij_sass_line_comment_at_first_column = false
|
||||
ij_sass_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow
|
||||
ij_sass_space_after_colon = true
|
||||
ij_sass_space_before_opening_brace = true
|
||||
ij_sass_use_double_quotes = true
|
||||
ij_sass_value_alignment = 0
|
||||
|
||||
[*.scss]
|
||||
indent_size = 2
|
||||
ij_scss_align_closing_brace_with_properties = false
|
||||
ij_scss_blank_lines_around_nested_selector = 1
|
||||
ij_scss_blank_lines_between_blocks = 1
|
||||
ij_scss_block_comment_add_space = false
|
||||
ij_scss_brace_placement = 0
|
||||
ij_scss_enforce_quotes_on_format = false
|
||||
ij_scss_hex_color_long_format = false
|
||||
ij_scss_hex_color_lower_case = false
|
||||
ij_scss_hex_color_short_format = false
|
||||
ij_scss_hex_color_upper_case = false
|
||||
ij_scss_keep_blank_lines_in_code = 2
|
||||
ij_scss_keep_indents_on_empty_lines = false
|
||||
ij_scss_keep_single_line_blocks = false
|
||||
ij_scss_line_comment_add_space = false
|
||||
ij_scss_line_comment_at_first_column = false
|
||||
ij_scss_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow
|
||||
ij_scss_space_after_colon = true
|
||||
ij_scss_space_before_opening_brace = true
|
||||
ij_scss_use_double_quotes = true
|
||||
ij_scss_value_alignment = 0
|
||||
|
||||
[.editorconfig]
|
||||
ij_editorconfig_align_group_field_declarations = false
|
||||
ij_editorconfig_space_after_colon = false
|
||||
ij_editorconfig_space_after_comma = true
|
||||
ij_editorconfig_space_before_colon = false
|
||||
ij_editorconfig_space_before_comma = false
|
||||
ij_editorconfig_spaces_around_assignment_operators = true
|
||||
|
||||
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
|
||||
ij_xml_align_attributes = true
|
||||
ij_xml_align_text = false
|
||||
ij_xml_attribute_wrap = normal
|
||||
ij_xml_block_comment_add_space = false
|
||||
ij_xml_block_comment_at_first_column = true
|
||||
ij_xml_keep_blank_lines = 2
|
||||
ij_xml_keep_indents_on_empty_lines = false
|
||||
ij_xml_keep_line_breaks = true
|
||||
ij_xml_keep_line_breaks_in_text = true
|
||||
ij_xml_keep_whitespaces = false
|
||||
ij_xml_keep_whitespaces_around_cdata = preserve
|
||||
ij_xml_keep_whitespaces_inside_cdata = false
|
||||
ij_xml_line_comment_at_first_column = true
|
||||
ij_xml_space_after_tag_name = false
|
||||
ij_xml_space_around_equals_in_attribute = false
|
||||
ij_xml_space_inside_empty_tag = false
|
||||
ij_xml_text_wrap = normal
|
||||
|
||||
[{*.ats,*.cts,*.mts,*.ts}]
|
||||
ij_continuation_indent_size = 4
|
||||
ij_typescript_align_imports = false
|
||||
ij_typescript_align_multiline_array_initializer_expression = false
|
||||
ij_typescript_align_multiline_binary_operation = false
|
||||
ij_typescript_align_multiline_chained_methods = false
|
||||
ij_typescript_align_multiline_extends_list = false
|
||||
ij_typescript_align_multiline_for = true
|
||||
ij_typescript_align_multiline_parameters = true
|
||||
ij_typescript_align_multiline_parameters_in_calls = false
|
||||
ij_typescript_align_multiline_ternary_operation = false
|
||||
ij_typescript_align_object_properties = 0
|
||||
ij_typescript_align_union_types = false
|
||||
ij_typescript_align_var_statements = 0
|
||||
ij_typescript_array_initializer_new_line_after_left_brace = false
|
||||
ij_typescript_array_initializer_right_brace_on_new_line = false
|
||||
ij_typescript_array_initializer_wrap = off
|
||||
ij_typescript_assignment_wrap = off
|
||||
ij_typescript_binary_operation_sign_on_next_line = false
|
||||
ij_typescript_binary_operation_wrap = off
|
||||
ij_typescript_blacklist_imports = rxjs/Rx, node_modules/**, **/node_modules/**, @angular/material, @angular/material/typings/**
|
||||
ij_typescript_blank_lines_after_imports = 1
|
||||
ij_typescript_blank_lines_around_class = 1
|
||||
ij_typescript_blank_lines_around_field = 0
|
||||
ij_typescript_blank_lines_around_field_in_interface = 0
|
||||
ij_typescript_blank_lines_around_function = 1
|
||||
ij_typescript_blank_lines_around_method = 1
|
||||
ij_typescript_blank_lines_around_method_in_interface = 1
|
||||
ij_typescript_block_brace_style = next_line
|
||||
ij_typescript_block_comment_add_space = false
|
||||
ij_typescript_block_comment_at_first_column = true
|
||||
ij_typescript_call_parameters_new_line_after_left_paren = false
|
||||
ij_typescript_call_parameters_right_paren_on_new_line = false
|
||||
ij_typescript_call_parameters_wrap = off
|
||||
ij_typescript_catch_on_new_line = false
|
||||
ij_typescript_chained_call_dot_on_new_line = true
|
||||
ij_typescript_class_brace_style = next_line
|
||||
ij_typescript_comma_on_new_line = false
|
||||
ij_typescript_do_while_brace_force = never
|
||||
ij_typescript_else_on_new_line = true
|
||||
ij_typescript_enforce_trailing_comma = whenmultiline
|
||||
ij_typescript_enum_constants_wrap = on_every_item
|
||||
ij_typescript_extends_keyword_wrap = off
|
||||
ij_typescript_extends_list_wrap = off
|
||||
ij_typescript_field_prefix = _
|
||||
ij_typescript_file_name_style = relaxed
|
||||
ij_typescript_finally_on_new_line = false
|
||||
ij_typescript_for_brace_force = always
|
||||
ij_typescript_for_statement_new_line_after_left_paren = false
|
||||
ij_typescript_for_statement_right_paren_on_new_line = false
|
||||
ij_typescript_for_statement_wrap = off
|
||||
ij_typescript_force_quote_style = true
|
||||
ij_typescript_force_semicolon_style = true
|
||||
ij_typescript_function_expression_brace_style = next_line
|
||||
ij_typescript_if_brace_force = always
|
||||
ij_typescript_import_merge_members = global
|
||||
ij_typescript_import_prefer_absolute_path = global
|
||||
ij_typescript_import_sort_members = true
|
||||
ij_typescript_import_sort_module_name = false
|
||||
ij_typescript_import_use_node_resolution = true
|
||||
ij_typescript_imports_wrap = off
|
||||
ij_typescript_indent_case_from_switch = true
|
||||
ij_typescript_indent_chained_calls = true
|
||||
ij_typescript_indent_package_children = 0
|
||||
ij_typescript_jsdoc_include_types = false
|
||||
ij_typescript_jsx_attribute_value = braces
|
||||
ij_typescript_keep_blank_lines_in_code = 2
|
||||
ij_typescript_keep_first_column_comment = true
|
||||
ij_typescript_keep_indents_on_empty_lines = false
|
||||
ij_typescript_keep_line_breaks = true
|
||||
ij_typescript_keep_simple_blocks_in_one_line = false
|
||||
ij_typescript_keep_simple_methods_in_one_line = true
|
||||
ij_typescript_line_comment_add_space = true
|
||||
ij_typescript_line_comment_at_first_column = false
|
||||
ij_typescript_method_brace_style = next_line
|
||||
ij_typescript_method_call_chain_wrap = off
|
||||
ij_typescript_method_parameters_new_line_after_left_paren = false
|
||||
ij_typescript_method_parameters_right_paren_on_new_line = false
|
||||
ij_typescript_method_parameters_wrap = off
|
||||
ij_typescript_object_literal_wrap = off
|
||||
ij_typescript_object_types_wrap = on_every_item
|
||||
ij_typescript_parentheses_expression_new_line_after_left_paren = false
|
||||
ij_typescript_parentheses_expression_right_paren_on_new_line = false
|
||||
ij_typescript_place_assignment_sign_on_next_line = false
|
||||
ij_typescript_prefer_as_type_cast = false
|
||||
ij_typescript_prefer_explicit_types_function_expression_returns = false
|
||||
ij_typescript_prefer_explicit_types_function_returns = false
|
||||
ij_typescript_prefer_explicit_types_vars_fields = false
|
||||
ij_typescript_prefer_parameters_wrap = false
|
||||
ij_typescript_property_prefix =
|
||||
ij_typescript_reformat_c_style_comments = false
|
||||
ij_typescript_space_after_colon = true
|
||||
ij_typescript_space_after_comma = true
|
||||
ij_typescript_space_after_dots_in_rest_parameter = false
|
||||
ij_typescript_space_after_generator_mult = true
|
||||
ij_typescript_space_after_property_colon = true
|
||||
ij_typescript_space_after_quest = true
|
||||
ij_typescript_space_after_type_colon = true
|
||||
ij_typescript_space_after_unary_not = false
|
||||
ij_typescript_space_before_async_arrow_lparen = true
|
||||
ij_typescript_space_before_catch_keyword = true
|
||||
ij_typescript_space_before_catch_left_brace = true
|
||||
ij_typescript_space_before_catch_parentheses = true
|
||||
ij_typescript_space_before_class_lbrace = true
|
||||
ij_typescript_space_before_class_left_brace = true
|
||||
ij_typescript_space_before_colon = true
|
||||
ij_typescript_space_before_comma = false
|
||||
ij_typescript_space_before_do_left_brace = true
|
||||
ij_typescript_space_before_else_keyword = true
|
||||
ij_typescript_space_before_else_left_brace = true
|
||||
ij_typescript_space_before_finally_keyword = true
|
||||
ij_typescript_space_before_finally_left_brace = true
|
||||
ij_typescript_space_before_for_left_brace = true
|
||||
ij_typescript_space_before_for_parentheses = true
|
||||
ij_typescript_space_before_for_semicolon = false
|
||||
ij_typescript_space_before_function_left_parenth = true
|
||||
ij_typescript_space_before_generator_mult = false
|
||||
ij_typescript_space_before_if_left_brace = true
|
||||
ij_typescript_space_before_if_parentheses = true
|
||||
ij_typescript_space_before_method_call_parentheses = false
|
||||
ij_typescript_space_before_method_left_brace = true
|
||||
ij_typescript_space_before_method_parentheses = false
|
||||
ij_typescript_space_before_property_colon = false
|
||||
ij_typescript_space_before_quest = true
|
||||
ij_typescript_space_before_switch_left_brace = true
|
||||
ij_typescript_space_before_switch_parentheses = true
|
||||
ij_typescript_space_before_try_left_brace = true
|
||||
ij_typescript_space_before_type_colon = false
|
||||
ij_typescript_space_before_unary_not = false
|
||||
ij_typescript_space_before_while_keyword = true
|
||||
ij_typescript_space_before_while_left_brace = true
|
||||
ij_typescript_space_before_while_parentheses = true
|
||||
ij_typescript_spaces_around_additive_operators = true
|
||||
ij_typescript_spaces_around_arrow_function_operator = true
|
||||
ij_typescript_spaces_around_assignment_operators = true
|
||||
ij_typescript_spaces_around_bitwise_operators = true
|
||||
ij_typescript_spaces_around_equality_operators = true
|
||||
ij_typescript_spaces_around_logical_operators = true
|
||||
ij_typescript_spaces_around_multiplicative_operators = true
|
||||
ij_typescript_spaces_around_relational_operators = true
|
||||
ij_typescript_spaces_around_shift_operators = true
|
||||
ij_typescript_spaces_around_unary_operator = false
|
||||
ij_typescript_spaces_within_array_initializer_brackets = true
|
||||
ij_typescript_spaces_within_brackets = true
|
||||
ij_typescript_spaces_within_catch_parentheses = false
|
||||
ij_typescript_spaces_within_for_parentheses = false
|
||||
ij_typescript_spaces_within_if_parentheses = false
|
||||
ij_typescript_spaces_within_imports = true
|
||||
ij_typescript_spaces_within_interpolation_expressions = true
|
||||
ij_typescript_spaces_within_method_call_parentheses = false
|
||||
ij_typescript_spaces_within_method_parentheses = false
|
||||
ij_typescript_spaces_within_object_literal_braces = true
|
||||
ij_typescript_spaces_within_object_type_braces = true
|
||||
ij_typescript_spaces_within_parentheses = false
|
||||
ij_typescript_spaces_within_switch_parentheses = false
|
||||
ij_typescript_spaces_within_type_assertion = false
|
||||
ij_typescript_spaces_within_union_types = true
|
||||
ij_typescript_spaces_within_while_parentheses = false
|
||||
ij_typescript_special_else_if_treatment = true
|
||||
ij_typescript_ternary_operation_signs_on_next_line = false
|
||||
ij_typescript_ternary_operation_wrap = off
|
||||
ij_typescript_union_types_wrap = on_every_item
|
||||
ij_typescript_use_chained_calls_group_indents = false
|
||||
ij_typescript_use_double_quotes = true
|
||||
ij_typescript_use_explicit_js_extension = auto
|
||||
ij_typescript_use_import_type = auto
|
||||
ij_typescript_use_path_mapping = always
|
||||
ij_typescript_use_public_modifier = false
|
||||
ij_typescript_use_semicolon_after_statement = true
|
||||
ij_typescript_var_declaration_wrap = off
|
||||
ij_typescript_while_brace_force = never
|
||||
ij_typescript_while_on_new_line = false
|
||||
ij_typescript_wrap_comments = false
|
||||
|
||||
[{*.bash,*.sh,*.zsh}]
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
ij_shell_binary_ops_start_line = false
|
||||
ij_shell_keep_column_alignment_padding = false
|
||||
ij_shell_minify_program = false
|
||||
ij_shell_redirect_followed_by_space = false
|
||||
ij_shell_switch_cases_indented = false
|
||||
ij_shell_use_unix_line_separator = true
|
||||
|
||||
[{*.cjs,*.js}]
|
||||
ij_continuation_indent_size = 4
|
||||
ij_javascript_align_imports = false
|
||||
ij_javascript_align_multiline_array_initializer_expression = false
|
||||
ij_javascript_align_multiline_binary_operation = false
|
||||
ij_javascript_align_multiline_chained_methods = false
|
||||
ij_javascript_align_multiline_extends_list = false
|
||||
ij_javascript_align_multiline_for = true
|
||||
ij_javascript_align_multiline_parameters = true
|
||||
ij_javascript_align_multiline_parameters_in_calls = false
|
||||
ij_javascript_align_multiline_ternary_operation = false
|
||||
ij_javascript_align_object_properties = 0
|
||||
ij_javascript_align_union_types = false
|
||||
ij_javascript_align_var_statements = 0
|
||||
ij_javascript_array_initializer_new_line_after_left_brace = false
|
||||
ij_javascript_array_initializer_right_brace_on_new_line = false
|
||||
ij_javascript_array_initializer_wrap = off
|
||||
ij_javascript_assignment_wrap = off
|
||||
ij_javascript_binary_operation_sign_on_next_line = false
|
||||
ij_javascript_binary_operation_wrap = off
|
||||
ij_javascript_blacklist_imports = rxjs/Rx, node_modules/**, **/node_modules/**, @angular/material, @angular/material/typings/**
|
||||
ij_javascript_blank_lines_after_imports = 1
|
||||
ij_javascript_blank_lines_around_class = 1
|
||||
ij_javascript_blank_lines_around_field = 0
|
||||
ij_javascript_blank_lines_around_function = 1
|
||||
ij_javascript_blank_lines_around_method = 1
|
||||
ij_javascript_block_brace_style = next_line
|
||||
ij_javascript_block_comment_add_space = false
|
||||
ij_javascript_block_comment_at_first_column = true
|
||||
ij_javascript_call_parameters_new_line_after_left_paren = false
|
||||
ij_javascript_call_parameters_right_paren_on_new_line = false
|
||||
ij_javascript_call_parameters_wrap = off
|
||||
ij_javascript_catch_on_new_line = false
|
||||
ij_javascript_chained_call_dot_on_new_line = true
|
||||
ij_javascript_class_brace_style = next_line
|
||||
ij_javascript_comma_on_new_line = false
|
||||
ij_javascript_do_while_brace_force = never
|
||||
ij_javascript_else_on_new_line = true
|
||||
ij_javascript_enforce_trailing_comma = whenmultiline
|
||||
ij_javascript_extends_keyword_wrap = off
|
||||
ij_javascript_extends_list_wrap = off
|
||||
ij_javascript_field_prefix = _
|
||||
ij_javascript_file_name_style = relaxed
|
||||
ij_javascript_finally_on_new_line = false
|
||||
ij_javascript_for_brace_force = always
|
||||
ij_javascript_for_statement_new_line_after_left_paren = false
|
||||
ij_javascript_for_statement_right_paren_on_new_line = false
|
||||
ij_javascript_for_statement_wrap = off
|
||||
ij_javascript_force_quote_style = true
|
||||
ij_javascript_force_semicolon_style = true
|
||||
ij_javascript_function_expression_brace_style = next_line
|
||||
ij_javascript_if_brace_force = always
|
||||
ij_javascript_import_merge_members = global
|
||||
ij_javascript_import_prefer_absolute_path = global
|
||||
ij_javascript_import_sort_members = true
|
||||
ij_javascript_import_sort_module_name = false
|
||||
ij_javascript_import_use_node_resolution = true
|
||||
ij_javascript_imports_wrap = off
|
||||
ij_javascript_indent_case_from_switch = true
|
||||
ij_javascript_indent_chained_calls = true
|
||||
ij_javascript_indent_package_children = 0
|
||||
ij_javascript_jsx_attribute_value = braces
|
||||
ij_javascript_keep_blank_lines_in_code = 2
|
||||
ij_javascript_keep_first_column_comment = true
|
||||
ij_javascript_keep_indents_on_empty_lines = false
|
||||
ij_javascript_keep_line_breaks = true
|
||||
ij_javascript_keep_simple_blocks_in_one_line = false
|
||||
ij_javascript_keep_simple_methods_in_one_line = true
|
||||
ij_javascript_line_comment_add_space = true
|
||||
ij_javascript_line_comment_at_first_column = false
|
||||
ij_javascript_method_brace_style = next_line
|
||||
ij_javascript_method_call_chain_wrap = off
|
||||
ij_javascript_method_parameters_new_line_after_left_paren = false
|
||||
ij_javascript_method_parameters_right_paren_on_new_line = false
|
||||
ij_javascript_method_parameters_wrap = off
|
||||
ij_javascript_object_literal_wrap = off
|
||||
ij_javascript_object_types_wrap = on_every_item
|
||||
ij_javascript_parentheses_expression_new_line_after_left_paren = false
|
||||
ij_javascript_parentheses_expression_right_paren_on_new_line = false
|
||||
ij_javascript_place_assignment_sign_on_next_line = false
|
||||
ij_javascript_prefer_as_type_cast = false
|
||||
ij_javascript_prefer_explicit_types_function_expression_returns = false
|
||||
ij_javascript_prefer_explicit_types_function_returns = false
|
||||
ij_javascript_prefer_explicit_types_vars_fields = false
|
||||
ij_javascript_prefer_parameters_wrap = false
|
||||
ij_javascript_property_prefix =
|
||||
ij_javascript_reformat_c_style_comments = false
|
||||
ij_javascript_space_after_colon = true
|
||||
ij_javascript_space_after_comma = true
|
||||
ij_javascript_space_after_dots_in_rest_parameter = false
|
||||
ij_javascript_space_after_generator_mult = true
|
||||
ij_javascript_space_after_property_colon = true
|
||||
ij_javascript_space_after_quest = true
|
||||
ij_javascript_space_after_type_colon = true
|
||||
ij_javascript_space_after_unary_not = false
|
||||
ij_javascript_space_before_async_arrow_lparen = true
|
||||
ij_javascript_space_before_catch_keyword = true
|
||||
ij_javascript_space_before_catch_left_brace = true
|
||||
ij_javascript_space_before_catch_parentheses = true
|
||||
ij_javascript_space_before_class_lbrace = true
|
||||
ij_javascript_space_before_class_left_brace = true
|
||||
ij_javascript_space_before_colon = true
|
||||
ij_javascript_space_before_comma = false
|
||||
ij_javascript_space_before_do_left_brace = true
|
||||
ij_javascript_space_before_else_keyword = true
|
||||
ij_javascript_space_before_else_left_brace = true
|
||||
ij_javascript_space_before_finally_keyword = true
|
||||
ij_javascript_space_before_finally_left_brace = true
|
||||
ij_javascript_space_before_for_left_brace = true
|
||||
ij_javascript_space_before_for_parentheses = true
|
||||
ij_javascript_space_before_for_semicolon = false
|
||||
ij_javascript_space_before_function_left_parenth = true
|
||||
ij_javascript_space_before_generator_mult = false
|
||||
ij_javascript_space_before_if_left_brace = true
|
||||
ij_javascript_space_before_if_parentheses = true
|
||||
ij_javascript_space_before_method_call_parentheses = false
|
||||
ij_javascript_space_before_method_left_brace = true
|
||||
ij_javascript_space_before_method_parentheses = false
|
||||
ij_javascript_space_before_property_colon = false
|
||||
ij_javascript_space_before_quest = true
|
||||
ij_javascript_space_before_switch_left_brace = true
|
||||
ij_javascript_space_before_switch_parentheses = true
|
||||
ij_javascript_space_before_try_left_brace = true
|
||||
ij_javascript_space_before_type_colon = false
|
||||
ij_javascript_space_before_unary_not = false
|
||||
ij_javascript_space_before_while_keyword = true
|
||||
ij_javascript_space_before_while_left_brace = true
|
||||
ij_javascript_space_before_while_parentheses = true
|
||||
ij_javascript_spaces_around_additive_operators = true
|
||||
ij_javascript_spaces_around_arrow_function_operator = true
|
||||
ij_javascript_spaces_around_assignment_operators = true
|
||||
ij_javascript_spaces_around_bitwise_operators = true
|
||||
ij_javascript_spaces_around_equality_operators = true
|
||||
ij_javascript_spaces_around_logical_operators = true
|
||||
ij_javascript_spaces_around_multiplicative_operators = true
|
||||
ij_javascript_spaces_around_relational_operators = true
|
||||
ij_javascript_spaces_around_shift_operators = true
|
||||
ij_javascript_spaces_around_unary_operator = false
|
||||
ij_javascript_spaces_within_array_initializer_brackets = true
|
||||
ij_javascript_spaces_within_brackets = true
|
||||
ij_javascript_spaces_within_catch_parentheses = false
|
||||
ij_javascript_spaces_within_for_parentheses = false
|
||||
ij_javascript_spaces_within_if_parentheses = false
|
||||
ij_javascript_spaces_within_imports = true
|
||||
ij_javascript_spaces_within_interpolation_expressions = true
|
||||
ij_javascript_spaces_within_method_call_parentheses = false
|
||||
ij_javascript_spaces_within_method_parentheses = false
|
||||
ij_javascript_spaces_within_object_literal_braces = true
|
||||
ij_javascript_spaces_within_object_type_braces = true
|
||||
ij_javascript_spaces_within_parentheses = false
|
||||
ij_javascript_spaces_within_switch_parentheses = false
|
||||
ij_javascript_spaces_within_type_assertion = false
|
||||
ij_javascript_spaces_within_union_types = true
|
||||
ij_javascript_spaces_within_while_parentheses = false
|
||||
ij_javascript_special_else_if_treatment = true
|
||||
ij_javascript_ternary_operation_signs_on_next_line = false
|
||||
ij_javascript_ternary_operation_wrap = off
|
||||
ij_javascript_union_types_wrap = on_every_item
|
||||
ij_javascript_use_chained_calls_group_indents = false
|
||||
ij_javascript_use_double_quotes = true
|
||||
ij_javascript_use_explicit_js_extension = auto
|
||||
ij_javascript_use_import_type = auto
|
||||
ij_javascript_use_path_mapping = always
|
||||
ij_javascript_use_public_modifier = false
|
||||
ij_javascript_use_semicolon_after_statement = true
|
||||
ij_javascript_var_declaration_wrap = off
|
||||
ij_javascript_while_brace_force = never
|
||||
ij_javascript_while_on_new_line = false
|
||||
ij_javascript_wrap_comments = false
|
||||
|
||||
|
||||
[{*.har,*.jsb2,*.jsb3,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}]
|
||||
indent_size = 2
|
||||
ij_json_array_wrapping = split_into_lines
|
||||
ij_json_keep_blank_lines_in_code = 0
|
||||
ij_json_keep_indents_on_empty_lines = false
|
||||
ij_json_keep_line_breaks = true
|
||||
ij_json_keep_trailing_comma = false
|
||||
ij_json_object_wrapping = split_into_lines
|
||||
ij_json_property_alignment = do_not_align
|
||||
ij_json_space_after_colon = true
|
||||
ij_json_space_after_comma = true
|
||||
ij_json_space_before_colon = false
|
||||
ij_json_space_before_comma = false
|
||||
ij_json_spaces_within_braces = false
|
||||
ij_json_spaces_within_brackets = false
|
||||
ij_json_wrap_long_lines = false
|
||||
|
||||
[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}]
|
||||
ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3
|
||||
ij_html_align_attributes = true
|
||||
ij_html_align_text = false
|
||||
ij_html_attribute_wrap = normal
|
||||
ij_html_block_comment_add_space = false
|
||||
ij_html_block_comment_at_first_column = true
|
||||
ij_html_do_not_align_children_of_min_lines = 0
|
||||
ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p
|
||||
ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot
|
||||
ij_html_enforce_quotes = false
|
||||
ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var
|
||||
ij_html_keep_blank_lines = 2
|
||||
ij_html_keep_indents_on_empty_lines = false
|
||||
ij_html_keep_line_breaks = true
|
||||
ij_html_keep_line_breaks_in_text = true
|
||||
ij_html_keep_whitespaces = false
|
||||
ij_html_keep_whitespaces_inside = span, pre, textarea
|
||||
ij_html_line_comment_at_first_column = true
|
||||
ij_html_new_line_after_last_attribute = never
|
||||
ij_html_new_line_before_first_attribute = never
|
||||
ij_html_quote_style = double
|
||||
ij_html_remove_new_line_before_tags = br
|
||||
ij_html_space_after_tag_name = false
|
||||
ij_html_space_around_equality_in_attribute = false
|
||||
ij_html_space_inside_empty_tag = false
|
||||
ij_html_text_wrap = normal
|
||||
|
||||
[{*.http,*.rest}]
|
||||
indent_size = 0
|
||||
ij_continuation_indent_size = 4
|
||||
ij_http-request_call_parameters_wrap = normal
|
||||
ij_http-request_method_parameters_wrap = split_into_lines
|
||||
ij_http-request_space_before_comma = true
|
||||
ij_http-request_spaces_around_assignment_operators = true
|
||||
|
||||
[{*.markdown,*.md}]
|
||||
ij_markdown_force_one_space_after_blockquote_symbol = true
|
||||
ij_markdown_force_one_space_after_header_symbol = true
|
||||
ij_markdown_force_one_space_after_list_bullet = true
|
||||
ij_markdown_force_one_space_between_words = true
|
||||
ij_markdown_format_tables = true
|
||||
ij_markdown_insert_quote_arrows_on_wrap = true
|
||||
ij_markdown_keep_indents_on_empty_lines = false
|
||||
ij_markdown_keep_line_breaks_inside_text_blocks = true
|
||||
ij_markdown_max_lines_around_block_elements = 1
|
||||
ij_markdown_max_lines_around_header = 1
|
||||
ij_markdown_max_lines_between_paragraphs = 1
|
||||
ij_markdown_min_lines_around_block_elements = 1
|
||||
ij_markdown_min_lines_around_header = 1
|
||||
ij_markdown_min_lines_between_paragraphs = 1
|
||||
ij_markdown_wrap_text_if_long = true
|
||||
ij_markdown_wrap_text_inside_blockquotes = true
|
||||
|
||||
[{*.yaml,*.yml}]
|
||||
indent_size = 2
|
||||
ij_yaml_align_values_properties = do_not_align
|
||||
ij_yaml_autoinsert_sequence_marker = true
|
||||
ij_yaml_block_mapping_on_new_line = false
|
||||
ij_yaml_indent_sequence_value = true
|
||||
ij_yaml_keep_indents_on_empty_lines = false
|
||||
ij_yaml_keep_line_breaks = true
|
||||
ij_yaml_sequence_on_new_line = false
|
||||
ij_yaml_space_before_colon = false
|
||||
ij_yaml_spaces_within_braces = true
|
||||
ij_yaml_spaces_within_brackets = true
|
10
.fleet/run.json
Normal file
10
.fleet/run.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "npm",
|
||||
"name": "start",
|
||||
"command": "run",
|
||||
"scripts": "start",
|
||||
},
|
||||
]
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 29 KiB |
Binary file not shown.
Before Width: | Height: | Size: 40 KiB |
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="TypeScriptCompiler">
|
||||
<option name="versionType" value="EMBEDDED" />
|
||||
</component>
|
||||
</project>
|
7
.idea/copyright/profiles_settings.xml
generated
Normal file
7
.idea/copyright/profiles_settings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="gnu agpl alekswilc">
|
||||
<module2copyright>
|
||||
<element module="Project Files" copyright="gnu agpl alekswilc" />
|
||||
</module2copyright>
|
||||
</settings>
|
||||
</component>
|
7
.idea/discord.xml
generated
Normal file
7
.idea/discord.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
10
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
10
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<Languages>
|
||||
<language minSize="457" name="TypeScript" />
|
||||
</Languages>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
6
.idea/jsLibraryMappings.xml
generated
Normal file
6
.idea/jsLibraryMappings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<file url="file://$PROJECT_DIR$/packages/frontend" libraries="{script}" />
|
||||
</component>
|
||||
</project>
|
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
9
.idea/modules.xml
generated
Normal file
9
.idea/modules.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/packages/backend/backend.iml" filepath="$PROJECT_DIR$/packages/backend/backend.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/packages/frontend/frontend.iml" filepath="$PROJECT_DIR$/packages/frontend/frontend.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
9
.idea/simrail.alekswilc.dev.iml
generated
Normal file
9
.idea/simrail.alekswilc.dev.iml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"npm.packageManager": "yarn"
|
||||
}
|
661
LICENSE
661
LICENSE
@ -1,661 +0,0 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
1353
LICENSE.txt
Normal file
1353
LICENSE.txt
Normal file
File diff suppressed because it is too large
Load Diff
163
package-lock.json
generated
163
package-lock.json
generated
@ -1,27 +1,20 @@
|
||||
{
|
||||
"name": "simrail-logs",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "simrail-logs",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@simrail/types": "^0.0.4",
|
||||
"@types/mongoose": "^5.11.97",
|
||||
"dayjs": "^1.11.12",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
"mongoose": "^8.5.1",
|
||||
"redis": "^4.6.15",
|
||||
"uuid": "^10.0.0",
|
||||
"wildcard-match": "^5.1.3"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/backend",
|
||||
"packages/frontend"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"copyfiles": "^2.4.1",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
@ -262,6 +255,10 @@
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz",
|
||||
"integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg=="
|
||||
},
|
||||
"node_modules/backend": {
|
||||
"resolved": "packages/backend",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
@ -388,6 +385,87 @@
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
|
||||
},
|
||||
"node_modules/concurrently": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.0.1.tgz",
|
||||
"integrity": "sha512-wYKvCd/f54sTXJMSfV6Ln/B8UrfLBKOYa+lzc6CHay3Qek+LorVSBdMVfyewFhRbH0Rbabsk4D+3PL/VjQ5gzg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"lodash": "^4.17.21",
|
||||
"rxjs": "^7.8.1",
|
||||
"shell-quote": "^1.8.1",
|
||||
"supports-color": "^8.1.1",
|
||||
"tree-kill": "^1.2.2",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"bin": {
|
||||
"conc": "dist/bin/concurrently.js",
|
||||
"concurrently": "dist/bin/concurrently.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/open-cli-tools/concurrently?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/concurrently/node_modules/cliui": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
|
||||
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"string-width": "^4.2.0",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"wrap-ansi": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/concurrently/node_modules/supports-color": {
|
||||
"version": "8.1.1",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
|
||||
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/supports-color?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/concurrently/node_modules/yargs": {
|
||||
"version": "17.7.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
|
||||
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"cliui": "^8.0.1",
|
||||
"escalade": "^3.1.1",
|
||||
"get-caller-file": "^2.0.5",
|
||||
"require-directory": "^2.1.1",
|
||||
"string-width": "^4.2.3",
|
||||
"y18n": "^5.0.5",
|
||||
"yargs-parser": "^21.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/concurrently/node_modules/yargs-parser": {
|
||||
"version": "21.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
||||
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
@ -889,6 +967,12 @@
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
@ -1263,6 +1347,15 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rxjs": {
|
||||
"version": "7.8.1",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz",
|
||||
"integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
@ -1350,6 +1443,15 @@
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
|
||||
},
|
||||
"node_modules/shell-quote": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz",
|
||||
"integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==",
|
||||
"dev": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
|
||||
@ -1496,6 +1598,21 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/tree-kill": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
|
||||
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tree-kill": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
|
||||
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/type-is": {
|
||||
"version": "1.6.18",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
||||
@ -1675,6 +1792,28 @@
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"packages/backend": {
|
||||
"version": "3.0.0",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@simrail/types": "^0.0.4",
|
||||
"@types/mongoose": "^5.11.97",
|
||||
"dayjs": "^1.11.12",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
"mongoose": "^8.5.1",
|
||||
"redis": "^4.6.15",
|
||||
"uuid": "^10.0.0",
|
||||
"wildcard-match": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"copyfiles": "^2.4.1",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
25
package.json
25
package.json
@ -1,31 +1,24 @@
|
||||
{
|
||||
"name": "simrail-logs",
|
||||
"private": true,
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"postbuild": "copyfiles --error --up 1 src/http/views/**/* src/http/views/* dist",
|
||||
"dev": "npm run build && doppler run node dist"
|
||||
"build": "yarn workspace backend build && yarn workspace frontend build",
|
||||
"start": "concurrently --kill-others-on-fail \"yarn workspace backend start\" \"yarn workspace frontend dev\""
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/backend",
|
||||
"packages/frontend"
|
||||
],
|
||||
"author": "Aleksander <alekswilc> Wilczyński",
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"copyfiles": "^2.4.1",
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@simrail/types": "^0.0.4",
|
||||
"@types/mongoose": "^5.11.97",
|
||||
"dayjs": "^1.11.12",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
"mongoose": "^8.5.1",
|
||||
"redis": "^4.6.15",
|
||||
"uuid": "^10.0.0",
|
||||
"wildcard-match": "^5.1.3"
|
||||
},
|
||||
"typings": "types/typings.d.ts"
|
||||
"type": "module"
|
||||
}
|
||||
|
3
packages/backend/.gitignore
vendored
Normal file
3
packages/backend/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
# Keep environment variables out of version control
|
||||
.env
|
20
packages/backend/Dockerfile
Normal file
20
packages/backend/Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
FROM node:21-alpine AS build
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN yarn add -D typescript
|
||||
RUN yarn rawbuild
|
||||
|
||||
RUN ls
|
||||
|
||||
|
||||
# Install Doppler CLI
|
||||
RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/cli@doppler-8004D9FF50437357.rsa.pub && \
|
||||
echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories && \
|
||||
apk add doppler
|
||||
|
||||
|
||||
|
||||
ENTRYPOINT ["doppler", "run", "--"]
|
||||
CMD ["node", "/app/dist"]
|
9
packages/backend/backend.iml
Normal file
9
packages/backend/backend.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
1680
packages/backend/package-lock.json
generated
Normal file
1680
packages/backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
36
packages/backend/package.json
Normal file
36
packages/backend/package.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"private": true,
|
||||
"main": "../../dist/backend/index.js",
|
||||
"version": "3.0.0",
|
||||
"scripts": {
|
||||
"build": "docker build --progress=plain -t simrailpro:backend .",
|
||||
"rawbuild": "yarn tsc",
|
||||
"start": "yarn build && doppler run node ../../dist/backend/index.js"
|
||||
},
|
||||
"author": "Aleksander <alekswilc> Wilczyński",
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"copyfiles": "^2.4.1",
|
||||
"tsc": "^2.0.4",
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@simrail/types": "^0.0.4",
|
||||
"@types/mongoose": "^5.11.97",
|
||||
"cors": "^2.8.5",
|
||||
"dayjs": "^1.11.12",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
"mongoose": "^8.5.1",
|
||||
"redis": "^4.6.15",
|
||||
"uuid": "^10.0.0",
|
||||
"wildcard-match": "^5.1.3"
|
||||
},
|
||||
"typings": "types/typings.d.ts"
|
||||
}
|
26
packages/backend/scripts/clear-redis.js
Normal file
26
packages/backend/scripts/clear-redis.js
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { createClient } from 'redis';
|
||||
|
||||
createClient({url: process.env.REDIS_URI}).connect().then(async (x) => {
|
||||
await x.json.del('stations_occupied');
|
||||
await x.json.del('stations');
|
||||
await x.json.del('trains');
|
||||
await x.json.del('trains_occupied');
|
||||
console.log('done')
|
||||
process.exit(1);
|
||||
})
|
95
packages/backend/src/http/responseBuilder.ts
Normal file
95
packages/backend/src/http/responseBuilder.ts
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { assert } from "node:console";
|
||||
|
||||
export interface IResponse<T>
|
||||
{
|
||||
success: boolean;
|
||||
data: T;
|
||||
code: number;
|
||||
}
|
||||
|
||||
export class BaseResponseBuilder<T>
|
||||
{
|
||||
protected success: IResponse<T>["success"] = undefined!;
|
||||
protected data: IResponse<T>["data"] = undefined!;
|
||||
protected code: IResponse<T>["code"] = undefined!;
|
||||
|
||||
|
||||
public constructor(data?: Partial<IResponse<T>>)
|
||||
{
|
||||
if (!data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ("success" in data)
|
||||
{
|
||||
this.success = data.success as IResponse<T>["success"];
|
||||
}
|
||||
if ("data" in data)
|
||||
{
|
||||
this.data = data.data as IResponse<T>["data"];
|
||||
}
|
||||
if ("code" in data)
|
||||
{
|
||||
this.code = data.code as IResponse<T>["code"];
|
||||
}
|
||||
}
|
||||
|
||||
public setData(data: T)
|
||||
{
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public setCode(code: number)
|
||||
{
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public toJSON()
|
||||
{
|
||||
const { success, data, code } = this;
|
||||
assert(typeof (success) === "boolean", "expected success to be boolean");
|
||||
assert(typeof (code) === "number", "expected success to be number");
|
||||
|
||||
return {
|
||||
success, data, code,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class SuccessResponseBuilder<T> extends BaseResponseBuilder<T>
|
||||
{
|
||||
public constructor(options?: IResponse<T>)
|
||||
{
|
||||
super(options);
|
||||
this.success = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class ErrorResponseBuilder<T> extends BaseResponseBuilder<T>
|
||||
{
|
||||
public constructor(options?: IResponse<T>)
|
||||
{
|
||||
super(options);
|
||||
this.success = false;
|
||||
}
|
||||
}
|
169
packages/backend/src/http/routes/activePlayer.ts
Normal file
169
packages/backend/src/http/routes/activePlayer.ts
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { TMProfile } from "../../mongo/profile.js";
|
||||
import { SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { escapeRegexString, arrayGroupBy } from "../../util/functions.js";
|
||||
import { PlayerUtil } from "../../util/PlayerUtil.js";
|
||||
|
||||
interface ActiveTrain
|
||||
{
|
||||
server: string;
|
||||
player: TMProfile;
|
||||
trainNumber: string;
|
||||
trainName: string;
|
||||
username: string;
|
||||
steam: string;
|
||||
}
|
||||
|
||||
interface ActiveStation
|
||||
{
|
||||
server: string;
|
||||
player: TMProfile;
|
||||
stationName: string;
|
||||
stationShort: string;
|
||||
username: string;
|
||||
steam: string;
|
||||
}
|
||||
|
||||
import { Server } from "@simrail/types";
|
||||
import { generateUrl } from "../../util/imgproxy.js";
|
||||
|
||||
const sortFunction = (a: ActiveStation | ActiveTrain, b: ActiveStation | ActiveTrain) =>
|
||||
{
|
||||
if (a.server.includes("pl") && !b.server.includes("pl"))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!a.server.includes("pl") && b.server.includes("pl"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
export class ActivePlayersRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/train", async (req, res) =>
|
||||
{
|
||||
const s = req.query.query?.toString().split(",").map(x => new RegExp(escapeRegexString(x), "i"));
|
||||
const sserver = req.query.server?.toString();
|
||||
|
||||
let a: ActiveTrain[] = [];
|
||||
|
||||
for (const data of sserver ? [ client.trains[ sserver as Server["ServerCode"] ] ] : Object.values(client.trains))
|
||||
{
|
||||
for (const d of data.filter(d => d.TrainData.ControlledBySteamID))
|
||||
{
|
||||
const p = await PlayerUtil.getPlayer(d.TrainData.ControlledBySteamID!);
|
||||
|
||||
if (p && process.env.IMGPROXY_KEY)
|
||||
{
|
||||
p.avatar = generateUrl(p.avatar);
|
||||
}
|
||||
|
||||
p && a.push({
|
||||
server: d.ServerCode,
|
||||
player: p,
|
||||
trainNumber: d.TrainNoLocal,
|
||||
trainName: d.TrainName,
|
||||
|
||||
username: p?.username,
|
||||
steam: p?.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (s)
|
||||
{
|
||||
a = a.filter(d => s.filter(c => c.test(d.server) || c.test(d.username) || c.test(d.steam) || c.test(d.steam) || c.test(d.trainName) || c.test(d.trainNumber)).length === s.length);
|
||||
}
|
||||
|
||||
a = arrayGroupBy(a, d => d.server)
|
||||
.sort(sortFunction);
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
records: a,
|
||||
servers: Object.keys(client.stations),
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
app.get("/station", async (req, res) =>
|
||||
{
|
||||
const s = req.query.query?.toString().split(",").map(x => new RegExp(escapeRegexString(x), "i"));
|
||||
const sserver = req.query.server?.toString();
|
||||
|
||||
let a: ActiveStation[] = [];
|
||||
|
||||
for (const server of sserver ? [ sserver ] : Object.keys(client.stations))
|
||||
{
|
||||
for (const d of client.stations[ server ].filter(d => d.DispatchedBy.length && d.DispatchedBy[ 0 ]?.SteamId))
|
||||
{
|
||||
// todo: optimize
|
||||
const p = await PlayerUtil.getPlayer(d.DispatchedBy[ 0 ].SteamId!);
|
||||
|
||||
if (p && process.env.IMGPROXY_KEY)
|
||||
{
|
||||
p.avatar = generateUrl(p.avatar);
|
||||
}
|
||||
|
||||
p && a.push({
|
||||
server: server,
|
||||
player: p,
|
||||
stationName: d.Name,
|
||||
stationShort: d.Prefix,
|
||||
|
||||
username: p?.username,
|
||||
steam: p?.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (s)
|
||||
{
|
||||
a = a.filter(d => s.filter(c => c.test(d.server) || c.test(d.username) || c.test(d.steam) || c.test(d.steam) || c.test(d.stationName) || c.test(d.stationShort)).length === s.length);
|
||||
}
|
||||
|
||||
|
||||
a = arrayGroupBy(a, d => d.server)
|
||||
.sort(sortFunction);
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
records: a,
|
||||
servers: Object.keys(client.stations),
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
306
packages/backend/src/http/routes/admin.ts
Normal file
306
packages/backend/src/http/routes/admin.ts
Normal file
@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { ErrorResponseBuilder, SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { MAdmin } from "../../mongo/admin.js";
|
||||
import { MProfile } from "../../mongo/profile.js";
|
||||
import { PlayerUtil } from "../../util/PlayerUtil.js";
|
||||
import { getVehicle } from "../../util/contants.js";
|
||||
import { isTruthyAndGreaterThanZero } from "../../util/functions.js";
|
||||
|
||||
export class AdminRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/auth", async (req, res) =>
|
||||
{
|
||||
const token = req.query.token;
|
||||
|
||||
if (!token)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400)
|
||||
.setData("Missing token query").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await MAdmin.findOne({ token });
|
||||
|
||||
if (!data)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid token").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
isAdmin: true,
|
||||
username: data.username,
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
app.post("/profile/:playerId/hideLeaderboard", async (req, res) =>
|
||||
{
|
||||
const token = req.headers[ "x-auth-token" ];
|
||||
|
||||
if (!token)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400)
|
||||
.setData("Missing token query").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const admin = await MAdmin.findOne({ token });
|
||||
|
||||
if (!admin)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid token").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const player = await MProfile.findOne({
|
||||
id: req.params.playerId,
|
||||
});
|
||||
|
||||
if (!player)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid playerId").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
player.flags.push("leaderboard_hidden");
|
||||
|
||||
await MProfile.updateOne({ id: player.id }, {
|
||||
flags: player.flags,
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
app.post("/profile/:playerId/showLeaderboard", async (req, res) =>
|
||||
{
|
||||
const token = req.headers[ "x-auth-token" ];
|
||||
|
||||
if (!token)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400)
|
||||
.setData("Missing token query").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const admin = await MAdmin.findOne({ token });
|
||||
|
||||
if (!admin)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid token").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const player = await MProfile.findOne({
|
||||
id: req.params.playerId,
|
||||
});
|
||||
|
||||
if (!player)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid playerId").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
player.flags = player.flags.filter(x => x !== "leaderboard_hidden");
|
||||
|
||||
await MProfile.updateOne({ id: player.id }, {
|
||||
flags: player.flags,
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
app.post("/profile/:playerId/hide", async (req, res) =>
|
||||
{
|
||||
const token = req.headers[ "x-auth-token" ];
|
||||
|
||||
if (!token)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400)
|
||||
.setData("Missing token").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const admin = await MAdmin.findOne({ token });
|
||||
|
||||
if (!admin)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid token").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const player = await MProfile.findOne({
|
||||
id: req.params.playerId,
|
||||
});
|
||||
|
||||
if (!player)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid playerId").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
player.flags.push("hidden");
|
||||
|
||||
await MProfile.updateOne({ id: player.id }, {
|
||||
flags: player.flags,
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
app.post("/profile/:playerId/forceUpdate", async (req, res) =>
|
||||
{
|
||||
const token = req.headers[ "x-auth-token" ];
|
||||
|
||||
if (!token)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400)
|
||||
.setData("Missing token").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const admin = await MAdmin.findOne({ token });
|
||||
|
||||
if (!admin)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid token").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const player = await MProfile.findOne({
|
||||
id: req.params.playerId,
|
||||
});
|
||||
|
||||
if (!player)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid playerId").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const stats = await PlayerUtil.getPlayerStats(player.id);
|
||||
|
||||
if (!stats)
|
||||
{
|
||||
res.status(401).json(new ErrorResponseBuilder()
|
||||
.setCode(401)
|
||||
.setData("Invalid playerId (2)").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
player.steamTrainDistance = stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0;
|
||||
player.steamDispatcherTime = stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0;
|
||||
player.steamTrainScore = stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0;
|
||||
|
||||
|
||||
if (player.steamTrainDistance > player.trainDistance)
|
||||
{
|
||||
player.trainDistance = player.steamTrainDistance;
|
||||
}
|
||||
if (player.steamTrainScore > player.trainPoints)
|
||||
{
|
||||
player.trainPoints = player.steamTrainScore;
|
||||
}
|
||||
|
||||
const sum = Object.keys(player.trainStats).filter(x => x !== "N/A").map(x => player.trainStats[ x ]).reduce((acc, obj) =>
|
||||
{
|
||||
acc.time += obj.time;
|
||||
acc.distance += obj.distance;
|
||||
acc.score += obj.score;
|
||||
return acc;
|
||||
}, { time: 0, distance: 0, score: 0 });
|
||||
|
||||
|
||||
player.trainStats[ "N/A" ] = {
|
||||
time: 0,
|
||||
distance: player.trainDistance - sum.distance,
|
||||
score: player.trainPoints - sum.score,
|
||||
};
|
||||
|
||||
|
||||
if (typeof player.createdAt !== "number")
|
||||
{
|
||||
player.createdAt = new Date(parseInt(player._id.toString().substring(0, 8), 16) * 1000).getTime();
|
||||
}
|
||||
|
||||
const playerData = await PlayerUtil.getPlayerSteamData(player.id);
|
||||
|
||||
player.username = playerData?.personaname ?? player.username;
|
||||
player.avatar = playerData?.avatarfull ?? player.avatar;
|
||||
|
||||
await MProfile.updateOne({ id: player.id }, player);
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
189
packages/backend/src/http/routes/leaderboard.ts
Normal file
189
packages/backend/src/http/routes/leaderboard.ts
Normal file
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { PipelineStage } from "mongoose";
|
||||
import { IProfile, MProfile } from "../../mongo/profile.js";
|
||||
import { ErrorResponseBuilder, SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { escapeRegexString, removeProperties } from "../../util/functions.js";
|
||||
import { generateUrl } from "../../util/imgproxy.js";
|
||||
|
||||
const generateSearch = (regex: RegExp) => [
|
||||
{
|
||||
id: { $regex: regex },
|
||||
},
|
||||
{
|
||||
username: { $regex: regex },
|
||||
},
|
||||
];
|
||||
|
||||
const sortyByMap: Record<string, any> = {
|
||||
time: { trainTime: -1 },
|
||||
points: { trainPoints: -1 },
|
||||
distance: { trainDistance: -1 },
|
||||
};
|
||||
|
||||
export class LeaderboardRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/train", async (req, res) =>
|
||||
{
|
||||
const s = req.query.query?.toString().split(",").map(x => new RegExp(escapeRegexString(x), "i"));
|
||||
|
||||
const limit = parseInt(req.query.limit as string) || 12;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
|
||||
if (page < 0 || limit < 0)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400).setData("Invalid page and/or limit"));
|
||||
return;
|
||||
}
|
||||
|
||||
const filter: PipelineStage[] = [
|
||||
{
|
||||
$match: {
|
||||
flags: { $nin: [ "hidden", "leaderboard_hidden" ] },
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
s && filter.push({
|
||||
$match: {
|
||||
$and: [
|
||||
...s.map(x => ({ $or: generateSearch(x) })),
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const sortBy = sortyByMap[ req.query.sort_by?.toString() ?? "distance" ] ?? sortyByMap.distance;
|
||||
|
||||
filter.push({
|
||||
$sort: sortBy,
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$facet: {
|
||||
data: [
|
||||
{ $match: {} },
|
||||
{ $skip: (page - 1) * limit },
|
||||
{ $limit: limit },
|
||||
],
|
||||
count: [
|
||||
{ $count: "count" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const records = await MProfile.aggregate(filter);
|
||||
|
||||
|
||||
process.env.IMGPROXY_KEY && records[ 0 ].data && records[ 0 ].data.forEach((p: IProfile) =>
|
||||
{
|
||||
if (p.avatar.includes("imgproxy.alekswilc.dev"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
p.avatar = generateUrl(p.avatar);
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
records: records[ 0 ].data.map((x: IProfile) => removeProperties<Omit<IProfile, "_id" | "__v">>(x, [ "_id", "__v" ])),
|
||||
pages: Math.floor((records[ 0 ]?.count?.[ 0 ]?.count ?? 0) / limit),
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
app.get("/station", async (req, res) =>
|
||||
{
|
||||
const s = req.query.query?.toString().split(",").map(x => new RegExp(escapeRegexString(x), "i"));
|
||||
|
||||
const limit = parseInt(req.query.limit as string) || 12;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
|
||||
if (page < 0 || limit < 0)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400).setData("Invalid page and/or limit"));
|
||||
return;
|
||||
}
|
||||
|
||||
const filter: PipelineStage[] = [
|
||||
{
|
||||
$match: {
|
||||
flags: { $nin: [ "hidden", "leaderboard_hidden" ] },
|
||||
},
|
||||
},
|
||||
];
|
||||
s && filter.push({
|
||||
$match: {
|
||||
$and: [
|
||||
...s.map(x => ({ $or: generateSearch(x) })),
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$sort: {
|
||||
dispatcherTime: -1,
|
||||
},
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$facet: {
|
||||
data: [
|
||||
{ $match: {} },
|
||||
{ $skip: (page - 1) * limit },
|
||||
{ $limit: limit },
|
||||
],
|
||||
count: [
|
||||
{ $count: "count" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const records = await MProfile.aggregate(filter);
|
||||
|
||||
process.env.IMGPROXY_KEY && records[ 0 ].data && records[ 0 ].data.forEach((p: IProfile) =>
|
||||
{
|
||||
if (p.avatar.includes("imgproxy.alekswilc.dev"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
p.avatar = generateUrl(p.avatar);
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
records: records[ 0 ].data.map((x: IProfile) => removeProperties<Omit<IProfile, "_id" | "__v">>(x, [ "_id", "__v" ])),
|
||||
pages: Math.floor((records[ 0 ]?.count?.[ 0 ]?.count ?? 0) / limit),
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
75
packages/backend/src/http/routes/log.ts
Normal file
75
packages/backend/src/http/routes/log.ts
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { MTrainLog } from "../../mongo/trainLog.js";
|
||||
import { ErrorResponseBuilder, SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { MStationLog } from "../../mongo/stationLog.js";
|
||||
import { IProfile } from "../../mongo/profile.js";
|
||||
import { generateUrl } from "../../util/imgproxy.js";
|
||||
|
||||
|
||||
export class LogRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/:id", async (req, res) =>
|
||||
{
|
||||
const { id } = req.params;
|
||||
if (!id)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400)
|
||||
.setData("Missing Id parameter").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
const log = await MStationLog.findOne({ id }).populate<{
|
||||
player: IProfile
|
||||
}>("player").orFail().catch(() => null) || await MTrainLog.findOne({
|
||||
id,
|
||||
}).populate<{ player: IProfile }>("player").orFail().catch(() => null);
|
||||
|
||||
if (!log)
|
||||
{
|
||||
res.status(404).json(new ErrorResponseBuilder()
|
||||
.setCode(404)
|
||||
.setData("Invalid Id parameter").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
if (log.player.flags.includes("hidden"))
|
||||
{
|
||||
res.status(403).json(new ErrorResponseBuilder()
|
||||
.setCode(403)
|
||||
.setData("Log blocked!").toJSON());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (process.env.IMGPROXY_KEY)
|
||||
{
|
||||
log.player.avatar = generateUrl(log.player.avatar, "rs:auto:256:256:1/f:png");
|
||||
}
|
||||
|
||||
res.status(200).json(new SuccessResponseBuilder().setCode(200).setData(log.toJSON()).toJSON());
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
200
packages/backend/src/http/routes/profile.ts
Normal file
200
packages/backend/src/http/routes/profile.ts
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { PipelineStage } from "mongoose";
|
||||
import { ErrorResponseBuilder, SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { PlayerUtil } from "../../util/PlayerUtil.js";
|
||||
import { IProfile, MProfile } from "../../mongo/profile.js";
|
||||
import { escapeRegexString } from "../../util/functions.js";
|
||||
import { generateUrl } from "../../util/imgproxy.js";
|
||||
|
||||
const generateSearch = (regex: RegExp) => [
|
||||
{
|
||||
id: { $regex: regex },
|
||||
},
|
||||
{
|
||||
username: { $regex: regex },
|
||||
},
|
||||
];
|
||||
|
||||
type ActiveTrain = {
|
||||
type: "train"
|
||||
trainNumber: string
|
||||
trainName: string
|
||||
server: string
|
||||
}
|
||||
|
||||
type ActiveStation = {
|
||||
type: "station",
|
||||
stationName: string
|
||||
stationShort: string
|
||||
server: string
|
||||
}
|
||||
|
||||
export class ProfilesRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/:id", async (req, res) =>
|
||||
{
|
||||
if (!req.params.id)
|
||||
{
|
||||
res.redirect("/");
|
||||
return;
|
||||
}
|
||||
|
||||
const player = await PlayerUtil.getPlayer(req.params.id);
|
||||
if (!player)
|
||||
{
|
||||
res.status(404).json(new ErrorResponseBuilder()
|
||||
.setCode(404).setData("Profile not found!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.flags.includes("hidden"))
|
||||
{
|
||||
res.status(403).json(new ErrorResponseBuilder()
|
||||
.setCode(403).setData("Profile blocked!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.flags.includes("private"))
|
||||
{
|
||||
res.status(404).json(new ErrorResponseBuilder()
|
||||
.setCode(404).setData("Profile is private!"));
|
||||
return;
|
||||
}
|
||||
|
||||
let active: ActiveStation | ActiveTrain = undefined!;
|
||||
|
||||
for (const x of Object.keys(client.trains))
|
||||
{
|
||||
const data = client.trains[ x ].find(x => x.TrainData.ControlledBySteamID === player.id);
|
||||
if (data)
|
||||
{
|
||||
active = {
|
||||
type: "train",
|
||||
trainNumber: data.TrainNoLocal,
|
||||
trainName: data.TrainName,
|
||||
server: x,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
for (const x of Object.keys(client.stations))
|
||||
{
|
||||
const data = client.stations[ x ].find(x => x.DispatchedBy[ 0 ]?.SteamId === player.id);
|
||||
if (data)
|
||||
{
|
||||
active = {
|
||||
type: "station",
|
||||
stationName: data.Name,
|
||||
stationShort: data.Prefix,
|
||||
server: x,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (process.env.IMGPROXY_KEY)
|
||||
{
|
||||
player.avatar = generateUrl(player.avatar, "rs:auto:256:256:1/f:png");
|
||||
}
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
player,
|
||||
active,
|
||||
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
app.get("/", async (req, res) =>
|
||||
{
|
||||
const s = req.query.q?.toString().split(",").map(x => new RegExp(escapeRegexString(x), "i"));
|
||||
|
||||
const limit = parseInt(req.query.limit as string) || 12;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
|
||||
if (page < 0 || limit < 0)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400).setData("Invalid page and/or limit"));
|
||||
return;
|
||||
}
|
||||
|
||||
const filter: PipelineStage[] = [
|
||||
{
|
||||
$match: {
|
||||
flags: { $nin: [ "hidden" ] },
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
s && filter.push({
|
||||
$match: {
|
||||
$and: [
|
||||
...s.map(x => ({ $or: generateSearch(x) })),
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$facet: {
|
||||
data: [
|
||||
{ $match: {} },
|
||||
{ $skip: (page - 1) * limit },
|
||||
{ $limit: limit },
|
||||
],
|
||||
count: [
|
||||
{ $count: "count" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const records = await MProfile.aggregate(filter);
|
||||
|
||||
|
||||
process.env.IMGPROXY_KEY && records[ 0 ].data && records[ 0 ].data.forEach((p: IProfile) =>
|
||||
{
|
||||
if (p.avatar.includes("imgproxy.alekswilc.dev"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
p.avatar = generateUrl(p.avatar);
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
records: records[ 0 ].data,
|
||||
pages: Math.floor((records[ 0 ]?.count?.[ 0 ]?.count ?? 0) / limit),
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
130
packages/backend/src/http/routes/stations.ts
Normal file
130
packages/backend/src/http/routes/stations.ts
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { IStationLog, MStationLog } from "../../mongo/stationLog.js";
|
||||
import { PipelineStage } from "mongoose";
|
||||
import { escapeRegexString } from "../../util/functions.js";
|
||||
import { ErrorResponseBuilder, SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { IProfile, MProfile } from "../../mongo/profile.js";
|
||||
import { generateUrl } from "../../util/imgproxy.js";
|
||||
|
||||
const generateSearch = (regex: RegExp) => [
|
||||
{
|
||||
stationName: { $regex: regex },
|
||||
},
|
||||
{
|
||||
username: { $regex: regex },
|
||||
},
|
||||
{
|
||||
stationShort: { $regex: regex },
|
||||
},
|
||||
{
|
||||
steam: { $regex: regex },
|
||||
},
|
||||
{
|
||||
server: { $regex: regex },
|
||||
},
|
||||
];
|
||||
|
||||
export class StationsRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/", async (req, res) =>
|
||||
{
|
||||
const s = req.query.query?.toString().split(",").map(x => new RegExp(escapeRegexString(x.trim()), "i"));
|
||||
const server = req.query.server?.toString();
|
||||
|
||||
const limit = parseInt(req.query.limit as string) || 12;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
|
||||
if (page < 0 || limit < 0)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400).setData("Invalid page and/or limit"));
|
||||
return;
|
||||
}
|
||||
|
||||
const filter: PipelineStage[] = [];
|
||||
|
||||
s && filter.push({
|
||||
$match: {
|
||||
$and: [
|
||||
...s.map(x => ({ $or: generateSearch(x) })),
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
server && filter.push({
|
||||
$match: {
|
||||
server: {
|
||||
$regex: new RegExp(escapeRegexString(server), "i"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$sort: {
|
||||
leftDate: -1,
|
||||
},
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$facet: {
|
||||
data: [
|
||||
{ $match: {} },
|
||||
{ $skip: (page - 1) * limit },
|
||||
{ $limit: limit },
|
||||
],
|
||||
count: [
|
||||
{ $count: "count" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const records = await MStationLog.aggregate(filter);
|
||||
|
||||
await MProfile.populate(records, { path: "data.player" });
|
||||
|
||||
process.env.IMGPROXY_KEY && records[ 0 ].data && records[ 0 ].data.forEach((p: IStationLog & {
|
||||
player: IProfile
|
||||
}) =>
|
||||
{
|
||||
if (p.player.avatar.includes("imgproxy.alekswilc.dev"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
p.player.avatar = generateUrl(p.player.avatar);
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
records: records[ 0 ].data,
|
||||
pages: Math.floor((records[ 0 ]?.count?.[ 0 ]?.count ?? 0) / limit),
|
||||
servers: Object.keys(client.stations),
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
51
packages/backend/src/http/routes/stats.ts
Normal file
51
packages/backend/src/http/routes/stats.ts
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { MTrainLog } from "../../mongo/trainLog.js";
|
||||
import { GitUtil } from "../../util/git.js";
|
||||
import { SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { MStationLog } from "../../mongo/stationLog.js";
|
||||
import { MProfile } from "../../mongo/profile.js";
|
||||
|
||||
export class StatsRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/", async (req, res) =>
|
||||
{
|
||||
const { commit, version } = GitUtil.getData();
|
||||
|
||||
const trains = await MTrainLog.countDocuments();
|
||||
const dispatchers = await MStationLog.countDocuments();
|
||||
const profiles = await MProfile.countDocuments();
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder<{
|
||||
git: { commit?: string, version?: string },
|
||||
stats: { trains: number, dispatchers: number, profiles: number }
|
||||
}>()
|
||||
.setCode(200)
|
||||
.setData({ git: { commit, version }, stats: { trains, dispatchers, profiles } })
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
127
packages/backend/src/http/routes/trains.ts
Normal file
127
packages/backend/src/http/routes/trains.ts
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { PipelineStage } from "mongoose";
|
||||
import { ITrainLog, MTrainLog } from "../../mongo/trainLog.js";
|
||||
import { ErrorResponseBuilder, SuccessResponseBuilder } from "../responseBuilder.js";
|
||||
import { escapeRegexString } from "../../util/functions.js";
|
||||
import { IProfile, MProfile } from "../../mongo/profile.js";
|
||||
import { generateUrl } from "../../util/imgproxy.js";
|
||||
|
||||
const generateSearch = (regex: RegExp) => [
|
||||
{
|
||||
trainNumber: { $regex: regex },
|
||||
},
|
||||
{
|
||||
username: { $regex: regex },
|
||||
},
|
||||
{
|
||||
server: { $regex: regex },
|
||||
},
|
||||
{
|
||||
steam: { $regex: regex },
|
||||
},
|
||||
];
|
||||
|
||||
export class TrainsRoute
|
||||
{
|
||||
static load()
|
||||
{
|
||||
const app = Router();
|
||||
|
||||
app.get("/", async (req, res) =>
|
||||
{
|
||||
const s = req.query.query?.toString().split(",").map(x => new RegExp(escapeRegexString(x), "i"));
|
||||
const server = req.query.server?.toString();
|
||||
|
||||
const filter: PipelineStage[] = [];
|
||||
|
||||
const limit = parseInt(req.query.limit as string) || 12;
|
||||
const page = parseInt(req.query.page as string) || 1;
|
||||
|
||||
if (page < 0 || limit < 0)
|
||||
{
|
||||
res.status(400).json(new ErrorResponseBuilder()
|
||||
.setCode(400).setData("Invalid page and/or limit"));
|
||||
return;
|
||||
}
|
||||
|
||||
s && filter.push({
|
||||
$match: {
|
||||
$and: [
|
||||
...s.map(x => ({ $or: generateSearch(x) })),
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
server && filter.push({
|
||||
$match: {
|
||||
server: {
|
||||
$regex: new RegExp(escapeRegexString(server), "i"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$sort: {
|
||||
leftDate: -1,
|
||||
},
|
||||
});
|
||||
|
||||
filter.push({
|
||||
$facet: {
|
||||
data: [
|
||||
{ $match: {} },
|
||||
{ $skip: (page - 1) * limit },
|
||||
{ $limit: limit },
|
||||
],
|
||||
count: [
|
||||
{ $count: "count" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const records = await MTrainLog.aggregate(filter);
|
||||
|
||||
await MProfile.populate(records, { path: "data.player" });
|
||||
|
||||
process.env.IMGPROXY_KEY && records[ 0 ].data && records[ 0 ].data.forEach((p: ITrainLog & {
|
||||
player: IProfile
|
||||
}) =>
|
||||
{
|
||||
if (p.player.avatar.includes("imgproxy.alekswilc.dev"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
p.player.avatar = generateUrl(p.player.avatar);
|
||||
});
|
||||
|
||||
res.json(
|
||||
new SuccessResponseBuilder()
|
||||
.setCode(200)
|
||||
.setData({
|
||||
records: records[ 0 ].data,
|
||||
pages: Math.floor((records[ 0 ]?.count?.[ 0 ]?.count ?? 0) / limit),
|
||||
servers: Object.keys(client.stations),
|
||||
})
|
||||
.toJSON(),
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
50
packages/backend/src/http/server.ts
Normal file
50
packages/backend/src/http/server.ts
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import express, { Router } from "express";
|
||||
import { StationsRoute } from "./routes/stations.js";
|
||||
import { TrainsRoute } from "./routes/trains.js";
|
||||
import { ProfilesRoute } from "./routes/profile.js";
|
||||
import { LeaderboardRoute } from "./routes/leaderboard.js";
|
||||
import cors from "cors";
|
||||
import { StatsRoute } from "./routes/stats.js";
|
||||
import { LogRoute } from "./routes/log.js";
|
||||
import { ActivePlayersRoute } from "./routes/activePlayer.js";
|
||||
import { AdminRoute } from "./routes/admin.js";
|
||||
|
||||
export class ApiModule
|
||||
{
|
||||
public static load()
|
||||
{
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
|
||||
const router = Router();
|
||||
router.use("/stations/", StationsRoute.load());
|
||||
router.use("/trains/", TrainsRoute.load());
|
||||
router.use("/profiles/", ProfilesRoute.load());
|
||||
router.use("/leaderboard/", LeaderboardRoute.load());
|
||||
router.use("/active/", ActivePlayersRoute.load());
|
||||
router.use("/admin/", AdminRoute.load());
|
||||
|
||||
router.use("/stats/", StatsRoute.load());
|
||||
router.use("/log/", LogRoute.load());
|
||||
|
||||
app.use("/api/v1", router);
|
||||
|
||||
app.listen(process.env.PORT);
|
||||
}
|
||||
}
|
81
packages/backend/src/index.ts
Normal file
81
packages/backend/src/index.ts
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { createClient, RedisClientType } from "redis";
|
||||
import "./util/time.js";
|
||||
import { SimrailClient, SimrailClientEvents } from "./util/SimrailClient.js";
|
||||
import { StationsModule } from "./modules/stations.js";
|
||||
import { ApiModule } from "./http/server.js";
|
||||
import mongoose from "mongoose";
|
||||
import { TrainsModule } from "./modules/trains.js";
|
||||
import { Server, Station, Train } from "@simrail/types";
|
||||
import dayjs from "dayjs";
|
||||
import { TMProfile } from "./mongo/profile.js";
|
||||
import { GitUtil } from "./util/git.js";
|
||||
|
||||
;(async () =>
|
||||
{
|
||||
global.redis = await createClient({
|
||||
url: process.env.REDIS_URI!,
|
||||
})
|
||||
.on("error", err => console.log("Redis Client Error", err))
|
||||
.connect() as RedisClientType;
|
||||
console.log("Redis connected");
|
||||
|
||||
await mongoose.connect(process.env.MONGO_URI!); // TODO: add typings
|
||||
|
||||
console.log("MongoDB connected");
|
||||
|
||||
if (process.env.NODE_ENV !== "preview") // disable writing data to db on preview.
|
||||
{
|
||||
global.client = new SimrailClient();
|
||||
|
||||
StationsModule.load();
|
||||
TrainsModule.load();
|
||||
}
|
||||
|
||||
ApiModule.load(); // TODO: use fastify
|
||||
GitUtil.getData();
|
||||
|
||||
if (process.env.NODE_ENV === "development")
|
||||
{
|
||||
client.on(SimrailClientEvents.StationJoined, (server: Server, station: Station, player: TMProfile) =>
|
||||
{
|
||||
console.log(`${ server.ServerCode } | ${ station.Name } | ${ player.username } joined`);
|
||||
});
|
||||
|
||||
client.on(SimrailClientEvents.StationLeft, (server: Server, station: Station, player: TMProfile, joinedAt: number) =>
|
||||
{
|
||||
console.log(`${ server.ServerCode } | ${ station.Name } | ${ player.username } left. | ${ joinedAt ? dayjs(joinedAt).fromNow() : "no time data." }`);
|
||||
});
|
||||
|
||||
client.on(SimrailClientEvents.TrainLeft, (server: Server, train: Train, player: TMProfile, joinedAt: number, leftAt: number, points: number, distance: number, vehicle: string) =>
|
||||
{
|
||||
console.log(`${ server.ServerCode } | ${ train.TrainName } | ${ player.username } left. | ${ joinedAt ? dayjs(joinedAt).fromNow() : "no time data." } |
|
||||
${ vehicle } | ${ distance / 1000 } | ${ points }`);
|
||||
});
|
||||
|
||||
client.on(SimrailClientEvents.TrainJoined, (server: Server, train: Train, player: TMProfile, start: number) =>
|
||||
{
|
||||
console.log(`${ server.ServerCode } | ${ train.TrainName } | ${ player.username } joined | ${ start }`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
148
packages/backend/src/modules/stations.ts
Normal file
148
packages/backend/src/modules/stations.ts
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Server, Station } from "@simrail/types";
|
||||
import { MStationLog } from "../mongo/stationLog.js";
|
||||
import { SimrailClientEvents } from "../util/SimrailClient.js";
|
||||
import { v4 } from "uuid";
|
||||
import { MProfile, TMProfile } from "../mongo/profile.js";
|
||||
import { PlayerUtil } from "../util/PlayerUtil.js";
|
||||
import { isTruthyAndGreaterThanZero } from "../util/functions.js";
|
||||
|
||||
export class StationsModule
|
||||
{
|
||||
public static load()
|
||||
{
|
||||
|
||||
client.on(SimrailClientEvents.StationLeft, async (server: Server, station: Station, player: TMProfile, joinedAt: number) =>
|
||||
{
|
||||
const stats = await PlayerUtil.getPlayerStats(player.id);
|
||||
const date = new Date();
|
||||
|
||||
if (stats && (date.getTime() - joinedAt) && (date.getTime() - joinedAt) > 0)
|
||||
{
|
||||
const time = (date.getTime() - joinedAt) || 0;
|
||||
|
||||
if (player.flags.includes("private"))
|
||||
{
|
||||
player.trainStats = {
|
||||
[ "N/A" ]: {
|
||||
score: stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0,
|
||||
distance: stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0,
|
||||
time: 0,
|
||||
},
|
||||
};
|
||||
|
||||
player.dispatcherStats = {
|
||||
[ "N/A" ]: {
|
||||
time: (stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0) * 1000 * 60,
|
||||
},
|
||||
};
|
||||
|
||||
player.trainPoints = stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0;
|
||||
player.trainDistance = stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0;
|
||||
player.dispatcherTime = (stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0) * 1000 * 60;
|
||||
player.trainTime = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!player.dispatcherStats)
|
||||
{
|
||||
player.dispatcherStats = {};
|
||||
}
|
||||
|
||||
if (player.dispatcherStats[ station.Name ] && isTruthyAndGreaterThanZero(player.dispatcherStats[ station.Name ].time + time))
|
||||
{
|
||||
player.dispatcherStats[ station.Name ].time = player.dispatcherStats[ station.Name ].time + time;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.dispatcherStats[ station.Name ] = {
|
||||
time,
|
||||
};
|
||||
}
|
||||
|
||||
if (isTruthyAndGreaterThanZero(player.dispatcherTime + time))
|
||||
{
|
||||
player.dispatcherTime = player.dispatcherTime + time;
|
||||
}
|
||||
|
||||
player.steamTrainDistance = stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0;
|
||||
player.steamDispatcherTime = stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0;
|
||||
player.steamTrainScore = stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0;
|
||||
|
||||
|
||||
if (player.steamTrainDistance > player.trainDistance)
|
||||
{
|
||||
player.trainDistance = player.steamTrainDistance;
|
||||
}
|
||||
if (player.steamTrainScore > player.trainPoints)
|
||||
{
|
||||
player.trainPoints = player.steamTrainScore;
|
||||
}
|
||||
|
||||
const sum = Object.keys(player.trainStats).filter(x => x !== "N/A").map(x => player.trainStats[ x ]).reduce((acc, obj) =>
|
||||
{
|
||||
acc.time += obj.time;
|
||||
acc.distance += obj.distance;
|
||||
acc.score += obj.score;
|
||||
return acc;
|
||||
}, { time: 0, distance: 0, score: 0 });
|
||||
|
||||
|
||||
player.trainStats[ "N/A" ] = {
|
||||
time: 0,
|
||||
distance: player.trainDistance - sum.distance,
|
||||
score: player.trainPoints - sum.score,
|
||||
};
|
||||
|
||||
|
||||
player.flags = player.flags.filter(x => x !== "private");
|
||||
|
||||
if (typeof player.createdAt !== "number")
|
||||
{
|
||||
player.createdAt = new Date(parseInt(player._id.toString().substring(0, 8), 16) * 1000).getTime();
|
||||
}
|
||||
}
|
||||
|
||||
const playerData = await PlayerUtil.getPlayerSteamData(player.id);
|
||||
|
||||
|
||||
player.flags = [ ...new Set(player.flags) ];
|
||||
|
||||
player.username = playerData?.personaname ?? player.username;
|
||||
player.avatar = playerData?.avatarfull ?? player.avatar;
|
||||
|
||||
await MProfile.updateOne({ id: player.id }, player);
|
||||
|
||||
await MStationLog.create({
|
||||
id: v4(),
|
||||
|
||||
steam: player.id,
|
||||
username: player.username,
|
||||
|
||||
joinedDate: joinedAt,
|
||||
leftDate: date.getTime(),
|
||||
stationName: station.Name,
|
||||
stationShort: station.Prefix,
|
||||
server: server.ServerCode,
|
||||
|
||||
player: player._id,
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
183
packages/backend/src/modules/trains.ts
Normal file
183
packages/backend/src/modules/trains.ts
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Server, Train } from "@simrail/types";
|
||||
import { SimrailClientEvents } from "../util/SimrailClient.js";
|
||||
import { v4 } from "uuid";
|
||||
import { getVehicle } from "../util/contants.js";
|
||||
import { MProfile, TMProfile } from "../mongo/profile.js";
|
||||
import { MTrainLog } from "../mongo/trainLog.js";
|
||||
import { PlayerUtil } from "../util/PlayerUtil.js";
|
||||
import { isTruthyAndGreaterThanZero } from "../util/functions.js";
|
||||
|
||||
export class TrainsModule
|
||||
{
|
||||
public static load()
|
||||
{
|
||||
|
||||
client.on(SimrailClientEvents.TrainLeft, async (server: Server, train: Train, player: TMProfile, joinedAt: number, leftAt: number, points: number, distance: number, vehicle: string) =>
|
||||
{
|
||||
const stats = await PlayerUtil.getPlayerStats(player.id);
|
||||
|
||||
if (stats && (leftAt - joinedAt) && (leftAt - joinedAt) > 0)
|
||||
{
|
||||
const time = (leftAt - joinedAt) || 0;
|
||||
|
||||
if (player.flags.includes("private"))
|
||||
{
|
||||
player.trainStats = {
|
||||
[ "N/A" ]: {
|
||||
score: stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0,
|
||||
distance: stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0,
|
||||
time: 0,
|
||||
},
|
||||
};
|
||||
|
||||
player.dispatcherStats = {
|
||||
[ "N/A" ]: {
|
||||
time: (stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0) * 1000 * 60,
|
||||
},
|
||||
};
|
||||
|
||||
player.trainPoints = stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0;
|
||||
player.trainDistance = stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0;
|
||||
player.dispatcherTime = (stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0) * 1000 * 60;
|
||||
player.trainTime = 0;
|
||||
}
|
||||
|
||||
const vehicleName = getVehicle(vehicle) ?? vehicle;
|
||||
|
||||
if (!isTruthyAndGreaterThanZero(distance))
|
||||
{
|
||||
distance = 0;
|
||||
}
|
||||
|
||||
if (!isTruthyAndGreaterThanZero(points))
|
||||
{
|
||||
points = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!player.trainStats)
|
||||
{
|
||||
player.trainStats = {};
|
||||
}
|
||||
|
||||
if (player.trainStats[ vehicleName ])
|
||||
{
|
||||
if (isTruthyAndGreaterThanZero(player.trainStats[ vehicleName ].distance + distance))
|
||||
{
|
||||
player.trainStats[ vehicleName ].distance = player.trainStats[ vehicleName ].distance + distance;
|
||||
}
|
||||
if (isTruthyAndGreaterThanZero(player.trainStats[ vehicleName ].score + points))
|
||||
{
|
||||
player.trainStats[ vehicleName ].score = player.trainStats[ vehicleName ].score + points;
|
||||
}
|
||||
if (isTruthyAndGreaterThanZero(player.trainStats[ vehicleName ].time + time))
|
||||
{
|
||||
player.trainStats[ vehicleName ].time = player.trainStats[ vehicleName ].time + time;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.trainStats[ vehicleName ] = {
|
||||
distance, score: points, time,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (isTruthyAndGreaterThanZero(player.trainTime + time))
|
||||
{
|
||||
player.trainTime = player.trainTime + time;
|
||||
}
|
||||
|
||||
if (isTruthyAndGreaterThanZero(player.trainPoints + points))
|
||||
{
|
||||
player.trainPoints = player.trainPoints + points;
|
||||
}
|
||||
|
||||
if (isTruthyAndGreaterThanZero(player.trainDistance + distance))
|
||||
{
|
||||
player.trainDistance = player.trainDistance + distance;
|
||||
}
|
||||
|
||||
player.steamTrainDistance = stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0;
|
||||
player.steamDispatcherTime = stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0;
|
||||
player.steamTrainScore = stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0;
|
||||
|
||||
|
||||
if (player.steamTrainDistance > player.trainDistance)
|
||||
{
|
||||
player.trainDistance = player.steamTrainDistance;
|
||||
}
|
||||
if (player.steamTrainScore > player.trainPoints)
|
||||
{
|
||||
player.trainPoints = player.steamTrainScore;
|
||||
}
|
||||
|
||||
const sum = Object.keys(player.trainStats).filter(x => x !== "N/A").map(x => player.trainStats[ x ]).reduce((acc, obj) =>
|
||||
{
|
||||
acc.time += obj.time;
|
||||
acc.distance += obj.distance;
|
||||
acc.score += obj.score;
|
||||
return acc;
|
||||
}, { time: 0, distance: 0, score: 0 });
|
||||
|
||||
|
||||
player.trainStats[ "N/A" ] = {
|
||||
time: 0,
|
||||
distance: player.trainDistance - sum.distance,
|
||||
score: player.trainPoints - sum.score,
|
||||
};
|
||||
|
||||
|
||||
player.flags = player.flags.filter(x => x !== "private");
|
||||
|
||||
if (typeof player.createdAt !== "number")
|
||||
{
|
||||
player.createdAt = new Date(parseInt(player._id.toString().substring(0, 8), 16) * 1000).getTime();
|
||||
}
|
||||
}
|
||||
|
||||
const playerData = await PlayerUtil.getPlayerSteamData(player.id);
|
||||
|
||||
!stats && !player.flags.includes("private") && player.flags.push("private");
|
||||
|
||||
player.flags = [ ...new Set(player.flags) ];
|
||||
|
||||
player.username = playerData?.personaname ?? player.username;
|
||||
player.avatar = playerData?.avatarfull ?? player.avatar;
|
||||
|
||||
await MProfile.updateOne({ id: player.id }, player);
|
||||
|
||||
await MTrainLog.create({
|
||||
id: v4(),
|
||||
|
||||
steam: player.id,
|
||||
username: player.username,
|
||||
|
||||
joinedDate: joinedAt,
|
||||
leftDate: leftAt,
|
||||
trainNumber: train.TrainNoLocal,
|
||||
server: server.ServerCode,
|
||||
distance, points,
|
||||
trainName: train.TrainName,
|
||||
|
||||
player: player._id,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
40
packages/backend/src/mongo/admin.ts
Normal file
40
packages/backend/src/mongo/admin.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { HydratedDocument, model, Schema } from "mongoose";
|
||||
|
||||
export const raw_schema = {
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
token: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
};
|
||||
|
||||
const schema = new Schema<IAdmin>(raw_schema);
|
||||
|
||||
export type TMAdmin = HydratedDocument<IAdmin>;
|
||||
|
||||
export const MAdmin = model<IAdmin>("admin", schema);
|
||||
|
||||
export interface IAdmin
|
||||
{
|
||||
token: string;
|
||||
username: string;
|
||||
}
|
139
packages/backend/src/mongo/profile.ts
Normal file
139
packages/backend/src/mongo/profile.ts
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { HydratedDocument, model, Schema } from "mongoose";
|
||||
|
||||
export const raw_schema = {
|
||||
// STEAM HEX
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
// USERNAME FROM STEAM
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
|
||||
// AVATAR FROM STEAM
|
||||
avatar: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
|
||||
// OBJECT WITH TRAIN STATS
|
||||
trainStats: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: {},
|
||||
},
|
||||
// OBJECT WITH DISPATCHER STATS
|
||||
dispatcherStats: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: {},
|
||||
},
|
||||
// FULL TRAIN-TIME for easy access
|
||||
trainTime: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
// FULL TRAIN-SCORE for easy access
|
||||
trainPoints: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
// FULL TRAIN-DISTANCE for easy access
|
||||
trainDistance: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
// FULL DISPATCHER-TIME for easy access
|
||||
dispatcherTime: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
steamDispatcherTime: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
steamTrainDistance: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
steamTrainScore: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
flags: [
|
||||
{
|
||||
type: String,
|
||||
required: false,
|
||||
default: [],
|
||||
},
|
||||
],
|
||||
createdAt: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
};
|
||||
|
||||
const schema = new Schema<IProfile>(raw_schema);
|
||||
|
||||
export type TMProfile = HydratedDocument<IProfile>;
|
||||
|
||||
export const MProfile = model<IProfile>("profile", schema);
|
||||
|
||||
export interface IProfile
|
||||
{
|
||||
id: string;
|
||||
username: string;
|
||||
avatar: string;
|
||||
|
||||
trainStats: {
|
||||
[ trainName: string ]: {
|
||||
score: number,
|
||||
distance: number
|
||||
time: number,
|
||||
}
|
||||
};
|
||||
dispatcherStats: {
|
||||
[ name: string ]: {
|
||||
time: number
|
||||
}
|
||||
};
|
||||
|
||||
trainTime: number;
|
||||
trainPoints: number;
|
||||
trainDistance: number;
|
||||
|
||||
dispatcherTime: number;
|
||||
|
||||
steamDispatcherTime: number;
|
||||
steamTrainDistance: number;
|
||||
steamTrainScore: number;
|
||||
|
||||
createdAt: number;
|
||||
flags: string[];
|
||||
}
|
82
packages/backend/src/mongo/stationLog.ts
Normal file
82
packages/backend/src/mongo/stationLog.ts
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Model, model, Schema } from "mongoose";
|
||||
|
||||
|
||||
export const raw_schema = {
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
joinedDate: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: undefined,
|
||||
},
|
||||
leftDate: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
stationName: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
stationShort: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
server: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
steam: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
|
||||
|
||||
player: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "profile",
|
||||
},
|
||||
};
|
||||
|
||||
const schema = new Schema<IStationLog>(raw_schema);
|
||||
|
||||
export type TMStationLog = Model<IStationLog>
|
||||
|
||||
export const MStationLog = model<IStationLog>("stations", schema);
|
||||
|
||||
export interface IStationLog
|
||||
{
|
||||
id: string;
|
||||
joinedDate?: number;
|
||||
leftDate: number;
|
||||
stationName: string;
|
||||
stationShort: string;
|
||||
server: string;
|
||||
|
||||
player: Schema.Types.ObjectId;
|
||||
|
||||
username: string;
|
||||
steam: string;
|
||||
|
||||
}
|
92
packages/backend/src/mongo/trainLog.ts
Normal file
92
packages/backend/src/mongo/trainLog.ts
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Model, model, Schema } from "mongoose";
|
||||
|
||||
|
||||
export const raw_schema = {
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
trainNumber: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
joinedDate: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: undefined,
|
||||
},
|
||||
leftDate: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
distance: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
points: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
server: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
trainName: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
steam: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
player: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "profile",
|
||||
},
|
||||
};
|
||||
|
||||
const schema = new Schema<ITrainLog>(raw_schema);
|
||||
|
||||
export type TMTrainLog = Model<ITrainLog>
|
||||
|
||||
export const MTrainLog = model<ITrainLog>("trains", schema);
|
||||
|
||||
export interface ITrainLog
|
||||
{
|
||||
id: string;
|
||||
joinedDate?: number;
|
||||
leftDate: number;
|
||||
trainNumber: string;
|
||||
trainName: string;
|
||||
distance: number;
|
||||
points: number;
|
||||
server: string;
|
||||
|
||||
player: Schema.Types.ObjectId;
|
||||
|
||||
username: string;
|
||||
steam: string;
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
/* steam api */
|
||||
|
||||
export type IPlayer = {
|
24
packages/backend/src/types/typings.d.ts
vendored
Normal file
24
packages/backend/src/types/typings.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { RedisClientType } from "redis";
|
||||
import { SimrailClient } from "../util/SimrailClient.ts";
|
||||
/* eslint no-var: off */
|
||||
declare global
|
||||
{
|
||||
declare var redis: RedisClientType,
|
||||
client: SimrailClient;
|
||||
}
|
173
packages/backend/src/util/PlayerUtil.ts
Normal file
173
packages/backend/src/util/PlayerUtil.ts
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { IPlayerPayload, IPlayerStatsPayload } from "../types/player.js";
|
||||
import { MProfile } from "../mongo/profile.js";
|
||||
import { assert } from "node:console";
|
||||
|
||||
const steamKeys: string[] = JSON.parse(process.env.STEAM_APIKEY!);
|
||||
|
||||
const steamFetch = (url: string) =>
|
||||
{
|
||||
let retries = 0;
|
||||
|
||||
return new Promise((res, _rej) =>
|
||||
{
|
||||
const req = () =>
|
||||
{
|
||||
const steamKey = steamKeys[ Math.floor(Math.random() * steamKeys.length) ];
|
||||
|
||||
fetch(url.replace("[STEAMKEY]", steamKey), { signal: AbortSignal.timeout(10000) }).then(x => x.json())
|
||||
.then(x => res(x))
|
||||
.catch(() =>
|
||||
{
|
||||
console.log("STEAM request failed! ", url.replace("[STEAMKEY]", steamKey), retries);
|
||||
|
||||
retries++;
|
||||
setTimeout(() => req(), retries * 1000);
|
||||
});
|
||||
};
|
||||
req();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export class PlayerUtil
|
||||
{
|
||||
public static async ensurePlayer(steamId: number | string)
|
||||
{
|
||||
assert(steamId, "expected steamId to be a string or a number");
|
||||
steamId = steamId.toString();
|
||||
let player = await MProfile.findOne({ id: steamId });
|
||||
|
||||
if (!player)
|
||||
{
|
||||
const data = await steamFetch(`https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=[STEAMKEY]&format=json&steamids=${ steamId }`) as IPlayerPayload;
|
||||
|
||||
assert(data.response.players, "Expected data.response.players to be truthy");
|
||||
|
||||
const stats = await this.getPlayerStats(steamId);
|
||||
|
||||
player = await MProfile.findOne({ id: steamId });
|
||||
if (player)
|
||||
{
|
||||
return player;
|
||||
}
|
||||
|
||||
const trainStats: {
|
||||
[ trainName: string ]: {
|
||||
score: number,
|
||||
distance: number
|
||||
time: number,
|
||||
}
|
||||
} = {};
|
||||
const dispatcherStats: {
|
||||
[ name: string ]: {
|
||||
time: number
|
||||
}
|
||||
} = {};
|
||||
|
||||
let trainPoints = 0;
|
||||
let trainDistance = 0;
|
||||
let dispatcherTime = 0;
|
||||
|
||||
if (stats)
|
||||
{
|
||||
trainStats[ "N/A" ] = {
|
||||
score: stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0,
|
||||
distance: stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0,
|
||||
time: 0,
|
||||
};
|
||||
|
||||
dispatcherStats[ "N/A" ] = {
|
||||
time: (stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0) * 1000 * 60,
|
||||
};
|
||||
|
||||
trainPoints = stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0;
|
||||
trainDistance = stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0;
|
||||
dispatcherTime = (stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0) * 1000 * 60;
|
||||
}
|
||||
|
||||
player = await MProfile.create({
|
||||
id: steamId,
|
||||
username: data.response.players[ 0 ].personaname,
|
||||
avatar: data.response.players[ 0 ].avatarfull,
|
||||
|
||||
steamDispatcherTime: stats?.stats?.find(x => x.name === "DISPATCHER_TIME")?.value ?? 0,
|
||||
steamTrainScore: stats?.stats?.find(x => x.name === "SCORE")?.value ?? 0,
|
||||
steamTrainDistance: stats?.stats?.find(x => x.name === "DISTANCE_M")?.value ?? 0,
|
||||
|
||||
trainStats,
|
||||
dispatcherStats,
|
||||
|
||||
trainPoints,
|
||||
trainDistance,
|
||||
trainTime: 0,
|
||||
|
||||
dispatcherTime,
|
||||
|
||||
flags: !stats ? [ "private" ] : [],
|
||||
|
||||
createdAt: Date.now(),
|
||||
}).catch(e => e);
|
||||
|
||||
if (player instanceof Error)
|
||||
{
|
||||
player = await MProfile.findOne({ id: steamId });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
assert(player, "expected player to be truthy");
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
public static async getPlayer(steamId: string)
|
||||
{
|
||||
const player = await MProfile.findOne({ id: steamId });
|
||||
|
||||
if (!player)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
public static async getPlayerSteamData(steamId: string)
|
||||
{
|
||||
const data = await steamFetch(`https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=[STEAMKEY]&format=json&steamids=${ steamId }`) as IPlayerPayload;
|
||||
|
||||
if (!data?.response?.players?.length)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return data.response.players[ 0 ];
|
||||
}
|
||||
|
||||
public static async getPlayerStats(steamId: string)
|
||||
{
|
||||
const data = await steamFetch(`https://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=1422130&key=[STEAMKEY]&steamid=${ steamId }`) as IPlayerStatsPayload;
|
||||
|
||||
if (!data.playerstats?.stats)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
return data.playerstats;
|
||||
}
|
||||
}
|
324
packages/backend/src/util/SimrailClient.ts
Normal file
324
packages/backend/src/util/SimrailClient.ts
Normal file
@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { EventEmitter } from "node:events";
|
||||
import { PlayerUtil } from "./PlayerUtil.js";
|
||||
import { Station, ApiResponse, Server, Train } from "@simrail/types";
|
||||
import { TMProfile } from "../mongo/profile.js";
|
||||
|
||||
export enum SimrailClientEvents
|
||||
{
|
||||
StationJoined = "stationJoined",
|
||||
StationLeft = "stationLeft",
|
||||
TrainJoined = "trainJoined",
|
||||
TrainLeft = "trainLeft",
|
||||
|
||||
}
|
||||
|
||||
export declare interface SimrailClient
|
||||
{
|
||||
on(event: SimrailClientEvents.StationJoined, listener: (server: Server, station: Station, player: TMProfile) => void): this;
|
||||
|
||||
on(event: SimrailClientEvents.StationLeft, listener: (server: Server, station: Station, player: TMProfile, joinedAt: number) => void): this;
|
||||
|
||||
|
||||
on(event: SimrailClientEvents.TrainJoined, listener: (server: Server, train: Train, player: TMProfile, startDistance: number) => void): this;
|
||||
|
||||
on(event: SimrailClientEvents.TrainLeft, listener: (server: Server, train: Train, player: TMProfile, joinedAt: number, leftAt: number, points: number, distance: number, vehicle: string) => void): this;
|
||||
|
||||
//on(event: string, listener: Function): this;
|
||||
}
|
||||
|
||||
export type OccupiedStation = {
|
||||
SteamId: string;
|
||||
JoinedAt: number;
|
||||
}
|
||||
|
||||
export type OccupiedTrain = {
|
||||
SteamId: string;
|
||||
JoinedAt: number;
|
||||
StartPlayerDistance: number;
|
||||
StartPlayerPoints: number;
|
||||
}
|
||||
|
||||
export class SimrailClient extends EventEmitter
|
||||
{
|
||||
public stations: Record<Server["ServerCode"], Station[]> = {};
|
||||
public stationsOccupied: Record<Server["ServerCode"], Record<string, OccupiedStation | null>> = {};
|
||||
|
||||
public trains: Record<Server["ServerCode"], Train[]> = {};
|
||||
public trainsOccupied: Record<Server["ServerCode"], Record<string, OccupiedTrain | null>> = {};
|
||||
|
||||
public constructor()
|
||||
{
|
||||
super();
|
||||
this.setup().then(() =>
|
||||
{
|
||||
void this.update(false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// todo: full rewrite, rewrite db structure with option to join log to user profile, check for negative values in user profile
|
||||
// todo: wipe database 13.12.2024
|
||||
|
||||
private async setup()
|
||||
{
|
||||
if (!await redis.get("last_updated"))
|
||||
{
|
||||
await redis.json.set("trains_occupied", "$", {});
|
||||
await redis.json.set("trains", "$", []);
|
||||
await redis.json.set("stations", "$", []);
|
||||
await redis.json.set("stations_occupied", "$", {});
|
||||
}
|
||||
|
||||
const lastUpdated = Date.now() - (Number(await redis.get("last_updated")) ?? 0);
|
||||
|
||||
if (lastUpdated > 300_000)
|
||||
{
|
||||
console.log("REDIS: last updated more than > 5 mins");
|
||||
await redis.json.set("trains_occupied", "$", {});
|
||||
await redis.json.set("trains", "$", []);
|
||||
await redis.json.set("stations", "$", []);
|
||||
await redis.json.set("stations_occupied", "$", {});
|
||||
}
|
||||
|
||||
if (!await redis.json.get("stations"))
|
||||
{
|
||||
redis.json.set("stations", "$", []);
|
||||
}
|
||||
if (!await redis.json.get("trains"))
|
||||
{
|
||||
redis.json.set("trains", "$", []);
|
||||
}
|
||||
if (!await redis.json.get("trains_occupied"))
|
||||
{
|
||||
redis.json.set("trains_occupied", "$", {});
|
||||
}
|
||||
if (!await redis.json.get("stations_occupied"))
|
||||
{
|
||||
redis.json.set("stations_occupied", "$", {});
|
||||
}
|
||||
|
||||
this.stations = (await redis.json.get("stations") as unknown as SimrailClient["stations"]);
|
||||
this.stationsOccupied = (await redis.json.get("stations_occupied") as unknown as SimrailClient["stationsOccupied"]);
|
||||
this.trains = (await redis.json.get("trains") as unknown as SimrailClient["trains"]);
|
||||
this.trainsOccupied = (await redis.json.get("trains_occupied") as unknown as SimrailClient["trainsOccupied"]);
|
||||
|
||||
redis.set("last_updated", Date.now().toString());
|
||||
}
|
||||
|
||||
private async processStation(server: Server, stations: ApiResponse<Station>)
|
||||
{
|
||||
if (stations.result)
|
||||
{
|
||||
if (!this.stations[ server.ServerCode ])
|
||||
{
|
||||
this.stations[ server.ServerCode ] = [];
|
||||
}
|
||||
if (!this.stationsOccupied[ server.ServerCode ])
|
||||
{
|
||||
this.stationsOccupied[ server.ServerCode ] = {};
|
||||
}
|
||||
|
||||
if (!this.stations[ server.ServerCode ].length)
|
||||
{
|
||||
this.stations[ server.ServerCode ] = stations.data;
|
||||
redis.json.set("stations", "$", this.stations);
|
||||
redis.set("last_updated", Date.now().toString());
|
||||
}
|
||||
|
||||
for (const x of stations.data)
|
||||
{
|
||||
const data = this.stations[ server.ServerCode ].find(y => y.Name === x.Name);
|
||||
if (!data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data.DispatchedBy[ 0 ]?.SteamId !== x.DispatchedBy[ 0 ]?.SteamId)
|
||||
{
|
||||
if (!data.DispatchedBy[ 0 ]?.SteamId)
|
||||
{
|
||||
// join
|
||||
const date = new Date();
|
||||
|
||||
const player = await PlayerUtil.ensurePlayer(x.DispatchedBy[ 0 ]?.SteamId);
|
||||
|
||||
this.emit(SimrailClientEvents.StationJoined, server, x, player);
|
||||
this.stationsOccupied[ server.ServerCode ][ data.Prefix ] = {
|
||||
SteamId: x.DispatchedBy[ 0 ]?.SteamId,
|
||||
JoinedAt: date.getTime(),
|
||||
};
|
||||
|
||||
continue;
|
||||
}
|
||||
// leave
|
||||
const player = await PlayerUtil.ensurePlayer(data.DispatchedBy[ 0 ]?.SteamId);
|
||||
|
||||
this.emit(SimrailClientEvents.StationLeft, server, x, player, this.stationsOccupied[ server.ServerCode ][ data.Prefix ]?.JoinedAt);
|
||||
delete this.stationsOccupied[ server.ServerCode ][ data.Prefix ];
|
||||
|
||||
}
|
||||
}
|
||||
redis.json.set("stations_occupied", "$", this.stationsOccupied);
|
||||
|
||||
this.stations[ server.ServerCode ] = stations.data;
|
||||
redis.json.set("stations", "$", this.stations);
|
||||
redis.set("last_updated", Date.now().toString());
|
||||
}
|
||||
}
|
||||
|
||||
private async processTrain(server: Server, trains: ApiResponse<Train>)
|
||||
{
|
||||
if (trains.result)
|
||||
{
|
||||
if (!this.trains[ server.ServerCode ])
|
||||
{
|
||||
this.trains[ server.ServerCode ] = [];
|
||||
}
|
||||
if (!this.trainsOccupied[ server.ServerCode ])
|
||||
{
|
||||
this.trainsOccupied[ server.ServerCode ] = {};
|
||||
}
|
||||
|
||||
if (!this.trains[ server.ServerCode ].length)
|
||||
{
|
||||
this.trains[ server.ServerCode ] = trains.data;
|
||||
redis.json.set("trains", "$", this.trains);
|
||||
redis.set("last_updated", Date.now().toString());
|
||||
return;
|
||||
}
|
||||
|
||||
for (const x of trains.data)
|
||||
{
|
||||
const data = this.trains[ server.ServerCode ].find(y => y.id === x.id);
|
||||
if (!data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data.TrainData.ControlledBySteamID !== x.TrainData.ControlledBySteamID)
|
||||
{
|
||||
|
||||
if (!data.TrainData.ControlledBySteamID)
|
||||
{
|
||||
if (!x.TrainData.ControlledBySteamID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// join
|
||||
const date = new Date();
|
||||
|
||||
const player = await PlayerUtil.ensurePlayer(x.TrainData.ControlledBySteamID!);
|
||||
|
||||
const playerStats = await PlayerUtil.getPlayerStats(x.TrainData.ControlledBySteamID!);
|
||||
|
||||
|
||||
this.emit(SimrailClientEvents.TrainJoined, server, x, player, playerStats?.stats.find(x => x.name === "DISTANCE_M")?.value);
|
||||
|
||||
this.trainsOccupied[ server.ServerCode ][ x.TrainNoLocal ] = {
|
||||
SteamId: x.TrainData.ControlledBySteamID!,
|
||||
JoinedAt: date.getTime(),
|
||||
StartPlayerDistance: playerStats?.stats.find(x => x.name === "DISTANCE_M")?.value!,
|
||||
StartPlayerPoints: playerStats?.stats.find(x => x.name === "SCORE")?.value!,
|
||||
};
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!data.TrainData.ControlledBySteamID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const date = new Date();
|
||||
|
||||
const player = await PlayerUtil.ensurePlayer(data.TrainData.ControlledBySteamID!);
|
||||
|
||||
const playerId = data.TrainData.ControlledBySteamID!;
|
||||
const trainOccupied = this.trainsOccupied[ server.ServerCode ][ data.TrainNoLocal ] && JSON.parse(JSON.stringify(this.trainsOccupied[ server.ServerCode ][ data.TrainNoLocal ])) || null;
|
||||
|
||||
setTimeout(() =>
|
||||
{
|
||||
PlayerUtil.getPlayerStats(playerId).then(playerStats =>
|
||||
{
|
||||
const oldKm = trainOccupied?.StartPlayerDistance ?? 0;
|
||||
|
||||
let distance = oldKm ? (playerStats?.stats.find(x => x.name === "DISTANCE_M")?.value ?? 0) - oldKm : 0;
|
||||
|
||||
const oldPoints = trainOccupied?.StartPlayerPoints ?? 0;
|
||||
|
||||
let points = oldPoints ? (playerStats?.stats.find(x => x.name === "SCORE")?.value ?? 0) - oldPoints : 0;
|
||||
|
||||
|
||||
if (distance < 0)
|
||||
{
|
||||
console.warn(`Player ${ playerId }, Train ${ data.TrainNoLocal } - distance < 0`);
|
||||
distance = 0;
|
||||
}
|
||||
|
||||
if (points < 0)
|
||||
{
|
||||
console.warn(`Player ${ playerId }, Train ${ data.TrainNoLocal } - distance < 0`);
|
||||
points = 0;
|
||||
}
|
||||
|
||||
this.emit(SimrailClientEvents.TrainLeft, server, data, player, trainOccupied?.JoinedAt, date.getTime(), points, distance, x.Vehicles[ 0 ]);
|
||||
});
|
||||
}, 30_000);
|
||||
delete this.trainsOccupied[ server.ServerCode ][ data.TrainNoLocal ];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.trains[ server.ServerCode ] = trains.data;
|
||||
redis.json.set("trains", "$", this.trains);
|
||||
redis.json.set("trains_occupied", "$", this.trainsOccupied);
|
||||
redis.set("last_updated", Date.now().toString());
|
||||
}
|
||||
}
|
||||
|
||||
private async update(needSetup: boolean = false)
|
||||
{
|
||||
const servers = (await fetch("https://panel.simrail.eu:8084/servers-open").then(x => x.json()).catch(() => ({ data: [], result: false })) as ApiResponse<Server>)
|
||||
.data ?? []; //?.filter(x => x.ServerName.includes("Polski")) ?? []; // TODO: remove this in v3
|
||||
|
||||
if (!servers.length)
|
||||
{
|
||||
console.log("SimrailAPI is down");
|
||||
await new Promise(res => setTimeout(res, 5000));
|
||||
await this.update(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (needSetup)
|
||||
{
|
||||
await this.setup();
|
||||
}
|
||||
|
||||
// TODO: maybe node:worker_threads?
|
||||
// TODO: check performance
|
||||
for (const server of servers)
|
||||
{
|
||||
const stations = (await fetch("https://panel.simrail.eu:8084/stations-open?serverCode=" + server.ServerCode).then(x => x.json()).catch(() => ({ result: false }))) as ApiResponse<Station>;
|
||||
const trains = (await fetch("https://panel.simrail.eu:8084/trains-open?serverCode=" + server.ServerCode).then(x => x.json()).catch(() => ({ result: false }))) as ApiResponse<Train>;
|
||||
|
||||
await this.processStation(server, stations);
|
||||
await this.processTrain(server, trains);
|
||||
}
|
||||
await new Promise(res => setTimeout(res, 1000));
|
||||
await this.update();
|
||||
}
|
||||
}
|
@ -1,4 +1,21 @@
|
||||
import wcmatch from 'wildcard-match'
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
|
||||
import wcmatch from "wildcard-match";
|
||||
|
||||
/*
|
||||
E186_134 = "Traxx/E186-134",
|
||||
@ -48,80 +65,82 @@ E186_134 = "Traxx/E186-134",
|
||||
|
||||
export const trainsList = [
|
||||
{
|
||||
train: 'Traxx (E186)',
|
||||
train: "Traxx (E186)",
|
||||
pattern: [
|
||||
'Traxx/E186-*',
|
||||
]
|
||||
"Traxx/E186-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: 'Dragon2 (E6ACTa, E6ACTadb)',
|
||||
train: "Dragon2 (E6ACTa, E6ACTadb)",
|
||||
pattern: [
|
||||
'Dragon2/E6ACTa-*',
|
||||
'Dragon2/E6ACTadb-*'
|
||||
]
|
||||
"Dragon2/E6ACTa-*",
|
||||
"Dragon2/E6ACTadb-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: 'Dragon2 (ET25)',
|
||||
train: "Dragon2 (ET25)",
|
||||
pattern: [
|
||||
'Dragon2/ET25-*',
|
||||
]
|
||||
"Dragon2/ET25-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: 'Pendolino (ED250)',
|
||||
train: "Pendolino (ED250)",
|
||||
pattern: [
|
||||
'Pendolino/ED250-*',
|
||||
]
|
||||
"Pendolino/ED250-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: 'EN57',
|
||||
train: "EN57",
|
||||
pattern: [
|
||||
'EN57/EN57-*',
|
||||
]
|
||||
"EN57/EN57-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: 'EN71',
|
||||
train: "EN71",
|
||||
pattern: [
|
||||
'EN57/EN71-*',
|
||||
]
|
||||
"EN57/EN71-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: 'EN96',
|
||||
train: "EN76",
|
||||
pattern: [
|
||||
'Elf/EN76-*',
|
||||
]
|
||||
"Elf/EN76-*",
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
train: 'EP07',
|
||||
train: "EN96",
|
||||
pattern: [
|
||||
'4E/EP07-*',
|
||||
]
|
||||
"Elf/EN96-*",
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
train: 'EP08',
|
||||
train: "EP07",
|
||||
pattern: [
|
||||
'4E/EP08-*',
|
||||
]
|
||||
"4E/EP07-*",
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
train: 'ET22',
|
||||
train: "EP08",
|
||||
pattern: [
|
||||
'201E/ET22-*',
|
||||
]
|
||||
"4E/EP08-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: "ET22",
|
||||
pattern: [
|
||||
"201E/ET22-*",
|
||||
],
|
||||
},
|
||||
{
|
||||
train: "EU07",
|
||||
pattern: [
|
||||
"4E/EU07-*",
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
export const getVehicle = (name: string) =>
|
||||
{
|
||||
train: 'EU07',
|
||||
pattern: [
|
||||
'4E/EU07-*',
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
export const getVehicle = (name: string) => {
|
||||
return trainsList.find(x => wcmatch(x.pattern)(name))?.train;
|
||||
};
|
48
packages/backend/src/util/functions.ts
Normal file
48
packages/backend/src/util/functions.ts
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
// TODO: typings
|
||||
export const removeProperties = <T>(data: any, names: string[]) =>
|
||||
{
|
||||
for (const name of names)
|
||||
{
|
||||
delete data[ name ];
|
||||
}
|
||||
return data as T;
|
||||
};
|
||||
|
||||
|
||||
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
||||
export const escapeRegexString = (str: string) =>
|
||||
{
|
||||
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
};
|
||||
|
||||
export const isTruthyAndGreaterThanZero = (data: number) =>
|
||||
{
|
||||
if (!data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return data > 0;
|
||||
};
|
||||
|
||||
export const arrayGroupBy = <T>(array: T[], predicate: (value: T, index: number, array: T[]) => string) =>
|
||||
Object.values((array.reduce((acc, value, index, array) =>
|
||||
{
|
||||
(acc[ predicate(value, index, array) ] ||= []).push(value);
|
||||
return acc;
|
||||
}, {} as { [ key: string ]: T[] }))).flat();
|
65
packages/backend/src/util/git.ts
Normal file
65
packages/backend/src/util/git.ts
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { execSync } from "child_process";
|
||||
|
||||
export class GitUtil
|
||||
{
|
||||
private static cache: { version?: string, commit?: string } = undefined!;
|
||||
|
||||
private static getLatestVersion()
|
||||
{
|
||||
return process.env.CURRENT_VERSION;
|
||||
// try
|
||||
// {
|
||||
// const data = execSync("git describe --tags --exact-match").toString();
|
||||
// return data.replace("\n", "");
|
||||
// } catch
|
||||
// {
|
||||
// return undefined;
|
||||
// }
|
||||
}
|
||||
|
||||
private static getLatestCommit()
|
||||
{
|
||||
return process.env.CURRENT_COMMIT;
|
||||
// try
|
||||
// {
|
||||
// const data = execSync("git rev-parse --short HEAD").toString();
|
||||
// return data.replace("\n", "");
|
||||
// } catch
|
||||
// {
|
||||
// return undefined;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public static getData()
|
||||
{
|
||||
if (this.cache)
|
||||
{
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
const data = {
|
||||
version: this.getLatestVersion(),
|
||||
commit: this.getLatestCommit(),
|
||||
};
|
||||
|
||||
this.cache = data;
|
||||
return data;
|
||||
}
|
||||
}
|
42
packages/backend/src/util/imgproxy.ts
Normal file
42
packages/backend/src/util/imgproxy.ts
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { createHmac, randomBytes } from "node:crypto";
|
||||
import { GitUtil } from "./git.js";
|
||||
|
||||
export const imgProxySign = (target: string) =>
|
||||
{
|
||||
const hmac = createHmac("sha256", Buffer.from(process.env.IMGPROXY_KEY!, 'hex'));
|
||||
hmac.update(Buffer.from(process.env.IMGPROXY_SALT!, 'hex'));
|
||||
hmac.update(target);
|
||||
|
||||
return hmac.digest("base64url");
|
||||
};
|
||||
|
||||
export const generateUrl = (url: string, options: string = "rs:auto:128:128:1/f:png") =>
|
||||
{
|
||||
if (url.includes('https://proxy.cdn.alekswilc.dev/')) return url;
|
||||
|
||||
if (process.env.NODE_ENV === "development")
|
||||
{
|
||||
options += "/cb:" + randomBytes(4).toString('hex');
|
||||
} else if (GitUtil.getData().version) {
|
||||
options += "/cb:" + GitUtil.getData().version;
|
||||
}
|
||||
|
||||
const signature = imgProxySign(`/${ options }/plain/${ url }`);
|
||||
return `https://proxy.cdn.alekswilc.dev/${ signature }/${ options }/plain/${ url }`;
|
||||
}
|
38
packages/backend/src/util/time.ts
Normal file
38
packages/backend/src/util/time.ts
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime.js";
|
||||
import duration from "dayjs/plugin/duration.js";
|
||||
import pl from "dayjs/locale/pl.js";
|
||||
|
||||
|
||||
dayjs.extend(duration);
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.locale(pl);
|
||||
|
||||
|
||||
export const msToTime = (duration: number, long = false) =>
|
||||
{
|
||||
const time = dayjs.duration(duration, "milliseconds");
|
||||
|
||||
if (long)
|
||||
{
|
||||
return `${ time.humanize() } (${ time.format("Y[y] M[mth] D[d] H[h] m[m] s[s]").split(" ").map(x => x.split("")[ 0 ] === "0" ? null : x).filter(x => x).join(" ") })`;
|
||||
}
|
||||
|
||||
return time.humanize();
|
||||
};
|
2
packages/frontend/.env.example
Normal file
2
packages/frontend/.env.example
Normal file
@ -0,0 +1,2 @@
|
||||
VITE_API_URL=API URL
|
||||
VITE_STATS_KEY=UMAMI API KEY
|
6
packages/frontend/.gitignore
vendored
Normal file
6
packages/frontend/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
*.log
|
||||
.env
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
3
packages/frontend/.prettierrc
Normal file
3
packages/frontend/.prettierrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"singleQuote": true
|
||||
}
|
17
packages/frontend/Dockerfile
Normal file
17
packages/frontend/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM node:18-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json .
|
||||
|
||||
RUN npm install
|
||||
|
||||
RUN npm i -g serve vite
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm run rawbuild
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD [ "serve", "-s", "dist" ]
|
10
packages/frontend/frontend.iml
Normal file
10
packages/frontend/frontend.iml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="script" level="application" />
|
||||
</component>
|
||||
</module>
|
34
packages/frontend/index.html
Normal file
34
packages/frontend/index.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!--
|
||||
~ Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU Affero General Public License as published
|
||||
~ by the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU Affero General Public License for more details.
|
||||
~
|
||||
~ See LICENSE for more.
|
||||
-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<link rel="icon" type="image/jpg" href="/favicon.png"/>
|
||||
<link rel="preconnect" href="https://umami.alekswilc.dev/script.js">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>simrail.pro | Simrail Logs</title>
|
||||
|
||||
<script defer src="https://umami.alekswilc.dev/script.js"
|
||||
data-website-id="%VITE_STATS_KEY%"
|
||||
data-domains="simrail.pro,simrail.info"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
3346
packages/frontend/package-lock.json
generated
Normal file
3346
packages/frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
packages/frontend/package.json
Normal file
42
packages/frontend/package.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "1.3.7",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"rawbuild": "vite build",
|
||||
"preview": "vite preview",
|
||||
"build": "docker build --progress=plain -t simrailpro:frontend ."
|
||||
},
|
||||
"dependencies": {
|
||||
"dayjs": "^1.11.13",
|
||||
"flatpickr": "^4.6.13",
|
||||
"i18next": "^23.15.1",
|
||||
"i18next-browser-languagedetector": "^8.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-country-flag": "^3.1.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-helmet-async": "^2.0.5",
|
||||
"react-i18next": "^15.0.2",
|
||||
"react-icons": "^4.10.1",
|
||||
"react-router-dom": "^6.14.2",
|
||||
"react-toastify": "^10.0.6",
|
||||
"swr": "^2.2.5",
|
||||
"use-debounce": "^10.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.17",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@types/react-toastify": "^4.1.0",
|
||||
"@vitejs/plugin-react": "^4.0.3",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"file-loader": "^6.2.0",
|
||||
"postcss": "^8.4.27",
|
||||
"prettier": "^3.0.0",
|
||||
"prettier-plugin-tailwindcss": "^0.4.1",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"vite": "^6.2.0",
|
||||
"webpack": "^5.88.2"
|
||||
}
|
||||
}
|
22
packages/frontend/postcss.config.cjs
Normal file
22
packages/frontend/postcss.config.cjs
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
BIN
packages/frontend/public/favicon.png
Normal file
BIN
packages/frontend/public/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
4
packages/frontend/public/robots.txt
Normal file
4
packages/frontend/public/robots.txt
Normal file
@ -0,0 +1,4 @@
|
||||
User-agent: *
|
||||
Disallow: /api/
|
||||
Disallow: /cgi-bin/
|
||||
Sitemap: https://simrail.pro/sitemap.xml
|
42
packages/frontend/public/sitemap.xml
Normal file
42
packages/frontend/public/sitemap.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset
|
||||
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
||||
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
||||
<url>
|
||||
<loc>https://simrail.pro/</loc>
|
||||
<lastmod>2024-12-24T23:09:07+00:00</lastmod>
|
||||
<priority>1.00</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://simrail.pro/profiles</loc>
|
||||
<lastmod>2024-12-24T23:09:07+00:00</lastmod>
|
||||
<priority>0.90</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://simrail.pro/leaderboard</loc>
|
||||
<lastmod>2024-12-24T23:09:07+00:00</lastmod>
|
||||
<priority>0.80</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://simrail.pro/logs/stations</loc>
|
||||
<lastmod>2024-12-24T23:09:07+00:00</lastmod>
|
||||
<priority>0.70</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://simrail.pro/logs/trains</loc>
|
||||
<lastmod>2024-12-24T23:09:07+00:00</lastmod>
|
||||
<priority>0.70</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://simrail.pro/active/stations</loc>
|
||||
<lastmod>2024-12-24T23:09:07+00:00</lastmod>
|
||||
<priority>0.60</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://simrail.pro/active/trains</loc>
|
||||
<lastmod>2024-12-24T23:09:07+00:00</lastmod>
|
||||
<priority>0.60</priority>
|
||||
</url>
|
||||
</urlset>
|
191
packages/frontend/src/App.tsx
Normal file
191
packages/frontend/src/App.tsx
Normal file
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { Route, Routes, useLocation } from "react-router-dom";
|
||||
|
||||
import { Loader } from "./components/mini/loaders/PageLoader.tsx";
|
||||
import { Home } from "./pages/Home";
|
||||
import DefaultLayout from "./layout/DefaultLayout";
|
||||
import "./i18n";
|
||||
import { Leaderboard } from "./pages/leaderboard/Leaderboard.tsx";
|
||||
import { TrainLogs } from "./pages/logs/TrainLogs.tsx";
|
||||
import { StationLogs } from "./pages/logs/StationLogs.tsx";
|
||||
import { Profile } from "./pages/profiles/Profile.tsx";
|
||||
import { Log } from "./pages/log/Log.tsx";
|
||||
import "react-toastify/dist/ReactToastify.css";
|
||||
import { ToastContainer } from "react-toastify";
|
||||
import useColorMode from "./hooks/useColorMode.tsx";
|
||||
import { HelmetProvider } from "react-helmet-async";
|
||||
import { PageMeta } from "./components/mini/util/PageMeta.tsx";
|
||||
import { ActiveStationsPlayers } from "./pages/activePlayers/ActiveStationsPlayers.tsx";
|
||||
import { ActiveTrainPlayers } from "./pages/activePlayers/ActiveTrainPlayers.tsx";
|
||||
import { AuthProvider } from "./hooks/useAuth.tsx";
|
||||
import { NotFoundError } from "./pages/errors/NotFound.tsx";
|
||||
import { Profiles } from "./pages/profiles/Profiles.tsx";
|
||||
|
||||
function App()
|
||||
{
|
||||
const [ loading, setLoading ] = useState<boolean>(true);
|
||||
const { pathname } = useLocation();
|
||||
const [ theme ] = useColorMode();
|
||||
useEffect(() =>
|
||||
{
|
||||
window.scrollTo(0, 0);
|
||||
}, [ pathname ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setTimeout(() => setLoading(false), 400);
|
||||
}, []);
|
||||
|
||||
|
||||
return <HelmetProvider>
|
||||
<AuthProvider>
|
||||
{ loading ? (
|
||||
<Loader/>
|
||||
) : (
|
||||
<>
|
||||
<ToastContainer
|
||||
position="top-center"
|
||||
autoClose={ 1500 }
|
||||
hideProgressBar={ false }
|
||||
newestOnTop={ false }
|
||||
closeOnClick
|
||||
rtl={ false }
|
||||
pauseOnHover
|
||||
theme={ theme as "light" | "dark" }
|
||||
/>
|
||||
<DefaultLayout>
|
||||
<Routes>
|
||||
<Route
|
||||
index
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Home"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
<Home/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/leaderboard/"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Train Leaderboard"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
<Leaderboard/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/logs/trains"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Trains Logs"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
<TrainLogs/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/logs/stations"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Stations Logs"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
<StationLogs/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/active/trains"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Active Trains"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
<ActiveTrainPlayers/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/active/stations"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Active Station"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
<ActiveStationsPlayers/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/profile/:id"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Profile"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
{/* page meta is modified in component! */ }
|
||||
<Profile/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/profiles/"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Profiles"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
{/* page meta is modified in component! */ }
|
||||
<Profiles/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="/log/:id"
|
||||
element={
|
||||
<>
|
||||
<PageMeta title="simrail.pro | Log"
|
||||
description="Simrail Stats - The best SimRail logs and statistics site!"/>
|
||||
{/* page title is modified after API response */ }
|
||||
<Log/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path="*"
|
||||
element={
|
||||
<>
|
||||
<NotFoundError/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Routes>
|
||||
</DefaultLayout>
|
||||
</>
|
||||
) }
|
||||
</AuthProvider>
|
||||
</HelmetProvider>;
|
||||
}
|
||||
|
||||
export default App;
|
34
packages/frontend/src/components/mini/alerts/Error.tsx
Normal file
34
packages/frontend/src/components/mini/alerts/Error.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { ErrorAlertIcon } from "../icons/AlertIcons.tsx";
|
||||
|
||||
export const ErrorAlert = ({ title, description }: { title: string, description: string }) => <div
|
||||
className="flex w-full border-l-6 border-[#F87171] bg-[#F87171] bg-opacity-[15%] dark:bg-[#1B1B24] px-7 py-8 shadow-md dark:bg-opacity-30 md:p-9">
|
||||
<div className="mr-5 flex h-9 w-full max-w-[36px] items-center justify-center rounded-lg bg-[#F87171]">
|
||||
<ErrorAlertIcon/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<h5 className="mb-3 font-semibold text-[#B45454]">
|
||||
{ title }
|
||||
</h5>
|
||||
<ul>
|
||||
<li className="leading-relaxed text-[#CD5D5D]">
|
||||
{ description }
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>;
|
33
packages/frontend/src/components/mini/alerts/Success.tsx
Normal file
33
packages/frontend/src/components/mini/alerts/Success.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { SuccessAlertIcon } from "../icons/AlertIcons.tsx";
|
||||
|
||||
export const SuccessAlert = ({ title, description }: { title: string, description: string }) =>
|
||||
<div
|
||||
className="flex w-full border-l-6 border-[#34D399] bg-[#34D399] bg-opacity-[15%] dark:bg-[#1B1B24] px-7 py-8 shadow-md dark:bg-opacity-30 md:p-9">
|
||||
<div className="mr-5 flex h-9 w-full max-w-[36px] items-center justify-center rounded-lg bg-[#34D399]">
|
||||
<SuccessAlertIcon/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<h5 className="mb-3 text-lg font-semibold text-black dark:text-[#34D399] ">
|
||||
{ title }
|
||||
</h5>
|
||||
<p className="text-base leading-relaxed text-body">
|
||||
{ description }
|
||||
</p>
|
||||
</div>
|
||||
</div>;
|
33
packages/frontend/src/components/mini/alerts/Warning.tsx
Normal file
33
packages/frontend/src/components/mini/alerts/Warning.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { WarningAlertIcon } from "../icons/AlertIcons.tsx";
|
||||
|
||||
export const WarningAlert = ({ title, description }: { title: string, description: string }) =>
|
||||
<div
|
||||
className="flex w-full border-l-6 border-warning bg-warning bg-opacity-[15%] dark:bg-[#1B1B24] px-7 py-8 shadow-md dark:bg-opacity-30 md:p-9">
|
||||
<div className="mr-5 flex h-9 w-9 items-center justify-center rounded-lg bg-warning bg-opacity-30">
|
||||
<WarningAlertIcon/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<h5 className="mb-3 text-lg font-semibold text-[#9D5425]">
|
||||
{ title }
|
||||
</h5>
|
||||
<p className="leading-relaxed text-[#D0915C]">
|
||||
{ description }
|
||||
</p>
|
||||
</div>
|
||||
</div>;
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import useColorMode from "../../../hooks/useColorMode";
|
||||
import { DarkIcon, LightIcon } from "../icons/DarkModeSwitchIcons.tsx";
|
||||
|
||||
const DarkModeSwitcher = () =>
|
||||
{
|
||||
const [ colorMode, setColorMode ] = useColorMode();
|
||||
|
||||
return (
|
||||
<li>
|
||||
<label
|
||||
className={ `relative m-0 block h-7.5 w-14 rounded-full ${
|
||||
colorMode === "dark" ? "bg-primary" : "bg-stroke"
|
||||
}` }
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
onChange={ () =>
|
||||
{
|
||||
if (typeof setColorMode === "function")
|
||||
{
|
||||
setColorMode(colorMode === "light" ? "dark" : "light");
|
||||
}
|
||||
} }
|
||||
className="dur absolute top-0 z-50 m-0 h-full w-full cursor-pointer opacity-0"
|
||||
/>
|
||||
<span
|
||||
className={ `absolute top-1/2 left-[3px] flex h-6 w-6 -translate-y-1/2 translate-x-0 items-center justify-center rounded-full bg-white shadow-switcher duration-75 ease-linear ${
|
||||
colorMode === "dark" && "!right-[3px] !translate-x-full"
|
||||
}` }
|
||||
>
|
||||
<span className="dark:hidden">
|
||||
<LightIcon />
|
||||
</span>
|
||||
<span className="hidden dark:inline-block">
|
||||
<DarkIcon />
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
||||
export default DarkModeSwitcher;
|
95
packages/frontend/src/components/mini/header/Header.tsx
Normal file
95
packages/frontend/src/components/mini/header/Header.tsx
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import DarkModeSwitcher from "./DarkModeSwitcher.tsx";
|
||||
import ReactCountryFlag from "react-country-flag";
|
||||
import i18n from "i18next";
|
||||
|
||||
export const Header = (props: {
|
||||
sidebarOpen: string | boolean | undefined;
|
||||
setSidebarOpen: (arg0: boolean) => void;
|
||||
}) =>
|
||||
{
|
||||
return (
|
||||
<header className="sticky top-0 z-999 flex w-full bg-white drop-shadow-1 dark:bg-boxdark dark:drop-shadow-none">
|
||||
<div className="flex flex-grow items-center justify-between px-4 py-4 shadow-2 md:px-6 2xl:px-11">
|
||||
<div className="flex items-center gap-2 sm:gap-4 lg:hidden">
|
||||
<button
|
||||
aria-controls="sidebar"
|
||||
onClick={ (e) =>
|
||||
{
|
||||
e.stopPropagation();
|
||||
props.setSidebarOpen(!props.sidebarOpen);
|
||||
} }
|
||||
className="z-99999 block rounded-sm border border-stroke bg-white p-1.5 shadow-sm dark:border-strokedark dark:bg-boxdark lg:hidden"
|
||||
>
|
||||
<span className="relative block h-5.5 w-5.5 cursor-pointer">
|
||||
<span className="du-block absolute right-0 h-full w-full">
|
||||
<span
|
||||
className={ `relative left-0 top-0 my-1 block h-0.5 w-0 rounded-sm bg-black delay-[0] duration-200 ease-in-out dark:bg-white ${
|
||||
!props.sidebarOpen && "!w-full delay-300"
|
||||
}` }
|
||||
></span>
|
||||
<span
|
||||
className={ `relative left-0 top-0 my-1 block h-0.5 w-0 rounded-sm bg-black delay-150 duration-200 ease-in-out dark:bg-white ${
|
||||
!props.sidebarOpen && "delay-400 !w-full"
|
||||
}` }
|
||||
></span>
|
||||
<span
|
||||
className={ `relative left-0 top-0 my-1 block h-0.5 w-0 rounded-sm bg-black delay-200 duration-200 ease-in-out dark:bg-white ${
|
||||
!props.sidebarOpen && "!w-full delay-500"
|
||||
}` }
|
||||
></span>
|
||||
</span>
|
||||
<span className="absolute right-0 h-full w-full rotate-45">
|
||||
<span
|
||||
className={ `absolute left-2.5 top-0 block h-full w-0.5 rounded-sm bg-black delay-300 duration-200 ease-in-out dark:bg-white ${
|
||||
!props.sidebarOpen && "!h-0 !delay-[0]"
|
||||
}` }
|
||||
></span>
|
||||
<span
|
||||
className={ `delay-400 absolute left-0 top-2.5 block h-0.5 w-full rounded-sm bg-black duration-200 ease-in-out dark:bg-white ${
|
||||
!props.sidebarOpen && "!h-0 !delay-200"
|
||||
}` }
|
||||
></span>
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="hidden sm:block"></div>
|
||||
|
||||
<div className="flex items-center gap-3 2xsm:gap-7">
|
||||
<ul className="flex items-center gap-2 2xsm:gap-4">
|
||||
<a className="cursor-pointer" onClick={ () => i18n.changeLanguage("pl") }>
|
||||
<ReactCountryFlag countryCode={ "PL" } svg alt={ "PL" }/>
|
||||
</a>
|
||||
<a className="cursor-pointer" onClick={ () => i18n.changeLanguage("en") }>
|
||||
<ReactCountryFlag countryCode={ "US" } svg alt={ "EN" }/>
|
||||
</a>
|
||||
<a className="cursor-pointer" onClick={ () => i18n.changeLanguage("cs") }>
|
||||
<ReactCountryFlag countryCode={ "CZ" } svg alt={ "CZ" }/>
|
||||
</a>
|
||||
</ul>
|
||||
<ul className="flex items-center gap-2 2xsm:gap-4">
|
||||
<DarkModeSwitcher/>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
36
packages/frontend/src/components/mini/icons/AlertIcons.tsx
Normal file
36
packages/frontend/src/components/mini/icons/AlertIcons.tsx
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
export const ErrorAlertIcon = () => <svg width="13" height="13" viewBox="0 0 13 13" fill="none"
|
||||
xmlns="<http://www.w3.org/2000/svg>">
|
||||
<path
|
||||
d="M6.4917 7.65579L11.106 12.2645C11.2545 12.4128 11.4715 12.5 11.6738 12.5C11.8762 12.5 12.0931 12.4128 12.2416 12.2645C12.5621 11.9445 12.5623 11.4317 12.2423 11.1114C12.2422 11.1113 12.2422 11.1113 12.2422 11.1113C12.242 11.1111 12.2418 11.1109 12.2416 11.1107L7.64539 6.50351L12.2589 1.91221L12.2595 1.91158C12.5802 1.59132 12.5802 1.07805 12.2595 0.757793C11.9393 0.437994 11.4268 0.437869 11.1064 0.757418C11.1063 0.757543 11.1062 0.757668 11.106 0.757793L6.49234 5.34931L1.89459 0.740581L1.89396 0.739942C1.57364 0.420019 1.0608 0.420019 0.740487 0.739944C0.42005 1.05999 0.419837 1.57279 0.73985 1.89309L6.4917 7.65579ZM6.4917 7.65579L1.89459 12.2639L1.89395 12.2645C1.74546 12.4128 1.52854 12.5 1.32616 12.5C1.12377 12.5 0.906853 12.4128 0.758361 12.2645L1.1117 11.9108L0.758358 12.2645C0.437984 11.9445 0.437708 11.4319 0.757539 11.1116C0.757812 11.1113 0.758086 11.111 0.75836 11.1107L5.33864 6.50287L0.740487 1.89373L6.4917 7.65579Z"
|
||||
fill="#ffffff" stroke="#ffffff"></path>
|
||||
</svg>;
|
||||
|
||||
export const SuccessAlertIcon = () => <svg width="16" height="12" viewBox="0 0 16 12" fill="none"
|
||||
xmlns="<http://www.w3.org/2000/svg>">
|
||||
<path
|
||||
d="M15.2984 0.826822L15.2868 0.811827L15.2741 0.797751C14.9173 0.401867 14.3238 0.400754 13.9657 0.794406L5.91888 9.45376L2.05667 5.2868C1.69856 4.89287 1.10487 4.89389 0.747996 5.28987C0.417335 5.65675 0.417335 6.22337 0.747996 6.59026L0.747959 6.59029L0.752701 6.59541L4.86742 11.0348C5.14445 11.3405 5.52858 11.5 5.89581 11.5C6.29242 11.5 6.65178 11.3355 6.92401 11.035L15.2162 2.11161C15.5833 1.74452 15.576 1.18615 15.2984 0.826822Z"
|
||||
fill="white" stroke="white"></path>
|
||||
</svg>;
|
||||
|
||||
export const WarningAlertIcon = () => <svg width="19" height="16" viewBox="0 0 19 16" fill="none"
|
||||
xmlns="<http://www.w3.org/2000/svg>">
|
||||
<path
|
||||
d="M1.50493 16H17.5023C18.6204 16 19.3413 14.9018 18.8354 13.9735L10.8367 0.770573C10.2852 -0.256858 8.70677 -0.256858 8.15528 0.770573L0.156617 13.9735C-0.334072 14.8998 0.386764 16 1.50493 16ZM10.7585 12.9298C10.7585 13.6155 10.2223 14.1433 9.45583 14.1433C8.6894 14.1433 8.15311 13.6155 8.15311 12.9298V12.9015C8.15311 12.2159 8.6894 11.688 9.45583 11.688C10.2223 11.688 10.7585 12.2159 10.7585 12.9015V12.9298ZM8.75236 4.01062H10.2548C10.6674 4.01062 10.9127 4.33826 10.8671 4.75288L10.2071 10.1186C10.1615 10.5049 9.88572 10.7455 9.50142 10.7455C9.11929 10.7455 8.84138 10.5028 8.79579 10.1186L8.13574 4.75288C8.09449 4.33826 8.33984 4.01062 8.75236 4.01062Z"
|
||||
fill="#FBBF24"></path>
|
||||
</svg>;
|
54
packages/frontend/src/components/mini/icons/ArrowIcon.tsx
Normal file
54
packages/frontend/src/components/mini/icons/ArrowIcon.tsx
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
export const ArrowIcon = ({ rotated }: { rotated?: boolean }) =>
|
||||
<svg
|
||||
className={ `absolute right-4 top-1/2 -translate-y-1/2 fill-current ${
|
||||
rotated && "rotate-180"
|
||||
}` }
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M4.41107 6.9107C4.73651 6.58527 5.26414 6.58527 5.58958 6.9107L10.0003 11.3214L14.4111 6.91071C14.7365 6.58527 15.2641 6.58527 15.5896 6.91071C15.915 7.23614 15.915 7.76378 15.5896 8.08922L10.5896 13.0892C10.2641 13.4147 9.73651 13.4147 9.41107 13.0892L4.41107 8.08922C4.08563 7.76378 4.08563 7.23614 4.41107 6.9107Z"
|
||||
fill=""
|
||||
/>
|
||||
</svg>;
|
||||
|
||||
|
||||
export const FlexArrowIcon = ({ rotated }: { rotated?: boolean }) =>
|
||||
<svg
|
||||
className={ `fill-current ${
|
||||
!rotated && "rotate-180"
|
||||
}` }
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 20 20"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d="M4.41107 6.9107C4.73651 6.58527 5.26414 6.58527 5.58958 6.9107L10.0003 11.3214L14.4111 6.91071C14.7365 6.58527 15.2641 6.58527 15.5896 6.91071C15.915 7.23614 15.915 7.76378 15.5896 8.08922L10.5896 13.0892C10.2641 13.4147 9.73651 13.4147 9.41107 13.0892L4.41107 8.08922C4.08563 7.76378 4.08563 7.23614 4.41107 6.9107Z"
|
||||
fill=""
|
||||
/>
|
||||
</svg>;
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
export const LightIcon = () => <svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M7.99992 12.6666C10.5772 12.6666 12.6666 10.5772 12.6666 7.99992C12.6666 5.42259 10.5772 3.33325 7.99992 3.33325C5.42259 3.33325 3.33325 5.42259 3.33325 7.99992C3.33325 10.5772 5.42259 12.6666 7.99992 12.6666Z"
|
||||
fill="#969AA1"
|
||||
/>
|
||||
<path
|
||||
d="M8.00008 15.3067C7.63341 15.3067 7.33342 15.0334 7.33342 14.6667V14.6134C7.33342 14.2467 7.63341 13.9467 8.00008 13.9467C8.36675 13.9467 8.66675 14.2467 8.66675 14.6134C8.66675 14.9801 8.36675 15.3067 8.00008 15.3067ZM12.7601 13.4267C12.5867 13.4267 12.4201 13.3601 12.2867 13.2334L12.2001 13.1467C11.9401 12.8867 11.9401 12.4667 12.2001 12.2067C12.4601 11.9467 12.8801 11.9467 13.1401 12.2067L13.2267 12.2934C13.4867 12.5534 13.4867 12.9734 13.2267 13.2334C13.1001 13.3601 12.9334 13.4267 12.7601 13.4267ZM3.24008 13.4267C3.06675 13.4267 2.90008 13.3601 2.76675 13.2334C2.50675 12.9734 2.50675 12.5534 2.76675 12.2934L2.85342 12.2067C3.11342 11.9467 3.53341 11.9467 3.79341 12.2067C4.05341 12.4667 4.05341 12.8867 3.79341 13.1467L3.70675 13.2334C3.58008 13.3601 3.40675 13.4267 3.24008 13.4267ZM14.6667 8.66675H14.6134C14.2467 8.66675 13.9467 8.36675 13.9467 8.00008C13.9467 7.63341 14.2467 7.33342 14.6134 7.33342C14.9801 7.33342 15.3067 7.63341 15.3067 8.00008C15.3067 8.36675 15.0334 8.66675 14.6667 8.66675ZM1.38675 8.66675H1.33341C0.966748 8.66675 0.666748 8.36675 0.666748 8.00008C0.666748 7.63341 0.966748 7.33342 1.33341 7.33342C1.70008 7.33342 2.02675 7.63341 2.02675 8.00008C2.02675 8.36675 1.75341 8.66675 1.38675 8.66675ZM12.6734 3.99341C12.5001 3.99341 12.3334 3.92675 12.2001 3.80008C11.9401 3.54008 11.9401 3.12008 12.2001 2.86008L12.2867 2.77341C12.5467 2.51341 12.9667 2.51341 13.2267 2.77341C13.4867 3.03341 13.4867 3.45341 13.2267 3.71341L13.1401 3.80008C13.0134 3.92675 12.8467 3.99341 12.6734 3.99341ZM3.32675 3.99341C3.15341 3.99341 2.98675 3.92675 2.85342 3.80008L2.76675 3.70675C2.50675 3.44675 2.50675 3.02675 2.76675 2.76675C3.02675 2.50675 3.44675 2.50675 3.70675 2.76675L3.79341 2.85342C4.05341 3.11342 4.05341 3.53341 3.79341 3.79341C3.66675 3.92675 3.49341 3.99341 3.32675 3.99341ZM8.00008 2.02675C7.63341 2.02675 7.33342 1.75341 7.33342 1.38675V1.33341C7.33342 0.966748 7.63341 0.666748 8.00008 0.666748C8.36675 0.666748 8.66675 0.966748 8.66675 1.33341C8.66675 1.70008 8.36675 2.02675 8.00008 2.02675Z"
|
||||
fill="#969AA1"
|
||||
/>
|
||||
</svg>;
|
||||
|
||||
export const DarkIcon = () => <svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M14.3533 10.62C14.2466 10.44 13.9466 10.16 13.1999 10.2933C12.7866 10.3667 12.3666 10.4 11.9466 10.38C10.3933 10.3133 8.98659 9.6 8.00659 8.5C7.13993 7.53333 6.60659 6.27333 6.59993 4.91333C6.59993 4.15333 6.74659 3.42 7.04659 2.72666C7.33993 2.05333 7.13326 1.7 6.98659 1.55333C6.83326 1.4 6.47326 1.18666 5.76659 1.48C3.03993 2.62666 1.35326 5.36 1.55326 8.28666C1.75326 11.04 3.68659 13.3933 6.24659 14.28C6.85993 14.4933 7.50659 14.62 8.17326 14.6467C8.27993 14.6533 8.38659 14.66 8.49326 14.66C10.7266 14.66 12.8199 13.6067 14.1399 11.8133C14.5866 11.1933 14.4666 10.8 14.3533 10.62Z"
|
||||
fill="#969AA1"
|
||||
/>
|
||||
</svg>;
|
29
packages/frontend/src/components/mini/icons/SidebarIcons.tsx
Normal file
29
packages/frontend/src/components/mini/icons/SidebarIcons.tsx
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
export const HamburgerGoBackIcon = () => <svg
|
||||
className="fill-current"
|
||||
width="20"
|
||||
height="18"
|
||||
viewBox="0 0 20 18"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M19 8.175H2.98748L9.36248 1.6875C9.69998 1.35 9.69998 0.825 9.36248 0.4875C9.02498 0.15 8.49998 0.15 8.16248 0.4875L0.399976 8.3625C0.0624756 8.7 0.0624756 9.225 0.399976 9.5625L8.16248 17.4375C8.31248 17.5875 8.53748 17.7 8.76248 17.7C8.98748 17.7 9.17498 17.625 9.36248 17.475C9.69998 17.1375 9.69998 16.6125 9.36248 16.275L3.02498 9.8625H19C19.45 9.8625 19.825 9.4875 19.825 9.0375C19.825 8.55 19.45 8.175 19 8.175Z"
|
||||
fill=""
|
||||
/>
|
||||
</svg>;
|
43
packages/frontend/src/components/mini/icons/UserIcons.tsx
Normal file
43
packages/frontend/src/components/mini/icons/UserIcons.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
import { ReactNode, useState } from "react";
|
||||
import { FaUserShield, FaUserSlash, FaUserLock } from "react-icons/fa6";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const UseHover = ({ children, hover }: { children: ReactNode, hover: ReactNode }) => {
|
||||
const [isHovered, setIsHovered] = useState(true);
|
||||
|
||||
|
||||
return <div className={"inline"} onMouseEnter={() => setIsHovered(false)} onMouseLeave={() => setIsHovered(true)}>
|
||||
{isHovered ? children : hover}
|
||||
</div>
|
||||
}
|
||||
|
||||
export const UserIcons = ({ flags }: { flags: string[] }) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
return <> { flags.includes('administrator') &&
|
||||
<UseHover hover={ <button
|
||||
className="inline-flex rounded-full bg-[#DC3545] py-1 px-3 text-sm font-medium text-white hover:bg-opacity-90">{t("icons.admin")}</button> }><FaUserShield
|
||||
className={ "inline text-meta-1 ml-1" }/></UseHover> } { flags.includes("leaderboard_hidden") &&
|
||||
<UseHover hover={ <button
|
||||
className="inline-flex rounded-full bg-[#F9C107] py-1 px-3 text-sm font-medium text-[#212B36] hover:bg-opacity-90">{t("icons.leaderboard_hidden")}</button> }><FaUserLock
|
||||
className={ "inline text-meta-6 ml-1" }/></UseHover> } { flags.includes("hidden") &&
|
||||
<UseHover hover={ <button
|
||||
className="inline-flex rounded-full bg-[#DC3545] py-1 px-3 text-sm font-medium text-white hover:bg-opacity-90">{ t("icons.hidden") }</button> }>
|
||||
<FaUserSlash className={ "inline text-meta-1 ml-1" }/></UseHover> }</>;
|
||||
};
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { ErrorAlertIcon } from "../icons/AlertIcons.tsx";
|
||||
|
||||
export const LoadError = () =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
return <div
|
||||
className="flex w-full border-l-6 border-[#F87171] bg-[#F87171] bg-opacity-[15%] dark:bg-[#1B1B24] px-7 py-8 shadow-md dark:bg-opacity-30 md:p-9">
|
||||
<div className="mr-5 flex h-9 w-full max-w-[36px] items-center justify-center rounded-lg bg-[#F87171]">
|
||||
<ErrorAlertIcon/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<h5 className="mb-3 font-semibold text-[#B45454]">
|
||||
{ t("content_loader.error.header") }
|
||||
</h5>
|
||||
<ul>
|
||||
<li className="leading-relaxed text-[#CD5D5D]">
|
||||
{ t("content_loader.error.description") }
|
||||
</li>
|
||||
<li className="leading-relaxed text-[#CD5D5D]">
|
||||
<div className="pt-4">
|
||||
{/* TODO: add git issue params */ }
|
||||
<div className="mb-7.5 flex flex-wrap gap-4">
|
||||
<Link
|
||||
className="inline-flex items-center justify-center rounded-md bg-primary py-2 px-8 text-center font-medium text-white hover:bg-opacity-70 lg:px-6 xl:px-8"
|
||||
to="https://git.alekswilc.dev/simrail/simrail.pro/issues/new">{ t("content_loader.error.report") }</Link>
|
||||
|
||||
<Link
|
||||
className="inline-flex items-center justify-center rounded-md bg-primary py-2 px-8 text-center font-medium text-white hover:bg-opacity-70 lg:px-6 xl:px-8"
|
||||
to="#"
|
||||
onClick={ () => window.location.reload() }>{ t("content_loader.error.refresh") }</Link>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>;
|
||||
};
|
||||
|
||||
export const ContentLoader = () =>
|
||||
{
|
||||
const [ error, setError ] = useState(false);
|
||||
useEffect(() =>
|
||||
{
|
||||
new Promise(res => setTimeout(res, 5000)).then(() =>
|
||||
{
|
||||
setError(true);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{ error ? <LoadError/> : <div
|
||||
className="flex h-screen items-center justify-center shadow-default bg-white dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="h-16 w-16 animate-spin rounded-full border-4 border-solid border-primary border-t-transparent"/>
|
||||
</div> }
|
||||
</>
|
||||
);
|
||||
};
|
24
packages/frontend/src/components/mini/loaders/PageLoader.tsx
Normal file
24
packages/frontend/src/components/mini/loaders/PageLoader.tsx
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
export const Loader = () =>
|
||||
{
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center bg-black">
|
||||
<div className="h-16 w-16 animate-spin rounded-full border-4 border-solid border-primary border-t-transparent"/>
|
||||
</div>
|
||||
);
|
||||
};
|
89
packages/frontend/src/components/mini/modal/ConfirmModal.tsx
Normal file
89
packages/frontend/src/components/mini/modal/ConfirmModal.tsx
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
|
||||
export const ConfirmModal = ({ showModal, setShowModal, onConfirm, title, description }: {
|
||||
showModal: boolean;
|
||||
setShowModal: Dispatch<SetStateAction<boolean>>;
|
||||
onConfirm: () => void;
|
||||
title: string;
|
||||
description: string;
|
||||
}) =>
|
||||
{
|
||||
|
||||
return (
|
||||
<>
|
||||
{ showModal ? (
|
||||
<>
|
||||
<div
|
||||
className="justify-center items-center flex overflow-x-hidden overflow-y-auto fixed inset-0 z-50 outline-none focus:outline-none"
|
||||
>
|
||||
<div className="relative w-auto my-6 mx-auto max-w-3xl">
|
||||
|
||||
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-strokedark outline-none focus:outline-none">
|
||||
|
||||
<div className="flex items-start justify-between p-5">
|
||||
<h3 className="text-3xl font-semibold text-meta-2">
|
||||
{ title }
|
||||
</h3>
|
||||
<button
|
||||
className="p-1 ml-auto bg-transparent border-0 text-meta-2 opacity-5 float-right text-3xl leading-none font-semibold outline-none focus:outline-none"
|
||||
onClick={ () => setShowModal(false) }
|
||||
>
|
||||
<span className="bg-transparent text-meta-2 opacity-5 h-6 w-6 text-2xl block outline-none focus:outline-none">
|
||||
×
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="relative p-6 flex-auto">
|
||||
<p className="my-4 text-blueGray-500 text-lg leading-relaxed text-meta-2">
|
||||
{ description }
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex items-center justify-end p-6 rounded-b">
|
||||
<button
|
||||
className="text-red-500 background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
|
||||
type="button"
|
||||
onClick={ () => setShowModal(false) }
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
<button
|
||||
className="bg-emerald-500 text-white active:bg-emerald-600 font-bold uppercase text-sm px-6 py-3 rounded shadow hover:shadow-lg outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
|
||||
type="button"
|
||||
onClick={ () =>
|
||||
{
|
||||
setShowModal(false);
|
||||
onConfirm();
|
||||
} }
|
||||
>
|
||||
Confirm
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="opacity-25 fixed inset-0 z-40 bg-black"></div>
|
||||
</>
|
||||
) : null }
|
||||
</>
|
||||
);
|
||||
};
|
323
packages/frontend/src/components/mini/sidebar/Sidebar.tsx
Normal file
323
packages/frontend/src/components/mini/sidebar/Sidebar.tsx
Normal file
@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { NavLink, useLocation } from "react-router-dom";
|
||||
import SidebarLinkGroup from "./SidebarLinkGroup.tsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { HamburgerGoBackIcon } from "../icons/SidebarIcons.tsx";
|
||||
import { ArrowIcon } from "../icons/ArrowIcon.tsx";
|
||||
import { FaHome, FaClipboardList } from "react-icons/fa";
|
||||
import { FaChartSimple, FaTrain, FaBuildingFlag, FaBolt, FaUsers } from "react-icons/fa6";
|
||||
import { useAuth } from "../../../hooks/useAuth.tsx";
|
||||
|
||||
interface SidebarProps
|
||||
{
|
||||
sidebarOpen: boolean;
|
||||
setSidebarOpen: (arg: boolean) => void;
|
||||
}
|
||||
|
||||
export const Sidebar = ({ sidebarOpen, setSidebarOpen }: SidebarProps) =>
|
||||
{
|
||||
const location = useLocation();
|
||||
const { pathname } = location;
|
||||
|
||||
const trigger = useRef<any>(null);
|
||||
const sidebar = useRef<any>(null);
|
||||
|
||||
const storedSidebarExpanded = localStorage.getItem("sidebar-expanded");
|
||||
const [ sidebarExpanded, setSidebarExpanded ] = useState(
|
||||
storedSidebarExpanded === null ? false : storedSidebarExpanded === "true",
|
||||
);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
// close on click outside
|
||||
useEffect(() =>
|
||||
{
|
||||
const clickHandler = ({ target }: MouseEvent) =>
|
||||
{
|
||||
if (!sidebar.current || !trigger.current)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!sidebarOpen ||
|
||||
sidebar.current.contains(target) ||
|
||||
trigger.current.contains(target)
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setSidebarOpen(false);
|
||||
};
|
||||
document.addEventListener("click", clickHandler);
|
||||
return () => document.removeEventListener("click", clickHandler);
|
||||
});
|
||||
|
||||
// close if the esc key is pressed
|
||||
useEffect(() =>
|
||||
{
|
||||
const keyHandler = ({ keyCode }: KeyboardEvent) =>
|
||||
{
|
||||
if (!sidebarOpen || keyCode !== 27)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setSidebarOpen(false);
|
||||
};
|
||||
document.addEventListener("keydown", keyHandler);
|
||||
return () => document.removeEventListener("keydown", keyHandler);
|
||||
});
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
localStorage.setItem("sidebar-expanded", sidebarExpanded.toString());
|
||||
if (sidebarExpanded)
|
||||
{
|
||||
document.querySelector("body")?.classList.add("sidebar-expanded");
|
||||
}
|
||||
else
|
||||
{
|
||||
document.querySelector("body")?.classList.remove("sidebar-expanded");
|
||||
}
|
||||
}, [ sidebarExpanded ]);
|
||||
|
||||
const { isAdmin, username } = useAuth();
|
||||
|
||||
return (
|
||||
<aside
|
||||
ref={ sidebar }
|
||||
className={ `absolute left-0 top-0 z-9999 flex h-screen w-72.5 flex-col overflow-y-hidden bg-black duration-300 ease-linear dark:bg-boxdark lg:static lg:translate-x-0 ${ sidebarOpen ? "translate-x-0" : "-translate-x-full"
|
||||
}` }
|
||||
>
|
||||
{/* <!-- SIDEBAR HEADER --> */ }
|
||||
<div className="flex items-center justify-between gap-2 px-6 py-5.5 lg:py-6.5">
|
||||
<button
|
||||
ref={ trigger }
|
||||
onClick={ () => setSidebarOpen(!sidebarOpen) }
|
||||
aria-controls="sidebar"
|
||||
aria-expanded={ sidebarOpen }
|
||||
className="block lg:hidden"
|
||||
>
|
||||
<HamburgerGoBackIcon/>
|
||||
</button>
|
||||
</div>
|
||||
{/* <!-- SIDEBAR HEADER --> */ }
|
||||
|
||||
<div className="no-scrollbar flex flex-col overflow-y-auto duration-300 ease-linear">
|
||||
<nav className="mt-5 py-4 px-4 lg:mt-9 lg:px-6">
|
||||
<div>
|
||||
<ul className="mb-6 flex flex-col gap-1.5">
|
||||
<li>
|
||||
<NavLink
|
||||
to="/"
|
||||
className={ `group relative flex items-center gap-2.5 rounded-sm py-2 px-4 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4 ${ pathname === "/" &&
|
||||
"bg-graydark dark:bg-meta-4"
|
||||
}` }
|
||||
>
|
||||
<FaHome/>
|
||||
{ t("sidebar.home") }
|
||||
</NavLink>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
<ul className="mb-6 flex flex-col gap-1.5">
|
||||
<h3 className="mb-4 ml-4 text-sm font-semibold text-bodydark2">
|
||||
{ t("sidebar.info") }
|
||||
</h3>
|
||||
|
||||
<li>
|
||||
<NavLink
|
||||
to="/profiles"
|
||||
className={ `group relative flex items-center gap-2.5 rounded-sm py-2 px-4 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4 ${ pathname === "/profiles" &&
|
||||
"bg-graydark dark:bg-meta-4"
|
||||
}` }
|
||||
>
|
||||
<FaUsers/>
|
||||
{ t("sidebar.profiles") }
|
||||
</NavLink>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<NavLink
|
||||
to="/leaderboard"
|
||||
className={ `group relative flex items-center gap-2.5 rounded-sm py-2 px-4 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4 ${ pathname.includes("/leaderboard") &&
|
||||
"bg-graydark dark:bg-meta-4"
|
||||
}` }
|
||||
>
|
||||
<FaChartSimple/>
|
||||
{ t("sidebar.leaderboard") }
|
||||
</NavLink>
|
||||
</li>
|
||||
|
||||
<SidebarLinkGroup
|
||||
isOpen={ true }
|
||||
activeCondition={
|
||||
pathname === "/logs" || pathname.includes("logs")
|
||||
}
|
||||
>
|
||||
{ (handleClick, open) =>
|
||||
{
|
||||
return (
|
||||
<React.Fragment>
|
||||
<NavLink
|
||||
to="#"
|
||||
className={ `group relative flex items-center gap-2.5 rounded-sm py-2 px-4 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4 ${ (pathname === "/logs" ||
|
||||
pathname.includes("logs")) &&
|
||||
"bg-graydark dark:bg-meta-4"
|
||||
}` }
|
||||
onClick={ (e) =>
|
||||
{
|
||||
e.preventDefault();
|
||||
sidebarExpanded
|
||||
? handleClick()
|
||||
: setSidebarExpanded(true);
|
||||
} }
|
||||
>
|
||||
<FaClipboardList/>
|
||||
{ t("sidebar.logs") }
|
||||
<ArrowIcon rotated={ open }/>
|
||||
</NavLink>
|
||||
|
||||
<div
|
||||
className={ `translate transform overflow-hidden ${ !open && "hidden"
|
||||
}` }
|
||||
>
|
||||
<ul className="mt-4 mb-5.5 flex flex-col gap-2.5 pl-6">
|
||||
<li>
|
||||
<NavLink
|
||||
to="/logs/stations"
|
||||
className={ ({ isActive }) =>
|
||||
"group relative flex items-center gap-2.5 rounded-md px-4 font-medium text-bodydark2 duration-300 ease-in-out hover:text-white " +
|
||||
(isActive && "!text-white")
|
||||
}
|
||||
>
|
||||
<FaBuildingFlag/>
|
||||
{ t("sidebar.stations") }
|
||||
</NavLink>
|
||||
</li>
|
||||
<li>
|
||||
<NavLink
|
||||
to="/logs/trains"
|
||||
className={ ({ isActive }) =>
|
||||
"group relative flex items-center gap-2.5 rounded-md px-4 font-medium text-bodydark2 duration-300 ease-in-out hover:text-white " +
|
||||
(isActive && "!text-white")
|
||||
}
|
||||
>
|
||||
<FaTrain/>
|
||||
{ t("sidebar.trains") }
|
||||
</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
} }
|
||||
</SidebarLinkGroup>
|
||||
|
||||
<SidebarLinkGroup
|
||||
isOpen={ true }
|
||||
|
||||
activeCondition={
|
||||
pathname === "/active/trains" || pathname.includes("active/trains")
|
||||
}
|
||||
>
|
||||
{ (handleClick, open) =>
|
||||
{
|
||||
return (
|
||||
<React.Fragment>
|
||||
<NavLink
|
||||
to="#"
|
||||
className={ `group relative flex items-center gap-2.5 rounded-sm py-2 px-4 font-medium text-bodydark1 duration-300 ease-in-out hover:bg-graydark dark:hover:bg-meta-4 ${ (pathname === "/active" ||
|
||||
pathname.includes("/active/")) &&
|
||||
"bg-graydark dark:bg-meta-4"
|
||||
}` }
|
||||
onClick={ (e) =>
|
||||
{
|
||||
e.preventDefault();
|
||||
sidebarExpanded
|
||||
? handleClick()
|
||||
: setSidebarExpanded(true);
|
||||
} }
|
||||
>
|
||||
<FaBolt/>
|
||||
{ t("sidebar.active_players") }
|
||||
<ArrowIcon rotated={ open }/>
|
||||
</NavLink>
|
||||
<div
|
||||
className={ `translate transform overflow-hidden ${ !open && "hidden"
|
||||
}` }
|
||||
>
|
||||
<ul className="mt-4 mb-5.5 flex flex-col gap-2.5 pl-6">
|
||||
<li>
|
||||
<NavLink
|
||||
to="/active/stations"
|
||||
className={ ({ isActive }) =>
|
||||
"group relative flex items-center gap-2.5 rounded-md px-4 font-medium text-bodydark2 duration-300 ease-in-out hover:text-white " +
|
||||
(isActive && "!text-white")
|
||||
}
|
||||
>
|
||||
<FaBuildingFlag/>
|
||||
{ t("sidebar.stations") }
|
||||
</NavLink>
|
||||
</li>
|
||||
<li>
|
||||
<NavLink
|
||||
to="/active/trains"
|
||||
className={ ({ isActive }) =>
|
||||
"group relative flex items-center gap-2.5 rounded-md px-4 font-medium text-bodydark2 duration-300 ease-in-out hover:text-white " +
|
||||
(isActive && "!text-white")
|
||||
}
|
||||
>
|
||||
<FaTrain/>
|
||||
{ t("sidebar.trains") }
|
||||
</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
} }
|
||||
</SidebarLinkGroup>
|
||||
</ul>
|
||||
|
||||
{ isAdmin && <ul className="mb-6 flex flex-col gap-1.5">
|
||||
<h3 className="ml-4 text-sm font-semibold text-bodydark2">
|
||||
{ t("sidebar.admin") }
|
||||
</h3>
|
||||
|
||||
<li>
|
||||
<p className="group relative flex items-center rounded-sm py-2 px-4 text-sm text-bodydark1 duration-300 ease-in-out ">{ t("sidebar.logged", { username }) }</p>
|
||||
</li>
|
||||
<button onClick={ () =>
|
||||
{
|
||||
window.localStorage.setItem("auth_token", "undefined");
|
||||
window.location.reload();
|
||||
} }
|
||||
className="inline-flex items-center justify-center rounded-md bg-primary py-2 px-8 text-center text-sm text-white hover:bg-opacity-90 lg:px-8 xl:px-10"
|
||||
>{ t("sidebar.logout") }
|
||||
</button>
|
||||
|
||||
</ul> }
|
||||
</div>
|
||||
</nav>
|
||||
{/* <!-- Sidebar Menu --> */ }
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
};
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { ReactNode, useState } from "react";
|
||||
|
||||
interface SidebarLinkGroupProps
|
||||
{
|
||||
children: (handleClick: () => void, open: boolean) => ReactNode;
|
||||
activeCondition: boolean;
|
||||
isOpen: boolean;
|
||||
}
|
||||
|
||||
const SidebarLinkGroup = ({ children, activeCondition, isOpen }: SidebarLinkGroupProps) =>
|
||||
{
|
||||
const [ open, setOpen ] = useState<boolean>(isOpen ?? activeCondition);
|
||||
|
||||
const handleClick = () =>
|
||||
{
|
||||
setOpen(!open);
|
||||
};
|
||||
|
||||
return <li>{ children(handleClick, open) }</li>;
|
||||
};
|
||||
|
||||
export default SidebarLinkGroup;
|
88
packages/frontend/src/components/mini/util/CardDataStats.tsx
Normal file
88
packages/frontend/src/components/mini/util/CardDataStats.tsx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
interface CardDataStatsProps
|
||||
{
|
||||
title: string;
|
||||
total: string | number;
|
||||
rate?: string;
|
||||
levelUp?: boolean;
|
||||
levelDown?: boolean;
|
||||
}
|
||||
|
||||
export const CardDataStats: React.FC<CardDataStatsProps> = ({
|
||||
title,
|
||||
total,
|
||||
rate,
|
||||
levelUp,
|
||||
levelDown,
|
||||
}) =>
|
||||
{
|
||||
return (
|
||||
<div className="rounded-sm border border-stroke bg-white py-6 px-7.5 shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
|
||||
<div className="mt-4 flex items-end justify-between">
|
||||
<div>
|
||||
<h4 className="text-title-md font-bold text-black dark:text-white">
|
||||
{ total }
|
||||
</h4>
|
||||
<span className="text-sm font-medium">{ title }</span>
|
||||
</div>
|
||||
|
||||
{ rate && <span
|
||||
className={ `flex items-center gap-1 text-sm font-medium ${
|
||||
levelUp && "text-meta-3"
|
||||
} ${ levelDown && "text-meta-5" } ` }
|
||||
>
|
||||
{ rate }
|
||||
|
||||
{ levelUp && (
|
||||
<svg
|
||||
className="fill-meta-3"
|
||||
width="10"
|
||||
height="11"
|
||||
viewBox="0 0 10 11"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M4.35716 2.47737L0.908974 5.82987L5.0443e-07 4.94612L5 0.0848689L10 4.94612L9.09103 5.82987L5.64284 2.47737L5.64284 10.0849L4.35716 10.0849L4.35716 2.47737Z"
|
||||
fill=""
|
||||
/>
|
||||
</svg>
|
||||
) }
|
||||
{ levelDown && (
|
||||
<svg
|
||||
className="fill-meta-5"
|
||||
width="10"
|
||||
height="11"
|
||||
viewBox="0 0 10 11"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M5.64284 7.69237L9.09102 4.33987L10 5.22362L5 10.0849L-8.98488e-07 5.22362L0.908973 4.33987L4.35716 7.69237L4.35716 0.0848701L5.64284 0.0848704L5.64284 7.69237Z"
|
||||
fill=""
|
||||
/>
|
||||
</svg>
|
||||
) }
|
||||
</span> }
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
46
packages/frontend/src/components/mini/util/PageMeta.tsx
Normal file
46
packages/frontend/src/components/mini/util/PageMeta.tsx
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Helmet } from "react-helmet-async";
|
||||
|
||||
// https://dev.to/facubotta/meta-data-in-react-1p93
|
||||
export const PageMeta = ({ title = "", description = "", image = "", name = "" }) =>
|
||||
{
|
||||
return (
|
||||
<Helmet>
|
||||
{ /* Standard metadata tags */ }
|
||||
<title>{ title }</title>
|
||||
<link rel="canonical" href={ window.location.href }/>
|
||||
<meta name="description" content={ description }/>
|
||||
{ /* Open Graph tags (OG) */ }
|
||||
<meta property="og:url" content={ window.location.href }/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<meta property="og:title" content={ title }/>
|
||||
<meta property="og:description" content={ description }/>
|
||||
{/* OG image tags */ }
|
||||
<meta property="og:image" content={ image }/>
|
||||
<meta property="og:image:secure_url" content={ image }/>
|
||||
<meta property="og:image:type" content="image/jpeg"/>
|
||||
<meta property="og:image:width" content="200"/>
|
||||
<meta property="og:image:alt" content={ `Image of ${ title } site` }/>
|
||||
{ /* Twitter tags */ }
|
||||
{ name && <meta name="twitter:creator" content={ name }/> }
|
||||
<meta name="twitter:card" content="summary"/>
|
||||
<meta name="twitter:title" content={ title }/>
|
||||
<meta name="twitter:description" content={ description }/>
|
||||
</Helmet>
|
||||
);
|
||||
};
|
78
packages/frontend/src/components/mini/util/Paginator.tsx
Normal file
78
packages/frontend/src/components/mini/util/Paginator.tsx
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
|
||||
export const Paginator = ({ page, setPage, pages }: {
|
||||
page: number,
|
||||
pages: number,
|
||||
setPage: Dispatch<SetStateAction<number>>
|
||||
}) =>
|
||||
{
|
||||
let numbers = [ 1, page - 2, page - 1, page, page + 1, page + 2 ];
|
||||
|
||||
page === 1 && (numbers = [ page, page + 1, page + 2, page + 3, page + 4 ]);
|
||||
|
||||
page === 2 && (numbers = [ page - 1, page, page + 1, page + 2, page + 3 ]);
|
||||
|
||||
page === 3 && (numbers = [ page - 2, page - 1, page, page + 1, page + 2 ]);
|
||||
|
||||
(page === pages) && (numbers = [ 1, page - 4, page - 3, page - 2, page - 1 ]);
|
||||
|
||||
(page === (pages - 1)) && (numbers = [ 1, page - 3, page - 2, page - 1, page ]);
|
||||
|
||||
(page === (pages - 2)) && (numbers = [ 1, page - 2, page - 1, page, page + 1 ]);
|
||||
|
||||
numbers = numbers.filter(x => (pages + 1) >= x && x > 0);
|
||||
|
||||
return <div
|
||||
className="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark flex flex-row align-center justify-center p-2">
|
||||
<ul className="flex flex-wrap items-center">
|
||||
<li>
|
||||
<a className="cursor-pointer flex h-9 w-9 items-center justify-center rounded-l-md border border-stroke hover:border-primary hover:bg-gray hover:text-primary dark:border-strokedark dark:hover:border-primary dark:hover:bg-graydark"
|
||||
onClick={ () => setPage(page => (page - 1) < 1 ? 1 : page - 1) }>
|
||||
<svg className="fill-current" width="8" height="16" viewBox="0 0 8 16" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.17578 15.1156C7.00703 15.1156 6.83828 15.0593 6.72578 14.9187L0.369531 8.44995C0.116406 8.19683 0.116406 7.80308 0.369531 7.54995L6.72578 1.0812C6.97891 0.828076 7.37266 0.828076 7.62578 1.0812C7.87891 1.33433 7.87891 1.72808 7.62578 1.9812L1.71953 7.99995L7.65391 14.0187C7.90703 14.2718 7.90703 14.6656 7.65391 14.9187C7.48516 15.0312 7.34453 15.1156 7.17578 15.1156Z"
|
||||
fill=""></path>
|
||||
</svg>
|
||||
</a></li>
|
||||
|
||||
{ numbers.map(num =>
|
||||
{
|
||||
return <li>
|
||||
<a onClick={ () => setPage(num) }
|
||||
className={ `cursor-pointer flex items-center justify-center border border-stroke border-l-transparent py-[5px] px-4 font-medium hover:border-primary hover:bg-gray hover:text-primary dark:border-strokedark dark:hover:border-primary dark:hover:bg-graydark select-none ${ page === num && "text-primary border-primary dark:border-primary" }` }>{ num }</a>
|
||||
</li>;
|
||||
}) }
|
||||
|
||||
{ !!pages && <li>
|
||||
<a className={ `cursor-pointer flex items-center justify-center border border-stroke border-l-transparent py-[5px] px-4 font-medium hover:border-primary hover:bg-gray hover:text-primary dark:border-strokedark dark:hover:border-primary dark:hover:bg-graydark select-none ${ page === pages && "text-primary border-primary dark:border-primary" }` }
|
||||
onClick={ () => setPage(pages) }>{ pages }</a></li> }
|
||||
<li>
|
||||
<a className="cursor-pointer flex h-9 w-9 items-center justify-center rounded-r-md border border-stroke border-l-transparent hover:border-primary hover:bg-gray hover:text-primary dark:border-strokedark dark:hover:border-primary dark:hover:bg-graydark select-none"
|
||||
onClick={ () => setPage(page => (page + 1) > pages ? pages : page + 1) }>
|
||||
<svg className="fill-current" width="8" height="16" viewBox="0 0 8 16" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0.819531 15.1156C0.650781 15.1156 0.510156 15.0593 0.369531 14.9468C0.116406 14.6937 0.116406 14.3 0.369531 14.0468L6.27578 7.99995L0.369531 1.9812C0.116406 1.72808 0.116406 1.33433 0.369531 1.0812C0.622656 0.828076 1.01641 0.828076 1.26953 1.0812L7.62578 7.54995C7.87891 7.80308 7.87891 8.19683 7.62578 8.44995L1.26953 14.9187C1.15703 15.0312 0.988281 15.1156 0.819531 15.1156Z"
|
||||
fill="">
|
||||
</path>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>;
|
||||
};
|
122
packages/frontend/src/components/mini/util/Search.tsx
Normal file
122
packages/frontend/src/components/mini/util/Search.tsx
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { ChangeEventHandler, Dispatch, ReactNode, SetStateAction } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export const SearchWithServerSelector = ({ searchItem, handleInputChange, children, servers, server, setServer }: {
|
||||
searchItem: string;
|
||||
handleInputChange: ChangeEventHandler,
|
||||
children?: ReactNode
|
||||
servers: string[];
|
||||
server: string;
|
||||
setServer: Dispatch<SetStateAction<string>>
|
||||
}) =>
|
||||
{
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
return <>
|
||||
<div
|
||||
className="col-span-12 rounded-sm border border-stroke bg-white px-5 p-5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:col-span-8">
|
||||
<div className="flex flex-col gap-6 xl:flex-row items-center justify-center">
|
||||
<div className="w-full xl:w-1/2 grow">
|
||||
<input onChange={ handleInputChange }
|
||||
value={ searchItem }
|
||||
type="text" placeholder={ t("search.placeholder_with_station") }
|
||||
className="w-full rounded border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary"/>
|
||||
</div>
|
||||
{ servers?.length &&
|
||||
<div className="items-center justify-center flex gap-2 flex-wrap">
|
||||
{
|
||||
servers.map(x =>
|
||||
{
|
||||
return <a
|
||||
onClick={ () =>
|
||||
{
|
||||
setServer(x);
|
||||
} }
|
||||
className={ `cursor-pointer inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ server === x ? "bg-opacity-50" : "" }` }>{ x.toUpperCase() }</a>;
|
||||
})
|
||||
}
|
||||
|
||||
<a
|
||||
onClick={ () =>
|
||||
{
|
||||
setServer(undefined!);
|
||||
} }
|
||||
className={ `cursor-pointer inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ !server ? "bg-opacity-50" : "" }` }>{ t("search.none") }</a>
|
||||
</div> }
|
||||
</div>
|
||||
|
||||
|
||||
{ children }
|
||||
</div>
|
||||
</>;
|
||||
};
|
||||
|
||||
export const Search = ({ searchItem, handleInputChange }: {
|
||||
searchItem: string;
|
||||
handleInputChange: ChangeEventHandler,
|
||||
}) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
return <>
|
||||
<div
|
||||
className="col-span-12 rounded-sm border border-stroke bg-white px-5 p-5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:col-span-8">
|
||||
<div className="flex flex-col gap-6 xl:flex-row items-center justify-center">
|
||||
<div className="w-full xl:w-1/2 grow">
|
||||
<input onChange={ handleInputChange }
|
||||
value={ searchItem }
|
||||
type="text" placeholder={ t("search.placeholder") }
|
||||
className="w-full rounded border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</>;
|
||||
};
|
||||
|
||||
export const SearchWithChild = ({ searchItem, handleInputChange, children }: {
|
||||
searchItem: string;
|
||||
handleInputChange: ChangeEventHandler,
|
||||
children: ReactNode
|
||||
}) =>
|
||||
{
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
return <>
|
||||
<div
|
||||
className="col-span-12 rounded-sm border border-stroke bg-white px-5 pt-7.5 pb-5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 xl:col-span-8">
|
||||
{ children }
|
||||
|
||||
<div className="mt-5 flex flex-col gap-6 xl:flex-row items-center justify-center">
|
||||
<div className="w-full xl:w-1/2 grow">
|
||||
<input onChange={ handleInputChange }
|
||||
value={ searchItem }
|
||||
type="text" placeholder={ t("search.placeholder") }
|
||||
className="w-full rounded border-[1.5px] border-stroke bg-transparent px-5 py-3 font-normal text-black outline-none transition focus:border-primary active:border-primary disabled:cursor-default disabled:bg-whiter dark:border-form-strokedark dark:bg-form-input dark:text-white dark:focus:border-primary"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</>;
|
||||
};
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { TActiveStationPlayersData } from "../../../types/active.ts";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
export const ActiveStationTable = ({ stations }: { stations: TActiveStationPlayersData[] }) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
const report = (data: TActiveStationPlayersData) =>
|
||||
{
|
||||
toast.info(t("log.toasts.report"), {
|
||||
autoClose: 5000,
|
||||
});
|
||||
void navigator.clipboard.writeText(`;user: \`${ data.player.username }\`\n;steam: \`https://steamcommunity.com/profiles/${ data.player.id }\`\n;server: \`${ data.server.toUpperCase() }\`\n;station: \`${ data.stationName }\`\n;link: https://${ location.hostname }/profile/${data.player.id}\n\n`);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-7.5 sm:grid-cols-3 xl:grid-cols-4">
|
||||
{ stations.map((station) =>
|
||||
{
|
||||
return <div
|
||||
key={ station.server + station.stationShort }
|
||||
className="flex flex-col align-center items-center rounded-sm border border-stroke bg-stroke shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="p-4">
|
||||
<img className="rounded-full" src={ station.player.avatar } alt="Player"/>
|
||||
</div>
|
||||
<div className="flex flex-col p-2 align-center items-center">
|
||||
<h4 className="mb-3 text-xl font-semibold text-black dark:text-white">
|
||||
{ station.player.username }
|
||||
<UserIcons flags={ station.player.flags }/>
|
||||
</h4>
|
||||
<p>{ t("log.station.station", { name: station.stationName, short: station.stationShort }) }</p>
|
||||
<p>{ t("log.station.server", { server: station.server.toUpperCase() }) }</p>
|
||||
</div>
|
||||
<div className="items-center justify-center p-2.5 flex xl:p-5 gap-2 flex-wrap mt-auto mb-2">
|
||||
<Link to={ "/profile/" + (station.steam ?? station.player.id) }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ station.player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ station.player.flags.includes("private") ? { pointerEvents: "none" } : undefined }>{ t("log.buttons.profile") }</Link>
|
||||
<a
|
||||
onClick={ () => report(station) }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-danger py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5"
|
||||
>
|
||||
{ t("log.buttons.report") }
|
||||
</a>
|
||||
</div>
|
||||
</div>;
|
||||
}) }
|
||||
</div>
|
||||
);
|
||||
};
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { TActiveTrainPlayersData } from "../../../types/active.ts";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
export const ActiveTrainTable = ({ trains }: {
|
||||
trains: TActiveTrainPlayersData[],
|
||||
}) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
const report = (data: TActiveTrainPlayersData) =>
|
||||
{
|
||||
toast.info(t("log.toasts.report"), {
|
||||
autoClose: 5000,
|
||||
});
|
||||
void navigator.clipboard.writeText(`;user: \`${ data.player.username }\`\n;steam: \`https://steamcommunity.com/profiles/${ data.player.id }\`\n;server: \`${ data.server.toUpperCase() }\`\n;train: \`${ data.trainNumber }\`\n;link: https://${ location.hostname }/profile/${ data.player.id }\n\n`);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-7.5 sm:grid-cols-3 xl:grid-cols-4">
|
||||
{ trains.map((train) =>
|
||||
{
|
||||
return <div
|
||||
key={ train.server + train.trainNumber }
|
||||
className="flex flex-col align-center items-center rounded-sm border border-stroke bg-stroke shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="p-4">
|
||||
<img className="rounded-full"
|
||||
src={ train.player.avatar }
|
||||
alt="Player"/>
|
||||
</div>
|
||||
<div className="flex flex-col p-2 align-center items-center">
|
||||
<h4 className="mb-3 text-xl font-semibold text-black dark:text-white">
|
||||
{ train.player.username }
|
||||
<UserIcons flags={ train.player.flags }/>
|
||||
</h4>
|
||||
<p>{ t("log.train.train", { name: train.trainName, number: train.trainNumber }) }</p>
|
||||
<p>{ t("log.train.server", { server: train.server.toUpperCase() }) }</p>
|
||||
</div>
|
||||
|
||||
<div className="items-center justify-center p-2.5 flex xl:p-5 gap-2 flex-wrap mt-auto mb-2">
|
||||
<Link to={ "/profile/" + (train.steam ?? train.player.id) }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ train.player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ train.player.flags.includes("private") ? { pointerEvents: "none" } : undefined }>{ t("log.buttons.profile") }</Link>
|
||||
<a
|
||||
onClick={ () => report(train) }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-danger py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5"
|
||||
>
|
||||
{ t("log.buttons.report") }
|
||||
</a>
|
||||
</div>
|
||||
</div>;
|
||||
}) }
|
||||
</div>
|
||||
);
|
||||
};
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { TLeaderboardRecord } from "../../../types/leaderboard.ts";
|
||||
import { formatTime } from "../../../util/time.ts";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
import { FaCrown } from "react-icons/fa6";
|
||||
|
||||
export const LeaderboardTable = ({ list, queryType, isUnmodified }: {
|
||||
list: TLeaderboardRecord[];
|
||||
queryType: string;
|
||||
isUnmodified?: boolean
|
||||
}) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-7.5 sm:grid-cols-3 xl:grid-cols-4">
|
||||
{ list.map((player, index) =>
|
||||
{
|
||||
return <div
|
||||
key={ player.id }
|
||||
className="flex flex-col align-center items-center rounded-sm border border-stroke shadow-default dark:border-strokedark dark:bg-boxdark bg-stroke">
|
||||
<div className="p-4">
|
||||
<img className="rounded-full"
|
||||
src={ player.avatar }
|
||||
alt="Player"/>
|
||||
</div>
|
||||
<div className="flex flex-col p-2 align-center items-center">
|
||||
<h4 className="mb-3 text-xl font-semibold text-black dark:text-white">
|
||||
{ player.username }
|
||||
<UserIcons flags={ player.flags }/>
|
||||
{ isUnmodified && index === 0 && <FaCrown className={ `inline text-gold ml-1` }/> }
|
||||
{ isUnmodified && index === 1 && <FaCrown className={ `inline text-silver ml-1` }/> }
|
||||
{ isUnmodified && index === 2 && <FaCrown className={ `inline text-bronze ml-1` }/> }
|
||||
</h4>
|
||||
{
|
||||
queryType === "train" ?
|
||||
<>
|
||||
<p className="break-words">{ t("leaderboard.train.distance", { distance: (player.trainDistance / 1000).toFixed(2) }) }</p>
|
||||
<p className="break-words">{ t("leaderboard.train.points", { points: player.trainPoints }) }</p>
|
||||
</>
|
||||
:
|
||||
<>
|
||||
<p>{ t("leaderboard.station.time", { time: formatTime(player.dispatcherTime) }) }</p>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div className="items-center justify-center p-2.5 flex xl:p-5 gap-2 flex-wrap sm:flex-nowrap mt-auto mb-2">
|
||||
<Link to={ "/profile/" + player.id }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ player.flags.includes("private") ? { pointerEvents: "none" } : undefined }>{ t("log.buttons.profile") }</Link>
|
||||
|
||||
</div>
|
||||
</div>;
|
||||
}) }
|
||||
</div>
|
||||
);
|
||||
};
|
100
packages/frontend/src/components/pages/log/StationLog.tsx
Normal file
100
packages/frontend/src/components/pages/log/StationLog.tsx
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TLogStationData } from "../../../types/log.ts";
|
||||
import dayjs from "dayjs";
|
||||
import { toast } from "react-toastify";
|
||||
import { Link } from "react-router-dom";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
|
||||
|
||||
export const StationLog = ({ data }: { data: TLogStationData }) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
const copyLink = () =>
|
||||
{
|
||||
void navigator.clipboard.writeText(location.href);
|
||||
toast.success(t("log.toasts.copied"));
|
||||
};
|
||||
|
||||
const report = () =>
|
||||
{
|
||||
toast.info(t("log.toasts.report"), {
|
||||
autoClose: 5000,
|
||||
});
|
||||
void navigator.clipboard.writeText(`;user: \`${ data.player.username }\`\n;steam: \`https://steamcommunity.com/profiles/${ data.player.id }\`\n;server: \`${ data.server.toUpperCase() }\`\n;left: <t:${ Math.floor(data.leftDate / 1000) }>${ data.joinedDate ? `\n;joined: <t:${ Math.floor(data.joinedDate / 1000) }>` : "" }\n;station: \`${ data.stationName }\`\n;link: ${ location.href }\n\n`);
|
||||
};
|
||||
|
||||
return <div
|
||||
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
|
||||
<div
|
||||
className="mx-auto max-w-44 rounded-full">
|
||||
<div className="relative">
|
||||
<img className="rounded-full"
|
||||
src={ data.player.avatar }
|
||||
alt="Player"/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<h3 className="mb-1.5 text-2xl font-semibold text-black dark:text-white">
|
||||
{ data.player.username } <UserIcons flags={ data.player.flags }/>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white px-5 pt-6 pb-5 shadow-default dark:bg-boxdark sm:px-7.5">
|
||||
<div className="flex flex-col sm:flex-row sm:flex-wrap sm:justify-end">
|
||||
<div className="flex flex-col">
|
||||
<h1 className="text-xl text-black dark:text-white pb-5">{ t("log.station.header") }</h1>
|
||||
<p>{ t("log.station.server", { server: data.server.toUpperCase() }) }</p>
|
||||
<p>{ t("log.station.station", { name: data.stationName, short: data.stationShort }) }</p>
|
||||
|
||||
{ data.joinedDate &&
|
||||
<p>{ t("log.station.joined", { date: dayjs(data.joinedDate).format("DD/MM/YYYY HH:mm") }) }</p> }
|
||||
<p>{ t("log.station.left", { date: dayjs(data.leftDate).format("DD/MM/YYYY HH:mm") }) }</p>
|
||||
{ data.joinedDate &&
|
||||
<p>{ t("log.station.spent", { date: dayjs.duration(data.leftDate - data.joinedDate).format("H[h] m[m]") }) }</p> }
|
||||
</div>
|
||||
<div className="flex flex-col gap-5 mt-5 sm:mt-0 sm:ml-auto">
|
||||
<a
|
||||
onClick={ report }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-meta-7 py-4 px-10 text-center font-medium text-white hover:bg-opacity-90 lg:px-8 xl:px-10"
|
||||
>
|
||||
{ t("log.buttons.report") }
|
||||
</a>
|
||||
|
||||
<a
|
||||
onClick={ copyLink }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-primary py-4 px-10 text-center font-medium text-white hover:bg-opacity-90 lg:px-8 xl:px-10"
|
||||
>
|
||||
|
||||
{ t("log.buttons.copy") }
|
||||
</a>
|
||||
<Link
|
||||
to={ "/profile/" + data.player.id }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-4 px-10 text-center font-medium text-white hover:bg-opacity-90 lg:px-8 xl:px-10 ${ data.player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ data.player.flags.includes("private") ? { pointerEvents: "none" } : undefined }>
|
||||
|
||||
{ t("log.buttons.profile") }
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
};
|
112
packages/frontend/src/components/pages/log/TrainLog.tsx
Normal file
112
packages/frontend/src/components/pages/log/TrainLog.tsx
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TLogTrainData } from "../../../types/log.ts";
|
||||
import dayjs from "dayjs";
|
||||
import { toast } from "react-toastify";
|
||||
import { Link } from "react-router-dom";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
|
||||
|
||||
export const TrainLog = ({ data }: { data: TLogTrainData }) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
const copyLink = () =>
|
||||
{
|
||||
void navigator.clipboard.writeText(location.href);
|
||||
toast.success(t("log.toasts.copied"));
|
||||
};
|
||||
|
||||
const report = () =>
|
||||
{
|
||||
toast.info(t("log.toasts.report"), {
|
||||
autoClose: 5000,
|
||||
});
|
||||
void navigator.clipboard.writeText(`;user: \`${ data.player.username }\`\n;steam: \`https://steamcommunity.com/profiles/${ data.player.id }\`\n;server: \`${ data.server.toUpperCase() }\`\n;left: <t:${ Math.floor(data.leftDate / 1000) }>${ data.joinedDate ? `\n;joined: <t:${ Math.floor(data.joinedDate / 1000) }>` : "" }\n;train: \`${ data.trainNumber }\`\n;link: ${ location.href }\n\n`);
|
||||
};
|
||||
|
||||
return <div
|
||||
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
|
||||
<div
|
||||
className="mx-auto max-w-44 rounded-full">
|
||||
<div className="relative">
|
||||
<img className="rounded-full"
|
||||
src={ data.player.avatar }
|
||||
alt="Player"/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<h3 className="mb-1.5 text-2xl font-semibold text-black dark:text-white">
|
||||
{ data.player.username } <UserIcons flags={ data.player.flags }/>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white px-5 pt-6 pb-5 shadow-default dark:bg-boxdark sm:px-7.5">
|
||||
<div className="flex flex-col sm:flex-row sm:flex-wrap sm:justify-end">
|
||||
<div className="flex flex-col">
|
||||
<h1 className="text-xl text-black dark:text-white pb-5">{ t("log.train.header") }</h1>
|
||||
<p>{ t("log.train.server", { server: data.server.toUpperCase() }) }</p>
|
||||
<p>{ t("log.train.train", { name: data.trainName, number: data.trainNumber }) }</p>
|
||||
|
||||
{
|
||||
!data.player.flags.includes("private") &&
|
||||
<>
|
||||
{ (data.distance || data.distance === 0) &&
|
||||
<p>{ t("log.train.distance", { distance: (data.distance / 1000).toFixed(2) }) }</p> }
|
||||
|
||||
{ (data.points || data.points === 0) &&
|
||||
<p>{ t("log.train.points", { points: data.points }) }</p> }
|
||||
</>
|
||||
}
|
||||
|
||||
{ data.joinedDate &&
|
||||
<p>{ t("log.train.joined", { date: dayjs(data.joinedDate).format("DD/MM/YYYY HH:mm") }) }</p> }
|
||||
<p>{ t("log.train.left", { date: dayjs(data.leftDate).format("DD/MM/YYYY HH:mm") }) }</p>
|
||||
{ data.joinedDate &&
|
||||
<p>{ t("log.train.spent", { date: dayjs.duration(data.leftDate - data.joinedDate).format("H[h] m[m]") }) }</p> }
|
||||
</div>
|
||||
<div className="flex flex-col gap-5 mt-5 sm:mt-0 sm:ml-auto">
|
||||
<a
|
||||
onClick={ report }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-meta-7 py-4 px-10 text-center font-medium text-white hover:bg-opacity-90 lg:px-8 xl:px-10"
|
||||
>
|
||||
{ t("log.buttons.report") }
|
||||
</a>
|
||||
|
||||
<a
|
||||
onClick={ copyLink }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-primary py-4 px-10 text-center font-medium text-white hover:bg-opacity-90 lg:px-8 xl:px-10"
|
||||
>
|
||||
|
||||
{ t("log.buttons.copy") }
|
||||
</a>
|
||||
<Link
|
||||
to={ "/profile/" + data.player.id }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-4 px-10 text-center font-medium text-white hover:bg-opacity-90 lg:px-8 xl:px-10 ${ data.player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ data.player.flags.includes("private") ? { pointerEvents: "none" } : undefined }
|
||||
>
|
||||
|
||||
{ t("log.buttons.profile") }
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
};
|
87
packages/frontend/src/components/pages/logs/StationTable.tsx
Normal file
87
packages/frontend/src/components/pages/logs/StationTable.tsx
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import dayjs from "dayjs";
|
||||
import { TStationRecord } from "../../../types/station.ts";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
|
||||
// setSearchItem: Dispatch<SetStateAction<string>>
|
||||
export const StationTable = ({ stations }: {
|
||||
stations: TStationRecord[]
|
||||
}) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
const report = (data: TStationRecord) =>
|
||||
{
|
||||
toast.info(t("log.toasts.report"), {
|
||||
autoClose: 5000,
|
||||
});
|
||||
void navigator.clipboard.writeText(`;user: \`${ data.player.username }\`\n;steam: \`https://steamcommunity.com/profiles/${ data.player.id }\`\n;server: \`${ data.server.toUpperCase() }\`\n;left: <t:${ Math.floor(data.leftDate / 1000) }>${ data.joinedDate ? `\n;joined: <t:${ Math.floor(data.joinedDate / 1000) }>` : "" }\n;station: \`${ data.stationName }\`\n;link: https://${ location.hostname }/log/${ data.id }\n\n`);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
<div className="grid grid-cols-1 gap-7.5 sm:grid-cols-3 xl:grid-cols-4">
|
||||
{ stations.map((station) =>
|
||||
{
|
||||
return <div
|
||||
key={ station.id }
|
||||
className="flex flex-col align-center items-center rounded-sm border border-stroke bg-stroke shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="p-4">
|
||||
<img className="rounded-full"
|
||||
src={ station.player.avatar }
|
||||
alt="Player"/>
|
||||
</div>
|
||||
<div className="flex flex-col p-2 align-center items-center">
|
||||
<h4 className="mb-3 text-xl font-semibold text-black dark:text-white">
|
||||
{ station.player.username }
|
||||
<UserIcons flags={ station.player.flags }/>
|
||||
</h4>
|
||||
<p className={'break-words'}>{ t("log.station.station", { name: station.stationName, short: station.stationShort }) }</p>
|
||||
<p>{ t("log.station.server", { server: station.server.toUpperCase() }) }</p>
|
||||
{ station.joinedDate &&
|
||||
<p>{ t("log.station.joined", { date: dayjs(station.joinedDate).format("HH:mm DD/MM/YYYY") }) }</p> }
|
||||
<p>{ t("log.station.left", { date: dayjs(station.leftDate).format("HH:mm DD/MM/YYYY") }) }</p>
|
||||
{ station.joinedDate &&
|
||||
<p>{ t("log.station.spent", { date: dayjs.duration(station.leftDate - station.joinedDate).format("H[h] m[m]") }) }</p> }
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div className="items-center justify-center p-2.5 flex xl:p-5 gap-2 flex-wrap mt-auto mb-2">
|
||||
<Link to={ "/profile/" + (station.steam ?? station.player.id) }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ station.player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ station.player.flags.includes("private") ? { pointerEvents: "none" } : undefined }>{ t("log.buttons.profile") }</Link>
|
||||
<Link to={ "/log/" + station.id }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5` }>{ t("log.buttons.record") }</Link>
|
||||
|
||||
<a
|
||||
onClick={ () => report(station) }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-danger py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5"
|
||||
>
|
||||
{ t("log.buttons.report") }
|
||||
</a>
|
||||
</div>
|
||||
</div>;
|
||||
}) }
|
||||
</div>
|
||||
);
|
||||
};
|
88
packages/frontend/src/components/pages/logs/TrainTable.tsx
Normal file
88
packages/frontend/src/components/pages/logs/TrainTable.tsx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { TTrainRecord } from "../../../types/train.ts";
|
||||
import dayjs from "dayjs";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
// setSearchItem: Dispatch<SetStateAction<string>>
|
||||
export const TrainTable = ({ trains }: {
|
||||
trains: TTrainRecord[]
|
||||
}) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
const report = (data: TTrainRecord) =>
|
||||
{
|
||||
toast.info(t("log.toasts.report"), {
|
||||
autoClose: 5000,
|
||||
});
|
||||
void navigator.clipboard.writeText(`;user: \`${ data.player.username }\`\n;steam: \`https://steamcommunity.com/profiles/${ data.player.id }\`\n;server: \`${ data.server.toUpperCase() }\`\n;left: <t:${ Math.floor(data.leftDate / 1000) }>${ data.joinedDate ? `\n;joined: <t:${ Math.floor(data.joinedDate / 1000) }>` : "" }\n;train: \`${ data.trainNumber }\`\n;link: https://${ location.hostname }/log/${ data.id }\n\n`);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-7.5 sm:grid-cols-3 xl:grid-cols-4">
|
||||
{ trains.map((train) =>
|
||||
{
|
||||
return <div
|
||||
key={ train.id }
|
||||
className="flex flex-col align-center items-center rounded-sm border border-stroke bg-stroke shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="p-4">
|
||||
<img className="rounded-full"
|
||||
src={ train.player.avatar }
|
||||
alt="Player"/>
|
||||
</div>
|
||||
<div className="flex flex-col p-2 align-center items-center">
|
||||
<h4 className="mb-3 text-xl font-semibold text-black dark:text-white">
|
||||
{ train.player.username }
|
||||
<UserIcons flags={ train.player.flags }/>
|
||||
</h4>
|
||||
<p>{ t("log.train.train", { name: train.trainName, number: train.trainNumber }) }</p>
|
||||
<p>{ t("log.train.server", { server: train.server.toUpperCase() }) }</p>
|
||||
{ train.joinedDate &&
|
||||
<p>{ t("log.train.joined", { date: dayjs(train.joinedDate).format("HH:mm DD/MM/YYYY") }) }</p> }
|
||||
<p>{ t("log.train.left", { date: dayjs(train.leftDate).format("HH:mm DD/MM/YYYY") }) }</p>
|
||||
{ train.joinedDate &&
|
||||
<p>{ t("log.train.spent", { date: dayjs.duration(train.leftDate - train.joinedDate).format("H[h] m[m]") }) }</p> }
|
||||
|
||||
<p>{ t("log.train.distance", { distance: train.distance ? (train.distance / 1000).toFixed(2) : "--" }) }</p>
|
||||
|
||||
<p>{ t("log.train.points", { points: train.points || "--" }) }</p>
|
||||
</div>
|
||||
|
||||
<div className="items-center justify-center p-2.5 flex xl:p-5 gap-2 flex-wrap mt-auto mb-2">
|
||||
<Link to={ "/profile/" + (train.steam ?? train.player.id) }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ train.player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ train.player.flags.includes("private") ? { pointerEvents: "none" } : undefined }>{ t("log.buttons.profile") }</Link>
|
||||
<Link to={ "/log/" + train.id }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5` }>{ t("log.buttons.record") }</Link>
|
||||
|
||||
<a
|
||||
onClick={ () => report(train) }
|
||||
className="cursor-pointer inline-flex items-center justify-center rounded-md bg-danger py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5"
|
||||
>
|
||||
{ t("log.buttons.report") }
|
||||
</a>
|
||||
</div>
|
||||
</div>;
|
||||
}) }
|
||||
</div>
|
||||
);
|
||||
};
|
285
packages/frontend/src/components/pages/profiles/Profile.tsx
Normal file
285
packages/frontend/src/components/pages/profiles/Profile.tsx
Normal file
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { TProfileData } from "../../../types/profile.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ArrowIcon, FlexArrowIcon } from "../../mini/icons/ArrowIcon.tsx";
|
||||
import { formatTime } from "../../../util/time.ts";
|
||||
import { useAuth } from "../../../hooks/useAuth.tsx";
|
||||
import { ConfirmModal } from "../../mini/modal/ConfirmModal.tsx";
|
||||
import { post } from "../../../util/fetcher.ts";
|
||||
import { toast } from "react-toastify";
|
||||
import dayjs from "dayjs";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
|
||||
export const ProfileCard = ({ data }: { data: TProfileData }) =>
|
||||
{
|
||||
|
||||
const [ showTrains, setShowTrains ] = useState(false);
|
||||
const [ showStations, setShowStations ] = useState(false);
|
||||
const [ sortTrainsBy, setSortTrainsBy ] = useState<"time" | "score" | "distance">("distance");
|
||||
const [ hideLeaderboardStatsModal, setHideLeaderboardStatsModal ] = useState(false);
|
||||
const [ hideProfileModal, setHideProfileModal ] = useState(false);
|
||||
|
||||
const { isAdmin, token } = useAuth();
|
||||
|
||||
const adminToggleHideLeaderboardPlayerProfile = () =>
|
||||
{
|
||||
post(`/admin/profile/${ data.player.id }/${ data.player.flags.includes("leaderboard_hidden") ? "showLeaderboard" : "hideLeaderboard" }`, {}, { "X-Auth-Token": token })
|
||||
.then((response) =>
|
||||
{
|
||||
if (response.code === 200)
|
||||
{
|
||||
toast.success(t("admin.hideLeaderboard.alert"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const adminHidePlayerProfile = () =>
|
||||
{
|
||||
post(`/admin/profile/${ data.player.id }/hide`, {}, { "X-Auth-Token": token })
|
||||
.then((response) =>
|
||||
{
|
||||
if (response.code === 200)
|
||||
{
|
||||
toast.success(t("admin.hide.alert"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const adminForceUpdate = () =>
|
||||
{
|
||||
post(`/admin/profile/${ data.player.id }/forceUpdate`, {}, { "X-Auth-Token": token })
|
||||
.then((response) =>
|
||||
{
|
||||
if (response.code === 200)
|
||||
{
|
||||
toast.success(t("admin.update.alert"));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const { t } = useTranslation();
|
||||
return <>
|
||||
<ConfirmModal showModal={ hideLeaderboardStatsModal } setShowModal={ setHideLeaderboardStatsModal }
|
||||
onConfirm={ adminToggleHideLeaderboardPlayerProfile }
|
||||
title={ t("admin.hideLeaderboard.modal.title") }
|
||||
description={ t("admin.hideLeaderboard.modal.description") }/>
|
||||
<ConfirmModal showModal={ hideProfileModal } setShowModal={ setHideProfileModal }
|
||||
onConfirm={ adminHidePlayerProfile } title={ t("admin.hide.modal.title") }
|
||||
description={ t("admin.hide.modal.description") }/>
|
||||
<div
|
||||
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
|
||||
<div
|
||||
className="mx-auto max-w-44 rounded-full">
|
||||
<div className="relative rounded-full">
|
||||
<img className="rounded-full" src={ data.player.avatar } alt="profile"/>
|
||||
{ data.active &&
|
||||
<span className="absolute w-full rounded-full border-white bg-[#219653] dark:border-black max-w-5.5 right-0 top-0 h-5.5 border-[3px]"></span> }
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<h3 className="text-2xl font-semibold text-black dark:text-white">
|
||||
{ data.player.username } <UserIcons flags={ data.player.flags }/>
|
||||
</h3>
|
||||
|
||||
<div
|
||||
className="mx-auto mt-4.5 mb-5.5 grid max-w-94 grid-cols-2 rounded-md border border-stroke py-2.5 shadow-1 dark:border-strokedark dark:bg-[#37404F]">
|
||||
<div
|
||||
className="flex flex-col items-center justify-center gap-1 border-r border-stroke px-4 dark:border-strokedark xsm:flex-row">
|
||||
<span className="font-semibold text-black dark:text-white">
|
||||
{ Math.floor(data.player.trainDistance / 1000) }km
|
||||
</span>
|
||||
<span className="text-sm text-wrap">{ t("profile.stats.distance") }</span>
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-col items-center justify-center gap-1 border-r border-stroke px-4 dark:border-strokedark xsm:flex-row">
|
||||
<span className="font-semibold text-black dark:text-white">
|
||||
{ formatTime(data.player.dispatcherTime) }
|
||||
</span>
|
||||
<span className="text-sm text-wrap">{ t("profile.stats.time") }</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{ data.active && data.active.type === "train" &&
|
||||
<div className="mx-auto text-center">
|
||||
<h4 className="font-semibold text-black dark:text-white">{ t("profile.active.train", { train: `${ data.active.trainName } - ${ data.active.trainNumber }`, server: data.active.server.toUpperCase() }) }</h4>
|
||||
</div> }
|
||||
|
||||
{ data.active && data.active.type === "station" &&
|
||||
<div className="mx-auto text-center">
|
||||
<h4 className="font-semibold text-black dark:text-white">{ t("profile.active.station", { station: `${ data.active.stationName } - ${ data.active.stationShort }`, server: data.active.server.toUpperCase() }) }</h4>
|
||||
</div> }
|
||||
</div>
|
||||
|
||||
|
||||
{ Object.keys(data.player.trainStats || {}).length > 0 &&
|
||||
<div className="bg-white px-5 pt-6 pb-5 shadow-default dark:bg-boxdark sm:px-7.5">
|
||||
<div className="group relative cursor-pointer" onClick={ () => setShowTrains(val => !val) }>
|
||||
<h1 className="text-xl text-black dark:text-white pb-5">{ t("profile.trains.header") }</h1>
|
||||
<ArrowIcon rotated={ showTrains }/>
|
||||
</div>
|
||||
|
||||
{ showTrains &&
|
||||
<div className="flex flex-col rounded-sm border border-stroke dark:border-strokedark">
|
||||
<div className="grid grid-cols-3 rounded-sm bg-gray-2 dark:bg-meta-4 sm:grid-cols-3">
|
||||
<div className="p-2.5 text-center xl:p-5">
|
||||
<h5 className="text-sm font-medium uppercase xsm:text-base">
|
||||
{ t("profile.trains.train") }
|
||||
</h5>
|
||||
</div>
|
||||
<div className="flex flex-row align-center justify-center gap-2 p-2.5 text-center xl:p-5 cursor-pointer"
|
||||
onClick={ () => setSortTrainsBy("distance") }>
|
||||
<h5 className="text-sm font-medium uppercase xsm:text-base">
|
||||
{ t("profile.trains.distance") }
|
||||
</h5>
|
||||
<FlexArrowIcon rotated={ sortTrainsBy === "distance" || !sortTrainsBy }/>
|
||||
</div>
|
||||
<div className="flex flex-row align-center justify-center gap-2 p-2.5 text-center xl:p-5 cursor-pointer"
|
||||
onClick={ () => setSortTrainsBy("score") }>
|
||||
<h5 className="text-sm font-medium uppercase xsm:text-base">
|
||||
{ t("profile.trains.points") }
|
||||
</h5>
|
||||
<FlexArrowIcon rotated={ sortTrainsBy === "score" }/>
|
||||
</div>
|
||||
{/*<div className="hidden sm:flex flex-row align-center justify-center gap-2 p-2.5 text-center xl:p-5 cursor-pointer"*/ }
|
||||
{/* onClick={ () => setSortTrainsBy("time") }>*/ }
|
||||
{/* <h5 className="text-sm font-medium uppercase xsm:text-base">*/ }
|
||||
{/* { t("profile.trains.time") }*/ }
|
||||
{/* </h5>*/ }
|
||||
{/* <FlexArrowIcon rotated={ sortTrainsBy === "time" }/>*/ }
|
||||
{/*</div>*/ }
|
||||
</div>
|
||||
|
||||
{ Object.keys(data.player.trainStats).sort((a, b) => data.player.trainStats[ b ][ sortTrainsBy ] - data.player.trainStats[ a ][ sortTrainsBy ]).map(trainName =>
|
||||
{
|
||||
const train = data.player.trainStats[ trainName ];
|
||||
|
||||
return <div
|
||||
className={ `grid grid-cols-3 sm:grid-cols-3 border-t border-t-stroke dark:border-t-strokedark` }
|
||||
key={ trainName }
|
||||
>
|
||||
<div className="flex items-center justify-center gap-3 p-2.5 lg:p-5">
|
||||
<p className="text-black dark:text-white sm:block break-all">
|
||||
{ trainName }
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-center p-2.5 lg:p-5">
|
||||
<p className="text-meta-6 sm:block break-all">{ Math.floor(train.distance / 1000) }km</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-center p-2.5 lg:p-5">
|
||||
<p className="text-meta-3">{ train.score }</p>
|
||||
</div>
|
||||
|
||||
{/*<div className="hidden sm:flex items-center justify-center p-2.5 lg:p-5">*/ }
|
||||
{/* <p className="text-meta-3">{ formatTime(train.time) }</p>*/ }
|
||||
{/*</div>*/ }
|
||||
</div>;
|
||||
}) }
|
||||
|
||||
|
||||
</div> }
|
||||
|
||||
</div> }
|
||||
{ Object.keys(data.player.dispatcherStats || {}).length > 0 &&
|
||||
<div className="bg-white px-5 pt-6 pb-5 shadow-default dark:bg-boxdark sm:px-7.5">
|
||||
<div className="group relative cursor-pointer" onClick={ () => setShowStations(val => !val) }>
|
||||
<h1 className="text-xl text-black dark:text-white pb-5">{ t("profile.stations.header") }</h1>
|
||||
<ArrowIcon rotated={ showStations }/>
|
||||
</div>
|
||||
{ showStations &&
|
||||
<div className="flex flex-col rounded-sm border border-stroke dark:border-strokedark">
|
||||
<div className="grid grid-cols-2 rounded-sm bg-gray-2 dark:bg-meta-4">
|
||||
<div className="p-2.5 text-center xl:p-5">
|
||||
<h5 className="text-sm font-medium uppercase xsm:text-base">
|
||||
{ t("profile.stations.station") }
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<div className="p-2.5 text-center xl:p-5">
|
||||
<h5 className="text-sm font-medium uppercase xsm:text-base">
|
||||
{ t("profile.stations.time") }
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
{ Object.keys(data.player.dispatcherStats).sort((a, b) => data.player.dispatcherStats[ b ].time - data.player.dispatcherStats[ a ].time).map(stationName =>
|
||||
{
|
||||
const station = data.player.dispatcherStats[ stationName ];
|
||||
return <div
|
||||
className={ `grid grid-cols-2 border-t border-t-stroke dark:border-t-strokedark` }
|
||||
key={ stationName }
|
||||
>
|
||||
<div className="flex items-center justify-center gap-3 p-2.5 lg:p-5">
|
||||
<p className="text-black dark:text-white sm:block break-all">
|
||||
{ stationName }
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-center p-2.5 lg:p-5">
|
||||
<p className="text-meta-3">{ formatTime(station.time) }</p>
|
||||
</div>
|
||||
</div>;
|
||||
}) }
|
||||
|
||||
</div> }
|
||||
|
||||
</div> }
|
||||
|
||||
|
||||
{ isAdmin && <>
|
||||
<div className="shadow-default dark:bg-boxdark items-center justify-center p-2.5 flex flex-col xl:p-5 gap-2">
|
||||
<h1 className="text-xl text-black dark:text-white">{ t("admin.header") }</h1>
|
||||
|
||||
<div className="items-center justify-center p-2.5 flex xl:p-5 gap-2 flex-wrap sm:flex-nowrap">
|
||||
|
||||
{ data.player.flags.includes("leaderboard_hidden") ?
|
||||
<button className={ "inline-flex items-center justify-center rounded-md py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 bg-success" }
|
||||
onClick={ () => adminToggleHideLeaderboardPlayerProfile() }>
|
||||
{ t("admin.hideLeaderboard.button2") }
|
||||
</button> :
|
||||
<button className={ "inline-flex items-center justify-center rounded-md py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 bg-danger" }
|
||||
onClick={ () => setHideLeaderboardStatsModal(true) }>
|
||||
{ t("admin.hideLeaderboard.button") }
|
||||
</button> }
|
||||
|
||||
<button className="inline-flex items-center justify-center rounded-md bg-danger py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5"
|
||||
onClick={ () => setHideProfileModal(true) }>
|
||||
{ t("admin.hide.button") }
|
||||
</button>
|
||||
|
||||
<button className="inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5"
|
||||
onClick={ () => adminForceUpdate() }>
|
||||
{ t("admin.update.button") }
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</> }
|
||||
|
||||
<div className="shadow-default dark:bg-boxdark items-center justify-center p-2.5 flex flex-col xl:p-5 gap-2">
|
||||
<h1 className="text-sm text-black dark:text-white">
|
||||
{ t("profile.info", { date: dayjs(data.player.createdAt).format("DD/MM/YYYY") }) }
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</>;
|
||||
};
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { UserIcons } from "../../mini/icons/UserIcons.tsx";
|
||||
import { TProfilePlayer } from "../../../types/profile.ts";
|
||||
// import { formatTime } from "../../../util/time.ts";
|
||||
|
||||
export const ProfilesTable = ({ profiles }: { profiles: TProfilePlayer[] }) =>
|
||||
{
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-7.5 sm:grid-cols-3 xl:grid-cols-4">
|
||||
{ profiles.map((player) =>
|
||||
{
|
||||
return <div
|
||||
className="flex flex-col align-center items-center rounded-sm border border-stroke shadow-default dark:border-strokedark dark:bg-boxdark bg-stroke ">
|
||||
<div className="p-4">
|
||||
<img className="rounded-full" src={ player.avatar } alt="Player"/>
|
||||
</div>
|
||||
<div className="flex flex-col p-2 align-center items-center">
|
||||
<h4 className="mb-3 text-xl font-semibold text-black dark:text-white">
|
||||
{ player.username }
|
||||
<UserIcons flags={ player.flags }/>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<div className="items-center justify-center p-2.5 flex xl:p-5 gap-2 flex-wrap sm:flex-nowrap mt-auto mb-2">
|
||||
<Link to={ "/profile/" + player.id }
|
||||
className={ `inline-flex items-center justify-center rounded-md bg-primary py-2 px-5 text-center font-medium text-white hover:bg-opacity-50 lg:px-4 xl:px-5 ${ player.flags.includes("private") ? "bg-opacity-50" : "" }` }
|
||||
style={ player.flags.includes("private") ? { pointerEvents: "none" } : undefined }>{ t("log.buttons.profile") }</Link>
|
||||
|
||||
</div>
|
||||
</div>;
|
||||
}) }
|
||||
</div>
|
||||
);
|
||||
};
|
147
packages/frontend/src/css/satoshi.css
Normal file
147
packages/frontend/src/css/satoshi.css
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
*
|
||||
* Font Family: Satoshi
|
||||
* Designed by: Deni Anggara
|
||||
* URL: https://www.fontshare.com/fonts/satoshi
|
||||
* © 2023 Indian Type Foundry
|
||||
*
|
||||
* Font Styles:
|
||||
* Satoshi Light
|
||||
* Satoshi Light Italic
|
||||
* Satoshi Regular
|
||||
* Satoshi Italic
|
||||
* Satoshi Medium
|
||||
* Satoshi Medium Italic
|
||||
* Satoshi Bold
|
||||
* Satoshi Bold Italic
|
||||
* Satoshi Black
|
||||
* Satoshi Black Italic
|
||||
*
|
||||
*/
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-Light.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-Light.woff') format('woff'),
|
||||
url('../fonts/Satoshi-Light.ttf') format('truetype');
|
||||
font-weight: 300;
|
||||
font-display: swap;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-LightItalic.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-LightItalic.woff') format('woff'),
|
||||
url('../fonts/Satoshi-LightItalic.ttf') format('truetype');
|
||||
font-weight: 300;
|
||||
font-display: swap;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-Regular.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-Regular.woff') format('woff'),
|
||||
url('../fonts/Satoshi-Regular.ttf') format('truetype');
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-Italic.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-Italic.woff') format('woff'),
|
||||
url('../fonts/Satoshi-Italic.ttf') format('truetype');
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-Medium.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-Medium.woff') format('woff'),
|
||||
url('../fonts/Satoshi-Medium.ttf') format('truetype');
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-MediumItalic.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-MediumItalic.woff') format('woff'),
|
||||
url('../fonts/Satoshi-MediumItalic.ttf') format('truetype');
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-Bold.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-Bold.woff') format('woff'),
|
||||
url('../fonts/Satoshi-Bold.ttf') format('truetype');
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-BoldItalic.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-BoldItalic.woff') format('woff'),
|
||||
url('../fonts/Satoshi-BoldItalic.ttf') format('truetype');
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-Black.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-Black.woff') format('woff'),
|
||||
url('../fonts/Satoshi-Black.ttf') format('truetype');
|
||||
font-weight: 900;
|
||||
font-display: swap;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: 'Satoshi';
|
||||
src: url('../fonts/Satoshi-BlackItalic.woff2') format('woff2'),
|
||||
url('../fonts/Satoshi-BlackItalic.woff') format('woff'),
|
||||
url('../fonts/Satoshi-BlackItalic.ttf') format('truetype');
|
||||
font-weight: 900;
|
||||
font-display: swap;
|
||||
font-style: italic;
|
||||
}
|
||||
|
260
packages/frontend/src/css/style.css
Normal file
260
packages/frontend/src/css/style.css
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Aleksander <alekswilc> Wilczyński (aleks@alekswilc.dev)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* See LICENSE for more.
|
||||
*/
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
body {
|
||||
@apply font-satoshi font-normal text-base text-body bg-whiten relative z-1;
|
||||
}
|
||||
}
|
||||
|
||||
@layer components {
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
/* Chrome, Safari and Opera */
|
||||
.no-scrollbar::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.no-scrollbar {
|
||||
-ms-overflow-style: none; /* IE and Edge */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
}
|
||||
|
||||
.chat-height {
|
||||
@apply h-[calc(100vh_-_8.125rem)] lg:h-[calc(100vh_-_5.625rem)];
|
||||
}
|
||||
|
||||
.inbox-height {
|
||||
@apply h-[calc(100vh_-_8.125rem)] lg:h-[calc(100vh_-_5.625rem)];
|
||||
}
|
||||
}
|
||||
|
||||
/* third-party libraries CSS */
|
||||
|
||||
.tableCheckbox:checked ~ div span {
|
||||
@apply opacity-100;
|
||||
}
|
||||
|
||||
.tableCheckbox:checked ~ div {
|
||||
@apply bg-primary border-primary;
|
||||
}
|
||||
|
||||
.apexcharts-legend-text {
|
||||
@apply !text-body dark:!text-bodydark;
|
||||
}
|
||||
|
||||
.apexcharts-text {
|
||||
@apply !fill-body dark:!fill-bodydark;
|
||||
}
|
||||
|
||||
.apexcharts-xcrosshairs {
|
||||
@apply !fill-stroke dark:!fill-strokedark;
|
||||
}
|
||||
|
||||
.apexcharts-gridline {
|
||||
@apply !stroke-stroke dark:!stroke-strokedark;
|
||||
}
|
||||
|
||||
.apexcharts-series.apexcharts-pie-series path {
|
||||
@apply dark:!stroke-transparent;
|
||||
}
|
||||
|
||||
.apexcharts-legend-series {
|
||||
@apply !inline-flex gap-1.5;
|
||||
}
|
||||
|
||||
.apexcharts-tooltip.apexcharts-theme-light {
|
||||
@apply dark:!border-strokedark dark:!bg-boxdark;
|
||||
}
|
||||
|
||||
.apexcharts-tooltip.apexcharts-theme-light .apexcharts-tooltip-title {
|
||||
@apply dark:!border-strokedark dark:!bg-meta-4;
|
||||
}
|
||||
|
||||
.apexcharts-xaxistooltip,
|
||||
.apexcharts-yaxistooltip {
|
||||
@apply dark:!border-meta-4 dark:!bg-meta-4 dark:!text-bodydark1;
|
||||
}
|
||||
|
||||
.apexcharts-xaxistooltip-bottom:after {
|
||||
@apply !border-b-gray dark:!border-b-meta-4;
|
||||
}
|
||||
|
||||
.apexcharts-xaxistooltip-bottom:before {
|
||||
@apply !border-b-gray dark:!border-b-meta-4;
|
||||
}
|
||||
|
||||
.apexcharts-xaxistooltip-bottom {
|
||||
@apply !rounded !border-none !bg-gray !text-xs !font-medium !text-black dark:!text-white;
|
||||
}
|
||||
|
||||
.apexcharts-tooltip-series-group {
|
||||
@apply !pl-1.5;
|
||||
}
|
||||
|
||||
.flatpickr-wrapper {
|
||||
@apply w-full;
|
||||
}
|
||||
|
||||
.flatpickr-months .flatpickr-prev-month:hover svg,
|
||||
.flatpickr-months .flatpickr-next-month:hover svg {
|
||||
@apply !fill-primary;
|
||||
}
|
||||
|
||||
.flatpickr-calendar.arrowTop:before {
|
||||
@apply dark:!border-b-boxdark;
|
||||
}
|
||||
|
||||
.flatpickr-calendar.arrowTop:after {
|
||||
@apply dark:!border-b-boxdark;
|
||||
}
|
||||
|
||||
.flatpickr-calendar {
|
||||
@apply !p-6 dark:!bg-boxdark dark:!text-bodydark dark:!shadow-8 2xsm:!w-auto;
|
||||
}
|
||||
|
||||
.flatpickr-day {
|
||||
@apply dark:!text-bodydark dark:hover:!border-meta-4 dark:hover:!bg-meta-4;
|
||||
}
|
||||
|
||||
.flatpickr-months .flatpickr-prev-month,
|
||||
.flatpickr-months .flatpickr-next-month {
|
||||
@apply !top-7 dark:!fill-white dark:!text-white;
|
||||
}
|
||||
|
||||
.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,
|
||||
.flatpickr-months .flatpickr-next-month.flatpickr-prev-month {
|
||||
@apply !left-7;
|
||||
}
|
||||
|
||||
.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,
|
||||
.flatpickr-months .flatpickr-next-month.flatpickr-next-month {
|
||||
@apply !right-7;
|
||||
}
|
||||
|
||||
span.flatpickr-weekday,
|
||||
.flatpickr-months .flatpickr-month {
|
||||
@apply dark:!fill-white dark:!text-white;
|
||||
}
|
||||
|
||||
.flatpickr-day.inRange {
|
||||
@apply dark:!shadow-7;
|
||||
box-shadow: -5px 0 0 #EFF4FB, 5px 0 0 #EFF4FB;
|
||||
}
|
||||
|
||||
.color-orchid {
|
||||
color: orchid;
|
||||
}
|
||||
|
||||
|
||||
.flatpickr-day.inRange,
|
||||
.flatpickr-day.prevMonthDay.inRange,
|
||||
.flatpickr-day.nextMonthDay.inRange,
|
||||
.flatpickr-day.today.inRange,
|
||||
.flatpickr-day.prevMonthDay.today.inRange,
|
||||
.flatpickr-day.nextMonthDay.today.inRange,
|
||||
.flatpickr-day:hover,
|
||||
.flatpickr-day.prevMonthDay:hover,
|
||||
.flatpickr-day.nextMonthDay:hover,
|
||||
.flatpickr-day:focus,
|
||||
.flatpickr-day.prevMonthDay:focus,
|
||||
.flatpickr-day.nextMonthDay:focus {
|
||||
@apply border-gray bg-gray dark:!border-meta-4 dark:!bg-meta-4;
|
||||
}
|
||||
|
||||
.flatpickr-day.selected,
|
||||
.flatpickr-day.startRange,
|
||||
.flatpickr-day.selected,
|
||||
.flatpickr-day.endRange {
|
||||
@apply dark:!text-white;
|
||||
}
|
||||
|
||||
.flatpickr-day.selected,
|
||||
.flatpickr-day.startRange,
|
||||
.flatpickr-day.endRange,
|
||||
.flatpickr-day.selected.inRange,
|
||||
.flatpickr-day.startRange.inRange,
|
||||
.flatpickr-day.endRange.inRange,
|
||||
.flatpickr-day.selected:focus,
|
||||
.flatpickr-day.startRange:focus,
|
||||
.flatpickr-day.endRange:focus,
|
||||
.flatpickr-day.selected:hover,
|
||||
.flatpickr-day.startRange:hover,
|
||||
.flatpickr-day.endRange:hover,
|
||||
.flatpickr-day.selected.prevMonthDay,
|
||||
.flatpickr-day.startRange.prevMonthDay,
|
||||
.flatpickr-day.endRange.prevMonthDay,
|
||||
.flatpickr-day.selected.nextMonthDay,
|
||||
.flatpickr-day.startRange.nextMonthDay,
|
||||
.flatpickr-day.endRange.nextMonthDay {
|
||||
background: #3c50e0;
|
||||
@apply !border-primary !bg-primary hover:!border-primary hover:!bg-primary;
|
||||
}
|
||||
|
||||
.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n + 1)),
|
||||
.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n + 1)),
|
||||
.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n + 1)) {
|
||||
box-shadow: -10px 0 0 #3c50e0;
|
||||
}
|
||||
|
||||
.map-btn .jvm-zoom-btn {
|
||||
@apply flex items-center justify-center w-7.5 h-7.5 rounded border border-stroke dark:border-strokedark hover:border-primary dark:hover:border-primary bg-white hover:bg-primary text-body hover:text-white dark:text-bodydark dark:hover:text-white text-2xl leading-none px-0 pt-0 pb-0.5;
|
||||
}
|
||||
|
||||
.mapOne .jvm-zoom-btn {
|
||||
@apply left-auto top-auto bottom-0;
|
||||
}
|
||||
|
||||
.mapOne .jvm-zoom-btn.jvm-zoomin {
|
||||
@apply right-10;
|
||||
}
|
||||
|
||||
.mapOne .jvm-zoom-btn.jvm-zoomout {
|
||||
@apply right-0;
|
||||
}
|
||||
|
||||
.mapTwo .jvm-zoom-btn {
|
||||
@apply top-auto bottom-0;
|
||||
}
|
||||
|
||||
.mapTwo .jvm-zoom-btn.jvm-zoomin {
|
||||
@apply left-0;
|
||||
}
|
||||
|
||||
.mapTwo .jvm-zoom-btn.jvm-zoomout {
|
||||
@apply left-10;
|
||||
}
|
||||
|
||||
.taskCheckbox:checked ~ .box span {
|
||||
@apply opacity-100;
|
||||
}
|
||||
|
||||
.taskCheckbox:checked ~ p {
|
||||
@apply line-through;
|
||||
}
|
||||
|
||||
.taskCheckbox:checked ~ .box {
|
||||
@apply bg-primary border-primary dark:border-primary;
|
||||
}
|
||||
|
||||
[x-cloak] {
|
||||
display: none !important;
|
||||
}
|
BIN
packages/frontend/src/fonts/Satoshi-Black.eot
Normal file
BIN
packages/frontend/src/fonts/Satoshi-Black.eot
Normal file
Binary file not shown.
BIN
packages/frontend/src/fonts/Satoshi-Black.ttf
Normal file
BIN
packages/frontend/src/fonts/Satoshi-Black.ttf
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user