コード例 #1
0
def node_page(path: str):
    """Creates a node visualization page including title, action buttons, etc."""
    node, found = pipelines.find_node(path.split('/'))
    if not found and node:
        return flask.redirect(views.node_url(node), 302)
    elif not node:
        flask.abort(404, f'Node "{path}" not found')

    title = [node.__class__.__name__, ' ',
             [[_.a(href=views.node_url(parent))[parent.id], ' / '] for parent in node.parents()[1:-1]],
             node.id] if node.parent else 'Data Integration'
    return response.Response(
        title=title,
        action_buttons=action_buttons(node) if config.allow_run_from_web_ui() else [],
        html=[_.script['''
var nodePage = null;
document.addEventListener('DOMContentLoaded', function() {
     nodePage = NodePage("''' + flask.url_for('data_integration.node_page', path='') + '''");
});'''],
              dependency_graph.card(node),
              run_time_chart.card(node),
              node_content(node),
              last_runs.card(node)],
        js_files=['https://www.gstatic.com/charts/loader.js',
                  flask.url_for('data_integration.static', filename='node-page.js'),
                  flask.url_for('data_integration.static', filename='utils.js'),
                  flask.url_for('data_integration.static', filename='run-time-chart.js'),
                  flask.url_for('data_integration.static', filename='system-stats-chart.js'),
                  flask.url_for('data_integration.static', filename='timeline-chart.js'),
                  flask.url_for('data_integration.static', filename='kolorwheel.js')],
        css_files=[flask.url_for('data_integration.static', filename='common.css'),
                   flask.url_for('data_integration.static', filename='node-page.css'),
                   flask.url_for('data_integration.static', filename='timeline-chart.css')])
コード例 #2
0
        def render_entry(entry: navigation.NavigationEntry, level: int = 1):
            attrs = {}
            if entry.children:
                attrs.update({'onClick': 'toggleNavigationEntry(this)'})
            else:
                attrs.update({
                    'onClick':
                    'highlightNavigationEntry(\'' + entry.uri_fn() +
                    '\');collapseNavigation()',
                    'href':
                    entry.uri_fn()
                })

            if entry.description:
                attrs.update({
                    'title': entry.description,
                    'data-toggle': 'tooltip',
                    'data-container': 'body',
                    'data-placement': 'right'
                })
            return _.div(
                _class='mara-nav-entry level-' + str(level),
                style='display:none' if level > 1 else
                '')[_.a(**attrs)[_.span(_class='fa fa-fw fa-' + entry.icon + (
                    ' fa-lg' if level == 1 else ''))[''] if entry.icon else '',
                                 entry.label.replace('_', '_<wbr>'),
                                 _.div(_class='mara-caret fa fa-caret-down'
                                       )[''] if entry.children else ''],
                    render_entries(entry.children, level + 1)]
コード例 #3
0
def pipeline_children_table(path: str):
    """Creates a table that documents all child nodes of a table"""
    pipeline, __ = pipelines.find_node(path.split('/'))
    assert (isinstance(pipeline, pipelines.Pipeline))

    node_durations_and_run_times = node_cost.node_durations_and_run_times(pipeline.path())

    rows = []
    for node in pipeline.nodes.values():
        [avg_duration, avg_run_time] = node_durations_and_run_times.get(tuple(node.path()), ['', ''])

        rows.append(
            _.tr[_.td[_.a(href=views.node_url(node))[node.id.replace('_', '_<wbr>')]],
                 _.td[node.description],
                 _.td[views.format_labels(node)],
                 _.td[node_cost.format_duration(avg_duration)],
                 _.td(style='color:#bbb' if avg_duration == avg_run_time else '')[
                     node_cost.format_duration(avg_run_time)],
                 _.td[node_cost.format_duration(
                     node_cost.compute_cost(node, node_durations_and_run_times))],
                 _.td[(_.input(class_='pipeline-node-checkbox', type='checkbox',
                               value=node.id, name='ids[]', onchange='runButtons.update()')
                 if config.allow_run_from_web_ui() else '')]])

    return \
        str(_.script['var runButtons = new PipelineRunButtons();']) \
        + str(bootstrap.table(['ID', 'Description', '', 'Avg duration', 'Avg run time', 'Cost', ''], rows)) \
        + str(_.script['floatMaraTableHeaders();'])
コード例 #4
0
def action_button(button: mara_page.response.ActionButton):
    """Renders an action button"""
    return [
        _.a(_class='btn', href=button.action,
            title=button.title)[_.span(_class='fa fa-' + button.icon)[''], ' ',
                                button.label]
    ]
