Made range facet more robust against bad expressions.

Centralized code that updates components of the UI. Show "Working..." indicator if anything takes more than 500ms.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@142 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-02-26 21:56:41 +00:00
parent 1e4b9f4e80
commit 30dce3b3d5
16 changed files with 403 additions and 262 deletions

View File

@ -42,6 +42,9 @@ public class RangeFacet implements Facet {
writer.key("name"); writer.value(_name); writer.key("name"); writer.value(_name);
writer.key("expression"); writer.value(_expression); writer.key("expression"); writer.value(_expression);
writer.key("columnName"); writer.value(_columnName); writer.key("columnName"); writer.value(_columnName);
writer.key("mode"); writer.value(_mode);
if (!Double.isInfinite(_min) && !Double.isInfinite(_max)) {
writer.key("min"); writer.value(_min); writer.key("min"); writer.value(_min);
writer.key("max"); writer.value(_max); writer.key("max"); writer.value(_max);
writer.key("step"); writer.value(_step); writer.key("step"); writer.value(_step);
@ -58,7 +61,6 @@ public class RangeFacet implements Facet {
} }
writer.endArray(); writer.endArray();
writer.key("mode"); writer.value(_mode);
if ("min".equals(_mode)) { if ("min".equals(_mode)) {
writer.key("from"); writer.value(_from); writer.key("from"); writer.value(_from);
} else if ("max".equals(_mode)) { } else if ("max".equals(_mode)) {
@ -67,6 +69,8 @@ public class RangeFacet implements Facet {
writer.key("from"); writer.value(_from); writer.key("from"); writer.value(_from);
writer.key("to"); writer.value(_to); writer.key("to"); writer.value(_to);
} }
}
writer.endObject(); writer.endObject();
} }

View File

@ -35,7 +35,11 @@ public class ApplyOperationsCommand extends Command {
reconstructOperation(project, obj); reconstructOperation(project, obj);
} }
if (project.processManager.hasPending()) {
respond(response, "{ \"code\" : \"pending\" }"); respond(response, "{ \"code\" : \"pending\" }");
} else {
respond(response, "{ \"code\" : \"ok\" }");
}
} catch (JSONException e) { } catch (JSONException e) {
respondException(response, e); respondException(response, e);
} }

View File

