Add zoom support for embedded maps.
Add new url to embedded maps
This commit is contained in:
@@ -1,78 +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 org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.filter.UserAgent;
|
||||
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
|
||||
public class EmbeddedViewController extends BaseMultiActionController {
|
||||
|
||||
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException noSuchRequestHandlingMethodException, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
||||
|
||||
ModelAndView view;
|
||||
try {
|
||||
final MindMap mindmap = this.getMindmapFromRequest(httpServletRequest);
|
||||
if (mindmap == null) {
|
||||
throw new IllegalStateException("Map could not be found");
|
||||
}
|
||||
|
||||
final String fullViewStr = httpServletRequest.getParameter("fullView");
|
||||
final boolean fullView = Boolean.parseBoolean(fullViewStr);
|
||||
|
||||
final UserAgent userAgent = UserAgent.create(httpServletRequest);
|
||||
|
||||
if (userAgent.isBrowserSupported()) {
|
||||
view = new ModelAndView("embeddedView");
|
||||
view.addObject("mindmap", mindmap);
|
||||
final String xmlMap = mindmap.getXmlAsJsLiteral();
|
||||
view.addObject("mapXml", xmlMap);
|
||||
|
||||
final String zoomStr = httpServletRequest.getParameter("zoom");
|
||||
float zoom = 1;
|
||||
if(zoomStr!=null)
|
||||
{
|
||||
try {
|
||||
zoom = Float.parseFloat(zoomStr);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
view.addObject("zoom",zoom);
|
||||
|
||||
} else {
|
||||
|
||||
view = new ModelAndView("embeddedViewNotSupported");
|
||||
}
|
||||
view.addObject("fullView", fullView);
|
||||
|
||||
} catch (UndeclaredThrowableException e) {
|
||||
// Security exception ....
|
||||
view = new ModelAndView("embeddedViewError");
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
@@ -55,7 +55,6 @@ public class UserAgent implements Serializable {
|
||||
firefox = UserAgent.create("Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.12) Gecko/20080129 Iceweasel/2.0.0.12 (Debian-2.0.0.12-0etch1)");
|
||||
assert firefox.isBrowserSupported();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -323,10 +322,10 @@ public class UserAgent implements Serializable {
|
||||
public boolean isBrowserSupported() {
|
||||
// Is it a supported browser ?.
|
||||
final UserAgent.Product product = this.getProduct();
|
||||
boolean result = product == UserAgent.Product.FIREFOX && this.isVersionGreatedOrEqualThan(3, 0);
|
||||
boolean result = product == UserAgent.Product.FIREFOX && this.isVersionGreatedOrEqualThan(10, 0);
|
||||
result = result || product == UserAgent.Product.EXPLORER && this.isVersionGreatedOrEqualThan(7, 0) && this.getOs() == UserAgent.OS.WINDOWS;
|
||||
result = result || product == UserAgent.Product.OPERA && this.isVersionGreatedOrEqualThan(9, 0);
|
||||
result = result || product == UserAgent.Product.CHROME && this.isVersionGreatedOrEqualThan(8, 0);
|
||||
result = result || product == UserAgent.Product.OPERA && this.isVersionGreatedOrEqualThan(11, 0);
|
||||
result = result || product == UserAgent.Product.CHROME && this.isVersionGreatedOrEqualThan(19, 0);
|
||||
result = result || product == UserAgent.Product.SAFARI && this.isVersionGreatedOrEqualThan(5, 0);
|
||||
return result;
|
||||
}
|
||||
|
@@ -23,6 +23,13 @@ import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class MindmapController {
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
MindmapController() {
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private MindmapService mindmapService;
|
||||
|
||||
@@ -100,6 +107,17 @@ public class MindmapController {
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "maps/{id}/embed")
|
||||
public ModelAndView embeddedView(@PathVariable int id, @RequestParam(required = false) Float zoom, @NotNull HttpServletRequest request) {
|
||||
ModelAndView view;
|
||||
final UserAgent userAgent = UserAgent.create(request);
|
||||
final MindMap mindmap = mindmapService.getMindmapById(id);
|
||||
view = new ModelAndView("mindmapEmbedded", "mindmap", mindmap);
|
||||
view.addObject("user", Utils.getUser());
|
||||
view.addObject("zoom", zoom == null ? 1 : zoom);
|
||||
return view;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "collaborator")
|
||||
public ModelAndView showCollaborator(@RequestParam(required = true) long mapId) {
|
||||
final MindMapBean modelObject = findMindmapBean(mapId);
|
||||
|
@@ -20,7 +20,6 @@ package com.wisemapping.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.exporter.ExportFormat;
|
||||
import com.wisemapping.importer.ImportFormat;
|
||||
import com.wisemapping.importer.Importer;
|
||||
import com.wisemapping.importer.ImporterException;
|
||||
@@ -33,10 +32,8 @@ import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
import com.wisemapping.security.Utils;
|
||||
import com.wisemapping.service.MindmapService;
|
||||
import com.wisemapping.service.UserService;
|
||||
import com.wisemapping.validator.MapInfoValidator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -45,7 +42,6 @@ import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
Reference in New Issue
Block a user