コード例 #5
0
        def render_entry(entry: navigation.NavigationEntry, level: int = 1):
            attrs = {}
            if entry.children:
                attrs['onClick'] = 'toggleNavigationEntry(this)'
            else:
                attrs['href'] = entry.uri_fn()

            if entry.description:
                attrs.update({
                    'title': entry.description,
                    'data-toggle': 'tooltip',
                    'data-container': 'body',
                    'data-placement': 'right'
                })
            return _.div(
                class_='mara-nav-entry level-' + str(level),
                style='display:none' if level > 1 else ''
            )[_.a(**attrs)[_.div(
                class_='mara-nav-entry-icon fa fa-fw fa-' + entry.icon +
                (' fa-lg' if level == 1 else ''))[''] if entry.icon else '',
                           _.div(class_='mara-nav-entry-text'
                                 )[entry.label.replace('_', '_<wbr>')],
                           _.div(class_='mara-caret fa fa-caret-down'
                                 )[''] if entry.children else ''],
              render_entries(entry.children, level + 1)]
コード例 #6
0
ファイル: views.py プロジェクト: jimmyhu4/mara-schema
def index_page() -> response.Response:
    """Renders the overview page"""
    from ..config import data_sets

    return response.Response(html=[
        bootstrap.card(header_left='Entities & their relations',
                       body=html.asynchronous_content(
                           flask.url_for('mara_schema.overview_graph'))),
        bootstrap.card(
            header_left='Data sets',
            body=bootstrap.table(['Name', 'Description'], [
                _.tr[_.td[_.a(
                    href=flask.
                    url_for('mara_schema.data_set_page', id=data_set.id()
                            ))[escape(data_set.name)]],
                     _.td[_.i[escape(data_set.entity.description)]], ]
                for data_set in data_sets()
            ]),
        )
    ],
                             title='Data sets documentation',
                             css_files=[
                                 flask.url_for('mara_schema.static',
                                               filename='schema.css')
                             ])
コード例 #7
0
def page_header(response: mara_page.response.Response):
    """Renders the fixed top part of the page"""
    return _.nav(id='mara-page-header', _class='navbar fixed-top')[
        _.a(_class='navigation-toggle-button fa fa-lg fa-reorder',
            onclick='toggleNavigation()')[' '],
        _.h1()[response.title],
        _.img(src=config.logo_url()),
        _.span(_class='action-buttons')[map(action_button, response.
                                            action_buttons)]]
コード例 #8
0
ファイル: docs.py プロジェクト: mara/mara-markdown-docs
def start_page():
    links = []
    for full_doc_id, doc in all_docs().items():
        folder_id, doc_id = doc.ids
        links.append(_.li[_.a(href=flask.url_for('docs.document', doc_id=doc_id, folder_id=folder_id))[doc.full_name]])

    return response.Response(title='Docs', html=[
        bootstrap.card(header_left='Table of Content', body=[_.ul[links]])
    ])
コード例 #9
0
def page_header(response: mara_page.response.Response):
    """Renders the fixed top part of the page"""
    return _.nav(id='mara-page-header', class_='navbar fixed-top')[
        _.a(class_='navigation-toggle-button fa fa-lg fa-reorder',
            onclick='toggleNavigation()')[' '],
        _.img(src=config.logo_url() + '?' + _current_git_commit()),
        _.h1[response.title],
        _.div(class_='action-buttons')[map(action_button, response.
                                           action_buttons)], ]
コード例 #10
0
def index_page():
    return response.Response(
        html=[bootstrap.card(
            header_left=_.a(href=flask.url_for('mara_data_explorer.data_set_page', data_set_id=ds.id))[ds.name],
            body=[html.asynchronous_content(flask.url_for('mara_data_explorer.data_set_preview', data_set_id=ds.id))])
            for i, ds in enumerate(config.data_sets())],
        title='Data sets',
        js_files=[flask.url_for('mara_data_explorer.static', filename='data-sets.js')],
        css_files=[flask.url_for('mara_data_explorer.static', filename='data-sets.css')])
コード例 #11
0
def query_list(data_set_id):
    from .query import list_queries

    queries = list_queries(data_set_id)
    if queries:
        return str(bootstrap.table(
            headers=['Query', 'Last changed', 'By'],
            rows=[_.tr[_.td[
                           _.a(href=flask.url_for('mara_data_explorer.data_set_page', data_set_id=data_set_id, query_id=row[0]))[
                               row[0]]],
                       _.td[row[1].strftime('%Y-%m-%d')],
                       _.td[row[2]]] for row in queries]))
    else:
        return 'No queries saved yet'