@ -47,6 +47,10 @@ public class ProcessManager implements Jsonizable {
} }
} }
public boolean hasPending() {
return _processes.size() > 0;
}
public void onDoneProcess(Process p) { public void onDoneProcess(Process p) {
_processes.remove(p); _processes.remove(p);
update(); update();

View File

@ -1,6 +1,16 @@
var theProject; var theProject;
var ui = {}; var ui = {};
var Gridworks = {
};
Gridworks.reportException = function(e) {
if (window.console) {
console.log(e);
}
};
function onLoad() { function onLoad() {
var params = URL.getParameters(); var params = URL.getParameters();
if ("project" in params) { if ("project" in params) {
@ -8,7 +18,7 @@ function onLoad() {
id: parseInt(params.project) id: parseInt(params.project)
}; };
reinitializeProjectData(initializeUI); Gridworks.reinitializeProjectData(initializeUI);
} }
} }
$(onLoad); $(onLoad);
@ -44,7 +54,7 @@ function initializeUI() {
ui.menuBar = new MenuBar(ui.menuBarPanel); ui.menuBar = new MenuBar(ui.menuBarPanel);
} }
function reinitializeProjectData(f) { Gridworks.reinitializeProjectData = function(f) {
Ajax.chainGetJSON( Ajax.chainGetJSON(
"/command/get-project-metadata?" + $.param({ project: theProject.id }), null, "/command/get-project-metadata?" + $.param({ project: theProject.id }), null,
function(data) { function(data) {
@ -63,13 +73,150 @@ function reinitializeProjectData(f) {
); );
} }
function cellIndexToColumn(index) { /*
* Utility state functions
*/
Gridworks.createUpdateFunction = function(options, onFinallyDone) {
var functions = [];
var pushFunction = function(f) {
var index = functions.length;
functions.push(function() {
f(functions[index + 1]);
});
};
pushFunction(function(onDone) {
ui.historyWidget.update(onDone);
});
if (options["everythingChanged"] || options["modelsChanged"]) {
pushFunction(Gridworks.reinitializeProjectData);
}
if (options["everythingChanged"] || options["modelsChanged"] || options["rowsChanged"] || options["cellsChanged"] || options["engineChanged"]) {
pushFunction(function(onDone) {
ui.dataTableView.update(onDone);
});
pushFunction(function(onDone) {
ui.browsingEngine.update(onDone);
});
}
functions.push(onFinallyDone || function() {});
return functions[0];
};
Gridworks.update = function(options, onFinallyDone) {
var done = false;
var dismissBusy = null;
Gridworks.createUpdateFunction(options, function() {
done = true;
if (dismissBusy) {
dismissBusy();
}
if (onFinallyDone) {
onFinallyDone();
}
})();
window.setTimeout(function() {
if (!done) {
dismissBusy = DialogSystem.showBusy();
}
}, 500);
};
Gridworks.postProcess = function(command, params, body, updateOptions, callbacks) {
params = params || {};
params.project = theProject.id;
body = body || {};
body.engine = JSON.stringify(ui.browsingEngine.getJSON());
updateOptions = updateOptions || {};
callbacks = callbacks || {};
var done = false;
var dismissBusy = null;
function onDone(o) {
done = true;
if (dismissBusy) {
dismissBusy();
}
if (o.code == "error") {
if ("onError" in callbacks) {
try {
callbacks["onError"](o);
} catch (e) {
Gridworks.reportException(e);
}
}
} else {
if ("onDone" in callbacks) {
try {
callbacks["onDone"](o);
} catch (e) {
Gridworks.reportException(e);
}
}
if (o.code == "ok") {
Gridworks.update(updateOptions, callbacks["onFinallyDone"]);
} else if (o.code == "pending") {
if ("onPending" in callbacks) {
try {
callbacks["onPending"](o);
} catch (e) {
Gridworks.reportException(e);
}
}
ui.processWidget.update(updateOptions, callbacks["onFinallyDone"]);
}
}
}
$.post(
"/command/" + command + "?" + $.param(params),
body,
onDone,
"json"
);
window.setTimeout(function() {
if (!done) {
dismissBusy = DialogSystem.showBusy();
}
}, 500);
};
/*
* Utility model functions
*/
Gridworks.cellIndexToColumn = function(cellIndex) {
var columns = theProject.columnModel.columns; var columns = theProject.columnModel.columns;
for (var i = 0; i < columns.length; i++) { for (var i = 0; i < columns.length; i++) {
var column = columns[i]; var column = columns[i];
if (column.cellIndex == index) { if (column.cellIndex == cellIndex) {
return column; return column;
} }
} }
return null; return null;
} };
Gridworks.fetchRows = function(start, limit, onDone) {
$.post(
"/command/get-rows?" + $.param({ project: theProject.id, start: start, limit: limit }),
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) },
function(data) {
theProject.rowModel = data;
if (onDone) {
onDone();
}
},
"json"
);
};

View File

@ -50,12 +50,11 @@ BrowsingEngine.prototype.removeFacet = function(facet) {
} }
if (update) { if (update) {
this.update(); Gridworks.update({ engineChanged: true }, onFinallyDone);
ui.dataTableView.update(true);
} }
}; };
BrowsingEngine.prototype.update = function() { BrowsingEngine.prototype.update = function(onDone) {
var self = this; var self = this;
$.post( $.post(
@ -67,6 +66,10 @@ BrowsingEngine.prototype.update = function() {
for (var i = 0; i < facetData.length; i++) { for (var i = 0; i < facetData.length; i++) {
self._facets[i].facet.updateState(facetData[i]); self._facets[i].facet.updateState(facetData[i]);
} }
if (onDone) {
onDone();
}
}, },
"json" "json"
); );

View File

@ -159,16 +159,16 @@ DataTableCellUI.prototype._doJudgment = function(judgment, params) {
params.row = this._rowIndex; params.row = this._rowIndex;
params.cell = this._cellIndex; params.cell = this._cellIndex;
params.judgment = judgment; params.judgment = judgment;
this.doPostThenUpdate("recon-judge-one-cell", params); this._postProcessOneCell("recon-judge-one-cell", params);
}; };
DataTableCellUI.prototype._doJudgmentForSimilarCells = function(judgment, params) { DataTableCellUI.prototype._doJudgmentForSimilarCells = function(judgment, params) {
params = params || {}; params = params || {};
params.columnName = cellIndexToColumn(this._cellIndex).headerLabel; params.columnName = Gridworks.cellIndexToColumn(this._cellIndex).headerLabel;
params.similarValue = this._cell.v; params.similarValue = this._cell.v;
params.judgment = judgment; params.judgment = judgment;
ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params); this._postProcessSeveralCells("recon-judge-similar-cells", params);
}; };
DataTableCellUI.prototype._searchForMatch = function() { DataTableCellUI.prototype._searchForMatch = function() {
@ -203,14 +203,14 @@ DataTableCellUI.prototype._searchForMatch = function() {
}; };
if (checkSimilar[0].checked) { if (checkSimilar[0].checked) {
params.similarValue = self._cell.v; params.similarValue = self._cell.v;
params.columnName = cellIndexToColumn(self._cellIndex).headerLabel; params.columnName = Gridworks.cellIndexToColumn(self._cellIndex).headerLabel;
ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params); self._postProcessSeveralCells("recon-judge-similar-cells", params);
} else { } else {
params.row = self._rowIndex; params.row = self._rowIndex;
params.cell = self._cellIndex; params.cell = self._cellIndex;
self.doPostThenUpdate("recon-judge-one-cell", params); self._postProcessOneCell("recon-judge-one-cell", params);
} }
DialogSystem.dismissUntil(level - 1); DialogSystem.dismissUntil(level - 1);
@ -225,36 +225,29 @@ DataTableCellUI.prototype._searchForMatch = function() {
input.focus().data("suggest").textchange(); input.focus().data("suggest").textchange();
}; };
DataTableCellUI.prototype.createUpdateFunction = function(onBefore) { DataTableCellUI.prototype._postProcessOneCell = function(command, params) {
var self = this; var self = this;
return function(data) {
if (data.code == "ok") { Gridworks.postProcess(
var onDone = function() { command,
params,
null,
{},
{
onDone: function(o) {
self._cell = data.cell; self._cell = data.cell;
self._render(); self._render();
ui.historyWidget.update();
};
} else {
var onDone = function() {
ui.processWidget.update();
} }
} }
);
if (onBefore) {
onBefore(onDone);
} else {
onDone();
}
};
}; };
DataTableCellUI.prototype.doPostThenUpdate = function(command, params) { DataTableCellUI.prototype._postProcessSeveralCells = function(command, params) {
params.project = theProject.id; Gridworks.postProcess(
$.post( command,
"/command/" + command + "?" + $.param(params), params,
null, null,
this.createUpdateFunction(), { cellsChanged: true }
"json"
); );
}; };

