flash.html 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. {#
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. #}
  17. {#-
  18. Adapted from: https://github.com/dpgaspar/Flask-AppBuilder/blob/master/flask_appbuilder/templates/appbuilder/flash.html
  19. -#}
  20. <link rel="stylesheet" type="text/css" href="{{ url_for_asset('flash.css') }}">
  21. {#
  22. Split messages into two arrays: one for regular alerts, another for DAG import errors
  23. #}
  24. {% with messages = get_flashed_messages(with_categories=true) %}
  25. {% set dag_import_errors = [] %}
  26. {% set regular_alerts = [] %}
  27. {% if messages %}
  28. {% for category, m in messages %}
  29. {% if category == 'dag_import_error' %}
  30. {{ dag_import_errors.append((category, m)) if dag_import_errors.append((category, m)) != None else '' }}
  31. {% elif not (request.path == auth_manager.get_url_login() and 'access is denied' in m.lower()) %}
  32. {# Don't show 'Access is Denied' alert if user is logged out and on the login page. #}
  33. {{ show_message(m, category) }}
  34. {% endif %}
  35. {% endfor %}
  36. {% endif %}
  37. {% if dag_import_errors %}
  38. <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true" style="margin-top: 16px;">
  39. <div class="panel panel-default">
  40. <div class="panel-heading" role="tab" id="errorHeading">
  41. <h4 class="panel-title">
  42. <a role="button" data-toggle="collapse" data-parent="#accordion" href="#errorCollapse" aria-expanded="true" aria-controls="errorCollapse" class="accordion-toggle collapsed">
  43. <span class="text-danger"><span class="material-icons" aria-hidden="true">error</span> DAG Import Errors ({{ dag_import_errors|length }})</span>
  44. <span class="material-icons pull-right toggle-direction" aria-hidden="true">expand_less</span>
  45. </a>
  46. </h4>
  47. </div>
  48. <div id="errorCollapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="errorHeading">
  49. <div class="panel-body">
  50. {% for category, m in dag_import_errors %}
  51. <div class="alert alert-error">
  52. <div class="dag-import-error" onclick="toggleErrorMessage.call(this)"><span class="material-icons pull-right toggle-direction" aria-hidden="true">expand_more</span>{{ m }}</div>
  53. </div>
  54. {% endfor %}
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. {% endif %}
  60. {% endwith %}
  61. {% block tail %}
  62. <script>
  63. function toggleErrorMessage() {
  64. $(this).toggleClass('expanded-error');
  65. }
  66. </script>
  67. {% endblock %}