Repository: openmeetings
Updated Branches:
  refs/heads/master c5cc6af49 -> 0e0c280d6


[OPENMEETINGS-19] wb resize on document drop is added, doc resize also works


Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo
Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/0e0c280d
Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/0e0c280d
Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/0e0c280d

Branch: refs/heads/master
Commit: 0e0c280d6c8c3da551cf045f1d014001433ecc3d
Parents: c5cc6af
Author: Maxim Solodovnik <solomax...@gmail.com>
Authored: Mon Aug 7 16:12:43 2017 +0700
Committer: Maxim Solodovnik <solomax...@gmail.com>
Committed: Mon Aug 7 16:12:43 2017 +0700

----------------------------------------------------------------------
 .../core/data/whiteboard/WhiteboardCache.java   |  3 +-
 .../openmeetings/web/room/wb/WbAction.java      |  1 +
 .../openmeetings/web/room/wb/WbPanel.java       | 29 +++++++++++++++++---
 .../org/apache/openmeetings/web/room/wb/wb.js   | 22 ++++++++++++---
 4 files changed, 46 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/openmeetings/blob/0e0c280d/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardCache.java
----------------------------------------------------------------------
diff --git 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardCache.java
 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardCache.java
index 8253815..d392c69 100644
--- 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardCache.java
+++ 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/data/whiteboard/WhiteboardCache.java
@@ -85,13 +85,14 @@ public class WhiteboardCache {
                return wb;
        }
 
