Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Merged

Redux #176

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
049d8ff
Login pin - WIP
Aug 26, 2017
e871913
Merge branch 'redux' into login-pin
Aug 26, 2017
5f8e42a
pin visual improvements
Aug 26, 2017
630bcca
Qr Invoice modal
Miikat Aug 28, 2017
ff22519
Body Bottom component for modal render
Miikat Aug 28, 2017
86ad0ae
Qr Invoice modal
Miikat Aug 30, 2017
bf70da3
Removed unused code
Miikat Aug 30, 2017
8293ff2
Code formatting
Miikat Aug 30, 2017
7039acf
Control panel visibility & animation with css
Miikat Sep 14, 2017
4d4980c
Remove test package
Miikat Sep 14, 2017
0e4bb63
Merge branch 'redux' into feature/settings-refactor
Miikat Sep 15, 2017
fc0af4f
Reduce code repetion in settings
Miikat Sep 17, 2017
ef76732
Merge branch 'redux' into feature/settings-refactor
Miikat Sep 17, 2017
6e7ef29
Fix panel heading
Miikat Sep 17, 2017
c21c096
Icon toggle to active panel
Miikat Sep 17, 2017
9f7a0ae
Cleaning up jsx
Miikat Sep 17, 2017
0977e1d
AGP-228, Merge branch 'redux' into feature/settings-refactor
Miikat Sep 17, 2017
28334f4
AGP-228, clean up jsx
Miikat Sep 17, 2017
f071756
Merge branch 'redux' of https://github.com/SuperNETorg/EasyDEX-GUI in…
pbca26 Sep 18, 2017
81de7c5
fixed code formatting
pbca26 Sep 18, 2017
8fdc9da
resolved merge conflicts
pbca26 Sep 18, 2017
7fda701
Merge pull request #171 from SuperNETorg/login-pin
pbca26 Sep 18, 2017
967dbc5
Merge pull request #174 from SuperNETorg/feature/settings-refactor
pbca26 Sep 18, 2017
6139969
Merge branch 'redux' into feature/qr-invoice
Miikat Sep 18, 2017
29942b1
AGP-215, Read invoice payload
Miikat Sep 18, 2017
5d9e43f
minor pin actions code formatting fix
pbca26 Sep 18, 2017
bfb0b5d
minor code style change
pbca26 Sep 19, 2017
9c1c979
Merge pull request #172 from SuperNETorg/feature/qr-invoice
pbca26 Sep 19, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions react/src/actions/actionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
DISPLAY_CLAIM_INTEREST_MODAL,
START_INTERVAL,
STOP_INTERVAL,
GET_PIN_LIST,
DASHBOARD_SYNC_ONLY_UPDATE,
DISPLAY_IMPORT_KEY_MODAL,
} from './storeType';
Expand Down Expand Up @@ -345,6 +346,13 @@ export function toggleClaimInterestModal(display) {
}
}

export function getPinList(pinList) {
return {
type: GET_PIN_LIST,
pinList: pinList,
}
}