コード例 #12
0
def index_page():
    """Overview page of mara_db"""
    return response.Response(
        title=f'Database schemas',
        html=bootstrap.card(body=[
            _.div(
                style=
                'display:inline-block; margin-top:15px; margin-bottom:15px; margin-right:50px;'
            )[_.a(href=flask.url_for('mara_db.schema_page', db_alias=db_alias)
                  )[_.span(class_='fa fa-database')[''], ' ', db_alias], _.br,
              _.span(style='color:#888')[escape(str(type(db).__name__))]]
            for db_alias, db in config.databases().items()
        ]),
        js_files=[flask.url_for('mara_db.static', filename='schema-page.js')])
コード例 #13
0
    def header(column: Column):
        if column.sortable():
            if query.sort_column_name == column.column_name and query.sort_order == 'ASC':
                icon = _.span(class_=('fa fa-sort-amount-asc'))['']
            elif query.sort_column_name == column.column_name and query.sort_order == 'DESC':
                icon = _.span(class_=('fa fa-sort-amount-desc'))['']
            else:
                icon = ''

            return _.a(href="#", name=flask.escape(column.column_name))[
                icon, ' ',
                flask.escape(column.column_name)]
        else:
            return flask.escape(column.column_name)
コード例 #14
0
ファイル: bootstrap.py プロジェクト: Danielson23/mara-page
def button(url: str, label: str, title: str, icon: str, id: str = None):
    """
    Renders a bootstrap button
    Args:
        url: The action to perform
        label: The button label
        title: A help message
        icon: An icon from the `fontawesome`_ collection
        id: An id that is added to the element
    Returns:
        The rendered button

    .. _fontawesome:
       http://fontawesome.io/icons/
    """
    return _.a(class_='btn mara-button', href=url, title=title, id=id or uuid.uuid1())[
        _.span(class_='fa fa-' + icon)[''], ' ', label]
コード例 #15
0
ファイル: views.py プロジェクト: jimmyhu4/mara-schema
 def attribute_rows(data_set: DataSet) -> []:
     rows = []
     for path, attributes in data_set.connected_attributes().items():
         if path:
             rows.append(_.tr[_.td(
                 colspan=3, style='border-top:none; padding-top: 20px;'
             )[[[
                 '→ ',
                 _.a(
                     href=data_set_url(entity.data_set)
                 )[link_title] if entity.data_set else link_title, ' &nbsp;'
             ] for entity, link_title in [(
                 entity_link.target_entity,
                 entity_link.prefix or entity_link.target_entity.name)
                                          for entity_link in path]],
               [' &nbsp;&nbsp;', _.
                i[path[-1].description]] if path[-1].description else '']])
         for prefixed_name, attribute in attributes.items():
             rows.append(_.tr[_.td[escape(prefixed_name)], _.td[_.i[escape(
                 attribute.description
             )]], _.td[_.tt[escape(
                 f'{path[-1].target_entity.table_name + "." if path else ""}{attribute.column_name}'
             )]]])
     return rows