-       public static void clear(Long roomId, Long wbId) {
+       public static Whiteboard clear(Long roomId, Long wbId) {
                Whiteboards wbs = get(roomId);
                Whiteboard wb = wbs.get(wbId);
                if (wb != null) {
                        wb.clear();
                        update(wbs);
                }
+               return wb;
        }
 
        public static Whiteboard remove(Long roomId, Long wbId) {

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/0e0c280d/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbAction.java
----------------------------------------------------------------------
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbAction.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbAction.java
index 52ee864..6838064 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbAction.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbAction.java
@@ -31,4 +31,5 @@ public enum WbAction {
        , save
        , load
        , undo
+       , setSize
 }

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/0e0c280d/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbPanel.java
----------------------------------------------------------------------
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbPanel.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbPanel.java
index 5872cd2..344bf91 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbPanel.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/WbPanel.java
@@ -40,6 +40,7 @@ import java.util.LinkedList;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.UUID;
+import java.util.function.Consumer;
 import java.util.function.Function;
 
 import org.apache.openmeetings.core.data.whiteboard.WhiteboardCache;
@@ -399,6 +400,10 @@ public class WbPanel extends Panel {
        }
 
        private JSONObject addFileUrl(String ruid, JSONObject _file) {
+               return addFileUrl(ruid, _file, null);
+       }
+
+       private JSONObject addFileUrl(String ruid, JSONObject _file, 
Consumer<FileItem> consumer) {
                try {
                        final long fid = _file.optLong("fileId", -1);
                        if (fid > 0) {
@@ -406,6 +411,9 @@ public class WbPanel extends Panel {
                                                ? 
getBean(RecordingDao.class).get(fid)
                                                : 
getBean(FileExplorerItemDao.class).get(fid);
                                if (fi != null) {
+                                       if (consumer != null) {
+                                               consumer.accept(fi);
+                                       }
                                        return 
WbWebSocketHelper.addFileUrl(ruid, _file, fi, rp.getClient());
                                }
                        }
@@ -435,11 +443,19 @@ public class WbPanel extends Panel {
                if (arr.length() != 0) {
                        addUndo(wb.getId(), new 
UndoObject(UndoObject.Type.remove, arr));
                }
-               WhiteboardCache.clear(roomId, wbId);
-               sendWbAll(WbAction.clearAll, new JSONObject().put("wbId", 
wb.getId()));
+               wb = WhiteboardCache.clear(roomId, wbId);
+               sendWbAll(WbAction.clearAll, new JSONObject().put("wbId", 
wbId));
+               sendWbAll(WbAction.setSize, getAddWbJson(wb));
+       }
+
+       private static void updateWbSize(Whiteboard wb, final FileItem fi) {
+               int w = fi.getWidth() == null ? DEFAULT_WIDTH : fi.getWidth();
+               int h = fi.getHeight() == null ? DEFAULT_HEIGHT : 
fi.getHeight();
+               wb.setWidth(Math.max(wb.getWidth(), w));
+               wb.setHeight(Math.max(wb.getHeight(), h));
        }
 
-       public void sendFileToWb(FileItem fi, boolean clean) {
+       public void sendFileToWb(final FileItem fi, boolean clean) {
                if (isVisible() && fi.getId() != null) {
                        Whiteboards wbs = WhiteboardCache.get(roomId);
                        String wuid = UUID.randomUUID().toString();
@@ -457,8 +473,11 @@ public class WbPanel extends Panel {
                                                        JSONArray arr = 
getArray(new JSONObject(new JSONTokener(br)), (o) -> {
                                                                        
wb.put(o.getString("uid"), o);
                                                                        
updated[0] = true;
-                                                                       return 
addFileUrl(wbs.getUid(), o);
+                                                                       return 
addFileUrl(wbs.getUid(), o, _f -> {
+                                                                               
updateWbSize(wb, _f);
+                                                                       });
                                                                });
+                                                       
sendWbAll(WbAction.setSize, getAddWbJson(wb));
                                                        
sendWbAll(WbAction.load, getObjWbJson(wb.getId(), arr));
                                                } catch (Exception e) {
                                                        log.error("Unexpected 
error while loading WB", e);
@@ -487,7 +506,9 @@ public class WbPanel extends Panel {
                                                clearAll(roomId, wb.getId());
                                        }
                                        wb.put(wuid, file);
+                                       updateWbSize(wb, fi);
                                        updated[0] = true;
+                                       sendWbAll(WbAction.setSize, 
getAddWbJson(wb));
                                        WbWebSocketHelper.sendWbFile(roomId, 
wb.getId(), ruid, file, fi);
                                }
                                        break;

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/0e0c280d/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/wb.js
----------------------------------------------------------------------
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/wb.js 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/wb.js
index aaabbb4..89d00ad 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/wb.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/wb.js
@@ -831,8 +831,7 @@ var Wb = function() {
                                                addCanvas();
                                        }
                                        var canvas = canvases[i];
-                                       canvas.setBackgroundImage(_o._src + 
"&slide=" + i, canvas.renderAll.bind(canvas), {})
-                                                       
.setWidth(width).setHeight(height);
+                                       canvas.setBackgroundImage(_o._src + 
"&slide=" + i, canvas.renderAll.bind(canvas), {});
                                }
                                _updateZoomPanel();
                                if (ccount != canvases.length) {
@@ -1021,8 +1020,12 @@ var Wb = function() {
                                cc.hide();
                        }
                }
+               __setSize(canvas);
                setHandlers(canvas);
        }
+       function __setSize(_cnv) {
+               _cnv.setWidth(wb.zoom * wb.width).setHeight(wb.zoom * 
wb.height).setZoom(wb.zoom);
+       }
        function _setSize() {
                switch (wb.zoomMode) {
                        case 'fullFit':
@@ -1045,7 +1048,7 @@ var Wb = function() {
                                break;
                }
                wb.eachCanvas(function(canvas) {
-                       canvas.setWidth(wb.zoom * wb.width).setHeight(wb.zoom * 
wb.height).setZoom(wb.zoom);
+                       __setSize(canvas);
                });
        }
        wb.setRole = function(_role) {
@@ -1095,11 +1098,18 @@ var Wb = function() {
                addCanvas();
                wb.setRole(_role);
        };
+       wb.setSize = function(wbo) {
+               wb.width = wbo.width;
+               wb.height = wbo.height;
+               wb.zoom = wbo.zoom;
+               wb.zoomMode = wbo.zoomMode;
+               _setSize();
+       }
        wb.resize = function(w, h) {
                if (t.position().left + t.width() > a.width()) {
                        t.position({
                                my: "right"
-                               , at: "right-10"
+                               , at: "right-20"
                                , of: a.selector
                                , collision: "fit"
                        });
@@ -1422,6 +1432,10 @@ var WbArea = (function() {
                wbTabs.height(hh);
                _resizeWbs();
        }
+       self.setSize = function(json) {
+               if (!_inited) return;
+               self.getWb(json.wbId).setSize(json);
+       }
        self.download = function(fmt) {
                var wb = getActive().data(), cnv = wb.getCanvas()
                        , a = document.createElement('a');

Reply via email to