-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement user chart builder view , part2
- Loading branch information
Showing
13 changed files
with
259 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
CACHE_REDIS = "redis" | ||
|
||
REDIS_PREFIX = "ckanext-charts:*" | ||
|
||
CHART_DEFAULT_ROW_LIMIT = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<form method="POST"> | ||
{% snippet "charts/snippets/chart_create_form.html", | ||
resource_id=resource_id, | ||
settings=settings, | ||
form_builder=form_builder(resource_id), | ||
errors={}, | ||
exclude_tabs=["General"] | ||
%} | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,6 @@ | ||
{% import "macros/form.html" as form %} | ||
|
||
{% asset "charts/plotly" %} | ||
{% asset "charts/chartjs" %} | ||
{% asset "charts/observable" %} | ||
|
||
{# Global styles for all charts #} | ||
{% asset "charts/charts-css" %} | ||
{% asset "charts/charts-js" %} | ||
|
||
{# Custom select library #} | ||
{% asset "charts/tom-select-js" %} | ||
{% asset "charts/tom-select-css" %} | ||
|
||
<div class="charts-view--form" data-module="charts-global"> | ||
{% snippet "charts/snippets/charts_form_fields.html", resource_id=resource_id, data=settings, | ||
builder=form_builder(resource_id), errors=errors %} | ||
</div> | ||
|
||
<div class="charts-view--preview" id="charts-view--preview" style="min-height: 450px;"></div> | ||
{% snippet "charts/snippets/chart_create_form.html", | ||
resource_id=resource_id, | ||
settings=settings, | ||
form_builder=form_builder(resource_id), | ||
errors=errors | ||
%} |
20 changes: 20 additions & 0 deletions
20
ckanext/charts/templates/charts/snippets/chart_create_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% import "macros/form.html" as form %} | ||
|
||
{% asset "charts/plotly" %} | ||
{% asset "charts/chartjs" %} | ||
{% asset "charts/observable" %} | ||
|
||
{# Global styles for all charts #} | ||
{% asset "charts/charts-css" %} | ||
{% asset "charts/charts-js" %} | ||
|
||
{# Custom select library #} | ||
{% asset "charts/tom-select-js" %} | ||
{% asset "charts/tom-select-css" %} | ||
|
||
<div class="charts-view--form" data-module="charts-global"> | ||
{% snippet "charts/snippets/charts_form_fields.html", resource_id=resource_id, data=settings, | ||
builder=form_builder, errors=errors, exclude_tabs=exclude_tabs or false, user_chart_builder=1 %} | ||
</div> | ||
|
||
<div class="charts-view--preview" id="charts-view--preview" style="min-height: 450px;"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
ckanext/charts/templates/package/snippets/resource_view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{# alter: adding resource-view-{{ resource_view.view_type }} #} | ||
|
||
{% import 'macros/form.html' as form %} | ||
|
||
{% block resource_view %} | ||
<div id="view-{{ resource_view['id'] }}" class="resource-view resource-view-{{ resource_view.view_type }}" data-id="{{ resource_view['id'] }}" data-title="{{ resource_view['title'] }}" data-description="{{ resource_view['descripion'] }}"> | ||
<div class="actions"> | ||
<a class="btn btn-default" | ||
target="_blank" | ||
rel="noreferrer" | ||
href="{{ h.url_for(package['type'] ~ '_resource.view', id=package['name'], resource_id=resource['id'], view_id=resource_view['id'], qualified=True) }}"> | ||
<i class="fa fa-arrows-alt"></i> | ||
{{ _("Fullscreen") }} | ||
</a> | ||
<a class="btn btn-default" | ||
href="#embed-{{ resource_view['id'] }}" | ||
data-module="resource-view-embed" | ||
data-module-id="{{ resource_view['id'] }}" | ||
data-module-url="{{ h.url_for(package['type'] ~ '_resource.view', id=package['name'], resource_id=resource['id'], view_id=resource_view['id'], qualified=True) }}"> | ||
<i class="fa fa-object-group"></i> | ||
{{ _("Embed") }} | ||
</a> | ||
</div> | ||
<p class="desc">{{ h.render_markdown(resource_view['description']) }}</p> | ||
<div class="m-top ckanext-datapreview"> | ||
{% if not to_preview and h.resource_view_is_filterable(resource_view) %} | ||
{% snippet 'package/snippets/resource_view_filters.html', resource=resource %} | ||
{% endif %} | ||
{% if not h.resource_view_is_iframed(resource_view) %} | ||
{{ h.rendered_resource_view(resource_view, resource, package) }} | ||
{% else %} | ||
<div class="data-viewer-error js-hide"> | ||
<p class="text-danger"> | ||
<i class="fa fa-info-circle"></i> | ||
{{ _('This resource view is not available at the moment.') }} | ||
<a href="#" data-bs-toggle="collapse" data-bs-target="#data-view-error"> | ||
{{ _('Click here for more information.') }} | ||
</a> | ||
</p> | ||
<p id="data-view-error" class="collapse"></p> | ||
<p> | ||
<a href="{{ resource.url }}" class="btn btn-default btn-lg resource-url-analytics" target="_blank" rel="noreferrer"> | ||
<i class="fa fa-lg fa-arrow-circle-down"></i> | ||
{{ _('Download resource') }} | ||
</a> | ||
</p> | ||
</div> | ||
{% if not to_preview %} | ||
{% set current_filters = request.args.get('filters') %} | ||
{% if current_filters %} | ||
{% set src = h.url_for(package['type'] ~ '_resource.view', id=package['name'], | ||
resource_id=resource['id'], | ||
view_id=resource_view['id'], | ||
filters=current_filters, qualified=true) %} | ||
{% else %} | ||
{% set src = h.url_for(package['type'] ~ '_resource.view', id=package['name'], | ||
resource_id=resource['id'], | ||
view_id=resource_view['id'], qualified=true) %} | ||
{% endif %} | ||
{% else %} | ||
{# When previewing we need to stick the whole resource_view as a param as there is no other way to pass to information on to the iframe #} | ||
{% set src = h.url_for(package['type'] ~ '_resource.view', id=package['name'], resource_id=resource['id'], qualified=true) + '?' + h.urlencode({'resource_view': h.dump_json(resource_view)}) %} | ||
{% endif %} | ||
<iframe title="Data viewer" src="{{ src }}" frameborder="0" width="100%" data-module="data-viewer"> | ||
<p>{{ _('Your browser does not support iframes.') }}</p> | ||
</iframe> | ||
{% endif %} | ||
</div> | ||
<div id="embed-{{ resource_view['id'] }}" class="modal fade resource-view-embed"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
|
||
<div class="modal-header"> | ||
<h3 class="modal-title">{{ _("Embed resource view") }}</h3> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ _('Close') }}"></button> | ||
|
||
</div> | ||
<div class="modal-body"> | ||
<p class="embed-content">{{ _("You can copy and paste the embed code into a CMS or blog software that supports raw HTML") }}</p> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
{{ form.input("width", label=_("Width"), value=700, classes=["control-full"]) }} | ||
</div> | ||
<div class="col-md-6"> | ||
{{ form.input("height", label=_("Height"), value=400, classes=["control-full"]) }} | ||
</div> | ||
</div> | ||
{{ form.textarea("code", label=_("Code"), value="", classes=["pre"], rows=3) }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.