Repository: incubator-airflow Updated Branches: refs/heads/master 27fde3840 -> 5a7f0b2e5
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/static/tree.css ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/static/tree.css b/airflow/www_rbac/static/tree.css deleted file mode 100644 index 9304bb1..0000000 --- a/airflow/www_rbac/static/tree.css +++ /dev/null @@ -1,96 +0,0 @@ -/** -* 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. -*/ - -#svg_container{ - // overflow: scroll; -} -.node text { - font: 11px sans-serif; - pointer-events: none; -} -path.link { - fill: none; - stroke: #3182bd; - stroke-width: 1.5px; - opacity: 0.5; -} -g.tick line{ - shape-rendering: crispEdges; -} -rect.state { - stroke: black; - shape-rendering: crispEdges; - cursor: pointer; -} -rect.null, rect.scheduled, rect.undefined { - fill: white; -} -rect.success { - fill: green; -} -rect.running { - fill: lime; -} -rect.failed { - fill: red; -} -rect.queued { - fill: gray; -} -rect.shutdown { - fill: blue; -} -rect.upstream_failed { - fill: orange; -} -rect.up_for_retry { - fill: gold; -} -rect.skipped { - fill: pink; -} -.tooltip.in { - opacity: 1; - filter: alpha(opacity=100); -} - -.axis path, .axis line { - fill: none; - stroke: #000; -} -.axis text { - font: 11px sans-serif; -} - -g.parent circle { - cursor: pointer; -} - -g.node.collapsed circle { - stroke: #444; - stroke-width: 4px; -} -circle { - stroke: blue; - fill: white; - stroke-width: 1.5px; -} -g.axis path { - shape-rendering: crispEdges; -} http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/static_config.py ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/static_config.py b/airflow/www_rbac/static_config.py new file mode 100644 index 0000000..278c499 --- /dev/null +++ b/airflow/www_rbac/static_config.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# +# 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. +from __future__ import print_function + +import json +import os + +manifest = dict() + + +def configure_manifest_files(app): + """ + Loads the manifest file and register the `url_for_asset_` template tag. + :param app: + :return: + """ + + def parse_manifest_json(): + # noinspection PyBroadException + try: + global manifest + manifest_file = os.path.join(os.path.dirname(__file__), + 'static/dist/manifest.json') + with open(manifest_file, 'r') as f: + manifest.update(json.load(f)) + except Exception: + print("Please make sure to build the frontend in " + "static/ directory and restart the server") + pass + + def get_asset_url(filename): + if app.debug: + parse_manifest_json() + return '/static/dist/{}'.format(manifest.get(filename, '')) + + parse_manifest_json() + + @app.context_processor + def get_url_for_asset(): + """ + Template tag to return the asset URL. + WebPack renders the assets after minification and modification + under the static/dist folder. + This template tag reads the asset name in manifest.json and returns + the appropriate file. + """ + return dict(url_for_asset=get_asset_url) http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/chart.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/chart.html b/airflow/www_rbac/templates/airflow/chart.html index 983a8dc..82ce7a1 100644 --- a/airflow/www_rbac/templates/airflow/chart.html +++ b/airflow/www_rbac/templates/airflow/chart.html @@ -21,15 +21,14 @@ {% block head_css %} {{ super() }} <link rel="stylesheet" type="text/css" - href="{{ url_for('static', filename='tree.css') }}"> + href="{{ url_for('static', filename='css/tree.css') }}"> <link rel="stylesheet" type="text/css" href="{{ url_for('appbuilder.static',filename='datepicker/bootstrap-datepicker.css')}}" > +<link href="{{ url_for_asset('dataTables.bootstrap.min.css') }}" rel="stylesheet" type="text/css" > <link rel="stylesheet" type="text/css" - href="{{ url_for("static", filename="dataTables.bootstrap.css") }}"> -<link rel="stylesheet" type="text/css" - href="{{ url_for("static", filename="nv.d3.css") }}"> -<script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script> -<script src="{{ url_for('static', filename='nv.d3.js') }}"></script> + href="{{ url_for_asset('nv.d3.min.css') }}"> +<script src="{{ url_for_asset('d3.min.js') }}"></script> +<script src="{{ url_for_asset('nv.d3.min.js') }}"></script> {% endblock %} {% block content %} http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/circles.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/circles.html b/airflow/www_rbac/templates/airflow/circles.html index 027b4ff..3362540 100644 --- a/airflow/www_rbac/templates/airflow/circles.html +++ b/airflow/www_rbac/templates/airflow/circles.html @@ -1,13 +1,13 @@ -{# +{# 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. @@ -26,7 +26,7 @@ <svg></svg> </div> - <script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script> + <script src="{{ url_for_asset('d3.min.js') }}"></script> <script> var height =700; var width = document.getElementById("div_svg").offsetWidth; http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/conn_create.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/conn_create.html b/airflow/www_rbac/templates/airflow/conn_create.html index 5e6326c..02bade6 100644 --- a/airflow/www_rbac/templates/airflow/conn_create.html +++ b/airflow/www_rbac/templates/airflow/conn_create.html @@ -1,13 +1,13 @@ -{# +{# 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. @@ -19,5 +19,5 @@ {% block tail %} {{ super() }} - <script src="{{ url_for('static', filename='connection_form.js') }}"></script> + <script src="{{ url_for_asset('connectionForm.js') }}"></script> {% endblock %} http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/conn_edit.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/conn_edit.html b/airflow/www_rbac/templates/airflow/conn_edit.html index 2ff44be..b1cac51 100644 --- a/airflow/www_rbac/templates/airflow/conn_edit.html +++ b/airflow/www_rbac/templates/airflow/conn_edit.html @@ -1,13 +1,13 @@ -{# +{# 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. @@ -19,5 +19,5 @@ {% block tail %} {{ super() }} - <script src="{{ url_for('static', filename='connection_form.js') }}"></script> + <script src="{{ url_for_asset('static', filename='connectionForm.js') }}"></script> {% endblock %} http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/dag.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/dag.html b/airflow/www_rbac/templates/airflow/dag.html index eb297ad..83bde73 100644 --- a/airflow/www_rbac/templates/airflow/dag.html +++ b/airflow/www_rbac/templates/airflow/dag.html @@ -21,8 +21,7 @@ {% block head_css %} {{ super() }} - <link href="{{ url_for('static', filename='main.css') }}" rel="stylesheet"> - <link href="{{ url_for('static', filename='bootstrap-toggle.min.css') }}" rel="stylesheet" type="text/css"> + <link href="{{ url_for_asset('bootstrap-toggle.min.css') }}" rel="stylesheet" type="text/css"> {% endblock %} {% block content %} @@ -53,48 +52,48 @@ Back to {{ dag.parent_dag.dag_id }}</a> </li> {% endif %} - <li><a href="{{ url_for("Airflow.graph", dag_id=dag.dag_id, root=root) }}"> + <li><a href="{{ url_for('Airflow.graph', dag_id=dag.dag_id, root=root) }}"> <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span> Graph View</a></li> - <li><a href="{{ url_for("Airflow.tree", dag_id=dag.dag_id, num_runs=num_runs, root=root) }}"> + <li><a href="{{ url_for('Airflow.tree', dag_id=dag.dag_id, num_runs=num_runs, root=root) }}"> <span class="glyphicon glyphicon-tree-deciduous" aria-hidden="true"></span> Tree View </a></li> - <li><a href="{{ url_for("Airflow.duration", dag_id=dag.dag_id, days=30, root=root) }}"> + <li><a href="{{ url_for('Airflow.duration', dag_id=dag.dag_id, days=30, root=root) }}"> <span class="glyphicon glyphicon-stats" aria-hidden="true"></span> Task Duration </a></li> - <li><a href="{{ url_for("Airflow.tries", dag_id=dag.dag_id, days=30, root=root) }}"> + <li><a href="{{ url_for('Airflow.tries', dag_id=dag.dag_id, days=30, root=root) }}"> <span class="glyphicon glyphicon-duplicate" aria-hidden="true"></span> Task Tries </a></li> <li> - <a href="{{ url_for("Airflow.landing_times", dag_id=dag.dag_id, days=30, root=root) }}"> + <a href="{{ url_for('Airflow.landing_times', dag_id=dag.dag_id, days=30, root=root) }}"> <span class="glyphicon glyphicon-plane" aria-hidden="true"></span> Landing Times </a> </li> <li> - <a href="{{ url_for("Airflow.gantt", dag_id=dag.dag_id, root=root) }}"> + <a href="{{ url_for('Airflow.gantt', dag_id=dag.dag_id, root=root) }}"> <span class="glyphicon glyphicon-align-left" aria-hidden="true"></span> <i class="icon-align-left"></i> Gantt </a> </li> <li> - <a href="{{ url_for("Airflow.dag_details", dag_id=dag.dag_id) }}"> + <a href="{{ url_for('Airflow.dag_details', dag_id=dag.dag_id) }}"> <span class="glyphicon glyphicon-list" aria-hidden="true"></span> Details </a> </li> <li> - <a href="{{ url_for("Airflow.code", dag_id=dag.dag_id, root=root) }}"> + <a href="{{ url_for('Airflow.code', dag_id=dag.dag_id, root=root) }}"> <span class="glyphicon glyphicon-file" aria-hidden="true"></span> Code </a> </li> <li> - <a href="{{ url_for("Airflow.refresh", dag_id=dag.dag_id) }}" title="Refresh"> + <a href="{{ url_for('Airflow.refresh', dag_id=dag.dag_id) }}" title="Refresh"> <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Refresh </a> @@ -276,7 +275,7 @@ {% endblock %} {% block tail %} {{ super() }} - <script src="{{ url_for('static', filename='bootstrap-toggle.min.js') }}"></script> + <script src="{{ url_for_asset('bootstrap-toggle.min.js') }}"></script> <script> function updateQueryStringParameter(uri, key, value) { var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"); http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/dags.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/dags.html b/airflow/www_rbac/templates/airflow/dags.html index c7aa338..5f49278 100644 --- a/airflow/www_rbac/templates/airflow/dags.html +++ b/airflow/www_rbac/templates/airflow/dags.html @@ -21,8 +21,8 @@ {% block head_css %} {{ super() }} -<link href="{{ url_for("static", filename="dataTables.bootstrap.css") }}" rel="stylesheet" type="text/css" > -<link href="{{ url_for("static", filename="bootstrap-toggle.min.css") }}" rel="stylesheet" type="text/css"> +<link href="{{ url_for_asset('dataTables.bootstrap.min.css') }}" rel="stylesheet" type="text/css" > +<link href="{{ url_for_asset('bootstrap-toggle.min.css') }}" rel="stylesheet" type="text/css"> {% endblock %} {% block content %} @@ -224,14 +224,15 @@ {% block tail %} {{ super() }} - <script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script> - <script src="{{ url_for('static', filename='jquery.dataTables.min.js') }}"></script> - <script src="{{ url_for('static', filename='bootstrap-toggle.min.js') }}"></script> - <script src="{{ url_for('static', filename='bootstrap3-typeahead.min.js') }}"></script> + <script src="{{ url_for_asset('d3.min.js') }}"></script> + <script src="{{ url_for_asset('jquery.dataTables.min.js') }}"></script> + <script src="{{ url_for_asset('dataTables.bootstrap.min.js') }}"></script> + <script src="{{ url_for_asset('bootstrap-toggle.min.js') }}"></script> + <script src="{{ url_for_asset('bootstrap3-typeahead.min.js') }}"></script> <script> - const DAGS_INDEX = "{{ url_for('Airflow.index') }}" - const ENTER_KEY_CODE = 13 + const DAGS_INDEX = "{{ url_for('Airflow.index') }}"; + const ENTER_KEY_CODE = 13; $('#dag_query').on('keypress', function (e) { // check for key press on ENTER (key code 13) to trigger the search http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/duration_chart.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/duration_chart.html b/airflow/www_rbac/templates/airflow/duration_chart.html index 89ddb94..e2eafd4 100644 --- a/airflow/www_rbac/templates/airflow/duration_chart.html +++ b/airflow/www_rbac/templates/airflow/duration_chart.html @@ -21,15 +21,14 @@ {% block head_css %} {{ super() }} <link rel="stylesheet" type="text/css" - href="{{ url_for('static', filename='tree.css') }}"> + href="{{ url_for('static', filename='css/tree.css') }}"> <link rel="stylesheet" type="text/css" href="{{url_for('appbuilder.static',filename='datepicker/bootstrap-datepicker.css')}}" > +<link href="{{ url_for_asset('dataTables.bootstrap.min.css') }}" rel="stylesheet" type="text/css" > <link rel="stylesheet" type="text/css" - href="{{ url_for("static", filename="dataTables.bootstrap.css") }}"> -<link rel="stylesheet" type="text/css" - href="{{ url_for("static", filename="nv.d3.css") }}"> -<script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script> -<script src="{{ url_for('static', filename='nv.d3.js') }}"></script> + href="{{ url_for_asset('nv.d3.min.css') }}"> +<script src="{{ url_for_asset('d3.min.js') }}"></script> +<script src="{{ url_for_asset('nv.d3.min.js') }}"></script> {% endblock %} {% block content %} http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/gantt.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/gantt.html b/airflow/www_rbac/templates/airflow/gantt.html index 3a567ee..64212a5 100644 --- a/airflow/www_rbac/templates/airflow/gantt.html +++ b/airflow/www_rbac/templates/airflow/gantt.html @@ -21,8 +21,8 @@ {{ super() }} <link rel="stylesheet" type="text/css" href="{{url_for('appbuilder.static',filename='datepicker/bootstrap-datepicker.css')}}" > -<link type="text/css" href="{{ url_for('static', filename='gantt.css') }}" rel="stylesheet" /> -<link type="text/css" href="{{ url_for('static', filename='tree.css') }}" rel="stylesheet" /> +<link type="text/css" href="{{ url_for('static', filename='css/gantt.css') }}" rel="stylesheet" /> +<link type="text/css" href="{{ url_for('static', filename='css/tree.css') }}" rel="stylesheet" /> {% endblock %} {% block content %} @@ -47,9 +47,9 @@ {% block tail %} {{ super() }} <script src="{{ url_for('appbuilder.static',filename='datepicker/bootstrap-datepicker.js') }}"></script> -<script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script> -<script src="{{ url_for('static', filename='d3.tip.v0.6.3.js') }}"></script>/ -<script src="{{ url_for('static', filename='gantt-chart-d3v2.js') }}"></script> +<script src="{{ url_for_asset('d3.min.js') }}"></script> +<script src="{{ url_for_asset('d3-tip.js') }}"></script>/ +<script src="{{ url_for_asset('ganttChartD3v2.js') }}"></script> <script> $( document ).ready(function() { var dag_id = '{{ dag.dag_id }}'; http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/graph.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/graph.html b/airflow/www_rbac/templates/airflow/graph.html index d56c5b7..2374428 100644 --- a/airflow/www_rbac/templates/airflow/graph.html +++ b/airflow/www_rbac/templates/airflow/graph.html @@ -22,9 +22,7 @@ {% block head_css %} {{ super() }} <link rel="stylesheet" type="text/css" - href="{{ url_for('static', filename='dagre.css') }}"> -<link rel="stylesheet" type="text/css" - href="{{ url_for('static', filename='graph.css') }}"> + href="{{ url_for('static', filename='css/graph.css') }}"> {% endblock %} {% block content %} @@ -95,8 +93,10 @@ {% block tail %} {{ super() }} - <script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script> - <script src="{{ url_for('static', filename='dagre-d3.js') }}"></script> + <script src="{{ url_for_asset('d3.min.js') }}"></script> + {# It's an old or custom dagre-d3 library not supported with webpack 4. #} + {# TODO: Fix this using NPM version #} + <script src="{{ url_for_asset('dagreD3.js') }}"></script> <script> var highlight_color = "#000000"; http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/airflow/tree.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/airflow/tree.html b/airflow/www_rbac/templates/airflow/tree.html index 1028861..da88631 100644 --- a/airflow/www_rbac/templates/airflow/tree.html +++ b/airflow/www_rbac/templates/airflow/tree.html @@ -21,8 +21,9 @@ {% block head_css %} {{ super() }} <link rel="stylesheet" type="text/css" - href="{{ url_for('static', filename='tree.css') }}"> -<link href="{{ url_for('static', filename='appbuilder/daterangepicker/bootstrap-datepicker.css') }}" rel="stylesheet"> + href="{{ url_for('static', filename='css/tree.css') }}"> +<link rel="stylesheet" type="text/css" + href="{{url_for('appbuilder.static',filename='datepicker/bootstrap-datepicker.css')}}" > {% endblock %} {% block content %} @@ -76,7 +77,7 @@ {% block tail %} {{ super() }} - <script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script> + <script src="{{ url_for_asset('d3.min.js') }}"></script> <script> $('span.status_square').tooltip({html: true}); http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/templates/appbuilder/baselayout.html ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/templates/appbuilder/baselayout.html b/airflow/www_rbac/templates/appbuilder/baselayout.html index eeb3d5c..6b0c441 100644 --- a/airflow/www_rbac/templates/appbuilder/baselayout.html +++ b/airflow/www_rbac/templates/appbuilder/baselayout.html @@ -20,9 +20,9 @@ {% block head_css %} {{ super() }} - <link href="{{ url_for('static', filename='main.css') }}" rel="stylesheet"> - <link href="{{ url_for('static', filename='bootstrap-theme.css') }}" rel="stylesheet"> - <link rel="icon" type="image/png" href="{{ url_for("static", filename="pin_30.png") }}"> + {# styleBundle.css file contains the styles from main.css and bootstrap-theme.css #} + <link href="{{ url_for_asset('styleBundle.css') }}" rel="stylesheet"> + <link rel="icon" type="image/png" href="{{ url_for('static', filename='pin_30.png') }}"> {% endblock %} @@ -34,7 +34,7 @@ {% include 'appbuilder/navbar.html' %} </header> {% endblock %} - + <div class="container"> <div class="row"> @@ -60,25 +60,10 @@ {% block tail_js %} {{ super() }} -<script src="{{ url_for('static', filename='jqClock.min.js') }}" type="text/javascript"></script> -<script> - x = new Date() - var UTCseconds = (x.getTime() + x.getTimezoneOffset()*60*1000); - $("#clock").clock({ - "dateFormat":"Y-m-d ", - "timeFormat":"H:i:s %UTC%", - "timestamp":UTCseconds - }).click(function(){ - alert('{{ hostname }}'); - }); - $('span').tooltip(); - - $.ajaxSetup({ - beforeSend: function(xhr, settings) { - if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) { - xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token() }}"); - } - } - }); +<script type="text/javascript"> + // below variables are used in clock.js + var hostName = '{{ hostname }}'; + var csrfToken = '{{ csrf_token() }}'; </script> -{% endblock %} \ No newline at end of file +<script src="{{ url_for_asset('clock.js') }}" type="text/javascript"></script> +{% endblock %} http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/airflow/www_rbac/webpack.config.js ---------------------------------------------------------------------- diff --git a/airflow/www_rbac/webpack.config.js b/airflow/www_rbac/webpack.config.js new file mode 100644 index 0000000..d20b0e2 --- /dev/null +++ b/airflow/www_rbac/webpack.config.js @@ -0,0 +1,128 @@ +/** +* 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. +*/ + +const webpack = require('webpack'); +const path = require('path'); +const ManifestPlugin = require('webpack-manifest-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); + +// Input Directory (airflow/www_rbac) +// noinspection JSUnresolvedVariable +const STATIC_DIR = path.resolve(__dirname, './static'); + +// Output Directory (airflow/www_rbac/static/dist) +// noinspection JSUnresolvedVariable +const BUILD_DIR = path.resolve(__dirname, './static/dist'); + +const config = { + entry: { + connectionForm: STATIC_DIR + '/js/connection_form.js', + clock: STATIC_DIR + '/js/clock.js', + dagreD3: STATIC_DIR + '/js/dagre-d3.js', + ganttChartD3v2: STATIC_DIR + '/js/gantt-chart-d3v2.js', + styleBundle: [ + STATIC_DIR + '/css/main.css', + STATIC_DIR + '/css/bootstrap-theme.css' + ] + }, + output: { + path: BUILD_DIR, + filename: '[name].[chunkhash].js', + chunkFilename: '[name].[chunkhash].js', + }, + resolve: { + extensions: [ + '.js', + '.jsx', + '.css', + ], + }, + module: { + rules: [ + { + test: /datatables\.net.*/, + loader: 'imports-loader?define=>false', + }, + { + test: /\.jsx?$/, + exclude: /node_modules/, + loader: 'babel-loader', + }, + // Extract css files + { + test: /\.css$/, + include: STATIC_DIR, + use: [ + MiniCssExtractPlugin.loader, + "css-loader" + ] + }, + /* for css linking images */ + { + test: /\.png$/, + loader: 'url-loader?limit=100000', + }, + { + test: /\.jpg$/, + loader: 'file-loader', + }, + { + test: /\.gif$/, + loader: 'file-loader', + }, + /* for font-awesome */ + { + test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, + loader: 'url-loader?limit=10000&mimetype=application/font-woff', + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, + loader: 'file-loader', + }, + ] + }, + plugins: [ + new ManifestPlugin(), + new CleanWebpackPlugin(['static/dist']), + new MiniCssExtractPlugin({filename: '[name].[chunkhash].css'}), + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify(process.env.NODE_ENV), + }, + }), + // Since we have all the dependencies separated from hard-coded JS within HTML, + // this seems like an efficient solution for now. Will update that once + // we'll have the dependencies imported within the custom JS + new CopyWebpackPlugin([ + {from: 'node_modules/nvd3/build/\*.min.\*',flatten:true}, + // Update this when upgrade d3 package, as the path in new D3 is different + {from: 'node_modules/d3/d3.min.\*', flatten:true}, + {from: 'node_modules/d3-tip/dist/index.js', to:'d3-tip.js', flatten:true}, + {from: 'node_modules/bootstrap-3-typeahead/\*min.\*', flatten:true}, + {from: 'node_modules/bootstrap-toggle/**/*bootstrap-toggle.min.\*', + flatten:true}, + {from: 'node_modules/datatables.net/**/*\*.min.\*',flatten:true}, + {from: 'node_modules/datatables.net-bs/**/*\*.min.\*',flatten:true}, + ], {copyUnmodified: true}) + ], +}; + +module.exports = config; http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/dev/README.md ---------------------------------------------------------------------- diff --git a/dev/README.md b/dev/README.md index 084020c..f5c9330 100755 --- a/dev/README.md +++ b/dev/README.md @@ -81,5 +81,16 @@ Unauthenticated users can only make 60 requests/hour to the Github API. If you g The release signing tool can be used to create the SHA512/MD5 and ASC files that required for Apache releases. ### Execution -To create a release tar ball execute `python setup.py sdist --formats=gztar` from Airflow's root. After that `cd dist` and -execute `../dev/sign.sh <the_created_tar_ball.tar.gz`. Signing files will be created in the same directory. +To create a release tar ball execute following command from Airflow's root. + +`python setup.py compile_assets sdist --formats=gztar` + +*Note: `compile_assets` command build the frontend assets (JS and CSS) files for the +Web UI using webpack and npm. Please make sure you have `npm` installed on your local machine globally. +Details on how to install `npm` can be found in CONTRIBUTING.md file.* + +After that navigate to relative directory i.e., `cd dist` and sign the release files. + +`../dev/sign.sh <the_created_tar_ball.tar.gz` + +Signing files will be created in the same directory. http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5a7f0b2e/setup.py ---------------------------------------------------------------------- diff --git a/setup.py b/setup.py index a8f63a8..b46a5a7 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ import imp import logging import os import sys +import subprocess logger = logging.getLogger(__name__) @@ -67,6 +68,23 @@ class CleanCommand(Command): os.system('rm -vrf ./build ./dist ./*.pyc ./*.tgz ./*.egg-info') +class CompileAssets(Command): + """ + Custom compile assets command to compile and build the frontend + assets using npm and webpack. + """ + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + subprocess.call('./airflow/www_rbac/compile_assets.sh') + + def git_version(version): """ Return a version to identify the state of the underlying git repo. The version will @@ -368,6 +386,7 @@ def do_setup(): cmdclass={ 'test': Tox, 'extra_clean': CleanCommand, + 'compile_assets': CompileAssets }, )
