From 0625a629cb006912da71d96c09b218163318c12e Mon Sep 17 00:00:00 2001
From: Emanuele Laface <emanuele.laface@gmail.com>
Date: Thu, 3 Sep 2020 11:44:22 +0200
Subject: [PATCH] Description of PV added to PVS

---
 PythonServer/pos-python-server.py |  13 ++++
 WebSites/pvs/dashboard.json       | 114 +++++++++++++++++++-----------
 2 files changed, 84 insertions(+), 43 deletions(-)

diff --git a/PythonServer/pos-python-server.py b/PythonServer/pos-python-server.py
index 2e250b9..f56ef5a 100755
--- a/PythonServer/pos-python-server.py
+++ b/PythonServer/pos-python-server.py
@@ -149,10 +149,16 @@ class myHandler(BaseHTTPRequestHandler):
                         pvinfo["channel_finder"] += "<tr><td>" + tag + "</tr></td>"
                     pvinfo["channel_finder"] += "</table>"
 
+                    myPV = epics.PV(path[1] + ".DESC")
+                    pvinfo["desc"] = myPV.value
+                    myPV.clear_auto_monitor()
+                    myPV.disconnect()
+
                     self.wfile.write(bytes(json.dumps(pvinfo), "utf-8"))
                     return
                 except Exception:
                     pvinfo["info"] = "The PV seems disconnected"
+                    pvinfo["desc"] = ""
                     pvinfo["archiver"] = ""
                     pvinfo["channel_finder"] = ""
                     self.wfile.write(bytes(json.dumps(pvinfo), "utf-8"))
@@ -226,6 +232,12 @@ class myHandler(BaseHTTPRequestHandler):
                     pvinfo["info"] = myPV.info
                     myPV.clear_auto_monitor()
                     myPV.disconnect()
+
+                    myPV = epics.PV(path[1] + ".DESC")
+                    pvinfo["desc"] = myPV.value
+                    myPV.clear_auto_monitor()
+                    myPV.disconnect()
+
                     archiver_stat = ""
                     archiver_dict = archiver.get_pv_status(pv=path[1])[0]
                     for i in archiver_dict:
@@ -244,6 +256,7 @@ class myHandler(BaseHTTPRequestHandler):
                     return
                 except Exception:
                     pvinfo["info"] = "Something wrong here, please retry"
+                    pvinfo["desc"] = "Something wrong here, please retry"
                     pvinfo["archiver"] = "Something wrong here, please retry"
                     self.wfile.write(bytes(json.dumps(pvinfo), "utf-8"))
                     return
diff --git a/WebSites/pvs/dashboard.json b/WebSites/pvs/dashboard.json
index 91d9d36..0b2fe90 100644
--- a/WebSites/pvs/dashboard.json
+++ b/WebSites/pvs/dashboard.json
@@ -29,36 +29,6 @@
 				}
 			]
 		},
