<commit_before>---
layout: default
---
{% include breadcrumbs.html parent="Datasets" %}
{% assign schema = page.schema | default: site.schema %}
{% assign dataset_fields = site.data.schemas[schema].dataset_fields %}
{% assign dataset_system_fields = "title|organization|notes|license" | split: "|" %}
{% assign resource_fields = site.data.schemas[schema].resource_fields %}
{% assign resource_system_fields = "name|url|format|description" | split: "|" %}

{% assign organization = site.organizations | where:"title",page.organization | first %}
{% capture organization_url %}{{ site.baseurl }}/datasets/?organization={{ organization.title | slugify }}{% endcapture %}

<div data-component="view-switcher">
  <div class="row" data-component="dataset-display" data-hook="view" data-view="display" typeof="dcat:Dataset" resource="{{ page.url }}">
    {% if organization %}
      <div class="col-sm-3" property="dct:publisher" resource="{{ organization_url }}">
        <div class="panel panel-default">
            <div class="panel-heading">
              {% if organization.logo and organization.logo != empty %}
              <a href="{{ site.baseurl }}/datasets/?organization={{ organization.title | slugify }}" class="thumbnail"><img src="{{ organization.logo }}" alt="{{ organization.title }} logo"></a>
              {% endif %}
            </div>
            <div class="panel-body">
              <h3>
                <a href="{{ organization_url }}" about="{{ organization_url }}" property="foaf:homepage">
                  <span property="foaf:name">{{ organization.title }}</span>
                </a>
              </h3>
              {{ organization.description }}
            </div>
          </div>
        </div>
    <div class="col-sm-9">
    {% else %}
    <div class="col-sm-12">
    {% endif %}
      <h1>
        <span property="dct:title">{{ page.title }}</span>
        <a href="?view=edit" class="pull-right btn btn-default admin-only" data-hook="edit-dataset-btn">Edit</a>
      </h1>
      <p property="dct:description">{{ page.notes }}</p>

<template is="dom-bind">
    <script>
        preview_url = function(url, title) {
            ajax_el = document.querySelector('iron-ajax');
            table_el = document.querySelector('aha-table');
			button_els = document.querySelectorAll('.resource-table-button');
		    title_el = document.querySelector('.preview-resource-title');
            var params = {
                'datasetUrl': url,
                'numRows': '10'
            }
            // Reset the table for new dataset.
			if (table_el) {
				table_el.meta = [];
				table_el._internalData = [];
			}

			// Remove active from all other buttons
			for (var i = 0; i < button_els.length; i++)
				button_els[i].set('active', false);

			title_el.textContent = title;
            ajax_el.set('params', params);
        }
    </script>

      <h2>Resources</h2>
        <table class="table table-striped table-condensed">
            <tr>
                <th>Resource</th>
                <th>Type</th>
                <th>Preview</th>
            </tr>
        {% for resource in page.resources %}
            {% if forloop.first %}
                {% capture first-resource-url %}{{ resource.url }}{% endcapture %}
                {% capture first-resource-title %}{{ resource.name }}{% endcapture %}
            	{% assign preview-is-active = 'active' %}
			{% else %}
            	{% assign preview-is-active = '' %}
            {% endif %}
            <tr>
                <td>
                    <div class="" data-hook="resource-item" property='dcat:distribution' typeof='dcat:Distribution'>
                        <a href="{{ resource.url }}" property='dcat:accessURL'>
                            <span property="dct:title">{{ resource.name }}</span>
                        </a>
                    </div>
                </td>
                <td>
                    {% if resource.format %}
                        <paper-button class="resource-table-button" toggles="true" disabled="true")>
                            <span class="label label-default" property='dcat:mediaType'>{{ resource.format}}</span>
                        </paper-button>
                    {% endif %}
                </td>
                <td>
                    {% if resource.format == 'csv' %}
                        <paper-button
						class="resource-table-button" {{ preview-is-active }}
						toggles="true" onclick="preview_url('{{ resource.url }}', '{{ resource.name }}')">
                            <iron-icon icon="visibility"></iron-icon>
                        </paper-button>
                    {% endif %}
                </td>
            </div>
            </tr>
        {% endfor %}
        </table>

        <iron-ajax
          auto
          url="https://8kf9rxn2x1.execute-api.us-east-1.amazonaws.com/dev/dataset/preview"
          params={% raw %}'{"datasetUrl": "{% endraw %}{{ first-resource-url }}{% raw %}", "numRows": "10"}'{% endraw %}
          handle-as="json"
          last-response="{% raw %}{{ jsondata }}{% endraw %}"
		  loading="{% raw %}{{ tableloading }}{% endraw %}"
          debounce-duration="300"></iron-ajax>

      <div class="preview-container">
	  <h4 class="preview-resource-title">{{ first-resource-title }}</h4>
      <px-spinner class="resource-preview-loading-spinner" finished="{% raw %}[[!tableloading]]{% endraw %}" size="50"></px-spinner>
      <px-data-table table-data="{% raw %}[[jsondata]]{% endraw %}" striped="true" filterable="true" show-column-chooser="true" hide-pagination-control="true"></px-data-table>
      </div>

        </template>

      <h2>Additional Info</h2>
      <table class="table table-striped dataset-details"><commit_msg>Adding logic for shp files.<commit_after>---