export function skipFullDashboardUpdate(skip) {
return {
type: DASHBOARD_SYNC_ONLY_UPDATE,
Expand Down
110 changes: 110 additions & 0 deletions react/src/actions/actions/pin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import Config from '../../config';
import {
getDecryptedPassphrase,
getPinList,
triggerToaster
} from '../actionCreators';
import { iguanaWalletPassphrase } from './walletAuth';

export function encryptPassphrase(passphrase, key, pubKey) {
const payload = {
string: passphrase,
key: key,
pubkey: pubKey,
};

return dispatch => {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/encryptkey`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(
triggerToaster(
'encryptKey',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
dispatch(
triggerToaster(
'Passphrase successfully encrypted',
'Success',
'success'
)
);
})
}
}

export function loginWithPin(key, pubKey) {
const payload = {
key: key,
pubkey: pubKey,
};

return dispatch => {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/decryptkey`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(
triggerToaster(
'decryptKey',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
dispatch(iguanaWalletPassphrase(json.result));
})
}
}

export function loadPinList() {
return dispatch => {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getpinlist`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(
triggerToaster(
'getPinList',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
dispatch(
triggerToaster(
'getPinList',
'Success',
'success'
)
);
dispatch(
getPinList(json.result)
);
})
}
}
1 change: 1 addition & 0 deletions react/src/actions/storeType.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ export const LOGOUT = 'LOGOUT';
export const DISPLAY_COIND_DOWN_MODAL = 'DISPLAY_COIND_DOWN_MODAL';
export const DISPLAY_LOGIN_SETTINGS_MODAL = 'DISPLAY_LOGIN_SETTINGS_MODAL';
export const DISPLAY_CLAIM_INTEREST_MODAL = 'DISPLAY_CLAIM_INTEREST_MODAL';
export const GET_PIN_LIST = 'GET_PIN_LIST';
export const DISPLAY_IMPORT_KEY_MODAL = 'DISPLAY_IMPORT_KEY_MODAL';
1 change: 1 addition & 0 deletions react/src/components/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Main from '../main/main';

function mapStateToProps(state) {
return {
login: state.login,
toaster: state.toaster,
AddCoin: state.AddCoin,
Main: state.Main,
Expand Down
32 changes: 32 additions & 0 deletions react/src/components/dashboard/bodyBottom/bodyBottom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';

export default class BodyEnd extends React.PureComponent {
static propTypes = {
children: PropTypes.node,
};

componentDidMount() {
this._popup = document.createElement('div');
document.body.appendChild(this._popup);
this._render();
}

componentDidUpdate() {
this._render();
}

componentWillUnmount() {
ReactDOM.unmountComponentAtNode(this._popup);
document.body.removeChild(this._popup);
}

_render() {
ReactDOM.render(this.props.children, this._popup);
}

render() {
return null;
}
}
140 changes: 140 additions & 0 deletions react/src/components/dashboard/invoiceModal/invoiceModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { connect } from 'react-redux';
import Store from '../../../store';
import { translate } from '../../../translate/translate';
import BodyEnd from '../bodyBottom/bodyBottom';
import {
InvoiceModalRender,
InvoiceModalButtonRender,
AddressItemRender,
} from './invoiceModal.render';

class InvoiceModal extends React.Component {
constructor() {
super();
this.state = {
modalIsOpen: false,
content: '',
qrAddress: '',
qrAmount: 0,
};
this.openModal = this.openModal.bind(this);
this.closeModal = this.closeModal.bind(this);
this.updateInput = this.updateInput.bind(this);
this.renderAddressList = this.renderAddressList.bind(this);
this.updateQRContent = this.updateQRContent.bind(this);
}

openModal() {
this.setState({
modalIsOpen: true
});
}

updateInput(e) {
this.setState({
[e.target.name]: e.target.value
}, this.updateQRContent);
}

updateQRContent() {
this.setState({
content: JSON.stringify({
address: this.state.qrAddress,
amount: this.state.qrAmount,
coin: this.props.ActiveCoin.coin,
}),
});
}

closeModal() {
this.setState({
modalIsOpen: false,
});
}

hasNoAmount(address) {
return address.amount === 'N/A' || address.amount === 0;
}

hasNoInterest(address) {
return address.interest === 'N/A' || address.interest === 0 || !address.interest;
}

isBasiliskMode() {
return this.props.ActiveCoin.mode === 'basilisk';
}

isNativeMode() {
return this.props.ActiveCoin.mode == 'native';
}

renderAddressList(type) {
const _addresses = this.props.ActiveCoin.addresses;
const _cache = this.props.ActiveCoin.cache;
const _coin = this.props.ActiveCoin.coin;

if (_addresses &&
_addresses[type] &&
_addresses[type].length) {
let items = [];

for (let i = 0; i < _addresses[type].length; i++) {
let address = _addresses[type][i];

if (this.isBasiliskMode() &&
this.hasNoAmount(address)) {
address.amount = _cache && _cache[_coin][address.address] &&
_cache[_coin][address.address].getbalance &&
_cache[_coin][address.address].getbalance.data &&
_cache[_coin][address.address].getbalance.data.balance ? _cache[_coin][address.address].getbalance.data.balance : 'N/A';
}
if (this.isBasiliskMode() &&
this.hasNoInterest(address)) {
address.interest = _cache && _cache[_coin][address.address] &&
_cache[_coin][address.address].getbalance &&
_cache[_coin][address.address].getbalance.data &&
_cache[_coin][address.address].getbalance.data.interest ? _cache[_coin][address.address].getbalance.data.interest : 'N/A';
}

items.push(
AddressItemRender.call(this, address, type)
);
}

return items;
} else {
return null;
}
}

render() {
if (this.state.modalIsOpen) {
return <BodyEnd>{ InvoiceModalRender.call(this) }</BodyEnd>
} else {
return InvoiceModalButtonRender.call(this);
}
}
}

const mapStateToProps = (state) => {
return {
ActiveCoin: {
coin: state.ActiveCoin.coin,
mode: state.ActiveCoin.mode,
send: state.ActiveCoin.send,
receive: state.ActiveCoin.receive,
balance: state.ActiveCoin.balance,
cache: state.ActiveCoin.cache,
activeAddress: state.ActiveCoin.activeAddress,
lastSendToResponse: state.ActiveCoin.lastSendToResponse,
addresses: state.ActiveCoin.addresses,
},
Dashboard: {
activeHandle: state.Dashboard.activeHandle,
},
};
};

export default connect(mapStateToProps)(InvoiceModal);
Loading