コード例 #16
0
def data_set_page(data_set_id, query_id):
    from .data_set import find_data_set
    ds = find_data_set(data_set_id)
    if not ds:
        flask.flash(f'Data set "{data_set_id}" does not exist anymore', category='danger')
        return flask.redirect(flask.url_for('mara_data_explorer.index_page'))

    action_buttons = []

    action_buttons.append(response.ActionButton(action='javascript:dataSetPage.downloadCSV()',
                                                icon='download',
                                                label='CSV', title='Download as CSV'))
    if config.google_sheet_oauth2_client_config():
        action_buttons.append(response.ActionButton(action='javascript:dataSetPage.exportToGoogleSheet()',
                                                    icon='cloud-upload',
                                                    label='Google sheet', title='Export to a Google sheet'))
    action_buttons.append(response.ActionButton(action='javascript:dataSetPage.load()',
                                                icon='folder-open',
                                                label='Load', title='Load previously saved query'))
    action_buttons.append(response.ActionButton(action='javascript:dataSetPage.save()',
                                                icon='save',
                                                label='Save', title='Save query'))
    action_buttons.append(response.ActionButton(action='javascript:dataSetPage.displayQuery()',
                                                icon='eye',
                                                label='SQL', title='Display query'))

    if query_id:
        action_buttons.insert(1, response.ActionButton(
            action=flask.url_for('mara_data_explorer._delete_query', data_set_id=data_set_id, query_id=query_id),
            icon='trash', label='Delete', title='Delete query'))

    return response.Response(
        title=f'Query "{query_id}" on "{ds.name}"' if query_id else f'New query on "{ds.name}"',
        html=[_.div(class_='row')[
                  _.div(class_='col-md-3')[
                      bootstrap.card(header_left='Query', body=_.div(id='query-details')[html.spinner()]),
                      bootstrap.card(header_left='Columns',
                                     header_right=_.a(id='select-all', href='#')[' Select all'],
                                     body=[_.div(class_="form-group")[
                                               _.input(type="search", class_="columns-search form-control",
                                                       value="", placeholder="Filter")],
                                           _.div(id='columns-list')[html.spinner()]])],
                  _.div(class_='col-md-9')[
                      bootstrap.card(
                          id='filter-card',
                          header_left=[_.div(class_="dropdown")[
                                           _.a(**{'class': 'dropdown-toggle', 'data-toggle': 'dropdown', 'href': '#'})[
                                               _.span(class_='fa fa-plus')[' '], ' Add filter'],
                                           _.div(class_="dropdown-menu", id='filter-menu')[
                                               _.div(class_="dropdown-item")[
                                                   _.input(type="text", class_="columns-search form-control", value="",
                                                           placeholder="Filter")]]]],
                          fixed_header_height=False,
                          body=_.div(id='filters')[html.spinner()]),
                      bootstrap.card(header_left=_.div(id='row-counts')[html.spinner()],
                                     header_right=_.div(id='pagination')[html.spinner()],
                                     body=_.div(id='preview')[html.spinner()]),
                      _.div(class_='row', id='distribution-charts')['']
                  ]], _.script[f"""
var dataSetPage = null;                  
document.addEventListener('DOMContentLoaded', function() {{
    dataSetPage = DataSetPage('{flask.url_for('mara_data_explorer.index_page')}', 
                              {json.dumps(
            {'data_set_id': data_set_id, 'query_id': query_id, 'query': flask.request.get_json()})},
                              15, '{config.charts_color()}');
}});
            """],
              html.spinner_js_function(),
              _.div(class_='col-xl-4 col-lg-6', id='distribution-chart-template', style='display: none')[
                  bootstrap.card(header_left=html.spinner(), body=_.div(class_='chart-container google-chart')[
                      html.spinner()])],
              _.div(class_='modal fade', id='load-query-dialog', tabindex="-1")[
                  _.div(class_='modal-dialog', role='document')[
                      _.div(class_='modal-content')[
                          _.div(class_='modal-header')[
                              _.h5(class_='modal-title')['Load query'],
                              _.button(**{'type': "button", 'class': "close", 'data-dismiss': "modal",
                                          'aria-label': "Close"})[
                                  _.span(**{'aria-hidden': 'true'})['&times']]],
                          _.div(class_='modal-body', id='query-list')['']
                      ]
                  ]
              ],
              _.div(class_='modal fade', id='display-query-dialog', tabindex="-1")[
                  _.div(class_='modal-dialog', role='document')[
                      _.div(class_='modal-content')[
                          _.div(class_='modal-header')[
                              _.h5(class_='modal-title')['Query statement'],
                              _.button(**{'type': "button", 'class': "close", 'data-dismiss': "modal",
                                          'aria-label': "Close"})[
                                  _.span(**{'aria-hidden': 'true'})['&times']]],
                          _.div(class_='modal-body', id='query-display')['']
                      ]
                  ]
              ],
              _.form(action=flask.url_for('mara_data_explorer.download_csv', data_set_id=data_set_id), method='post')[
                  _.div(class_="modal fade", id="download-csv-dialog", tabindex="-1")[
                      _.div(class_="modal-dialog", role='document')[
                          _.div(class_="modal-content")[
                              _.div(class_="modal-header")[
                                  _.h5(class_='modal-title')['Download as CSV'],
                                  _.button(**{'type': "button", 'class': "close", 'data-dismiss': "modal",
                                              'aria-label': "Close"})[
                                      _.span(**{'aria-hidden': 'true'})['&times']]],
                              _.div(class_="modal-body")[
                                  'Delimiter: &nbsp',
                                  _.input(type="radio", value="\t", name="delimiter",
                                          checked="checked"), ' tab &nbsp&nbsp',

                                  _.input(type="radio", value=";", name="delimiter"), ' semicolon &nbsp&nbsp',
                                  _.input(type="radio", value=",", name="delimiter"), ' comma &nbsp&nbsp',
                                  _.hr,
                                  'Number format: &nbsp',
                                  _.input(type="radio", value=".", name="decimal-mark",
                                          checked="checked"), ' 42.7 &nbsp&nbsp',
                                  _.input(type="radio", value=",", name="decimal-mark"), ' 42,7 &nbsp&nbsp',
                                  _.input(type="hidden", name="query")],
                              _.div(class_="modal-footer")[
                                  _.button(id="csv-download-button", type="submit", class_="btn btn-primary")[
                                      'Download']]]]]],

              _.form(action=flask.url_for('mara_data_explorer.oauth2_export_to_google_sheet', data_set_id=data_set_id),
                     method='post',
                     target="_blank")[
                  _.div(class_="modal fade", id="google-sheet-export-dialog", tabindex="-1")[
                      _.div(class_="modal-dialog", role='document')[
                          _.div(class_="modal-content")[
                              _.div(class_="modal-header")[
                                  _.h5(class_='modal-title')['Google sheet export'],
                                  _.button(**{'type': "button", 'class': "close", 'data-dismiss': "modal",
                                              'aria-label': "Close"})[
                                      _.span(**{'aria-hidden': 'true'})['&times']]],
                              _.div(class_="modal-body")[
                                  'Number format: &nbsp',
                                  _.input(type="radio", value=".", name="decimal-mark",
                                          checked="checked"), ' 42.7 &nbsp&nbsp',
                                  _.input(type="radio", value=",", name="decimal-mark"), ' 42,7 &nbsp&nbsp',
                                  _.hr,
                                  'Array format: &nbsp',
                                  _.input(type="radio", value="curly", name="array-format",
                                          checked="checked"), ' {"a", "b"} &nbsp&nbsp',
                                  _.input(type="radio", value="normal", name="array-format"), ' ["a", "b"] &nbsp&nbsp',
                                  _.input(type="radio", value="tuple", name="array-format"), ' ("a", "b") &nbsp&nbsp',
                                  _.hr,
                                  'By clicking Export below:',
                                  _.br,
                                  _.ul[
                                      _.li['Google authentication will be required.'],
                                      _.li['A maximum limit of 100.000 rows will be applied.'],
                                      _.li['A maximum limit of 50.000 characters per cell will be applied.'],
                                      _.li['A Google sheet with the selected data will be available in a new tab.']
                                  ],
                                  _.input(type="hidden", name="query")
                              ],
                              _.div(class_="modal-footer")[
                                  _.button(id="export-to-google-sheet", type="submit", class_="btn btn-primary")[
                                      'Export']]]]]]

              ],
        action_buttons=action_buttons,
        js_files=['https://www.gstatic.com/charts/loader.js',
                  flask.url_for('mara_data_explorer.static', filename='tagsinput.js'),
                  flask.url_for('mara_data_explorer.static', filename='typeahead.js'),
                  flask.url_for('mara_data_explorer.static', filename='data-sets.js')],
        css_files=[flask.url_for('mara_data_explorer.static', filename='tagsinput.css'),
                   flask.url_for('mara_data_explorer.static', filename='data-sets.css')])
