Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agregando lista databases #21

Merged
merged 6 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ckanext/superset/blueprints/superset.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,17 @@ def create_dataset(chart_id):
# redirect to the new CKAN dataset
url = tk.h.url_for('dataset.read', id=pkg['name'])
return tk.redirect_to(url)


@superset_bp.route('/list_databases', methods=['GET'])
@require_sysadmin_user
def list_databases():
cfg = get_config()
sc = SupersetCKAN(**cfg)
superset_databases = sc.get_databases()
superset_url = tk.config.get('ckanext.superset.instance.url')
extra_vars = {
'databases': superset_databases,
'superset_url': superset_url,
}
return tk.render('superset/databases_list.html', extra_vars)
6 changes: 6 additions & 0 deletions ckanext/superset/data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def get_chart(self, chart_id):
self.charts.append(chart)
return chart

def get_databases(self):
""" Get a list_database """
# Get from the API
self.load_databases(self)
return self.databases

def prepare_connection(self):
""" Define the client and login if required """
log.info(f"Connecting to {self.superset_url}")
Expand Down
52 changes: 52 additions & 0 deletions ckanext/superset/templates/superset/databases_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% extends "page.html" %}

{% block primary_content %}
<section class="module">
<div class="module-content">
<h3>Databases</h3>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{{ _('ID') }}</th>
<th>{{ _('Nombre de la base de datos') }}</th>
<th>{{ _('Autor') }}</th>
<th>{{ _('Actualizado') }}</th>
</tr>
</thead>
<tbody>
{% for database in databases %}
<tr>
<td>{{ database.id }}</td>
<td>{{ database.database_name }}</td>
<td>{{ database.created_by.first_name }}, {{ database.created_by.last_name }}</td>
<td>{{ database.changed_on }}</td>
</tr>
{% endfor %}
</tbody>

</table>
</div>
</section>
{% endblock %}

{% block secondary_content %}

<div class="module module-narrow module-shallow">
<h2 class="module-heading">
{{ _('Apache Superset') }}
</h2>
<div class="module-content">
<img src="{{ h.url_for_static('/base/images/apache-superset-logo.png') }}" alt="Apache Superset" style="max-width: 200px; display: block; margin: 0 auto;">
<p>
Apache Superset es una herramienta de visualización de datos de código abierto que permite a los usuarios
crear paneles de control y visualizaciones interactivas.
</p>
<p>
<a href="{{ h.url_for('superset_blueprint.index') }}" class="btn btn-primary">
{{ ('Lista de Charts') }}
</a>
</p>
</div>
</div>

{% endblock %}
7 changes: 6 additions & 1 deletion ckanext/superset/templates/superset/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ <h2 class="module-heading">
<p>
Apache Superset es una herramienta de visualización de datos de código abierto que permite a los usuarios
crear paneles de control y visualizaciones interactivas.
</p>
</p>
<p>
<a href="{{ h.url_for('superset_blueprint.list_databases') }}" target="_blank" class="btn btn-primary">
{{ _('Ver lista de bases de datos') }}
</a>
</p>
</div>
</div>

Expand Down
Loading