Consolidated the two different forms for public URLs together into one. Made sure we could still import public docs while signed in.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2377 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2011-11-17 01:32:28 +00:00
parent c07046f542
commit 39c6ae1b80
5 changed files with 55 additions and 62 deletions

View File

@ -59,12 +59,13 @@ Refine.GDataSourceUI.prototype.attachUI = function(body) {
self._elmts.signinPage.show(); self._elmts.signinPage.show();
}); });
var importURL1 = function(evt) { this._elmts.urlNextButton.click(function(evt) {
if ($.trim(self._elmts.urlInput1[0].value).length === 0) { var url = $.trim(self._elmts.urlInput[0].value);
if (url.length === 0) {
window.alert("You must specify a web address (URL) to import."); window.alert("You must specify a web address (URL) to import.");
} else { } else {
var doc={} var doc = { isPublic: true };
doc.docSelfLink = self._elmts.urlInput1[0].value; doc.docSelfLink = url;
if (doc.docSelfLink.contains('spreadsheet')) { // TODO: fragile? if (doc.docSelfLink.contains('spreadsheet')) { // TODO: fragile?
doc.type = 'spreadsheet'; doc.type = 'spreadsheet';
} else { } else {
@ -72,26 +73,7 @@ Refine.GDataSourceUI.prototype.attachUI = function(body) {
} }
self._controller.startImportingDocument(doc); self._controller.startImportingDocument(doc);
} }
} });
// TODO: Consolidate these two URL input forms
var importURL2 = function(evt) {
if ($.trim(self._elmts.urlInput2[0].value).length === 0) {
window.alert("You must specify a web address (URL) to import.");
} else {
var doc={}
doc.docSelfLink = self._elmts.urlInput2[0].value;
if (doc.docSelfLink.contains('spreadsheet')) { // TODO: fragile?
doc.type = 'spreadsheet';
} else {
doc.type = 'table';
}
self._controller.startImportingDocument(doc);
}
}
this._elmts.urlNextButton1.click(importURL1);
this._elmts.urlNextButton2.click(importURL2);
this._body.find('.gdata-page').hide(); this._body.find('.gdata-page').hide();
this._elmts.signinPage.show(); this._elmts.signinPage.show();

View File

@ -1,31 +1,31 @@
<div> <div>
<div bind="publicDocsPanel" class="gdata-panel">
<h1>Public Documents</h1>
<div class="grid-layout layout-tighter"><table>
<tr><td colspan="2">Import a <em>public</em> Google Spreadsheet or Fusion Table by its URL:</td></tr>
<tr bind="urlRow">
<td><input bind="urlInput" name="download" class="default-importing-web-url" /></td>
<td><button bind="urlNextButton" class="button button-primary" type="button">Next &raquo;</button></td>
</tr>
</table></div>
</div>
<div bind="authorizedDocsPanel" class="gdata-panel">
<h1>Authorized Documents</h1>
<div bind="signinPage" class="gdata-page"> <div bind="signinPage" class="gdata-page">
<p>Please <button class="gdata-signin button button-primary">sign in and authorize</button> <p>Please <button class="gdata-signin button button-primary">sign in and authorize</button>
access to your Google data.</p></tr> access to your Google data.</p>
<form bind="form"><div class="grid-layout layout-normal"><table>
<tr><td colspan="2">Or enter web address (URL) of a <em>public</em> Google Spreadsheet or Fusion Table below and click Next:</td></tr>
<tr bind="urlRow"><td colspan="2"><input bind="urlInput1" name="download" class="default-importing-web-url" /></td></tr>
<tr bind="buttons">
<td><button bind="urlNextButton1" class="button button-primary" type="button">Next &raquo;</button></td>
</tr>
</table></div></form>
</div> </div>
<div bind="progressPage" class="gdata-page"> <div bind="progressPage" class="gdata-page">
<p><img src="images/large-spinner.gif" /> Retrieving Google Docs documents ...</p> <p><img src="images/large-spinner.gif" /> Retrieving Google Docs documents ...</p>
</div> </div>
<div bind="listingPage" class="gdata-page grid-layout layout-full layout-normal"><table> <div bind="listingPage" class="gdata-page grid-layout layout-normal"><table>
<tr> <tr>
<td>Google Docs documents</td> <td width="%"><button class="gdata-signout button">sign out</button></td>
<td style="text-align: center;"><button class="gdata-signin button">re-sign in</button> with another account</td> <td><button class="gdata-signin button">re-sign in</button> with another account</td>
<td style="text-align: right;"><button class="gdata-signout button">sign out</button></td>
</tr> </tr>
<tr><td colspan="2">Click one of the documents below or enter the web address (URL) of a <em>public</em> Google Spreadsheet or Fusion Table and click "Next":</td></tr> <tr><td colspan="2"><div bind="listingContainer" class="grid-layout layout-tight gdata-document-container"></div></td></tr>
<tr bind="urlRow"><td colspan="2">
<form bind="form">
<input bind="urlInput2" name="download" class="default-importing-web-url" /></td>
</form>
<td bind="buttons"><button bind="urlNextButton2" class="button button-primary" type="button">Next &raquo;</button></td>
</tr>
<tr><td colspan="3"><div bind="listingContainer" class="grid-layout layout-tight gdata-document-container"></div></td></tr>
</table></div> </table></div>
</div> </div>
</div>

View File

@ -57,7 +57,8 @@ Refine.GDataImportingController.prototype.startImportingDocument = function(doc)
"controller": "gdata/gdata-importing-controller", "controller": "gdata/gdata-importing-controller",
"subCommand": "initialize-parser-ui", "subCommand": "initialize-parser-ui",
"docUrl": doc.docSelfLink, "docUrl": doc.docSelfLink,
"docType": doc.type "docType": doc.type,
"isPublic": (doc.isPublic)
}), }),
null, null,
function(data2) { function(data2) {

View File

@ -33,6 +33,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@import-less url("theme.less"); @import-less url("theme.less");
.gdata-panel {
margin-bottom: 2em;
}
.gdata-panel > h1 {
font-size: 130%;
margin-bottom: 0.5em;
}
.gdata-extension-signin-iframe { .gdata-extension-signin-iframe {
border: 1px solid #aaa; border: 1px solid #aaa;
width: 100%; width: 100%;

View File

@ -195,10 +195,12 @@ public class GDataImportingController implements ImportingController {
HttpServletRequest request, HttpServletResponse response, Properties parameters) HttpServletRequest request, HttpServletResponse response, Properties parameters)
throws ServletException, IOException { throws ServletException, IOException {
String token = TokenCookie.getToken(request); // authorization token, if logged in
String type = parameters.getProperty("docType"); String type = parameters.getProperty("docType");
String urlString = parameters.getProperty("docUrl"); String urlString = parameters.getProperty("docUrl");
boolean isPublic = "true".equals(parameters.getProperty("isPublic"));
String token = isPublic ? null : TokenCookie.getToken(request); // authorization token, if logged in
URL url = new URL(urlString); URL url = new URL(urlString);
try { try {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();