mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
better feedback for replayStoredEdits()
This commit is contained in:
parent
5f82c3f514
commit
2eadaae362
@ -98,11 +98,11 @@ define([
|
||||
this._online = false;
|
||||
},
|
||||
|
||||
goOnline: function()
|
||||
goOnline: function(callback)
|
||||
{
|
||||
console.log('going online');
|
||||
this._online = true;
|
||||
this.replayStoredEdits();
|
||||
this.replayStoredEdits(callback);
|
||||
//this.refresh();
|
||||
},
|
||||
|
||||
@ -111,7 +111,7 @@ define([
|
||||
return this._online;
|
||||
},
|
||||
|
||||
replayStoredEdits: function()
|
||||
replayStoredEdits: function(callback)
|
||||
{
|
||||
if( editsStore.hasPendingEdits() )
|
||||
{
|
||||
@ -168,7 +168,7 @@ define([
|
||||
{
|
||||
console.log(err);
|
||||
}
|
||||
self.replayStoredEdits();
|
||||
self.replayStoredEdits(callback);
|
||||
},
|
||||
function(err)
|
||||
{
|
||||
@ -183,6 +183,7 @@ define([
|
||||
{
|
||||
console.log("'finished!");
|
||||
this.emit('all-edits-sent',{});
|
||||
callback && callback();
|
||||
}
|
||||
}, // replayStoredEdits()
|
||||
|
||||
|
||||
@ -42,9 +42,10 @@
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
#connectivityIndicator { color: white; background-color: #aaa; }
|
||||
#connectivityIndicator.online { background-color: #0C0; }
|
||||
#connectivityIndicator.offline { background-color: #E00; }
|
||||
#connectivityIndicator { color: white; background-color: #aaa; }
|
||||
#connectivityIndicator.online { background-color: #0C0; }
|
||||
#connectivityIndicator.offline { background-color: #E00; }
|
||||
#connectivityIndicator.reconnecting { background-color: orange; }
|
||||
|
||||
#pendingEdits {
|
||||
border: 1px solid black;
|
||||
@ -102,7 +103,7 @@
|
||||
"dojo/i18n!esri/nls/jsapi",
|
||||
|
||||
"dojo/_base/array", "dojo/parser", "dojo/keys",
|
||||
"dojo/dom", "dojo/on", "dojo/dom-construct", "dojo/dom-class",
|
||||
"dojo/dom", "dojo/on", "dojo/dom-construct", "dojo/dom-class", "esri/domUtils",
|
||||
|
||||
"dijit/layout/BorderContainer", "dijit/layout/ContentPane",
|
||||
"dojo/domReady!"
|
||||
@ -114,8 +115,10 @@
|
||||
Editor, TemplatePicker,
|
||||
esriConfig, jsapiBundle,
|
||||
arrayUtils, parser, keys,
|
||||
dom, on, domConstruct, domClass
|
||||
dom, on, domConstruct, domClass, domUtils
|
||||
) {
|
||||
var editor;
|
||||
|
||||
parser.parse();
|
||||
dojo.fadeOut({node:'loader-cloak', onEnd: function(n){n.style.display="none"}}).play();
|
||||
|
||||
@ -174,9 +177,6 @@
|
||||
});
|
||||
|
||||
updatePendingEditsList();
|
||||
|
||||
// jabadia: only if we have internet available
|
||||
offlineFeaturesManager.replayStoredEdits();
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
@ -215,7 +215,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
var editor = new Editor({ settings: settings }, 'editorDiv');
|
||||
editor = new Editor({ settings: settings }, 'editorDiv');
|
||||
editor.startup();
|
||||
|
||||
console.log("ok!");
|
||||
@ -224,6 +224,19 @@
|
||||
{
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
try {
|
||||
// jabadia: only if we have internet available
|
||||
domUtils.show(editor.progressBar.domNode);
|
||||
offlineFeaturesManager.replayStoredEdits(function()
|
||||
{
|
||||
domUtils.hide(editor.progressBar.domNode);
|
||||
});
|
||||
}
|
||||
catch(err)
|
||||
{
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatus()
|
||||
@ -275,8 +288,17 @@
|
||||
|
||||
function goOnline()
|
||||
{
|
||||
offlineFeaturesManager.goOnline();
|
||||
updateConnectivityIndicator();
|
||||
var node = dom.byId('connectivityIndicator');
|
||||
domClass.remove(node, "online offline reconnecting");
|
||||
node.innerHTML = "<i class='fa fa-spinner fa-spin'></i> reconnecting";
|
||||
domClass.add(node, "reconnecting");
|
||||
|
||||
domUtils.show(editor.progressBar.domNode);
|
||||
offlineFeaturesManager.goOnline(function()
|
||||
{
|
||||
domUtils.hide(editor.progressBar.domNode);
|
||||
updateConnectivityIndicator();
|
||||
});
|
||||
}
|
||||
|
||||
function goOffline()
|
||||
@ -289,7 +311,7 @@
|
||||
{
|
||||
var node = dom.byId('connectivityIndicator');
|
||||
|
||||
domClass.remove(node, "online offline");
|
||||
domClass.remove(node, "online offline reconnecting");
|
||||
|
||||
if( offlineFeaturesManager.isOnline() )
|
||||
{
|
||||
@ -329,7 +351,7 @@
|
||||
<div id="pendingEditsPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-propos="region:'top'">
|
||||
<button style="width:60%" id="clear-pending-edits-btn" class="btn1">Clear Local Edits</button>
|
||||
<button style="width:38%" id="go-offline-btn" class="btn1">Go Offline</button>
|
||||
<button style="width:60%" id="refresh-feature-layers-btn" class="btn1">Refesh Layer</button>
|
||||
<button style="width:60%" id="refresh-feature-layers-btn" class="btn1">Refresh Layers</button>
|
||||
<button style="width:38%" id="go-online-btn" class="btn1">Go Online</button>
|
||||
<ul id="pendingEdits"></ul>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user