forked from Gitlink/forgeplus-react
change blockchain related things
This commit is contained in:
parent
b59e83ee00
commit
21762c21eb
1441
.idea/workspace.xml
1441
.idea/workspace.xml
File diff suppressed because it is too large
Load Diff
|
@ -178,7 +178,7 @@
|
|||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"proxy": "http://localhost:3000",
|
||||
"proxy": "http://localhost:3001",
|
||||
"port": "3007",
|
||||
"devDependencies": {
|
||||
"@babel/runtime": "7.0.0-beta.51",
|
||||
|
@ -198,7 +198,7 @@
|
|||
"purgecss": "^2.1.2",
|
||||
"reqwest": "^2.0.5",
|
||||
"resize-observer-polyfill": "^1.5.1",
|
||||
"terser-webpack-plugin": "^2.3.5",
|
||||
"terser-webpack-plugin": "^2.3.8",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"webpack": "^4.42.1",
|
||||
"webpack-bundle-analyzer": "^3.7.0"
|
||||
|
|
|
@ -57,8 +57,8 @@ export function initAxiosInterceptors(props) {
|
|||
initOnlineOfflineListener()
|
||||
// TODO 避免重复的请求 https://github.com/axios/axios#cancellation
|
||||
var
|
||||
proxy = "http://localhost:3000";
|
||||
proxy = "https://testforgeplus.trustie.net";
|
||||
proxy = "http://localhost:3001";
|
||||
// proxy = "https://testforgeplus.trustie.net";
|
||||
|
||||
const requestMap = {};
|
||||
window.setfalseInRequestMap = function (keyName) {
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
import React , { useState , useEffect } from 'react';
|
||||
import { Spin } from 'antd';
|
||||
import { Blueback } from '../Component/layout';
|
||||
import Editor from "react-monaco-editor";
|
||||
import Modals from './DisposeModal';
|
||||
import FileLanguage from '../Component/OpsFileLanguage';
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
function Dispose(props){
|
||||
const [ spining , setSpining ] = useState(true);
|
||||
const [ info , setInfo ] = useState('.trustie-pipeline.yml');
|
||||
const [ visible , setVisible ] = useState(false);
|
||||
const [ ymlValue , setYmlValue ] = useState("");
|
||||
const [ sha , setSha ] = useState(undefined);
|
||||
const [ fileLanguage , setFileLanguage ] = useState(undefined);
|
||||
const [ first , setFirst ] = useState(false);
|
||||
|
||||
let projectsId = props.match.params.projectsId;
|
||||
let owner = props.match.params.owner;
|
||||
useEffect(()=>{
|
||||
if(projectsId){
|
||||
const url = `/${owner}/${projectsId}/get_trustie_pipeline.json`;
|
||||
axios.get(url,{
|
||||
params:{
|
||||
project_id:projectsId
|
||||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data.content){
|
||||
setInfo(result.data.name);
|
||||
setYmlValue(result.data.content);
|
||||
setFirst(true);
|
||||
setSha(result.data.sha);
|
||||
}else{
|
||||
setFirst(false);
|
||||
}
|
||||
setSpining(false);
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
},[projectsId])
|
||||
|
||||
// 修改文件内容
|
||||
function changeEditor(value){
|
||||
setYmlValue(value);
|
||||
}
|
||||
|
||||
// 切换语言
|
||||
function select_language(value,array){
|
||||
setFileLanguage(value);
|
||||
setYmlValue( array && array.content);
|
||||
}
|
||||
|
||||
// 确定提交
|
||||
function submit(){
|
||||
let url = '';
|
||||
const { defaultBranch } = props;
|
||||
let params = {
|
||||
branch: defaultBranch,
|
||||
content:ymlValue,
|
||||
filepath:info,
|
||||
message:''
|
||||
}
|
||||
if(first){
|
||||
// 为true,则是编辑否则是新建
|
||||
url = `/${owner}/${projectsId}/update_trustie_pipeline.json`;
|
||||
axios.put(url,{
|
||||
...params,
|
||||
sha
|
||||
}).then(result=>{
|
||||
if(result){
|
||||
setVisible(true);
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}else{
|
||||
url = `/${owner}/${projectsId}/create_file.json`;
|
||||
axios.post(url,params).then(result=>{
|
||||
if(result){
|
||||
setVisible(true);
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
}
|
||||
function suresubmit(){
|
||||
setVisible(false);
|
||||
props.history.push(`/projects/${owner}/${projectsId}/devops/list`);
|
||||
}
|
||||
|
||||
return(
|
||||
<Spin spinning={spining}>
|
||||
<Modals visible={visible} closeFunc={(flag)=>setVisible(flag)} sureFunc={suresubmit}></Modals>
|
||||
<p>编程语言:</p>
|
||||
|
||||
<div className="mt20 mb20">
|
||||
<FileLanguage language={fileLanguage} select_language={select_language}/>
|
||||
</div>
|
||||
<p>配置脚本:</p>
|
||||
<div className="editorBody">
|
||||
<p className="editorHead">{info}</p>
|
||||
<Editor
|
||||
height="300px"
|
||||
language={"yml"}
|
||||
theme={"vs-grey"}
|
||||
defaultValue="请输入内容"
|
||||
value={ymlValue}
|
||||
options={"editor_options"}
|
||||
onChange={changeEditor}
|
||||
></Editor>
|
||||
</div>
|
||||
<Blueback onClick={submit}>确定提交</Blueback>
|
||||
</Spin>
|
||||
)
|
||||
}
|
||||
export default Dispose;
|
|
@ -42,6 +42,8 @@ class MessageCount extends Component {
|
|||
pr_status: undefined,
|
||||
|
||||
copyVisible:false,
|
||||
|
||||
fix_issue_id: "",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -120,7 +122,7 @@ class MessageCount extends Component {
|
|||
SpinMerge: true,
|
||||
});
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
const { data, title, body, mergekey, pr_status } = this.state;
|
||||
const { data, title, body, mergekey, pr_status, fix_issue_id } = this.state;
|
||||
const url = `/${owner}/${projectsId}/pulls/${data.pull_request.id}/pr_merge.json`;
|
||||
axios
|
||||
.post(url, {
|
||||
|
@ -129,6 +131,7 @@ class MessageCount extends Component {
|
|||
do: mergekey,
|
||||
body: body,
|
||||
title: title,
|
||||
fix_issue_id: fix_issue_id,
|
||||
})
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
|
@ -160,6 +163,12 @@ class MessageCount extends Component {
|
|||
});
|
||||
};
|
||||
|
||||
changefixissue = (e) => {
|
||||
this.setState({
|
||||
fix_issue_id: parseInt(e.target.value),
|
||||
});
|
||||
};
|
||||
|
||||
submitmerge = () => {
|
||||
if (this.state.mergekey === "rebase") {
|
||||
this.setState({
|
||||
|
@ -497,6 +506,12 @@ class MessageCount extends Component {
|
|||
value={this.state.body}
|
||||
onChange={this.changbodypr}
|
||||
/>
|
||||
<Input
|
||||
placeholder="请输入解决的issue id"
|
||||
style={{ marginTop: 20 }}
|
||||
value={this.state.fix_issue_id}
|
||||
onChange={this.changefixissue}
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
className="clearfix mt15"
|
||||
|
|
|
@ -6,6 +6,8 @@ import { Base64 } from 'js-base64';
|
|||
import '../css/index.scss';
|
||||
import './new.css'
|
||||
|
||||
import { findDOMNode } from 'react-dom'
|
||||
|
||||
import axios from 'axios';
|
||||
const Option = Select.Option;
|
||||
class Index extends Component {
|
||||
|
@ -224,6 +226,11 @@ class Index extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
// add by zxh: handleBlockchainChange
|
||||
handleBlockchainChange = (event) => {
|
||||
console.log("here need the change of display")
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
// 项目类型:deposit-托管项目,mirror-镜像项目
|
||||
|
@ -438,6 +445,39 @@ class Index extends Component {
|
|||
<Checkbox value="limit">将项目设为私有<span className="ml15 font-13 color-grey-9">(只有项目所有人或拥有权限的项目成员才能看到)</span></Checkbox>
|
||||
)}
|
||||
</Form.Item >
|
||||
{/*增加区块链选项,不要求必选,默认是选择的*/}
|
||||
<Form.Item
|
||||
label="确权"
|
||||
style={{ margin: "0px" }}
|
||||
className="privatePart"
|
||||
>
|
||||
{getFieldDecorator('blockchain')(
|
||||
<Checkbox value="limit" onClick={this.handleBlockchainChange}>项目加入确权机制<span className="ml15 font-13 color-grey-9">(贡献确权上链并使用token机制)</span></Checkbox>
|
||||
)}
|
||||
</Form.Item >
|
||||
|
||||
<Form.Item
|
||||
style={{ margin: "15px", display: "block" }}
|
||||
className="privatePart"
|
||||
ref={(blockchain_item => {this.blockchain_item = blockchain_item})}
|
||||
>
|
||||
{getFieldDecorator('blockchain_token_all', {
|
||||
rules: [{
|
||||
required: false, message: '请填写项目token总数(单位:枚)'
|
||||
}],
|
||||
})(
|
||||
<Input placeholder="请填写项目token总数(单位:枚)" />
|
||||
)}
|
||||
|
||||
{getFieldDecorator('blockchain_init_token', {
|
||||
rules: [{
|
||||
required: false, message: '请填写项目创始人获取token总数(单位:枚)'
|
||||
}],
|
||||
})(
|
||||
<Input placeholder="请填写项目创始人获去总token的百分比(%)" />
|
||||
)}
|
||||
</Form.Item>
|
||||
|
||||
{
|
||||
projectsType !== "deposit" &&
|
||||
<Form.Item
|
||||
|
|
|
@ -36,11 +36,13 @@ class Detail extends Component {
|
|||
visible: false,
|
||||
journal_spin: false,
|
||||
edit_spin: false,
|
||||
blockchain_token_num: 0,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
this.getDetail();
|
||||
this.getBlockchainTokenNum();
|
||||
};
|
||||
|
||||
getDetail = () => {
|
||||
|
@ -61,6 +63,20 @@ class Detail extends Component {
|
|||
});
|
||||
};
|
||||
|
||||
getBlockchainTokenNum = () => {
|
||||
const { projectsId, orderId, owner } = this.props.match.params;
|
||||
const url = `/blockchain/issue/get_token_num`;
|
||||
axios.post(url,{
|
||||
"issue_id": {orderId}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
this.state.blockchain_token_num = result.data.blockchain_token_num;
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
};
|
||||
|
||||
handleok = () => {
|
||||
this.setState({
|
||||
isShow: false,
|
||||
|
@ -330,6 +346,10 @@ class Detail extends Component {
|
|||
)}
|
||||
</span>
|
||||
</p>
|
||||
<p className="grid-item-left pb15">
|
||||
<span className="issue_detail_info">悬赏金额:</span>
|
||||
<span>{this.state.blockchain_token_num}</span>
|
||||
</p>
|
||||
<p className="grid-item-left pb15">
|
||||
<span className="issue_detail_info">里程碑:</span>
|
||||
<span className="title_overflow">
|
||||
|
|
|
@ -13,6 +13,7 @@ const Option = Select.Option;
|
|||
class order_form extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.getTokenProject(props.current_user.user_id, this.props.match.params.owner, this.props.match.params.projectsId);
|
||||
this.state = {
|
||||
branch_name: "",
|
||||
issue_tag_ids: "",
|
||||
|
@ -35,9 +36,27 @@ class order_form extends Component {
|
|||
get_attachments: undefined,
|
||||
show_token: false,
|
||||
cannot_edit: false,
|
||||
issue_current_user: true
|
||||
issue_current_user: true,
|
||||
issue_token_num: 0,
|
||||
blockchain_token_num: 0
|
||||
};
|
||||
}
|
||||
|
||||
getTokenProject = (user_id, owner_login, project_name) => {
|
||||
const url = `/users/blockchain/balance_project`;
|
||||
axios.post(url,{
|
||||
user_id: user_id,
|
||||
owner_login: owner_login,
|
||||
project_name: project_name
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
this.state.issue_token_num = result.data.balance;
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
componentDidUpdate=(prevPros)=>{
|
||||
if(prevPros && this.props && this.props.checkIfLogin()===false){
|
||||
this.props.history.push("/403")
|
||||
|
@ -152,7 +171,7 @@ class order_form extends Component {
|
|||
if (values.issue_tag_ids.length > 0) {
|
||||
values.issue_tag_ids = [values.issue_tag_ids];
|
||||
}
|
||||
const { description, start_date, due_date, issue_type } = this.state;
|
||||
const { description, start_date, due_date, issue_type, blockchain_token_num } = this.state;
|
||||
if (form_type === "new") {
|
||||
const url = `/${owner}/${projectsId}/issues.json`;
|
||||
axios.post(url, {
|
||||
|
@ -162,6 +181,7 @@ class order_form extends Component {
|
|||
start_date: start_date,
|
||||
due_date: due_date,
|
||||
issue_type: issue_type,
|
||||
blockchain_token_num: blockchain_token_num
|
||||
}).then((result) => {
|
||||
if (result && result.data.id) {
|
||||
this.props.showNotification("任务创建成功!");
|
||||
|
@ -297,6 +317,20 @@ class order_form extends Component {
|
|||
}
|
||||
};
|
||||
|
||||
adjustTokenNum = (e) => {
|
||||
var val = e.target.value;
|
||||
val = parseInt(val);
|
||||
if (val > this.state.issue_token_num) {
|
||||
val = this.state.issue_token_num;
|
||||
e.target.value = this.state.issue_token_num;
|
||||
} else {
|
||||
e.target.value = val;
|
||||
}
|
||||
this.setState({
|
||||
blockchain_token_num: val,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
|
@ -379,6 +413,18 @@ class order_form extends Component {
|
|||
</div>
|
||||
<div className="list-left list-left-padding issue-edit-form-right">
|
||||
<div className="pd20 background-f issue-form-right">
|
||||
<Form.Item label="悬赏金额">
|
||||
{getFieldDecorator("issue_token_num", {rules: []})(
|
||||
<Input
|
||||
ref={(input) => this.input_token=input}
|
||||
type={"number"}
|
||||
min={0}
|
||||
max={this.state.issue_token_num}
|
||||
onChange={this.adjustTokenNum.bind(this)}
|
||||
placeholder="定义悬赏token数量"
|
||||
/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item label="指派成员">
|
||||
{getFieldDecorator("assigned_to_id", {rules: []})(
|
||||
<Select>
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
import React , { useEffect , useState } from 'react';
|
||||
import axios from 'axios';
|
||||
import { Select, Input, Button } from 'antd';
|
||||
const Option = Select.Option;
|
||||
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.async = true;
|
||||
script.src = 'https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js';
|
||||
document.head.appendChild(script);
|
||||
|
||||
const limit = 10;
|
||||
function BlockchainExCreate(props){
|
||||
const [ status , setStatus ] = useState(0);
|
||||
const [ total , setTotal ] = useState(0);
|
||||
const [ list , setList ] = useState([]);
|
||||
const [ authorityValBox , setAuthorityValBox] = useState(false);
|
||||
const [ selectKey , setSelectKey ] = useState("list");
|
||||
const { selectedOption, setSelectedOption } = useState("选择交易的项目");
|
||||
let user = props.current_user;
|
||||
|
||||
useEffect(()=>{
|
||||
if(user && user.login){
|
||||
getInfo();
|
||||
}
|
||||
}, [])
|
||||
|
||||
// read all the projects that the user has more than 0 tokens
|
||||
function getInfo(){
|
||||
const url = `/users/blockchain/balance`;
|
||||
axios.get(url,{
|
||||
params:{
|
||||
"user_id": user.user_id
|
||||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
setStatus(result.data.status);
|
||||
if(status == 0) {
|
||||
setList(result.data.projects);
|
||||
setTotal(result.data.total_count);
|
||||
}
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
function createTrade(user_id) {
|
||||
const url = '/users/blockchain/create_trade';
|
||||
axios.post(url, {
|
||||
"user_id": user_id,
|
||||
"project_id": document.getElementById("input_project").value,
|
||||
"money": document.getElementById("money").value,
|
||||
"token_num": document.getElementById("token_num").value,
|
||||
// "description": document.getElementById("input_description").value
|
||||
}).then((result) => {
|
||||
if(result && result.data){
|
||||
if (result.data.status == 2) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function renderProjectList(list) {
|
||||
if (list && list.length > 0) {
|
||||
return list.map((item, index) => {
|
||||
return (
|
||||
<Option
|
||||
key={index+1}
|
||||
value={item[1].id+"/"+item[2]}
|
||||
>
|
||||
{item[0].login + "/" + item[1].name}
|
||||
</Option>
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function selectProjectChange(e) {
|
||||
document.getElementById("money").removeAttribute("hidden");
|
||||
document.getElementById("token_num").removeAttribute("hidden");
|
||||
document.getElementById("submit_btn").removeAttribute("hidden");
|
||||
// document.getElementById("input_description").removeAttribute("hidden");
|
||||
|
||||
document.getElementById("token_num").setAttribute("max", e.split('/')[1]);
|
||||
document.getElementById("input_project").value=e.split('/')[0];
|
||||
}
|
||||
|
||||
function adjustTokenNum() {
|
||||
var val = document.getElementById("token_num").value;
|
||||
val = parseInt(val);
|
||||
var max_val = document.getElementById("token_num").getAttribute("max");
|
||||
if (val > max_val) {
|
||||
document.getElementById("token_num").value = max_val;
|
||||
} else {
|
||||
document.getElementById("token_num").value = val;
|
||||
}
|
||||
}
|
||||
|
||||
return(
|
||||
<div style={{minHeight:"400px"}}>
|
||||
<span className="authTag">
|
||||
<Select
|
||||
id = {'select_project'}
|
||||
style={{width: "220px"}}
|
||||
placeholder={"选择交易的项目"}
|
||||
onSelect={(e) => {selectProjectChange(e)}}
|
||||
>
|
||||
{renderProjectList(list)}
|
||||
</Select>
|
||||
</span>
|
||||
|
||||
<span className="authTag">
|
||||
<Input
|
||||
id={"input_project"}
|
||||
hidden={true}
|
||||
/>
|
||||
</span>
|
||||
|
||||
<span className="authTag">
|
||||
<Input
|
||||
id={"input_project"}
|
||||
hidden={true}
|
||||
/>
|
||||
</span>
|
||||
|
||||
{/*<span className="authTag">*/}
|
||||
{/*<Input*/}
|
||||
{/* id={"input_description"}*/}
|
||||
{/* placeholder={"输入交易描述"}*/}
|
||||
{/* hidden={true}*/}
|
||||
{/*/>*/}
|
||||
{/*</span>*/}
|
||||
|
||||
<span className="authTag">
|
||||
<Input
|
||||
type={'number'}
|
||||
id={"token_num"}
|
||||
placeholder={"输入售卖币数量"}
|
||||
hidden={true}
|
||||
min={1}
|
||||
onInput={() => {adjustTokenNum()}}
|
||||
/>
|
||||
</span>
|
||||
|
||||
<span className="authTag">
|
||||
<Input
|
||||
id={"money"}
|
||||
placeholder={"输入售卖金额"}
|
||||
hidden={true}
|
||||
/>
|
||||
</span>
|
||||
|
||||
<Button hidden={true} id='submit_btn' className="primary" onClick={() => {createTrade(user.user_id)}}>确认</Button>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default BlockchainExCreate;
|
|
@ -0,0 +1,60 @@
|
|||
import React , { useEffect , useState } from 'react';
|
||||
import moment from "moment";
|
||||
import { Button ,Spin , Pagination , Popconfirm } from 'antd';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Nodata from '../Nodata';
|
||||
import axios from 'axios';
|
||||
|
||||
const limit = 10;
|
||||
function BlockchainExHistory(props){
|
||||
const [ list , setList ] = useState([]);
|
||||
let user = props.current_user;
|
||||
|
||||
useEffect(()=>{
|
||||
if(user && user.login){
|
||||
getInfo();
|
||||
}
|
||||
},[])
|
||||
|
||||
function getInfo(){
|
||||
const url = `/users/blockchain/get_history_trades`;
|
||||
axios.get(url,{
|
||||
params:{
|
||||
"user_id": user.user_id
|
||||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
setList(result.data.results);
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
return(
|
||||
<div style={{minHeight:"400px"}}>
|
||||
{
|
||||
list && list.length > 0 ?
|
||||
<ul className="CIList">
|
||||
{list.map((item,key)=>{
|
||||
return(
|
||||
<li key={key}>
|
||||
<span>
|
||||
<span id={key} hidden={true}>{item[3].id}</span>
|
||||
<span className="authTag green ml20">{item[0].login}</span>
|
||||
<span className="authTag green ml20">{item[1].login + "/" + item[2].name}</span>
|
||||
<span className="authTag green ml20">{item[3].token_num + ":" + item[3].money}</span>
|
||||
<span className="authTag red ml20">{item[4].login}</span>
|
||||
<span className="authTag red ml20">{moment(item[3].created_at).format('YYYY-MM-DD HH:mm:ss')}</span>
|
||||
<span className="authTag red ml20">{moment(item[3].updated_at).format('YYYY-MM-DD HH:mm:ss')}</span>
|
||||
</span>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
:<Nodata _html="无历史交易"/>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default BlockchainExHistory;
|
|
@ -0,0 +1,81 @@
|
|||
import React , { useEffect , useState } from 'react';
|
||||
import { Button ,Spin , Pagination , Popconfirm } from 'antd';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Nodata from '../Nodata';
|
||||
import axios from 'axios';
|
||||
|
||||
const limit = 10;
|
||||
function BlockchainExList(props){
|
||||
const [ list , setList ] = useState([]);
|
||||
let user = props.current_user;
|
||||
|
||||
useEffect(()=>{
|
||||
if(user && user.login){
|
||||
getInfo();
|
||||
}
|
||||
},[])
|
||||
|
||||
function getInfo(){
|
||||
const url = `/users/blockchain/get_trades`;
|
||||
axios.get(url,{
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
setList(result.data.results);
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
function trade(index) {
|
||||
const url = `/users/blockchain/trade`;
|
||||
axios.post(url,{
|
||||
"user_id": user.user_id,
|
||||
"user_id2": user.user_id,
|
||||
"trade_id": document.getElementById(index).innerText
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
if (result.data.status == 2) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
return(
|
||||
<div style={{minHeight:"400px"}}>
|
||||
{
|
||||
list && list.length > 0 ?
|
||||
<ul className="CIList">
|
||||
{list.map((item,key)=>{
|
||||
return(
|
||||
<li key={key}>
|
||||
<span>
|
||||
<span id={key} hidden={true}>{item[3].id}</span>
|
||||
<span className="authTag green ml20">{item[0].login}</span>
|
||||
<span className="authTag green ml20">{item[1].login + "/" + item[2].name}</span>
|
||||
<span className="authTag green ml20">{item[3].token_num}</span>
|
||||
<span className="authTag red ml20">{item[3].money}</span>
|
||||
</span>
|
||||
{
|
||||
<Popconfirm
|
||||
title="确定交易?"
|
||||
onConfirm={() => {trade(key)}}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Button>交易</Button>
|
||||
</Popconfirm>
|
||||
}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
:<Nodata _html="暂无交易"/>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default BlockchainExList;
|
|
@ -0,0 +1,38 @@
|
|||
import React , { useEffect , useState } from 'react';
|
||||
import { Menu } from 'antd';
|
||||
import './Index.scss';
|
||||
import BlockchainExCreate from './BlockchainExCre';
|
||||
import BlockchainExList from './BlockchainExList';
|
||||
import BlockchainExVerify from './BlockchainExVerify';
|
||||
import BlockchainExHistory from './BlockchainExHistory';
|
||||
|
||||
|
||||
function BlockchainExMenu(props){
|
||||
const [ selectKey , setSelectKey ] = useState("list");
|
||||
|
||||
function changeKeys(e){
|
||||
setSelectKey(e.key);
|
||||
}
|
||||
|
||||
function renderMenu() {
|
||||
if (selectKey === "list") {return (<BlockchainExList {...props}/>)}
|
||||
else if (selectKey == 'create') {return (<BlockchainExCreate {...props}/>)}
|
||||
else if (selectKey == "verify") {return (<BlockchainExVerify {...props}/>)}
|
||||
else if (selectKey == "history") {return (<BlockchainExHistory {...props}/>)}
|
||||
}
|
||||
|
||||
return(
|
||||
<div>
|
||||
<Menu mode="horizontal" className="menuStyle" onClick={changeKeys} selectedKeys={[selectKey]}>
|
||||
<Menu.Item key="list">交易列表</Menu.Item>
|
||||
<Menu.Item key="create">创建交易</Menu.Item>
|
||||
<Menu.Item key="verify">确认交易</Menu.Item>
|
||||
<Menu.Item key="history">历史交易</Menu.Item>
|
||||
</Menu>
|
||||
{
|
||||
renderMenu()
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default BlockchainExMenu;
|
|
@ -0,0 +1,84 @@
|
|||
import React , { useEffect , useState } from 'react';
|
||||
import { Button ,Spin , Pagination , Popconfirm } from 'antd';
|
||||
import Nodata from '../Nodata';
|
||||
import moment from "moment";
|
||||
import axios from 'axios';
|
||||
|
||||
const limit = 10;
|
||||
function BlockchainExVerify(props){
|
||||
const [ list , setList ] = useState([]);
|
||||
let user = props.current_user;
|
||||
|
||||
useEffect(()=>{
|
||||
if(user && user.login){
|
||||
getInfo();
|
||||
}
|
||||
},[])
|
||||
|
||||
function getInfo(){
|
||||
const url = `/users/blockchain/get_verify_trades`;
|
||||
axios.get(url,{
|
||||
params:{
|
||||
"user_id": user.user_id
|
||||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
setList(result.data.results);
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
function verify_trade(index) {
|
||||
const url = `/users/blockchain/verify_trade`;
|
||||
axios.post(url,{
|
||||
"user_id": user.user_id,
|
||||
"trade_id": document.getElementById(index).innerText
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
if (result.data.status == 2) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
return(
|
||||
<div style={{minHeight:"400px"}}>
|
||||
{
|
||||
list && list.length > 0 ?
|
||||
<ul className="CIList">
|
||||
{list.map((item,key)=>{
|
||||
return(
|
||||
<li key={key}>
|
||||
<span>
|
||||
<span id={key} hidden={true}>{item[3].id}</span>
|
||||
<span className="authTag green ml20">{item[0].login}</span>
|
||||
<span className="authTag green ml20">{item[1].login + "/" + item[2].name}</span>
|
||||
<span className="authTag green ml20">{item[3].token_num + ":" + item[3].token_num}</span>
|
||||
<span className="authTag red ml20">{item[4].login}</span>
|
||||
<span className="authTag red ml20">{moment(item[3].created_at).format('YYYY-MM-DD HH:mm:ss')}</span>
|
||||
</span>
|
||||
{
|
||||
<Popconfirm
|
||||
title="确认收货?"
|
||||
onConfirm={() => {verify_trade(key)}}
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Button>确认收货</Button>
|
||||
</Popconfirm>
|
||||
}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
:<Nodata _html="暂无待处理交易"/>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default BlockchainExVerify;
|
|
@ -0,0 +1,108 @@
|
|||
import React , { useEffect , useState , forwardRef , useCallback } from 'react';
|
||||
import { Button , Modal , Form , Input } from 'antd';
|
||||
import { AlignCenter } from '../Component/layout';
|
||||
import axios from 'axios';
|
||||
import Modals from '../Component/Modal';
|
||||
import PasswordAuthority from '../Component/PasswordAuthority';
|
||||
import Nodata from "../Nodata";
|
||||
|
||||
function BlockchainTransfer(props){
|
||||
|
||||
const [ status , setStatus ] = useState(0);
|
||||
const [ total , setTotal ] = useState(0);
|
||||
const [ list , setList ] = useState([]);
|
||||
const [ authorityValBox , setAuthorityValBox] = useState(false);
|
||||
|
||||
const { form: { getFieldDecorator, validateFields , setFieldsValue } } = props;
|
||||
const helper = useCallback(
|
||||
(label, name, rules, widget, isRequired) => (
|
||||
<React.Fragment>
|
||||
<span className={isRequired ? "required" : ""}>{label}</span>
|
||||
<Form.Item>
|
||||
{getFieldDecorator(name, { rules, validateFirst: true })(widget)}
|
||||
</Form.Item>
|
||||
</React.Fragment>
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
let user = props.current_user;
|
||||
|
||||
useEffect(()=>{
|
||||
if(user && user.login){
|
||||
getInfo();
|
||||
}
|
||||
},[])
|
||||
|
||||
// read all the projects that the user has more than 0 tokens
|
||||
function getInfo(){
|
||||
const url = `/users/blockchain/balance`;
|
||||
axios.get(url,{
|
||||
params:{
|
||||
"user_id": user.user_id
|
||||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
setStatus(result.data.status);
|
||||
if(status == 0) {
|
||||
setList(result.data.projects);
|
||||
setTotal(result.data.total_count);
|
||||
}
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
function okAuthority(){
|
||||
setAuthorityValBox(false);
|
||||
}
|
||||
|
||||
function cancelAuthority(){
|
||||
setAuthorityValBox(false);
|
||||
}
|
||||
|
||||
|
||||
function submit(owner, project, balance, id) {
|
||||
const url = '/users/blockchain/transfer';
|
||||
axios.post(url, {
|
||||
payer_id: user.user_id,
|
||||
project_id: project.id,
|
||||
transfer_amount: document.getElementById("amount_" + id).value,
|
||||
transfer_login: document.getElementById("login_" + id).value
|
||||
}).then((result) => {
|
||||
if (result && result.data) {
|
||||
if (result.data.status == 2) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return(
|
||||
<div style={{minHeight:"400px"}}>
|
||||
<PasswordAuthority authorityValBox={authorityValBox} successFunc={okAuthority} cancelFunc={cancelAuthority}></PasswordAuthority>
|
||||
{
|
||||
status == 0 && list && list.length > 0 ?
|
||||
<ul className="BalanceList">
|
||||
{list.map((item,index)=>{
|
||||
return(
|
||||
<li key={index}>
|
||||
<Form>
|
||||
<span className="authTag green ml20">{item[0].login + "/" + item[1].name}</span>
|
||||
<span className="authTag green ml20">{item[2]}</span>
|
||||
<span className="authTag"><Input type="text" placeholder={"请输入转给哪个用户(login)"} name={"transfer_login"} id={"login_"+index} /></span>
|
||||
<span className="authTag"><Input type="text" placeholder={"请输入转账token数量"} name={"transfer_amount"} id={"amount_"+index} /></span>
|
||||
<Button className="primary" onClick={() => {submit(item[0], item[1], item[2], index)}}>确认</Button>
|
||||
</Form>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
:<Nodata _html="暂无数据"/>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default Form.create()(forwardRef(BlockchainTransfer));;
|
|
@ -19,6 +19,14 @@ const InfosDevOps = Loadable({
|
|||
loader: () => import("./devOpsCI"),
|
||||
loading: Loading,
|
||||
});
|
||||
const InfosBlockchainTransfer = Loadable({
|
||||
loader: () => import("./BlockchainTransfer"),
|
||||
loading: Loading,
|
||||
});
|
||||
const InfosBlockchainExMenu = Loadable({
|
||||
loader: () => import("./BlockchainExMenu"),
|
||||
loading: Loading,
|
||||
});
|
||||
const InfosDevOpsCD = Loadable({
|
||||
loader: () => import("./devOpsCD"),
|
||||
loading: Loading,
|
||||
|
@ -114,6 +122,16 @@ class Infos extends Component {
|
|||
this.props.history.push(`/users/${user && user.login}/devops/${type}`);
|
||||
}
|
||||
|
||||
change_blockchain_type=(type)=>{
|
||||
console.log(type)
|
||||
const {user} = this.state;
|
||||
this.setState({
|
||||
project_type: type ,
|
||||
route_type: undefined
|
||||
})
|
||||
this.props.history.push(`/users/${user && user.login}/blockchain/${type}`);
|
||||
}
|
||||
|
||||
undo_link = () => {
|
||||
const {user} = this.state
|
||||
this.setState({
|
||||
|
@ -286,7 +304,39 @@ class Infos extends Component {
|
|||
</ul>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
current_user && current_user.login && current_user.login === username &&
|
||||
<div className="bgcF">
|
||||
<ul className="list-l-Menu">
|
||||
<li className="MenuTitle">
|
||||
<i className="iconfont icon-gongzuoliu font-15 mr5"></i>
|
||||
贡献确权
|
||||
<i className="iconfont icon-youjiantou font-15 mr20 color-grey-9 pull-right"></i>
|
||||
</li>
|
||||
<li className={project_type && project_type === "BlockchainService" ? "active" : ""} onClick={() => this.change_blockchain_type("TransferService")}>
|
||||
<p>
|
||||
<span className="font-16 color-grey-3">币-币交易服务</span>
|
||||
</p>
|
||||
</li>
|
||||
<li className={project_type && project_type === "BlockchainService" ? "active" : ""} onClick={() => this.change_blockchain_type("ExchangeService")}>
|
||||
<p>
|
||||
<span className="font-16 color-grey-3">币-法交易服务</span>
|
||||
</p>
|
||||
</li>
|
||||
{/* <li className={project_type && project_type === "CDService" ? "active" : ""} onClick={() => this.change_devops_type("CDService")}>
|
||||
<p>
|
||||
<span className="font-16">CD服务</span>
|
||||
<span className="color-blue">
|
||||
{user && user.common_projects_count}
|
||||
</span>
|
||||
</p>
|
||||
</li> */}
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
{/* <div className="bgcF">
|
||||
<div className="list-l-Menu">
|
||||
|
@ -336,6 +386,18 @@ class Infos extends Component {
|
|||
return <InfosDevOps {...this.props} {...this.state} />;
|
||||
}}
|
||||
></Route>
|
||||
<Route
|
||||
path="/users/:username/blockchain/TransferService"
|
||||
render={() => {
|
||||
return <InfosBlockchainTransfer {...this.props} {...this.state} />;
|
||||
}}
|
||||
></Route>
|
||||
<Route
|
||||
path="/users/:username/blockchain/ExchangeService"
|
||||
render={() => {
|
||||
return <InfosBlockchainExMenu {...this.props} {...this.state} />;
|
||||
}}
|
||||
></Route>
|
||||
<Route
|
||||
path="/users/:username/projects/:project_type"
|
||||
render={() => {
|
||||
|
|
Loading…
Reference in New Issue