Mild refactoring & adds debug statements
diff --git a/asterix-examples/src/main/resources/black-cherry/cherry.tpl b/asterix-examples/src/main/resources/black-cherry/cherry.tpl
index 015daf2..87fc2f5 100755
--- a/asterix-examples/src/main/resources/black-cherry/cherry.tpl
+++ b/asterix-examples/src/main/resources/black-cherry/cherry.tpl
@@ -84,27 +84,28 @@
<p>Welcome to the top-level page of the mysteriously named Black Cherry Demo of AsterixDB. The purpose of this demo is to illustrate how a "cool application" can be built using the JavaScript SDK of AsterixDB and to exercise all of the AsterixDB HTTP APIs. If you are building an app of your own, reading the code for this app is a great way to get acquainted with what you'll need to know.</p>
<p>In this demo, which is based on spatial analysis of Tweets (it is 2013, afterall), you will see how to formulate aggregate queries and drill-down queries using the query door of the AsterixDB API. You will see how to do this either synchronously or asynchronously (for larger queries whose results may take a while to cook). You will also see how to create and drop datasets (to manage Tweetbooks, notebooks with user commentary on Tweets) and how to perform inserts and deletes (to add/remove Tweetbook entries). Let's walk through the demo.</p>
+ </div>
+
+ <hr/>
- <hr/>
+ <!-- Tutorial Part 1: Overview -->
+ <div style="margin-bottom: 2em; text-align: center;">
+ <img src="static/img/Tutorial1.png" style="max-width:100%;">
+ </div><hr/>
- <div style="margin-bottom: 2em; text-align: center;">
- <img src="static/img/Tutorial1.png" style="max-width:100%;">
- </div><hr/>
+ <!-- Tutorial Part 2: Location Search -->
+ <div style="margin-bottom: 2em; text-align: center;">
+ <img src="static/img/Tutorial2.png" style="max-width:100%;">
+ </div><hr/>
- <!-- Tutorial Part 2: Location Search -->
- <div style="margin-bottom: 2em; text-align: center;">
- <img src="static/img/Tutorial2.png" style="max-width:100%;">
- </div><hr/>
+ <!-- Tutorial Part 3: Search Results, Drilling Down, Saving Comments -->
+ <div style="margin-bottom: 2em; text-align: center;">
+ <img src="static/img/Tutorial3.png" style="max-width:100%;">
+ </div><hr/>
- <!-- Tutorial Part 3: Search Results, Drilling Down, Saving Comments -->
- <div style="margin-bottom: 2em; text-align: center;">
- <img src="static/img/Tutorial3.png" style="max-width:100%;">
- </div><hr/>
-
- <!-- Tutorial Part 4: Review Mode -->
- <div style="margin-bottom: 2em; text-align: center;">
- <img src="static/img/Tutorial4.png" style="max-width:100%;">
- </div>
+ <!-- Tutorial Part 4: Review Mode -->
+ <div style="margin-bottom: 2em; text-align: center;">
+ <img src="static/img/Tutorial4.png" style="max-width:100%;">
</div>
</div>
</div><!-- End About Tab -->
@@ -165,8 +166,7 @@
<!-- Submission Buttons -->
<li class="list-group-item">
<button class="btn btn-primary" type="button" id="submit-button">Submit</button>
- <button class="btn btn-primary" type="button" id="clear-button">Clear</button>
- <button class="btn btn-primary" type="button" id="show-query-button">Show Query</button><br/>
+ <button class="btn btn-primary" type="button" id="clear-button">Clear</button><br/>
<input type="checkbox" value="Submit Asynchronously" name="async" id="asbox" />
Submit asynchronously?
</li>
diff --git a/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py b/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py
index d78514b..8616438 100755
--- a/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py
+++ b/asterix-examples/src/main/resources/black-cherry/run_black_cherry.py
@@ -30,6 +30,8 @@
chunk = urlresponse.read(CHUNK)
if not chunk: break
urlresult += chunk
+
+ # QUERY ISSUE 2: UNCOMMENT THIS TO SEE WEIRD BUG
urlresult = ','.join(urlresult.split(']}{"results":['))
# Create JSON dump of resulting response
@@ -71,4 +73,4 @@
return (build_response("update", dict(request.query)))
res = black_cherry_bootstrap.bootstrap()
-run(host='localhost', port=8080, debug=True)
\ No newline at end of file
+run(host='localhost', port=8080, debug=True)
diff --git a/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js b/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js
index ac7e26c..3e5aa8d 100755
--- a/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js
+++ b/asterix-examples/src/main/resources/black-cherry/static/js/asterix-sdk-stable.js
@@ -85,6 +85,9 @@
}
var m = typeof mode ? mode : "synchronous";
+
+ // DEBUG
+ //alert(statements.join("\n"));
var query = "use dataverse " + this._properties["dataverse"] + ";\n" + statements.join("\n");
@@ -173,6 +176,9 @@
statements = [ statements ];
}
+ // DEBUG
+ // alert(statements.join("\n"));
+
this._api(
{
"statements" : "use dataverse " + this._properties["dataverse"] + ";\n" + statements.join("\n")
@@ -293,6 +299,8 @@
} else {
+ // NOTE: This section is in progress; currently API requires jQuery.
+
// First, we encode the parameters of the query to create a new url.
api_endpoint = endpoint_url + "?" + Object.keys(json).map(function(k) {
return encodeURIComponent(k) + '=' + encodeURIComponent(json[k])
diff --git a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
index 898afb2..b63b676 100755
--- a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
+++ b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
@@ -62,7 +62,8 @@
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
- draggable : false
+ draggable : false,
+ mapTypeControl: false
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
@@ -109,9 +110,6 @@
rectangleManager.setDrawingMode(null);
});
- // Open about tab to start user on a tutorial
- //$('#mode-tabs a:first').tab('show') // Select first tab
-
// Initialize data structures
APIqueryTracker = {};
asyncQueryManager = {};
@@ -122,6 +120,12 @@
getAllDataverseTweetbooks();
initDemoUIButtonControls();
+
+ google.maps.event.addListenerOnce(map, 'idle', function(){
+ // Show tutorial tab only the first time the map is loaded
+ $('#mode-tabs a:first').tab('show');
+ });
+
});
function initDemoUIButtonControls() {
@@ -175,6 +179,8 @@
$('#location-button').on('change', function (e) {
$("#location-text-box").removeAttr("disabled");
rectangleManager.setMap(null);
+ selectionRectangle = null;
+ rectangleManager.setDrawingMode(google.maps.drawing.OverlayType.RECTANGLE);
});
$("#selection-button").trigger("click");
@@ -195,7 +201,6 @@
$("#report-message").html('');
$("#submit-button").attr("disabled", true);
rectangleManager.setDrawingMode(null);
- $("body").css("cursor", "progress");
var kwterm = $("#keyword-textbox").val();
var startdp = $("#start-date").datepicker("getDate");
@@ -232,9 +237,6 @@
var build_cherry_mode = "synchronous";
if ($('#asbox').is(":checked")) {
build_cherry_mode = "asynchronous";
- //$('#show-query-button').attr("disabled", false);
- } else {
- //$('#show-query-button').attr("disabled", true);
}
var f = buildAQLQueryFromForm(formData);
@@ -243,9 +245,6 @@
"query" : "use dataverse twitter;\n" + f.val(),
"data" : formData
};
-
- // TODO Make dialog work correctly.
- //$('#dialog').html(APIqueryTracker["query"]);
if (build_cherry_mode == "synchronous") {
A.query(f.val(), cherryQuerySyncCallback, build_cherry_mode);
@@ -419,7 +418,7 @@
// Add to stored map of existing handles
asyncQueryManager[handle_id] = {
"handle" : handle,
- "query" : handle_query,
+ "query" : handle_query, // This will show up when query control button is clicked.
"data" : APIqueryTracker["data"]
};
@@ -447,8 +446,6 @@
"query" : asyncQueryManager[handle_id]["query"],
"data" : asyncQueryManager[handle_id]["data"]
};
- // TODO
- //$('#dialog').html(APIqueryTracker["query"]);
if (!asyncQueryManager[handle_id].hasOwnProperty("result")) {
// Generate new Asterix Core API Query
@@ -487,7 +484,6 @@
$('#async_container_' + handle_id).append('<br/>');
- $("body").css("cursor", "default");
$("#submit-button").attr("disabled", false);
}
@@ -497,6 +493,13 @@
*/
function cherryQuerySyncCallback(res) {
+ // First, we check if any results came back in.
+ // If they didn't, return.
+ if (!res.hasOwnProperty("results")) {
+ reportUserMessage("Oops, no results found for those parameters.", false, "report-message");
+ return;
+ }
+
// Initialize coordinates and weights, to store
// coordinates of map cells and their weights
var coordinates = [];
@@ -599,8 +602,6 @@
$("#legend-max").html(maxWeight);
$("#rainbow-legend-container").show();
});
-
- $("body").css("cursor", "default");
}
/**
@@ -610,8 +611,6 @@
*/
function onMapPointDrillDown(marker_borders) {
- $("body").css("cursor", "progress");
-
var zoneData = APIqueryTracker["data"];
var zswBounds = new google.maps.LatLng(marker_borders.latSW, marker_borders.lngSW);
@@ -878,7 +877,7 @@
function onPlotTweetbook(tweetbook) {
// Clear map for this one
- mapWidgetResetMap();
+ mapWidgetClearMap();
var plotTweetQuery = new FLWOGRExpression()
.ForClause("$t", new AExpression("dataset TweetMessagesShifted"))
@@ -907,6 +906,13 @@
*/
function onTweetbookQuerySuccessPlot (res) {
+ // First, we check if any results came back in.
+ // If they didn't, return.
+ if (!res.hasOwnProperty("results")) {
+ reportUserMessage("Oops, no data matches this query.", false, "report-message");
+ return;
+ }
+
// Parse out tweet Ids, texts, and locations
var tweets = [];
var al = 1;
@@ -956,8 +962,6 @@
// Add marker to index of tweets
map_tweet_markers.push(map_tweet_m);
});
-
- $("body").css("cursor", "default");
}
/**
@@ -1023,6 +1027,7 @@
$('#review-well').show();
mapWidgetResetMap();
rectangleManager.setMap(null);
+ rectangleManager.setDrawingMode(null);
});
// Does some alignment necessary for the map canvas