* Adds support for token-based authentication when syncing feature
edits.
* Reduces POST request payload size when syncing edits by removing the
InfoTemplate from request parameters.
This commit is contained in:
robkspeer 2015-08-07 11:08:54 -07:00
parent 46b12bdc2e
commit c362f86a4d
12 changed files with 6955 additions and 6914 deletions

View File

@ -1,5 +1,13 @@
# offline-editor-js - Changelog
## Version 2.12
No breaking changes.
**Enhancements**
* Adds support for token-based authentication when syncing feature edits.
* Reduces POST request payload size when syncing edits by removing the InfoTemplate from request parameters.
## Version 2.11.0.1 - Aug. 6, 2015
No breaking changes. Documentation and samples update, only.

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! offline-editor-js - v2.11.0 - 2015-07-30
/*! offline-editor-js - v2.12.0 - 2015-08-07
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
/*jshint -W030 */
@ -12,6 +12,7 @@ define([
"dojo/dom-style",
"dojo/query",
"esri/config",
"esri/kernel",
"esri/layers/GraphicsLayer",
"esri/graphic",
"esri/request",
@ -20,7 +21,7 @@ define([
"esri/symbols/SimpleFillSymbol",
"esri/urlUtils"],
function (Evented, Deferred, all, declare, array, domAttr, domStyle, query,
esriConfig, GraphicsLayer, Graphic, esriRequest, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, urlUtils) {
esriConfig, kernel, GraphicsLayer, Graphic, esriRequest, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, urlUtils) {
"use strict";
return declare("O.esri.Edit.OfflineFeaturesManager", [Evented],
{
@ -2107,6 +2108,11 @@ define([
a = "&adds=" + JSON.stringify((adds));
}
if(updates.length > 0) {
array.forEach(updates, function(update){
if(update.hasOwnProperty("infoTemplate")){ // if the update has an infoTemplate attached,
delete update.infoTemplate; // delete it to reduce payload size.
}
}, this);
u = "&updates=" + JSON.stringify(updates);
}
if(deletes.length > 0) {
@ -2116,6 +2122,16 @@ define([
var params = f + a + u + d;
if(kernel.hasOwnProperty("id")){ // if there are credentials stored
if(kernel.id.hasOwnProperty("credentials")){ // within the kernel object,
array.forEach(kernel.id.credentials, function(credential){ // go thru all of them,
if(credential.server === url.split("/", 3).join("/")){ // find the credential that lines up with the server our feature is on,
params = params + "&token=" + credential.token; // and then append the token to the params.
}
}, this);
}
}
var req = new XMLHttpRequest();
req.open("POST", url + "/applyEdits", true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
@ -2128,14 +2144,15 @@ define([
callback(obj.addResults, obj.updateResults, obj.deleteResults);
}
catch(err) {
errback("Unable to parse xhr response");
console.error("EDIT REQUEST REPONSE WAS NOT SUCCESSFUL:", req);
errback("Unable to parse xhr response", req);
}
}
};
req.onerror = function(e)
{
console.log("_makeEditRequest failed: " + e);
console.error("_makeEditRequest failed: " + e);
errback(e);
};
req.ontimeout = function() {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

8246
dist/offline-tpk-src.js vendored

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,7 @@ define([
"dojo/dom-style",
"dojo/query",
"esri/config",
"esri/kernel",
"esri/layers/GraphicsLayer",
"esri/graphic",
"esri/request",
@ -17,7 +18,7 @@ define([
"esri/symbols/SimpleFillSymbol",
"esri/urlUtils"],
function (Evented, Deferred, all, declare, array, domAttr, domStyle, query,
esriConfig, GraphicsLayer, Graphic, esriRequest, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, urlUtils) {
esriConfig, kernel, GraphicsLayer, Graphic, esriRequest, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, urlUtils) {
"use strict";
return declare("O.esri.Edit.OfflineFeaturesManager", [Evented],
{
@ -2104,6 +2105,11 @@ define([
a = "&adds=" + JSON.stringify((adds));
}
if(updates.length > 0) {
array.forEach(updates, function(update){
if(update.hasOwnProperty("infoTemplate")){ // if the update has an infoTemplate attached,
delete update.infoTemplate; // delete it to reduce payload size.
}
}, this);
u = "&updates=" + JSON.stringify(updates);
}
if(deletes.length > 0) {
@ -2113,6 +2119,16 @@ define([
var params = f + a + u + d;
if(kernel.hasOwnProperty("id")){ // if there are credentials stored
if(kernel.id.hasOwnProperty("credentials")){ // within the kernel object,
array.forEach(kernel.id.credentials, function(credential){ // go thru all of them,
if(credential.server === url.split("/", 3).join("/")){ // find the credential that lines up with the server our feature is on,
params = params + "&token=" + credential.token; // and then append the token to the params.
}
}, this);
}
}
var req = new XMLHttpRequest();
req.open("POST", url + "/applyEdits", true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
@ -2125,14 +2141,15 @@ define([
callback(obj.addResults, obj.updateResults, obj.deleteResults);
}
catch(err) {
errback("Unable to parse xhr response");
console.error("EDIT REQUEST REPONSE WAS NOT SUCCESSFUL:", req);
errback("Unable to parse xhr response", req);
}
}
};
req.onerror = function(e)
{
console.log("_makeEditRequest failed: " + e);
console.error("_makeEditRequest failed: " + e);
errback(e);
};
req.ontimeout = function() {

View File

@ -1,6 +1,6 @@
{
"name": "offline-editor-js",
"version": "2.11.0.1",
"version": "2.12.0",
"description": "Lightweight set of libraries for working offline with map tiles and ArcGIS feature services",
"author": "Andy Gup <agup@esri.com> (http://blog.andygup.net)",
"license": "Apache 2",

View File

@ -9,7 +9,7 @@
"appHomePage": "appcache-tiles.html",
"optimizedApiURL": "../samples/jsolib",
"arcGISBaseURL": "http://js.arcgis.com/3.14",
"version": "2.11.0.1",
"version": "2.12.0",
"private": true,
"description": "manifest generator project",
"repository": {