数据集-v1

This commit is contained in:
caishi 2024-04-08 10:12:38 +08:00
parent 4bd0d67f87
commit a513442751
7 changed files with 64 additions and 22 deletions

View File

@ -1,13 +1,15 @@
import React, { useState , useEffect } from 'react';
import { Button , Table } from 'antd';
import { Button , Table , Tooltip } from 'antd';
import { getImageUrl } from 'educoder';
import paperImg from './image/paperImg.png';
import NewModal from './component/new';
import { Link } from 'react-router-dom';
import "./index.scss";
import axios from 'axios';
function Index(props){
const { project , match } =props;
const { project , match , current_user , projectDetail , getProject } =props;
const permission = current_user && current_user.login ? (projectDetail && projectDetail.permission):"";
const { owner ,projectsId } = match && match.params;
const [ dataSource , setDataSource ] = useState([]);
const [ empty , setEmpty ] = useState(project && (!project.has_dataset));
@ -15,7 +17,8 @@ function Index(props){
const [ page , setPage ] = useState(1);
const [ visible , setVisible ] = useState(false);
const [ detail , setDetail ] = useState({});
const pageSize = 20;
const pageSize = 10;
useEffect(()=>{
if(!empty){
Init();
@ -51,7 +54,10 @@ function Index(props){
dataIndex:"description",
key:2,
ellipsis:true,
width:"30%"
width:"30%",
render:(value)=>{
return <Tooltip title={value}>{value}</Tooltip>
}
},
{
title:"创建者",
@ -59,7 +65,7 @@ function Index(props){
key:3,
width:"10%",
render:(value,item)=>{
return <img src={getImageUrl(`/${value.image_url}`)} alt="" style={{borderRadius:"50%"}} width="32px" height="32px" />
return <Link to={`/${value.login}`}><img src={getImageUrl(`/${value.image_url}`)} alt="" style={{borderRadius:"50%"}} width="32px" height="32px" /></Link>
}
},
{
@ -88,6 +94,7 @@ function Index(props){
function addFunc(){
setEmpty(false);
setVisible(false);
getProject && getProject();
detail && detail.id && Init();
}
return(
@ -98,14 +105,14 @@ function Index(props){
<span className="font-16">数据集</span>
:
<React.Fragment>
<div>
<p className="font-16 weight500">{detail.title}</p>
<p>{detail.description}</p>
<div style={{width:0,flex:1}} className="mr20">
<div className="df mb15" style={{alignItems:"center"}}><p className="font-16 weight500 task-hide">{detail.title}</p>{ detail.license_name ? <span className="license ml20">许可证 : {detail.license_name}</span> :""}</div>
<p style={{wordBreak:"break-all"}}>{detail.description}</p>
</div>
<div className="df">
{(permission && permission!== "") ? <div className="df">
<Button type="primary" ghost onClick={()=>{setVisible(true)}}><i className="iconfont icon-a-bianji12 color-blue mr5 font-12"></i>编辑</Button>
<Link className="ml20 operateButton" to={`/${owner}/${projectsId}/dataset/upload`}><i className="iconfont icon-a-shangchuan2x color-white mr5 font-13"></i>上传文件</Link>
</div>
</div>:""}
</React.Fragment>
}
</div>
@ -114,8 +121,8 @@ function Index(props){
<div className={"emtpyData"}>
<img src={require('./image/empty.png')} alt="" width="68px"/>
<span className="font-22 weight400 color-grey-3">暂无数据集</span>
<p className="mt25 font-15 color-grey-6 weight400">我们非常欢迎您创建并分享您的数据集以便与其他用户共同促进开源社区的发展</p>
<Button type="primary" className="mt15" onClick={()=>{setVisible(true)}}>创建数据集</Button>
{ (permission && permission!== "") ? <p className="mt25 font-15 color-grey-6 weight400">我们非常欢迎您创建并分享您的数据集以便与其他用户共同促进开源社区的发展</p> :"" }
{ (permission && permission!== "") ? <Button type="primary" className="mt15" onClick={()=>{setVisible(true)}}>创建数据集</Button> :""}
</div>
:
<Table
@ -125,6 +132,14 @@ function Index(props){
pagination={{total,pageSize,current:page,hideOnSinglePage:true,onChange:(p)=>setPage(p)}}
/>
}
{
detail.paper_content ?
<div className="mt25">
<p className="mb15 df" style={{alignItems:'center'}}><img src={paperImg} width={24} className="mr10" alt="" /><span className="font-16">研究论文</span></p>
<div className={`mnistData`}>{ detail.paper_content }</div>
</div>
:""
}
</div>
)
}

View File

@ -94,7 +94,7 @@ function New(props){
onCancel={onCancel}
>
<Form>
<Form.Item label="名称">
<Form.Item label="数据集名称">
{getFieldDecorator('title', {
rules: [
{
@ -103,7 +103,7 @@ function New(props){
}
],
})(
<Input placeholder="请输入数据集名称" />,
<Input placeholder="请输入数据集名称" maxLength={100} />,
)}
</Form.Item>
<Form.Item label="开源许可证">
@ -128,7 +128,7 @@ function New(props){
</AutoComplete>
)}
</Form.Item>
<Form.Item label="描述">
<Form.Item label="数据集描述">
{getFieldDecorator('description', {
rules: [
{
@ -136,12 +136,12 @@ function New(props){
message:"请输入描述内容"
}
]})(
<TextArea placeholder="请输入描述内容" autosize={{ minRows: 5, maxRows: 5 }} showCount/>,
<TextArea maxLength={500} placeholder="请输入描述内容" autosize={{ minRows: 5, maxRows: 5 }} showCount/>,
)}
</Form.Item>
<Form.Item label="研究论文">
{getFieldDecorator('paper_content', {rules:[]})(
<TextArea placeholder="请输入研究论文" autosize={{ minRows: 5, maxRows: 5 }} showCount/>,
<TextArea maxLength={500} placeholder="请输入研究论文" autosize={{ minRows: 5, maxRows: 5 }} showCount/>,
)}
</Form.Item>
<div className="center">

View File

@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Upload ,Form ,Input , Button } from 'antd';
import { Upload ,Form ,Input , Button , message } from 'antd';
import '../index.scss';
import { Link } from 'react-router-dom';
import axios from 'axios';
@ -53,13 +53,28 @@ function UploadModal(props){
}
})
}
function isFolder(fileName) {
//
const lastDotIndex = fileName.lastIndexOf('.');
//
const nameAfterLastSlash = fileName.substring(fileName.lastIndexOf('/') + 1);
//
return lastDotIndex !== -1 && nameAfterLastSlash.includes('.');
}
const upload= {
name: 'file',
multiple: false,
maxCount:1,
type:"file",
beforeUpload: file => {
const isDirectory = file.type;
const name = file.name;
if (!isDirectory && !isFolder(name)) {
message.error('不能上传文件夹!');
}else{
setFileList([file]);
}
return false;
},
onRemove: file => {

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

View File

@ -4,7 +4,7 @@
padding:25px 0px;
.mnistData{
background: #FAFCFF;
border-radius: 3px 3px 0px 0px;
border-radius: 3px;
border: 1px solid rgba(42,97,255,0.23);
padding:20px;
display: flex;
@ -16,9 +16,20 @@
color: #202D40;
line-height: 22px;
&:first-child{
margin-bottom: 15px!important;
max-width: 600px;
}
}
.license{
height: 40px;
line-height: 40px;
background: #ECEFFE;
border-radius: 6px 6px 6px 6px;
padding:0px 12px;
font-weight: bold;
font-size: 15px;
color: #202D40;
display: inline-block;
}
}
.datasetTable{
.ant-table-thead > tr > th{

View File

@ -564,6 +564,7 @@ class Detail extends Component {
const common = {
getDetail: this.getDetail,
getBanner: this.getBanner,
getProject:this.getProject,
changeOpenDevops: this.changeOpenDevops,
defaultBranch
}

View File

@ -228,7 +228,7 @@
li{
text-align: center;
padding:0px;
margin-right: 35px;
margin-right: 30px;
display: flex;
& > a{
position: relative;