2011-08-08 01:26:51 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 2011, Google Inc.
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are
|
|
|
|
met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the following disclaimer
|
|
|
|
in the documentation and/or other materials provided with the
|
|
|
|
distribution.
|
|
|
|
* Neither the name of Google Inc. nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-06-27 17:25:53 +02:00
|
|
|
//Internationalization init
|
|
|
|
var lang = navigator.language.split("-")[0]
|
|
|
|
|| navigator.userLanguage.split("-")[0];
|
|
|
|
var dictionary = "";
|
|
|
|
$.ajax({
|
2014-12-03 14:52:06 +01:00
|
|
|
url : "command/core/load-language?",
|
2013-06-27 17:25:53 +02:00
|
|
|
type : "POST",
|
|
|
|
async : false,
|
|
|
|
data : {
|
2013-07-31 06:31:31 +02:00
|
|
|
module : "gdata",
|
|
|
|
// lang : lang
|
2013-06-27 17:25:53 +02:00
|
|
|
},
|
|
|
|
success : function(data) {
|
|
|
|
dictionary = data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.i18n.setDictionary(dictionary);
|
|
|
|
// End internationalization
|
|
|
|
|
2011-08-08 01:26:51 +02:00
|
|
|
Refine.GDataImportingController = function(createProjectUI) {
|
|
|
|
this._createProjectUI = createProjectUI;
|
2011-08-11 02:35:01 +02:00
|
|
|
|
|
|
|
this._parsingPanel = createProjectUI.addCustomPanel();
|
2011-08-08 01:26:51 +02:00
|
|
|
|
|
|
|
createProjectUI.addSourceSelectionUI({
|
|
|
|
label: "Google Data",
|
|
|
|
id: "gdata-source",
|
|
|
|
ui: new Refine.GDataSourceUI(this)
|
|
|
|
});
|
2013-06-27 17:25:53 +02:00
|
|
|
|
2018-11-21 16:24:57 +01:00
|
|
|
$('#gdata-authorize').text($.i18n._('gdata-auth/authorize-label'));
|
|
|
|
$('#gdata-authorized').text($.i18n._('gdata-auth/authorized-label'));
|
2011-08-08 01:26:51 +02:00
|
|
|
};
|
|
|
|
Refine.CreateProjectUI.controllers.push(Refine.GDataImportingController);
|
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
Refine.GDataImportingController.prototype.startImportingDocument = function(doc) {
|
2018-11-21 16:24:57 +01:00
|
|
|
var dismiss = DialogSystem.showBusy($.i18n._('gdata-import/preparing'));
|
2011-08-08 01:26:51 +02:00
|
|
|
|
|
|
|
var self = this;
|
2011-08-11 02:35:01 +02:00
|
|
|
$.post(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/core/create-importing-job",
|
2011-08-11 02:35:01 +02:00
|
|
|
null,
|
|
|
|
function(data) {
|
|
|
|
$.post(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/core/importing-controller?" + $.param({
|
2011-08-11 02:35:01 +02:00
|
|
|
"controller": "gdata/gdata-importing-controller",
|
|
|
|
"subCommand": "initialize-parser-ui",
|
2011-08-13 00:31:39 +02:00
|
|
|
"docUrl": doc.docSelfLink,
|
2011-11-17 19:52:14 +01:00
|
|
|
"docType": doc.type
|
2011-08-11 02:35:01 +02:00
|
|
|
}),
|
|
|
|
null,
|
|
|
|
function(data2) {
|
|
|
|
dismiss();
|
|
|
|
|
|
|
|
if (data2.status == 'ok') {
|
|
|
|
self._doc = doc;
|
|
|
|
self._jobID = data.jobID;
|
|
|
|
self._options = data2.options;
|
|
|
|
|
|
|
|
self._showParsingPanel();
|
|
|
|
} else {
|
|
|
|
alert(data2.message);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2011-08-08 01:26:51 +02:00
|
|
|
},
|
2011-08-11 02:35:01 +02:00
|
|
|
"json"
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Refine.GDataImportingController.prototype.getOptions = function() {
|
|
|
|
var options = {
|
|
|
|
docUrl: this._doc.docSelfLink,
|
2011-08-13 00:31:39 +02:00
|
|
|
docType: this._doc.type,
|
2011-08-11 02:35:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
var parseIntDefault = function(s, def) {
|
|
|
|
try {
|
|
|
|
var n = parseInt(s);
|
|
|
|
if (!isNaN(n)) {
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// Ignore
|
|
|
|
}
|
|
|
|
return def;
|
|
|
|
};
|
|
|
|
|
2011-09-15 23:40:40 +02:00
|
|
|
if (this._doc.type != 'table') {
|
|
|
|
this._parsingPanelElmts.sheetRecordContainer.find('input').each(function() {
|
|
|
|
if (this.checked) {
|
|
|
|
options.sheetUrl = this.getAttribute('sheetUrl');
|
|
|
|
}
|
|
|
|
});
|
2011-08-11 02:35:01 +02:00
|
|
|
|
2011-09-15 23:40:40 +02:00
|
|
|
if (this._parsingPanelElmts.ignoreCheckbox[0].checked) {
|
|
|
|
options.ignoreLines = parseIntDefault(this._parsingPanelElmts.ignoreInput[0].value, -1);
|
|
|
|
} else {
|
|
|
|
options.ignoreLines = -1;
|
|
|
|
}
|
|
|
|
if (this._parsingPanelElmts.headerLinesCheckbox[0].checked) {
|
|
|
|
options.headerLines = parseIntDefault(this._parsingPanelElmts.headerLinesInput[0].value, 0);
|
|
|
|
} else {
|
|
|
|
options.headerLines = 0;
|
|
|
|
}
|
2011-08-11 02:35:01 +02:00
|
|
|
}
|
2011-09-15 23:40:40 +02:00
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
if (this._parsingPanelElmts.skipCheckbox[0].checked) {
|
|
|
|
options.skipDataLines = parseIntDefault(this._parsingPanelElmts.skipInput[0].value, 0);
|
|
|
|
} else {
|
|
|
|
options.skipDataLines = 0;
|
|
|
|
}
|
|
|
|
if (this._parsingPanelElmts.limitCheckbox[0].checked) {
|
|
|
|
options.limit = parseIntDefault(this._parsingPanelElmts.limitInput[0].value, -1);
|
|
|
|
} else {
|
|
|
|
options.limit = -1;
|
|
|
|
}
|
|
|
|
options.storeBlankRows = this._parsingPanelElmts.storeBlankRowsCheckbox[0].checked;
|
|
|
|
options.storeBlankCellsAsNulls = this._parsingPanelElmts.storeBlankCellsAsNullsCheckbox[0].checked;
|
|
|
|
|
|
|
|
return options;
|
2011-08-08 01:26:51 +02:00
|
|
|
};
|
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
Refine.GDataImportingController.prototype._showParsingPanel = function() {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this._parsingPanel.unbind().empty().html(
|
2011-09-15 23:40:40 +02:00
|
|
|
DOM.loadHTML("gdata",
|
|
|
|
this._doc.type == 'table' ?
|
|
|
|
'scripts/index/gdata-fusion-tables-parsing-panel.html' :
|
|
|
|
'scripts/index/gdata-parsing-panel.html'));
|
2011-08-11 02:35:01 +02:00
|
|
|
this._parsingPanelElmts = DOM.bind(this._parsingPanel);
|
|
|
|
|
2013-06-27 17:25:53 +02:00
|
|
|
if(this._doc.type != 'table'){
|
2018-11-21 16:24:57 +01:00
|
|
|
this._parsingPanelElmts.gdata_worksheet.html($.i18n._('gdata-parsing/worksheet'));
|
|
|
|
this._parsingPanelElmts.gdata_ignore_first.html($.i18n._('gdata-parsing/ignore-first'));
|
|
|
|
this._parsingPanelElmts.gdata_ignore.html($.i18n._('gdata-parsing/ignore'));
|
|
|
|
this._parsingPanelElmts.gdata_parse_next.html($.i18n._('gdata-parsing/parse-next'));
|
|
|
|
this._parsingPanelElmts.gdata_parse.html($.i18n._('gdata-parsing/parse'));
|
2013-06-27 17:25:53 +02:00
|
|
|
}
|
2018-11-21 16:24:57 +01:00
|
|
|
this._parsingPanelElmts.startOverButton.html($.i18n._('gdata-parsing/start-over'));
|
|
|
|
this._parsingPanelElmts.gdata_conf_pars.html($.i18n._('gdata-parsing/conf-pars'));
|
|
|
|
this._parsingPanelElmts.gdata_proj_name.html($.i18n._('gdata-parsing/proj-name'));
|
|
|
|
this._parsingPanelElmts.createProjectButton.html($.i18n._('gdata-parsing/create-proj'));
|
|
|
|
this._parsingPanelElmts.gdata_options.html($.i18n._('gdata-parsing/option'));
|
|
|
|
this._parsingPanelElmts.previewButton.html($.i18n._('gdata-parsing/preview-button'));
|
|
|
|
this._parsingPanelElmts.gdata_updating.html($.i18n._('gdata-parsing/updating-preview'));
|
|
|
|
this._parsingPanelElmts.gdata_discard_next.html($.i18n._('gdata-parsing/discard-next'));
|
|
|
|
this._parsingPanelElmts.gdata_discard.html($.i18n._('gdata-parsing/discard'));
|
|
|
|
this._parsingPanelElmts.gdata_limit_next.html($.i18n._('gdata-parsing/limit-next'));
|
|
|
|
this._parsingPanelElmts.gdata_limit.html($.i18n._('gdata-parsing/limit'));
|
|
|
|
this._parsingPanelElmts.gdata_store_row.html($.i18n._('gdata-parsing/store-row'));
|
|
|
|
this._parsingPanelElmts.gdata_store_cell.html($.i18n._('gdata-parsing/store-cell'));
|
2013-06-27 17:25:53 +02:00
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
if (this._parsingPanelResizer) {
|
|
|
|
$(window).unbind('resize', this._parsingPanelResizer);
|
|
|
|
}
|
2011-08-08 01:26:51 +02:00
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
this._parsingPanelResizer = function() {
|
|
|
|
var elmts = self._parsingPanelElmts;
|
|
|
|
var width = self._parsingPanel.width();
|
|
|
|
var height = self._parsingPanel.height();
|
|
|
|
var headerHeight = elmts.wizardHeader.outerHeight(true);
|
|
|
|
var controlPanelHeight = 250;
|
|
|
|
|
|
|
|
elmts.dataPanel
|
|
|
|
.css("left", "0px")
|
|
|
|
.css("top", headerHeight + "px")
|
|
|
|
.css("width", (width - DOM.getHPaddings(elmts.dataPanel)) + "px")
|
|
|
|
.css("height", (height - headerHeight - controlPanelHeight - DOM.getVPaddings(elmts.dataPanel)) + "px");
|
|
|
|
elmts.progressPanel
|
|
|
|
.css("left", "0px")
|
|
|
|
.css("top", headerHeight + "px")
|
|
|
|
.css("width", (width - DOM.getHPaddings(elmts.progressPanel)) + "px")
|
|
|
|
.css("height", (height - headerHeight - controlPanelHeight - DOM.getVPaddings(elmts.progressPanel)) + "px");
|
|
|
|
|
|
|
|
elmts.controlPanel
|
|
|
|
.css("left", "0px")
|
|
|
|
.css("top", (height - controlPanelHeight) + "px")
|
|
|
|
.css("width", (width - DOM.getHPaddings(elmts.controlPanel)) + "px")
|
|
|
|
.css("height", (controlPanelHeight - DOM.getVPaddings(elmts.controlPanel)) + "px");
|
|
|
|
};
|
|
|
|
$(window).resize(this._parsingPanelResizer);
|
|
|
|
this._parsingPanelResizer();
|
2011-08-08 01:26:51 +02:00
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
this._parsingPanelElmts.startOverButton.click(function() {
|
|
|
|
// explicitly cancel the import job
|
2012-01-29 09:01:05 +01:00
|
|
|
Refine.CreateProjectUI.cancelImportingJob(self._jobID);
|
2011-08-11 02:35:01 +02:00
|
|
|
|
|
|
|
delete self._doc;
|
|
|
|
delete self._jobID;
|
|
|
|
delete self._options;
|
|
|
|
|
|
|
|
self._createProjectUI.showSourceSelectionPanel();
|
|
|
|
});
|
|
|
|
this._parsingPanelElmts.createProjectButton.click(function() { self._createProject(); });
|
|
|
|
this._parsingPanelElmts.previewButton.click(function() { self._updatePreview(); });
|
2011-08-08 01:26:51 +02:00
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
this._parsingPanelElmts.projectNameInput[0].value = this._doc.title;
|
|
|
|
|
2011-09-15 23:40:40 +02:00
|
|
|
if (this._doc.type != 'table') {
|
|
|
|
var sheetTable = this._parsingPanelElmts.sheetRecordContainer[0];
|
|
|
|
$.each(this._options.worksheets, function(i, v) {
|
2013-09-03 18:05:06 +02:00
|
|
|
var id = 'gdata_worksheet-' + Math.round(Math.random() * 1000000);
|
2011-09-29 07:58:02 +02:00
|
|
|
|
2011-09-15 23:40:40 +02:00
|
|
|
var tr = sheetTable.insertRow(sheetTable.rows.length);
|
|
|
|
var td0 = $(tr.insertCell(0)).attr('width', '1%');
|
|
|
|
var checkbox = $('<input>')
|
2011-09-29 07:58:02 +02:00
|
|
|
.attr('id', id)
|
2011-09-15 23:40:40 +02:00
|
|
|
.attr('type', 'radio')
|
|
|
|
.attr('name', 'gdata-importing-parsing-worksheet')
|
|
|
|
.attr('sheetUrl', this.link)
|
|
|
|
.appendTo(td0);
|
|
|
|
if (i === 0) {
|
2013-09-18 21:38:12 +02:00
|
|
|
checkbox.prop("checked", true);
|
2011-09-15 23:40:40 +02:00
|
|
|
}
|
2011-09-29 07:58:02 +02:00
|
|
|
|
|
|
|
$('<label>')
|
|
|
|
.attr('for', id)
|
|
|
|
.text(this.name)
|
|
|
|
.appendTo(tr.insertCell(1));
|
|
|
|
|
|
|
|
$('<label>')
|
|
|
|
.attr('for', id)
|
|
|
|
.text(this.rows + ' rows')
|
|
|
|
.appendTo(tr.insertCell(2));
|
2011-09-15 23:40:40 +02:00
|
|
|
});
|
2011-08-11 02:35:01 +02:00
|
|
|
|
2011-09-15 23:40:40 +02:00
|
|
|
if (this._options.ignoreLines > 0) {
|
2013-09-18 21:38:12 +02:00
|
|
|
this._parsingPanelElmts.ignoreCheckbox.prop("checked", true);
|
2011-09-15 23:40:40 +02:00
|
|
|
this._parsingPanelElmts.ignoreInput[0].value = this._options.ignoreLines.toString();
|
|
|
|
}
|
|
|
|
if (this._options.headerLines > 0) {
|
2013-09-18 21:38:12 +02:00
|
|
|
this._parsingPanelElmts.headerLinesCheckbox.prop("checked", true);
|
2011-09-15 23:40:40 +02:00
|
|
|
this._parsingPanelElmts.headerLinesInput[0].value = this._options.headerLines.toString();
|
|
|
|
}
|
2011-08-11 02:35:01 +02:00
|
|
|
}
|
2011-09-15 23:40:40 +02:00
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
if (this._options.limit > 0) {
|
2013-09-18 21:38:12 +02:00
|
|
|
this._parsingPanelElmts.limitCheckbox.prop("checked", true);
|
2011-08-11 02:35:01 +02:00
|
|
|
this._parsingPanelElmts.limitInput[0].value = this._options.limit.toString();
|
|
|
|
}
|
|
|
|
if (this._options.skipDataLines > 0) {
|
2013-09-18 21:38:12 +02:00
|
|
|
this._parsingPanelElmts.skipCheckbox.prop("checked", true);
|
2011-08-11 02:35:01 +02:00
|
|
|
this._parsingPanelElmts.skipInput.value[0].value = this._options.skipDataLines.toString();
|
|
|
|
}
|
|
|
|
if (this._options.storeBlankRows) {
|
2013-09-18 21:38:12 +02:00
|
|
|
this._parsingPanelElmts.storeBlankRowsCheckbox.prop("checked", true);
|
2011-08-11 02:35:01 +02:00
|
|
|
}
|
|
|
|
if (this._options.storeBlankCellsAsNulls) {
|
2013-09-18 21:38:12 +02:00
|
|
|
this._parsingPanelElmts.storeBlankCellsAsNullsCheckbox.prop("checked", true);
|
2011-08-11 02:35:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var onChange = function() {
|
|
|
|
self._scheduleUpdatePreview();
|
|
|
|
};
|
|
|
|
this._parsingPanel.find("input").bind("change", onChange);
|
|
|
|
this._parsingPanel.find("select").bind("change", onChange);
|
|
|
|
|
|
|
|
this._createProjectUI.showCustomPanel(this._parsingPanel);
|
|
|
|
this._updatePreview();
|
2011-08-08 01:26:51 +02:00
|
|
|
};
|
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
Refine.GDataImportingController.prototype._scheduleUpdatePreview = function() {
|
|
|
|
if (this._timerID != null) {
|
|
|
|
window.clearTimeout(this._timerID);
|
|
|
|
this._timerID = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
this._timerID = window.setTimeout(function() {
|
|
|
|
self._timerID = null;
|
|
|
|
self._updatePreview();
|
|
|
|
}, 500); // 0.5 second
|
2011-08-08 01:26:51 +02:00
|
|
|
};
|
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
Refine.GDataImportingController.prototype._updatePreview = function() {
|
2011-08-08 01:26:51 +02:00
|
|
|
var self = this;
|
2011-08-11 02:35:01 +02:00
|
|
|
|
|
|
|
this._parsingPanelElmts.dataPanel.hide();
|
|
|
|
this._parsingPanelElmts.progressPanel.show();
|
|
|
|
|
2011-08-08 01:26:51 +02:00
|
|
|
$.post(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/core/importing-controller?" + $.param({
|
2011-08-08 01:26:51 +02:00
|
|
|
"controller": "gdata/gdata-importing-controller",
|
2011-08-11 02:35:01 +02:00
|
|
|
"jobID": this._jobID,
|
|
|
|
"subCommand": "parse-preview"
|
2011-08-08 01:26:51 +02:00
|
|
|
}),
|
2011-08-11 02:35:01 +02:00
|
|
|
{
|
|
|
|
"options" : JSON.stringify(this.getOptions())
|
|
|
|
},
|
|
|
|
function(result) {
|
2011-09-15 23:40:40 +02:00
|
|
|
if (result.status == "ok") {
|
2011-08-11 02:35:01 +02:00
|
|
|
self._getPreviewData(function(projectData) {
|
|
|
|
self._parsingPanelElmts.progressPanel.hide();
|
|
|
|
self._parsingPanelElmts.dataPanel.show();
|
|
|
|
|
|
|
|
new Refine.PreviewTable(projectData, self._parsingPanelElmts.dataPanel.unbind().empty());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
self._parsingPanelElmts.progressPanel.hide();
|
2011-09-16 01:52:05 +02:00
|
|
|
alert('Errors:\n' +
|
|
|
|
(result.message) ? result.message : Refine.CreateProjectUI.composeErrorMessage(job));
|
2011-08-11 02:35:01 +02:00
|
|
|
}
|
2011-08-08 01:26:51 +02:00
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
Refine.GDataImportingController.prototype._getPreviewData = function(callback, numRows) {
|
|
|
|
var self = this;
|
|
|
|
var result = {};
|
2011-08-08 01:26:51 +02:00
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
$.post(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/core/get-models?" + $.param({ "importingJobID" : this._jobID }),
|
2011-08-11 02:35:01 +02:00
|
|
|
null,
|
|
|
|
function(data) {
|
|
|
|
for (var n in data) {
|
|
|
|
if (data.hasOwnProperty(n)) {
|
|
|
|
result[n] = data[n];
|
|
|
|
}
|
2011-08-08 01:26:51 +02:00
|
|
|
}
|
|
|
|
|
2011-08-11 02:35:01 +02:00
|
|
|
$.post(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/core/get-rows?" + $.param({
|
2011-08-11 02:35:01 +02:00
|
|
|
"importingJobID" : self._jobID,
|
|
|
|
"start" : 0,
|
|
|
|
"limit" : numRows || 100 // More than we parse for preview anyway
|
|
|
|
}),
|
|
|
|
null,
|
|
|
|
function(data) {
|
|
|
|
result.rowModel = data;
|
|
|
|
callback(result);
|
|
|
|
},
|
|
|
|
"jsonp"
|
|
|
|
);
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Refine.GDataImportingController.prototype._createProject = function() {
|
|
|
|
var projectName = $.trim(this._parsingPanelElmts.projectNameInput[0].value);
|
|
|
|
if (projectName.length == 0) {
|
|
|
|
window.alert("Please name the project.");
|
|
|
|
this._parsingPanelElmts.projectNameInput.focus();
|
|
|
|
return;
|
2011-08-08 01:26:51 +02:00
|
|
|
}
|
2011-08-11 02:35:01 +02:00
|
|
|
|
|
|
|
var self = this;
|
|
|
|
var options = this.getOptions();
|
|
|
|
options.projectName = projectName;
|
|
|
|
$.post(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/core/importing-controller?" + $.param({
|
2011-08-11 02:35:01 +02:00
|
|
|
"controller": "gdata/gdata-importing-controller",
|
|
|
|
"jobID": this._jobID,
|
|
|
|
"subCommand": "create-project"
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
"options" : JSON.stringify(options)
|
|
|
|
},
|
2011-09-16 01:52:05 +02:00
|
|
|
function(o) {
|
|
|
|
if (o.status == 'error') {
|
|
|
|
alert(o.message);
|
|
|
|
} else {
|
|
|
|
var start = new Date();
|
|
|
|
var timerID = window.setInterval(
|
|
|
|
function() {
|
|
|
|
self._createProjectUI.pollImportJob(
|
|
|
|
start,
|
|
|
|
self._jobID,
|
|
|
|
timerID,
|
|
|
|
function(job) {
|
|
|
|
return "projectID" in job.config;
|
|
|
|
},
|
|
|
|
function(jobID, job) {
|
|
|
|
window.clearInterval(timerID);
|
2012-01-29 09:01:05 +01:00
|
|
|
Refine.CreateProjectUI.cancelImportingJob(jobID);
|
2011-09-16 01:52:05 +02:00
|
|
|
document.location = "project?project=" + job.config.projectID;
|
|
|
|
},
|
|
|
|
function(job) {
|
|
|
|
alert(Refine.CreateProjectUI.composeErrorMessage(job));
|
|
|
|
}
|
|
|
|
);
|
2011-08-11 02:35:01 +02:00
|
|
|
},
|
2011-09-16 01:52:05 +02:00
|
|
|
1000
|
|
|
|
);
|
2018-11-21 16:24:57 +01:00
|
|
|
self._createProjectUI.showImportProgressPanel($.i18n._('gdata-import/creating'), function() {
|
2011-09-16 01:52:05 +02:00
|
|
|
// stop the timed polling
|
|
|
|
window.clearInterval(timerID);
|
2011-08-11 02:35:01 +02:00
|
|
|
|
2011-09-16 01:52:05 +02:00
|
|
|
// explicitly cancel the import job
|
2012-01-29 09:01:05 +01:00
|
|
|
Refine.CreateProjectUI.cancelImportingJob(jobID);
|
2011-08-11 02:35:01 +02:00
|
|
|
|
2011-09-16 01:52:05 +02:00
|
|
|
self._createProjectUI.showSourceSelectionPanel();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2011-08-08 01:26:51 +02:00
|
|
|
};
|