@shzlx/ui-default 4.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/api.ts +61 -0
- package/backendlib/builder.ts +182 -0
- package/backendlib/markdown-it-imsize.ts +235 -0
- package/backendlib/markdown-it-katex.ts +139 -0
- package/backendlib/markdown-it-media.ts +163 -0
- package/backendlib/markdown-it-xss.ts +200 -0
- package/backendlib/markdown.js +64 -0
- package/backendlib/misc.ts +54 -0
- package/backendlib/template.ts +279 -0
- package/breakpoints.json +5 -0
- package/components/DOMAttachedObject.ts +128 -0
- package/components/autocomplete/AssignSelectAutoComplete.tsx +22 -0
- package/components/autocomplete/CustomSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/DomainSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/FileSelectAutoComplete.tsx +26 -0
- package/components/autocomplete/LanguageSelectAutoComplete.tsx +24 -0
- package/components/autocomplete/ProblemSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/UserSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/components/AssignSelectAutoComplete.tsx +118 -0
- package/components/autocomplete/components/DomainSelectAutoComplete.tsx +53 -0
- package/components/autocomplete/components/FileSelectAutoComplete.tsx +50 -0
- package/components/autocomplete/components/LanguageSelectAutoComplete.tsx +48 -0
- package/components/autocomplete/components/ProblemSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/components/UserSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/domainselectautocomplete.page.styl +6 -0
- package/components/autocomplete/index.tsx +110 -0
- package/components/autocomplete/problemselectautocomplete.page.styl +6 -0
- package/components/autocomplete/userselectautocomplete.page.styl +6 -0
- package/components/browser-update.page.ts +27 -0
- package/components/calendar/calendar.page.styl +129 -0
- package/components/calendar/index.js +367 -0
- package/components/clipboard.page.ts +23 -0
- package/components/contest/contest.page.styl +119 -0
- package/components/contest/contest.page.ts +23 -0
- package/components/contest/contest_sidebar.page.styl +21 -0
- package/components/contest/problem-contest-bg.png +0 -0
- package/components/contest/problem-contest-bg@2x.png +0 -0
- package/components/customFont.page.tsx +90 -0
- package/components/datepicker/datepicker.page.tsx +94 -0
- package/components/dialog/DomDialog.ts +145 -0
- package/components/dialog/dialog.page.styl +40 -0
- package/components/dialog/index.tsx +285 -0
- package/components/discussion/CommentBox.js +103 -0
- package/components/discussion/collapsible.page.styl +40 -0
- package/components/discussion/collapsible.page.tsx +62 -0
- package/components/discussion/comments.page.styl +142 -0
- package/components/discussion/comments.page.tsx +192 -0
- package/components/discussion/discussion.page.styl +17 -0
- package/components/discussion/history.page.tsx +81 -0
- package/components/discussion/reaction.page.styl +30 -0
- package/components/discussion/reaction.page.tsx +103 -0
- package/components/drop/drop.page.styl +40 -0
- package/components/dropdown/Dropdown.js +50 -0
- package/components/dropdown/dropdown.page.styl +33 -0
- package/components/dropdown/dropdown.page.ts +8 -0
- package/components/editor/cmeditor.page.ts +23 -0
- package/components/editor/cmeditor.styl +10 -0
- package/components/editor/index.tsx +293 -0
- package/components/editor/mdeditor.ts +60 -0
- package/components/editor/textareaHandler.ts +29 -0
- package/components/footer/footer.page.styl +94 -0
- package/components/footer/footer.page.ts +26 -0
- package/components/form/button.page.default.styl +59 -0
- package/components/form/button.page.styl +36 -0
- package/components/form/checkbox.page.styl +89 -0
- package/components/form/form.page.styl +200 -0
- package/components/form/form.page.ts +20 -0
- package/components/form/multiSelectCheckbox.page.js +46 -0
- package/components/form/radiobox.page.styl +62 -0
- package/components/form/select.page.styl +29 -0
- package/components/form/textbox.page.styl +79 -0
- package/components/form/textbox.page.ts +21 -0
- package/components/form/var.inc.styl +14 -0
- package/components/header/header.page.styl +79 -0
- package/components/highlighter/code-example.js +111 -0
- package/components/highlighter/highlighter.page.styl +99 -0
- package/components/highlighter/highlighter.page.ts +72 -0
- package/components/highlighter/meta.js +15 -0
- package/components/highlighter/prismjs.js +122 -0
- package/components/hint.page.styl +9 -0
- package/components/hint.ts +19 -0
- package/components/hitokoto/index.page.js +21 -0
- package/components/hotkey/hotkey.page.js +83 -0
- package/components/katex/katex.page.js +26 -0
- package/components/katex/katex.page.styl +2 -0
- package/components/languageselect.tsx +94 -0
- package/components/loader/loader.page.styl +40 -0
- package/components/mantine.page.tsx +39 -0
- package/components/marker/Marker.js +192 -0
- package/components/marker/MarkerReactive.js +55 -0
- package/components/marker/marker.page.js +8 -0
- package/components/marker/marker.page.styl +57 -0
- package/components/media/media.page.js +46 -0
- package/components/menu/menu-heading.page.js +28 -0
- package/components/menu/menu.page.js +18 -0
- package/components/menu/menu.page.styl +68 -0
- package/components/message/index.page.ts +166 -0
- package/components/message/worker.ts +110 -0
- package/components/messagepad/DialogueListItem.page.styl +28 -0
- package/components/messagepad/DialogueListItemComponent.jsx +39 -0
- package/components/messagepad/Message.page.styl +64 -0
- package/components/messagepad/MessageComponent.jsx +33 -0
- package/components/messagepad/MessagePad.page.styl +99 -0
- package/components/messagepad/MessagePadDialogueContentContainer.jsx +104 -0
- package/components/messagepad/MessagePadDialogueListContainer.jsx +49 -0
- package/components/messagepad/MessagePadInputContainer.jsx +100 -0
- package/components/messagepad/index.jsx +49 -0
- package/components/messagepad/reducers/activeId.ts +36 -0
- package/components/messagepad/reducers/dialogues.js +53 -0
- package/components/messagepad/reducers/index.ts +14 -0
- package/components/messagepad/reducers/inputs.js +43 -0
- package/components/messagepad/reducers/isPosting.ts +49 -0
- package/components/monaco/index.ts +178 -0
- package/components/monaco/languages/markdown.ts +97 -0
- package/components/monaco/languages/typescript.ts +45 -0
- package/components/monaco/languages/yaml.ts +22 -0
- package/components/monaco/loader.ts +96 -0
- package/components/monaco/monaco.styl +30 -0
- package/components/monaco/nls.js +31 -0
- package/components/monaco/schema/problemconfig.ts +123 -0
- package/components/navigation/hamburgers.page.styl +87 -0
- package/components/navigation/nav-logo-small_dark.png +0 -0
- package/components/navigation/navigation.page.js +203 -0
- package/components/navigation/navigation.page.styl +211 -0
- package/components/notification/index.ts +105 -0
- package/components/notification/notification.page.js +14 -0
- package/components/notification/notification.page.styl +84 -0
- package/components/nprogress.page.styl +50 -0
- package/components/omnisearch/index.page.tsx +124 -0
- package/components/omnisearch/omnibar.page.styl +138 -0
- package/components/pager/pager.page.styl +57 -0
- package/components/preview/preview.page.ts +187 -0
- package/components/problem/create.page.js +12 -0
- package/components/problem/list.page.js +9 -0
- package/components/problem/rp.page.styl +4 -0
- package/components/problem/tag.page.styl +84 -0
- package/components/problemconfig/BasicForm.tsx +92 -0
- package/components/problemconfig/ProblemConfigEditor.tsx +170 -0
- package/components/problemconfig/ProblemConfigForm.tsx +140 -0
- package/components/problemconfig/ProblemConfigTree.tsx +163 -0
- package/components/problemconfig/ProblemType.tsx +165 -0
- package/components/problemconfig/index.tsx +91 -0
- package/components/problemconfig/reducer/config.ts +173 -0
- package/components/problemconfig/reducer/index.ts +11 -0
- package/components/problemconfig/reducer/testdata.ts +16 -0
- package/components/problemconfig/tree/AddTestcase.tsx +137 -0
- package/components/problemconfig/tree/SelectionManager.tsx +140 -0
- package/components/problemconfig/tree/SubtaskSettings.tsx +180 -0
- package/components/problemconfig/tree/Testcase.tsx +98 -0
- package/components/profile/backgrounds/1.jpg +0 -0
- package/components/profile/backgrounds/10.jpg +0 -0
- package/components/profile/backgrounds/11.jpg +0 -0
- package/components/profile/backgrounds/12.jpg +0 -0
- package/components/profile/backgrounds/13.jpg +0 -0
- package/components/profile/backgrounds/14.jpg +0 -0
- package/components/profile/backgrounds/15.jpg +0 -0
- package/components/profile/backgrounds/16.jpg +0 -0
- package/components/profile/backgrounds/17.jpg +0 -0
- package/components/profile/backgrounds/18.jpg +0 -0
- package/components/profile/backgrounds/19.jpg +0 -0
- package/components/profile/backgrounds/2.jpg +0 -0
- package/components/profile/backgrounds/20.jpg +0 -0
- package/components/profile/backgrounds/21.jpg +0 -0
- package/components/profile/backgrounds/3.jpg +0 -0
- package/components/profile/backgrounds/4.jpg +0 -0
- package/components/profile/backgrounds/5.jpg +0 -0
- package/components/profile/backgrounds/6.jpg +0 -0
- package/components/profile/backgrounds/7.jpg +0 -0
- package/components/profile/backgrounds/8.jpg +0 -0
- package/components/profile/backgrounds/9.jpg +0 -0
- package/components/profile/backgrounds/gen_thumbnails.sh +7 -0
- package/components/profile/backgrounds/thumbnail/1.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/10.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/11.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/12.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/13.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/14.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/15.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/16.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/17.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/18.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/19.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/2.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/20.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/21.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/3.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/4.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/5.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/6.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/7.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/8.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/9.jpg +0 -0
- package/components/profile/profile.page.styl +23 -0
- package/components/react/DomComponent.tsx +14 -0
- package/components/react/IconComponent.tsx +20 -0
- package/components/record/record.page.styl +26 -0
- package/components/rotator/index.js +75 -0
- package/components/rotator/rotator.page.styl +20 -0
- package/components/scratchpad/DataInput.page.styl +17 -0
- package/components/scratchpad/DataInputComponent.jsx +45 -0
- package/components/scratchpad/Editor.page.styl +13 -0
- package/components/scratchpad/Panel.page.styl +18 -0
- package/components/scratchpad/PanelButton.page.styl +15 -0
- package/components/scratchpad/PanelButtonComponent.jsx +19 -0
- package/components/scratchpad/PanelComponent.jsx +25 -0
- package/components/scratchpad/ScratchpadEditorContainer.tsx +137 -0
- package/components/scratchpad/ScratchpadPretestContainer.jsx +57 -0
- package/components/scratchpad/ScratchpadRecordsContainer.jsx +45 -0
- package/components/scratchpad/ScratchpadRecordsRowContainer.jsx +83 -0
- package/components/scratchpad/ScratchpadSettings.tsx +48 -0
- package/components/scratchpad/ScratchpadToolbarContainer.jsx +190 -0
- package/components/scratchpad/Tab.page.styl +24 -0
- package/components/scratchpad/Toolbar.page.styl +53 -0
- package/components/scratchpad/ToolbarComponent.jsx +85 -0
- package/components/scratchpad/index.tsx +132 -0
- package/components/scratchpad/reducers/editor.ts +24 -0
- package/components/scratchpad/reducers/index.ts +17 -0
- package/components/scratchpad/reducers/pretest.ts +34 -0
- package/components/scratchpad/reducers/records.ts +40 -0
- package/components/scratchpad/reducers/state.ts +10 -0
- package/components/scratchpad/reducers/ui.ts +152 -0
- package/components/scratchpad/scratchpad.page.styl +55 -0
- package/components/scratchpad/var.inc.styl +2 -0
- package/components/selectUser.tsx +16 -0
- package/components/signin/signInDialog.page.js +84 -0
- package/components/signin/signin_dialog.page.styl +57 -0
- package/components/smoothscroll/smoothscroll.page.js +44 -0
- package/components/socket/index.ts +68 -0
- package/components/star/star.page.styl +20 -0
- package/components/star/star.page.ts +58 -0
- package/components/sticky/sticky.page.js +66 -0
- package/components/tab/Tab.js +168 -0
- package/components/tab/tab.page.js +9 -0
- package/components/tab/tab.page.styl +105 -0
- package/components/tab/var.inc.styl +3 -0
- package/components/table/StyledTable.js +51 -0
- package/components/table/styledTable.page.js +8 -0
- package/components/table/table.page.styl +73 -0
- package/components/time/time.page.js +47 -0
- package/components/tooltip/Tooltip.js +49 -0
- package/components/tooltip/tooltip.page.js +29 -0
- package/components/tooltip/tooltip.page.styl +69 -0
- package/components/training/training.page.styl +25 -0
- package/components/upload.tsx +103 -0
- package/components/vote/vote.page.js +43 -0
- package/components/zipDownloader/index.ts +157 -0
- package/constant/domain.js +21 -0
- package/constant/message.js +5 -0
- package/constant/record.js +52 -0
- package/context.ts +11 -0
- package/entry.js +72 -0
- package/hydro.ts +112 -0
- package/index.ts +226 -0
- package/lazyload.ts +69 -0
- package/locales/en.yaml +71 -0
- package/locales/ko.yaml +823 -0
- package/locales/zh.yaml +1137 -0
- package/locales/zh_TW.yaml +1133 -0
- package/misc/Page.ts +49 -0
- package/misc/PageLoader.js +31 -0
- package/misc/float.styl +14 -0
- package/misc/grid.styl +1048 -0
- package/misc/immersive-background.jpg +0 -0
- package/misc/immersive-background@2x.jpg +0 -0
- package/misc/immersive.styl +23 -0
- package/misc/nothing.styl +13 -0
- package/misc/puzzled_twd2.svg +1 -0
- package/misc/section.styl +105 -0
- package/misc/slideout.styl +46 -0
- package/misc/structure.styl +158 -0
- package/misc/textalign.styl +11 -0
- package/misc/typography.styl +485 -0
- package/package.json +148 -0
- package/polyfill.ts +90 -0
- package/postcss.config.js +15 -0
- package/sentry.ts +26 -0
- package/service-worker.ts +265 -0
- package/setting.yaml +98 -0
- package/templates/about.html +14 -0
- package/templates/bsod.html +35 -0
- package/templates/components/comments_discussion.html +165 -0
- package/templates/components/comments_solution.html +171 -0
- package/templates/components/contest.html +12 -0
- package/templates/components/form.html +214 -0
- package/templates/components/home.html +20 -0
- package/templates/components/homework.html +8 -0
- package/templates/components/md_hint.html +39 -0
- package/templates/components/noscript_note.html +15 -0
- package/templates/components/nothing.html +6 -0
- package/templates/components/paginator.html +25 -0
- package/templates/components/problem.html +33 -0
- package/templates/components/record.html +21 -0
- package/templates/components/sidemenu.html +11 -0
- package/templates/components/user.html +49 -0
- package/templates/contest_balloon.html +48 -0
- package/templates/contest_clarification.html +103 -0
- package/templates/contest_detail.html +56 -0
- package/templates/contest_edit.html +259 -0
- package/templates/contest_main.html +146 -0
- package/templates/contest_manage.html +80 -0
- package/templates/contest_print.html +27 -0
- package/templates/contest_problemlist.html +231 -0
- package/templates/contest_scoreboard.html +46 -0
- package/templates/contest_scoreboard_download_html.html +71 -0
- package/templates/contest_user.html +47 -0
- package/templates/discussion_create.html +28 -0
- package/templates/discussion_detail.html +149 -0
- package/templates/discussion_edit.html +30 -0
- package/templates/discussion_main_or_node.html +47 -0
- package/templates/domain_base.html +26 -0
- package/templates/domain_create.html +55 -0
- package/templates/domain_dashboard.html +45 -0
- package/templates/domain_edit.html +6 -0
- package/templates/domain_group.html +51 -0
- package/templates/domain_join.html +47 -0
- package/templates/domain_join_applications.html +67 -0
- package/templates/domain_permission.html +66 -0
- package/templates/domain_role.html +71 -0
- package/templates/domain_user.html +86 -0
- package/templates/domain_user_raw.html +5 -0
- package/templates/error.html +25 -0
- package/templates/home_domain.html +64 -0
- package/templates/home_files.html +16 -0
- package/templates/home_messages.html +9 -0
- package/templates/home_security.html +224 -0
- package/templates/home_settings.html +21 -0
- package/templates/homework_detail.html +82 -0
- package/templates/homework_edit.html +138 -0
- package/templates/homework_files.html +24 -0
- package/templates/homework_main.html +76 -0
- package/templates/layout/basic.html +27 -0
- package/templates/layout/home_base.html +13 -0
- package/templates/layout/html5.html +74 -0
- package/templates/layout/immersive.html +22 -0
- package/templates/layout/mail.html +31 -0
- package/templates/layout/simple.html +4 -0
- package/templates/layout/wiki_base.html +16 -0
- package/templates/main.html +22 -0
- package/templates/manage_base.html +24 -0
- package/templates/manage_config.html +6 -0
- package/templates/manage_dashboard.html +27 -0
- package/templates/manage_script.html +56 -0
- package/templates/manage_setting.html +6 -0
- package/templates/manage_user_import.html +23 -0
- package/templates/manage_user_priv.html +76 -0
- package/templates/partials/category.html +19 -0
- package/templates/partials/contest.html +3 -0
- package/templates/partials/contest_balloon.html +37 -0
- package/templates/partials/contest_sidebar.html +150 -0
- package/templates/partials/contest_sidebar_management.html +56 -0
- package/templates/partials/contest_user.html +19 -0
- package/templates/partials/discussion_edit_form.html +45 -0
- package/templates/partials/discussion_list.html +50 -0
- package/templates/partials/discussion_nodes_widget.html +17 -0
- package/templates/partials/files.html +49 -0
- package/templates/partials/footer.html +108 -0
- package/templates/partials/hamburger.html +7 -0
- package/templates/partials/header_mobile.html +12 -0
- package/templates/partials/homepage/bulletin.html +7 -0
- package/templates/partials/homepage/contest.html +48 -0
- package/templates/partials/homepage/discussion.html +13 -0
- package/templates/partials/homepage/discussion_nodes.html +4 -0
- package/templates/partials/homepage/error.html +5 -0
- package/templates/partials/homepage/hitokoto.html +6 -0
- package/templates/partials/homepage/homework.html +45 -0
- package/templates/partials/homepage/problem_search.html +13 -0
- package/templates/partials/homepage/ranking.html +39 -0
- package/templates/partials/homepage/recent_problems.html +17 -0
- package/templates/partials/homepage/starred_problems.html +15 -0
- package/templates/partials/homepage/suggestion.html +34 -0
- package/templates/partials/homepage/training.html +50 -0
- package/templates/partials/homework.html +3 -0
- package/templates/partials/homework_default_penalty_rules.yaml +6 -0
- package/templates/partials/homework_sidebar.html +93 -0
- package/templates/partials/login_dialog.html +56 -0
- package/templates/partials/manage_user_priv.html +78 -0
- package/templates/partials/nav.html +138 -0
- package/templates/partials/problem-sidebar-information.html +25 -0
- package/templates/partials/problem.html +2 -0
- package/templates/partials/problem_category_dialog.html +43 -0
- package/templates/partials/problem_default.md +26 -0
- package/templates/partials/problem_description.html +33 -0
- package/templates/partials/problem_files.html +63 -0
- package/templates/partials/problem_list.html +68 -0
- package/templates/partials/problem_lucky.html +10 -0
- package/templates/partials/problem_sidebar.html +14 -0
- package/templates/partials/problem_sidebar_contest.html +43 -0
- package/templates/partials/problem_sidebar_homework.html +42 -0
- package/templates/partials/problem_sidebar_normal.html +152 -0
- package/templates/partials/problem_stat.html +3 -0
- package/templates/partials/scoreboard.html +79 -0
- package/templates/partials/setting.html +92 -0
- package/templates/partials/training_default.json +14 -0
- package/templates/partials/training_detail.html +153 -0
- package/templates/partials/user.html +2 -0
- package/templates/partials/user_detail/activity.html +18 -0
- package/templates/partials/user_detail/solution.html +29 -0
- package/templates/problem_config.html +39 -0
- package/templates/problem_detail.html +150 -0
- package/templates/problem_edit.html +111 -0
- package/templates/problem_files.html +91 -0
- package/templates/problem_hack.html +41 -0
- package/templates/problem_import.html +58 -0
- package/templates/problem_main.html +100 -0
- package/templates/problem_solution.html +55 -0
- package/templates/problem_statistics.html +96 -0
- package/templates/problem_submit.html +40 -0
- package/templates/ranking.html +81 -0
- package/templates/record_detail.html +134 -0
- package/templates/record_detail_status.html +93 -0
- package/templates/record_detail_summary.html +19 -0
- package/templates/record_main.html +142 -0
- package/templates/record_main_tr.html +35 -0
- package/templates/status.html +75 -0
- package/templates/training_detail.html +120 -0
- package/templates/training_edit.html +68 -0
- package/templates/training_files.html +64 -0
- package/templates/training_main.html +107 -0
- package/templates/user_changemail_mail.html +6 -0
- package/templates/user_changemail_mail_sent.html +9 -0
- package/templates/user_delete_pending.html +10 -0
- package/templates/user_detail.html +181 -0
- package/templates/user_login.html +46 -0
- package/templates/user_logout.html +13 -0
- package/templates/user_lostpass.html +27 -0
- package/templates/user_lostpass_mail.html +6 -0
- package/templates/user_lostpass_mail_sent.html +9 -0
- package/templates/user_lostpass_with_code.html +29 -0
- package/templates/user_register.html +22 -0
- package/templates/user_register_mail.html +6 -0
- package/templates/user_register_mail_sent.html +9 -0
- package/templates/user_register_with_code.html +35 -0
- package/templates/user_sudo.html +54 -0
- package/templates/user_sudo_redirect.html +18 -0
- package/templates/wiki_help.html +189 -0
- package/theme/bp6-compat.css +48 -0
- package/theme/dark.styl +397 -0
- package/theme/default.js +33 -0
- package/typed.d.ts +20 -0
- package/utils/base.ts +209 -0
- package/utils/base64.js +104 -0
- package/utils/db.ts +32 -0
- package/utils/index.ts +73 -0
- package/utils/loadReactRedux.ts +32 -0
- package/utils/mediaQuery.ts +13 -0
- package/utils/pjax.js +148 -0
- package/utils/slide.ts +57 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { ProblemConfigFile, TestCaseConfig } from 'hydrooj/src/interface';
|
|
2
|
+
import { diffLines } from 'diff';
|
|
3
|
+
import $ from 'jquery';
|
|
4
|
+
import yaml from 'js-yaml';
|
|
5
|
+
import { isEqual } from 'lodash';
|
|
6
|
+
import type { editor } from 'monaco-editor';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { connect } from 'react-redux';
|
|
9
|
+
import Editor from 'vj/components/editor';
|
|
10
|
+
import { load } from 'vj/components/monaco/loader';
|
|
11
|
+
|
|
12
|
+
const mapStateToProps = (state) => ({
|
|
13
|
+
config: state.config,
|
|
14
|
+
});
|
|
15
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
16
|
+
handleUpdateCode: (code) => {
|
|
17
|
+
dispatch({
|
|
18
|
+
type: 'CONFIG_CODE_UPDATE',
|
|
19
|
+
payload: code,
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
config: any;
|
|
26
|
+
handleUpdateCode: (val: string) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const configKey = [
|
|
30
|
+
'type', 'subType', 'target', 'score', 'time',
|
|
31
|
+
'memory', 'filename', 'checker_type', 'checker', 'interactor',
|
|
32
|
+
'manager', 'num_processes', 'multi_pass', 'validator', 'user_extra_files',
|
|
33
|
+
'judge_extra_files', 'detail', 'outputs', 'redirect', 'cases',
|
|
34
|
+
'subtasks', 'langs', 'key', 'time_limit_rate', 'memory_limit_rate',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const subtasksKey = [
|
|
38
|
+
'time', 'memory', 'score', 'if', 'id',
|
|
39
|
+
'type', 'cases',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const casesKey = ['time', 'memory', 'input', 'output'];
|
|
43
|
+
|
|
44
|
+
export function configYamlFormat(config: ProblemConfigFile) {
|
|
45
|
+
const formatConfig: ProblemConfigFile = {};
|
|
46
|
+
configKey.forEach((key) => {
|
|
47
|
+
if (config[key] !== undefined) {
|
|
48
|
+
if (key === 'subType' && ['single', 'multi'].includes(config[key]) && config.type !== 'submit_answer') return;
|
|
49
|
+
if (key === 'checker_type' && config.type !== 'default') return;
|
|
50
|
+
if (key === 'checker'
|
|
51
|
+
&& (['default', 'strict'].includes(formatConfig.checker_type) || !formatConfig.checker_type)) return;
|
|
52
|
+
if (key === 'interactor' && config.type !== 'interactive') return;
|
|
53
|
+
if (key === 'multi_pass' && (!Number.isInteger(config.multi_pass) || config.multi_pass <= 1 || config.multi_pass > 20)) return;
|
|
54
|
+
if (key === 'subtasks') {
|
|
55
|
+
formatConfig[key] = [];
|
|
56
|
+
config[key].forEach((subtask) => {
|
|
57
|
+
const formatSubtask: object = {};
|
|
58
|
+
subtasksKey.forEach((subtaskKey) => {
|
|
59
|
+
if (subtask && subtask[subtaskKey] !== undefined) {
|
|
60
|
+
formatSubtask[subtaskKey] = subtask[subtaskKey];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
formatConfig[key].push(formatSubtask);
|
|
64
|
+
});
|
|
65
|
+
} else if (key === 'cases') {
|
|
66
|
+
formatConfig[key] = [];
|
|
67
|
+
config[key].forEach((caseItem) => {
|
|
68
|
+
const formatCase: TestCaseConfig = {
|
|
69
|
+
time: '1000ms', memory: '256MB', input: '', output: '',
|
|
70
|
+
};
|
|
71
|
+
casesKey.forEach((caseKey) => {
|
|
72
|
+
if (caseItem[caseKey] !== undefined) formatCase[caseKey] = caseItem[caseKey];
|
|
73
|
+
else delete formatCase[caseKey];
|
|
74
|
+
});
|
|
75
|
+
formatConfig[key].push(formatCase);
|
|
76
|
+
});
|
|
77
|
+
} else formatConfig[key] = config[key];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
if (formatConfig.type === 'objective') {
|
|
81
|
+
Object.keys(formatConfig).filter((i) => !['type', 'answers'].includes(i)).forEach((i) => delete formatConfig[i]);
|
|
82
|
+
formatConfig.answers = config.answers || {};
|
|
83
|
+
}
|
|
84
|
+
Object.keys(formatConfig).filter((i) => i.startsWith('__')).forEach((i) => delete formatConfig[i]);
|
|
85
|
+
return formatConfig;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default connect(mapStateToProps, mapDispatchToProps)(class MonacoEditor extends React.PureComponent<Props> {
|
|
89
|
+
disposable = [];
|
|
90
|
+
containerElement: HTMLElement;
|
|
91
|
+
__preventUpdate = false;
|
|
92
|
+
__preventFormat = false;
|
|
93
|
+
|
|
94
|
+
editor: editor.IStandaloneCodeEditor;
|
|
95
|
+
model: editor.ITextModel;
|
|
96
|
+
vjEditor: Editor;
|
|
97
|
+
|
|
98
|
+
async componentDidMount() {
|
|
99
|
+
const { monaco } = await load(['yaml']);
|
|
100
|
+
const uri = monaco.Uri.parse('hydro://problem/file/config.yaml');
|
|
101
|
+
this.model = monaco.editor.createModel(yaml.dump(configYamlFormat(this.props.config), { noArrayIndent: true }), 'yaml', uri);
|
|
102
|
+
this.vjEditor = Editor.getOrConstruct($(this.containerElement), {
|
|
103
|
+
language: 'yaml',
|
|
104
|
+
model: this.model,
|
|
105
|
+
lineNumbers: 'off',
|
|
106
|
+
onChange: (value: string) => {
|
|
107
|
+
this.__preventUpdate = true;
|
|
108
|
+
if (!this.__preventFormat) this.props.handleUpdateCode(value);
|
|
109
|
+
this.__preventUpdate = false;
|
|
110
|
+
},
|
|
111
|
+
}) as Editor;
|
|
112
|
+
this.editor = this.vjEditor.editor;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
componentDidUpdate(prevProps) {
|
|
116
|
+
if (this.__preventUpdate || !this.model || !this.props.config.__valid) return;
|
|
117
|
+
if (yaml.dump(prevProps.config, { noArrayIndent: true }) === yaml.dump(this.props.config, { noArrayIndent: true })) return;
|
|
118
|
+
const curValue = this.model.getValue();
|
|
119
|
+
const pending = configYamlFormat(this.props.config);
|
|
120
|
+
try {
|
|
121
|
+
const curConfig = yaml.load(curValue);
|
|
122
|
+
if (isEqual(curConfig, pending)) return;
|
|
123
|
+
} catch { }
|
|
124
|
+
this.__preventFormat = true;
|
|
125
|
+
const diff = diffLines(curValue, yaml.dump(pending, { noArrayIndent: true }));
|
|
126
|
+
const ops = [];
|
|
127
|
+
let cursor = 1;
|
|
128
|
+
for (const line of diff) {
|
|
129
|
+
if (line.added) {
|
|
130
|
+
let range = this.model.getFullModelRange();
|
|
131
|
+
range = range.setStartPosition(cursor, 0);
|
|
132
|
+
range = range.setEndPosition(cursor, 0);
|
|
133
|
+
ops.push({ range, text: line.value });
|
|
134
|
+
} else if (line.removed) {
|
|
135
|
+
let range = this.model.getFullModelRange();
|
|
136
|
+
range = range.setStartPosition(cursor, 0);
|
|
137
|
+
cursor += line.count;
|
|
138
|
+
range = range.setEndPosition(cursor, 0);
|
|
139
|
+
ops.push({ range, text: '' });
|
|
140
|
+
} else cursor += line.count;
|
|
141
|
+
}
|
|
142
|
+
this.model.pushEditOperations([], ops, undefined);
|
|
143
|
+
this.__preventFormat = false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
componentWillUnmount() {
|
|
147
|
+
if (this.vjEditor) this.vjEditor.destroy();
|
|
148
|
+
if (this.model) this.model.dispose();
|
|
149
|
+
if (this.editor) this.editor.dispose();
|
|
150
|
+
this.disposable.map((i) => i.dispose());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
assignRef = (component) => {
|
|
154
|
+
this.containerElement = component;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
render() {
|
|
158
|
+
return (
|
|
159
|
+
<div
|
|
160
|
+
ref={this.assignRef}
|
|
161
|
+
style={{
|
|
162
|
+
minHeight: '500px',
|
|
163
|
+
height: '100%',
|
|
164
|
+
width: '100%',
|
|
165
|
+
}}
|
|
166
|
+
className="ConfigMonacoEditor"
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Card, Switch, Text, TextInput } from '@mantine/core';
|
|
2
|
+
import { isEqual } from 'lodash';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
5
|
+
import { i18n } from 'vj/utils';
|
|
6
|
+
import FileSelectAutoComplete from '../autocomplete/components/FileSelectAutoComplete';
|
|
7
|
+
import LanguageSelectAutoComplete from '../autocomplete/components/LanguageSelectAutoComplete';
|
|
8
|
+
import { FormItem } from './BasicForm';
|
|
9
|
+
import ProblemType from './ProblemType';
|
|
10
|
+
import type { RootState } from './reducer/index';
|
|
11
|
+
|
|
12
|
+
function FileIOConfig() {
|
|
13
|
+
const filename = useSelector((state: RootState) => state.config.filename);
|
|
14
|
+
const dispatch = useDispatch();
|
|
15
|
+
return (
|
|
16
|
+
<FormItem columns={6} label="FileIOConfig" disableLabel>
|
|
17
|
+
<Card withBorder style={{ padding: 10, overflow: 'visible' }}>
|
|
18
|
+
<div className="row">
|
|
19
|
+
<FormItem columns={12} label="FileIO">
|
|
20
|
+
<TextInput
|
|
21
|
+
rightSection={<Text size="sm">.in/.out</Text>}
|
|
22
|
+
rightSectionWidth={100}
|
|
23
|
+
rightSectionPointerEvents="none"
|
|
24
|
+
value={filename || ''}
|
|
25
|
+
onChange={(ev) => {
|
|
26
|
+
dispatch({ type: 'problemconfig/updateFileIO', filename: ev.currentTarget.value });
|
|
27
|
+
}}
|
|
28
|
+
style={{ width: '100%' }}
|
|
29
|
+
/>
|
|
30
|
+
</FormItem>
|
|
31
|
+
</div>
|
|
32
|
+
</Card>
|
|
33
|
+
</FormItem>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function MultiPassConfig() {
|
|
38
|
+
const multiPass = useSelector((state: RootState) => state.config.multi_pass);
|
|
39
|
+
const dispatch = useDispatch();
|
|
40
|
+
const [enabled, setEnabled] = useState(multiPass > 1);
|
|
41
|
+
return (
|
|
42
|
+
<FormItem columns={6} label="Multi-pass" disableLabel>
|
|
43
|
+
<Card withBorder style={{ padding: 10, overflow: 'visible' }}>
|
|
44
|
+
<div className="row">
|
|
45
|
+
<FormItem columns={6} label="Multi Pass">
|
|
46
|
+
<Switch
|
|
47
|
+
styles={{ body: { display: 'flex', height: '36px', alignItems: 'center' } }}
|
|
48
|
+
checked={enabled}
|
|
49
|
+
label={i18n('Enabled')}
|
|
50
|
+
onChange={() => {
|
|
51
|
+
setEnabled(!enabled);
|
|
52
|
+
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'multi_pass', value: enabled ? 0 : 2 });
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
</FormItem>
|
|
56
|
+
{enabled && (
|
|
57
|
+
<FormItem columns={6} label={i18n('Max Passes')}>
|
|
58
|
+
<TextInput
|
|
59
|
+
type="number"
|
|
60
|
+
min={2}
|
|
61
|
+
max={10}
|
|
62
|
+
value={multiPass}
|
|
63
|
+
onChange={(ev) => dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'multi_pass', value: +ev.currentTarget.value })}
|
|
64
|
+
/>
|
|
65
|
+
</FormItem>
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
68
|
+
</Card>
|
|
69
|
+
</FormItem>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function ExtraFilesConfig() {
|
|
74
|
+
const Files = useSelector((state: RootState) => state.testdata);
|
|
75
|
+
const userExtraFiles = useSelector((state: RootState) => state.config.user_extra_files || [], isEqual);
|
|
76
|
+
const judgeExtraFiles = useSelector((state: RootState) => state.config.judge_extra_files || [], isEqual);
|
|
77
|
+
const dispatch = useDispatch();
|
|
78
|
+
return (
|
|
79
|
+
<FormItem columns={12} label="ExtraFilesConfig" disableLabel>
|
|
80
|
+
<Card withBorder style={{ padding: 10, overflow: 'visible' }}>
|
|
81
|
+
<div className="row">
|
|
82
|
+
<FormItem columns={12} label={i18n('user_extra_files')}>
|
|
83
|
+
<FileSelectAutoComplete
|
|
84
|
+
data={Files}
|
|
85
|
+
selectedKeys={userExtraFiles}
|
|
86
|
+
onChange={(val) => dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'user_extra_files', value: val.split(',') })}
|
|
87
|
+
multi
|
|
88
|
+
/>
|
|
89
|
+
</FormItem>
|
|
90
|
+
<FormItem columns={12} label={i18n('judge_extra_files')}>
|
|
91
|
+
<FileSelectAutoComplete
|
|
92
|
+
data={Files}
|
|
93
|
+
selectedKeys={judgeExtraFiles}
|
|
94
|
+
onChange={(val) => dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'judge_extra_files', value: val.split(',') })}
|
|
95
|
+
multi
|
|
96
|
+
/>
|
|
97
|
+
</FormItem>
|
|
98
|
+
</div>
|
|
99
|
+
</Card>
|
|
100
|
+
</FormItem>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function LangConfig() {
|
|
105
|
+
const langs = useSelector((state: RootState) => state.config.langs) || [];
|
|
106
|
+
const dispatch = useDispatch();
|
|
107
|
+
return (
|
|
108
|
+
<FormItem columns={12} label="langs" disableLabel>
|
|
109
|
+
<Card withBorder style={{ padding: 10, overflow: 'visible' }}>
|
|
110
|
+
<div className="row">
|
|
111
|
+
<FormItem columns={12} label="langs">
|
|
112
|
+
<LanguageSelectAutoComplete
|
|
113
|
+
placeholder={!langs.length ? i18n('Unlimited') : i18n('Code language')}
|
|
114
|
+
selectedKeys={langs}
|
|
115
|
+
onChange={(value) => dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'langs', value: value.split(',') })}
|
|
116
|
+
multi
|
|
117
|
+
/>
|
|
118
|
+
</FormItem>
|
|
119
|
+
</div>
|
|
120
|
+
</Card>
|
|
121
|
+
</FormItem>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default function ProblemConfigForm() {
|
|
126
|
+
const Type = useSelector((state: RootState) => state.config.type);
|
|
127
|
+
return (
|
|
128
|
+
<div className="row problem-config-form">
|
|
129
|
+
<ProblemType />
|
|
130
|
+
{Type === 'default' && <FileIOConfig />}
|
|
131
|
+
{['default', 'interactive'].includes(Type) && <MultiPassConfig />}
|
|
132
|
+
{!['submit_answer', 'objective'].includes(Type) && (
|
|
133
|
+
<>
|
|
134
|
+
<ExtraFilesConfig />
|
|
135
|
+
<LangConfig />
|
|
136
|
+
</>
|
|
137
|
+
)}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { normalizeSubtasks, readSubtasksFromFiles } from '@hydrooj/common';
|
|
2
|
+
import { TestCaseConfig } from 'hydrooj';
|
|
3
|
+
import { Button, Text, Tree } from '@mantine/core';
|
|
4
|
+
import { isEqual } from 'lodash';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { DndProvider, useDrop } from 'react-dnd';
|
|
7
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
8
|
+
import { useDispatch, useSelector, useStore } from 'react-redux';
|
|
9
|
+
import { confirm } from 'vj/components/dialog/index';
|
|
10
|
+
import { i18n } from 'vj/utils';
|
|
11
|
+
import { RootState } from './reducer';
|
|
12
|
+
import { AddTestcase } from './tree/AddTestcase';
|
|
13
|
+
import { SelectionManager } from './tree/SelectionManager';
|
|
14
|
+
import { GlobalSettings, SubtaskSettings } from './tree/SubtaskSettings';
|
|
15
|
+
|
|
16
|
+
interface TestcasesDndItem {
|
|
17
|
+
cases: TestCaseConfig[];
|
|
18
|
+
subtaskId: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function SubtaskNode(props: { subtaskId: number }) {
|
|
22
|
+
const { subtaskId } = props;
|
|
23
|
+
const subtaskIds = useSelector((s: RootState) => Object.values(s.config?.subtasks || []).map((i) => i.id), isEqual);
|
|
24
|
+
const cases = useSelector((state: RootState) => (subtaskId === -1
|
|
25
|
+
? state.config.__cases
|
|
26
|
+
: state.config.subtasks.find((i) => i.id === subtaskId).cases || []));
|
|
27
|
+
const time = useSelector((s: RootState) => s.config?.time);
|
|
28
|
+
const memory = useSelector((s: RootState) => s.config?.memory);
|
|
29
|
+
const dispatch = useDispatch();
|
|
30
|
+
const [expand, setExpand] = React.useState(true);
|
|
31
|
+
const [, drop] = useDrop<TestcasesDndItem>(() => ({
|
|
32
|
+
accept: 'cases',
|
|
33
|
+
canDrop(item) {
|
|
34
|
+
return item.subtaskId !== subtaskId;
|
|
35
|
+
},
|
|
36
|
+
drop(item) {
|
|
37
|
+
dispatch({
|
|
38
|
+
type: 'problemconfig/moveTestcases',
|
|
39
|
+
payload: {
|
|
40
|
+
target: subtaskId,
|
|
41
|
+
source: item.subtaskId,
|
|
42
|
+
cases: item.cases,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
function deleteSubtask() {
|
|
49
|
+
dispatch({
|
|
50
|
+
type: 'problemconfig/deleteSubtask',
|
|
51
|
+
id: subtaskId,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div style={{ marginBottom: 8 }}>
|
|
57
|
+
{subtaskId !== -1 && (
|
|
58
|
+
<div style={{ display: 'flex', alignItems: 'center', cursor: 'pointer' }} onClick={() => setExpand((e) => !e)}>
|
|
59
|
+
<Text fw={600} style={{ marginRight: 8 }}>
|
|
60
|
+
{expand ? <i className="icon icon-expand_more" /> : <i className="icon icon-expand_less" />}
|
|
61
|
+
</Text>
|
|
62
|
+
<Text>{i18n('Subtask {0}', subtaskId)}</Text>
|
|
63
|
+
<Button
|
|
64
|
+
variant="subtle"
|
|
65
|
+
size="sm"
|
|
66
|
+
color="black"
|
|
67
|
+
style={{ marginLeft: 'auto' }}
|
|
68
|
+
onClick={(ev) => {
|
|
69
|
+
ev.stopPropagation();
|
|
70
|
+
confirm(i18n('Are you sure you want to delete this subtask?')).then((yes) => {
|
|
71
|
+
if (yes) deleteSubtask();
|
|
72
|
+
});
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
<i className="icon icon-delete" />
|
|
76
|
+
</Button>
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
<div ref={drop as any}>
|
|
80
|
+
{subtaskId !== -1 && expand && (
|
|
81
|
+
<SubtaskSettings subtaskId={subtaskId} subtaskIds={subtaskIds} time={time} memory={memory} />
|
|
82
|
+
)}
|
|
83
|
+
{expand
|
|
84
|
+
? <SelectionManager subtaskId={subtaskId} subtaskIds={subtaskIds} />
|
|
85
|
+
: <div style={{ paddingLeft: 22 }}>
|
|
86
|
+
<Text>{cases.length} testcases.</Text>
|
|
87
|
+
</div>}
|
|
88
|
+
{!cases.length && (
|
|
89
|
+
<div style={{ paddingLeft: 22 }}>
|
|
90
|
+
<Text c="dimmed">{subtaskId === -1
|
|
91
|
+
? i18n('No testcase here')
|
|
92
|
+
: i18n('Drag and drop testcases here:')}</Text>
|
|
93
|
+
</div>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function SubtaskConfigTree() {
|
|
101
|
+
const ids = useSelector((s: RootState) => Object.values(s.config?.subtasks || []).map((i) => i.id), isEqual);
|
|
102
|
+
const dispatch = useDispatch();
|
|
103
|
+
const store = useStore<RootState>();
|
|
104
|
+
const autoConfigure = React.useCallback(() => {
|
|
105
|
+
const state = store.getState();
|
|
106
|
+
const subtasks = readSubtasksFromFiles(state.testdata.map((t) => t.name), state.config);
|
|
107
|
+
const cases = subtasks.reduce((a, b) => a.concat(b.cases), []);
|
|
108
|
+
dispatch({
|
|
109
|
+
type: 'CONFIG_AUTOCASES_UPDATE',
|
|
110
|
+
subtasks: normalizeSubtasks(subtasks, (i) => i, state.config.time, state.config.memory, true),
|
|
111
|
+
});
|
|
112
|
+
dispatch({
|
|
113
|
+
type: 'problemconfig/delTestcases',
|
|
114
|
+
cases,
|
|
115
|
+
});
|
|
116
|
+
}, [dispatch, store]);
|
|
117
|
+
const rootNodes = React.useMemo<any[]>(() => [
|
|
118
|
+
{ id: 'auto', label: i18n('Auto configure'), type: 'action' as const },
|
|
119
|
+
{ id: 'global', label: i18n('Global settings'), type: 'global' as const },
|
|
120
|
+
...ids.map((id) => ({ id: `sub-${id}`, label: i18n('Subtask {0}', id), type: 'subtask' as const, subtaskId: id })),
|
|
121
|
+
{ id: 'add', label: i18n('Add new subtask'), type: 'add' as const },
|
|
122
|
+
], [ids]);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<Tree
|
|
126
|
+
data={rootNodes}
|
|
127
|
+
levelOffset={12}
|
|
128
|
+
renderNode={({ node }) => {
|
|
129
|
+
const n: any = node;
|
|
130
|
+
if (n.type === 'action') {
|
|
131
|
+
return <div style={{ padding: '6px 0' }} onClick={autoConfigure}>
|
|
132
|
+
<Text><i className="icon icon-settings" /> {i18n('Auto configure')}</Text>
|
|
133
|
+
</div>;
|
|
134
|
+
}
|
|
135
|
+
if (n.type === 'global') return <GlobalSettings />;
|
|
136
|
+
if (n.type === 'add') {
|
|
137
|
+
return <div style={{ padding: '6px 0' }} onClick={() => dispatch({ type: 'problemconfig/addSubtask' })}>
|
|
138
|
+
<Text><i className="icon icon-add" /> {i18n('Add new subtask')}</Text>
|
|
139
|
+
</div>;
|
|
140
|
+
}
|
|
141
|
+
return <SubtaskNode subtaskId={n.subtaskId} />;
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function ProblemConfigTree() {
|
|
148
|
+
return (
|
|
149
|
+
<DndProvider backend={HTML5Backend} context={window}>
|
|
150
|
+
<div className="row">
|
|
151
|
+
<div className="medium-6 columns">
|
|
152
|
+
<SubtaskConfigTree />
|
|
153
|
+
</div>
|
|
154
|
+
<div className="medium-6 columns">
|
|
155
|
+
<div>
|
|
156
|
+
<AddTestcase />
|
|
157
|
+
<SubtaskNode subtaskId={-1} />
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</DndProvider>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Card, SegmentedControl, Switch } from '@mantine/core';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
4
|
+
import { i18n } from 'vj/utils';
|
|
5
|
+
import { testlibCheckers } from '../monaco/schema/problemconfig';
|
|
6
|
+
import { FormItem, ManagedSelect, SingleFileSelect } from './BasicForm';
|
|
7
|
+
import type { RootState } from './reducer/index';
|
|
8
|
+
|
|
9
|
+
export default function ProblemType() {
|
|
10
|
+
const Type = useSelector((state: RootState) => state.config.type);
|
|
11
|
+
const checkerType = useSelector((state: RootState) => state.config.checker_type);
|
|
12
|
+
const filename = useSelector((state: RootState) => state.config.filename);
|
|
13
|
+
const numProcesses = useSelector((state: RootState) => state.config.num_processes);
|
|
14
|
+
const subType = useSelector((state: RootState) => state.config.subType);
|
|
15
|
+
const checker = useSelector((state: RootState) => state.config.checker);
|
|
16
|
+
const [category, setCategory] = React.useState('');
|
|
17
|
+
const dispatch = useDispatch();
|
|
18
|
+
const dispatcher = (base) => (value) => dispatch({ ...base, value });
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (category || !checker) return;
|
|
21
|
+
const name = typeof checker === 'string' ? checker : checker.file;
|
|
22
|
+
if (name.includes('.')) setCategory('custom');
|
|
23
|
+
else setCategory('preset');
|
|
24
|
+
}, [checker]);
|
|
25
|
+
return (
|
|
26
|
+
<FormItem columns={12} label="" disableLabel>
|
|
27
|
+
<Card withBorder style={{ padding: 10, overflow: 'visible' }}>
|
|
28
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 3 }}>
|
|
29
|
+
<div>{i18n('Problem Type')}</div>
|
|
30
|
+
<SegmentedControl
|
|
31
|
+
value={Type}
|
|
32
|
+
onChange={dispatcher({ type: 'CONFIG_FORM_UPDATE', key: 'type' })}
|
|
33
|
+
data={[
|
|
34
|
+
{ label: i18n('problem_type.default'), value: 'default' },
|
|
35
|
+
{ label: i18n('problem_type.interactive'), value: 'interactive' },
|
|
36
|
+
{ label: i18n('problem_type.communication'), value: 'communication' },
|
|
37
|
+
{ label: i18n('problem_type.submit_answer'), value: 'submit_answer' },
|
|
38
|
+
{ label: i18n('problem_type.objective'), value: 'objective' },
|
|
39
|
+
]}
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
{['default', 'submit_answer'].includes(Type) && (
|
|
44
|
+
<>
|
|
45
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 3 }}>
|
|
46
|
+
<div>{i18n('CheckerType')}</div>
|
|
47
|
+
<SegmentedControl
|
|
48
|
+
value={(['strict', 'default'].includes(checkerType) || !checkerType)
|
|
49
|
+
? 'default' : (checkerType !== 'testlib' ? 'other' : 'testlib')}
|
|
50
|
+
onChange={(value) => {
|
|
51
|
+
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'checker_type', value });
|
|
52
|
+
if (value === 'testlib' && !category) setCategory('custom');
|
|
53
|
+
}}
|
|
54
|
+
data={[
|
|
55
|
+
{ label: i18n('default'), value: 'default' },
|
|
56
|
+
{ label: 'testlib', value: 'testlib' },
|
|
57
|
+
{ label: 'other', value: 'other' },
|
|
58
|
+
]}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
{((['strict', 'default'].includes(checkerType) || !checkerType)) && (
|
|
63
|
+
<Switch
|
|
64
|
+
styles={{ body: { display: 'flex' } }}
|
|
65
|
+
checked={checkerType !== 'strict'}
|
|
66
|
+
label={i18n('Ignore trailing space and enter.')}
|
|
67
|
+
onChange={() => {
|
|
68
|
+
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'checker_type', value: checkerType === 'strict' ? 'default' : 'strict' });
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{(!['strict', 'default'].includes(checkerType) && checkerType && checkerType === 'testlib') && (
|
|
74
|
+
<div className="row">
|
|
75
|
+
<FormItem columns={4} label="Type">
|
|
76
|
+
<select
|
|
77
|
+
value={category}
|
|
78
|
+
onChange={(ev) => {
|
|
79
|
+
setCategory(ev.currentTarget.value);
|
|
80
|
+
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'checker', value: ev.currentTarget.value === 'preset' ? 'acmp' : null });
|
|
81
|
+
}}
|
|
82
|
+
className="select"
|
|
83
|
+
>
|
|
84
|
+
<option value="preset">{i18n('Preset')}</option>
|
|
85
|
+
<option value="custom">{i18n('Custom')}</option>
|
|
86
|
+
</select>
|
|
87
|
+
</FormItem>
|
|
88
|
+
{category === 'preset'
|
|
89
|
+
? <FormItem columns={8} label="Checker">
|
|
90
|
+
<select
|
|
91
|
+
value={typeof checker === 'string' ? checker : checker.file}
|
|
92
|
+
onChange={(ev) => dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'checker', value: ev.currentTarget.value })}
|
|
93
|
+
className="select"
|
|
94
|
+
>
|
|
95
|
+
{testlibCheckers.map((c) => (
|
|
96
|
+
<option key={c} value={c}>{c}</option>
|
|
97
|
+
))}
|
|
98
|
+
</select>
|
|
99
|
+
</FormItem>
|
|
100
|
+
: <SingleFileSelect formKey="checker" label="Checker" withLang />}
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
|
|
104
|
+
{(!['strict', 'default'].includes(checkerType) && checkerType && checkerType !== 'testlib') && (
|
|
105
|
+
<div className="row">
|
|
106
|
+
<FormItem columns={4} label="Interface">
|
|
107
|
+
<ManagedSelect options={['syzoj', 'hustoj', 'qduoj', 'lemon', 'kattis']} formKey="checker_type" />
|
|
108
|
+
</FormItem>
|
|
109
|
+
<SingleFileSelect formKey="checker" label="Checker" withLang />
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
</>
|
|
113
|
+
)}
|
|
114
|
+
|
|
115
|
+
{Type === 'interactive' && (
|
|
116
|
+
<div className="row">
|
|
117
|
+
<SingleFileSelect formKey="interactor" label="Interactor" withLang />
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
{Type === 'communication' && (
|
|
122
|
+
<div className="row">
|
|
123
|
+
<SingleFileSelect formKey="manager" label="Manager" withLang />
|
|
124
|
+
<FormItem columns={4} label="Number of Processes">
|
|
125
|
+
<input
|
|
126
|
+
defaultValue={numProcesses || 2}
|
|
127
|
+
placeholder="2"
|
|
128
|
+
onChange={(ev) => dispatch(({ type: 'CONFIG_FORM_UPDATE', key: 'num_processes', value: +ev.currentTarget.value }))}
|
|
129
|
+
className="textbox"
|
|
130
|
+
/>
|
|
131
|
+
</FormItem>
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
{Type === 'submit_answer' && (
|
|
136
|
+
<div className="row">
|
|
137
|
+
<FormItem columns={6} label="Config" disableLabel>
|
|
138
|
+
<Switch
|
|
139
|
+
checked={subType === 'multi'}
|
|
140
|
+
styles={{ body: { display: 'flex' } }}
|
|
141
|
+
label={i18n('Multi-file')}
|
|
142
|
+
onChange={() => {
|
|
143
|
+
dispatch({ type: 'CONFIG_FORM_UPDATE', key: 'subType', value: subType === 'multi' ? 'single' : 'multi' });
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
146
|
+
</FormItem>
|
|
147
|
+
<FormItem columns={6} label="Filename">
|
|
148
|
+
<input
|
|
149
|
+
defaultValue={filename || '#.txt'}
|
|
150
|
+
placeholder="#.txt"
|
|
151
|
+
disabled={subType !== 'multi'}
|
|
152
|
+
onChange={(ev) => dispatch(({ type: 'CONFIG_FORM_UPDATE', key: 'filename', value: ev.currentTarget.value }))}
|
|
153
|
+
className="textbox"
|
|
154
|
+
/>
|
|
155
|
+
</FormItem>
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
|
|
159
|
+
{Type === 'objective' && (
|
|
160
|
+
<p>{i18n('Unsupported configure this type of problem. Please refer to the documentation.')}</p>
|
|
161
|
+
)}
|
|
162
|
+
</Card>
|
|
163
|
+
</FormItem>
|
|
164
|
+
);
|
|
165
|
+
}
|