Skip to content

Commit

Permalink
refac js
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashuaidehao committed Sep 21, 2022
1 parent 545e8fb commit 62b27a4
Show file tree
Hide file tree
Showing 36 changed files with 645 additions and 1,026 deletions.
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/ClientApp/gui-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Host": "localhost",
"Port": 8081,
"RPCURL": "http://localhost:8081",
"Language": "",
"Network": "mainnet"
}
4 changes: 2 additions & 2 deletions neo3-gui/neo3-gui/ClientApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/ClientApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neo-gui",
"version": "1.4.3",
"version": "1.4.4",
"private": true,
"main": "main.js",
"homepage": "./",
Expand Down
137 changes: 55 additions & 82 deletions neo3-gui/neo3-gui/ClientApp/src/components/Advanced/candidate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable */
import React from "react";
import "antd/dist/antd.css";
import axios from "axios";
import {
Checkbox,
PageHeader,
Expand All @@ -20,6 +19,7 @@ import { observer, inject } from "mobx-react";
import { withRouter } from "react-router-dom";
import { withTranslation } from "react-i18next";
import "../../static/css/advanced.css";
import { postAsync } from "../../core/request";

const { Option } = Select;

Expand All @@ -45,92 +45,65 @@ class Advancedcandidate extends React.Component {
});
});
}
listPublicKey = (callback) => {
listPublicKey = async (callback) => {
const { t } = this.props;
axios
.post("http://localhost:8081", {
id: "1",
method: "ListCandidatePublicKey",
})
.then(function (response) {
var _data = response.data;
console.log(_data);
if (_data.msgType === -1) {
let res = _data.error;
Modal.error({
title: t("contract.fail title"),
width: 400,
content: (
<div className="show-pri">
<p>
{t("error code")}: {res.code}
</p>
<p>
{t("error msg")}: {res.message}
</p>
</div>
),
okText: t("button.ok"),
});
return;
} else if (_data.msgType === 3) {
callback(_data);
}
})
.catch(function (error) {
console.log(error);
console.log("error");
let response = await postAsync("ListCandidatePublicKey");
if (response.msgType === -1) {
let res = response.error;
Modal.error({
title: t("contract.fail title"),
width: 400,
content: (
<div className="show-pri">
<p>
{t("error code")}: {res.code}
</p>
<p>
{t("error msg")}: {res.message}
</p>
</div>
),
okText: t("button.ok"),
});
return;
}
callback(response);
};
onCandidate = (fieldsValue) => {
onCandidate = async (fieldsValue) => {
const { t } = this.props;
axios
.post("http://localhost:8081", {
id: "1",
method: "ApplyForValidator",
params: {
pubkey: fieldsValue.pubkey,
},
})
.then(function (response) {
var _data = response.data;
console.log(_data);
if (_data.msgType === -1) {
let res = _data.error;
Modal.error({
title: t("advanced.candidate fail"),
width: 400,
content: (
<div className="show-pri">
<p>
{t("error code")}: {res.code}
</p>
<p>
{t("error msg")}: {res.message}
</p>
</div>
),
okText: t("button.ok"),
});
return;
} else if (_data.msgType === 3) {
Modal.success({
title: t("advanced.candidate success"),
width: 400,
content: (
<div className="show-pri">
<p>TxID : {_data.result.txId ? _data.result.txId : "--"}</p>
</div>
),
okText: t("button.ok"),
});
return;
}
})
.catch(function (error) {
console.log(error);
console.log("error");
let response = await postAsync("ApplyForValidator", {
pubkey: fieldsValue.pubkey,
});
if (response.msgType === -1) {
let res = response.error;
Modal.error({
title: t("advanced.candidate fail"),
width: 400,
content: (
<div className="show-pri">
<p>
{t("error code")}: {res.code}
</p>
<p>
{t("error msg")}: {res.message}
</p>
</div>
),
okText: t("button.ok"),
});
return;
}

Modal.success({
title: t("advanced.candidate success"),
width: 400,
content: (
<div className="show-pri">
<p>TxID : {response.result.txId ? response.result.txId : "--"}</p>
</div>
),
okText: t("button.ok"),
});
};
render = () => {
const { t } = this.props;
Expand Down
104 changes: 47 additions & 57 deletions neo3-gui/neo3-gui/ClientApp/src/components/Advanced/designrole.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import {
Col,
Form,
Select,
Button,
message} from 'antd';
Button,
message
} from 'antd';
import { Layout } from 'antd';
import Sync from '../sync';
import { observer, inject } from "mobx-react";
import { withRouter } from "react-router-dom";
import { withTranslation } from "react-i18next";
import "../../static/css/advanced.css";
import { postAsync } from '../../core/request';

const { Option } = Select;
const { Content } = Layout;
Expand All @@ -31,27 +33,15 @@ class Advanceddesignrole extends React.Component {
super(props);
this.state = {
size: 'default',
rolelist: [{type:4,role:"StateValidator"},{type:8,role:"Oracle"}],
rolelist: [{ type: 4, role: "StateValidator" }, { type: 8, role: "Oracle" }],
};
}
onRole = fieldsValue =>{
onRole = async (fieldsValue) => {
const { t } = this.props;
axios.post('http://localhost:8081', {
"id": "1",
"method": "GetNodesByRole",
"params":{
"role":fieldsValue.role
}
})
.then(function (response) {
var _data = response.data;
console.log(_data);
return;
})
.catch(function (error) {
console.log(error);
console.log("error");
let response = await postAsync("GetNodesByRole", {
"role": fieldsValue.role
});
console.log(response);
}
render = () => {
const { t } = this.props;
Expand All @@ -62,44 +52,44 @@ class Advanceddesignrole extends React.Component {
<Content className="mt3">
<Row gutter={[30, 0]} style={{ 'minHeight': 'calc( 100vh - 120px )' }}>
<Col span={24} className="bg-white pv4">
<PageHeader title={t('指派节点角色')}></PageHeader>
<div className="pa3">
<Alert
className="mt3 mb3"
type="warning"
message="我也不知道该写什么,就先这么写吧"
showIcon
/>
<Form ref="formRef" onFinish={this.onRole}>
<h4 className="bolder mb4">{t('advanced.be candidate')}</h4>
<Form.Item
name="节点角色类型"
className="select-role"
rules={[
{
required: true,
message: t("必须选择想要查询的节点"),
},
]}
>
<Select
placeholder={t("advanced.select address")}
style={{ width: '100%' }}
onChange={this.setAddress}>
{rolelist.map((item)=>{
return(
<Option key={item.role}>{item.name}</Option>
)
})}
</Select>
</Form.Item>
<p className="text-c mt3">
<Button type="primary" htmlType="submit" disabled={disabled} loading={this.state.iconLoading}>
{t("button.confirm")}
</Button>
</p>
</Form>
<PageHeader title={t('指派节点角色')}></PageHeader>

<div className="pa3">
<Alert
className="mt3 mb3"
type="warning"
message="我也不知道该写什么,就先这么写吧"
showIcon
/>
<Form ref="formRef" onFinish={this.onRole}>
<h4 className="bolder mb4">{t('advanced.be candidate')}</h4>
<Form.Item
name="节点角色类型"
className="select-role"
rules={[
{
required: true,
message: t("必须选择想要查询的节点"),
},
]}
>
<Select
placeholder={t("advanced.select address")}
style={{ width: '100%' }}
onChange={this.setAddress}>
{rolelist.map((item) => {
return (
<Option key={item.role}>{item.name}</Option>
)
})}
</Select>
</Form.Item>
<p className="text-c mt3">
<Button type="primary" htmlType="submit" disabled={disabled} loading={this.state.iconLoading}>
{t("button.confirm")}
</Button>
</p>
</Form>
</div>
</Col>
</Row>
Expand Down
Loading

0 comments on commit 62b27a4

Please sign in to comment.