mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 22:34:24 +00:00
Implemented logic to detect if IPFS node is running or not and display online/offline status and error message in the demo app boilerplate
This commit is contained in:
parent
e6d998fd1a
commit
e36fca383a
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
<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)<span class="pull-right" id="status-storage"></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>
|
<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">
|
||||||
@ -37,7 +37,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="storage">
|
<div role="tabpanel" class="tab-pane" id="storage">
|
||||||
note: You need to have an IPFS node running
|
<div class="error alert alert-danger" role="alert">The node you are using does not support IPFS. Please ensure <a href="https://github.com/ipfs/js-ipfs-api#cors" target="_blank">CORS</a> is setup for the IPFS node.</div>
|
||||||
|
<div id="storage-controls">
|
||||||
|
|
||||||
<h3>Save text to IPFS</h3>
|
<h3>Save text to IPFS</h3>
|
||||||
<div class="form-group form-inline">
|
<div class="form-group form-inline">
|
||||||
@ -72,10 +73,10 @@
|
|||||||
<div class="logs">
|
<div class="logs">
|
||||||
<br> EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'})
|
<br> EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'})
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="communication">
|
<div role="tabpanel" class="tab-pane" id="communication">
|
||||||
<div class="error alert alert-danger" role="alert">The node you are using does not support whisper</div>
|
<div class="error alert alert-danger" role="alert">The node you are using does not support Whisper</div>
|
||||||
<div id="communication-controls">
|
<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">
|
||||||
|
@ -30,6 +30,21 @@ $(document).ready(function() {
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'});
|
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() {
|
$("#storage button.setIpfsText").click(function() {
|
||||||
var value = $("#storage input.ipfsText").val();
|
var value = $("#storage input.ipfsText").val();
|
||||||
EmbarkJS.Storage.saveText(value).then(function(hash) {
|
EmbarkJS.Storage.saveText(value).then(function(hash) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user