Skip to content

Commit

Permalink
Merge pull request #89 from bokuns/gui-252/260
Browse files Browse the repository at this point in the history
Fix more Error Modals
  • Loading branch information
Ashuaidehao authored Aug 10, 2020
2 parents 4b9aa97 + ad92d7e commit 2c6328e
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 38 deletions.
2 changes: 1 addition & 1 deletion 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.0.6",
"version": "1.0.7",
"private": true,
"main": "main.js",
"homepage": "./",
Expand Down
38 changes: 30 additions & 8 deletions neo3-gui/neo3-gui/ClientApp/src/components/Advanced/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 { withTranslation, Trans } from "react-i18next";
import "../../static/css/advanced.css";
import { shell } from "electron";
import {post} from '../../core/request';
Expand Down Expand Up @@ -50,6 +50,10 @@ class Advancedvote extends React.Component {
})
});
}
clickToCopy = (text) => {
navigator.clipboard.writeText(text)
message.success(<Trans>common.copied</Trans>)
}
listCandidate = callback => {
const { t } = this.props;
post("GetValidators",{}).then(function (response) {
Expand Down Expand Up @@ -81,6 +85,7 @@ class Advancedvote extends React.Component {
onVote = values =>{
const { t } = this.props;
let {value} = this.state;
const _this = this;
if(!value) {
message.error(t('advanced.vote fail info'));
return;
Expand All @@ -93,15 +98,32 @@ class Advancedvote extends React.Component {
var _data = response.data;
if (_data.msgType === -1) {
let res = _data.error;
Modal.error({
title: t('advanced.vote fail'),
width: 400,
content: (
let title = t('advanced.vote fail')
let content = (
<div className="show-pri">
<p>{t('error code')}: {res.code}</p>
<p>{t('error msg')}: {res.message}</p>
</div>
);
if (res.code === 20014) {
content = (
<div className="show-pri">
<p>{t('error code')}: {res.code}</p>
<p>{t('error msg')}: {res.message}</p>
<pre style={{ overflow: 'hidden', overflowX: 'auto', overflowY: 'scroll', maxHeight: '60vh', width: 'auto' }}>
<code>{ JSON.stringify(JSON.parse(res.message), null, 2) }</code>
</pre>
<p>
<Button type="link" style={{ margin: 0, color: '#00B594' }} onClick={() => _this.clickToCopy(res.message)}>
<Trans>button.copy to clipboard</Trans>
</Button>
</p>
</div>
),
);
}
Modal.error({
title: title,
centered: true,
width: 650,
content: content,
okText: t("button.ok")
});
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,41 @@ class Multitomulti extends React.Component{

if(_data.msgType === -1){
let res = _data.error;
const errorTitle = res.code === 20014 ? (
t('wallet.transfer send error 20014')
) : (
t('wallet.transfer send error')
let title = (<Trans>wallet.transfer send error</Trans>);
let content = (
<div className="show-pri">
<p><Trans>blockchain.transaction hash</Trans>: {res.code}</p>
<p><Trans>error msg</Trans>: {res.message}</p>
</div>
);
Modal.warning({
title: errorTitle,
width: 650,
centered: true,
content: (

if (res.code === 20014) {
title = (<Trans>wallet.transfer send error 20014</Trans>);
content = (
<div className="show-pri">
<pre style={{ overflow: 'hidden', overflowX: 'auto', overflowY: 'scroll', maxHeight: '60vh', width: 'auto' }}>
<code>{ JSON.stringify(JSON.parse(res.message), null, 2) }</code>
</pre>
<p>
<Button type="link" style={{ margin: 0, color: '#00B594' }}
onClick={() => this.clickToCopy(res.message)}>{t("button.copy to clipboard")}</Button>
<Button type="link" style={{ margin: 0, color: '#00B594' }} onClick={() => this.clickToCopy(res.message)}>
<Trans>button.copy to clipboard</Trans>
</Button>
</p>
</div>
),
okText:t("button.confirm")
});
);
}
const args = {
title: title,
width: 650,
centered: true,
content: content,
okText: (<Trans>button.confirm</Trans>)
};
if (res.code === 20014) {
Modal.warning(args);
} else {
Modal.error(args);
}
return;
}else{
Modal.success({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from 'antd';
import { Layout } from 'antd';
import '../../static/css/wallet.css'
import { withTranslation } from "react-i18next";
import { withTranslation, Trans } from "react-i18next";
import { post } from "../../core/request";

const { Option } = Select;
Expand All @@ -39,6 +39,10 @@ class Onetomulti extends React.Component{
selectadd: _detail
})
}
clickToCopy = (text) => {
navigator.clipboard.writeText(text)
message.success(<Trans>common.copied</Trans>)
}
transfer = values =>{
var _this = this;
const {t}=this.props;
Expand Down Expand Up @@ -67,23 +71,47 @@ class Onetomulti extends React.Component{
};

post("SendToMultiAddress",params).then(res =>{
var _data = res.data;
var result = res.data.result;
if(_data.msgType === -1){
const _data = res.data;
const result = res.data.result;
if (_data.msgType === -1) {
let res = _data.error;
Modal.error({
title: t('wallet.transfer send error'),
width: 400,
content: (
let title = (<Trans>wallet.transfer send error</Trans>);
let content = (
<div className="show-pri">
<p>{t("error code")}: {res.code}</p>
<p>{t("error msg")}: {res.message}</p>
<p><Trans>blockchain.transaction hash</Trans>: {res.code}</p>
<p><Trans>error msg</Trans>: {res.message}</p>
</div>
),
okText:t("button.confirm")
});
);

if (res.code === 20014) {
title = (<Trans>wallet.transfer send error 20014</Trans>);
content = (
<div className="show-pri">
<pre style={{ overflow: 'hidden', overflowX: 'auto', overflowY: 'scroll', maxHeight: '60vh', width: 'auto' }}>
<code>{ JSON.stringify(JSON.parse(res.message), null, 2) }</code>
</pre>
<p>
<Button type="link" style={{ margin: 0, color: '#00B594' }} onClick={() => _this.clickToCopy(res.message)}>
<Trans>button.copy to clipboard</Trans>
</Button>
</p>
</div>
);
}
const args = {
title: title,
width: 650,
centered: true,
content: content,
okText: (<Trans>button.confirm</Trans>)
};
if (res.code === 20014) {
Modal.warning(args);
} else {
Modal.error(args);
}
return;
}else{
} else {
Modal.success({
title: t('wallet.transfer send success'),
content: (
Expand Down

0 comments on commit 2c6328e

Please sign in to comment.