|
From: <tob...@us...> - 2014-07-23 23:10:31
|
Revision: 8589
http://sourceforge.net/p/bigdata/code/8589
Author: tobycraig
Date: 2014-07-23 23:10:27 +0000 (Wed, 23 Jul 2014)
Log Message:
-----------
Made namespace/default namespace loading occur synchronously at startup, so there's no need to check later if it's complete
Modified Paths:
--------------
branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-23 16:08:47 UTC (rev 8588)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-07-23 23:10:27 UTC (rev 8589)
@@ -58,7 +58,7 @@
var QUERY_RESULTS, PAGE_SIZE = 50, TOTAL_PAGES, CURRENT_PAGE;
// namespaces
-var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACES_READY = false, DEFAULT_NAMESPACE_READY = false;
+var DEFAULT_NAMESPACE, NAMESPACE;
// namespace creation
var NAMESPACE_PARAMS = {
@@ -116,7 +116,7 @@
/* Load balancing */
function useLBS(state) {
- // allows passing in of boolean, or firing on event
+ // allows passing in of boolean, or firing on checkbox change
if(typeof(state) != 'boolean') {
state = this.checked;
}
@@ -208,69 +208,56 @@
/* Namespaces */
-function getNamespaces() {
- $.get(RO_URL_PREFIX + 'namespace?describe-each-named-graph=false', function(data) {
- $('#namespaces-list').empty();
- var rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
- var namespaces = namespaces = data.getElementsByTagNameNS(rdf, 'Description')
- for(var i=0; i<namespaces.length; i++) {
- var title = namespaces[i].getElementsByTagName('title')[0].textContent;
- var titleText = title == DEFAULT_NAMESPACE ? title + ' (default)' : title;
- var url = namespaces[i].getElementsByTagName('sparqlEndpoint')[0].getAttributeNS(rdf, 'resource');
- var use;
- if(title == NAMESPACE) {
- use = 'In use';
- } else {
- use = '<a href="#" class="use-namespace">Use</a>';
+function getNamespaces(synchronous) {
+ // synchronous mode is for startup only, and is false by default
+ var settings = {
+ async: !synchronous,
+ url: RO_URL_PREFIX + 'namespace?describe-each-named-graph=false',
+ success: function(data) {
+ $('#namespaces-list').empty();
+ var rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
+ var namespaces = namespaces = data.getElementsByTagNameNS(rdf, 'Description')
+ for(var i=0; i<namespaces.length; i++) {
+ var title = namespaces[i].getElementsByTagName('title')[0].textContent;
+ var titleText = title == DEFAULT_NAMESPACE ? title + ' (default)' : title;
+ var url = namespaces[i].getElementsByTagName('sparqlEndpoint')[0].getAttributeNS(rdf, 'resource');
+ var use;
+ if(title == NAMESPACE) {
+ use = 'In use';
+ } else {
+ use = '<a href="#" class="use-namespace">Use</a>';
+ }
+ $('#namespaces-list').append('<tr data-name="' + title + '">><td>' + titleText + '</td><td>' + use + '</td><td><a href="#" class="delete-namespace">Delete</a></td><td><a href="#" class="namespace-properties">Properties</a></td><td><a href="#" class="clone-namespace">Clone</a></td><td><a href="' + RO_URL_PREFIX + 'namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></td></tr>');
}
- $('#namespaces-list').append('<tr data-name="' + title + '">><td>' + titleText + '</td><td>' + use + '</td><td><a href="#" class="delete-namespace">Delete</a></td><td><a href="#" class="namespace-properties">Properties</a></td><td><a href="#" class="clone-namespace">Clone</a></td><td><a href="' + RO_URL_PREFIX + 'namespace/' + title + '/sparql" class="namespace-service-description">Service Description</a></td></tr>');
+ $('.use-namespace').click(function(e) {
+ e.preventDefault();
+ useNamespace($(this).parents('tr').data('name'));
+ });
+ $('.delete-namespace').click(function(e) {
+ e.preventDefault();
+ deleteNamespace($(this).parents('tr').data('name'));
+ });
+ $('.namespace-properties').click(function(e) {
+ e.preventDefault();
+ getNamespaceProperties($(this).parents('tr').data('name'));
+ });
+ $('.namespace-properties-java').click(function(e) {
+ e.preventDefault();
+ getNamespaceProperties($(this).parents('tr').data('name'), 'java');
+ });
+ $('.clone-namespace').click(function(e) {
+ e.preventDefault();
+ cloneNamespace($(this).parents('tr').data('name'));
+ $('#namespace-create-errors').html('');
+ });
+ $('.namespace-service-description').click(function(e) {
+ return confirm('This can be an expensive operation. Proceed anyway?');
+ });
}
- $('.use-namespace').click(function(e) {
- e.preventDefault();
- useNamespace($(this).parents('tr').data('name'));
- });
- $('.delete-namespace').click(function(e) {
- e.preventDefault();
- deleteNamespace($(this).parents('tr').data('name'));
- });
- $('.namespace-properties').click(function(e) {
- e.preventDefault();
- getNamespaceProperties($(this).parents('tr').data('name'));
- });
- $('.namespace-properties-java').click(function(e) {
- e.preventDefault();
- getNamespaceProperties($(this).parents('tr').data('name'), 'java');
- });
- $('.clone-namespace').click(function(e) {
- e.preventDefault();
- cloneNamespace($(this).parents('tr').data('name'));
- $('#namespace-create-errors').html('');
- });
- $('.namespace-service-description').click(function(e) {
- return confirm('This can be an expensive operation. Proceed anyway?');
- });
- NAMESPACES_READY = true;
- });
+ };
+ $.ajax(settings);
}
-// waits for namespaces to be loaded, then tries to use the supplied namespace
-function selectNamespace(name) {
- if(!NAMESPACES_READY) {
- setTimeout(function() { selectNamespace(name); }, 10);
- } else {
- useNamespace(name);
- }
-}
-
-// waits for default namespace to be loaded, then uses it
-function selectDefaultNamespace() {
- if(!DEFAULT_NAMESPACE_READY) {
- setTimeout(function() { selectDefaultNamespace(); }, 10);
- } else {
- selectNamespace(DEFAULT_NAMESPACE);
- }
-}
-
function useNamespace(name) {
if(!namespaceExists(name)) {
return;
@@ -437,12 +424,16 @@
}
function getDefaultNamespace() {
- $.get(RO_URL_PREFIX + 'namespace?describe-each-named-graph=false&describe-default-namespace=true', function(data) {
- // Chrome does not work with rdf\:Description, so look for Description too
- var defaultDataset = $(data).find('rdf\\:Description, Description');
- DEFAULT_NAMESPACE = defaultDataset.find('title')[0].textContent;
- DEFAULT_NAMESPACE_READY = true;
- });
+ var settings = {
+ async: false,
+ url: RO_URL_PREFIX + 'namespace?describe-each-named-graph=false&describe-default-namespace=true',
+ success: function(data) {
+ // Chrome does not work with rdf\:Description, so look for Description too
+ var defaultDataset = $(data).find('rdf\\:Description, Description');
+ DEFAULT_NAMESPACE = defaultDataset.find('title')[0].textContent;
+ }
+ };
+ $.ajax(settings);
}
@@ -1396,12 +1387,8 @@
}
function exploreNamespacedURI(namespace, uri, nopush) {
- if(!NAMESPACES_READY) {
- setTimeout(function() { exploreNamespacedURI(namespace, uri, nopush); }, 10);
- } else {
- selectNamespace(namespace);
- explore(uri, nopush);
- }
+ useNamespace(namespace);
+ explore(uri, nopush);
}
function explore(uri, nopush) {
@@ -1584,13 +1571,18 @@
}
function showHealthTab() {
- $.get('/status?health', function(data) {
- if(data.deployment == 'HA') {
- $('#tab-selector a[data-target=health]').show();
- } else {
- $('#tab-selector a[data-target=health]').remove();
+ var settings = {
+ async: false,
+ url: '/status?health',
+ success: function(data) {
+ if(data.deployment == 'HA') {
+ $('#tab-selector a[data-target=health]').show();
+ } else {
+ $('#tab-selector a[data-target=health]').remove();
+ }
}
- });
+ };
+ $.ajax(settings);
}
@@ -1665,11 +1657,11 @@
/* Local storage functions */
function loadLastNamespace() {
- if(localStorage['lastNamespace']) {
- selectNamespace(localStorage['lastNamespace']);
+ if(localStorage['lastNamespace'] && namespaceExists(localStorage['lastNamespace'])) {
+ useNamespace(localStorage['lastNamespace']);
} else {
// no previously selected namespace, or it doesn't exist - use the default
- selectDefaultNamespace();
+ useNamespace(DEFAULT_NAMESPACE);
}
}
@@ -1735,24 +1727,20 @@
}
function startup() {
- setupHandlers();
-
+ // load namespaces, default namespace, HA status
useLBS(true);
-
+ getNamespaces(true);
+ getDefaultNamespace();
showHealthTab();
- getNamespaces();
-
- getDefaultNamespace();
-
+ // complete setup
+ setupHandlers();
createNamespaceShortcuts();
-
createUpdateEditor();
-
createQueryEditor();
-
createExportOptions();
+ // restore last used namespace
loadLastNamespace();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|