Gaudenz Alder před 6 roky
rodič
revize
6ca7fa405a

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+09-MAR-2019: 10.4.0
+
+- Handles timeouts in realtime convert tool
+- Fixes bugs for older versions of IE
+
 08-MAR-2019: 10.3.9
 
 - Adds warning for Google Drive legacy files

+ 1 - 1
VERSION

@@ -1 +1 @@
-10.3.9
+10.4.0

+ 1 - 1
src/main/webapp/cache.manifest

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 03/08/2019 06:31 PM
+# 03/09/2019 08:48 AM
 
 app.html
 index.html?offline=1

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 355 - 353
src/main/webapp/js/app.min.js


+ 0 - 5
src/main/webapp/js/diagramly/App.js

@@ -770,11 +770,6 @@ App.prototype.formatHideImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/format-hide.
  */
 App.prototype.fullscreenImage = (!mxClient.IS_SVG) ? IMAGE_PATH + '/fullscreen.png' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAAAAAClZ7nPAAAAAXRSTlMAQObYZgAAABpJREFUCNdjgAAbGxAy4AEh5gNwBBGByoIBAIueBd12TUjqAAAAAElFTkSuQmCC';
 
-/**
- * Executes the first step for connecting to Google Drive.
- */
-App.prototype.timeout = 25000;
-
 /**
  * Overriden UI settings depending on mode.
  */

+ 89 - 15
src/main/webapp/js/diagramly/DriveClient.js

@@ -2421,7 +2421,7 @@ DriveClient.prototype.convertRealtimeFiles = function()
 		output.scrollTop = output.scrollHeight;
 	});
 	
-	print('draw.io is searching files to be converted...');
+	print('draw.io (' + EditorUi.VERSION + ') is searching files to be converted...');
 	
 	if (this.ui.spinner.spin(document.body, 'Searching files...'))
 	{
@@ -2431,8 +2431,11 @@ DriveClient.prototype.convertRealtimeFiles = function()
 			var convertDelay = 15000;
 			var convertedIds = {};
 			var converted = 0;
+			var fromJson = 0;
+			var fromXml = 0;
+			var loadFail = 0;
+			var saveFail = 0;
 			var failed = 0;
-			var counter = 0;
 			var total = 0;
 			
 			var done = mxUtils.bind(this, function()
@@ -2451,6 +2454,21 @@ DriveClient.prototype.convertRealtimeFiles = function()
 				{
 					print('<br><br>This window can now be closed.')
 				}
+				
+				try
+				{
+					EditorUi.sendReport('Convert Realtime Files Report ' +
+						new Date().toISOString() + ':' +
+						'\n\nBrowser=' + navigator.userAgent +
+						'\nUser=' + ((this.user != null) ? this.user.id : 'unknown') +
+						'\nFound=' + total  + ' (Backup: ' + fromXml + ', Realtime: ' + fromJson + ')' +
+						'\nConverted=' + converted +
+						'\nFailed=' + failed  + ' (Load: ' + loadFail + ', Save: ' + saveFail + ')');
+				}
+				catch (e)
+				{
+					// ignore
+				}
 			});
 			
 			var totals = {'maxResults': 10000, 'q': q, 'includeTeamDriveItems': true, 'supportsTeamDrives': true};