View File

@ -375,9 +375,11 @@ DataTableColumnHeaderUI.prototype._doFilterByExpressionPrompt = function(express
}; };
DataTableColumnHeaderUI.prototype._doTextTransform = function(expression) { DataTableColumnHeaderUI.prototype._doTextTransform = function(expression) {
this._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"do-text-transform", "do-text-transform",
{ columnName: this._column.headerLabel, expression: expression } { columnName: this._column.headerLabel, expression: expression },
null,
{ cellsChanged: true }
); );
}; };
@ -446,23 +448,29 @@ DataTableColumnHeaderUI.prototype._doReconcile = function() {
}; };
DataTableColumnHeaderUI.prototype._doReconDiscardJudgments = function() { DataTableColumnHeaderUI.prototype._doReconDiscardJudgments = function() {
this._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"recon-discard-judgments", "recon-discard-judgments",
{ columnName: this._column.headerLabel } { columnName: this._column.headerLabel },
null,
{ cellsChanged: true }
); );
}; };
DataTableColumnHeaderUI.prototype._doReconMatchBestCandidates = function() { DataTableColumnHeaderUI.prototype._doReconMatchBestCandidates = function() {
this._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"recon-match-best-candidates", "recon-match-best-candidates",
{ columnName: this._column.headerLabel } { columnName: this._column.headerLabel },
null,
{ cellsChanged: true }
); );
}; };
DataTableColumnHeaderUI.prototype._doReconMarkNewTopics = function(shareNewTopics) { DataTableColumnHeaderUI.prototype._doReconMarkNewTopics = function(shareNewTopics) {
this._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"recon-mark-new-topics", "recon-mark-new-topics",
{ columnName: this._column.headerLabel, shareNewTopics: shareNewTopics } { columnName: this._column.headerLabel, shareNewTopics: shareNewTopics },
null,
{ cellsChanged: true }
); );
}; };
@ -480,7 +488,7 @@ DataTableColumnHeaderUI.prototype._doSearchToMatch = function() {
var input = $('<input />').appendTo($('<p></p>').appendTo(body)); var input = $('<input />').appendTo($('<p></p>').appendTo(body));
input.suggest({}).bind("fb-select", function(e, data) { input.suggest({}).bind("fb-select", function(e, data) {
self._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"recon-match-specific-topic-to-cells", "recon-match-specific-topic-to-cells",
{ {
columnName: self._column.headerLabel, columnName: self._column.headerLabel,
@ -488,8 +496,11 @@ DataTableColumnHeaderUI.prototype._doSearchToMatch = function() {
topicGUID: data.guid, topicGUID: data.guid,
topicName: data.name, topicName: data.name,
types: $.map(data.type, function(elmt) { return elmt.id; }).join(",") types: $.map(data.type, function(elmt) { return elmt.id; }).join(",")
} },
null,
{ cellsChanged: true }
); );
DialogSystem.dismissUntil(level - 1); DialogSystem.dismissUntil(level - 1);
}); });
@ -510,7 +521,7 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
function(expression) { function(expression) {
var headerLabel = window.prompt("Enter header label for new column:"); var headerLabel = window.prompt("Enter header label for new column:");
if (headerLabel != null) { if (headerLabel != null) {
self._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"add-column", "add-column",
{ {
baseColumnName: self._column.headerLabel, baseColumnName: self._column.headerLabel,
@ -518,7 +529,8 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
headerLabel: headerLabel, headerLabel: headerLabel,
columnInsertIndex: self._columnIndex + 1 columnInsertIndex: self._columnIndex + 1
}, },
true null,
{ modelsChanged: true }
); );
} }
} }
@ -526,23 +538,28 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
}; };
DataTableColumnHeaderUI.prototype._doRemoveColumn = function() { DataTableColumnHeaderUI.prototype._doRemoveColumn = function() {
this._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"remove-column", "remove-column",
{ columnName: this._column.headerLabel }, {
true columnName: this._column.headerLabel
},
null,
{ modelsChanged: true }
); );
}; };
DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() { DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() {
var separator = window.prompt("Enter separator to use between values", ", "); var separator = window.prompt("Enter separator to use between values", ", ");
if (separator != null) { if (separator != null) {
this._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"join-multi-value-cells", "join-multi-value-cells",
{ {
columnName: this._column.headerLabel, columnName: this._column.headerLabel,
keyColumnName: theProject.columnModel.keyColumnName, keyColumnName: theProject.columnModel.keyColumnName,
separator: separator separator: separator
} },
null,
{ rowsChanged: true }
); );
} }
}; };
@ -550,14 +567,16 @@ DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() {
DataTableColumnHeaderUI.prototype._doSplitMultiValueCells = function() { DataTableColumnHeaderUI.prototype._doSplitMultiValueCells = function() {
var separator = window.prompt("What separator currently separates the values?", ","); var separator = window.prompt("What separator currently separates the values?", ",");
if (separator != null) { if (separator != null) {
this._dataTableView.doPostThenUpdate( Gridworks.postProcess(
"split-multi-value-cells", "split-multi-value-cells",
{ {
columnName: this._column.headerLabel, columnName: this._column.headerLabel,
keyColumnName: theProject.columnModel.keyColumnName, keyColumnName: theProject.columnModel.keyColumnName,
separator: separator, separator: separator,
mode: "plain" mode: "plain"
} },
null,
{ rowsChanged: true }
); );
} }
}; };

View File

@ -5,15 +5,8 @@ function DataTableView(div) {
this._showRows(0); this._showRows(0);
} }
DataTableView.prototype.update = function(reset) { DataTableView.prototype.update = function(onDone) {
if (reset) { this._showRows(0, onDone);
var self = this;
reinitializeProjectData(function() {
self._showRows(0);
});
} else {
this._showRows(theProject.rowModel.start);
}
}; };
DataTableView.prototype.render = function() { DataTableView.prototype.render = function() {
@ -72,7 +65,7 @@ DataTableView.prototype.render = function() {
} else { } else {
a.text(pageSize).addClass("action").click(function(evt) { a.text(pageSize).addClass("action").click(function(evt) {
self._pageSize = pageSize; self._pageSize = pageSize;
self.update(true); self.update();
}); });
} }
}; };
@ -205,6 +198,8 @@ DataTableView.prototype.render = function() {
var rows = theProject.rowModel.rows; var rows = theProject.rowModel.rows;
var renderRow = function(tr, r, row, even) { var renderRow = function(tr, r, row, even) {
$(tr).empty();
var cells = row.cells; var cells = row.cells;
var tdStar = tr.insertCell(tr.cells.length); var tdStar = tr.insertCell(tr.cells.length);
@ -213,25 +208,19 @@ DataTableView.prototype.render = function() {
.appendTo(tdStar) .appendTo(tdStar)
.click(function() { .click(function() {
var newStarred = !row.starred; var newStarred = !row.starred;
$.post(
"/command/annotate-one-row?" + $.param({ project: theProject.id, row: row.i, starred: newStarred }), Gridworks.postProcess(
"annotate-one-row",
{ row: row.i, starred: newStarred },
null, null,
function(o) { {},
if (o.code == "ok") { { onDone: function(o) {
row.starred = newStarred; row.starred = newStarred;
$(tr).empty();
renderRow(tr, r, row, even); renderRow(tr, r, row, even);
ui.historyWidget.update();
} else {
ui.processWidget.update();
} }
}, },
"json" "json"
); );
}); });
var tdIndex = tr.insertCell(tr.cells.length); var tdIndex = tr.insertCell(tr.cells.length);
@ -273,20 +262,13 @@ DataTableView.prototype.render = function() {
DataTableView.prototype._showRows = function(start, onDone) { DataTableView.prototype._showRows = function(start, onDone) {
var self = this; var self = this;
Gridworks.fetchRows(start, this._pageSize, function() {
$.post(
"/command/get-rows?" + $.param({ project: theProject.id, start: start, limit: this._pageSize }),
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) },
function(data) {
theProject.rowModel = data;
self.render(); self.render();
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}, });
"json"
);
}; };
DataTableView.prototype._onClickPreviousPage = function(elmt, evt) { DataTableView.prototype._onClickPreviousPage = function(elmt, evt) {
@ -330,50 +312,18 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) {
{ {
label: "Star Rows", label: "Star Rows",
click: function() { click: function() {
self.doPostThenUpdate("annotate-rows", { "starred" : "true" }, false); Gridworks.postProcess("annotate-rows", { "starred" : "true" }, null, { rowMetadataChanged: true });
} }
}, },
{ {
label: "Unstar Rows", label: "Unstar Rows",
click: function() { click: function() {
self.doPostThenUpdate("annotate-rows", { "starred" : "false" }, false); Gridworks.postProcess("annotate-rows", { "starred" : "false" }, null, { rowMetadataChanged: true });
} }
} }
], elmt); ], elmt);
}; };
DataTableView.prototype.createUpdateFunction = function(onBefore) {
var self = this;
return function(data) {
if (data.code == "ok") {
var onDone = function() {
self.update();
ui.historyWidget.update();
};
} else {
var onDone = function() {
ui.processWidget.update();
}
}
if (onBefore) {
onBefore(onDone);
} else {
onDone();
}
};
};
DataTableView.prototype.doPostThenUpdate = function(command, params, updateColumnModel) {
params.project = theProject.id;
$.post(
"/command/" + command + "?" + $.param(params),
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) },
this.createUpdateFunction(updateColumnModel ? reinitializeProjectData : undefined),
"json"
);
};
DataTableView.promptExpressionOnVisibleRows = function(column, title, expression, onDone) { DataTableView.promptExpressionOnVisibleRows = function(column, title, expression, onDone) {
var rowIndices = []; var rowIndices = [];
var values = []; var values = [];

View File

@ -10,6 +10,10 @@ HistoryWidget.prototype.update = function(onDone) {
function(data) { function(data) {
self._data = data; self._data = data;
self._render(); self._render();
if (onDone) {
onDone();
}
} }
); );
}; };
@ -88,18 +92,12 @@ HistoryWidget.prototype._render = function() {
HistoryWidget.prototype._onClickHistoryEntry = function(evt, entry, lastDoneID) { HistoryWidget.prototype._onClickHistoryEntry = function(evt, entry, lastDoneID) {
var self = this; var self = this;
$.post(
"/command/undo-redo?" + $.param({ project: theProject.id, lastDoneID: lastDoneID }), Gridworks.postProcess(
"undo-redo",
{ lastDoneID: lastDoneID },
null, null,
function(data) { { everythingChanged: true }
if (data.code == "ok") {
self.update();
ui.dataTableView.update(true);
} else {
// update process UI
}
},
"json"
); );
}; };
@ -218,18 +216,22 @@ HistoryWidget.prototype._showApplyOperationsDialog = function(json) {
return; return;
} }
DialogSystem.dismissUntil(level - 1); Gridworks.postProcess(
"apply-operations",
$.post( {},
"/command/apply-operations?" + $.param({ project: theProject.id }),
{ operations: JSON.stringify(json) }, { operations: JSON.stringify(json) },
function(data) { { everythingChanged: true },
self.update(); {
ui.dataTableView.update(true); onDone: function(o) {
ui.processWidget.update(); if (o.code == "pending") {
}, // Something might have already been done and so it's good to update
"json" Gridworks.update({ everythingChanged: true });
}
}
}
); );
DialogSystem.dismissUntil(level - 1);
}).appendTo(footer); }).appendTo(footer);
$('<button></button>').text("Cancel").click(function() { $('<button></button>').text("Cancel").click(function() {

View File

@ -162,12 +162,6 @@ ListFacet.prototype.render = function() {
self.render(); self.render();
}).appendTo(footerDiv); }).appendTo(footerDiv);
} }
$('<span>').html(" &bull; ").appendTo(footerDiv);
$('<a href="javascript:{}"></a>').addClass("action").text("refresh").click(function() {
ui.browsingEngine.update();
}).appendTo(footerDiv);
} }
}; };
@ -204,6 +198,5 @@ ListFacet.prototype._remove = function() {
}; };
ListFacet.prototype._updateRest = function() { ListFacet.prototype._updateRest = function() {
ui.browsingEngine.update(); Gridworks.update({ engineChanged: true });
ui.dataTableView.update(true);
}; };