layout: default
---
{% include breadcrumbs.html parent="Datasets" %}
{% assign schema = page.schema | default: site.schema %}
{% assign dataset_fields = site.data.schemas[schema].dataset_fields %}
{% assign dataset_system_fields = "title|organization|notes|license" | split: "|" %}
{% assign resource_fields = site.data.schemas[schema].resource_fields %}
{% assign resource_system_fields = "name|url|format|description" | split: "|" %}

{% assign organization = site.organizations | where:"title",page.organization | first %}
{% capture organization_url %}{{ site.baseurl }}/datasets/?organization={{ organization.title | slugify }}{% endcapture %}

<div data-component="view-switcher">
  <div class="row" data-component="dataset-display" data-hook="view" data-view="display" typeof="dcat:Dataset" resource="{{ page.url }}">
    {% if organization %}
      <div class="col-sm-3" property="dct:publisher" resource="{{ organization_url }}">
        <div class="panel panel-default">
            <div class="panel-heading">
              {% if organization.logo and organization.logo != empty %}
              <a href="{{ site.baseurl }}/datasets/?organization={{ organization.title | slugify }}" class="thumbnail"><img src="{{ organization.logo }}" alt="{{ organization.title }} logo"></a>
              {% endif %}
            </div>
            <div class="panel-body">
              <h3>
                <a href="{{ organization_url }}" about="{{ organization_url }}" property="foaf:homepage">
                  <span property="foaf:name">{{ organization.title }}</span>
                </a>
              </h3>
              {{ organization.description }}
            </div>
          </div>
        </div>
    <div class="col-sm-9">
    {% else %}
    <div class="col-sm-12">
    {% endif %}
      <h1>
        <span property="dct:title">{{ page.title }}</span>
        <a href="?view=edit" class="pull-right btn btn-default admin-only" data-hook="edit-dataset-btn">Edit</a>
      </h1>
      <p property="dct:description">{{ page.notes }}</p>

<template is="dom-bind">
    <script>
        preview_url = function(url, title) {
            ajax_el = document.querySelector('iron-ajax');
            table_el = document.querySelector('aha-table');
			button_els = document.querySelectorAll('.resource-table-button');
		    title_el = document.querySelector('.preview-resource-title');
            var params = {
                'datasetUrl': url,
                'numRows': '10'
            }
            // Reset the table for new dataset.
			if (table_el) {
				table_el.meta = [];
				table_el._internalData = [];
			}

			// Remove active from all other buttons
			for (var i = 0; i < button_els.length; i++)
				button_els[i].set('active', false);

			title_el.textContent = title;
            ajax_el.set('params', params);
        }
    </script>

      <h2>Resources</h2>
        <table class="table table-striped table-condensed">
            <tr>
                <th>Resource</th>
                <th>Type</th>
                <th>Preview</th>
            </tr>
        {% assign first_resource_url = '' %}
        {% for resource in page.resources %}
            {% if first_resource_url == '' and resource.url contains '.csv' %}
                {% capture first_resource_url %}{{ resource.url }}{% endcapture %}
                {% capture first_resource_title %}{{ resource.name }}{% endcapture %}
            	{% assign preview-is-active = 'active' %}
			{% else %}
            	{% assign preview-is-active = '' %}
            {% endif %}
            <tr>
                <td>
                    <div class="" data-hook="resource-item" property='dcat:distribution' typeof='dcat:Distribution'>
                        <a href="{{ resource.url }}" property='dcat:accessURL'>
                            <span property="dct:title">{{ resource.name }}</span>
                        </a>
                    </div>
                </td>
                <td>
                    {% if resource.format %}
                        <paper-button class="resource-table-button" toggles="true" disabled="true")>
                            <span class="label label-default" property='dcat:mediaType'>{{ resource.format}}</span>
                        </paper-button>
                    {% endif %}
                </td>
                <td>
                    {% if resource.format == 'csv' %}
                        <paper-button
						class="resource-table-button" {{ preview-is-active }}
						toggles="true" onclick="preview_url('{{ resource.url }}', '{{ resource.name }}')">
                            <iron-icon icon="visibility"></iron-icon>
                        </paper-button>
                    {% endif %}
                </td>
            </div>
            </tr>
        {% endfor %}
        </table>

        <iron-ajax
          auto
          url="https://8kf9rxn2x1.execute-api.us-east-1.amazonaws.com/dev/dataset/preview"
          params={% raw %}'{"datasetUrl": "{% endraw %}{{ first_resource_url }}{% raw %}", "numRows": "10"}'{% endraw %}
          handle-as="json"
          last-response="{% raw %}{{ jsondata }}{% endraw %}"
		  loading="{% raw %}{{ tableloading }}{% endraw %}"
          debounce-duration="300"></iron-ajax>

      <div class="preview-container">
	  <h4 class="preview-resource-title">{{ first_resource_title }}</h4>
      <px-spinner class="resource-preview-loading-spinner" finished="{% raw %}[[!tableloading]]{% endraw %}" size="50"></px-spinner>
      <px-data-table table-data="{% raw %}[[jsondata]]{% endraw %}" striped="true" filterable="true" show-column-chooser="true" hide-pagination-control="true"></px-data-table>
      </div>

        </template>

      <h2>Additional Info</h2>
      <table class="table table-striped dataset-details">
{'fraction_non_alphanumeric': 0.1725446236095542, 'fraction_numerical': 0.005001293437958093, 'mean_word_length': 2.07557677008751, 'pattern_counts': {'":': 4, '<': 167, '<?xml version=': 0, '>': 165, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4007123', 'n_tokens_mistral': 3529, 'n_tokens_neox': 3235, 'n_words': 621}