mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-25 23:44:54 +01:00
Fix error handling for Import Operation.
Remove some old icons
This commit is contained in:
parent
907f31c030
commit
6f923656ee
@ -35,9 +35,8 @@ public class BaseController {
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ResponseBody
|
||||
public String handleClientErrors(@NotNull Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ex.getMessage();
|
||||
public RestErrors handleClientErrors(@NotNull IllegalArgumentException ex) {
|
||||
return new RestErrors(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
|
@ -76,7 +76,6 @@ public class MindmapController extends BaseController {
|
||||
return new ModelAndView("transformViewWise", values);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}", produces = {"application/freemind"}, params = {"download=mm"})
|
||||
@ResponseBody
|
||||
public ModelAndView retrieveDocumentAsFreemind(@PathVariable int id) throws IOException {
|
||||
@ -105,6 +104,14 @@ public class MindmapController extends BaseController {
|
||||
return new ModelAndView("mapsView", "list", restMindmapList);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/maps/{id}/history", produces = {"application/json", "text/html", "application/xml"})
|
||||
public ModelAndView retrieveHistory(@PathVariable int id) throws IOException {
|
||||
final User user = com.wisemapping.security.Utils.getUser();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/document", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void updateDocument(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException {
|
||||
@ -302,6 +309,7 @@ public class MindmapController extends BaseController {
|
||||
final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml);
|
||||
mindMap = importer.importMap(title, "", stream);
|
||||
} catch (ImporterException e) {
|
||||
// @Todo: This should be an illegal argument exception. Review the all the other cases.
|
||||
throw buildValidationException("xml", "The selected file does not seems to be a valid Freemind or WiseMapping file. Contact support in case the problem persists.");
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ import java.util.*;
|
||||
public class RestErrors {
|
||||
@JsonIgnore
|
||||
private Errors errors;
|
||||
|
||||
@JsonIgnore
|
||||
private List<String> globalErrors;
|
||||
|
||||
@JsonIgnore
|
||||
MessageSource messageSource;
|
||||
|
||||
@ -38,9 +42,14 @@ public class RestErrors {
|
||||
|
||||
this.errors = errors;
|
||||
this.messageSource = messageSource;
|
||||
this.globalErrors = this.processGlobalErrors(errors, messageSource);
|
||||
}
|
||||
|
||||
public List<String> getGlobalErrors() {
|
||||
public RestErrors(@NotNull String errorMsg) {
|
||||
globalErrors.add(errorMsg);
|
||||
}
|
||||
|
||||
private List<String> processGlobalErrors(@NotNull Errors errors, @NotNull MessageSource messageSource) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
final List<ObjectError> globalErrors = errors.getGlobalErrors();
|
||||
for (ObjectError globalError : globalErrors) {
|
||||
@ -49,6 +58,10 @@ public class RestErrors {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> getGlobalErrors() {
|
||||
return globalErrors;
|
||||
}
|
||||
|
||||
public void setGlobalErrors(List<String> list) {
|
||||
// Implemented only for XML serialization contract ...
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 778 B |
Binary file not shown.
Before Width: | Height: | Size: 612 B |
@ -445,6 +445,10 @@ $(function() {
|
||||
showEmbeddedDialog("c/maps/import", 'import-dialog-modal', true);
|
||||
});
|
||||
|
||||
$("#shareBtn").click(function() {
|
||||
showEmbeddedDialog("c/maps/{mapId}/share", 'share-dialog-modal', true);
|
||||
});
|
||||
|
||||
|
||||
var showEmbeddedDialog = function(urlTemplate, dialogElemId, ignore) {
|
||||
var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds();
|
||||
|
@ -9,12 +9,10 @@
|
||||
<base href="${pageContext.request.contextPath}/"/>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css"/>
|
||||
<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>
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap-responsive.min.css"/>
|
||||
|
||||
|
||||
<body>
|
||||
<div style="padding-top:20px">
|
||||
<tiles:insert name="body"/>
|
||||
|
@ -72,7 +72,14 @@
|
||||
inputField.parent().addClass('error');
|
||||
}
|
||||
}
|
||||
|
||||
var globalErrors = errors.globalErrors;
|
||||
if (globalErrors) {
|
||||
for (var error in globalErrors) {
|
||||
// Mark the field with errors ...
|
||||
$("#dialogMainForm").find(".errorMessage").text(error).addClass("alert alert-error");
|
||||
inputField.parent().addClass('error');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(errorThrown);
|
||||
console.log(jqXHR);
|
||||
|
@ -279,6 +279,22 @@
|
||||
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Share Dialog Config -->
|
||||
<div id="share-dialog-modal" class="modal fade" style="display: none">
|
||||
<div class="modal-header">
|
||||
<button class="close" data-dismiss="modal">x</button>
|
||||
<h3>Share</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary btn-accept" data-loading-text="Saving ..">Accept</button>
|
||||
<button class="btn btn-cancel" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,39 +1,209 @@
|
||||
<%@ include file="/jsp/init.jsp" %>
|
||||
<style type="text/css">
|
||||
#sharingContainer {
|
||||
height: 300px;
|
||||
width: 300px;
|
||||
overflow: scroll;
|
||||
height: 180px;
|
||||
width: 100%;
|
||||
overflow-y: scroll;
|
||||
border-top: 1px solid #d3d3d3;
|
||||
border-bottom: 1px solid #d3d3d3;
|
||||
}
|
||||
|
||||
#sharingContainer table {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
#collabEmails {
|
||||
float: left;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
#roleBtn {
|
||||
float: left;
|
||||
margin: 0px 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<p>Who has access</p>
|
||||
<p><strong>Who has access:</strong></p>
|
||||
|
||||
<div id="sharingContainer">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Email</td>
|
||||
<td><a href="">Action</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<table class="table" id="collabsTable">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<form method="post" id="dialogMainForm" action="#" class="well form-inline">
|
||||
<label for="collabEmails" class="control-label">Add People:
|
||||
<input type="text" id="collabEmails" name="collabEmail" placeholder="Enter collaborators emails separared by comas."/>
|
||||
</label>
|
||||
</form>
|
||||
<div class="well">
|
||||
<div id="errorMsg" class="alert alert-error"></div>
|
||||
<p>Add People: </p>
|
||||
<input type="text" id="collabEmails" name="collabEmails"
|
||||
placeholder="Enter collaborators emails separared by comas."/>
|
||||
|
||||
<div class="btn-group" id="roleBtn">
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Can edit
|
||||
<span class="caret"> </span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" data-role="editor" id="shareRole">
|
||||
<li><a href="#" data-role="editor">Can edit</a></li>
|
||||
<li><a href="#" data-role="viewer">Can view</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<button id="addBtn" class="btn btn-primary">Add</button>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$("#errorMsg").hide();
|
||||
|
||||
function onClickShare(aElem) {
|
||||
var role = $(aElem).attr('data-role');
|
||||
var roleDec = role == 'viewer' ? "Can view" : "Can edit";
|
||||
var btnElem = $(aElem).parent().parent().parent().find(".dropdown-toggle");
|
||||
btnElem.text(roleDec).append(' <span class="caret"> </span>');
|
||||
return role;
|
||||
}
|
||||
|
||||
function addCollaborator(email, role) {
|
||||
// Add row to the table ...
|
||||
var tableElem = $("#collabsTable");
|
||||
var rowTemplate = '\
|
||||
<tr data-collab="{email}" data-role="{role}">\
|
||||
<td>{email}</td>\
|
||||
<td>\
|
||||
<div class="btn-group">\
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#""></a>\
|
||||
<ul class="dropdown-menu">\
|
||||
<li><a href="#" data-role="editor">Can edit</a></li>\
|
||||
<li><a href="#" data-role="viewer">Can view</a></li>\
|
||||
</ul>\
|
||||
</div>\
|
||||
</td>\
|
||||
<td><a href="#">x</a></td>\
|
||||
</tr>';
|
||||
|
||||
var rowStr = rowTemplate.replace(/{email}/g, email);
|
||||
rowStr = rowStr.replace(/{role}/g, role);
|
||||
var elem = tableElem.append(rowStr);
|
||||
|
||||
// Register change role event ...
|
||||
var rowElem = $("#collabsTable tr:last");
|
||||
$(rowElem.find(".dropdown-menu a").click(function() {
|
||||
var role = onClickShare(this);
|
||||
rowElem.attr('data-role', role);
|
||||
event.preventDefault();
|
||||
}));
|
||||
rowElem.find('.dropdown-menu a[data-role="' + role + '"]').click();
|
||||
|
||||
// Register remove event ...
|
||||
rowElem.find("td:last a").click(function(event) {
|
||||
var email = rowElem.attr('data-collab');
|
||||
removeCollab(email);
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
var removeCollab = function(email) {
|
||||
// Remove html entry ...
|
||||
$('#collabsTable tr[data-collab="' + email + '"]').detach();
|
||||
};
|
||||
|
||||
$(function() {
|
||||
var loadedCollabs = [
|
||||
{email:'paulo1@pveiga.com.ar',role:'viewer'},
|
||||
{email:'paulo2@pveiga.com.ar',role:'editor'},
|
||||
{email:'paulo3@pveiga.com.ar',role:'editor'}
|
||||
];
|
||||
|
||||
// Init table will all values ...
|
||||
for (var i = 0; i < loadedCollabs.length; i++) {
|
||||
var collab = loadedCollabs[i];
|
||||
addCollaborator(collab.email, collab.role);
|
||||
}
|
||||
});
|
||||
|
||||
$("#addBtn").click(function(event) {
|
||||
var i,email;
|
||||
var emailsStr = $("#collabEmails").val();
|
||||
var role = $("#shareRole").attr('data-role');
|
||||
|
||||
// Clear previous state ...
|
||||
$("#errorMsg").text("").hide();
|
||||
|
||||
// Split emails ...
|
||||
var valid = true;
|
||||
if (emailsStr.length > 0) {
|
||||
var emails = jQuery.grep(emailsStr.split(/[;|,|\s]/), function(val) {
|
||||
return val.length > 0
|
||||
});
|
||||
|
||||
var model = buildCollabModel();
|
||||
for (i = 0; i < emails.length; i++) {
|
||||
email = emails[i];
|
||||
if (!isValidEmailAddress(email)) {
|
||||
reportError("Invalid email address:" + email);
|
||||
valid = false;
|
||||
}
|
||||
|
||||
// Is there a collab with the same email ?
|
||||
var useExists = jQuery.grep(model,
|
||||
function(val) {
|
||||
return val.email == email;
|
||||
}).length > 0;
|
||||
if (useExists) {
|
||||
reportError(email + " is already in the shared list");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
reportError("Emails address can not be empty");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
|
||||
if (valid) {
|
||||
// Emails are valid, add them as rows ...
|
||||
$("#collabEmails").val("");
|
||||
for (i = 0; i < emails.length; i++) {
|
||||
email = emails[i];
|
||||
addCollaborator(email, role);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// Register change event ...
|
||||
$("#shareRole a").click(function() {
|
||||
var role = onClickShare(this);
|
||||
$(this).parent().attr('data-role', role);
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
function isValidEmailAddress(emailAddress) {
|
||||
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
|
||||
return pattern.test(emailAddress);
|
||||
}
|
||||
|
||||
function reportError(msg) {
|
||||
$('#errorMsg').show();
|
||||
$('#errorMsg').append("<p>" + msg + "</p>");
|
||||
}
|
||||
|
||||
function buildCollabModel() {
|
||||
return $('#collabsTable tr').map(function() {
|
||||
return {
|
||||
email: $(this).attr('data-collab'),
|
||||
role: $(this).attr('data-role')
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Hook for interaction with the main parent window ...
|
||||
var submitDialogForm = function() {
|
||||
$('#dialogMainForm').submit();
|
||||
|
||||
console.log(buildCollabModel());
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user