From fdc4a20667fff080e11149babf4544a5510bea17 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 20 May 2012 21:46:55 -0300 Subject: [PATCH] Firt version of publish dialog. --- .../controller/MindmapPublishController.java | 69 ------ .../ncontroller/MindmapController.java | 11 +- .../wisemapping/rest/MindmapController.java | 20 +- .../rest/model/RestMindmapInfo.java | 15 ++ .../webapp/WEB-INF/classes/log4j.properties | 4 +- .../WEB-INF/classes/messages.properties | 11 +- .../webapp/WEB-INF/wisemapping-servlet.xml | 7 - wise-webapp/src/main/webapp/css/mymaps.less | 2 - wise-webapp/src/main/webapp/js/mymaps.js | 32 ++- .../src/main/webapp/jsp/mindmapDetail.jsp | 43 ++-- .../src/main/webapp/jsp/mindmapList.jsp | 65 +++--- .../src/main/webapp/jsp/mindmapPublish.jsp | 215 +++++++++--------- wise-webapp/src/test/sql/hsql/test-data.sql | 2 +- 13 files changed, 223 insertions(+), 273 deletions(-) delete mode 100644 wise-webapp/src/main/java/com/wisemapping/controller/MindmapPublishController.java diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapPublishController.java b/wise-webapp/src/main/java/com/wisemapping/controller/MindmapPublishController.java deleted file mode 100644 index 18999eda..00000000 --- a/wise-webapp/src/main/java/com/wisemapping/controller/MindmapPublishController.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -package com.wisemapping.controller; - -import com.wisemapping.exceptions.WiseMappingException; -import com.wisemapping.model.MindMap; -import com.wisemapping.model.User; -import com.wisemapping.security.Utils; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class MindmapPublishController extends BaseMultiActionController { - - protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { - - final MindMap mindmap = this.getMindmapFromRequest(httpServletRequest); - if (mindmap == null) { - throw new IllegalStateException("Map could not be found"); - } - - return new ModelAndView("mindmapPublish", "mindmap", mindmap); - } - - public ModelAndView save(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws WiseMappingException { - - final MindMap mindmap = this.getMindmapFromRequest(httpServletRequest); - if (mindmap == null) { - throw new IllegalStateException("Map could not be found"); - } - - User user = Utils.getUser(); - if (!mindmap.getOwner().equals(user)) { - throw new IllegalStateException("No enought right to execute this operation"); - } - - - final String publicViewStr = httpServletRequest.getParameter("publicView"); - boolean publicView = Boolean.valueOf(publicViewStr); - - if (mindmap.isPublic() != publicView) { - mindmap.setPublic(publicView); - getMindmapService().updateMindmap(mindmap, false); - } - - - return new ModelAndView("closeDialog"); - } - - -} diff --git a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java index 3d3cbfb7..e27634bc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/ncontroller/MindmapController.java @@ -49,9 +49,16 @@ public class MindmapController { return view; } + @RequestMapping(value = "map/{id}/publish") + public ModelAndView showPublishPage(@PathVariable int id) { + final MindMap mindmap = findMindmap(id); + final ModelAndView view = new ModelAndView("mindmapPublish", "mindmap", mindmap); + view.addObject("user", Utils.getUser()); + return view; + } + @RequestMapping(value = "map/{id}/edit") - public ModelAndView editMap(@PathVariable int id, @NotNull HttpServletRequest request) - { + public ModelAndView editMap(@PathVariable int id, @NotNull HttpServletRequest request) { ModelAndView view; final UserAgent userAgent = UserAgent.create(request); if (userAgent.needsGCF()) { diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 48d83031..076ed514 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -110,10 +110,26 @@ public class MindmapController extends BaseController { updateMindmap(true, mindMap, user); } + @RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/publish", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"}) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void changeMapPublish(@RequestBody String value, @PathVariable int id) throws WiseMappingException { + + final MindMap mindMap = mindmapService.getMindmapById(id); + final User user = Utils.getUser(); + + if (!mindMap.getOwner().equals(user)) { + throw new IllegalArgumentException("No enough to execute this operation"); + } + + // Update map status ... + mindMap.setPublic(Boolean.parseBoolean(value)); + updateMindmap(true, mindMap, user); + + } @RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}") @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void updateMap(@PathVariable int id) throws IOException, WiseMappingException { + public void updateMap( @PathVariable int id) throws IOException, WiseMappingException { final User user = Utils.getUser(); final MindMap mindmap = mindmapService.getMindmapById(id); mindmapService.removeMindmap(mindmap, user); @@ -187,7 +203,7 @@ public class MindmapController extends BaseController { @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"}) @ResponseStatus(value = HttpStatus.CREATED) public void copyMap(@RequestBody RestMindmapInfo restMindmap, @PathVariable int id, @NotNull HttpServletResponse response) throws IOException, WiseMappingException { - // Validate ... + // Validate ... final BindingResult result = new BeanPropertyBindingResult(restMindmap, ""); new MapInfoValidator(mindmapService).validate(restMindmap.getDelegated(), result); if (result.hasErrors()) { diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java index 63864712..ec7ab603 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapInfo.java @@ -70,6 +70,15 @@ public class RestMindmapInfo { return mindmap.getCreator(); } + public String getOwnerEmail() { + return mindmap.getOwner().getEmail(); + } + + public String getOwner() { + final User owner = mindmap.getOwner(); + return owner.getUsername(); + } + public String getLastModifierUser() { return mindmap.getLastModifierUser(); } @@ -109,6 +118,12 @@ public class RestMindmapInfo { public void setLastModifierUser(String value) { } + public void setOwnerEmail(String value) { + } + + public void setOwner(String value) { + } + @JsonIgnore public MindMap getDelegated() { return this.mindmap; diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties index 8eaa1dff..8abef6ba 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/log4j.properties @@ -1,7 +1,7 @@ log4j.rootLogger=WARN, stdout, R log4j.logger.com.wisemapping=WARN,stdout,R -log4j.logger.org.springframework=DEBUG,stdout,R -log4j.logger.org.codehaus.jackson=DEBUG,stdout,R +log4j.logger.org.springframework=WARN,stdout,R +log4j.logger.org.codehaus.jackson=WARN,stdout,R # Stdout logger � log4j.appender.stdout=org.apache.log4j.ConsoleAppender diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties index 03aa614b..ae6a9f4f 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages.properties @@ -115,8 +115,8 @@ VIEWER=Viewer PRIVATE=Private PUBLIC=Public SHARED=Shared -ONLY_VIEW_PRIVATE = This document can be viewed by you only. -ALL_VIEW_PUBLIC = This document can be viewed by any user. +ONLY_VIEW_PRIVATE = This mindmap can be viewed by you only. +ALL_VIEW_PUBLIC = This mindmap can be viewed by any user. EMAILS_ADRESSES = E-mails Addresses CURRENT_CONTACTS = Current Contacts @@ -128,7 +128,7 @@ NEW_MAP_MSG=Fill all the fields to create a new map TAG=Tag PUBLISH=Publish PUBLISH_MSG = What about using your maps in sites and blogs? -PUBLISH_DETAILS=By publishing the map you make it visible to everyone on the Internet. Copy the code snippets below to integrate it into your website or blog. +PUBLISH_DETAILS=By publishing the map you make it visible to everyone on the Internet. DETAIL=Detail RECENT_FILES=Recent Maps MINDMAP_DETAIL = Mind Map Detail @@ -180,7 +180,8 @@ MAX_CHARACTER_SIZE= Maximum allowed message length of 512 characters. PUBLISH_MAP_TO_INTERNET=Publish map to the Internet URL=URL DIRECT_LINK=Direct Link -BLOG_INCLUSION=For inclusion in blogs and web pages +BLOG_INCLUSION=You can customize the code snippet to embed this map on your blog or website. Make sure you enter the correct dimensions of the content area of your blog so that the map fits nicely +BLOG_SNIPPET=Copy this snippet of code to embed in your blog or page OPEN=Open OPEN_MSG=Open map for edition @@ -303,3 +304,5 @@ BROWSER_NOT_SUPPOERTED= Current Browser is not supported. CHECK_BROWSERS= You can check supported browser at NO_PRODUCTION_DATABASE_CONFIGURED=Note: Although HSQLDB is bundled with WiseMapping by default during the installation, we do not recommend this database for production use. Please consider using MySQL 5.5 instead. You can find more information how to configure MySQL IMPORT=Import + +EMBEDDED_MAP_SIZE=* Note: You can change embedded map size modifying 'height' and 'width' style properties. You can also adjust the zoom factor modifying 'zoom' parameter from the URL. diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index f28b204d..d89d2494 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -52,12 +52,6 @@ - - - - - - @@ -205,7 +199,6 @@ changePasswordController cookerController settingsController - publishController editProfileController tagsController publicView diff --git a/wise-webapp/src/main/webapp/css/mymaps.less b/wise-webapp/src/main/webapp/css/mymaps.less index 6d2fe77d..0f63f622 100644 --- a/wise-webapp/src/main/webapp/css/mymaps.less +++ b/wise-webapp/src/main/webapp/css/mymaps.less @@ -159,6 +159,4 @@ input#selectAll { width:100%; height:50px; white-space:nowrap; - } - diff --git a/wise-webapp/src/main/webapp/js/mymaps.js b/wise-webapp/src/main/webapp/js/mymaps.js index b44f700b..a55cf28a 100644 --- a/wise-webapp/src/main/webapp/js/mymaps.js +++ b/wise-webapp/src/main/webapp/js/mymaps.js @@ -31,7 +31,7 @@ jQuery.fn.dataTableExt.selectAllMaps = function() { $(this).prop("checked", false); }); } - updateToolbar(); + updateStatus(); }; jQuery.fn.dataTableExt.getSelectedMapsIds = function() { @@ -107,11 +107,6 @@ jQuery.fn.dialogForm = function(options) { error: function(jqXHR, textStatus, errorThrown) { if (jqXHR.status == 400) { var errors = JSON.parse(jqXHR.responseText); - // Clean previous marks .... - $("#" + containerId + ' input').each(function(index, elem) { - $(elem).removeClass("ui-state-error"); - }); - // Mark fields with errors ... var fieldErrors = errors.fieldErrors; if (fieldErrors) { @@ -145,27 +140,30 @@ jQuery.fn.dialogForm = function(options) { // Update toolbar events ... -function updateToolbar() { +function updateStatus() { + // Mark column row selection values ... $("#mindmapListTable tbody input:checked").parent().parent().addClass('row-selected'); $("#mindmapListTable tbody input:not(:checked)").parent().parent().removeClass('row-selected'); - var inputs = $("#mindmapListTable tbody input:checked"); - + // Update toolbar ... $("#buttonsToolbar .act-multiple").hide(); $("#buttonsToolbar .act-single").hide(); + var tableElem = $('#mindmapListTable'); + var selectedRows = tableElem.dataTableExt.getSelectedRows(); - console.log($("#buttonsToolbar .act-multiple")); - - - - - - if (inputs.length > 0) { - if (inputs.length == 1) { + if (selectedRows.length > 0) { + if (selectedRows.length == 1) { $("#buttonsToolbar .act-single").show(); $("#buttonsToolbar .act-multiple").show(); + + // Can be executed by the owner ? + var rowData = tableElem.dataTable().fnGetData(selectedRows[0]); + if (rowData.ownerEmail != principalEmail) { + $("#buttonsToolbar #publishBtn").hide(); + $("#buttonsToolbar #shareBtn").hide(); + } } else { $("#buttonsToolbar .act-multiple").show(); } diff --git a/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp b/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp index 4e8fb63a..5f15d9b3 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapDetail.jsp @@ -37,38 +37,27 @@
-
    - - -
  • : -
  • -
  • <: - + +
      +

      + +
    • : +
    • -
    • : - -
    • : - +
    • +
      <iframe style="border:0;width:600px;height:400px;border: 1px solid black" src="http://www.wisemapping.com/c/embeddedView.htm?mapId=${wisemapDetail.id}&amzoom=1"></iframe>
    • - - -
    • : -
    • -
      - -
    +
+ + + +

+
+
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp index 715fc010..08c6a113 100644 --- a/wise-webapp/src/main/webapp/jsp/mindmapList.jsp +++ b/wise-webapp/src/main/webapp/jsp/mindmapList.jsp @@ -16,7 +16,6 @@ - @@ -25,20 +24,20 @@ @@ -216,17 +218,18 @@ } }); - $("#exportBtn").click(function() { + $("#publishBtn").click(function() { var mapIds = $('#mindmapListTable').dataTableExt.getSelectedMapsIds(); if (mapIds.length > 0) { - $('#export-dialog-modal .modal-body').load("c/map/" + mapIds[0] + "/export.htm", function() { - $('#export-dialog-modal').modal(); - }); - + $('#publish-dialog-modal .modal-body').load("c/map/" + mapIds[0] + "/publish.htm", + function() { + $('#publish-dialog-modal .btn-accept').click(function() { + $('#publish-dialog-modal #publishForm').submit(); + }); + $('#publish-dialog-modal').modal(); + }); } }); - $("#actionButtons .publishMap").click(function() { - }); $("#actionButtons .shareMap").click(function() { }); @@ -250,7 +253,7 @@ -
+
@@ -261,21 +264,21 @@
- - + +
@@ -423,20 +424,21 @@
-
\ No newline at end of file + + $('#sharingPanel #frameWith').change(function() { + replaceCode.bind(this)(/width:[0-9]+px/g, "width:%spx", 1); + }); + + $('#sharingPanel #frameHeight').keyup(function() { + replaceCode.bind(this)(/height:[0-9]+px/g, "height:%spx", 1); + }); + + $('#sharingPanel #frameHeight').change(function() { + replaceCode.bind(this)(/height:[0-9]+px/g, "height:%spx", 1); + }); + + $('#sharingPanel #mapZoom').keyup(function() { + replaceCode.bind(this)(/zoom=.+\"/g, "zoom=%s\"", 0.1); + }); + + $('#sharingPanel #mapZoom').change(function() { + replaceCode.bind(this)(/zoom=.+\"/g, "zoom=%s\"", 0.01); + }); + + + // Save status on click ... + $('#publishForm').submit(function(event) { + jQuery.ajax("service/maps/${mindmap.id}/publish", { + async:false, + dataType: 'json', + data: $('#publishForm #enablePublicView')[0].checked ? 'true' : 'false', + type: 'PUT', + contentType:"text/plain", + success : function(data, textStatus, jqXHR) { + $('#publish-dialog-modal').modal('hide'); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert(textStatus); + } + }); + event.preventDefault(); + }); + + + diff --git a/wise-webapp/src/test/sql/hsql/test-data.sql b/wise-webapp/src/test/sql/hsql/test-data.sql index 54318c6d..1b8b1452 100644 --- a/wise-webapp/src/test/sql/hsql/test-data.sql +++ b/wise-webapp/src/test/sql/hsql/test-data.sql @@ -1,6 +1,6 @@ INSERT INTO COLABORATOR(id,email,creation_date) values (1,'test@wisemapping.org',CURDATE()); INSERT INTO USER (colaborator_id,username,firstname, lastname, password, activationCode,activation_date,allowSendEmail) -values(1,'WiseMapping Test User','Wise','test', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',1237,CURDATE(),1); +values(1,'wi','Wise','test', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',1237,CURDATE(),1); INSERT INTO COLABORATOR(id,email,creation_date) values (2,'admin@wisemapping.org',CURDATE()); INSERT INTO USER (colaborator_id,username,firstname, lastname, password, activationCode,activation_date,allowSendEmail)