Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
backslash47 committed Apr 7, 2018
0 parents commit 1486aa7
Show file tree
Hide file tree
Showing 64 changed files with 12,430 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
**/node_modules

# testing
/coverage

# production
**/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
49 changes: 49 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "ontdetective",
"author": "Matus Zamborsky",
"version": "0.1.0",
"license": "LGPL",
"private": true,
"dependencies": {
"date-fns": "^1.29.0",
"elasticsearch": "^14.2.1",
"html5-websocket": "^2.0.2",
"lodash": "^4.17.5",
"make-runnable": "^1.3.6",
"numeral": "^2.0.6",
"ont-sdk-ts": "backslash47/ontology-ts-sdk#exported",
"query-string": "^6.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"react-scripts-ts": "2.14.0",
"recompose": "^0.26.0",
"semantic-ui-css": "^2.3.1",
"semantic-ui-react": "^0.79.0",
"util": "^0.10.3"
},
"scripts": {
"start": "react-scripts-ts start",
"build": "REACT_APP_API_URL='http://api.ontdetective.org' react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject",
"buildServer": "tsc -p src/server",
"mappings": "node build/server/server mappings",
"ingest": "node build/server/server ingest",
"recalculate": "node build/server/server recalculate"
},
"devDependencies": {
"@types/elasticsearch": "^5.0.22",
"@types/jest": "^22.2.0",
"@types/lodash": "^4.14.105",
"@types/node": "^9.4.7",
"@types/numeral": "^0.0.22",
"@types/query-string": "^5.1.0",
"@types/react": "^16.0.40",
"@types/react-dom": "^16.0.4",
"@types/react-router-dom": "^4.2.5",
"@types/recompose": "^0.24.6",
"@types/ws": "^4.0.2",
"typescript": "^2.7.2"
}
}
Binary file added public/favicon.ico
Binary file not shown.
40 changes: 40 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Ont Detective</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Ont Detective",
"name": "Ont Detective",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
66 changes: 66 additions & 0 deletions src/accounts/accountDetail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2018 Matus Zamborsky
* This file is part of The ONT Detective.
*
* The ONT Detective is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ONT Detective is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with The ONT Detective. If not, see <http://www.gnu.org/licenses/>.
*/

import { compose, lifecycle, branch, renderNothing, withProps, withState, flattenProp } from 'recompose';
import { match } from 'react-router';
import { Location } from 'history';
import { StateSetter } from '~/utils';
import { getAccount } from '~/shared/accountsApi';
import { Account } from '~/shared/ont/model';
import View from './accountDetailView';

interface PropsOuter {
match: match<{id: string}>;
location: Location;
}

interface PropsOwn {
txId: string;
}

interface State {
account: Account;
loaded: boolean;
}

export interface PropsInner extends State, PropsOuter {
}

export default compose<PropsInner, PropsOuter>(
withProps<PropsOwn, PropsOuter>(props => ({
txId: props.match.params.id
})),
withState<null, Partial<State>, 'state', 'setState'>('state', 'setState', {
loaded: false
}),
lifecycle<PropsOwn & StateSetter<State>, null>({
async componentDidMount() {
const account = await getAccount(this.props.txId);

this.props.setState({
account,
loaded: true
});
}
}),
flattenProp('state'),
branch<State>(
({loaded}) => !loaded,
renderNothing
)
) (View);
86 changes: 86 additions & 0 deletions src/accounts/accountDetailView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (C) 2018 Matus Zamborsky
* This file is part of The ONT Detective.
*
* The ONT Detective is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ONT Detective is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with The ONT Detective. If not, see <http://www.gnu.org/licenses/>.
*/

import * as React from 'react';
import { Link } from 'react-router-dom';
import { Breadcrumb, Segment, Table, Header, Popup } from 'semantic-ui-react';
import { distanceInWordsToNow, format } from 'date-fns';
import { AssetIdToName } from '~/const';
import { PropsInner as Props } from './accountDetail';
import AccountTransfers from './accountTransfers';

