diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 23f22c76d..ff002cf89 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -149,42 +149,42 @@ export function initAxiosInterceptors(props) { // https://github.com/axios/axios/issues/1497 // TODO 读取到package.json中的配置? - var proxy = "http://localhost:3000" - // proxy = "http://testbdweb.trustie.net" - // proxy = "http://testbdweb.educoder.net" - // proxy = "https://testeduplus2.educoder.net" - //proxy="http://47.96.87.25:48080" - proxy = "https://pre-newweb.educoder.net" - proxy = "https://test-newweb.educoder.net" - // proxy="https://test-jupyterweb.educoder.net" - // proxy="https://test-newweb.educoder.net" - // proxy="https://test-jupyterweb.educoder.net" - //proxy="http://192.168.2.63:3001" - try { - const str = window.location.pathname; - if (str.indexOf("/wxcode") !== -1) { - // console.log("开始重写cookis"); - const _params = window.location.search; - // console.log("1111"); - if (_params) { - // console.log("22222"); - let _search = _params.split('?')[1]; - _search.split('&').forEach(item => { - const _arr = item.split('='); - if (_arr[0] === '_educoder_session') { - cookie.save('_educoder_session', _arr[1], { path: '/' }); - cookie.save('_educoder_session', _arr[1], { domain: '.educoder.net', path: '/' }); - - } else { - cookie.save('autologin_trustie', _arr[1], { path: '/' }); - cookie.save('autologin_trustie', _arr[1], { domain: '.educoder.net', path: '/' }); - } - }); - } - } - } catch (e) { - - } + var proxy = "http://localhost:3000" + // proxy = "http://testbdweb.trustie.net" + // proxy = "http://testbdweb.educoder.net" + // proxy = "https://testeduplus2.educoder.net" + //proxy="http://47.96.87.25:48080" + proxy="https://pre-newweb.educoder.net" + proxy="https://test-newweb.educoder.net" + // proxy="https://test-jupyterweb.educoder.net" + // proxy="https://test-newweb.educoder.net" + proxy="https://test-jupyterweb.educoder.net" + //proxy="http://192.168.2.63:3001" + try { + const str =window.location.pathname; + if(str.indexOf("/wxcode") !== -1){ + // console.log("开始重写cookis"); + const _params = window.location.search; + // console.log("1111"); + if (_params) { + // console.log("22222"); + let _search = _params.split('?')[1]; + _search.split('&').forEach(item => { + const _arr = item.split('='); + if(_arr[0]==='_educoder_session'){ + cookie.save('_educoder_session',_arr[1],{ path: '/' }); + cookie.save('_educoder_session',_arr[1], { domain: '.educoder.net', path: '/'}); + + }else{ + cookie.save('autologin_trustie',_arr[1],{ path: '/' }); + cookie.save('autologin_trustie',_arr[1], { domain: '.educoder.net', path: '/'}); + } + }); + } + } + }catch (e) { + + } // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index 3c4a5cabf..145db7090 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -544,8 +544,30 @@ class TPMIndex extends Component { />) }> + () + }> - {/* */} + () + }> + + + () + }> + + + () + }> + + + {/* */} -
- {/* 可能会影响到其他页面的样式,需要测试、协商 */} -
- - {loadingContent ? - : - - } -
- - {isflag &&
- -
} +
+ {/* 可能会影响到其他页面的样式,需要测试、协商 */} +
+ + { loadingContent ? + : + + }
+ + { listItemtypes===false?
+ +
:""} +
); diff --git a/public/react/src/modules/tpm/TPMRepositoryComponent.js b/public/react/src/modules/tpm/TPMRepositoryComponent.js index 443501d9e..e1806f524 100644 --- a/public/react/src/modules/tpm/TPMRepositoryComponent.js +++ b/public/react/src/modules/tpm/TPMRepositoryComponent.js @@ -19,13 +19,15 @@ class TPMRepositoryComponent extends Component { let pathArray = [] var splitArray = window.location.pathname.split('shixun_show/'); if (splitArray[1]) { - pathArray = splitArray[1].split('/') + // pathArray = splitArray[1].split('/') + pathArray = decodeURIComponent(splitArray[1]).split('/') if (pathArray[pathArray.length - 1] == '') { // 有可能是这么访问的: http://localhost:3007/shixuns/3ozvy5f8/repository/fsu7tkaw/master/shixun_show/src/ pathArray.length = pathArray.length - 1; } } this.state = { + listItemtype:false, repositoryLoading: true, pathArray: pathArray, isContentWidth100: this._isFileInPathArray(pathArray) @@ -33,6 +35,9 @@ class TPMRepositoryComponent extends Component { } componentDidUpdate(prevProps, prevState) { if (this.props.secret_repository_tab != prevProps.secret_repository_tab) { + this.setState({ + listItemtype:false, + }) this.fetchRepo() } } @@ -64,7 +69,7 @@ class TPMRepositoryComponent extends Component { }); } trace_collapse('tpm save code res: ', response) - this.props.showSnackbar('文件保存成功') + this.props.showNotification('文件保存成功') }).catch((error)=>{ console.log(error) @@ -75,7 +80,7 @@ class TPMRepositoryComponent extends Component { // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/file_content.json this.setContentWidth100(true) - this.setState({ repositoryLoading: true, pathArray: newPathArray }) + // let id = this.props.match.params.shixunId; let url = `/shixuns/${id}/file_content.json`; axios.post(url, { @@ -85,21 +90,37 @@ class TPMRepositoryComponent extends Component { trace_collapse('repository res: ', response) if (response.data.status == -1) { - this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') + //this.props.showNotification('无法找到对应的资源,请变更地址或联系管理员!') return; } + + if (response.data.status == -2) { + + this.props.showNotification(response.data.message) + return; + } + if(response.status === 200){ this.setState({ + listItemtypes:true + }) + + this.setState({ repositoryLoading: true, pathArray: newPathArray }) + this.setState({ fileContent: response.data.content, repositoryLoading: false - }); - if(response.data.content){ - this.props.history.replace(`${this.props.match.url}/master/shixun_show/${newPathArray.join('/')}`) - } + }); + + if(response.data.content){ + this.props.history + .replace(`/shixuns/${id}/repository` + + (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) + // this.props.history.replace(`${this.props.match.url}/master/shixun_show/${newPathArray.join('/')}`) + } } }).catch((error)=>{ - this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') + // this.props.showNotification('无法找到对应的资源,请变更地址或联系管理员!') console.log(error) }); } @@ -114,27 +135,42 @@ class TPMRepositoryComponent extends Component { } // listItem 如果是num,则是通过面包屑点击过来的,取pathArray的子集 fetchRepo = (listItem) => { - console.log(1) - debugger + + // if(listItem === "main"||listItem){ + // this.props.history.replace(`/shixuns/${this.props.match.params.shixunId}/repository`) + // return; + // } const { pathArray } = this.state; let newPathArray = pathArray.slice(0) if (listItem === 0 || listItem) { + this.setContentWidth100(false) this.nameTypeMap[listItem.name] = listItem.type if (typeof listItem == 'number') { // 参数是数字的话,做截取 // if (this._isFileName(newPathArray[listItem])) { // 面包屑中的文件不让点击了 // listItem--; // } + this.setState({ + listItemtypes:false + }) newPathArray = newPathArray.slice(0, listItem) } else if (listItem.type === 'tree') { + this.setState({ + listItemtypes:false + }) newPathArray.push(listItem.name) } else if (listItem.type === 'blob') { + newPathArray.push(listItem.name) - this.setState({ pathArray: newPathArray }) + // this.setState({ pathArray: newPathArray }) this.fetchCode(newPathArray) return; } + }else{ + this.setState({ + listItemtypes:false + }) } // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/repository.json this.setState({ repositoryLoading: true, pathArray: newPathArray }) @@ -143,6 +179,7 @@ class TPMRepositoryComponent extends Component { if (newPathArray.length) { fileInPathArray = this.nameTypeMap[newPathArray[newPathArray.length - 1]] ? this.nameTypeMap[newPathArray[newPathArray.length - 1]] !== 'tree' : (listItem ? listItem.type !== 'tree' : this._isFileName( newPathArray[newPathArray.length - 1] )) + if ( fileInPathArray ) { urlNewPathArray = newPathArray.slice(0, newPathArray.length - 1) } @@ -151,16 +188,18 @@ class TPMRepositoryComponent extends Component { let id = this.props.match.params.shixunId; let url = `/shixuns/${id}/${this.props.secret_repository_tab ? 'secret_repository' : 'repository'}.json`; + // this.props.setLoadingContent(true) axios.post(url, { path: path ? path : '' }).then((response) => { + // this.props.setLoadingContent(false) const trees = response.data.trees const treeIsFileMap = {} if (!trees || !Array.isArray(trees)) { - // this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') + // this.props.showNotification('无法找到对应的资源,请变更地址或联系管理员!') // return; } else { trees.forEach(item => { @@ -169,19 +208,20 @@ class TPMRepositoryComponent extends Component { } if(response.status === 200){ this.setState({ + treeIsFileMap, ...response.data, repositoryLoading: false }); - // console.log(response) - // console.log(newPathArray.length) - // this.props.history - // .replace(`${this.props.match.url}` + - // (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) + + this.props.history + .replace(`/shixuns/${id}/repository` + + (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : '')) } // 初始化时,repo接口完毕后需要看是否需要fetchCode if (fileInPathArray) { + // this.fetchCode(newPathArray) } // info(response) @@ -192,30 +232,45 @@ class TPMRepositoryComponent extends Component { }); } - + oncodechanner=()=>{ + this.fetchRepo(0) + } render() { - const { isContentWidth100 } = this.state; + const { listItemtypes } = this.state; let matchpath =this.props.match.path; let flag =false; - if(matchpath==="/shixuns/:shixunId/repository"){ - flag =true; - }else if(matchpath==="/shixuns/:shixunId/secret_repository"){ - flag =true; - } + + // if(matchpath==="/shixuns/:shixunId/repository"){ + // flag =true; + // }else if(matchpath==="/shixuns/:shixunId/secret_repository"){ + // flag =true; + // } // 需要重构 return ( - { flag ? - :"" + :
+ {/* 可能会影响到其他页面的样式,需要测试、协商 */} +
+ +
+
}
diff --git a/public/react/src/modules/tpm/TPMRepositoryComponentdetails.js b/public/react/src/modules/tpm/TPMRepositoryComponentdetails.js index cd08a7b03..0b4c9f70a 100644 --- a/public/react/src/modules/tpm/TPMRepositoryComponentdetails.js +++ b/public/react/src/modules/tpm/TPMRepositoryComponentdetails.js @@ -11,7 +11,8 @@ class TPMRepositoryComponentdetails extends Component { let pathArray = [] var splitArray = window.location.pathname.split('shixun_show/'); if (splitArray[1]) { - pathArray = splitArray[1].split('/') + pathArray = decodeURIComponent(splitArray[1]).split('/') + if (pathArray[pathArray.length - 1] == '') { // 有可能是这么访问的: http://localhost:3007/shixuns/3ozvy5f8/repository/fsu7tkaw/master/shixun_show/src/ pathArray.length = pathArray.length - 1; @@ -25,14 +26,13 @@ class TPMRepositoryComponentdetails extends Component { } componentDidUpdate(prevProps, prevState) { if (this.props.secret_repository_tab != prevProps.secret_repository_tab) { - this.fetchRepo() + this.fetchRepo() } } componentDidMount = () => { - - this.fetchRepo() + this.fetchRepo() } setContentWidth100 = (flag) => { const newFileContent = flag === false ? '' : this.state.fileContent @@ -57,7 +57,7 @@ class TPMRepositoryComponentdetails extends Component { }); } trace_collapse('tpm save code res: ', response) - this.props.showSnackbar('文件保存成功') + this.props.showNotification('文件保存成功') }).catch((error)=>{ console.log(error) @@ -65,7 +65,6 @@ class TPMRepositoryComponentdetails extends Component { } fetchCode = (newPathArray) => { const path = newPathArray.join('/') - debugger // https://testeduplus2.educoder.net/shixuns/3ozvy5f8/file_content.json this.setContentWidth100(true) @@ -79,7 +78,12 @@ class TPMRepositoryComponentdetails extends Component { trace_collapse('repository res: ', response) if (response.data.status == -1) { - this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') + // this.props.showNotification('无法找到对应的资源,请变更地址或联系管理员!') + return; + } + if (response.data.status == -2) { + this.props.showNotification(response.data.message) + // this.props.showNotification('无法找到对应的资源,请变更地址或联系管理员!') return; } if(response.status === 200){ @@ -92,7 +96,7 @@ class TPMRepositoryComponentdetails extends Component { } }).catch((error)=>{ - this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') + // this.props.showNotification('无法找到对应的资源,请变更地址或联系管理员!') console.log(error) }); } @@ -107,8 +111,12 @@ class TPMRepositoryComponentdetails extends Component { } // listItem 如果是num,则是通过面包屑点击过来的,取pathArray的子集 fetchRepo = (listItem) => { - console.log(2) - debugger + + if(listItem === "main"||listItem){ + this.props.history.replace(`/shixuns/${this.props.match.params.shixunId}/repository`) + return; + } + const { pathArray } = this.state; let newPathArray = pathArray.slice(0) @@ -125,7 +133,7 @@ class TPMRepositoryComponentdetails extends Component { } else if (listItem.type === 'blob') { newPathArray.push(listItem.name) this.setState({ pathArray: newPathArray }) - this.fetchCode(newPathArray) + //this.fetchCode(newPathArray) return; } } @@ -153,7 +161,7 @@ class TPMRepositoryComponentdetails extends Component { const trees = response.data.trees const treeIsFileMap = {} if (!trees || !Array.isArray(trees)) { - // this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!') + // this.props.showNotification('无法找到对应的资源,请变更地址或联系管理员!') // return; } else { trees.forEach(item => { @@ -172,7 +180,7 @@ class TPMRepositoryComponentdetails extends Component { } // 初始化时,repo接口完毕后需要看是否需要fetchCode - if (fileInPathArray) { + if (fileInPathArray&&listItem!=2) { this.fetchCode(newPathArray) } // info(response) diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js index a2586a6d6..fc1e0ee70 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repository.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repository.js @@ -61,6 +61,7 @@ class Repository extends Component { } onSelectDirectoryTree=(selectedKeys, info)=>{ + this.onRepoFileClick(info.node.props.item) } diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js index c8d6a393f..595557408 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryCodeEditor.js @@ -123,6 +123,9 @@ class RepositoryCodeEditor extends Component { } }) } + setCohetepaperbool=()=>{ + this.props.oncodechanner() + } render() { const { fileContent, shixunId, saveCode } = this.props; const { codeSaving } = this.state; @@ -178,7 +181,11 @@ class RepositoryCodeEditor extends Component {
- this.saveCode(this.extend_editor.getValue())} /> + this.setCohetepaperbool()} + onSubmits={() => this.saveCode(this.extend_editor.getValue())}/> ); diff --git a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryDirectories.js b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryDirectories.js index ea88cdfb8..6e4aab0ff 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/RepositoryDirectories.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/RepositoryDirectories.js @@ -1,66 +1,130 @@ import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames'; +import { Button ,Modal } from "antd"; import axios from 'axios'; import { trace_collapse } from 'educoder' const $ = window.$; - +const { confirm } = Modal; class RepositoryDirectories extends Component { constructor(props) { super(props) this.state = { - + } } componentDidMount() { } + + showDeleteConfirm =()=>{ + + let that=this; + + confirm({ + title: '确认需要要删除该文件?', + okText: '确定', + cancelText: '取消', + onOk() { + that.onAttachmentRemove() + } + }); + + } + onAttachmentRemove=()=>{ + + let shixunId = this.props.match.params.shixunId; + let matchpath =this.props.match.path; + let Repositoryflag =undefined; + + if( matchpath.indexOf("repository")>-1){ + Repositoryflag =undefined; + } + if(matchpath.indexOf("secret_repository")>-1){ + Repositoryflag =true; + } + + let newfilspath=this.state.ischeckevalue; + + let path=""; + + if(this.props.pathArray.length>0){ + this.props.pathArray.map((item,key)=>{ + if(key===0){ + path=item + }else{ + path=path+"/"+item + } + }) + } + + if(path===undefined||path===""){ + path=newfilspath + }else{ + path=path + } + + const url = `/shixuns//${shixunId}/delete_git_file.json`; + + axios.delete(url, { data: { + path:path, + message:"删除"+path, + secret_repository:Repositoryflag + }}) + .then((response) => { + if(response.data.status == 0) { + this.props.showNotification("删除成功") + this.props.oncodechanner() + } + }) + .catch(function (error) { + + }); + } render() { - const { match, pathArray, fetchRepo + const { match, pathArray, fetchRepo,TPMRightSectionData } = this.props; let { RepositoryList } = this.state; return ( - - { pathArray.length !== 0 && + + { pathArray.length !== 0 &&
fetchRepo(0)} + onClick={() => fetchRepo(0)} > {match.params.shixunId} - / + { pathArray.map((item, index) => { - // /shixuns/3ozvy5f8/repository/3ozvy5f8/master/shixun_show/src + if(index - { this.props.nameTypeMap[item] === 'tree' || item.indexOf('.') === -1 - ? fetchRepo(index + 1)} + + { this.props.nameTypeMap[item] === 'tree' || item.indexOf('.') === -1 + ? fetchRepo(index + 1)} className={this.props.tpmComment===true?"color888":"color-blue"} > - {item} - : - - {item} + / {item} + : + + / {item} } - {index !== pathArray.length - 1 && /} - + {index !== pathArray.length - 1 && } + ) + } }) } + { this.props.current_user && (this.props.current_user.admin ==true || (TPMRightSectionData && TPMRightSectionData.creator && TPMRightSectionData.creator.login == this.props.current_user.login)) ? + :""} +
+
} - +
- + ); } } diff --git a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js index 7336fcd9e..ff6d09d9c 100644 --- a/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js +++ b/public/react/src/modules/tpm/shixunchild/Repository/Repositoryfile.js @@ -117,7 +117,8 @@ class Repositoryfile extends Component{ } handleSubmit = (e) => { - let {path}=this.state; + let {path,trees}=this.state; + let matchpath =this.props.match.path; let flag =undefined; @@ -147,6 +148,21 @@ class Repositoryfile extends Component{ let url=`/shixuns/${this.props.match.params.shixunId}/upload_git_folder.json`; this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { + + let types=false; + trees.map((item,key)=>{ + if(item.type==="tree"){ + if(item.name===values.name){ + types=true + return + } + } + }) + + if(types===true){ + this.props.showNotification("请勿新建相同名字的文件夹") + return + } let paths; if(path===""){ paths=values.name;