Browse Source

Merge pull request #45 from AToMPM/about-button

Add About button
BentleyJOakes 7 years ago
parent
commit
3f182caddb

+ 3 - 1
client/constants.js

@@ -5,7 +5,9 @@
 
 
 /****************************** GLOBAL CONSTANTS ******************************/
 /****************************** GLOBAL CONSTANTS ******************************/
 var __WEBPAGE__ = 'https://atompm.github.io/',
 var __WEBPAGE__ = 'https://atompm.github.io/',
-    __VERSION__ = '0.7.0',
+	__RELEASE_LOC__ = "https://api.github.com/repos/AToMPM/atompm/releases/latest",
+	__DOC_WEBPAGE__ = "https://atompm.readthedocs.io",
+    __VERSION__ = '0.8.0',
     __DEFAULT_SAVEAS		 	= '.autosave.model',
     __DEFAULT_SAVEAS		 	= '.autosave.model',
 	 __TITLE						= 'AToMPM',
 	 __TITLE						= 'AToMPM',
 	 __EXITWARNING				= 'There are unsaved changes. Proceeding will cause'+
 	 __EXITWARNING				= 'There are unsaved changes. Proceeding will cause'+

+ 11 - 7
client/http_utils.js

@@ -28,13 +28,17 @@ HttpUtils = function(){
 		var onreadystatechange = function(ev) {
 		var onreadystatechange = function(ev) {
 			 if( req.readyState == 4 )
 			 if( req.readyState == 4 )
 			 {
 			 {
-	 			 console.debug(method+' '+url+' >> '+req.status);
-				 if( req.status == 0 )
-	 				 WindowManagement.openDialog(__FATAL_ERROR,'lost connection to back-end');
-				 else if( onresponse )
-					 onresponse(req.status,req.responseText);
-				 else if( ! utils.isHttpSuccessCode(req.status) )
-	 				 WindowManagement.openDialog(_ERROR,req.responseText);
+                 console.debug(method + ' ' + url + ' >> ' + req.status);
+                 //ignore calls made to other addresses
+                 if (url.startsWith("http://") || url.startsWith("https://")) {
+                     onresponse(req.status, req.responseText);
+                 }
+                 else if (req.status == 0)
+                     WindowManagement.openDialog(__FATAL_ERROR, 'lost connection to back-end');
+                 else if (onresponse)
+                     onresponse(req.status, req.responseText);
+                 else if (!utils.isHttpSuccessCode(req.status))
+                     WindowManagement.openDialog(_ERROR, req.responseText);
 			 }
 			 }
  		 };
  		 };
 	
 	

+ 49 - 0
client/window_management.js

@@ -58,6 +58,55 @@ WindowManagement = function(){
 		__setCanvasScrolling(false);
 		__setCanvasScrolling(false);
 	};
 	};
 	
 	
+	this.showAboutDialog = function () {
+
+        let create_about = function (status, text) {
+
+            let version = null;
+            let time_at = null;
+
+            if (utils.isHttpSuccessCode(status)) {
+                let resp = JSON.parse(text);
+                version = resp['tag_name'];
+
+                time_at = resp['published_at'];
+                time_at = time_at.split("T")[0];
+            }
+
+            let title = "About AToMPM";
+            let elements = [];
+
+            let website = "<a href= '" + __WEBPAGE__ + "' target='_blank'>Website and Tutorials</a>";
+            elements.push(GUIUtils.getTextSpan(website));
+
+            let doc_website = "<a href= '" + __DOC_WEBPAGE__ + "' target='_blank'>Documentation</a>";
+            elements.push(GUIUtils.getTextSpan(doc_website));
+
+            let curr_version_str = "Current Version: " + __VERSION__;
+            elements.push(GUIUtils.getTextSpan(curr_version_str));
+
+            elements.push(GUIUtils.getTextSpan("\n"));
+
+            if (version != null) {
+                let new_version_str = "Newest Version: " + version;
+                elements.push(GUIUtils.getTextSpan(new_version_str));
+
+                let time_at_str = "Released on: " + time_at;
+                elements.push(GUIUtils.getTextSpan(time_at_str));
+
+            }
+
+            GUIUtils.setupAndShowDialog(
+                elements,
+                null,
+                __ONE_BUTTON,
+                title,
+                null);
+        };
+
+        HttpUtils.httpReq("GET", "https://api.github.com/repos/AToMPM/atompm/releases/latest", null, create_about);
+	};
+	
 	//Todo: Shred this function into smaller functions, as this should
 	//Todo: Shred this function into smaller functions, as this should
 	// really just amount to a switch statement
 	// really just amount to a switch statement
 	//TBI: complete comments about each dialog (copy from user's manual)
 	//TBI: complete comments about each dialog (copy from user's manual)

+ 1 - 1
doc/overview.rst

@@ -52,7 +52,7 @@ All button toolbar models can be found under the */Toolbars/* user folder. A but
 #. Paste the copied elements on the canvas (copy/paste also works across AToMPM tabs).
 #. Paste the copied elements on the canvas (copy/paste also works across AToMPM tabs).
 #. Verify whether the constraints of the current model are satisfied.
 #. Verify whether the constraints of the current model are satisfied.
 #. Show or hide entities of a particular formalism (but do not remove them from the model).
 #. Show or hide entities of a particular formalism (but do not remove them from the model).
-#. Open the manual.
+#. Display information about AToMPM, such as the current version, website, and documentation.
 
 
 Most of these actions are intuitive. Others are explained in more detail in the next sections.
 Most of these actions are intuitive. Others are explained in more detail in the next sections.
     
     

+ 4 - 4
users/(default)/Toolbars/MainMenu/MainMenu.buttons.model

@@ -2430,7 +2430,7 @@
 							"2": {
 							"2": {
 								"textContent": {
 								"textContent": {
 									"type": "string",
 									"type": "string",
-									"value": "userguide"
+									"value": "about"
 								},
 								},
 								"style": {
 								"style": {
 									"type": "map<string,string>",
 									"type": "map<string,string>",
@@ -2910,15 +2910,15 @@
 			"13": {
 			"13": {
 				"name": {
 				"name": {
 					"type": "string",
 					"type": "string",
-					"value": "userguide"
+					"value": "about"
 				},
 				},
 				"tooltip": {
 				"tooltip": {
 					"type": "string",
 					"type": "string",
-					"value": "open the user's manual"
+					"value": "about AToMPM"
 				},
 				},
 				"code": {
 				"code": {
 					"type": "code",
 					"type": "code",
-					"value": "window.open('https://msdl.uantwerpen.be/documentation/AToMPM/', '_blank')"
+					"value": "showAboutDialog();"
 				},
 				},
 				"$type": "/Formalisms/__Utilities__/Buttons/Buttons/Button"
 				"$type": "/Formalisms/__Utilities__/Buttons/Buttons/Button"
 			},
 			},

users/(default)/Toolbars/MainMenu/userguide.icon.png → users/(default)/Toolbars/MainMenu/about.icon.png