Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_tpm_ui
杨树林 5 years ago
commit ef31d94c55

@ -1,7 +1,8 @@
json.hack do json.hack do
json.(@hack, :id, :name, :difficult, :time_limit, :description, :score, :identifier, :status, :praises_count) json.(@hack, :id, :name, :difficult, :time_limit, :description, :score, :identifier, :status, :praises_count)
json.language @hack.language json.language @hack.language
json.username @hack.user.real_name json.username @hack.user&.real_name
json.user_path "/users/#{@hack.user&.login}"
json.code @my_hack.code json.code @my_hack.code
json.pass_count @hack.pass_num json.pass_count @hack.pass_num
json.submit_count @hack.submit_num json.submit_count @hack.submit_num
@ -19,5 +20,4 @@ json.user do
json.partial! 'users/user', user: current_user json.partial! 'users/user', user: current_user
json.hack_manager @hack.manager?(current_user) json.hack_manager @hack.manager?(current_user)
json.admin current_user.admin_or_business? json.admin current_user.admin_or_business?
end end

@ -0,0 +1,48 @@
/*
* @Description:
* @Author: tangjiang
* @Github:
* @Date: 2019-12-27 19:18:09
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-27 19:19:23
*/
import React, { useState } from 'react';
import Editor from "@monaco-editor/react";
function App() {
const [theme, setTheme] = useState("light");
const [language, setLanguage] = useState("javascript");
const [isEditorReady, setIsEditorReady] = useState(false);
function handleEditorDidMount() {
setIsEditorReady(true);
}
function toggleTheme() {
setTheme(theme === "light" ? "dark" : "light");
}
function toggleLanguage() {
setLanguage(language === "javascript" ? "python" : "javascript");
}
return (
<React.Fragment>
<LinkToRepo />
<button onClick={toggleTheme} disabled={!isEditorReady}>
Toggle theme
</button>
<button onClick={toggleLanguage} disabled={!isEditorReady}>
Toggle language
</button>
<Editor
height="calc(100% - 19px)" // By default, it fully fits with its parent
theme={theme}
language={language}
value={'c'}
editorDidMount={handleEditorDidMount}
/>
</React.Fragment>
);
}

