Add wisemapping support for import.

This commit is contained in:
Paulo Gustavo Veiga
2012-06-06 00:48:46 -03:00
parent 88b0efa859
commit 79b009e29e
23 changed files with 214 additions and 339 deletions

View File

@@ -2,6 +2,15 @@
<%@ include file="/jsp/init.jsp" %>
<script type="text/javascript" language="javascript">
$(function() {
$('.btn-primary').click(function() {
$(this).button("loading");
});
});
</script>
<div id="loginContent">
<div class="loginNews">
<h1>What is New: </h1>
@@ -38,8 +47,9 @@
</c:if>
<div class="form-inline">
<input type="submit" class="btn btn-primary" value="<spring:message code="SIGN_IN"/>"
data-toggle="button">&nbsp;&nbsp;&nbsp;
<button class="btn btn-primary" data-loading-text="<spring:message code="SIGN_IN"/> ...">
<spring:message code="SIGN_IN"/></button>
&nbsp;&nbsp;&nbsp;
<input type="checkbox" id="rememberme" name="_spring_security_remember_me"/>
<label for="rememberme"><spring:message code="REMEMBER_ME"/></label>
</div>

View File

@@ -1,68 +1,98 @@
<%@ include file="/jsp/init.jsp" %>
<div class="fform">
<h1>
<spring:message code="${requestScope.title}"/>
</h1>
<div id="messagePanel" class="alert alert-error">
<p><spring:message code="${requestScope.details}"/></p>
</div>
<form method="post" enctype="multipart/form-data" action="#">
<div>
<p class="well"><spring:message code="IMPORT_MINDMAP_INFO"/></p>
<form method="POST" enctype="multipart/form-data" action="#" id="dialogMainForm" class="form-horizontal">
<fieldset>
<label for="title"><spring:message code="NAME"/></label>
<input type="text" id="title" required="required"/>
<div class="control-group">
<label for="mapFile" class="control-label"><spring:message code="MIND_FILE"/>: </label>
<input type="file" name="mapFile" id="mapFile" required="required" class="control"/>
</div>
<div class="control-group">
<label for="title" class="control-label"><spring:message code="NAME"/>: </label>
<input type="text" id="title" required="required" placeholder="Name of the new map to create"
class="control"/>
</div>
<div class="control-group">
<label for="description"><spring:message code="DESCRIPTION"/></label>
<input type="text" name="description" id="description"/>
<label for="description" class="control-label"><spring:message code="DESCRIPTION"/>: </label>
<textarea type="text" name="description" id="description"
placeholder="Some description for your map" class="control"></textarea>
</div>
<label><spring:message code="DESCRIPTION"/> </label>
<input type="radio" name="type" value="mm"/> Freemind (0.9)
<input type="radio" name="type" value="wxml"/> WiseMapping
<label for="mapFile"><spring:message code="FREE_MIND_FILE"/></label>
<input type="file" name="mapFile" id="mapFile"/>
</fieldset>
<input type="button" id="acceptButton" value="<spring:message code="IMPORT"/>" class="btn btn-primary"/>
<input type="button" id="cancelButton" value="<spring:message code="CANCEL"/>" class="btn">
</form>
</div>
<script type="text/javascript">
// @Todo: Pending: report errors, manage corrupted mapsmanage case,escape url parameters, import with same title tries to save in post XML, explanation.
$('#messagePanel').hide();
// Save status on click ...
var contentType = null;
var fileContent = null;
$('#cancelButton').click(function() {
window.location = '/c/maps/';
});
$('#dialogMainForm').submit(function(event) {
// Load form parameters ...
var title = $('#dialogMainForm #title').attr('value');
title = title == undefined ? "" : title;
$('#acceptButton').click(function(event) {
var description = $('#dialogMainForm #description').attr('value');
description = description == undefined ? "" : description;
// http://www.html5rocks.com/en/tutorials/file/dndfiles/
var content;
if (window.FileReader) {
reader = new FileReader();
reader.onloadend = function (e) {
content = e.target.result;
};
reader.readAsDataURL(file);
}
// Save status on click ...
jQuery.ajax("service/maps?title=" + encodeURI(title) + "&description=" + encodeURI(description),
{
async:false,
data: fileContent,
type: 'POST',
dataType: 'json',
contentType:contentType,
success : function(data, textStatus, jqXHR) {
var resourceId = jqXHR.getResponseHeader("ResourceId");
window.location = "c/maps/" + resourceId + "/edit";
},
error: function(jqXHR, textStatus, errorThrown) {
$('#messagePanel').text(textStatus);
}
});
event.preventDefault();
});
jQuery.ajax("service/maps", {
async:false,
dataType: 'application/freemind',
data: "",
type: 'PUT',
contentType:"text/plain",
success : function(data, textStatus, jqXHR) {
},
error: function(jqXHR, textStatus, errorThrown) {
}
$('#dialogMainForm #mapFile').change(function(event) {
var file = event.target.files[0];
var reader = new FileReader();
var title = file.name;
title = title.substring(0, title.lastIndexOf("."));
$('#dialogMainForm #title').attr('value', jQuery.camelCase(title));
// Closure to capture the file information.
reader.onload = (function(event) {
fileContent = event.target.result;
contentType = file.name.lastIndexOf(".wxml") != -1 ? "application/xml" : "application/freemind";
});
// Read in the image file as a data URL.
reader.readAsBinaryString(file);
});
// Hook for interaction with the main parent window ...
var submitDialogForm = function() {
$('#dialogMainForm').submit();
}
</script>

View File

@@ -40,6 +40,7 @@
<div id="mindmapListContainer">
<div id="messagesPanel" class="alert alert-error alert-block fade in hide" style="margin-top: 10px">
<strong><spring:message code="UNEXPECTED_ERROR"/></strong>
<p><spring:message code="UNEXPECTED_ERROR_SERVER_ERROR"/></p>
<div></div>
@@ -264,6 +265,20 @@
</div>
</div>
<!-- Export Dialog Config -->
<div id="import-dialog-modal" class="modal fade" style="display: none">
<div class="modal-header">
<button class="close" data-dismiss="modal">x</button>
<h3>Import</h3>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button class="btn btn-primary btn-accept" data-loading-text="Importing...">Import</button>
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</body>
</html>

View File

@@ -28,7 +28,7 @@
<script type="text/javascript" language="javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script>
<script src="js/less.js" type="text/javascript"></script>
</head>
<body>