def init_appbuilder_views(app): """Initialize Web UI views""" appbuilder = app.appbuilder from airflow.www import views # Remove the session from scoped_session registry to avoid # reusing a session with a disconnected connection appbuilder.session.remove() appbuilder.add_view_no_menu(views.DagModelView()) appbuilder.add_view_no_menu(views.Airflow()) appbuilder.add_view( views.DagRunModelView, permissions.RESOURCE_DAG_RUN, category=permissions.RESOURCE_BROWSE_MENU, category_icon="fa-globe", ) appbuilder.add_view(views.JobModelView, permissions.RESOURCE_JOB, category=permissions.RESOURCE_BROWSE_MENU) appbuilder.add_view(views.LogModelView, permissions.RESOURCE_AUDIT_LOG, category=permissions.RESOURCE_BROWSE_MENU) appbuilder.add_view(views.VariableModelView, permissions.RESOURCE_VARIABLE, category=permissions.RESOURCE_ADMIN_MENU) appbuilder.add_view( views.TaskInstanceModelView, permissions.RESOURCE_TASK_INSTANCE, category=permissions.RESOURCE_BROWSE_MENU, ) appbuilder.add_view( views.TaskRescheduleModelView, permissions.RESOURCE_TASK_RESCHEDULE, category=permissions.RESOURCE_BROWSE_MENU, ) appbuilder.add_view( views.ConfigurationView, permissions.RESOURCE_CONFIG, category=permissions.RESOURCE_ADMIN_MENU, category_icon="fa-user", ) appbuilder.add_view(views.ConnectionModelView, permissions.RESOURCE_CONNECTION, category=permissions.RESOURCE_ADMIN_MENU) appbuilder.add_view(views.SlaMissModelView, permissions.RESOURCE_SLA_MISS, category=permissions.RESOURCE_BROWSE_MENU) appbuilder.add_view(views.PluginView, permissions.RESOURCE_PLUGIN, category=permissions.RESOURCE_ADMIN_MENU) appbuilder.add_view(views.PoolModelView, permissions.RESOURCE_POOL, category=permissions.RESOURCE_ADMIN_MENU) appbuilder.add_view(views.XComModelView, permissions.RESOURCE_XCOM, category=permissions.RESOURCE_ADMIN_MENU) # add_view_no_menu to change item position. # I added link in extensions.init_appbuilder_links.init_appbuilder_links appbuilder.add_view_no_menu(views.RedocView)
def init_appbuilder_views(app): """Initialize Web UI views""" appbuilder = app.appbuilder from airflow.www import views # Remove the session from scoped_session registry to avoid # reusing a session with a disconnected connection appbuilder.session.remove() appbuilder.add_view_no_menu(views.Airflow()) appbuilder.add_view_no_menu(views.DagModelView()) appbuilder.add_view(views.DagRunModelView, "DAG Runs", category="Browse", category_icon="fa-globe") appbuilder.add_view(views.JobModelView, "Jobs", category="Browse") appbuilder.add_view(views.LogModelView, "Logs", category="Browse") appbuilder.add_view(views.SlaMissModelView, "SLA Misses", category="Browse") appbuilder.add_view(views.TaskInstanceModelView, "Task Instances", category="Browse") appbuilder.add_view(views.TaskRescheduleModelView, "Task Reschedules", category="Browse") appbuilder.add_view(views.ConfigurationView, "Configurations", category="Admin", category_icon="fa-user") appbuilder.add_view(views.ConnectionModelView, "Connections", category="Admin") appbuilder.add_view(views.PoolModelView, "Pools", category="Admin") appbuilder.add_view(views.VariableModelView, "Variables", category="Admin") appbuilder.add_view(views.XComModelView, "XComs", category="Admin") appbuilder.add_view(views.VersionView, 'Version', category='About', category_icon='fa-th') # add_view_no_menu to change item position. # I added link in extensions.init_appbuilder_links.init_appbuilder_links appbuilder.add_view_no_menu(views.RedocView)
def create_app(config=None): app = Flask(__name__) app.secret_key = conf.get('webserver', 'SECRET_KEY') #app.config = config login.login_manager.init_app(app) cache = Cache(app=app, config={ 'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp' }) app.register_blueprint(ck, url_prefix='/ck') app.register_blueprint(routes) app.jinja_env.add_extension("chartkick.ext.charts") with app.app_context(): from airflow.www.views import HomeView admin = Admin( app, name='Airflow', static_url_path='/admin', index_view=HomeView(endpoint='', url='/admin'), template_mode='bootstrap3', ) from airflow.www import views admin.add_view(views.Airflow(name='DAGs')) admin.add_view( views.SlaMissModelView(models.SlaMiss, Session, name="SLA Misses", category="Browse")) admin.add_view( views.TaskInstanceModelView(models.TaskInstance, Session, name="Task Instances", category="Browse")) admin.add_view( views.LogModelView(models.Log, Session, name="Logs", category="Browse")) admin.add_view( views.JobModelView(jobs.BaseJob, Session, name="Jobs", category="Browse")) admin.add_view( views.QueryView(name='Ad Hoc Query', category="Data Profiling")) admin.add_view( views.ChartModelView(models.Chart, Session, name="Charts", category="Data Profiling")) admin.add_view( views.KnowEventView(models.KnownEvent, Session, name="Known Events", category="Data Profiling")) admin.add_view( views.PoolModelView(models.Pool, Session, name="Pools", category="Admin")) admin.add_view( views.ConfigurationView(name='Configuration', category="Admin")) admin.add_view( views.UserModelView(models.User, Session, name="Users", category="Admin")) admin.add_view( views.ConnectionModelView(models.Connection, Session, name="Connections", category="Admin")) admin.add_view( views.VariableView(models.Variable, Session, name="Variables", category="Admin")) admin.add_link( base.MenuLink(category='Docs', name='Documentation', url='http://pythonhosted.org/airflow/')) admin.add_link( base.MenuLink(category='Docs', name='Github', url='https://github.com/airbnb/airflow')) admin.add_view(views.DagModelView(models.DagModel, Session, name=None)) # Hack to not add this view to the menu admin._menu = admin._menu[:-1] def integrate_plugins(): """Integrate plugins to the context""" from airflow.plugins_manager import (admin_views, flask_blueprints, menu_links) for v in admin_views: admin.add_view(v) for bp in flask_blueprints: print(bp) app.register_blueprint(bp) for ml in menu_links: admin.add_link(ml) integrate_plugins() @app.context_processor def jinja_globals(): return { 'hostname': socket.gethostname(), } @app.teardown_appcontext def shutdown_session(exception=None): settings.Session.remove() return app
def init_views(appbuilder): from airflow.www import views # Remove the session from scoped_session registry to avoid # reusing a session with a disconnected connection appbuilder.session.remove() appbuilder.add_view_no_menu(views.Airflow()) appbuilder.add_view_no_menu(views.DagModelView()) appbuilder.add_view(views.DagRunModelView, "DAG Runs", category="Browse", category_icon="fa-globe") appbuilder.add_view(views.JobModelView, "Jobs", category="Browse") appbuilder.add_view(views.LogModelView, "Logs", category="Browse") appbuilder.add_view(views.SlaMissModelView, "SLA Misses", category="Browse") appbuilder.add_view(views.TaskInstanceModelView, "Task Instances", category="Browse") appbuilder.add_view(views.ConfigurationView, "Configurations", category="Admin", category_icon="fa-user") appbuilder.add_view(views.ConnectionModelView, "Connections", category="Admin") appbuilder.add_view(views.PoolModelView, "Pools", category="Admin") appbuilder.add_view(views.VariableModelView, "Variables", category="Admin") appbuilder.add_view(views.XComModelView, "XComs", category="Admin") if "dev" in version.version: airflow_doc_site = "https://airflow.readthedocs.io/en/latest" else: airflow_doc_site = 'https://airflow.apache.org/docs/{}'.format( version.version) appbuilder.add_link("Website", href='https://airflow.apache.org', category="Docs", category_icon="fa-globe") appbuilder.add_link("Documentation", href=airflow_doc_site, category="Docs", category_icon="fa-cube") appbuilder.add_link("GitHub", href='https://github.com/apache/airflow', category="Docs") appbuilder.add_view(views.VersionView, 'Version', category='About', category_icon='fa-th') def integrate_plugins(): """Integrate plugins to the context""" from airflow import plugins_manager plugins_manager.initialize_web_ui_plugins() for v in plugins_manager.flask_appbuilder_views: log.debug("Adding view %s", v["name"]) appbuilder.add_view(v["view"], v["name"], category=v["category"]) for ml in sorted(plugins_manager.flask_appbuilder_menu_links, key=lambda x: x["name"]): log.debug("Adding menu link %s", ml["name"]) appbuilder.add_link(ml["name"], href=ml["href"], category=ml["category"], category_icon=ml["category_icon"]) integrate_plugins()
def init_views(appbuilder): from airflow.www import views appbuilder.add_view_no_menu(views.Airflow()) appbuilder.add_view_no_menu(views.DagModelView()) appbuilder.add_view_no_menu(views.ConfigurationView()) appbuilder.add_view_no_menu(views.VersionView()) appbuilder.add_view(views.DagRunModelView, "DAG Runs", category="Browse", category_icon="fa-globe") appbuilder.add_view(views.JobModelView, "Jobs", category="Browse") appbuilder.add_view(views.LogModelView, "Logs", category="Browse") appbuilder.add_view(views.SlaMissModelView, "SLA Misses", category="Browse") appbuilder.add_view(views.TaskInstanceModelView, "Task Instances", category="Browse") appbuilder.add_link("Configurations", href='/configuration', category="Admin", category_icon="fa-user") appbuilder.add_view(views.ConnectionModelView, "Connections", category="Admin") appbuilder.add_view(views.PoolModelView, "Pools", category="Admin") appbuilder.add_view(views.VariableModelView, "Variables", category="Admin") appbuilder.add_view(views.XComModelView, "XComs", category="Admin") appbuilder.add_link("Documentation", href='https://airflow.apache.org/', category="Docs", category_icon="fa-cube") appbuilder.add_link("GitHub", href='https://github.com/apache/airflow', category="Docs") appbuilder.add_link('Version', href='/version', category='About', category_icon='fa-th') def integrate_plugins(): """Integrate plugins to the context""" from airflow.plugins_manager import ( flask_appbuilder_views, flask_appbuilder_menu_links) for v in flask_appbuilder_views: log.debug("Adding view %s", v["name"]) appbuilder.add_view(v["view"], v["name"], category=v["category"]) for ml in sorted(flask_appbuilder_menu_links, key=lambda x: x["name"]): log.debug("Adding menu link %s", ml["name"]) appbuilder.add_link(ml["name"], href=ml["href"], category=ml["category"], category_icon=ml["category_icon"]) integrate_plugins()
def init_views(appbuilder): override_route_base("airflow") from airflow.www import views # Remove the session from scoped_session registry to avoid # reusing a session with a disconnected connection appbuilder.session.remove() appbuilder.add_view_no_menu(views.Airflow()) appbuilder.add_view_no_menu(views.DagModelView()) appbuilder.add_view(views.DagRunModelView, "DAG Runs", category="Browse", category_icon="fa-globe") appbuilder.add_view(views.JobModelView, "Jobs", category="Browse") appbuilder.add_view(views.LogModelView, "Logs", category="Browse") appbuilder.add_view(views.SlaMissModelView, "SLA Misses", category="Browse") appbuilder.add_view(views.TaskInstanceModelView, "Task Instances", category="Browse") appbuilder.add_view(views.ConfigurationView, "Configurations", category="Admin", category_icon="fa-user") appbuilder.add_view(views.ConnectionModelView, "Connections", category="Admin") appbuilder.add_view(views.PoolModelView, "Pools", category="Admin") appbuilder.add_view(views.VariableModelView, "Variables", category="Admin") appbuilder.add_view(views.XComModelView, "XComs", category="Admin") if "dev" in version.version: airflow_doc_site = "https://airflow.readthedocs.io/en/latest" else: airflow_doc_site = 'https://airflow.apache.org/docs/1.10.9' appbuilder.add_link("Website", href='https://airflow.apache.org', category="Docs", category_icon="fa-globe") appbuilder.add_link("Documentation", href=airflow_doc_site, category="Docs", category_icon="fa-cube") appbuilder.add_link("GitHub", href='https://github.com/apache/airflow', category="Docs") appbuilder.add_link("Qubole Documentation", href='http://docs.qubole.com/en/latest/user-guide/airflow/index.html', category="Docs", category_icon="fa-cube") appbuilder.add_link("Blog", href='https://www.qubole.com/tech-category/airflow/', category="Docs", category_icon="fa-cube") appbuilder.add_link("Video Tutorial", href='https://www.youtube.com/watch?v=4_Ifm4PNRyg&list=PL5_c35Deekdm6N1OBHdQm7JZECTdm7zl-', category="Docs", category_icon="fa-cube") appbuilder.add_view(views.VersionView, 'Version', category='About', category_icon='fa-th') def integrate_plugins(): """Integrate plugins to the context""" from airflow.plugins_manager import ( flask_appbuilder_views, flask_appbuilder_menu_links ) for v in flask_appbuilder_views: log.debug("Adding view %s", v["name"]) appbuilder.add_view(v["view"], v["name"], category=v["category"]) for ml in sorted(flask_appbuilder_menu_links, key=lambda x: x["name"]): log.debug("Adding menu link %s", ml["name"]) appbuilder.add_link(ml["name"], href=ml["href"], category=ml["category"], category_icon=ml["category_icon"]) integrate_plugins()