improve rendering of popup error/warning messages
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 11 Jul 2013 15:00:11 +0000 (17:00 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 11 Jul 2013 15:00:11 +0000 (17:00 +0200)
manifold/core/result_value.py
manifold/manifoldproxy.py
third-party/jquery-notify/ui.notify.css
views/templates/messages.html

index 9eb7a93..7728e8a 100644 (file)
@@ -1,6 +1,7 @@
 # Inspired from GENI error codes
 
 import time
+import pprint
 
 class ResultValue(dict):
 
@@ -94,6 +95,10 @@ class ResultValue(dict):
     def ok_value(self):
         return self['value']
 
+    @staticmethod
+    def to_html (raw_dict):
+        return pprint.pformat (raw_dict).replace("\\n","<br/>")
+
 # 67    <code>
 # 68      <value>9</value>
 # 69      <label>DBERROR</label>
index 984531e..9d322ca 100644 (file)
@@ -5,6 +5,7 @@ from django.http import HttpResponse, HttpResponseForbidden
 
 #from manifold.manifoldquery import ManifoldQuery
 from manifold.core.query import Query
+from manifold.core.result_value import ResultValue
 from manifold.manifoldapi import ManifoldAPI
 from manifold.manifoldresult import ManifoldException
 
@@ -89,11 +90,7 @@ with the query passed using POST"""
         result = manifold_api.forward(manifold_query.to_dict())
 
         # XXX TEMP HACK
-        import pprint
-        htmlLines = []
-        for textLine in pprint.pformat(result['description']).splitlines():
-            htmlLines.append('<br/>%s' % textLine) # or something even nicer
-        result['description'] = ('\n'.join(htmlLines)).replace(' ', '&nbsp;')
+        result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ]
 
         json_answer=json.dumps(result)
         # if in debug mode we save this so we can use offline mode later
index 8ace216..7d88a60 100644 (file)
@@ -1,4 +1,4 @@
-.ui-notify { width:350px; position:fixed; top: 67px; right:10px; z-index: 999;}
+.ui-notify { width:500px; position:fixed; top: 67px; right:10px; z-index: 999;}
 /* .ui-notify { width:350px; position:fixed; top:10px; right:10px; } */
 .ui-notify-message { padding:10px; margin-bottom:15px; -moz-border-radius:8px; -webkit-border-radius:8px; border-radius:8px; /* jordan */ max-height: 600px; }
 .ui-notify-message h1 { font-size:14px; margin:0; padding:0 }
@@ -6,9 +6,15 @@
 .ui-notify-message:last-child { margin-bottom:0 }
 .ui-notify-message-style { background:#000; background:rgba(0,0,0,0.8); -moz-box-shadow: 0 0 6px #000; -webkit-box-shadow: 0 0 6px #000; box-shadow: 0 0 6px #000; }
 .ui-notify-message-style h1 { color:#fff; font-weight:bold }
-.ui-notify-message-style p { color:#fff; /* jordan */ max-height: 500px; overflow: auto; }
 .ui-notify-close { color:#fff; text-decoration:underline }
 .ui-notify-click { cursor:pointer }
 .ui-notify-cross { margin-top:-4px; float:right; cursor:pointer; text-decoration:none; font-size:12px; font-weight:bold; text-shadow:0 1px 1px #fff; padding:2px }
 .ui-notify-cross:hover { color:#ffffab }
 .ui-notify-cross:active { position:relative; top:1px }
+/* jordan */ 
+.ui-notify-message-style p,.ui-notify-message-style pre { 
+    font: normal 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+    background-color:#111; 
+    color:#eee;
+    max-height: 500px; 
+    overflow: auto; }
index b684336..06ac2ef 100644 (file)
@@ -9,7 +9,7 @@
                <div id="sticky">
                        <a class="ui-notify-close ui-notify-cross" href="#">x</a>
                        <h1>#{title}</h1>
-                       <p>#{text}</p>
+                       <pre>#{text}</pre>
                </div>
                
                <div id="themeroller" class="ui-state-error" style="padding:10px; -moz-box-shadow:0 0 6px #980000; -webkit-box-shadow:0 0 6px #980000; box-shadow:0 0 6px #980000;">