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:
parent
1e4b9f4e80
commit
30dce3b3d5
@ -42,6 +42,9 @@ public class RangeFacet implements Facet {
|
||||
writer.key("name"); writer.value(_name);
|
||||
writer.key("expression"); writer.value(_expression);
|
||||
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("max"); writer.value(_max);
|
||||
writer.key("step"); writer.value(_step);
|
||||
@ -58,7 +61,6 @@ public class RangeFacet implements Facet {
|
||||
}
|
||||
writer.endArray();
|
||||
|
||||
writer.key("mode"); writer.value(_mode);
|
||||
if ("min".equals(_mode)) {
|
||||
writer.key("from"); writer.value(_from);
|
||||
} else if ("max".equals(_mode)) {
|
||||
@ -67,6 +69,8 @@ public class RangeFacet implements Facet {
|
||||
writer.key("from"); writer.value(_from);
|
||||
writer.key("to"); writer.value(_to);
|
||||
}
|
||||
}
|
||||
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,11 @@ public class ApplyOperationsCommand extends Command {
|
||||
reconstructOperation(project, obj);
|
||||
}
|
||||
|
||||
if (project.processManager.hasPending()) {
|
||||
respond(response, "{ \"code\" : \"pending\" }");
|
||||
} else {
|
||||
respond(response, "{ \"code\" : \"ok\" }");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
respondException(response, e);
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ public class ProcessManager implements Jsonizable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPending() {
|
||||
return _processes.size() > 0;
|
||||
}
|
||||
|
||||
public void onDoneProcess(Process p) {
|
||||
_processes.remove(p);
|
||||
update();
|
||||
|
@ -1,6 +1,16 @@
|
||||
var theProject;
|
||||
var ui = {};
|
||||
|
||||
var Gridworks = {
|
||||
};
|
||||
|
||||
Gridworks.reportException = function(e) {
|
||||
if (window.console) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function onLoad() {
|
||||
var params = URL.getParameters();
|
||||
if ("project" in params) {
|
||||
@ -8,7 +18,7 @@ function onLoad() {
|
||||
id: parseInt(params.project)
|
||||
};
|
||||
|
||||
reinitializeProjectData(initializeUI);
|
||||
Gridworks.reinitializeProjectData(initializeUI);
|
||||
}
|
||||
}
|
||||
$(onLoad);
|
||||
@ -44,7 +54,7 @@ function initializeUI() {
|
||||
ui.menuBar = new MenuBar(ui.menuBarPanel);
|
||||
}
|
||||
|
||||
function reinitializeProjectData(f) {
|
||||
Gridworks.reinitializeProjectData = function(f) {
|
||||
Ajax.chainGetJSON(
|
||||
"/command/get-project-metadata?" + $.param({ project: theProject.id }), null,
|
||||
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;
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
var column = columns[i];
|
||||
if (column.cellIndex == index) {
|
||||
if (column.cellIndex == cellIndex) {
|
||||
return column;
|
||||
}
|
||||
}
|
||||
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"
|
||||
);
|
||||
};
|
||||
|
@ -50,12 +50,11 @@ BrowsingEngine.prototype.removeFacet = function(facet) {
|
||||
}
|
||||
|
||||
if (update) {
|
||||
this.update();
|
||||
ui.dataTableView.update(true);
|
||||
Gridworks.update({ engineChanged: true }, onFinallyDone);
|
||||
}
|
||||
};
|
||||
|
||||
BrowsingEngine.prototype.update = function() {
|
||||
BrowsingEngine.prototype.update = function(onDone) {
|
||||
var self = this;
|
||||
|
||||
$.post(
|
||||
@ -67,6 +66,10 @@ BrowsingEngine.prototype.update = function() {
|
||||
for (var i = 0; i < facetData.length; i++) {
|
||||
self._facets[i].facet.updateState(facetData[i]);
|
||||
}
|
||||
|
||||
if (onDone) {
|
||||
onDone();
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
@ -159,16 +159,16 @@ DataTableCellUI.prototype._doJudgment = function(judgment, params) {
|
||||
params.row = this._rowIndex;
|
||||
params.cell = this._cellIndex;
|
||||
params.judgment = judgment;
|
||||
this.doPostThenUpdate("recon-judge-one-cell", params);
|
||||
this._postProcessOneCell("recon-judge-one-cell", params);
|
||||
};
|
||||
|
||||
DataTableCellUI.prototype._doJudgmentForSimilarCells = function(judgment, params) {
|
||||
params = params || {};
|
||||
params.columnName = cellIndexToColumn(this._cellIndex).headerLabel;
|
||||
params.columnName = Gridworks.cellIndexToColumn(this._cellIndex).headerLabel;
|
||||
params.similarValue = this._cell.v;
|
||||
params.judgment = judgment;
|
||||
|
||||
ui.dataTableView.doPostThenUpdate("recon-judge-similar-cells", params);
|
||||
this._postProcessSeveralCells("recon-judge-similar-cells", params);
|
||||
};
|
||||
|
||||
DataTableCellUI.prototype._searchForMatch = function() {
|
||||
@ -203,14 +203,14 @@ DataTableCellUI.prototype._searchForMatch = function() {
|
||||
};
|
||||
if (checkSimilar[0].checked) {
|
||||
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 {
|
||||
params.row = self._rowIndex;
|
||||
params.cell = self._cellIndex;
|
||||
|
||||
self.doPostThenUpdate("recon-judge-one-cell", params);
|
||||
self._postProcessOneCell("recon-judge-one-cell", params);
|
||||
}
|
||||
|
||||
DialogSystem.dismissUntil(level - 1);
|
||||
@ -225,36 +225,29 @@ DataTableCellUI.prototype._searchForMatch = function() {
|
||||
input.focus().data("suggest").textchange();
|
||||
};
|
||||
|
||||
DataTableCellUI.prototype.createUpdateFunction = function(onBefore) {
|
||||
DataTableCellUI.prototype._postProcessOneCell = function(command, params) {
|
||||
var self = this;
|
||||
return function(data) {
|
||||
if (data.code == "ok") {
|
||||
var onDone = function() {
|
||||
|
||||
Gridworks.postProcess(
|
||||
command,
|
||||
params,
|
||||
null,
|
||||
{},
|
||||
{
|
||||
onDone: function(o) {
|
||||
self._cell = data.cell;
|
||||
self._render();
|
||||
ui.historyWidget.update();
|
||||
};
|
||||
} else {
|
||||
var onDone = function() {
|
||||
ui.processWidget.update();
|
||||
}
|
||||
}
|
||||
|
||||
if (onBefore) {
|
||||
onBefore(onDone);
|
||||
} else {
|
||||
onDone();
|
||||
}
|
||||
};
|
||||
);
|
||||
};
|
||||
|
||||
DataTableCellUI.prototype.doPostThenUpdate = function(command, params) {
|
||||
params.project = theProject.id;
|
||||
$.post(
|
||||
"/command/" + command + "?" + $.param(params),
|
||||
DataTableCellUI.prototype._postProcessSeveralCells = function(command, params) {
|
||||
Gridworks.postProcess(
|
||||
command,
|
||||
params,
|
||||
null,
|
||||
this.createUpdateFunction(),
|
||||
"json"
|
||||
{ cellsChanged: true }
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -375,9 +375,11 @@ DataTableColumnHeaderUI.prototype._doFilterByExpressionPrompt = function(express
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doTextTransform = function(expression) {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"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() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"recon-discard-judgments",
|
||||
{ columnName: this._column.headerLabel }
|
||||
{ columnName: this._column.headerLabel },
|
||||
null,
|
||||
{ cellsChanged: true }
|
||||
);
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doReconMatchBestCandidates = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"recon-match-best-candidates",
|
||||
{ columnName: this._column.headerLabel }
|
||||
{ columnName: this._column.headerLabel },
|
||||
null,
|
||||
{ cellsChanged: true }
|
||||
);
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doReconMarkNewTopics = function(shareNewTopics) {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"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));
|
||||
|
||||
input.suggest({}).bind("fb-select", function(e, data) {
|
||||
self._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"recon-match-specific-topic-to-cells",
|
||||
{
|
||||
columnName: self._column.headerLabel,
|
||||
@ -488,8 +496,11 @@ DataTableColumnHeaderUI.prototype._doSearchToMatch = function() {
|
||||
topicGUID: data.guid,
|
||||
topicName: data.name,
|
||||
types: $.map(data.type, function(elmt) { return elmt.id; }).join(",")
|
||||
}
|
||||
},
|
||||
null,
|
||||
{ cellsChanged: true }
|
||||
);
|
||||
|
||||
DialogSystem.dismissUntil(level - 1);
|
||||
});
|
||||
|
||||
@ -510,7 +521,7 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
||||
function(expression) {
|
||||
var headerLabel = window.prompt("Enter header label for new column:");
|
||||
if (headerLabel != null) {
|
||||
self._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"add-column",
|
||||
{
|
||||
baseColumnName: self._column.headerLabel,
|
||||
@ -518,7 +529,8 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
||||
headerLabel: headerLabel,
|
||||
columnInsertIndex: self._columnIndex + 1
|
||||
},
|
||||
true
|
||||
null,
|
||||
{ modelsChanged: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -526,23 +538,28 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doRemoveColumn = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"remove-column",
|
||||
{ columnName: this._column.headerLabel },
|
||||
true
|
||||
{
|
||||
columnName: this._column.headerLabel
|
||||
},
|
||||
null,
|
||||
{ modelsChanged: true }
|
||||
);
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() {
|
||||
var separator = window.prompt("Enter separator to use between values", ", ");
|
||||
if (separator != null) {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"join-multi-value-cells",
|
||||
{
|
||||
columnName: this._column.headerLabel,
|
||||
keyColumnName: theProject.columnModel.keyColumnName,
|
||||
separator: separator
|
||||
}
|
||||
},
|
||||
null,
|
||||
{ rowsChanged: true }
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -550,14 +567,16 @@ DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() {
|
||||
DataTableColumnHeaderUI.prototype._doSplitMultiValueCells = function() {
|
||||
var separator = window.prompt("What separator currently separates the values?", ",");
|
||||
if (separator != null) {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
Gridworks.postProcess(
|
||||
"split-multi-value-cells",
|
||||
{
|
||||
columnName: this._column.headerLabel,
|
||||
keyColumnName: theProject.columnModel.keyColumnName,
|
||||
separator: separator,
|
||||
mode: "plain"
|
||||
}
|
||||
},
|
||||
null,
|
||||
{ rowsChanged: true }
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -5,15 +5,8 @@ function DataTableView(div) {
|
||||
this._showRows(0);
|
||||
}
|
||||
|
||||
DataTableView.prototype.update = function(reset) {
|
||||
if (reset) {
|
||||
var self = this;
|
||||
reinitializeProjectData(function() {
|
||||
self._showRows(0);
|
||||
});
|
||||
} else {
|
||||
this._showRows(theProject.rowModel.start);
|
||||
}
|
||||
DataTableView.prototype.update = function(onDone) {
|
||||
this._showRows(0, onDone);
|
||||
};
|
||||
|
||||
DataTableView.prototype.render = function() {
|
||||
@ -72,7 +65,7 @@ DataTableView.prototype.render = function() {
|
||||
} else {
|
||||
a.text(pageSize).addClass("action").click(function(evt) {
|
||||
self._pageSize = pageSize;
|
||||
self.update(true);
|
||||
self.update();
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -205,6 +198,8 @@ DataTableView.prototype.render = function() {
|
||||
|
||||
var rows = theProject.rowModel.rows;
|
||||
var renderRow = function(tr, r, row, even) {
|
||||
$(tr).empty();
|
||||
|
||||
var cells = row.cells;
|
||||
|
||||
var tdStar = tr.insertCell(tr.cells.length);
|
||||
@ -213,25 +208,19 @@ DataTableView.prototype.render = function() {
|
||||
.appendTo(tdStar)
|
||||
.click(function() {
|
||||
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,
|
||||
function(o) {
|
||||
if (o.code == "ok") {
|
||||
{},
|
||||
{ onDone: function(o) {
|
||||
row.starred = newStarred;
|
||||
|
||||
$(tr).empty();
|
||||
|
||||
renderRow(tr, r, row, even);
|
||||
|
||||
ui.historyWidget.update();
|
||||
} else {
|
||||
ui.processWidget.update();
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
var tdIndex = tr.insertCell(tr.cells.length);
|
||||
@ -273,20 +262,13 @@ DataTableView.prototype.render = function() {
|
||||
|
||||
DataTableView.prototype._showRows = function(start, onDone) {
|
||||
var self = this;
|
||||
|
||||
$.post(
|
||||
"/command/get-rows?" + $.param({ project: theProject.id, start: start, limit: this._pageSize }),
|
||||
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) },
|
||||
function(data) {
|
||||
theProject.rowModel = data;
|
||||
Gridworks.fetchRows(start, this._pageSize, function() {
|
||||
self.render();
|
||||
|
||||
if (onDone) {
|
||||
onDone();
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
DataTableView.prototype._onClickPreviousPage = function(elmt, evt) {
|
||||
@ -330,50 +312,18 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) {
|
||||
{
|
||||
label: "Star Rows",
|
||||
click: function() {
|
||||
self.doPostThenUpdate("annotate-rows", { "starred" : "true" }, false);
|
||||
Gridworks.postProcess("annotate-rows", { "starred" : "true" }, null, { rowMetadataChanged: true });
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Unstar Rows",
|
||||
click: function() {
|
||||
self.doPostThenUpdate("annotate-rows", { "starred" : "false" }, false);
|
||||
Gridworks.postProcess("annotate-rows", { "starred" : "false" }, null, { rowMetadataChanged: true });
|
||||
}
|
||||
}
|
||||
], 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) {
|
||||
var rowIndices = [];
|
||||
var values = [];
|
||||
|
@ -10,6 +10,10 @@ HistoryWidget.prototype.update = function(onDone) {
|
||||
function(data) {
|
||||
self._data = data;
|
||||
self._render();
|
||||
|
||||
if (onDone) {
|
||||
onDone();
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
@ -88,18 +92,12 @@ HistoryWidget.prototype._render = function() {
|
||||
|
||||
HistoryWidget.prototype._onClickHistoryEntry = function(evt, entry, lastDoneID) {
|
||||
var self = this;
|
||||
$.post(
|
||||
"/command/undo-redo?" + $.param({ project: theProject.id, lastDoneID: lastDoneID }),
|
||||
|
||||
Gridworks.postProcess(
|
||||
"undo-redo",
|
||||
{ lastDoneID: lastDoneID },
|
||||
null,
|
||||
function(data) {
|
||||
if (data.code == "ok") {
|
||||
self.update();
|
||||
ui.dataTableView.update(true);
|
||||
} else {
|
||||
// update process UI
|
||||
}
|
||||
},
|
||||
"json"
|
||||
{ everythingChanged: true }
|
||||
);
|
||||
};
|
||||
|
||||
@ -218,18 +216,22 @@ HistoryWidget.prototype._showApplyOperationsDialog = function(json) {
|
||||
return;
|
||||
}
|
||||
|
||||
DialogSystem.dismissUntil(level - 1);
|
||||
|
||||
$.post(
|
||||
"/command/apply-operations?" + $.param({ project: theProject.id }),
|
||||
Gridworks.postProcess(
|
||||
"apply-operations",
|
||||
{},
|
||||
{ operations: JSON.stringify(json) },
|
||||
function(data) {
|
||||
self.update();
|
||||
ui.dataTableView.update(true);
|
||||
ui.processWidget.update();
|
||||
},
|
||||
"json"
|
||||
{ everythingChanged: true },
|
||||
{
|
||||
onDone: function(o) {
|
||||
if (o.code == "pending") {
|
||||
// Something might have already been done and so it's good to update
|
||||
Gridworks.update({ everythingChanged: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
DialogSystem.dismissUntil(level - 1);
|
||||
}).appendTo(footer);
|
||||
|
||||
$('<button></button>').text("Cancel").click(function() {
|
||||
|
@ -162,12 +162,6 @@ ListFacet.prototype.render = function() {
|
||||
self.render();
|
||||
}).appendTo(footerDiv);
|
||||
}
|
||||
|
||||
$('<span>').html(" • ").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() {
|
||||
ui.browsingEngine.update();
|
||||
ui.dataTableView.update(true);
|
||||
Gridworks.update({ engineChanged: true });
|
||||
};
|
||||
|
@ -2,10 +2,23 @@ function ProcessWidget(div) {
|
||||
this._div = div;
|
||||
this._timerID = null;
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -25,22 +38,19 @@ ProcessWidget.prototype._render = function() {
|
||||
|
||||
this._div.empty();
|
||||
|
||||
var bodyDiv = $('<div></div>').addClass("process-panel-inner").appendTo(this._div);
|
||||
if (this._data.processes.length == 0) {
|
||||
this._div.hide();
|
||||
|
||||
if (this._processCount > 0) {
|
||||
this._processCount = 0;
|
||||
|
||||
ui.historyWidget.update();
|
||||
ui.dataTableView.update(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this._processCount = this._data.processes.length;
|
||||
|
||||
} else {
|
||||
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 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++) {
|
||||
renderProcess(processes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (processes.length > 0 && this._timerID == null) {
|
||||
if (this._data.processes.length > 0 && this._timerID == null) {
|
||||
this._timerID = window.setTimeout(function() {
|
||||
self._timerID = null;
|
||||
self.update();
|
||||
}, 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -7,6 +7,7 @@ function RangeFacet(div, config, options) {
|
||||
this._to = ("to" in this._config) ? this._config.to : null;
|
||||
|
||||
this._timerID = null;
|
||||
this._error = false;
|
||||
this._initializedUI = false;
|
||||
}
|
||||
|
||||
@ -93,6 +94,10 @@ RangeFacet.prototype._initializeUI = function() {
|
||||
|
||||
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._sliderDiv = $('<div></div>').addClass("facet-range-slider").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) {
|
||||
if ("min" in data && "max" in data) {
|
||||
this._config.min = data.min;
|
||||
this._config.max = data.max;
|
||||
this._config.step = data.step;
|
||||
@ -178,6 +184,9 @@ RangeFacet.prototype.updateState = function(data) {
|
||||
this._to = data.max;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this._error = true;
|
||||
}
|
||||
|
||||
this.render();
|
||||
};
|
||||
@ -187,6 +196,9 @@ RangeFacet.prototype.render = function() {
|
||||
this._initializeUI();
|
||||
this._initializedUI = true;
|
||||
}
|
||||
if (this._error) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._sliderDiv.slider("option", "min", this._config.min);
|
||||
this._sliderDiv.slider("option", "max", this._config.max);
|
||||
@ -249,6 +261,5 @@ RangeFacet.prototype._scheduleUpdate = function() {
|
||||
};
|
||||
|
||||
RangeFacet.prototype._updateRest = function() {
|
||||
ui.browsingEngine.update();
|
||||
ui.dataTableView.update(true);
|
||||
Gridworks.update({ engineChanged: true });
|
||||
};
|
||||
|
@ -69,24 +69,18 @@ ReconDialog.prototype._createDialog = function() {
|
||||
alert("Please specify a type.");
|
||||
} else {
|
||||
DialogSystem.dismissUntil(level - 1);
|
||||
$.post(
|
||||
"/command/reconcile?" + $.param({
|
||||
project: theProject.id,
|
||||
|
||||
Gridworks.postProcess(
|
||||
"reconcile",
|
||||
{
|
||||
columnName: self._column.headerLabel,
|
||||
typeID: type.id,
|
||||
typeName: type.name,
|
||||
autoMatch: autoMatchCheckbox[0].checked,
|
||||
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);
|
||||
|
@ -162,26 +162,16 @@ SchemaAlignmentDialog.prototype._constructFooter = function(footer) {
|
||||
$('<button></button>').html(" OK ").click(function() {
|
||||
var protograph = self.getJSON();
|
||||
|
||||
$.post(
|
||||
"/command/save-protograph?" + $.param({ project: theProject.id }),
|
||||
Gridworks.postProcess(
|
||||
"save-protograph",
|
||||
{},
|
||||
{ protograph: JSON.stringify(protograph) },
|
||||
function(data) {
|
||||
if (data.code == "error") {
|
||||
alert("Failed to save protograph");
|
||||
return;
|
||||
} else if (data.code == "ok") {
|
||||
ui.historyWidget.update();
|
||||
} else {
|
||||
ui.processWidget.update();
|
||||
}
|
||||
|
||||
{
|
||||
onDone: function() {
|
||||
DialogSystem.dismissUntil(self._level - 1);
|
||||
|
||||
theProject.protograph = protograph;
|
||||
|
||||
self._onDone(protograph);
|
||||
},
|
||||
"json"
|
||||
}
|
||||
}
|
||||
);
|
||||
}).appendTo(footer);
|
||||
|
||||
|
@ -81,6 +81,5 @@ TextSearchFacet.prototype._scheduleUpdate = function() {
|
||||
};
|
||||
|
||||
TextSearchFacet.prototype._updateRest = function() {
|
||||
ui.browsingEngine.update();
|
||||
ui.dataTableView.update(true);
|
||||
Gridworks.update({ engineChanged: true });
|
||||
};
|
||||
|
@ -11,8 +11,8 @@
|
||||
max-height: 70px;
|
||||
overflow: auto;
|
||||
padding: 10px;
|
||||
background: #fffee0;
|
||||
margin: 0 auto;
|
||||
text-align: left;
|
||||
background: #fffee0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user