@@ -2463,6 +2481,7 @@ DriveClient.prototype.convertRealtimeFiles = function()
 				if (this.ui.spinner.spin(document.body, 'Converting ' + total + ' file(s)'))
 				{
 					print('Found ' + total + ' file(s). This will take up to ' + Math.ceil((total * convertDelay) / 60000) + ' minute(s). <b>Please do not close this window!</b><br>');
+					var counter = 0;
 
 					// Does not show picker if there are no folders in the root
 					var nextPage = mxUtils.bind(this, function(token, delay)
@@ -2519,27 +2538,82 @@ DriveClient.prototype.convertRealtimeFiles = function()
 										if (convertedIds[fileId] == null)
 										{
 											convertedIds[fileId] = true;
-				
+											
+											var acceptResponse = true;
+											
+											var timeoutThread = window.setTimeout(mxUtils.bind(this, function()
+											{
+												acceptResponse = false;
+												
+												failed++;
+												loadFail++;
+												print('<img src="' + this.ui.editor.graph.warningImage.src + '" border="0" valign="absmiddle"/> Timeout');
+												doNextPage();
+											}), this.ui.timeout);
+											
 											this.getFile(fileId, mxUtils.bind(this, function(file)
 											{
-												this.saveFile(file, null, mxUtils.bind(this, function()
+												window.clearTimeout(timeoutThread);
+												
+												if (acceptResponse)
 												{
-													converted++;
-													print('<img src="' + Editor.checkmarkImage + '" border="0" valign="middle"/>');
-													doNextPage();
-												}), mxUtils.bind(this, function(err)
+													if (file.convertFrom == 'json')
+													{
+														fromJson++;
+													}
+													else
+													{
+														fromXml++;
+													}
+													
+													acceptResponse = true;
+													
+													timeoutThread = window.setTimeout(mxUtils.bind(this, function()
+													{
+														acceptResponse = false;
+														
+														failed++;
+														saveFail++;
+														print('<img src="' + this.ui.editor.graph.warningImage.src + '" border="0" valign="absmiddle"/> Timeout');
+														doNextPage();
+													}), this.ui.timeout);
+
+													this.saveFile(file, null, mxUtils.bind(this, function()
+													{
+														window.clearTimeout(timeoutThread);
+														
+														if (acceptResponse)
+														{
+															converted++;
+															print('<img src="' + Editor.checkmarkImage + '" border="0" valign="middle"/>');
+															doNextPage();
+														}
+													}), mxUtils.bind(this, function(err)
+													{
+														window.clearTimeout(timeoutThread);
+														
+														if (acceptResponse)
+														{
+															var msg = (err != null && err.error != null && err.error.message != null) ? err.error.message : '';
+															failed++;
+															saveFail++;
+															print('<img src="' + this.ui.editor.graph.warningImage.src + '" border="0" valign="absmiddle"/> ' + msg);
+															doNextPage();
+														}
+													}));
+												}
+											}), mxUtils.bind(this, function(err)
+											{
+												window.clearTimeout(timeoutThread);
+												
+												if (acceptResponse)
 												{
 													var msg = (err != null && err.error != null && err.error.message != null) ? err.error.message : '';
 													failed++;
+													loadFail++;
 													print('<img src="' + this.ui.editor.graph.warningImage.src + '" border="0" valign="absmiddle"/> ' + msg);
 													doNextPage();
-												}));
-											}), mxUtils.bind(this, function(e)
-											{
-												var msg = (err != null && err.error != null && err.error.message != null) ? err.error.message : '';
-												failed++;
-												print('<img src="' + this.ui.editor.graph.warningImage.src + '" border="0" valign="absmiddle"/> ' + msg);
-												doNextPage();
+												}
 											}));
 										}
 										else

+ 27 - 4
src/main/webapp/js/diagramly/Editor.js

@@ -2453,8 +2453,10 @@
 					this.findCommonProperties(edges[i], properties, vertices.length == 0 && i == 0);
 				}
 
-				if (Object.getOwnPropertyNames(properties).length > 0)
+				if (Object.getOwnPropertyNames != null && Object.getOwnPropertyNames(properties).length > 0)
+				{
 					this.container.appendChild(this.addProperties(this.createPanel(), properties, sstate));
+				}
 			}
 		};
 
@@ -3416,15 +3418,36 @@
 			mouseEvent = evt;
 			
 			// Workaround for member not found in IE8-
-			if (mxClient.IS_QUIRKS || document.documentMode == 7 || document.documentMode == 8)
+			try
 			{
-				mouseEvent = mxUtils.clone(evt);
+				if (mxClient.IS_QUIRKS || document.documentMode == 7 || document.documentMode == 8)
+				{
+					mouseEvent = document.createEventObject(evt);
+					mouseEvent.type = evt.type;
+					mouseEvent.canBubble = evt.canBubble;
+					mouseEvent.cancelable = evt.cancelable;
+					mouseEvent.view = evt.view;
+					mouseEvent.detail = evt.detail;
+					mouseEvent.screenX = evt.screenX;
+					mouseEvent.screenY = evt.screenY;
+					mouseEvent.clientX = evt.clientX;
+					mouseEvent.clientY = evt.clientY;
+					mouseEvent.ctrlKey = evt.ctrlKey;
+					mouseEvent.altKey = evt.altKey;
+					mouseEvent.shiftKey = evt.shiftKey;
+					mouseEvent.metaKey = evt.metaKey;
+					mouseEvent.button = evt.button;
+					mouseEvent.relatedTarget = evt.relatedTarget;
+				}
+			}
+			catch (e)
+			{
+				// ignores possible event cloning errors
 			}
 		};
 		
 		mxEvent.addListener(this.container, 'mouseenter', setMouseEvent);
 		mxEvent.addListener(this.container, 'mousemove', setMouseEvent);
