' + data + '');
+ console.log(data);
+ body.html(
+ '
' + data + '
' +
+ '
' +
+ '
Describe the data you\'re about to load ¬
' +
+ '
' +
+ '
'
+ );
self._level = DialogSystem.showDialog(frame);
}
);
- var left_footer = footer.find(".left");
- $('
').text("Cancel").click(function() {
+ var left_footer = footer.find(".left");
+
+ var cancel_button = $('
').text("Cancel").click(function() {
self._dismiss();
}).appendTo(left_footer);
+ var center_footer = footer.find(".center");
+
+ var authorization = $('
').addClass("freebase-loading-authorization").hide().appendTo(center_footer);
+
var right_footer = footer.find(".right");
- //$('
Signed in as:
').appendTo(right_footer);
-
- var selector = $('
').addClass("freebase-loading-graph-selector").html("Load into " +
+ var selector = $('').addClass("freebase-loading-graph-selector").html("Load this data into " +
'' +
- ''
+ ''
).buttonset().appendTo(right_footer);
-
- $('').text("Load").click(function() {
- self._check_authorization(self._load);
- }).appendTo(right_footer);
+
+ var load_button = $('').text("Sign In").appendTo(right_footer);
this._elmts = DOM.bind(frame);
+
+ var provider = "www.freebase.com";
- this._elmts.otg.click(function() {
- if (!confirm("are you sure?")) {
- self._elmts.sandbox.attr("checked","checked");
- self._elmts.otg.removeAttr("checked");
- selector.find("input").button('refresh');
- }
+ var check_authorization = function() {
+ $.get("/command/check-authorization/" + provider, function(data) {
+ if ("status" in data && data.status == "200 OK") {
+ authorization.html('Signed in as: ' + data.username + ' | Sign Out').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();
});
-};
-
-FreebaseLoadingDialog.prototype._check_authorization = function(cont) {
- var freebase = this._elmts.otg.attr("checked");
- var provider = (freebase) ? "freebase" : "sandbox";
- $.get("/command/check-authorization",{ "provider" : provider }, function(data) {
- if ("status" in data && data.status == "200 OK") {
- if (typeof cont == "function") cont();
- } else {
- alert("Sorry, we're working very hard to make this happen.");
- //Sign.signin(cont,provider);
+ 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');
}
- },"json");
+ //check_authorization();
+ });
};
-FreebaseLoadingDialog.prototype._load = function() {
- // do the real loading here
+FreebaseLoadingDialog.prototype._load = function(self) {
+ $.post("/command/upload-data",
+ {
+ project: theProject.id,
+ "graph" : ($("#freebase-loading-graph-selector-freebase").attr("checked")) ? "otg" : "sandbox",
+ "info" : $("#freebase-loading-tripleloader-info textarea").val()
+ },
+ function(data) {
+ var body = $(".dialog-body");
+ if ("status" in data && data.status == "200 OK") {
+ body.html('Data successfully loaded!
' + data.message + '');
+ } else {
+ body.html('Error loading data!
' + JSON.stringify(data,null,2) + '
');
+ }
+ $("button#freebase-loading-load").text("Close").unbind().click(function() {
+ self._dismiss();
+ });
+ $("button#freebase-loading-cancel").hide();
+ },
+ "json"
+ );
}
FreebaseLoadingDialog.prototype._dismiss = function() {
diff --git a/src/main/webapp/scripts/util/sign.js b/src/main/webapp/scripts/util/sign.js
index fd2ef350d..4522488e7 100644
--- a/src/main/webapp/scripts/util/sign.js
+++ b/src/main/webapp/scripts/util/sign.js
@@ -56,27 +56,7 @@
return window.open(url, windowname || "", params_list.join(","));
},
-
- block : function() {
- if ($.blockUI) {
- $.blockUI({ css: {
- border: 'none',
- padding: '15px',
- backgroundColor: '#000',
- '-webkit-border-radius': '10px',
- '-moz-border-radius': '10px',
- opacity: .5,
- color: '#fff'
- } });
- }
- },
-
- unblock : function() {
- if ($.unblockUI) {
- $.unblockUI();
- }
- },
-
+
signintize : function(cont) {
$('.signedin').show();
$('.signedout').hide();
@@ -87,33 +67,31 @@
},
signin : function(success, provider, width, height) {
- var newwin = window.Sign.popup("/command/authorize?" + $.param({ "provider" : provider}), width, height);
+ var newwin = window.Sign.popup("/command/authorize/" + provider, width, height);
- console.log(newwin);
-
- newwin.opener = window;
+ if (newwin !== null) {
+ newwin.opener = window;
+ }
window.onauthorization = function() {
- window.Sign.block();
if (typeof success == 'undefined') {
window.location.reload();
} else {
$.ajax({
- url: "/command/check-authorization",
+ url: "/command/check-authorization/" + provider,
dataType: "json",
success: function(data) {
window.user = data;
window.Sign.signintize(success);
- window.Sign.unblock();
}
});
}
};
- if (window.focus) {
+ if (window.focus && newwin !== null) {
newwin.focus();
- console.log("focus");
}
+
return false;
},
@@ -124,17 +102,13 @@
},
signout : function(success,provider) {
- window.Sign.block();
-
$.ajax({
- url: "/command/deauthorize",
- data: { "provider" : provider },
+ url: "/command/deauthorize/" + provider,
success: function() {
if (typeof success == 'undefined') {
window.location.reload();
} else {
window.Sign.signoutize(success);
- window.Sign.unblock();
}
}
});
diff --git a/src/main/webapp/styles/dialogs/freebase-loading-dialog.css b/src/main/webapp/styles/dialogs/freebase-loading-dialog.css
index 8c9eac7f8..8b76b2f18 100644
--- a/src/main/webapp/styles/dialogs/freebase-loading-dialog.css
+++ b/src/main/webapp/styles/dialogs/freebase-loading-dialog.css
@@ -1,8 +1,34 @@
.freebase-loading-tripleloader-data {
- height: 500px;
+ height: 400px;
+ width: 99%;
overflow: auto;
border: 1px solid #aaa;
white-space: pre;
padding: 0.3em 0.5em 0.5em 0.5em;
font-family: monospace;
}
+
+.freebase-loading-tripleloader-message {
+ height: 500px;
+ overflow: auto;
+ border: 1px solid #aaa;
+ padding: 0.3em 0.5em 0.5em 0.5em;
+}
+
+.freebase-loading-authorization {
+ margin: 0em 2em;
+ padding: 0.6em 0.8em;
+ border: 1px solid #ccc;
+ background-color: #fff;
+ -moz-border-radius: 0.8em;
+ -webkit-border-radius: 0.8em;
+}
+
+.freebase-loading-tripleloader-info {
+ margin-top: 1em;
+}
+
+.freebase-loading-tripleloader-info textarea {
+ width: 99%;
+ height: 5em;
+}
\ No newline at end of file
diff --git a/src/server/java/com/metaweb/gridworks/Gridworks.java b/src/server/java/com/metaweb/gridworks/Gridworks.java
index 2b1cd7859..f981a3250 100644
--- a/src/server/java/com/metaweb/gridworks/Gridworks.java
+++ b/src/server/java/com/metaweb/gridworks/Gridworks.java
@@ -20,18 +20,15 @@ import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
-import org.apache.log4j.Appender;
-import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;
-import org.mortbay.log.Log;
import org.mortbay.util.Scanner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import com.metaweb.util.logging.IndentingLayout;
import com.metaweb.util.signal.AbstractSignalHandler;
import com.metaweb.util.threads.ThreadPoolExecutorAdapter;
@@ -45,29 +42,8 @@ public class Gridworks {
static private File tempDir;
static private int port;
static private String host;
-
- private static Logger root = Logger.getRootLogger();
- private static Logger logger = Logger.getLogger("com.metaweb.gridworks");
- public static void log(String message) {
- logger.info(message);
- }
-
- public static void info(String message) {
- logger.info(message);
- }
-
- public static void error(String message, Throwable t) {
- logger.error(message, t);
- }
-
- public static void warn(String message) {
- logger.warn(message);
- }
-
- public static void warn(String message, Throwable t) {
- logger.warn(message, t);
- }
+ final static Logger logger = LoggerFactory.getLogger("gridworks");
public static String getVersion() {
return VERSION;
@@ -100,20 +76,15 @@ public class Gridworks {
System.setProperty("com.apple.eawt.CocoaComponent.CompatibilityMode", "false");
// tell the signpost library to log
- System.setProperty("debug","true");
+ //System.setProperty("debug","true");
// if not already set, make sure jython can find its python stuff
if (System.getProperty("python.path") == null) {
System.setProperty("python.path","lib/python");
}
- // initialize the log4j system
- Appender console = new ConsoleAppender(new IndentingLayout());
- root.setLevel(Level.ALL);
- root.addAppender(console);
-
- Logger jetty_logger = Logger.getLogger("org.mortbay.log");
- jetty_logger.setLevel(Level.WARN);
+ // set the log verbosity level
+ org.apache.log4j.Logger.getRootLogger().setLevel(Level.toLevel(Configurations.get("gridworks.verbosity","info")));
tempDir = new File(Configurations.get("gridworks.temp","temp"));
if (!tempDir.exists()) tempDir.mkdirs();
@@ -137,7 +108,7 @@ public class Gridworks {
GridworksClient client = new GridworksClient();
client.init(host,port);
} catch (Exception e) {
- Log.warn("Sorry, some error prevented us from launching the browser for you.\n\n Point your browser to http://" + host + ":" + port + "/ to start using Gridworks.");
+ logger.warn("Sorry, some error prevented us from launching the browser for you.\n\n Point your browser to http://" + host + ":" + port + "/ to start using Gridworks.");
}
}
@@ -152,6 +123,8 @@ public class Gridworks {
class GridworksServer extends Server {
+ final static Logger logger = LoggerFactory.getLogger("gridworks_server");
+
private ThreadPoolExecutor threadPool;
public void init(String host, int port) throws Exception {
@@ -177,11 +150,11 @@ class GridworksServer extends Server {
File webXml = new File(contextRoot, "WEB-INF/web.xml");
if (!webXml.isFile()) {
- Gridworks.warn("Warning: Failed to find web application. Could not find 'web.xml' at '" + webXml.getAbsolutePath() + "'");
+ logger.warn("Warning: Failed to find web application. Could not find 'web.xml' at '" + webXml.getAbsolutePath() + "'");
System.exit(-1);
}
- Gridworks.info("Initializing context: '" + contextPath + "' from '" + contextRoot.getAbsolutePath() + "'");
+ logger.info("Initializing context: '" + contextPath + "' from '" + contextRoot.getAbsolutePath() + "'");
WebAppContext context = new WebAppContext(contextRoot.getAbsolutePath(), contextPath);
//context.setCopyWebDir(false);
//context.setDefaultsDescriptor(null);
@@ -217,7 +190,7 @@ class GridworksServer extends Server {
scanList.add(new File(contextRoot, "WEB-INF/web.xml"));
findFiles(".class", new File(contextRoot, "WEB-INF/classes"), scanList);
- Gridworks.info("Starting autoreloading scanner... ");
+ logger.info("Starting autoreloading scanner... ");
Scanner scanner = new Scanner();
scanner.setScanInterval(Configurations.getInteger("gridworks.scanner.period",1));
@@ -228,10 +201,10 @@ class GridworksServer extends Server {
@SuppressWarnings("unchecked")
public void filesChanged(List changedFiles) {
try {
- Gridworks.info("Stopping context: " + contextRoot.getAbsolutePath());
+ logger.info("Stopping context: " + contextRoot.getAbsolutePath());
context.stop();
- Gridworks.info("Starting context: " + contextRoot.getAbsolutePath());
+ logger.info("Starting context: " + contextRoot.getAbsolutePath());
context.start();
} catch (Exception ex) {
throw new RuntimeException(ex);