Skip to content

Commit

Permalink
implemented busy indicator, UI handling of SPARQL endpoints and addin…
Browse files Browse the repository at this point in the history
…g of data sources
  • Loading branch information
mhausenblas committed Mar 14, 2011
1 parent 0f8077b commit 3492b79
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ui/forms/config.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="pane-title">Configure qrcan ...</div>
<div class="pane-title" id="pane-head">Configure qrcan ...</div>
<div id="config-main">
<fieldset>
<legend>Data source store</legend>
Expand Down
2 changes: 1 addition & 1 deletion ui/forms/ds-add.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</select>
<div class="fnote">Define the access to the data source: you can either specify the location of an RDF document (in RDF/XML, Turtle, RDFa, etc.) or you provide a SPARQL Endpoint URI (see also the <a href="http://labs.mondeca.com/sparqlEndpointsStatus/" target="_new">list of public SPARQL Endpoints</a> and their status).</div>
</fieldset>
<fieldset>
<fieldset id="ds-mode-field">
<legend>Access mode</legend>
<input type="radio" name="ds-mode" value="local" /> local <input type="radio" name="ds-mode" value="remote" checked="checked"/> remote
<div class="fnote">Specify the way the data source should be accessed: if you choose <strong>local</strong>, the data source will be downloaded to the local store. If you choose <strong>remote</strong>, the data source will be queried live.</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/forms/ds-status.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<span id="ds-last-update" class="status-field"></span>
<div class="fnote">Shows when the data source has been changed (via the <em>Admin</em> tab).</div>
</fieldset>
<fieldset>
<fieldset id="ds-last-sync-field">
<legend>Last synchronisation</legend>
<span id="ds-last-sync" class="status-field"></span>
<div class="fnote">Shows when the data source has been synchronised. This is only applicable for local data sources as remote data sources are accessed live.</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/forms/ds-work.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="pane-title">Data source ...</div>
<div class="pane-title" id="pane-head">Data source ...</div>
<div>
<div class="ws-ds">Selected data source: <span id="ws-selected-ds"></span></div>
<div id="ws-tabs">
Expand Down
Binary file added ui/img/busy.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 53 additions & 6 deletions ui/js/qrcan_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ $(function() {

$("#ds-update").live("click", function() {
updateDatasource();
// refresh list
if($("#ds-update").text() == "Add ..."){
$("#workspace").html("");
}
});

/* menu */
Expand Down Expand Up @@ -54,8 +56,10 @@ $(function() {
// sync
$("#ds-sync").live("click", function () {
var dsID = $("#ws-selected-ds a").attr("href");
busy();
$.get(dsID + '/sync', function(data) {
selectTab('ws-tab-status', dsID);
done();
});
});

Expand All @@ -64,8 +68,19 @@ $(function() {
var dsID = $("#ws-selected-ds a").attr("href");
queryDatasource(dsID);
});



// access method selection
$("#ds-access").live("change", function () {
var method = $("#ds-access").val();
if(method == 'sparql') {
$("#ds-mode-field").hide('slow');
}
else {
$("#ds-mode-field").show('slow');
}
});


// hoover effects
$(".datasource").live("mouseover", function() {
$(this).css("color", "#44A");
Expand Down Expand Up @@ -93,25 +108,37 @@ function listDatasources(){
}

function updateDatasource(){
var dsid = $("#ds-id").text()
var dsid = $("#ds-id").text();
var method = $("#ds-access").val();

if(method == 'sparql') {
mode = 'remote';
}
else {
mode = $("input:radio[name='ds-mode']:checked").val();
}

var dsdata = {
name : $("#ds-name").val(),
access_method : $("#ds-access").val(),
access_uri : $("#ds-access-uri").val(),
access_mode : $("input:radio[name='ds-mode']:checked").val()
access_mode : mode
};
var noun = "../api/datasource";

if(dsid != '') {
noun = dsid + "/";
}

busy();

$.ajax({
type: "POST",
url: noun,
data: "dsdata="+ $.toJSON(dsdata),
success: function(data){
listDatasources();
done();
},
error: function(msg){
alert(msg);
Expand All @@ -124,12 +151,14 @@ function queryDatasource(dsid){
query_str : $("#ds-query-str").val()
};

busy();
$.ajax({
type: "POST",
url: dsid + "/query",
data: "querydata="+ $.toJSON(querydata),
success: function(data){
$("#query-result").html(data);
done();
},
error: function(msg){
alert(msg);
Expand Down Expand Up @@ -158,6 +187,13 @@ function selectTab(tabID, dsID) {
$("#ds-access option[value='" + data.access_method + "']").attr("selected", true);
$("#ds-access-uri").val(data.access_uri);
$("input:radio[name='ds-mode'][value='" + data.access_mode +"']").attr('checked', true);
if(data.access_method == 'sparql') {
$("#ds-mode-field").hide('fast');
}
else {
$("#ds-mode-field").show('fast');
}

});
return;
}
Expand All @@ -170,10 +206,11 @@ function selectTab(tabID, dsID) {
$.getJSON(dsID, function(data) {
$("#ds-last-update").text(data.updated);
if(data.access_mode == 'local') {
$("#ds-last-sync-field").show();
$("#ds-last-sync").text(data.last_sync);
}
else {
$("#ds-last-sync").text('N/A');
$("#ds-last-sync-field").hide();
}
});
return;
Expand All @@ -184,3 +221,13 @@ function selectTab(tabID, dsID) {
});
}

function busy(){
var oldtext = $("#pane-head").text();
$("#pane-head").html("<img src='img/busy.gif' alt='busy' /><span style='display:none'>" + oldtext + "</span>");
}

function done(){
var oldtext = $("#pane-head span").text();
$("#pane-head").html(oldtext);
}

0 comments on commit 3492b79

Please sign in to comment.