From 7d63604ac4f444a67a5d2d1ae59b3b1cd1246dee Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Thu, 16 Feb 2017 15:52:03 -0500 Subject: [PATCH 1/3] Added logic to demo app to display a offline/online status connection on the Whisper tab and hide controls if offline --- demo/app/css/main.css | 23 +++++++++++++++++++++++ demo/app/index.html | 8 ++++---- demo/app/js/index.js | 4 +++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/demo/app/css/main.css b/demo/app/css/main.css index abfcd67f..e0043e37 100644 --- a/demo/app/css/main.css +++ b/demo/app/css/main.css @@ -24,3 +24,26 @@ div { margin-bottom: 0; } +.status-offline { + vertical-align: middle; + margin-left: 5px; + margin-top: 4px; + width: 12px; + height: 12px; + background: red; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + border-radius: 10px; +} + +.status-online { + vertical-align: middle; + margin-left: 5px; + margin-top: 4px; + width: 12px; + height: 12px; + background: mediumseagreen; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + border-radius: 10px; +} diff --git a/demo/app/index.html b/demo/app/index.html index 417f6096..6544e05d 100644 --- a/demo/app/index.html +++ b/demo/app/index.html @@ -10,7 +10,7 @@
@@ -75,8 +75,8 @@
- The node you are using does not support whisper - + +

Listen To channel

@@ -97,7 +97,7 @@

EmbarkJS.Messages.setProvider('whisper')
- +
diff --git a/demo/app/js/index.js b/demo/app/js/index.js index e5a1ebe6..60147b1b 100644 --- a/demo/app/js/index.js +++ b/demo/app/js/index.js @@ -76,8 +76,11 @@ $(document).ready(function() { web3.version.getWhisper(function(err, res) { if (err) { $("#communication .error").show(); + $("#communication-controls").hide(); ++ $("#status-communication").addClass('status-offline'); } else { EmbarkJS.Messages.setProvider('whisper'); + $("#status-communication").addClass('status-online'); } }); @@ -98,4 +101,3 @@ $(document).ready(function() { }); }); - From e6d998fd1af2ab807ce54b148b1c6f452716ef82 Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Fri, 17 Feb 2017 14:34:07 -0500 Subject: [PATCH 2/3] If no arguments are passed to embark, then display help by default --- lib/cmd.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/cmd.js b/lib/cmd.js index fd93a9f0..05bcd33a 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -16,6 +16,12 @@ Cmd.prototype.process = function(args) { this.test(); this.upload(); this.otherCommands(); + + //If no arguments are passed display help by default + if (!process.argv.slice(2).length) { + program.help(); + } + program.parse(args); }; From e36fca383a648488f0a4dee3f3d9eac5e23ad2af Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Fri, 17 Feb 2017 18:11:20 -0500 Subject: [PATCH 3/3] Implemented logic to detect if IPFS node is running or not and display online/offline status and error message in the demo app boilerplate --- demo/app/index.html | 11 ++++++----- demo/app/js/index.js | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/demo/app/index.html b/demo/app/index.html index 6544e05d..9dcde044 100644 --- a/demo/app/index.html +++ b/demo/app/index.html @@ -9,8 +9,8 @@
@@ -37,7 +37,8 @@
- note: You need to have an IPFS node running + +

Save text to IPFS

@@ -72,10 +73,10 @@

EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'})
- +
- +

Listen To channel

diff --git a/demo/app/js/index.js b/demo/app/js/index.js index 60147b1b..c430bbf9 100644 --- a/demo/app/js/index.js +++ b/demo/app/js/index.js @@ -30,6 +30,21 @@ $(document).ready(function() { $(document).ready(function() { EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'}); + $("#storage .error").hide(); + EmbarkJS.Storage.ipfsConnection.ping() + .then(function(){ + $("#status-storage").addClass('status-online'); + $("#storage-controls").show(); + }) + .catch(function(err) { + if(err){ + console.log("IPFS Connection Error => " + err.message); + $("#storage .error").show(); + $("#status-storage").addClass('status-offline'); + $("#storage-controls").hide(); + } + }); + $("#storage button.setIpfsText").click(function() { var value = $("#storage input.ipfsText").val(); EmbarkJS.Storage.saveText(value).then(function(hash) {