@ -4,10 +4,10 @@
* @Github: * @Github:
* @Date: 2019-12-01 10:18:35 * @Date: 2019-12-01 10:18:35
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 10:17:07 * @LastEditTime : 2019-12-27 19:33:50
*/ */
import './index.scss'; import './index.scss';
import React from 'react'; import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor'; import MyMonacoEditor from '../../components/myMonacoEditor';
// import ControlSetting from '../../components/controlSetting'; // import ControlSetting from '../../components/controlSetting';
@ -18,6 +18,7 @@ function RightPane (props, ref) {
const { const {
// identifier, // identifier,
code, code,
showCode,
language, language,
// onSubmitForm, // onSubmitForm,
saveOjFormCode saveOjFormCode
@ -46,7 +47,7 @@ function RightPane (props, ref) {
<div className={'right_pane_code_wrap'}> <div className={'right_pane_code_wrap'}>
<MyMonacoEditor <MyMonacoEditor
language={language} language={language}
code={code} code={showCode}
onCodeChange={handleCodeChange}/> onCodeChange={handleCodeChange}/>
{/* <ControlSetting {/* <ControlSetting
@ -60,9 +61,10 @@ function RightPane (props, ref) {
} }
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { ojForm, testCases, code, identifier } = state.ojFormReducer; const { ojForm, testCases, code, identifier, showCode } = state.ojFormReducer;
return { return {
code, code,
showCode,
identifier, identifier,
language: ojForm.language, language: ojForm.language,
input: (testCases[0] && testCases[0].input) || '', input: (testCases[0] && testCases[0].input) || '',

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 14:59:51 * @Date: 2019-11-27 14:59:51
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 10:28:41 * @LastEditTime : 2019-12-27 19:23:46
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
@ -45,13 +45,14 @@ const RightPane = (props) => {
// const [code, setCode] = useState(editor_code || hack.code); // const [code, setCode] = useState(editor_code || hack.code);
// let initFlag = true; // let initFlag = true;
useEffect(() => { // useEffect(() => {
if (editor_code) { // if (editor_code) {
setEditorCode(editor_code); // setEditorCode(editor_code);
} else { // } else {
setEditorCode(hack.code); // setEditorCode(hack.code);
} // }
}, [hack, editor_code]); // }, [hack, editor_code]);
const handleSubmitForm = () => { const handleSubmitForm = () => {
// 提交时, 先调用提交接口,提交成功后,循环调用测评接口 // 提交时, 先调用提交接口,提交成功后,循环调用测评接口
@ -119,7 +120,7 @@ const RightPane = (props) => {
notice={notice} notice={notice}
identifier={identifier} identifier={identifier}
language={hack.language} language={hack.language}
code={editorCode} code={editor_code || hack.code}
hadCodeUpdate={hadCodeUpdate} hadCodeUpdate={hadCodeUpdate}
onCodeChange={handleCodeChange} onCodeChange={handleCodeChange}
onUpdateNotice={handleUpdateNotice} onUpdateNotice={handleUpdateNotice}

@ -164,7 +164,7 @@ export default class Shixuninformation extends Component {
axios.post(url, axios.post(url,
{ {
scope_partment: list, scope_partment:use_scope===0?undefined:list,
shixun: { shixun: {
can_copy: can_copy, can_copy: can_copy,
use_scope: use_scope, use_scope: use_scope,
@ -213,7 +213,6 @@ export default class Shixuninformation extends Component {
if(scope_partment.length>0){ if(scope_partment.length>0){
scope_partment.map((item, key) => { scope_partment.map((item, key) => {
if (item === e) { if (item === e) {
debugger
scopetype = true scopetype = true
} }
}) })
@ -222,7 +221,6 @@ export default class Shixuninformation extends Component {
if(oldscope_partment.length>0){ if(oldscope_partment.length>0){
oldscope_partment.map((item, key) => { oldscope_partment.map((item, key) => {
if (item === e) { if (item === e) {
debugger
scopetype = true scopetype = true
} }
}) })

@ -219,7 +219,6 @@ function JupyterTPI (props) {
title: '重置环境', title: '重置环境',
content: ( content: (
<p style={{ lineHeight: '24px' }}> <p style={{ lineHeight: '24px' }}>
你在本文件中修改的内容将丢失,<br />
是否确定重置环境 是否确定重置环境
</p> </p>
), ),
@ -277,20 +276,22 @@ function JupyterTPI (props) {
const firstDrawerWidth = ()=>{ const firstDrawerWidth = ()=>{
return 260 return 260
}; };
let newPage=false
// 分页处理 // 分页处理
const handleChangePage = (e) => { const handleChangePage = (e,page) => {
//滑动到底判断 //滑动到底判断
let newscrollTop=parseInt(e.currentTarget.scrollTop); let newscrollTop=parseInt(e.currentTarget.scrollTop);
let allclientHeight=e.currentTarget.clientHeight+newscrollTop; let allclientHeight=e.currentTarget.clientHeight+newscrollTop;
if(e.currentTarget.scrollHeight-allclientHeight===0||e.currentTarget.scrollHeight-allclientHeight===1||e.currentTarget.scrollHeight-allclientHeight===-1){ if(dataSets.length<total){
handlePageChange(pagination.page+1); if(e.currentTarget.scrollHeight-allclientHeight===0||e.currentTarget.scrollHeight-allclientHeight===1||e.currentTarget.scrollHeight-allclientHeight===-1){
handlePageChange(page+1);
}
} }
} }
// const listCtx = ; // const listCtx = ;
useEffect(() => { useEffect(() => {
if (dataSets.length > 0) { if (dataSets.length > 0) {
console.log('数据集的个数: ', dataSets.length); // console.log('数据集的个数: ', dataSets.length);
const oList = dataSets.map((item, i) => { const oList = dataSets.map((item, i) => {
return ( return (
<li className="jupyter_item" key={`key_${i}`}> <li className="jupyter_item" key={`key_${i}`}>
@ -314,7 +315,7 @@ function JupyterTPI (props) {
}); });
const oUl = ( const oUl = (
<ul className="jupyter_data_list" onScroll={(event)=>handleChangePage(event)} > <ul className="jupyter_data_list" onScroll={(event)=>handleChangePage(event,pagination.page)} >
{ oList } { oList }
</ul> </ul>
); );
@ -413,17 +414,17 @@ function JupyterTPI (props) {
<i className={"iconfont icon-base"}></i> <i className={"iconfont icon-base"}></i>
{/* <span className="iconfont icon-java jupyter_data_icon"></span>数据集 */} {/* <span className="iconfont icon-java jupyter_data_icon"></span>数据集 */}
</h2> </h2>
<h2 className="borbottom17212F jupyterfilepaths"> {dataSets&&dataSets.length===0?"":<h2 className="borbottom17212F jupyterfilepaths bortop17212F pt5">
<span className={"ml50"}>文件路径</span> <span className={"ml50"}>文件路径</span>
<div className="sortinxdirection"> <div className="sortinxdirection">
<a className="jupyter_name ml50 maxnamewidth186JUPYTER lineheighttaj colorlineheighttaj">{jupyter_folder_name}</a> <a className="jupyter_name ml50 maxnamewidth186JUPYTER colorlineheightta height45lineheight45">{jupyter_folder_name}</a>
<a className={"fr color-blue lineheighttaj font-14"} <a className={"fr color-blue font-14 height45lineheight45"}
onClick={() => { onClick={() => {
jsCopy("jupyter_folder_name") jsCopy("jupyter_folder_name")
}}>复制地址</a> }}>复制地址</a>
</div> </div>
<input id="jupyter_folder_name" className={"file_path_input"} value={jupyter_folder_name}/> <input id="jupyter_folder_name" className={"file_path_input"} value={jupyter_folder_name}/>
</h2> </h2>}
{ renderCtx } { renderCtx }
{/*<div className='jupyter_pagination'>*/} {/*<div className='jupyter_pagination'>*/}
{/* {total<20?"":<Pagination*/} {/* {total<20?"":<Pagination*/}

@ -132,7 +132,7 @@
.jupyter_data_list{ .jupyter_data_list{
height:500px; height:500px;
overflow: auto; overflow-y: auto;
} }
.ant-pagination{ .ant-pagination{
@ -237,4 +237,9 @@ line-height: 50px !important;
white-space: nowrap; white-space: nowrap;
cursor: default; cursor: default;
width: 181px; width: 181px;
}
.height45lineheight45{
height: 45px;
line-height: 45px !important;
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:35:46 * @Date: 2019-11-20 16:35:46
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 18:50:22 * @LastEditTime : 2019-12-27 20:03:12
*/ */
import types from './actionTypes'; import types from './actionTypes';
import CONST from '../../constants'; import CONST from '../../constants';
@ -286,20 +286,22 @@ export const validateOjForm = (props, type, cb) => {
} else if (type === 'challenge') { } else if (type === 'challenge') {
cb && cb(); cb && cb();
} else { } else {
const {identifier} = res.data;
// if (paramsObj['submitType'] === 'add' && identifier) {
// dispatch(validateOjForm(props, 'update'));
// props.history.push(`/problems/${identifier}/edit`);
// return;
// };
// message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'); // message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功');
notification.success({ notification.success({
message: '提示', message: '提示',
description: paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功' description: paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'
}); });
const {identifier} = res.data;
// 保存成功后的identifier // 保存成功后的identifier
identifier && dispatch({ identifier && dispatch({
type: types.SAVE_OJ_FORM_ID, type: types.SAVE_OJ_FORM_ID,
payload: identifier payload: identifier
}); });
if (paramsObj['submitType'] === 'add' && identifier) {
props.history.push(`/problems/${identifier}/edit`)
};
} }
// 保存或更新后调用start接口 // 保存或更新后调用start接口
// linkToDev(dispatch, props); // linkToDev(dispatch, props);
@ -502,7 +504,7 @@ export const deleteTestCase = (obj) => {
export const getOJFormById = (id) => { export const getOJFormById = (id) => {
return (dispatch) => { return (dispatch) => {
fetchGetOjById(id).then(res => { fetchGetOjById(id).then(res => {
console.log('获取OJ表单信息成功: ', res); // console.log('获取OJ表单信息成功: ', res);
dispatch({ dispatch({
type: types.SAVE_EDIT_OJ_FORM_AND_TEST_CASE, type: types.SAVE_EDIT_OJ_FORM_AND_TEST_CASE,
payload: res.data payload: res.data

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 13:41:48 * @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 16:52:30 * @LastEditTime : 2019-12-27 19:56:06
*/ */
import types from "../actions/actionTypes"; import types from "../actions/actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -179,7 +179,7 @@ const ojForUserReducer = (state = initialState, action) => {
commitTestRecordDetail: {}, // 调试代码执行结果 commitTestRecordDetail: {}, // 调试代码执行结果
commitRecordDetail: {}, // 提交成功后记录提交的详情 commitRecordDetail: {}, // 提交成功后记录提交的详情
commitRecord: [], // 提交记录 commitRecord: [], // 提交记录
userCode: '', // 保存当前用户输入的代码 // userCode: '', // 保存当前用户输入的代码
isUpdateCode: false, // 是否更新了代码内容 isUpdateCode: false, // 是否更新了代码内容
userCodeTab: 'task', // 学员测评tab位置: task | record | comment userCodeTab: 'task', // 学员测评tab位置: task | record | comment
userTestInput: '', // 用户自定义输入值 userTestInput: '', // 用户自定义输入值

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:40:32 * @Date: 2019-11-20 16:40:32
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 10:35:06 * @LastEditTime : 2019-12-27 20:00:26
*/ */
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import types from '../actions/actionTypes'; import types from '../actions/actionTypes';
@ -61,6 +61,7 @@ const init = {
position: 1, // TODO 每次加载信息时同步指定positio值 position: 1, // TODO 每次加载信息时同步指定positio值
score: 200, // 分值: 选择难易度后自动计算分值 200 | 500 | 1000 score: 200, // 分值: 选择难易度后自动计算分值 200 | 500 | 1000
code: '', // 提交的代码 code: '', // 提交的代码
showCode: '', // 编辑器显示的代码
identifier: '', // OJ表单id identifier: '', // OJ表单id
loading: false, // 僵尸loading标志 loading: false, // 僵尸loading标志
testCodeStatus: 'default', // 调试代码状态 default(默认值) | loading(加载中) | loaded(加载完成) | userCase(用户自定义测试用例) | finish(测试完成) testCodeStatus: 'default', // 调试代码状态 default(默认值) | loading(加载中) | loaded(加载完成) | userCase(用户自定义测试用例) | finish(测试完成)
@ -216,7 +217,8 @@ const ojFormReducer = (state = initialState, action) => {
testCases: curTestCases, testCases: curTestCases,
testCasesValidate: curTcValidates, testCasesValidate: curTcValidates,
testCodeStatus: hack_sets.length > 0 ? 'userCase' : 'default', testCodeStatus: hack_sets.length > 0 ? 'userCase' : 'default',
isPublish: status isPublish: status,
showCode: cbcode
} }
case types.CHANGE_PUBLISH_VALUE: case types.CHANGE_PUBLISH_VALUE:
return { return {

Loading…
Cancel
Save