コード例 #17
0
ファイル: views.py プロジェクト: davidp94/data-sets
def data_set_page(data_set_id, query_id):
    ds = find_data_set(data_set_id)
    if not ds:
        flask.flash(f'Data set "{data_set_id}" does not exist anymore',
                    category='danger')
        return flask.redirect(flask.url_for('data_sets.index_page'))

    action_buttons = [
        response.ActionButton(action='javascript:dataSetPage.downloadCSV()',
                              icon='download',
                              label='CSV',
                              title='Download as CSV'),
        response.ActionButton(action='javascript:dataSetPage.load()',
                              icon='folder-open',
                              label='Load',
                              title='Load previously saved query'),
        response.ActionButton(action='javascript:dataSetPage.save()',
                              icon='save',
                              label='Save',
                              title='Save query')
    ]

    if query_id:
        action_buttons.insert(
            1,
            response.ActionButton(action=flask.url_for(
                'data_sets._delete_query',
                data_set_id=data_set_id,
                query_id=query_id),
                                  icon='trash',
                                  label='Delete',
                                  title='Delete query'))

    return response.Response(
        title=f'Query "{query_id}" on "{ds.name}"'
        if query_id else f'New query on "{ds.name}"',
        html=[
            _.div(
                class_='row')[_.div(
                    class_='col-md-3'
                )[bootstrap.card(header_left='Query',
                                 body=_.div(
                                     id='query-details')[html.spinner()]),
                  bootstrap.
                  card(header_left='Columns',
                       body=[
                           _.div(
                               class_="form-group"
                           )[_.input(type="search",
                                     class_="columns-search form-control",
                                     value="",
                                     placeholder="Filter")],
                           _.div(id='columns-list')[html.spinner()]
                       ])],
                              _.div(class_='col-md-9')[bootstrap.card(
                                  id='filter-card',
                                  header_left=[
                                      _.div(class_="dropdown")[_.a(
                                          **{
                                              'class': 'dropdown-toggle',
                                              'data-toggle': 'dropdown',
                                              'href': '#'
                                          }
                                      )[_.span(
                                          class_='fa fa-plus')[' '],
                                        ' Add filter'],
                                                               _.
                                                               div(class_=
                                                                   "dropdown-menu",
                                                                   id=
                                                                   'filter-menu'
                                                                   )
                                                               [_.div(
                                                                   class_
                                                                   ="dropdown-item"
                                                               )[_.input(
                                                                   type
                                                                   ="text",
                                                                   class_=
                                                                   "columns-search form-control",
                                                                   value="",
                                                                   placeholder=
                                                                   "Filter")]]]
                                  ],
                                  fixed_header_height=False,
                                  body=_.div(id='filters')[html.spinner()]),
                                                       bootstrap.
                                                       card(header_left=_.div(
                                                           id='row-counts'
                                                       )[html.spinner()],
                                                            header_right=_.div(
                                                                id='pagination'
                                                            )[html.spinner()],
                                                            body=_.div(
                                                                id='preview'
                                                            )[html.spinner()]),
                                                       _.
                                                       div(class_='row',
                                                           id=
                                                           'distribution-charts'
                                                           )['']]],
            _.script[f"""
var dataSetPage = null;                  
document.addEventListener('DOMContentLoaded', function() {{
    dataSetPage = DataSetPage('{flask.url_for('data_sets.index_page')}', 
                              {json.dumps({'data_set_id': data_set_id, 'query_id': query_id, 'query': flask.request.get_json()})},
                              15, '{config.charts_color()}');
}});
            """],
            html.spinner_js_function(),
            _.div(class_='col-xl-4 col-lg-6',
                  id='distribution-chart-template',
                  style='display: none')[bootstrap.card(
                      header_left=html.spinner(),
                      body=_.div(class_='chart-container google-chart')[
                          html.spinner()])],
            _.div(
                class_='modal fade', id='load-query-dialog',
                tabindex="-1")[_.div(
                    class_='modal-dialog', role='document')[_.div(
                        class_='modal-content')[_.div(class_='modal-header')[
                            _.h5(class_='modal-title')['Load query'],
                            _.button(
                                **{
                                    'type': "button",
                                    'class': "close",
                                    'data-dismiss': "modal",
                                    'aria-label': "Close"
                                })[_.span(
                                    **{'aria-hidden': 'true'})['&times']]],
                                                _.div(class_='modal-body',
                                                      id='query-list')['']]]],
            _.form(
                action=flask.url_for('data_sets.download_csv'),
                method='post')[_.div(
                    class_="modal fade",
                    id="download-csv-dialog",
                    tabindex="-1"
                )[_.div(class_="modal-dialog", role='document')[_.div(
                    class_="modal-content"
                )[_.div(class_="modal-header")
                  [_.h5(class_='modal-title')['Download as CSV'],
                   _.button(
                       **{
                           'type': "button",
                           'class': "close",
                           'data-dismiss': "modal",
                           'aria-label': "Close"
                       })[_.span(
                           **{'aria-hidden': 'true'})['&times']]],
                  _.div(class_="modal-body")[
                      'Delimiter: &nbsp',
                      _.input(type="radio",
                              value="\t",
                              name="delimiter",
                              checked="checked"),
                      ' tab &nbsp&nbsp',
                      _.input(type="radio", value=";", name="delimiter"),
                      ' semicolon &nbsp&nbsp',
                      _.input(type="radio", value=",", name="delimiter"),
                      ' comma &nbsp&nbsp', _.hr, 'Number format: &nbsp',
                      _.input(type="radio",
                              value=".",
                              name="decimal-mark",
                              checked="checked"), ' 42.7 &nbsp&nbsp',
                      _.input(type="radio", value=",", name="decimal-mark"),
                      ' 42,7 &nbsp&nbsp',
                      _.input(type="hidden", name="query")],
                  _.div(class_="modal-footer"
                        )[_.button(id="csv-download-button",
                                   type="submit",
                                   class_="btn btn-primary")['Download']]]]]]
        ],
        action_buttons=action_buttons,
        js_files=[
            'https://www.gstatic.com/charts/loader.js',
            flask.url_for('data_sets.static', filename='tagsinput.js'),
            flask.url_for('data_sets.static', filename='typeahead.js'),
            flask.url_for('data_sets.static', filename='data-sets.js')
        ],
        css_files=[
            flask.url_for('data_sets.static', filename='tagsinput.css'),
            flask.url_for('data_sets.static', filename='data-sets.css')
        ])
