版本库调整

dev_new_shixunsrepository
杨树明 5 years ago
parent cebc38512f
commit 0fef39ce57

@ -126,7 +126,7 @@ export function initAxiosInterceptors(props) {
let timestamp = Date.parse(new Date())/1000;
if (window.location.port === "3007") {
// let timestamp=railsgettimes(proxy);
console.log(timestamp)
// console.log(timestamp)
railsgettimes(`${proxy}/api/main/first_stamp.json`);
let newopens=md5(opens+timestamp)
config.url = `${proxy}${url}`;

@ -20,6 +20,8 @@ import TPMShixunDiscussContainer from './TPMShixunDiscussContainer';
import TPMRepositoryComponent from './TPMRepositoryComponent';
import TPMRepositoryComponentdetails from './TPMRepositoryComponentdetails';
import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits';
import TPMsettings from './TPMsettings/TPMsettings';
@ -133,6 +135,11 @@ const AddFile = Loadable({
loader: () => import('./shixunchild/Repository/RepositoryAddFile'),
loading: Loading,
})
// 版本库上传文件
const Uploadfile= Loadable({
loader: () => import('./shixunchild/Repository/RepositoryAddFileupload_file'),
loading: Loading,
})
const interceptorUrlArray = ['repository.json', 'commits.json', 'propaedeutics.json'
, 'challenges.json', 'discusses.json', 'ranking_list.json', 'collaborators.json']
@ -267,23 +274,23 @@ class TPMIndex extends Component {
});
});
this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => {
let url = config.url;
// console.log('tpmContentRequestInterceptor:', url)
for ( let i = 0; i < interceptorUrlArray.length; i++ ) {
if (url.indexOf(interceptorUrlArray[i]) != -1) {
url = url.split('?')[0]
console.log('loadingContent, url:', url)
this.setState({ loadingContent: true })
cacheInterceptorUrlMap[url] = true
}
}
return config;
}, function (error) {
return Promise.reject(error);
});
// this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => {
// let url = config.url;
// // console.log('tpmContentRequestInterceptor:', url)
// for ( let i = 0; i < interceptorUrlArray.length; i++ ) {
// if (url.indexOf(interceptorUrlArray[i]) != -1) {
// url = url.split('?')[0]
// console.log('loadingContent, url:', url)
//
// this.setState({ loadingContent: true })
//
// cacheInterceptorUrlMap[url] = true
// }
// }
// return config;
// }, function (error) {
// return Promise.reject(error);
// });
// Add a response interceptor
this.tpmContentResponseInterceptor = axios.interceptors.response.use((response) => {
@ -387,7 +394,8 @@ class TPMIndex extends Component {
render() {
let url = window.location.href;
let flag = url.indexOf("add_file")>-1;
let flag =false;
// url.indexOf("add_file")>-1;
return (
<div className="newMain clearfix">
@ -509,20 +517,50 @@ class TPMIndex extends Component {
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/upload_file" render={
(props) => (<Uploadfile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/add_file" render={
(props) => (<AddFile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/upload_file" render={
(props) => (<Uploadfile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/add_file" render={
(props) => (<AddFile {...this.props} {...this.state} {...props}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponentdetails {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository/master/shixun_show/:fileId" render={
(props) => (<TPMRepositoryComponentdetails {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
<Route path="/shixuns/:shixunId/secret_repository" render={
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
/>)
(props) => (<TPMRepositoryComponent {...this.props} {...this.state} {...props} secret_repository_tab={true} is_jupyter={this.state.is_jupyter}
/>)
}></Route>
{/* <Route exact path="/shixuns/:shixunId/propaedeutics" component={TPMPropaedeuticsComponent}></Route> */}
<Route exact path="/shixuns/:shixunId/propaedeutics" render={

@ -21,23 +21,16 @@ class TPMRepository extends Component {
render() {
const { loadingContent, creator, shixun, myshixun, recommend_shixuns, current_user, watched,
aboutFocus, user, match, isContentWidth100
aboutFocus, user, match, isContentWidth100,isflag
} = this.props;
return (
<React.Fragment>
<div className="tpmComment educontent clearfix mt30 mb80">
{/* 可能会影响到其他页面的样式,需要测试、协商 */}
<div className={`${isContentWidth100 ? 'width100': 'with65'} fl edu-back-white`}
<div className={`${!isflag ? 'width100': 'with65'} fl edu-back-white`}
style={{background: 'transparent'}}>
<TPMNav
match={match}
user={user}
shixun={shixun}
{...this.props}
is_jupyter={this.props.is_jupyter}
></TPMNav>
{/* <RepositoryChooseModal {...this.props}></RepositoryChooseModal> */}
{ loadingContent ?
<CircularProgress size={40} thickness={3} style={{ marginLeft: 'auto', marginRight: 'auto', marginTop: '200px', display: 'block' }}/> :
<Repository
@ -46,7 +39,7 @@ class TPMRepository extends Component {
}
</div>
{ !isContentWidth100 && <div className="with35 fr pl20">
{ isflag && <div className="with35 fr pl20">
<TPMRightSection {...this.props}></TPMRightSection>
</div>}
</div>

@ -39,7 +39,6 @@ class TPMRepositoryComponent extends Component {
componentDidMount = () => {
this.fetchRepo()
}
setContentWidth100 = (flag) => {
@ -114,6 +113,7 @@ class TPMRepositoryComponent extends Component {
}
// listItem 如果是num则是通过面包屑点击过来的取pathArray的子集
fetchRepo = (listItem) => {
const { pathArray } = this.state;
let newPathArray = pathArray.slice(0)
@ -191,33 +191,27 @@ class TPMRepositoryComponent extends Component {
render() {
const { isContentWidth100 } = 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;
}
// 需要重构
return (
<React.Fragment>
{ !isContentWidth100 ? <TPMRepository
{ flag ? <TPMRepository
{...this.props}
{...this.state}
nameTypeMap={this.nameTypeMap}
fetchRepo={this.fetchRepo}
is_jupyter={this.props.is_jupyter}
isflag={flag}
>
</TPMRepository>
:
<div className="tpmComment educontent clearfix mt30 mb80">
{/* 可能会影响到其他页面的样式,需要测试、协商 */}
<div className={`width100 fl edu-back-white`}
style={{background: 'transparent'}}>
<RepositoryCodeEditor
{...this.state}
{...this.props}
fetchRepo={this.fetchRepo}
saveCode={this.saveCode}
nameTypeMap={this.nameTypeMap}
></RepositoryCodeEditor>
</div>
</div>
:""
}
</React.Fragment>

@ -0,0 +1,231 @@
import React, { Component } from 'react';
import { Redirect } from 'react-router';
import PropTypes from 'prop-types';
import TPMRepository from './TPMRepository'
import axios from 'axios';
import { trace_collapse, info } from 'educoder'
import RepositoryCodeEditor from './shixunchild/Repository/RepositoryCodeEditor'
class TPMRepositoryComponentdetails extends Component {
constructor(props) {
super(props)
this.nameTypeMap = {}
let pathArray = []
var splitArray = window.location.pathname.split('shixun_show/');
if (splitArray[1]) {
pathArray = 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 = {
repositoryLoading: true,
pathArray: pathArray,
isContentWidth100: this._isFileInPathArray(pathArray)
}
}
componentDidUpdate(prevProps, prevState) {
if (this.props.secret_repository_tab != prevProps.secret_repository_tab) {
this.fetchRepo()
}
}
componentDidMount = () => {
this.fetchRepo()
}
setContentWidth100 = (flag) => {
const newFileContent = flag === false ? '' : this.state.fileContent
this.setState({
// isCodeFile
isContentWidth100: flag,
fileContent: newFileContent
})
}
saveCode = (content) => {
const path = this.state.pathArray.join('/')
let id = this.props.match.params.shixunId;
let url = `/shixuns/${id}/update_file.json`;
axios.post(url, {
path: path,
content
}).then((response) => {
if(response.status === 200){
this.setState({
fileContent: response.data.content,
repositoryLoading: false
});
}
trace_collapse('tpm save code res: ', response)
this.props.showSnackbar('文件保存成功')
}).catch((error)=>{
console.log(error)
});
}
fetchCode = (newPathArray) => {
const path = newPathArray.join('/')
// 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, {
path: path,
secret_repository: this.props.secret_repository_tab
}).then((response) => {
trace_collapse('repository res: ', response)
if (response.data.status == -1) {
this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!')
return;
}
if(response.status === 200){
this.setState({
fileContent: response.data.content,
repositoryLoading: false
});
// this.props.history
// .replace(`${this.props.match.url}/master/shixun_show/${newPathArray.join('/')}`)
}
}).catch((error)=>{
this.props.showSnackbar('无法找到对应的资源,请变更地址或联系管理员!')
console.log(error)
});
}
_isFileName = (name) => {
return name.indexOf('.') !== -1
}
_isFileInPathArray = (array) => {
if (!array || array.length === 0) {
return false
}
return this.nameTypeMap[array[array.length - 1]] !== 'tree' && this._isFileName( array[array.length - 1] )
}
// listItem 如果是num则是通过面包屑点击过来的取pathArray的子集
fetchRepo = (listItem) => {
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--;
// }
newPathArray = newPathArray.slice(0, listItem)
} else if (listItem.type === 'tree') {
newPathArray.push(listItem.name)
} else if (listItem.type === 'blob') {
newPathArray.push(listItem.name)
this.setState({ pathArray: newPathArray })
this.fetchCode(newPathArray)
return;
}
}
// https://testeduplus2.educoder.net/shixuns/3ozvy5f8/repository.json
this.setState({ repositoryLoading: true, pathArray: newPathArray })
let urlNewPathArray = newPathArray;
let fileInPathArray = false;
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)
}
}
const path = urlNewPathArray.join('/')
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('无法找到对应的资源,请变更地址或联系管理员!')
// return;
} else {
trees.forEach(item => {
treeIsFileMap[item.name] = item.type == 'blob'
})
}
if(response.status === 200){
this.setState({
treeIsFileMap,
...response.data,
repositoryLoading: false
});
// this.props.history
// .replace(`${this.props.match.url}` +
// (newPathArray.length ? `/master/shixun_show/${newPathArray.join('/')}` : ''))
}
// 初始化时repo接口完毕后需要看是否需要fetchCode
if (fileInPathArray) {
this.fetchCode(newPathArray)
}
// info(response)
trace_collapse('repository res: ', response)
}).catch((error)=>{
console.log(error)
});
}
render() {
const { isContentWidth100 } = 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;
}
// 需要重构
return (
<React.Fragment>
{ flag ? ""
:
<div className="tpmComment educontent clearfix mt30 mb80">
{/* 可能会影响到其他页面的样式,需要测试、协商 */}
<div className={`width100 fl edu-back-white`}
style={{background: 'transparent'}}>
<RepositoryCodeEditor
{...this.state}
{...this.props}
fetchRepo={this.fetchRepo}
saveCode={this.saveCode}
nameTypeMap={this.nameTypeMap}
></RepositoryCodeEditor>
</div>
</div>
}
</React.Fragment>
);
}
}
export default TPMRepositoryComponentdetails ;

@ -56,4 +56,8 @@
}
.padding040pxRepository{
padding: 40px 40px 0px 40px;
}
.color888{
color:#888888
}

@ -1,17 +1,14 @@
import React, { Component } from 'react';
import axios from 'axios';
import { trace, trace_collapse ,getImageUrl, toPath} from "educoder";
import {getImageUrl} from "educoder";
import RepositoryDirectories from './RepositoryDirectories';
import { Button } from "antd";
import { Button ,Tree,Icon} from "antd";
import {Link} from 'react-router-dom';
import RepositoryCombinePath from './RepositoryCombinePath';
import RepositoryNoneData from './RepositoryNoneData';
import Repositoryfile from './Repositoryfile';
import './Repository.css';
const $ = window.$;
const { TreeNode, DirectoryTree } = Tree;
// 点击按钮复制功能
function jsCopy(){
var e = document.getElementById("copy_rep_content");
@ -26,19 +23,39 @@ class Repository extends Component {
constructor(props) {
super(props);
this.state={
evaluationvisible:false,
}
}
componentDidMount() {
}
onRepoFileClick = (item) => {
onRepoFileClick = (item) => {
this.props.fetchRepo(item)
}
NewFolder=()=>{
this.setState({
evaluationvisible:true
})
}
hideNewFolder=()=>{
this.setState({
evaluationvisible:false
})
}
render() {
let { match, author, git_url, lastest_commit,repositoryLoading, commits,trees,pathArray , TPMRightSectionData } = this.props;
let matchpath =this.props.match.path;
let Repositoryflag ="";
if(matchpath==="/shixuns/:shixunId/repository"){
Repositoryflag ="repository";
}else if(matchpath==="/shixuns/:shixunId/secret_repository"){
Repositoryflag ="secret_repository";
}
if (!author) {
author = {}
}
@ -48,6 +65,12 @@ class Repository extends Component {
}
return (
<React.Fragment>
{this.state.evaluationvisible===true?<Repositoryfile
{...this.state}
{...this.props}
hideNewFolder={()=>this.hideNewFolder()}
setfilepath={(path)=>this.setfilepath(path)}
/>:""}
{ repositoryLoading ? <div style={{ minHeight: '500px'}}></div> :
<div className="mb10" id="collaborators_list_info">
<div className="clearfix edu-back-white">
@ -126,18 +149,21 @@ class Repository extends Component {
(
<div>
<Button type="primary"
onClick={this.NewFolder}
className="edu-default-btn edu-greenback-btn mt5 fr"
>新建文件夹</Button>
<Link to={`/shixuns/${match.params.shixunId}/repository/add_file`}>
<Link to={`/shixuns/${match.params.shixunId}/${Repositoryflag}/add_file`}>
<Button type="primary"
className="edu-default-btn edu-greenback-btn mt5 mr10 fr"
>新建文件</Button>
</Link>
<Link to={`/shixuns/${match.params.shixunId}/${Repositoryflag}/upload_file`}>
<Button type="primary"
className="edu-default-btn edu-greenback-btn mt5 mr10 fr"
>上传文件</Button>
</Link>
</div>
)
@ -215,6 +241,13 @@ class Repository extends Component {
)
})}
</div>
<DirectoryTree multiple defaultExpandAll onSelect={this.onSelect} onExpand={this.onExpand}>
<TreeNode title="parent 0" key="0-0" icon={<i className="iconfont icon-xingzhuangjiehebeifen color-blue font-12" />}>
<TreeNode title="leaf 0-0" key="0-0-0" isLeaf icon={<i className="iconfont icon-xingzhuangjiehe color-blue font-12" />} />
<TreeNode title="leaf 0-1" key="0-0-1" isLeaf icon={<i className="iconfont icon-xingzhuangjiehe color-blue font-12" />}/>
</TreeNode>
</DirectoryTree>
</div>
</div>

@ -6,6 +6,7 @@ import { Form , Modal , Input , Breadcrumb , Button } from 'antd'
import { Link } from 'react-router-dom'
import axios from 'axios'
import Bottomsubmit from "../../../modals/Bottomsubmit";
/**
---------------------------- START
@ -121,7 +122,8 @@ class RepositoryAddFile extends Component {
const {getFieldDecorator} = this.props.form;
let { shixunId } = this.props.match.params;
return(
<div className="educontent">
<div>
<div className="educontent">
<style>
{`
.formStyle .ant-form-item{
@ -135,9 +137,9 @@ class RepositoryAddFile extends Component {
.breadcrumb .ant-breadcrumb-separator{
margin:0px 2px;
}
.backgroudwhite{
display:none;
}
// .backgroudwhite{
// display:none;
// }
/*.filecode .CodeMirror.cm-s-railscasts{
border:1px solid #E5E5E5;
}
@ -187,11 +189,13 @@ class RepositoryAddFile extends Component {
</Form.Item>
</div>
<div className="clearfix mt30 edu-txt-right mb30">
<Button type="primary" className="defalutSubmitbtn fr ml20" onClick={this.handleSubmit}>提交</Button>
<Link className="defalutCancelbtn fr" to={`/shixuns/${shixunId}/repository`}>取消</Link>
{/*<Button type="primary" className="defalutSubmitbtn fr ml20" onClick={this.handleSubmit}>提交</Button>*/}
{/*<Link className="defalutCancelbtn fr" to={`/shixuns/${shixunId}/repository`}>取消</Link>*/}
</div>
</Form>
</div>
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/repository`} onSubmits={() => this.handleSubmit()}/>
</div>
)
}

@ -0,0 +1,201 @@
import React, { Component } from 'react';
import { Form , Upload , Input , Icon, message } from 'antd';
import axios from 'axios';
import { getUploadActionUrl } from 'educoder';
import Bottomsubmit from "../../../modals/Bottomsubmit";
import "./Repository.css"
const { Dragger } = Upload;
class RepositoryAddFileupload_files extends Component {
constructor(props) {
super(props);
this.state={
filspath:"",
fileList: [
// {
// uid: '-1',
// name: 'xxx.png',
// status: 'done',
// url: 'http://www.baidu.com/xxx.png',
// },
]
}
}
componentDidMount(){
}
handleSubmit = () =>{
this.props.form.validateFieldsAndScroll((err, values) => {
if(!err){
// let shixunId = this.props.match.params.shixunId;
// let url = `/shixuns/${shixunId}/add_file.json`
// axios.post(url,{
// path:values.path,
// message:values.message,
// content:this.extend_editor.getValue()
// }).then((result)=>{
// if(result){
// this.props.history.push(`${result.data.url}`)
// }
// }).catch((error)=>{
// console.log(error);
// })
}
})
}
handleChange = (info) => {
const { status } = info.file;
if (status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (status === 'done') {
message.success(`${info.file.name} file uploaded successfully.`);
} else if (status === 'error') {
message.error(`${info.file.name} file upload failed.`);
}
let fileList = [...info.fileList];
fileList = fileList.slice(-2);
fileList = fileList.map(file => {
if (file.response) {
file.url = file.response.url;
}
return file;
});
this.setState({ fileList });
console.log(fileList)
};
onAttachmentRemove=(info)=>{
}
render(){
const {getFieldDecorator} = this.props.form;
let { shixunId } = this.props.match.params;
const props = {
height:300,
name: 'file',
multiple: true,
fileList:this.state.fileList,
action: getUploadActionUrl(),
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
// beforeUpload: (file) => {
// console.log('beforeUpload', file.name);
// const isLt150M = file.size / 1024 / 1024 < 150;
// if (!isLt150M) {
// this.props.showNotification('文件大小必须小于150MB!');
// }
// return isLt150M;
// },
};
return(
<div>
<div className="educontent mt30">
<style>
{`
.formStyle .ant-form-item{
margin-bottom:10px!important;
}
// .formStyle .ant-col.ant-form-item-label{
// margin-left:-10px;
// line-height:30px;
// margin-bottom:10px;
// }
.breadcrumb .ant-breadcrumb-separator{
margin:0px 2px;
}
.ant-upload ant-upload-drag{
height: 300px;
}
// .backgroudwhite{
// display:none;
// }
/*.filecode .CodeMirror.cm-s-railscasts{
border:1px solid #E5E5E5;
}
.filecode .CodeMirror.cm-s-railscasts .CodeMirror-sizer,.filecode .CodeMirror-gutters,.filecode .CodeMirror-scroll{
background:#fff;
}
.filecode .CodeMirror-linenumber{
text-align:center
}*/
`}
</style>
{/*<p className="mt10 mb10">*/}
{/* <Breadcrumb separator='>' className="breadcrumb">*/}
{/* <Breadcrumb.Item href='/shixuns'>实训项目</Breadcrumb.Item>*/}
{/* <Breadcrumb.Item href={`/shixuns/${shixunId}/repository`}>版本库</Breadcrumb.Item>*/}
{/* <Breadcrumb.Item>添加新文件</Breadcrumb.Item>*/}
{/* </Breadcrumb>*/}
{/*</p>*/}
<Form onSubmit={this.handleSubmit} className="formStyle">
<div className="edu-back-white padding20-30 mb10">
<p className="ant-form-item-label">
<div className={"font-20 color-black"}>上传文件</div>
</p>
<Form.Item label="提交信息">
{getFieldDecorator('message', {
rules: [{
required: true, message: '请输入名称',
},{
whitespace: true, message: '请勿输入空格'
}],
})(
<Input placeholder="必填描述主要修改内容相当于Git Commit message的Header" className="winput-300-35 fl"/>
)}
</Form.Item>
<p className="ant-form-item-label">
<div className={"color888 font-16"}>{this.state.filspath} <span className={"color-blue"}>选择文件目录</span></div>
</p>
{/*<div className="mt10 mb25 repoCMWrapper filecode">*/}
{/* <textarea className="" id="codemirror-file-edit" style={{display:'none'}} name="content"></textarea>*/}
{/*</div>*/}
<Dragger {...props}>
<p className="ant-upload-drag-icon">
<i className="iconfont icon-shangchuan font-50 color-blue" />
</p>
<p className="ant-upload-hint mt20">
拖拽文件或 <span className="color-blue" >点击此处上传</span>
</p>
</Dragger>
{/*<Form.Item label="提交信息">*/}
{/* {getFieldDecorator('message', {*/}
{/* rules: [{required: true, message: "请输入提交信息"}],*/}
{/* })(*/}
{/* <textarea className="winput-100-130 fl"></textarea>*/}
{/* )}*/}
{/*</Form.Item>*/}
</div>
</Form>
</div>
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${shixunId}/repository`} onSubmits={() => this.handleSubmit()}/>
</div>
)
}
}
const RepositoryAddFileupload_file = Form.create({name: 'RepositoryAddFileupload_files'})(RepositoryAddFileupload_files);
// RouteHOC()
export default (RepositoryAddFileupload_file);

@ -0,0 +1,239 @@
import React, { Component } from 'react';
import {Modal,Input,Form} from "antd";
import axios from 'axios';
import {TPMIndexHOC} from "../../TPMIndexHOC";
class Repositoryfile extends Component{
constructor(props) {
super(props)
this.state={
selectpath:"",
trees:[],
main:[],
path:""
}
}
// sendgetfilepath=(item)=>{
// this.getfilepath(item.name);
//
// }
evaluationhideModal=()=>{
this.props.hideNewFolder();
}
componentDidMount() {
this.goblakepath("")
}
goblakepath=(path,key)=>{
let {main} =this.state;
let matchpath =this.props.match.path;
let id = this.props.match.params.shixunId;
let url ="";
if(matchpath==="/shixuns/:shixunId/repository"){
url ="/shixuns/"+id+"/repository.json";
}else if(matchpath==="/shixuns/:shixunId/secret_repository"){
url ="/shixuns/"+id+"/secret_repository.json";
}
let newmain=[]
for(var i=0;i<=key;i++){
newmain.push(main[i])
}
axios.post(url,{
path: path
}).then((response) => {
if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
}else {
this.setState({
trees: response.data.trees,
path: path,
main: newmain,
// selectpath:selectpath
})
}
}).catch((error) => {
console.log(error)
});
}
sendgetfilepath=(newpath,type)=>{
let id = this.props.match.params.shixunId;
let{path,main}=this.state;
let matchpath =this.props.match.path;
let url ="";
if(matchpath==="/shixuns/:shixunId/repository"){
url ="/shixuns/"+id+"/repository.json";
}else if(matchpath==="/shixuns/:shixunId/secret_repository"){
url ="/shixuns/"+id+"/secret_repository.json";
}
let ary=main;
let paths=path;
this.setState({
selectpatharr:[],
})
if(paths===""&&type==="tree"){
newpath=newpath+"/";
paths="";
if(main.length===0){
ary.push({val:"根目录/",path:""},{val:newpath,path:paths+newpath})
}else{
ary.push({val:newpath,path:paths+newpath})
}
}else if(paths!=""&&type==="tree"){
newpath=newpath+"/";
ary.push({val:newpath,path:paths+newpath})
}
axios.post(url,{
path: paths+newpath
}).then((response) => {
if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
}else{
this.setState({
trees:response.data.trees,
path:paths+newpath,
main:ary,
// selectpath:""
})
}
}).catch((error) => {
console.log(error)
});
}
handleSubmit = (e) => {
let {path}=this.state;
let matchpath =this.props.match.path;
let flag =false;
if(matchpath==="/shixuns/:shixunId/repository"){
flag =false;
}else if(matchpath==="/shixuns/:shixunId/secret_repository"){
flag =true;
}
let url=`/shixuns/${this.props.match.params.shixunId}/upload_git_folder.json`;
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
let paths=path+values.name;
axios.post(url,{
path: paths,
secret_repository:flag,
}).then((result)=>{
if(result){
if(result.data.status===0){
this.props.showNotification("新建成功")
}
}
}).catch((error)=>{
console.log(error);
})
}
});
};
render(){
const {getFieldDecorator} = this.props.form;
const {evaluationvisible} = this.props;
const {selectpath,trees,main,path}=this.state;
return(
evaluationvisible===true?<Modal
keyboard={false}
title="新建文件夹"
visible={evaluationvisible}
closable={false}
footer={false}
>
<div className="task_popup_con">
<style>
{
`
.ant-form-explain{
padding-left: 0px;
margin-top:5px;
}
`
}
</style>
<div className="newupload_conbox clearfix">
<ul id="directory_file">
{
main.length===0?"":main.map((item,key)=>{
return(
<a className="f14 fb" onClick={()=>this.goblakepath(item.path,key,item)}>{item.val}</a>
)
})
}
{/*文件*/}
{trees === undefined || trees === null ? "" : trees.map((item, key) => {
return(
<li className="entry" key={key}>
<div className="filename_no_report hidden">{
item.type==="tree"?<a onClick={()=>this.sendgetfilepath(item.name,item.type)} data-remote="true">
<i className="iconfont icon-wenjianjia color-blue mr2"></i>
{item.name}</a>:""
}
</div>
</li>
)
})}
</ul>
{/*
<a data-remote="true">
<i className="iconfont icon-zuoye color-blue mr2"></i>
<span onClick={()=>this.savegetfilepath(path+item.name,item.type)}>{item.name}</span>
</a>
*/}
<div className="clearfix mt5">
<label className=" mt5">选中的新建文件夹目录</label>
<div className={"mt5 mb5"} >{path}</div>
<Form>
<Form.Item
className="mt15"
>
{getFieldDecorator('name', {
rules: [{
required: true, message: '请输入名称',
},{
whitespace: true, message: '请勿输入空格'
}],
})(
<Input id="points_tusi" placeholder="请输入新建文件夹目录名称" className="input-60-40"
style={{width:"400px"}}
/>
)}
</Form.Item>
</Form>
</div>
<a className="task-btn task-btn-orange fr"
style={{marginTop: '20px',marginLeft:'20px'}} id="add_path"
// onClick={()=>this.evaluationenter()}
onClick={() => this.handleSubmit()}>确定</a>
<a className="pop_close task-btn mb10 fr"
style={{marginTop: '20px'}} id="back_page" onClick={()=>this.evaluationhideModal()}>取消</a>
</div>
</div>
</Modal>:""
)
}
}
const newRepositoryfile = Form.create({name: 'newRepositoryfile'})(Repositoryfile);
export default newRepositoryfile;
Loading…
Cancel
Save