View File

@ -2,10 +2,23 @@ function ProcessWidget(div) {
this._div = div; this._div = div;
this._timerID = null; this._timerID = null;
this._processCount = 0; this._processCount = 0;
this.update();
this._updateOptions = {};
this._onDones = [];
this.update({});
} }
ProcessWidget.prototype.update = function() { ProcessWidget.prototype.update = function(updateOptions, onDone) {
for (var n in updateOptions) {
if (updateOptions.hasOwnProperty(n)) {
this._updateOptions[n] = updateOptions[n];
}
}
if (onDone) {
this._onDones.push(onDone);
}
if (this._timerID != null) { if (this._timerID != null) {
return; return;
} }
@ -25,22 +38,19 @@ ProcessWidget.prototype._render = function() {
this._div.empty(); this._div.empty();
var bodyDiv = $('<div></div>').addClass("process-panel-inner").appendTo(this._div);
if (this._data.processes.length == 0) { if (this._data.processes.length == 0) {
this._div.hide(); this._div.hide();
} else {
if (this._processCount > 0) {
this._processCount = 0;
ui.historyWidget.update();
ui.dataTableView.update(true);
}
return;
}
this._processCount = this._data.processes.length;
this._div.show(); this._div.show();
var bodyDiv = $('<div></div>').addClass("process-panel-inner").appendTo(this._div);
$('<img src="images/small-spinner.gif" />')
.css("float", "right")
.css("margin-left", "10px")
.css("margin-bottom", "10px")
.css("opacity", "0.3")
.appendTo(bodyDiv);
var renderProcess = function(process) { var renderProcess = function(process) {
var div = $('<div></div>').addClass("process-panel-entry").appendTo(bodyDiv); var div = $('<div></div>').addClass("process-panel-entry").appendTo(bodyDiv);
@ -55,11 +65,29 @@ ProcessWidget.prototype._render = function() {
for (var i = 0; i < processes.length; i++) { for (var i = 0; i < processes.length; i++) {
renderProcess(processes[i]); renderProcess(processes[i]);
} }
}
if (processes.length > 0 && this._timerID == null) { if (this._data.processes.length > 0 && this._timerID == null) {
this._timerID = window.setTimeout(function() { this._timerID = window.setTimeout(function() {
self._timerID = null; self._timerID = null;
self.update(); self.update();
}, 500); }, 500);
} else {
var updateOptions = this._updateOptions;
var onDones = this._onDones;
this._updateOptions = {};
this._onDones = [];
Gridworks.update(updateOptions, function() {
for (var i = 0; i < onDones.length; i++) {
try {
onDones[i]();
} catch (e) {
Gridworks.reportException(e);
}
}
});
} }
}; };

View File

@ -7,6 +7,7 @@ function RangeFacet(div, config, options) {
this._to = ("to" in this._config) ? this._config.to : null; this._to = ("to" in this._config) ? this._config.to : null;
this._timerID = null; this._timerID = null;
this._error = false;
this._initializedUI = false; this._initializedUI = false;
} }
@ -93,6 +94,10 @@ RangeFacet.prototype._initializeUI = function() {
var bodyDiv = $('<div></div>').addClass("facet-range-body").appendTo(container); var bodyDiv = $('<div></div>').addClass("facet-range-body").appendTo(container);
if (this._error) {
return;
}
this._histogramDiv = $('<div></div>').addClass("facet-range-histogram").appendTo(bodyDiv); this._histogramDiv = $('<div></div>').addClass("facet-range-histogram").appendTo(bodyDiv);
this._sliderDiv = $('<div></div>').addClass("facet-range-slider").appendTo(bodyDiv); this._sliderDiv = $('<div></div>').addClass("facet-range-slider").appendTo(bodyDiv);
this._statusDiv = $('<div></div>').addClass("facet-range-status").appendTo(bodyDiv); this._statusDiv = $('<div></div>').addClass("facet-range-status").appendTo(bodyDiv);
@ -157,6 +162,7 @@ RangeFacet.prototype._setRangeIndicators = function() {
}; };
RangeFacet.prototype.updateState = function(data) { RangeFacet.prototype.updateState = function(data) {
if ("min" in data && "max" in data) {
this._config.min = data.min; this._config.min = data.min;
this._config.max = data.max; this._config.max = data.max;
this._config.step = data.step; this._config.step = data.step;
@ -178,6 +184,9 @@ RangeFacet.prototype.updateState = function(data) {
this._to = data.max; this._to = data.max;
} }
} }
} else {
this._error = true;
}
this.render(); this.render();
}; };
@ -187,6 +196,9 @@ RangeFacet.prototype.render = function() {
this._initializeUI(); this._initializeUI();
this._initializedUI = true; this._initializedUI = true;
} }
if (this._error) {
return;
}
this._sliderDiv.slider("option", "min", this._config.min); this._sliderDiv.slider("option", "min", this._config.min);
this._sliderDiv.slider("option", "max", this._config.max); this._sliderDiv.slider("option", "max", this._config.max);
@ -249,6 +261,5 @@ RangeFacet.prototype._scheduleUpdate = function() {
}; };
RangeFacet.prototype._updateRest = function() { RangeFacet.prototype._updateRest = function() {
ui.browsingEngine.update(); Gridworks.update({ engineChanged: true });
ui.dataTableView.update(true);
}; };