コード例 #18
0
def start_page():
    import mara_pipelines.config

    from mara_data_explorer.data_set import find_data_set
    data_set_for_preview = find_data_set('order_items')
    assert (data_set_for_preview)

    return response.Response(
        title='MyCompany BI',
        html=_.div(class_='row')[_.div(
            class_='col-lg-6'
        )[bootstrap.
          card(header_left=_.b['Welcome'],
               body=[
                   _.
                   p['This is the first thing that users of your data warehouse will see. ',
                     'Please add links to relevant documentation, tutorials & other ',
                     'data tools in your organization.'], _.p[
                         _.a(href='https://github.com/mara/mara-example-project-1/blob/master/app/ui/start_page.py'
                             )[
                                 'Here'],
                         ' is the source code for this page, and here is a picture of a ',
                         _.a(href='https://en.wikipedia.org/wiki/Mara_(mammal)'
                             )[
                                 'mara'], ':'],
                   _.
                   img(src=flask.url_for('ui.static', filename='mara.jpg'),
                       style
                       ='width:40%; margin-left: auto; margin-right:auto; display:block;'
                       )
               ]),
          bootstrap.card(header_left=[
              _.b[_.a(href=flask.url_for('mara_metabase.metabase'))[_.span(
                  class_='fa fa-bar-chart')[''], ' Metabase']], ' &amp; ', _.
              b[_.a(href=flask.url_for('mara_mondrian.saiku'))[_.span(
                  class_='fa fa-bar-chart')[''], ' Saiku']],
              ': Company wide dashboards, pivoting & ad hoc analysis'
          ],
                         body=[
                             _.
                             p['Metabase tutorial: ',
                               _.
                               a(href=
                                 'https://www.metabase.com/docs/latest/getting-started.html'
                                 )
                               ['https://www.metabase.com/docs/latest/getting-started.html']],
                             _.
                             p['Saiku introduction: ',
                               _.
                               a(href=
                                 'https://saiku-documentation.readthedocs.io/en/latest/'
                                 )
                               ['https://saiku-documentation.readthedocs.io/en/latest/']]
                         ]),
          bootstrap.card(header_left=[
              _.b[_.a(href=flask.url_for('mara_data_explorer.index_page'))[
                  _.span(class_='fa fa-table')[''],
                  ' Explore']], ': Raw data access & segmentation'
          ],
                         body=[
                             _.p[_.a(
                                 href=flask.
                                 url_for('mara_data_explorer.data_set_page',
                                         data_set_id=data_set_for_preview.id
                                         ))[data_set_for_preview.name], ':',
                                 html.asynchronous_content(
                                     flask.url_for(
                                         'mara_data_explorer.data_set_preview',
                                         data_set_id=data_set_for_preview.id)
                                 )], _.
                             p['Other data sets: ', ', '.join([
                                 str(
                                     _.a(href=flask.url_for(
                                         'mara_data_explorer.data_set_page',
                                         data_set_id=ds.id))[ds.name])
                                 for ds in mara_data_explorer.config.data_sets(
                                 ) if ds.id != data_set_for_preview.id
                             ])]
                         ])],
                                 _.div(class_='col-lg-6')
                                 [bootstrap.
                                  card(header_left=[
                                      _.b[_.a(href=flask.url_for(
                                          'mara_schema.index_page'))[_.span(
                                              class_='fa fa-book'
                                          )[''], ' Data sets']],
                                      ': Documentation of attributes and metrics of all data sets'
                                  ],
                                       body=html.asynchronous_content(
                                           url=flask.
                                           url_for('mara_schema.overview_graph'
                                                   ))),
                                  bootstrap.card(header_left=[
                                      _.b[_.a(
                                          href=flask.
                                          url_for('mara_pipelines.node_page')
                                      )[_.span(class_='fa fa-wrench')[''],
                                        ' Pipelines']],
                                      ': The data integration pipelines that create the DWH'
                                  ],
                                                 body=html.
                                                 asynchronous_content(
                                                     flask.url_for(
                                                         'mara_pipelines.dependency_graph',
                                                         path='/'))),
                                  bootstrap.card(header_left=[
                                      _.b[_.a(href=flask.
                                              url_for('mara_db.index_page')
                                              )[_.span(
                                                  class_='fa fa-database')[''],
                                                ' Database Schemas']],
                                      ': Schemas of all databases connections'
                                  ],
                                                 body=[
                                                     html.asynchronous_content(
                                                         flask.url_for(
                                                             'mara_db.draw_schema',
                                                             db_alias=
                                                             mara_pipelines.
                                                             config.
                                                             default_db_alias(
                                                             ),
                                                             schemas='ec_dim'
                                                         ) +
                                                         '?hide-columns=True')
                                                 ])]])
