From 9531d0e853f4aaff6a3ff4972b5639dff110f08a Mon Sep 17 00:00:00 2001 From: Jake Cooper Date: Mon, 3 Apr 2017 19:43:16 -0700 Subject: [PATCH 01/14] Split FE, and now also make user on socket connect --- incomingTxWatcher.go | 11 +- static/index.html | 233 ++----------------------------------------- static/scripts.js | 169 +++++++++++++++++++++++++++++++ static/styles.css | 29 ++++++ 4 files changed, 214 insertions(+), 228 deletions(-) create mode 100644 static/scripts.js create mode 100644 static/styles.css diff --git a/incomingTxWatcher.go b/incomingTxWatcher.go index 1a71f71..021818d 100644 --- a/incomingTxWatcher.go +++ b/incomingTxWatcher.go @@ -102,13 +102,18 @@ func wsHandler(w http.ResponseWriter, r *http.Request) { } // frontend handshake to get user and hook them into the userMap for sockets _, message, err := conn.ReadMessage() + userID := string(message) failOnError(err, "Failed to handshake") - fmt.Printf("Handshake from client is %s\n", message) - userSocket, found := userSocketmap[string(message)] + fmt.Printf("Handshake from client is %s\n", userID) + userSocket, found := userSocketmap[string(userID)] if found { userSocket.Close() } - userSocketmap[string(message)] = conn + userSocketmap[string(userID)] = conn + if _, accountExists := accountStore[userID]; !accountExists { + consoleLog.Infof("Creating account for %s", userID) + accountStore[userID] = newAccountForUser(userID) + } } func incomingTxWatcher() { diff --git a/static/index.html b/static/index.html index 32c67c0..697e6f2 100644 --- a/static/index.html +++ b/static/index.html @@ -5,245 +5,28 @@ + + -
- -
diff --git a/static/scripts.js b/static/scripts.js index e7fd99a..fb71741 100644 --- a/static/scripts.js +++ b/static/scripts.js @@ -72,6 +72,11 @@ function doAuth(rawData) { } } document.getElementById("portfolio").innerHTML = portfolioContainer.innerHTML + + autoTxContainer = document.createElement("div") + userData["pendingATX"].map(function(elem) { + console.log(elem) + }) }; } else { var item = document.createElement("div"); From ce055b6a0ad49c8fa0501a6aff5274bff1234012 Mon Sep 17 00:00:00 2001 From: Jake Cooper Date: Tue, 4 Apr 2017 16:26:45 -0700 Subject: [PATCH 14/14] AutoTx now shows in FE --- static/index.html | 2 +- static/scripts.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/static/index.html b/static/index.html index 6dae88c..81fd3c3 100644 --- a/static/index.html +++ b/static/index.html @@ -188,7 +188,7 @@

User Info:

PendingBuys:
PendingSells:
Portfolio:
-
Portfolio:
+
AutoTx:
diff --git a/static/scripts.js b/static/scripts.js index 9ad5fc5..81d9dd0 100644 --- a/static/scripts.js +++ b/static/scripts.js @@ -75,8 +75,11 @@ function doAuth(rawData) { autoTxContainer = document.createElement("div") userData["pendingATX"].map(function(elem) { - console.log(elem) + var item = document.createElement("div"); + item.innerText = "{" + elem.stock + "," + elem.amount + "," + elem.trigger + "," + elem.action + "}" + autoTxContainer.appendChild(item) }) + document.getElementById("autotx").innerHTML = autoTxContainer.innerHTML }; } else { var item = document.createElement("div");