const Transaction: React.SFC<Props> = (props) => (
<Segment.Group>
<Segment>
<Header as="h2">
<Breadcrumb size="huge">
<Breadcrumb.Section as={Link} to="/accounts">Accounts</Breadcrumb.Section>
<Breadcrumb.Divider icon="right chevron" />
<Breadcrumb.Section active={true}>{props.account.address}</Breadcrumb.Section>
</Breadcrumb>
</Header>
</Segment>
<Segment>
<Table celled={false} basic="very" selectable={true} fixed={true}>
<Table.Body>
<Table.Row>
<Table.Cell width={1}>Created</Table.Cell>
<Table.Cell width={1}>
<Link to={`/transactions/${props.account.firstTx}`}>
<Popup trigger={<span>{distanceInWordsToNow(props.account.firstTime)}</span>}>
{format(props.account.firstTime, 'MMM Do YYYY HH:mm:ss')}
</Popup>
</Link>
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell width={1}>Last transaction</Table.Cell>
<Table.Cell width={1}>
<Link to={`/transactions/${props.account.lastTx}`}>
<Popup trigger={<span>{distanceInWordsToNow(props.account.lastTime)}</span>}>
{format(props.account.lastTime, 'MMM Do YYYY HH:mm:ss')}
</Popup>
</Link>
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell width={1}>Transactions count</Table.Cell>
<Table.Cell width={1}>{props.account.transactionsCount}</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
</Segment>
<Segment>
<Header as="h2">Assets</Header>
<Table celled={false} basic="very" selectable={true} fixed={true}>
<Table.Body>
{props.account.assets.map(assetBalance => (
<Table.Row>
<Table.Cell width={1} >{AssetIdToName[assetBalance.asset]}</Table.Cell>
<Table.Cell width={1} className="bold">{assetBalance.balance}</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
</Segment>

<AccountTransfers address={props.account.address} location={props.location} />
</Segment.Group>
);

export default Transaction;
50 changes: 50 additions & 0 deletions src/accounts/accountTransfers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2018 Matus Zamborsky
* This file is part of The ONT Detective.
*
* The ONT Detective is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ONT Detective is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with The ONT Detective. If not, see <http://www.gnu.org/licenses/>.
*/

import { compose, withProps, branch, renderNothing } from 'recompose';
import { Location } from 'history';
import innerGrid from '~/common/innerGrid';
import { Direction } from '~/common/gridTypes';
import { SortColumn, getAccountTransfers } from '~/shared/transfersApi';
import { Transfer } from '~/shared/ont/model';
import View from '~/transfers/embeddedTransfersGridView';
import { Props } from '~/transfers/transfersGrid';

interface PropsOuter {
location: Location;
address: string;
}

export default compose<Props, PropsOuter>(
withProps<{}, PropsOuter>((props) => ({
dataLoader: (
from: number,
size: number,
sortColumn: SortColumn,
order: Direction,
) => getAccountTransfers(props.address, from, size, sortColumn, order),
sort: 'Timestamp',
order: 'ascending',
highlightAddress: props.address
})),
innerGrid<Transfer, SortColumn>('transfers'),
branch<Props>(
({items}) => items.length === 0,
renderNothing
)
) (View);
36 changes: 36 additions & 0 deletions src/accounts/accountsGrid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2018 Matus Zamborsky
* This file is part of The ONT Detective.
*
* The ONT Detective is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The ONT Detective is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with The ONT Detective. If not, see <http://www.gnu.org/licenses/>.
*/

import { compose, defaultProps } from 'recompose';
import { RouteComponentProps } from 'react-router';
import { getAccounts, SortColumn } from '~/shared/accountsApi';
import { Account } from '~/shared/ont/model';
import View from './accountsGridView';
import remoteGrid from '~/common/remoteGrid';
import { PropsInner } from '~/common/gridTypes';

export type Props = PropsInner<Account, SortColumn>;

export default compose<Props, RouteComponentProps<{}>>(
defaultProps({
dataLoader: getAccounts,
sort: 'address',
order: 'ascending'
}),
remoteGrid<Account, SortColumn>()
) (View);
Loading

0 comments on commit 1486aa7

Please sign in to comment.