View File

@ -69,24 +69,18 @@ ReconDialog.prototype._createDialog = function() {
alert("Please specify a type."); alert("Please specify a type.");
} else { } else {
DialogSystem.dismissUntil(level - 1); DialogSystem.dismissUntil(level - 1);
$.post(
"/command/reconcile?" + $.param({ Gridworks.postProcess(
project: theProject.id, "reconcile",
{
columnName: self._column.headerLabel, columnName: self._column.headerLabel,
typeID: type.id, typeID: type.id,
typeName: type.name, typeName: type.name,
autoMatch: autoMatchCheckbox[0].checked, autoMatch: autoMatchCheckbox[0].checked,
minScore: minScoreInput[0].value minScore: minScoreInput[0].value
}),
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) },
function(data) {
if (data.code != "error") {
ui.processWidget.update();
} else {
alert(data.message);
}
}, },
"json" null,
{ cellsChanged: true }
); );
} }
}).appendTo(footer); }).appendTo(footer);

View File

@ -162,26 +162,16 @@ SchemaAlignmentDialog.prototype._constructFooter = function(footer) {
$('<button></button>').html("&nbsp;&nbsp;OK&nbsp;&nbsp;").click(function() { $('<button></button>').html("&nbsp;&nbsp;OK&nbsp;&nbsp;").click(function() {
var protograph = self.getJSON(); var protograph = self.getJSON();
$.post( Gridworks.postProcess(
"/command/save-protograph?" + $.param({ project: theProject.id }), "save-protograph",
{},
{ protograph: JSON.stringify(protograph) }, { protograph: JSON.stringify(protograph) },
function(data) { {
if (data.code == "error") { onDone: function() {
alert("Failed to save protograph");
return;
} else if (data.code == "ok") {
ui.historyWidget.update();
} else {
ui.processWidget.update();
}
DialogSystem.dismissUntil(self._level - 1); DialogSystem.dismissUntil(self._level - 1);
theProject.protograph = protograph; theProject.protograph = protograph;
}
self._onDone(protograph); }
},
"json"
); );
}).appendTo(footer); }).appendTo(footer);

View File

@ -81,6 +81,5 @@ TextSearchFacet.prototype._scheduleUpdate = function() {
}; };
TextSearchFacet.prototype._updateRest = function() { TextSearchFacet.prototype._updateRest = function() {
ui.browsingEngine.update(); Gridworks.update({ engineChanged: true });
ui.dataTableView.update(true);
}; };

View File

@ -11,8 +11,8 @@
max-height: 70px; max-height: 70px;
overflow: auto; overflow: auto;
padding: 10px; padding: 10px;
background: #fffee0;
margin: 0 auto; margin: 0 auto;
text-align: left; text-align: left;
background: #fffee0;
} }