diff --git a/src/mmw/apps/bigcz/clients/cuahsi/models.py b/src/mmw/apps/bigcz/clients/cuahsi/models.py index bfceacfa4..8a5c757db 100644 --- a/src/mmw/apps/bigcz/clients/cuahsi/models.py +++ b/src/mmw/apps/bigcz/clients/cuahsi/models.py @@ -10,7 +10,7 @@ class CuahsiResource(Resource): def __init__(self, id, description, author, links, title, created_at, updated_at, geom, details_url, sample_mediums, concept_keywords, service_org, service_code, service_url, - begin_date, end_date): + service_title, service_citation, begin_date, end_date): super(CuahsiResource, self).__init__(id, description, author, links, title, created_at, updated_at, geom) @@ -21,5 +21,7 @@ def __init__(self, id, description, author, links, title, self.service_org = service_org self.service_code = service_code self.service_url = service_url + self.service_title = service_title + self.service_citation = service_citation self.begin_date = begin_date self.end_date = end_date diff --git a/src/mmw/apps/bigcz/clients/cuahsi/search.py b/src/mmw/apps/bigcz/clients/cuahsi/search.py index 770f1b6ba..f89f12ae3 100644 --- a/src/mmw/apps/bigcz/clients/cuahsi/search.py +++ b/src/mmw/apps/bigcz/clients/cuahsi/search.py @@ -107,6 +107,8 @@ def parse_record(record, service): service_org=service['organization'], service_code=record['serv_code'], service_url=service['ServiceDescriptionURL'], + service_title=service['Title'], + service_citation=service['citation'], begin_date=record['begin_date'], end_date=record['end_date'] ) @@ -156,10 +158,10 @@ def group_series_by_location(series): 'site_name': group[0]['Sitename'], 'latitude': group[0]['latitude'], 'longitude': group[0]['longitude'], - 'sample_mediums': ', '.join(sorted(set([r['samplemedium'] - for r in group]))), - 'concept_keywords': '; '.join(sorted(set([r['conceptKeyword'] - for r in group]))), + 'sample_mediums': sorted(set([r['samplemedium'] + for r in group])), + 'concept_keywords': sorted(set([r['conceptKeyword'] + for r in group])), 'begin_date': min([parse_date(r['beginDate']) for r in group]), 'end_date': max([parse_date(r['endDate']) diff --git a/src/mmw/apps/bigcz/clients/cuahsi/serializers.py b/src/mmw/apps/bigcz/clients/cuahsi/serializers.py index 937be7e07..549a971a0 100644 --- a/src/mmw/apps/bigcz/clients/cuahsi/serializers.py +++ b/src/mmw/apps/bigcz/clients/cuahsi/serializers.py @@ -3,17 +3,22 @@ from __future__ import unicode_literals from __future__ import division -from rest_framework.serializers import CharField, DateTimeField +from rest_framework.serializers import (CharField, + DateTimeField, + ListField, + ) from apps.bigcz.serializers import ResourceSerializer class CuahsiResourceSerializer(ResourceSerializer): details_url = CharField() - sample_mediums = CharField() - concept_keywords = CharField() + sample_mediums = ListField(child=CharField()) + concept_keywords = ListField(child=CharField()) service_org = CharField() service_code = CharField() service_url = CharField() + service_title = CharField() + service_citation = CharField() begin_date = DateTimeField() end_date = DateTimeField() diff --git a/src/mmw/js/src/app.js b/src/mmw/js/src/app.js index 05df828b4..d3c20da76 100644 --- a/src/mmw/js/src/app.js +++ b/src/mmw/js/src/app.js @@ -64,6 +64,11 @@ var App = new Marionette.Application({ // Enable screenshot functionality initializeShutterbug(); + + // Enabling hiding popovers from within them + window.closePopover = function() { + $('[data-toggle="popover"]').popover('hide'); + }; }, load: function(data) { diff --git a/src/mmw/js/src/core/filters.js b/src/mmw/js/src/core/filters.js index fc7c9c516..2158a9d5d 100644 --- a/src/mmw/js/src/core/filters.js +++ b/src/mmw/js/src/core/filters.js @@ -60,6 +60,33 @@ nunjucks.env.addFilter('toDateWithoutTime', function(date) { fullDate.getUTCFullYear(); }); +nunjucks.env.addFilter('toTimeAgo', function(date) { + var diff = Date.now() - (new Date(date)).getTime(), + secs = diff / 1000, + mins = secs / 60, + hrs = mins / 60, + days = hrs / 24, + wks = days / 7, + mths = days / 30, + yrs = days / 365; + + if (yrs > 1) { + return Math.floor(yrs) + " years ago"; + } else if (mths > 1) { + return Math.floor(mths) + " months ago"; + } else if (wks > 1) { + return Math.floor(wks) + " weeks ago"; + } else if (days > 1) { + return Math.floor(days) + " days ago"; + } else if (hrs > 1) { + return Math.floor(hrs) + " hours ago"; + } else if (mins > 1) { + return Math.floor(mins) + " minutes ago"; + } else { + return Math.floor(secs) + " seconds ago"; + } +}); + nunjucks.env.addFilter('split', function(str, splitChar, indexToReturn) { var items = str.split(splitChar); diff --git a/src/mmw/js/src/data_catalog/templates/resultDetails.html b/src/mmw/js/src/data_catalog/templates/resultDetailsCinergi.html similarity index 62% rename from src/mmw/js/src/data_catalog/templates/resultDetails.html rename to src/mmw/js/src/data_catalog/templates/resultDetailsCinergi.html index aa8fef787..e10a52b4d 100644 --- a/src/mmw/js/src/data_catalog/templates/resultDetails.html +++ b/src/mmw/js/src/data_catalog/templates/resultDetailsCinergi.html @@ -14,30 +14,16 @@

{{ author }}

{% endif %} - {% if activeCatalog != 'cuahsi' %}

{{ created_at|toDateFullYear }}

- {% else %} - {% if begin_date == end_date %} -

- {{ begin_date|toDateWithoutTime }} -

- {% else %} -

- {{ begin_date|toDateWithoutTime }} - {{ end_date|toDateWithoutTime }} -

- {% endif %} - {% endif %}

{{ description }}

- {% if activeCatalog == 'cinergi' %}  Repository - {% endif %}

diff --git a/src/mmw/js/src/data_catalog/templates/resultDetailsCuahsi.html b/src/mmw/js/src/data_catalog/templates/resultDetailsCuahsi.html new file mode 100644 index 000000000..baa09da4f --- /dev/null +++ b/src/mmw/js/src/data_catalog/templates/resultDetailsCuahsi.html @@ -0,0 +1,73 @@ +
+
+ +

+ Site: {{ location }} {{ title }} +

+

+ Source: {{ service_org }} {{ service_title }} + + + +

+
+ {% if author %} +

+ {{ author }} +

+ {% endif %} + {% if begin_date == end_date %} +

+ Data collected on: {{ begin_date|toDateWithoutTime }} +

+ {% else %} +

+ Data collected between: {{ begin_date|toDateWithoutTime }} - {{ end_date|toDateWithoutTime }} +

+ {% endif %} +

+ Medium: {{ sample_mediums|join(", ") }} +

+

+ {% if details_url %} + +  Source Data + + {% endif %} + +  Web Services + +

+
+

+ Last collected value {{ end_date|toTimeAgo }}: +

+ + + + + + + + + + {% for ck in concept_keywords %} + + + + + + {% endfor %} + +
VariableValueUnits
{{ ck }}
+ +
+

Citation: {{ service_citation }}

+
diff --git a/src/mmw/js/src/data_catalog/templates/resultDetailsHydroshare.html b/src/mmw/js/src/data_catalog/templates/resultDetailsHydroshare.html new file mode 100644 index 000000000..aacadd961 --- /dev/null +++ b/src/mmw/js/src/data_catalog/templates/resultDetailsHydroshare.html @@ -0,0 +1,23 @@ +
+
+

+ {{ title }} +

+ + Zoom to extent +
+
+ {% if author %} +

+ {{ author }} +

+ {% endif %} +

+ {{ created_at|toDateFullYear }} +

+

+ {{ description }} +

+
diff --git a/src/mmw/js/src/data_catalog/templates/cuahsiSearchResult.html b/src/mmw/js/src/data_catalog/templates/searchResultCuahsi.html similarity index 94% rename from src/mmw/js/src/data_catalog/templates/cuahsiSearchResult.html rename to src/mmw/js/src/data_catalog/templates/searchResultCuahsi.html index 41a088fd1..7dd66856a 100644 --- a/src/mmw/js/src/data_catalog/templates/cuahsiSearchResult.html +++ b/src/mmw/js/src/data_catalog/templates/searchResultCuahsi.html @@ -9,7 +9,7 @@

- {{ concept_keywords }} + {{ concept_keywords|join("; ") }}
diff --git a/src/mmw/js/src/data_catalog/views.js b/src/mmw/js/src/data_catalog/views.js index ac8ffb3c7..c3f84191c 100644 --- a/src/mmw/js/src/data_catalog/views.js +++ b/src/mmw/js/src/data_catalog/views.js @@ -10,12 +10,14 @@ var $ = require('jquery'), formTmpl = require('./templates/form.html'), pagerTmpl = require('./templates/pager.html'), searchResultTmpl = require('./templates/searchResult.html'), - cuahsiSearchResultTmpl = require('./templates/cuahsiSearchResult.html'), + searchResultCuahsiTmpl = require('./templates/searchResultCuahsi.html'), tabContentTmpl = require('./templates/tabContent.html'), tabPanelTmpl = require('./templates/tabPanel.html'), headerTmpl = require('./templates/header.html'), windowTmpl = require('./templates/window.html'), - resultDetailsTmpl = require('./templates/resultDetails.html'), + resultDetailsCinergiTmpl = require('./templates/resultDetailsCinergi.html'), + resultDetailsHydroshareTmpl = require('./templates/resultDetailsHydroshare.html'), + resultDetailsCuahsiTmpl = require('./templates/resultDetailsCuahsi.html'), resultsWindowTmpl = require('./templates/resultsWindow.html'), resultMapPopoverTmpl = require('./templates/resultMapPopover.html'); @@ -24,7 +26,12 @@ var ENTER_KEYCODE = 13, CATALOG_RESULT_TEMPLATE = { cinergi: searchResultTmpl, hydroshare: searchResultTmpl, - cuahsi: cuahsiSearchResultTmpl, + cuahsi: searchResultCuahsiTmpl, + }, + CATALOG_RESULT_DETAILS_TEMPLATE = { + cinergi: resultDetailsCinergiTmpl, + hydroshare: resultDetailsHydroshareTmpl, + cuahsi: resultDetailsCuahsiTmpl, }; var HeaderView = Marionette.LayoutView.extend({ @@ -131,7 +138,7 @@ var DataCatalogWindow = Marionette.LayoutView.extend({ } else { this.detailsRegion.show(new ResultDetailsView({ model: detailResult, - activeCatalog: activeCatalog.id + catalog: activeCatalog.id })); App.map.set({ 'dataCatalogResults': null, @@ -444,7 +451,9 @@ var ResultsView = Marionette.CollectionView.extend({ }); var ResultDetailsView = Marionette.ItemView.extend({ - template: resultDetailsTmpl, + getTemplate: function() { + return CATALOG_RESULT_DETAILS_TEMPLATE[this.catalog]; + }, ui: { closeDetails: '.close' @@ -455,12 +464,23 @@ var ResultDetailsView = Marionette.ItemView.extend({ }, initialize: function(options) { - this.activeCatalog = options.activeCatalog; + this.catalog = options.catalog; + }, + + onAttach: function() { + this.$('[data-toggle="popover"]').popover({ + placement: 'right', + trigger: 'click', + }); + this.$('[data-toggle="table"]').bootstrapTable(); }, templateHelpers: function() { + var id = this.model.get('id'), + location = id.substring(id.indexOf(':') + 1); + return { - activeCatalog: this.activeCatalog + location: location, }; }, diff --git a/src/mmw/sass/pages/_data-catalog.scss b/src/mmw/sass/pages/_data-catalog.scss index ba6ec416e..23aa344a8 100644 --- a/src/mmw/sass/pages/_data-catalog.scss +++ b/src/mmw/sass/pages/_data-catalog.scss @@ -22,10 +22,14 @@ top: 0px; width: 100%; position: absolute; - z-index: 10000; + z-index: 1000; background-color: #fff; overflow: auto; + p { + margin: 5px 0 0 0; + } + .result-detail-header { h2 { display: inline-block; @@ -33,7 +37,7 @@ max-width: 95%; } - a { + a.zoom { display: block; } }