Skip to content

Commit 1513d58

Browse files
committed
Add loading animation and prepare for production release
1 parent d045c5c commit 1513d58

File tree

5 files changed

+184
-33
lines changed

5 files changed

+184
-33
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ typings/
6060
# lnd files
6161
lnd.cert
6262
admin.macaroon
63+
64+
# built files
65+
dist/

client/GraphMap.jsx

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ import { ObjectTypes } from './DataStore.js';
44
import { computed, autorun } from 'mobx';
55
import { observer } from 'mobx-react';
66

7+
import FontAwesome from 'react-fontawesome';
8+
import FA from 'font-awesome/css/font-awesome.css';
9+
10+
var styles = {
11+
container: {
12+
position: 'relative',
13+
width: '100%',
14+
height: '100%'
15+
},
16+
overlay: {
17+
position: 'absolute',
18+
top: 0,
19+
left: 0,
20+
width: '100%',
21+
height: '100%',
22+
display: 'flex',
23+
alignItems: 'center',
24+
justifyContent: 'center'
25+
}
26+
}
27+
728
@observer
829
export default class App extends React.Component {
930
state = {
@@ -37,8 +58,15 @@ export default class App extends React.Component {
3758
this.props.store.selectObject(event.edges[0]);
3859
else
3960
this.props.store.selectObject(undefined);
61+
},
62+
// Called when initial stabilization is complete
63+
stabilizationIterationsDone: (event) => {
64+
this.setState({
65+
loading: false
66+
});
4067
}
41-
}
68+
},
69+
loading: true
4270
};
4371

4472
// Transforms network data into vis.js data format
@@ -80,6 +108,12 @@ export default class App extends React.Component {
80108
});
81109
}
82110

111+
// Notify that graph changed and will need to be restabilised
112+
this.graphChanged = true;
113+
this.setState({
114+
loading: true
115+
});
116+
83117
return graph;
84118
}
85119

@@ -95,8 +129,6 @@ export default class App extends React.Component {
95129

96130
if (!this.network || !object)
97131
return;
98-
99-
console.log(object);
100132

101133
if (object.type == ObjectTypes.NODE)
102134
{
@@ -114,16 +146,29 @@ export default class App extends React.Component {
114146
});
115147
}
116148

149+
componentWillReact() {
150+
151+
}
152+
117153
componentDidUpdate(prevProps, prevState) {
118-
if (this.network)
154+
// Stabilize if graph changed
155+
if (this.network && this.graphChanged)
119156
{
120-
setTimeout(() => this.network.fit(), 500);
157+
this.network.stabilize();
158+
this.graphChanged = false;
121159
}
122160
}
123161

124162
render() {
125163
return (
126-
<Graph graph={this.graphData} options={this.state.options} events={this.state.events} getNetwork={(network) => this.getNetwork(network)} />
164+
<div style={styles.container}>
165+
<Graph graph={this.graphData} options={this.state.options} events={this.state.events} getNetwork={(network) => this.getNetwork(network)} />
166+
{ this.state.loading ? (
167+
<div style={styles.overlay}>
168+
<FontAwesome name='spinner' pulse size='2x' cssModule={FA} />
169+
</div>
170+
) : '' }
171+
</div>
127172
);
128173
}
129174
}

package-lock.json

Lines changed: 35 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/chemicstry/recksplorer.git"
9+
},
610
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
11+
"test": "echo \"Error: no test specified\" && exit 1",
12+
"build": "rimraf dist && cross-env NODE_ENV=production webpack --config ./webpack.production.config.js --progress --profile --colors",
13+
"start": "node server"
814
},
915
"author": "",
1016
"license": "ISC",
@@ -43,6 +49,7 @@
4349
"file-loader": "^1.1.6",
4450
"html-webpack-plugin": "^2.30.1",
4551
"resolve-url-loader": "^2.2.1",
52+
"rimraf": "^2.6.2",
4653
"style-loader": "^0.19.1",
4754
"webpack": "^3.10.0",
4855
"webpack-dev-middleware": "^2.0.4",

webpack.production.config.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
'use strict';
2+
3+
var path = require('path');
4+
var webpack = require('webpack');
5+
var HtmlWebpackPlugin = require('html-webpack-plugin');
6+
7+
module.exports = {
8+
entry: [
9+
path.join(__dirname, 'client/main.js')
10+
],
11+
output: {
12+
path: path.join(__dirname, '/dist/'),
13+
filename: '[name]-[hash].min.js',
14+
publicPath: '/'
15+
},
16+
plugins: [
17+
new HtmlWebpackPlugin({
18+
template: 'client/index.tpl.html',
19+
inject: 'body',
20+
filename: 'index.html'
21+
}),
22+
new webpack.optimize.OccurrenceOrderPlugin(),
23+
new webpack.optimize.UglifyJsPlugin({
24+
compressor: {
25+
warnings: false,
26+
screw_ie8: true
27+
}
28+
})
29+
],
30+
module: {
31+
loaders: [
32+
{
33+
test: /\.jsx?$/,
34+
exclude: /node_modules/,
35+
loader: 'babel-loader',
36+
query: {
37+
"presets": [
38+
["env", {"modules": false}],
39+
"stage-1",
40+
"react"
41+
],
42+
"plugins": [
43+
"transform-runtime",
44+
"transform-decorators-legacy"
45+
]
46+
}
47+
},
48+
{
49+
test: /\.json?$/,
50+
loader: 'json'
51+
},
52+
{
53+
test: /\font-awesome.css$/,
54+
loader: 'css-loader',
55+
query: {
56+
modules: false
57+
}
58+
},
59+
{
60+
test: /\.css$/,
61+
loaders: [
62+
{
63+
loader: 'style-loader'
64+
},
65+
{
66+
loader: 'css-loader',
67+
query: {
68+
modules: true,
69+
localIdentName: '[name]__[local]___[hash:base64:5]'
70+
}
71+
},
72+
{
73+
loader: 'resolve-url-loader'
74+
}
75+
],
76+
},
77+
{
78+
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
79+
loader: "url-loader?limit=10000&mimetype=application/font-woff"
80+
},
81+
{
82+
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
83+
loader: "file-loader"
84+
},
85+
]
86+
}
87+
};

0 commit comments

Comments
 (0)