-		{
-			"title": "Archiver",
-			"width": 1,
-			"row": {
-				"1": 47,
-				"2": 47,
-				"3": 47,
-				"4": 29,
-				"12": 29,
-				"13": 29
-			},
-			"col": {
-				"1": 1,
-				"2": 1,
-				"3": 1,
-				"4": 1,
-				"12": 3,
-				"13": 3
-			},
-			"col_width": 2,
-			"widgets": [
-				{
-					"type": "html",
-					"settings": {
-						"html": "<div id=\"result_ar\" style=\"overflow: visible;\"></div>",
-						"height": 8
-					}
-				}
-			]
-		},
 		{
 			"title": "PV Search",
 			"width": 1,
@@ -83,7 +53,7 @@
 				{
 					"type": "html",
 					"settings": {
-						"html": "<script>\nfunction clickPress(event) {\n    if (event.which == 13) {\n        freeboard.showLoadingIndicator(true);\n    \tvar searchVar = document.getElementById(\"searchBar\").value;\n        $.get(\"/data/search/\"+searchVar).done(function(data) {\n\t\t\tdocument.getElementById('result_div').innerHTML=data[\"pvs\"];\n            freeboard.showLoadingIndicator(false);\n        });\n\t};\n};\n\nfunction searchPV(PVname) {\n\tfreeboard.showLoadingIndicator(true);\n\t$.get(\"/data/getPVHTML/\"+PVname).done(function(data) {\n        if (typeof data[\"link\"] === 'undefined') {\n\t\t\tdocument.getElementById('result_pv').innerHTML=data[\"info\"];\n            document.getElementById('result_ar').innerHTML=data[\"archiver\"];\n            document.getElementById('result_cf').innerHTML=data[\"channel_finder\"];\n        }\n        else {\n            document.getElementById('result_pv').innerHTML=data[\"info\"];\n            document.getElementById('result_ar').innerHTML=data[\"archiver\"]+\"<p>\"+data[\"link\"];\n            document.getElementById('result_cf').innerHTML=data[\"channel_finder\"];\n        };\n        freeboard.showLoadingIndicator(false);\n    });\n};\n</script>\n<center><input id=\"searchBar\" type=\"text\" onkeypress=\"clickPress(event)\" placeholder=\"Search for a PV\"></input></center>\n\n",
+						"html": "<script>\nfunction clickPress(event) {\n    if (event.which == 13) {\n        freeboard.showLoadingIndicator(true);\n    \tvar searchVar = document.getElementById(\"searchBar\").value;\n        $.get(\"/data/search/\"+searchVar).done(function(data) {\n\t\t\tdocument.getElementById('result_div').innerHTML=data[\"pvs\"];\n            freeboard.showLoadingIndicator(false);\n        });\n\t};\n};\n\nfunction searchPV(PVname) {\n\tfreeboard.showLoadingIndicator(true);\n\t$.get(\"/data/getPVHTML/\"+PVname).done(function(data) {\n        if (typeof data[\"link\"] === 'undefined') {\n\t\t\tdocument.getElementById('result_pv').innerHTML=data[\"info\"];\n            document.getElementById('result_de').innerHTML=data[\"desc\"];\n            document.getElementById('result_ar').innerHTML=data[\"archiver\"];\n            document.getElementById('result_cf').innerHTML=data[\"channel_finder\"];\n        }\n        else {\n            document.getElementById('result_pv').innerHTML=data[\"info\"];\n            document.getElementById('result_de').innerHTML=data[\"desc\"];\n            document.getElementById('result_ar').innerHTML=data[\"archiver\"]+\"<p>\"+data[\"link\"];\n            document.getElementById('result_cf').innerHTML=data[\"channel_finder\"];\n        };\n        freeboard.showLoadingIndicator(false);\n    });\n};\n</script>\n<center><input id=\"searchBar\" type=\"text\" onkeypress=\"clickPress(event)\" placeholder=\"Search for a PV\"></input></center>\n\n",
 						"height": 1
 					}
 				}
@@ -127,10 +97,10 @@
 			"title": "PV Info",
 			"width": 1,
 			"row": {
-				"1": 29,
-				"2": 29,
-				"3": 29,
-				"4": 11,
+				"1": 41,
+				"2": 41,
+				"3": 41,
+				"4": 29,
 				"5": 23,
 				"6": 23,
 				"7": 23,
@@ -142,7 +112,7 @@
 				"1": 1,
 				"2": 1,
 				"3": 1,
-				"4": 3,
+				"4": 1,
 				"5": 9,
 				"6": 9,
 				"7": 9,
@@ -161,14 +131,46 @@
 				}
 			]
 		},
+		{
+			"title": "Archiver",
+			"width": 1,
+			"row": {
+				"1": 59,
+				"2": 59,
+				"3": 59,
+				"4": 23,
+				"11": 29,
+				"12": 29,
+				"13": 29
+			},
+			"col": {
+				"1": 1,
+				"2": 1,
+				"3": 1,
+				"4": 3,
+				"11": 3,
+				"12": 3,
+				"13": 3
+			},
+			"col_width": 2,
+			"widgets": [
+				{
+					"type": "html",
+					"settings": {
+						"html": "<div id=\"result_ar\" style=\"overflow: visible;\"></div>",
+						"height": 5
+					}
+				}
+			]
+		},
 		{
 			"title": "Channel Finder",
 			"width": 1,
 			"row": {
-				"1": 65,
-				"2": 65,
-				"3": 65,
-				"4": 29,
+				"1": 71,
+				"2": 71,
+				"3": 71,
+				"4": 35,
 				"11": 29,
 				"12": 29
 			},
@@ -177,8 +179,8 @@
 				"2": 1,
 				"3": 1,
 				"4": 3,
-				"11": -9,
-				"12": -9
+				"11": 9,
+				"12": 9
 			},
 			"col_width": 2,
 			"widgets": [
@@ -186,7 +188,33 @@
 					"type": "html",
 					"settings": {
 						"html": "<div id=\"result_cf\" style=\"overflow: visible;\"></div>",
-						"height": 8
+						"height": 5
+					}
+				}
+			]
+		},
+		{
+			"title": "Description",
+			"width": 1,
+			"row": {
+				"1": 29,
+				"2": 29,
+				"3": 29,
+				"4": 11
+			},
+			"col": {
+				"1": 1,
+				"2": 1,
+				"3": 1,
+				"4": 3
+			},
+			"col_width": 2,
+			"widgets": [
+				{
+					"type": "html",
+					"settings": {
+						"html": "<div id=\"result_de\" style=\"overflow: visible;\"></div>",
+						"height": 5
 					}
 				}
 			]
-- 
GitLab