small update: integrated webserver in the main.go, small frontend changes, not finished relation loops bug fix
arnaucode idoctnef@openmailbox.org
Thu, 17 Aug 2017 13:51:02 +0200
10 files changed,
53 insertions(+),
23 deletions(-)
M
README.md
→
README.md
@@ -7,10 +7,14 @@ - Network Address generation avoiding infinite relation loops
- Sankey Address generation without loops - Frontend - After Sankey visualization, go to Network Address visualization and render without Sankey dots - +- Both + - Tx/day + - Tx volume + - Block size + - Blockchain size ### Install -1. Nodejs & NPM https://nodejs.org/ --> to serve the web, not necessary if the web files are in a webserver +1. Nodejs & NPM https://nodejs.org/ --> to get npm packages for the web 2. MongoDB https://www.mongodb.com/ 3. Faircoin wallet https://download.faircoin.world/, or the Cryptocurrency desired wallet 4. goBlockchainDataAnalysis https://github.com/arnaucode/goBlockchainDataAnalysis@@ -61,8 +65,11 @@ 3.1. The next runs, once the database have data, can just run:
``` ./goBlockchainDataAnalysis ``` +Webapp will run on 127.0.0.1:8080 -4. Run the webserver, in the /web directory +4. ADDITIONAL - Run the webserver, directly from the /web directory +This can be useful if need to deploy the API server in one machine and the webserver in other. +In the /web directory: ``` npm start ```@@ -83,7 +90,7 @@ ### Some screenshots
 - + 
M
addressTree.go
→
addressTree.go
@@ -2,11 +2,12 @@ package main
import ( "fmt" + "log" + + "github.com/fatih/color" "gopkg.in/mgo.v2/bson" ) - -var upLevelEdge EdgeModel func upTree(address string, network NetworkModel) NetworkModel { var upNetwork NetworkModel@@ -33,16 +34,22 @@ nodes := []NodeModel{}
err := nodeCollection.Find(bson.M{"id": }).All(&edges) check(err) */ + endBranch := false edgeUpCheck := EdgeModel{} err := edgeCollection.Find(bson.M{"to": e.From}).One(&edgeUpCheck) - check(err) + if err != nil { + log.Println(err) + color.Blue("not found") + endBranch = true + } //need to be fixed when there is a bucle between the addresses (A-->B, B-->C, C-->A) fmt.Println(e.From + " - " + e.To) //if e.From != e.To && e.From != upLevelEdge.To && e.To != upLevelEdge.From { //if e.From != e.To { - if edgeInEdges(network.Edges, edgeUpCheck) == false { - upLevelEdge = e + fmt.Println(endBranch) + fmt.Println(edgeInEdges(network.Edges, edgeUpCheck)) + if edgeInEdges(network.Edges, edgeUpCheck) == false && endBranch == false { upNetwork = upTree(e.From, network) for _, upN := range upNetwork.Nodes { if nodeInNodes(network.Nodes, upN) == false {
M
main.go
→
main.go
@@ -67,6 +67,8 @@ }
log.Printf("Block count: %d", blockCount) } } + //run thw webserver + go webserver() //http server start readServerConfig("./serverConfig.json")@@ -82,3 +84,9 @@ log.Fatal(http.ListenAndServe(":"+serverConfig.ServerPort, handlers.CORS(originsOk, headersOk, methodsOk)(router)))
//log.Fatal(http.ListenAndServe(":"+serverConfig.ServerPort, router)) } + +func webserver() { + log.Println("webserver in port " + serverConfig.WebServerPort) + http.Handle("/", http.FileServer(http.Dir("./web"))) + http.ListenAndServe(":"+serverConfig.WebServerPort, nil) +}
M
mongoOperations.go
→
mongoOperations.go
@@ -12,7 +12,7 @@ )
//MongoConfig stores the configuration of mongodb to connect type MongoConfig struct { - Ip string `json:"ip"` + IP string `json:"ip"` Database string `json:"database"` }@@ -28,7 +28,7 @@ json.Unmarshal([]byte(content), &mongoConfig)
} func getSession() (*mgo.Session, error) { - session, err := mgo.Dial("mongodb://" + mongoConfig.Ip) + session, err := mgo.Dial("mongodb://" + mongoConfig.IP) if err != nil { panic(err) }
M
serverConfig.go
→
serverConfig.go
@@ -20,10 +20,11 @@ }
//server config type ServerConfig struct { - ServerIP string `json:"serverIP"` - ServerPort string `json:"serverPort"` - AllowedIPs []string `json:"allowedIPs"` - BlockedIPs []string `json:"blockedIPs"` + ServerIP string `json:"serverIP"` + ServerPort string `json:"serverPort"` + WebServerPort string `json:"webserverPort"` + AllowedIPs []string `json:"allowedIPs"` + BlockedIPs []string `json:"blockedIPs"` } var serverConfig ServerConfig
M
web/css/style.css
→
web/css/style.css
@@ -32,8 +32,13 @@
/* sidebar */ .o_sidebar a{ color: white; + padding: 10px; } .o_sidebar a:hover{ background: #9E9E9E!important; color: white; } +.o_sidebarIcon{ + font-size: 180%; + margin-right: 10px; +}
M
web/views/addressNetwork/addressNetwork.html
→
web/views/addressNetwork/addressNetwork.html
@@ -1,7 +1,7 @@
<div class="row"> <div class="col-sm-3"> <div class="panel-heading c_blueGrey300"> - <h3 class="panel-title">All addresses</h3> + <h3 class="panel-title">All addresses ({{addresses.length}})</h3> </div> <div class="panel-body" style="max-height: 500px;overflow-y: scroll;"> <div class="form-group label-floating">@@ -18,7 +18,7 @@ </div>
</div> <div class="col-sm-9"> <div class="panel-heading c_blueGrey300"> - <h3 class="panel-title">Address history Network Map</h3> + <h3 class="panel-title">Address history Network Map {{selectedAddress.id}}, BlockHeight: {{selectedAddress.group}}</h3> </div> <div class="panel-body"> <div id="mynetwork" style="height:800px;"></div>
M
web/views/addressNetwork/addressNetwork.js
→
web/views/addressNetwork/addressNetwork.js
@@ -71,8 +71,10 @@ }, function(data, status, headers, config) {
console.log('data error'); }); + $scope.selectedAddress=""; $scope.getAddressNetwork = function(address) { console.log(address); + $scope.selectedAddress=address; $http.get(urlapi + 'address/network/' + address.id) .then(function(data, status, headers, config) { console.log('data success');