Added logic to demo app to display a offline/online status connection on the Whisper tab and hide controls if offline

This commit is contained in:
Andy Nogueira 2017-02-16 15:52:03 -05:00
parent 73c7d58e40
commit 7d63604ac4
3 changed files with 30 additions and 5 deletions

View File

@ -24,3 +24,26 @@ div {
margin-bottom: 0; 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;
}

View File

@ -10,7 +10,7 @@
<ul class="nav nav-tabs" role="tablist" id="myTabs"> <ul class="nav nav-tabs" role="tablist" id="myTabs">
<li role="presentation" class="active"><a href="#blockchain" aria-controls="blockchain" role="tab" data-toggle="tab">Blockchain</a></li> <li role="presentation" class="active"><a href="#blockchain" aria-controls="blockchain" role="tab" data-toggle="tab">Blockchain</a></li>
<li role="presentation"><a href="#storage" aria-controls="storage" role="tab" data-toggle="tab">Decentralized Storage (IPFS)</a></li> <li role="presentation"><a href="#storage" aria-controls="storage" role="tab" data-toggle="tab">Decentralized Storage (IPFS)</a></li>
<li role="presentation"><a href="#communication" aria-controls="communication" role="tab" data-toggle="tab">P2P communication (whisper/orbit)</a></li> <li role="presentation"><a href="#communication" aria-controls="communication" role="tab" data-toggle="tab">P2P communication (whisper/orbit)<span class="pull-right" id="status-communication"></span></a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
@ -75,8 +75,8 @@
</div> </div>
<div role="tabpanel" class="tab-pane" id="communication"> <div role="tabpanel" class="tab-pane" id="communication">
<span class="error">The node you are using does not support whisper</span> <div class="error alert alert-danger" role="alert">The node you are using does not support whisper</div>
<div id="communication-controls">
<h3>Listen To channel</h3> <h3>Listen To channel</h3>
<div class="form-group form-inline listen"> <div class="form-group form-inline listen">
<input type="text" class="channel text form-control" placeholder="channel"> <input type="text" class="channel text form-control" placeholder="channel">
@ -97,7 +97,7 @@
<div class="logs"> <div class="logs">
<br> EmbarkJS.Messages.setProvider('whisper') <br> EmbarkJS.Messages.setProvider('whisper')
</div> </div>
</div>
</div> </div>
</div> </div>

View File

@ -76,8 +76,11 @@ $(document).ready(function() {
web3.version.getWhisper(function(err, res) { web3.version.getWhisper(function(err, res) {
if (err) { if (err) {
$("#communication .error").show(); $("#communication .error").show();
$("#communication-controls").hide();
+ $("#status-communication").addClass('status-offline');
} else { } else {
EmbarkJS.Messages.setProvider('whisper'); EmbarkJS.Messages.setProvider('whisper');
$("#status-communication").addClass('status-online');
} }
}); });
@ -98,4 +101,3 @@ $(document).ready(function() {
}); });
}); });