コード例 #19
0
ファイル: run_page.py プロジェクト: mara/mara-pipelines
def run_page(path: str, with_upstreams: bool, ids: str):
    if not config.allow_run_from_web_ui():
        flask.abort(
            403,
            'Running piplelines from web ui is disabled for this instance')

    # the pipeline to run
    pipeline, found = pipelines.find_node(path.split('/'))
    if not found:
        flask.abort(404, f'Pipeline "{path}" not found')
    assert (isinstance(pipeline, pipelines.Pipeline))

    # a list of nodes to run selectively in the pipeline
    nodes = []
    for id in (ids.split('/') if ids else []):
        node = pipeline.nodes.get(id)
        if not node:
            flask.abort(404, f'Node "{id}" not found in pipeline "{path}"')
        else:
            nodes.append(node)

    stream_url = flask.url_for('mara_pipelines.do_run',
                               path=path,
                               with_upstreams=with_upstreams,
                               ids=ids)

    title = [
        'Run ', 'with upstreams ' if with_upstreams else '', ' / '.join([
            str(_.a(href=views.node_url(parent))[parent.id])
            for parent in pipeline.parents()[1:]
        ])
    ]
    if nodes:
        title += [
            ' / [', ', '.join([
                str(_.a(href=views.node_url(node))[node.id]) for node in nodes
            ]), ']'
        ]

    return response.Response(
        html=[
            _.script['''
document.addEventListener('DOMContentLoaded', function() {
     processRunEvents(''' + json.dumps(
                flask.url_for('mara_pipelines.node_page', path='')) + ', ' +
                     json.dumps(stream_url) + ', ' +
                     json.dumps(pipeline.path()) + ''');
});'''],
            _.style[
                'span.action-buttons > * {display:none}'],  # hide reload button until run finishes
            _.div(class_='row')
            [_.div(class_='col-lg-7')[bootstrap.card(body=_.div(
                id='main-output-area', class_='run-output')[''])],
             _.div(class_='col-lg-5 scroll-container')[
                 bootstrap.
                 card(header_left='Timeline',
                      body=[
                          _.div(id='system-stats-chart', class_='google-chart'
                                )[' '],
                          _.div(id='timeline-chart')[' ']
                      ]),
                 _.div(id='failed-tasks-container')[''],
                 _.div(id='running-tasks-container')[''],
                 _.div(id='succeeded-tasks-container')[''],
                 bootstrap.card(id='card-template',
                                header_left=' ',
                                header_right=' ',
                                body=[_.div(class_='run-output')['']])]]
        ],
        js_files=[
            'https://www.gstatic.com/charts/loader.js',
            flask.url_for('mara_pipelines.static',
                          filename='timeline-chart.js'),
            flask.url_for('mara_pipelines.static',
                          filename='system-stats-chart.js'),
            flask.url_for('mara_pipelines.static', filename='utils.js'),
            flask.url_for('mara_pipelines.static', filename='run-page.js')
        ],
        css_files=[
            flask.url_for('mara_pipelines.static',
                          filename='timeline-chart.css'),
            flask.url_for('mara_pipelines.static', filename='run-page.css'),
            flask.url_for('mara_pipelines.static', filename='common.css')
        ],
        action_buttons=[
            response.ActionButton(
                action='javascript:location.reload()',
                label='Run again',
                icon='play',
                title='Run pipeline again with same parameters as before')
        ],
        title=title,
    )