sohami commented on a change in pull request #1644: DRILL-7036: Improve UI for 
alert and error messages
URL: https://github.com/apache/drill/pull/1644#discussion_r258633205
 
 

 ##########
 File path: exec/java-exec/src/main/resources/rest/alertModals.ftl
 ##########
 @@ -0,0 +1,111 @@
+<#--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<style>
+  .modalHeaderAlert, .closeX {
+    color:red !important;
+    text-align: center;
+    font-size: 16px;
+  }
+</style>
+  <!--
+    Alert Modal to use across templates.
+    By default, modal is hidden and expected to be populated and activated by 
relevant JavaScripts
+  -->
+  <div class="modal" id="errorModal" role="dialog" data-backdrop="static" 
data-keyboard="false" style="display: none;" aria-hidden="true">
+    <div class="modal-dialog">
+      <!-- Modal content-->
+      <div class="modal-content">
+        <div class="modal-header modalHeaderAlert">
+          <button type="button" class="close closeX" data-dismiss="modal" 
style="color:red;font-size:200%">×</button>
+          <h4 class="modal-title"><span class="glyphicon glyphicon-alert" 
style="font-size:125%"></span><span id="modalHeader" 
style="font-family:Helvetica 
Neue,Helvetica,Arial,sans-serif;white-space:pre">~ErrorMessage~ 
Title</span></h4>
+        </div>
+        <div class="modal-body" id="modalBody" style="line-height:3">
+        ~ErrorMessage Details~
+        </div>
+        <div class="modal-footer">
+          <button type="button" class="btn btn-info btn-default" 
data-dismiss="modal">Close</button>
+        </div>
+      </div>
+    </div>
+  </div>
+<script>
+    //Populate the alert modal with the right message params and show
+    function populateAndShowAlert(errorMsg, inputValues) {
+      //console.log("placeHolder -> "+ 
JSON.stringify(errorMap[errorMsg].placeHolder));
+      //console.log("inputValues -> "+ JSON.stringify(inputValues));
+      modalHeader.innerHTML=errorMap[errorMsg].msgHeader;
+      modalBody.innerHTML=errorMap[errorMsg].msgBody;
+      let substNames=[];
+      let substValues=[];
+      //Check if substitutions are needed
+      if (errorMap[errorMsg].placeHolder != null) {
 
 Review comment:
   You can get rid of `placeHolder` and instead the caller of 
`populateAndShowAlert` can pass you an object with key as placeholder string 
and its value as string to substitute. For example in `options.ftl ` it will 
pass in below:
   
   `
   var inputValues = {
        _numericOption_: optionValue,
        _optionName_: optionName
   };
   populateAndShowAlert('invalidOptionValue', inputValues);
   `
   
   Then inside populateAndShowAlert do below. This will make sure that ordering 
of placeHolder strings and passed values is not messed up by caller.
   ```
   populateAndShowAlert(errorMsg, inputValues) {
        ....
        ....
        let updatedHtml=modalBody.innerHTML;
        var inputValuesKeys = Object.keys(inputValues);
        for (int i=0; i<inputValuesKeys.length; ++i) {
               var currKey = inputValuesKeys[i];
               updatedHtml = updatedHtml.replace(currKey, inputValues[currKey]);
         }
   }
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to