-		
 		mxEvent.addListener(this.container, 'mouseleave', function(evt)
 		{
 			mouseEvent = null;

+ 7 - 2
src/main/webapp/js/diagramly/EditorUi.js

@@ -204,6 +204,11 @@
 	 */
 	EditorUi.prototype.mode = null;
 
+	/**
+	 * General timeout is 25 seconds.
+	 */
+	EditorUi.prototype.timeout = 25000;
+
 	/**
 	 * Allows for two buttons in the sidebar footer.
 	 */
@@ -11531,7 +11536,7 @@
 		var graph = this.editor.graph;
 		var active = this.isDiagramActive();
 		var file = this.getCurrentFile();
-		var enabled = file != null || urlParams['embed'] == '1';
+		var enabled = file != null || urlParams['embed'] == '1';
 		this.actions.get('pageSetup').setEnabled(active);
 		this.actions.get('autosave').setEnabled(file != null && file.isEditable() && file.isAutosaveOptional());
 		this.actions.get('guides').setEnabled(active);
@@ -11552,7 +11557,7 @@
 		this.actions.get('find').setEnabled(this.diagramContainer.style.visibility != 'hidden');
 		this.actions.get('layers').setEnabled(this.diagramContainer.style.visibility != 'hidden');
 		this.actions.get('outline').setEnabled(this.diagramContainer.style.visibility != 'hidden');
-		this.actions.get('rename').setEnabled((file != null && file.isRenamable()) || urlParams['embed'] == '1');
+		this.actions.get('rename').setEnabled((file != null && file.isRenamable()) || urlParams['embed'] == '1');
 		this.actions.get('close').setEnabled(file != null);
 		this.menus.get('publish').setEnabled(file != null && !file.isRestricted());
 		

+ 24 - 17
src/main/webapp/js/mxgraph/Editor.js

@@ -1215,27 +1215,34 @@ PrintDialog.prototype.create = function(editorUi)
  */
 PrintDialog.printPreview = function(preview)
 {
-	if (preview.wnd != null)
+	try
 	{
-		var printFn = function()
+		if (preview.wnd != null)
 		{
-			preview.wnd.focus();
-			preview.wnd.print();
-			preview.wnd.close();
-		};
-		
-		// Workaround for Google Chrome which needs a bit of a
-		// delay in order to render the SVG contents
-		// Needs testing in production
-		if (mxClient.IS_GC)
-		{
-			window.setTimeout(printFn, 500);
-		}
-		else
-		{
-			printFn();
+			var printFn = function()
+			{
+				preview.wnd.focus();
+				preview.wnd.print();
+				preview.wnd.close();
+			};
+			
+			// Workaround for Google Chrome which needs a bit of a
+			// delay in order to render the SVG contents
+			// Needs testing in production
+			if (mxClient.IS_GC)
+			{
+				window.setTimeout(printFn, 500);
+			}
+			else
+			{
+				printFn();
+			}
 		}
 	}
+	catch (e)
+	{
+		// ignores possible Access Denied
+	}
 };
 
 /**

+ 1 - 1
src/main/webapp/js/mxgraph/EditorUi.js

@@ -1677,7 +1677,7 @@ EditorUi.prototype.initCanvas = function()
 				}
 				
 				this.chromelessToolbar.style.display = '';
-				mxUtils.setOpacity(this.chromelessToolbar, opacity || 30);
+				mxUtils.setOpacity(this.chromelessToolbar, opacity || 30);
 			});
 	
 			if (urlParams['layers'] == '1')

+ 32 - 0
src/main/webapp/js/mxgraph/Graph.js

@@ -13,6 +13,38 @@ if (typeof html4 !== 'undefined')
 	//html4.ATTRIBS["video::autobuffer"] = 0;
 }
 
+// Shim for missing toISOString in older versions of IE
+// See https://stackoverflow.com/questions/12907862
+if (!Date.prototype.toISOString)
+{         
+    (function()
+    {         
+        function pad(number)
+        {
+            var r = String(number);
+            
+            if (r.length === 1) 
+            {
+                r = '0' + r;
+            }
+            
+            return r;
+        };
+        
+        Date.prototype.toISOString = function()
+        {
+            return this.getUTCFullYear()
+                + '-' + pad( this.getUTCMonth() + 1 )
+                + '-' + pad( this.getUTCDate() )
+                + 'T' + pad( this.getUTCHours() )
+                + ':' + pad( this.getUTCMinutes() )
+                + ':' + pad( this.getUTCSeconds() )
+                + '.' + String( (this.getUTCMilliseconds()/1000).toFixed(3) ).slice( 2, 5 )
+                + 'Z';
+        };       
+    }());
+}
+
 /**
  * Sets global constants.
  */

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 187 - 186
src/main/webapp/js/viewer.min.js