Browse Source

added warnings display to web interface (#47)

Matt Miller 1 year ago
parent
commit
514900fb6a
1 changed files with 21 additions and 4 deletions
  1. 21 4
      scriptshifter/templates/index.html

+ 21 - 4
scriptshifter/templates/index.html

@@ -20,6 +20,13 @@
             padding: 1em;
         }
 
+        pre.warnings{
+            border-left: 0.3rem solid #FF5722 !important;
+        }
+        #warnings-toggle{
+            display: none;
+        }
+
     </style>
 
 
@@ -62,7 +69,9 @@
         </fieldset>
     </form>
 
-    <div id="warnings"></div>
+    <div id="warnings-toggle"><pre class="warnings"><code id="warnings">
+
+    </code></pre></div>
     <div id="results">
         Results will appear here.
     </div>
@@ -91,10 +100,18 @@
                 method: 'post',
                 body: data,
             })
-            .then(response=>response.text())
-            .then((text)=>{
+            .then(response=>response.json())
+            .then((results)=>{
+
+                document.getElementById('warnings-toggle').style.display="none"
+
+                document.getElementById('results').innerText = results.output
+
+                if (results.warnings.length>0){
+                    document.getElementById('warnings-toggle').style.display="block"
+                }
+                document.getElementById('warnings').innerText = "WARNING:\n" + results.warnings.join("\n")
 
-                document.getElementById('results').innerText = text
 
             }).catch((error) => {
               alert("Error:\n" + error)