Skip to content

Commit

Permalink
Merge pull request #58 from SmdhMdep/ui-updates
Browse files Browse the repository at this point in the history
* add data API link to the resource explore links
* change download button to 'Download Preview' for streaming resources
  • Loading branch information
aymanizz authored Oct 9, 2024
2 parents 37cd457 + 3f07ae2 commit 7e7e8b2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
44 changes: 43 additions & 1 deletion ckanext/smdh/templates/package/resource_read.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
{% ckan_extends %}

{% block resource_actions_inner %}
{{ super() }}
{% if h.check_access('package_update', {'id':pkg.id }) and not is_activity_archive %}
<li>{% link_for _('Manage'), named_route=pkg.type ~ '_resource.edit', id=pkg.name, resource_id=res.id, class_='btn
btn-default', icon='wrench' %}</li>
{% endif %}
{% if res.url and h.is_url(res.url) %}
<li>
<div class="btn-group">
<a class="btn btn-primary resource-url-analytics resource-type-{{ res.resource_type }}" href="{{ res.url }}">
{% if res.resource_type in ('listing', 'service') %}
<i class="fa fa-eye"></i> {{ _('View') }}
{% elif res.resource_type == 'api' %}
<i class="fa fa-key"></i> {{ _('API Endpoint') }}
{% elif not res.has_views and not res.url_type == 'upload' %}
<i class="fa fa-external-link"></i> {{ _('Go to resource') }}
{% elif not h.is_stream_resource(res) %}
<i class="fa fa-arrow-circle-o-down"></i> {{ _('Download') }}
{% else %}
<i class="fa fa-arrow-circle-o-down"></i> Download Preview
{% endif %}
</a>
{% block download_resource_button %}
{% if res.datastore_active %}
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="{{ h.url_for('datastore.dump', resource_id=res.id, bom=True) }}"
target="_blank"><span>CSV</span></a>
<a href="{{ h.url_for('datastore.dump', resource_id=res.id, format='tsv', bom=True) }}"
target="_blank"><span>TSV</span></a>
<a href="{{ h.url_for('datastore.dump', resource_id=res.id, format='json') }}"
target="_blank"><span>JSON</span></a>
<a href="{{ h.url_for('datastore.dump', resource_id=res.id, format='xml') }}"
target="_blank"><span>XML</span></a>
</li>
</ul>
{% endif %}
{% endblock %}
</div>
</li>
{% endif %}

{% if h.check_access('package_update', {'id':pkg.id }) and not is_activity_archive %}
<li>
{% set loading_text = _('Loading...') %}
Expand Down
15 changes: 15 additions & 0 deletions ckanext/smdh/templates/package/snippets/resource_item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% ckan_extends %}

{% block resource_item_explore_links %}
{{ super() }}
{% if h.check_access('package_update', {'id':pkg.id }) and not is_activity_archive %}
<li>
{% set loading_text = _('Loading...') %}
{% set api_info_url = h.url_for(controller='api', action='snippet', ver=1, snippet_path='api_popup.html',
resource_id=res.id) %}
<a href="{{ api_info_url }}" data-module="api-info"
data-module-template="/api/1/util/snippet/api_popup.html?resource_id={{ res.id }}"
data-loading-text="{{ loading_text }}"><i class="fa fa-flask"></i> {{ _('Data API') }}</a>
</li>
{% endif %}
{% endblock %}

0 comments on commit 7e7e8b2

Please sign in to comment.