even smoother oauth interaction on load
git-svn-id: http://google-refine.googlecode.com/svn/trunk@534 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
d14b840d04
commit
00e195dbd3
src/main/webapp
File diff suppressed because one or more lines are too long
@ -12,13 +12,59 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
|
|||||||
var footer = $(
|
var footer = $(
|
||||||
'<div class="dialog-footer">' +
|
'<div class="dialog-footer">' +
|
||||||
'<table width="100%"><tr>' +
|
'<table width="100%"><tr>' +
|
||||||
'<td class="left" style="text-align: left" width="40%" nowrap="true"></td>' +
|
'<td bind="left" style="text-align: left" width="40%" nowrap="true"></td>' +
|
||||||
'<td class="center" style="text-align: center" width="20%" nowrap="true"></td>' +
|
'<td bind="center" style="text-align: center" width="20%" nowrap="true"></td>' +
|
||||||
'<td class="right" style="text-align: right" width="40%" nowrap="true"></td>' +
|
'<td bind="right" style="text-align: right" width="40%" nowrap="true"></td>' +
|
||||||
'</tr></table>' +
|
'</tr></table>' +
|
||||||
'</div>'
|
'</div>'
|
||||||
).appendTo(frame);
|
).appendTo(frame);
|
||||||
|
|
||||||
|
this._elmts = DOM.bind(frame);
|
||||||
|
|
||||||
|
var left_footer = this._elmts.left;
|
||||||
|
var center_footer = this._elmts.center;
|
||||||
|
var right_footer = this._elmts.right;
|
||||||
|
|
||||||
|
var cancel_button = $('<button bind="cancel" id="freebase-loading-cancel"></button>').text("Cancel").click(function() {
|
||||||
|
self._dismiss();
|
||||||
|
}).appendTo(left_footer);
|
||||||
|
|
||||||
|
var authorization = $('<div bind="authorization">').addClass("freebase-loading-authorization").hide().appendTo(center_footer);
|
||||||
|
|
||||||
|
var selector = $('<span bind="selector">').addClass("freebase-loading-graph-selector").html("Load this data into " +
|
||||||
|
'<input type="radio" bind="sandbox" id="freebase-loading-graph-selector-sandbox" name="graph-selector" checked="checked" value="sandbox"/><label class="sandbox" for="freebase-loading-graph-selector-sandbox" title="Load into the sandbox">sandbox</label>' +
|
||||||
|
'<input type="radio" bind="freebase" id="freebase-loading-graph-selector-freebase" name="graph-selector" value="freebase"/><label class="freebase" for="freebase-loading-graph-selector-freebase" title="Load into Freebase">freebase</label>'
|
||||||
|
).buttonset().appendTo(right_footer);
|
||||||
|
|
||||||
|
var load_button = $('<button bind="load" id="freebase-loading-load"></button>').text("Load").appendTo(right_footer);
|
||||||
|
|
||||||
|
var provider = "www.freebase.com";
|
||||||
|
|
||||||
|
var check_authorization = function(autoload) {
|
||||||
|
$.get("/command/check-authorization/" + provider, function(data) {
|
||||||
|
if ("status" in data && data.status == "200 OK") {
|
||||||
|
authorization.html('Signed in as: <a target="_new" href="http://www.freebase.com/view/user/' + data.username + '">' + data.username + '</a> | <a href="javascript:{}" bind="signout">Sign Out</a>').show();
|
||||||
|
DOM.bind(authorization).signout.click(function() {
|
||||||
|
Sign.signout(check_authorization,provider);
|
||||||
|
});
|
||||||
|
if (autoload) {
|
||||||
|
self._load();
|
||||||
|
} else {
|
||||||
|
load_button.unbind().click(function() {
|
||||||
|
self._load();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
authorization.html("").hide();
|
||||||
|
load_button.unbind().click(function() {
|
||||||
|
Sign.signin(function() {
|
||||||
|
check_authorization(true);
|
||||||
|
},provider);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},"json");
|
||||||
|
};
|
||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
"/command/export-rows",
|
"/command/export-rows",
|
||||||
{
|
{
|
||||||
@ -26,96 +72,73 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
|
|||||||
format : "tripleloader"
|
format : "tripleloader"
|
||||||
},
|
},
|
||||||
function(data) {
|
function(data) {
|
||||||
body.html(
|
if (data == null || data == "") {
|
||||||
'<div class="freebase-loading-tripleloader-data">' + data + '</div>' +
|
body.html(
|
||||||
'<div class="freebase-loading-tripleloader-info">' +
|
'<div class="freebase-loading-tripleloader-message">'+
|
||||||
'<div>Describe the data you\'re about to load ¬</div>' +
|
'<h2>This dataset has no triples</h2>' +
|
||||||
'<textarea></textarea>' +
|
'<p>Have you aligned it with the Freebase schemas yet?</p>' +
|
||||||
'</div>'
|
'</div>'
|
||||||
);
|
);
|
||||||
|
left_footer.hide();
|
||||||
|
center_footer.hide();
|
||||||
|
selector.hide();
|
||||||
|
load_button.text("Close").unbind().click(function() {
|
||||||
|
self._dismiss();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
body.html(
|
||||||
|
'<div class="freebase-loading-tripleloader-data">' + data + '</div>' +
|
||||||
|
'<div class="freebase-loading-tripleloader-info">' +
|
||||||
|
'<div>Describe the data you\'re about to load ¬</div>' +
|
||||||
|
'<textarea bind="info"></textarea>' +
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
self._elmts = DOM.bind(frame);
|
||||||
|
check_authorization(false);
|
||||||
|
}
|
||||||
self._level = DialogSystem.showDialog(frame);
|
self._level = DialogSystem.showDialog(frame);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var left_footer = footer.find(".left");
|
|
||||||
|
|
||||||
var cancel_button = $('<button id="freebase-loading-cancel"></button>').text("Cancel").click(function() {
|
|
||||||
self._dismiss();
|
|
||||||
}).appendTo(left_footer);
|
|
||||||
|
|
||||||
var center_footer = footer.find(".center");
|
|
||||||
|
|
||||||
var authorization = $('<div>').addClass("freebase-loading-authorization").hide().appendTo(center_footer);
|
|
||||||
|
|
||||||
var right_footer = footer.find(".right");
|
|
||||||
|
|
||||||
var selector = $('<span>').addClass("freebase-loading-graph-selector").html("Load this data into " +
|
|
||||||
'<input type="radio" bind="sandbox" id="freebase-loading-graph-selector-sandbox" name="graph-selector" checked="checked" value="sandbox"/><label class="sandbox" for="freebase-loading-graph-selector-sandbox" title="Load into the sandbox">sandbox</label>' +
|
|
||||||
'<input type="radio" bind="freebase" id="freebase-loading-graph-selector-freebase" name="graph-selector" value="freebase"/><label class="freebase" for="freebase-loading-graph-selector-freebase" title="Load into Freebase">freebase</label>'
|
|
||||||
).buttonset().appendTo(right_footer);
|
|
||||||
|
|
||||||
var load_button = $('<button id="freebase-loading-load"></button>').text("Sign In").appendTo(right_footer);
|
|
||||||
|
|
||||||
this._elmts = DOM.bind(frame);
|
|
||||||
|
|
||||||
var provider = "www.freebase.com";
|
|
||||||
|
|
||||||
var check_authorization = function() {
|
|
||||||
$.get("/command/check-authorization/" + provider, function(data) {
|
|
||||||
if ("status" in data && data.status == "200 OK") {
|
|
||||||
authorization.html('Signed in as: <a target="_new" href="http://www.freebase.com/view/user/' + data.username + '">' + data.username + '</a> | <a href="javascript:{}" bind="signout">Sign Out</a>').show();
|
|
||||||
DOM.bind(authorization).signout.click(function() {
|
|
||||||
Sign.signout(check_authorization,provider);
|
|
||||||
});
|
|
||||||
load_button.text("Load").unbind().click(function() {
|
|
||||||
self._load(self);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
authorization.html("").hide();
|
|
||||||
load_button.text("Sign In").removeAttr("disabled").unbind().click(function() {
|
|
||||||
Sign.signin(check_authorization,provider);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},"json");
|
|
||||||
};
|
|
||||||
|
|
||||||
check_authorization();
|
|
||||||
|
|
||||||
this._elmts.sandbox.click(function() {
|
|
||||||
//check_authorization();
|
|
||||||
});
|
|
||||||
|
|
||||||
this._elmts.freebase.click(function() {
|
|
||||||
if (!confirm("Are you sure your data is clean enough to enter Freebase?")) {
|
|
||||||
self._elmts.sandbox.attr("checked","checked");
|
|
||||||
self._elmts.freebase.removeAttr("checked");
|
|
||||||
selector.find("input").button('refresh');
|
|
||||||
}
|
|
||||||
//check_authorization();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FreebaseLoadingDialog.prototype._load = function(self) {
|
FreebaseLoadingDialog.prototype._load = function() {
|
||||||
$.post("/command/upload-data",
|
var self = this;
|
||||||
{
|
var freebase = self._elmts.freebase.attr("checked");
|
||||||
project: theProject.id,
|
if (!freebase || (freebase && confirm("Are you sure this data is clean enough to enter Freebase?"))) {
|
||||||
"graph" : ($("#freebase-loading-graph-selector-freebase").attr("checked")) ? "otg" : "sandbox",
|
$.post("/command/upload-data",
|
||||||
"info" : $("#freebase-loading-tripleloader-info textarea").val()
|
{
|
||||||
},
|
project: theProject.id,
|
||||||
function(data) {
|
"graph" : (freebase) ? "otg" : "sandbox",
|
||||||
var body = $(".dialog-body");
|
"info" : self._elmts.info.val()
|
||||||
if ("status" in data && data.status == "200 OK") {
|
},
|
||||||
body.html('<div class="freebase-loading-tripleloader-message"><h2>Data successfully loaded!</h2>' + data.message + '</div>');
|
function(data) {
|
||||||
} else {
|
var body = $(".dialog-body");
|
||||||
body.html('<div class="freebase-loading-tripleloader-message"><h2>Error loading data!</h2><pre>' + JSON.stringify(data,null,2) + '</pre></div>');
|
if ("status" in data && data.status == "200 OK") {
|
||||||
}
|
body.html(
|
||||||
$("button#freebase-loading-load").text("Close").unbind().click(function() {
|
'<div class="freebase-loading-tripleloader-message">' +
|
||||||
self._dismiss();
|
'<h2>Data successfully loaded</h2>' +
|
||||||
});
|
'<p>' + data.message + '</p>' +
|
||||||
$("button#freebase-loading-cancel").hide();
|
'</div>'
|
||||||
},
|
);
|
||||||
"json"
|
} else {
|
||||||
);
|
body.html(
|
||||||
|
'<div class="freebase-loading-tripleloader-message">' +
|
||||||
|
'<h2>Error loading data</h2>' +
|
||||||
|
'<p>' + data.message + '</p>' +
|
||||||
|
'<pre>' + data.stack.replace(/\\n/g,'\n').replace(/\\t/g,'\t') + '</p>' +
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
self._elmts.load.text("Close").unbind().click(function() {
|
||||||
|
self._dismiss();
|
||||||
|
});
|
||||||
|
self._elmts.cancel.hide();
|
||||||
|
self._elmts.authorization.hide();
|
||||||
|
self._elmts.selector.hide();
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FreebaseLoadingDialog.prototype._dismiss = function() {
|
FreebaseLoadingDialog.prototype._dismiss = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user