|
|
@@ -17,654 +17,1837 @@
|
|
|
<%!
|
|
|
from desktop.views import commonheader, commonfooter
|
|
|
from django.utils.translation import ugettext as _
|
|
|
-from django.utils.dateparse import parse_datetime
|
|
|
-from search.api import utf_quoter
|
|
|
-import urllib
|
|
|
-import math
|
|
|
-import time
|
|
|
%>
|
|
|
|
|
|
-<%namespace name="macros" file="macros.mako" />
|
|
|
+${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
|
|
|
|
|
|
-${ commonheader(_('Search'), "search", user, "90px") | n,unicode }
|
|
|
-
|
|
|
-<link rel="stylesheet" href="/search/static/css/search.css">
|
|
|
-<link href="/static/ext/css/hue-filetypes.css" rel="stylesheet">
|
|
|
-<script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
-<script src="/search/static/js/search.utils.js" type="text/javascript" charset="utf-8"></script>
|
|
|
-<script src="/static/ext/js/jquery/plugins/jquery.flot.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
-<script src="/static/ext/js/jquery/plugins/jquery.flot.selection.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
-<script src="/static/ext/js/jquery/plugins/jquery.flot.time.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
-<script src="/static/js/jquery.blueprint.js" type="text/javascript" charset="utf-8"></script>
|
|
|
-
|
|
|
-<%
|
|
|
- if "q" not in solr_query:
|
|
|
- solr_query["q"] = ""
|
|
|
- else:
|
|
|
- solr_query["q"] = solr_query["q"].decode("utf8")
|
|
|
- if "fq" not in solr_query:
|
|
|
- solr_query["fq"] = ""
|
|
|
- if "rows" not in solr_query:
|
|
|
- solr_query["rows"] = ""
|
|
|
- if "start" not in solr_query:
|
|
|
- solr_query["start"] = ""
|
|
|
-%>
|
|
|
+<script type="text/javascript">
|
|
|
+ if (window.location.hash != ""){
|
|
|
+ location.href = "/search/?" + window.location.hash.substr(1);
|
|
|
+ }
|
|
|
+</script>
|
|
|
|
|
|
<div class="search-bar">
|
|
|
% if user.is_superuser:
|
|
|
- <div class="pull-right" style="margin-top: 6px; margin-right: 40px">
|
|
|
- <a class="change-settings" href="#"><i class="fa fa-edit"></i> ${ _('Customize this collection') }</a>
|
|
|
- <a href="${ url('search:admin_collections') }"><i class="fa fa-sitemap"></i> ${ _('Collection manager') }</a>
|
|
|
+ <div class="pull-right" style="padding-right:50px">
|
|
|
+ <button type="button" title="${ _('Edit') }" rel="tooltip" data-placement="bottom" data-bind="click: toggleEditing, css: {'btn': true, 'btn-inverse': isEditing}"><i class="fa fa-pencil"></i></button>
|
|
|
+ <button type="button" title="${ _('Save') }" rel="tooltip" data-placement="bottom" data-loading-text="${ _("Saving...") }" data-bind="click: save, css: {'btn': true}"><i class="fa fa-save"></i></button>
|
|
|
+ <button type="button" title="${ _('Save') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}"><i class="fa fa-cog"></i></button>
|
|
|
+ ## for enable, live search, max number of downloads, change solr
|
|
|
+ <button type="button" title="${ _('Share') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}"><i class="fa fa-link"></i></button>
|
|
|
+
|
|
|
+ <a class="btn" href="${ url('search:new_search') }" title="${ _('New') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}"><i class="fa fa-file-o"></i></a>
|
|
|
+ <a class="btn" href="${ url('search:admin_collections') }" title="${ _('Collections') }" rel="tooltip" data-placement="bottom" data-bind="css: {'btn': true}"><i class="fa fa-tags"></i></a>
|
|
|
</div>
|
|
|
% endif
|
|
|
- <form class="form-search" style="margin: 0">
|
|
|
+
|
|
|
+ <form data-bind="visible: columns().length == 0">
|
|
|
+ ${ _('Search') }
|
|
|
+ <!-- ko if: $root.initial.collections -->
|
|
|
+ <select data-bind="options: $root.initial.collections, value: $root.collection.name">
|
|
|
+ </select>
|
|
|
+ <!-- /ko -->
|
|
|
+ </form>
|
|
|
+
|
|
|
+ <form class="form-search" style="margin: 0" data-bind="submit: searchBtn, visible: columns().length != 0"">
|
|
|
<strong>${_("Search")}</strong>
|
|
|
<div class="input-append">
|
|
|
<div class="selectMask">
|
|
|
- <span class="current-collection"></span>
|
|
|
- <div id="collectionPopover" class="hide">
|
|
|
- <ul class="unstyled">
|
|
|
- % if user.is_superuser:
|
|
|
- <li><a class="dropdown-collection" href="#" data-value="${ hue_collection.id }" data-settings-url="${ hue_collection.get_absolute_url() }">${ hue_collection.label }</a></li>
|
|
|
- % else:
|
|
|
- <li><a class="dropdown-hue_collection" href="#" data-value="${ hue_collection.id }">${ hue_collection.label }</a></li>
|
|
|
- % endif
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
+ <span
|
|
|
+ data-bind="editable: collection.label, editableOptions: {enabled: $root.isEditing(), placement: 'right'}">
|
|
|
+ </span>
|
|
|
+ ##<i class="fa fa-edit" data-bind="visible: $root.isEditing() && ! $root.changeCollection(), click: function(){$root.changeCollection(true);}"></i>
|
|
|
+ <!-- ko if: $root.isEditing() && $root.changeCollection() -->
|
|
|
+ <select data-bind="options: $root.initial.collections, value: $root.collection.name">
|
|
|
+ </select>
|
|
|
+ <!-- /ko -->
|
|
|
</div>
|
|
|
|
|
|
- ${ search_form | n,unicode }
|
|
|
- <button type="submit" id="search-btn" class="btn btn-inverse"><i class="fa fa-search"></i></button>
|
|
|
+ <span data-bind="foreach: query.qs">
|
|
|
+ <input data-bind="value: q" maxlength="256" type="text" class="search-query input-xlarge" style="cursor: auto;">
|
|
|
+ <!-- ko if: $index() >= 1 -->
|
|
|
+ <a class="btn" href="javascript:void(0)" data-bind="click: $root.query.removeQ"><i class="fa fa-minus"></i></a>
|
|
|
+ <!-- /ko -->
|
|
|
+ </span>
|
|
|
|
|
|
- % if response and 'response' in response and 'docs' in response['response'] and len(response['response']['docs']) > 0:
|
|
|
- <div class="btn-group download-btn-group" style="margin-left: 15px">
|
|
|
- <button type="button" id="download-btn" class="btn btn-inverse dropdown-toggle" data-toggle="dropdown"><i class="fa fa-download"></i></button>
|
|
|
- <ul class="dropdown-menu" role="menu">
|
|
|
- <li><a href="javascript:void(0)" id="download-xls"><i class="hfo hfo-file-xls"></i> ${ _('XLS') }</a></li>
|
|
|
- <li><a href="javascript:void(0)" id="download-csv"><i class="hfo hfo-file-csv"> ${ _('CSV') }</i></a></li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- % endif
|
|
|
+ <a class="btn" href="javascript:void(0)" data-bind="click: $root.query.addQ"><i class="fa fa-plus"></i></a>
|
|
|
+
|
|
|
+ <button type="submit" id="search-btn" class="btn btn-inverse" style="margin-left:10px"><i class="fa fa-search"></i></button>
|
|
|
</div>
|
|
|
</form>
|
|
|
</div>
|
|
|
|
|
|
-% if 'is_demo' in response.get('responseHeader', {}):
|
|
|
- <div class="container-fluid">
|
|
|
- <div class="row-fluid">
|
|
|
- <div class="span12">
|
|
|
- <div class="alert alert-warn">
|
|
|
- ${ _('A demo index is used. In order to be interactive, please ') } <a href="http://gethue.tumblr.com/post/78012277574/tutorial-demo-the-search-on-hadoop-examples" target="_blank">${ _('create the indexes') }</a> ${ _(' in Solr.') }
|
|
|
- </div>
|
|
|
+<div class="card card-toolbar" data-bind="slideVisible: isEditing">
|
|
|
+ <div style="float: left">
|
|
|
+ <div class="toolbar-label">${_('LAYOUT')}</div>
|
|
|
+ <a href="javascript: oneThirdLeftLayout()" onmouseover="viewModel.previewColumns('oneThirdLeft')" onmouseout="viewModel.previewColumns('')">
|
|
|
+ <div class="layout-container">
|
|
|
+ <div class="layout-box" style="width: 24px"></div>
|
|
|
+ <div class="layout-box" style="width: 72px; margin-left: 4px"></div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </a>
|
|
|
+ <a href="javascript: fullLayout()" onmouseover="viewModel.previewColumns('full')" onmouseout="viewModel.previewColumns('')">
|
|
|
+ <div class="layout-container">
|
|
|
+ <div class="layout-box" style="width: 100px;"></div>
|
|
|
+ </div>
|
|
|
+ </a>
|
|
|
+ <a data-bind="visible: columns().length == 0" href="javascript: magicLayout(viewModel)" onmouseover="viewModel.previewColumns('magic')" onmouseout="viewModel.previewColumns('')">
|
|
|
+ <div class="layout-container">
|
|
|
+ <div class="layout-box" style="width: 100px;"><i class="fa fa-magic"></i></div>
|
|
|
+ </div>
|
|
|
+ </a>
|
|
|
</div>
|
|
|
-% endif
|
|
|
|
|
|
+ <div style="float: left; margin-left: 20px" data-bind="visible: columns().length > 0">
|
|
|
+ <div class="toolbar-label">${_('WIDGETS')}</div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableResultset() },
|
|
|
+ draggable: {data: draggableResultset(), isEnabled: availableDraggableResultset,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast'); $root.collection.template.isGridLayout(true); }}}"
|
|
|
+ title="${_('Grid Results')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableResultset() ? 'move' : 'default' }">
|
|
|
+ <i class="fa fa-table"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableResultset() },
|
|
|
+ draggable: {data: draggableHtmlResultset(),
|
|
|
+ isEnabled: availableDraggableResultset,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)}); $root.collection.template.isGridLayout(false); }}}"
|
|
|
+ title="${_('HTML Results')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableResultset() ? 'move' : 'default' }">
|
|
|
+ <i class="fa fa-code"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableChart() },
|
|
|
+ draggable: {data: draggableFacet(), isEnabled: availableDraggableChart,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
|
|
|
+ title="${_('Text Facet')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
|
|
|
+ <i class="fa fa-sort-amount-asc"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableChart() },
|
|
|
+ draggable: {data: draggablePie(), isEnabled: availableDraggableChart,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
|
|
|
+ title="${_('Pie Chart')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
|
|
|
+ <i class="hcha hcha-pie-chart"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <!-- <div class="draggable-widget" data-bind="draggable: {data: draggableHit(), options: {'start': function(event, ui){$('.card-body').slideUp('fast');}, 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}" title="${_('Hit Count')}" rel="tooltip" data-placement="top"><a data-bind="attr: {href: $root.availableDraggableResultset()}, css: {'btn-inverse': ! $root.availableDraggableResultset() }, style: { cursor: $root.availableDraggableResultset() ? 'move' : 'default' }"><i class="fa fa-tachometer"></i></a></div> -->
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableChart() },
|
|
|
+ draggable: {data: draggableBar(), isEnabled: availableDraggableChart,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
|
|
|
+ title="${_('Bar Chart')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
|
|
|
+ <i class="hcha hcha-bar-chart"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableNumbers() },
|
|
|
+ draggable: {data: draggableLine(), isEnabled: availableDraggableNumbers,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
|
|
|
+ title="${_('Line')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableNumbers() ? 'move' : 'default' }">
|
|
|
+ <i class="hcha hcha-line-chart"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableHistogram() },
|
|
|
+ draggable: {data: draggableHistogram(), isEnabled: availableDraggableHistogram,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
|
|
|
+ title="${_('Histogram')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableHistogram() ? 'move' : 'default' }">
|
|
|
+ <i class="hcha hcha-timeline-chart"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableFilter() },
|
|
|
+ draggable: {data: draggableFilter(), isEnabled: availableDraggableFilter,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
|
|
|
+ title="${_('Filter Bar')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableFilter() ? 'move' : 'default' }">
|
|
|
+ <i class="fa fa-filter"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: { 'draggable-widget': true, 'disabled': !availableDraggableChart() },
|
|
|
+ draggable: {data: draggableMap(), isEnabled: availableDraggableChart,
|
|
|
+ options: {'start': function(event, ui){lastWindowScrollPosition = $(window).scrollTop();$('.card-body').slideUp('fast');},
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}}"
|
|
|
+ title="${_('Map')}" rel="tooltip" data-placement="top">
|
|
|
+ <a data-bind="style: { cursor: $root.availableDraggableChart() ? 'move' : 'default' }">
|
|
|
+ <i class="hcha hcha-map-chart"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="clearfix"></div>
|
|
|
+</div>
|
|
|
|
|
|
-<div id="loader" class="row" style="text-align: center;margin-top: 20px">
|
|
|
- <!--[if lte IE 9]>
|
|
|
- <img src="/static/art/spinner-big.gif" />
|
|
|
- <![endif]-->
|
|
|
- <!--[if !IE]> -->
|
|
|
- <i class="fa fa-spinner fa-spin" style="font-size: 60px; color: #DDD"></i>
|
|
|
- <!-- <![endif]-->
|
|
|
+<div id="emptyDashboard" data-bind="visible: !isEditing() && columns().length == 0">
|
|
|
+ <div style="float:left; padding-top: 90px; margin-right: 20px; text-align: center; width: 260px">${_('Click on the pencil to get started with your dashboard!')}</div>
|
|
|
+ <img src="/search/static/art/hint_arrow.png" />
|
|
|
</div>
|
|
|
|
|
|
-% if error:
|
|
|
-<div class="container-fluid">
|
|
|
- <div class="row-fluid">
|
|
|
- <div class="span12">
|
|
|
- <div class="alert alert-error">
|
|
|
- % if error['title']:
|
|
|
- <h4>${ error['title'] }</h4><br/>
|
|
|
- % endif
|
|
|
- <span class="decodeError" data-message="${ error['message'] }"></span>
|
|
|
+
|
|
|
+<div data-bind="visible: isEditing() && previewColumns() != '' && columns().length == 0, css:{'with-top-margin': isEditing()}">
|
|
|
+ <div class="container-fluid">
|
|
|
+ <div class="row-fluid" data-bind="visible: previewColumns() == 'oneThirdLeft'">
|
|
|
+ <div class="span3 preview-row"></div>
|
|
|
+ <div class="span9 preview-row"></div>
|
|
|
+ </div>
|
|
|
+ <div class="row-fluid" data-bind="visible: previewColumns() == 'full'">
|
|
|
+ <div class="span12 preview-row">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="row-fluid" data-bind="visible: previewColumns() == 'magic'">
|
|
|
+ <div class="span12 preview-row">
|
|
|
+ ${ _('Template predefined with some widgets.') }
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-% else:
|
|
|
-<div class="container results">
|
|
|
-
|
|
|
- <div id="mainContent" class="row hide">
|
|
|
- % if response and 'response' in response and 'docs' in response['response'] and len(response['response']['docs']) > 0 and 'normalized_facets' in response:
|
|
|
- <% shown_facets = 0 %>
|
|
|
- <div class="span2 results">
|
|
|
- <ul class="facet-list">
|
|
|
- ## Force chart facets first
|
|
|
- % for fld in response['normalized_facets']:
|
|
|
- % if fld['type'] == 'chart':
|
|
|
- <%
|
|
|
- found_value = ""
|
|
|
- for fq in solr_query['fq'].split('|'):
|
|
|
- if fq and fq.split(':')[0] == fld['field']:
|
|
|
- found_value = fq[fq.find(":") + 1:]
|
|
|
- remove_list = solr_query['fq'].split('|')
|
|
|
- remove_list.remove(fq)
|
|
|
- %>
|
|
|
- %if found_value != "":
|
|
|
- <% shown_facets += 1 %>
|
|
|
- <li class="nav-header">${fld['label']}</li>
|
|
|
- <li><strong>${ found_value }</strong> <a href="?collection=${ current_collection }&query=${ solr_query['q'] }&fq=${utf_quoter('|'.join(remove_list))}${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}"><i class="fa fa-times"></i></a></li>
|
|
|
- %endif
|
|
|
- % endif
|
|
|
- % endfor
|
|
|
- % for fld in response['normalized_facets']:
|
|
|
- % if fld['type'] != 'chart':
|
|
|
- <% shown_facets += 1 %>
|
|
|
- % if fld['type'] == 'date':
|
|
|
- <li class="nav-header facetHeader dateFacetHeader">${fld['label']}</li>
|
|
|
- % else:
|
|
|
- <li class="nav-header facetHeader">${fld['label']}</li>
|
|
|
- % endif
|
|
|
-
|
|
|
- <%
|
|
|
- found_value = ""
|
|
|
- for fq in solr_query['fq'].split('|'):
|
|
|
- if fq and fq.split(':')[0] == fld['field']:
|
|
|
- found_value = fq[fq.find(":") + 1:]
|
|
|
- remove_list = solr_query['fq'].split('|')
|
|
|
- remove_list.remove(fq)
|
|
|
- %>
|
|
|
- % for group, count in macros.pairwise(fld['counts']):
|
|
|
- % if count > 0 and group != "" and found_value == "" and loop.index < 100:
|
|
|
- % if fld['type'] == 'field':
|
|
|
- <li class="facetItem"><a href='?collection=${ current_collection }&query=${ solr_query['q'] }&fq=${ utf_quoter(solr_query['fq']) }|${ fld['field'] }:"${utf_quoter(group)}"${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}'>${group}</a> <span class="counter">(${ count })</span></li>
|
|
|
- % endif
|
|
|
- % if fld['type'] == 'range':
|
|
|
- <li class="facetItem"><a href='?collection=${ current_collection }&query=${ solr_query['q'] }&fq=${ utf_quoter(solr_query['fq']) }|${ fld['field'] }:["${ group }" TO "${ str(int(group) + int(fld['gap']) - 1) }"]${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}'>${ group } - ${ str(int(group) + int(fld['gap']) - 1) }</a> <span class="counter">(${ count })</span></li>
|
|
|
- % endif
|
|
|
- % if fld['type'] == 'date':
|
|
|
- <li class="facetItem dateFacetItem"><a href='?collection=${ current_collection }&query=${ solr_query['q'] }&fq=${ utf_quoter(solr_query['fq']) }|${ fld['field'] }:[${ group } TO ${ group }${ utf_quoter(fld['gap']) }]${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}'><span class="dateFacet" data-format="${fld['format']}">${ group }<span class="dateFacetGap hide">${ fld['gap'] }</span></span></a> <span class="counter">(${ count })</span></li>
|
|
|
- % endif
|
|
|
- % endif
|
|
|
- % if found_value != "" and loop.index < 100:
|
|
|
- % if fld['type'] == 'field' and '"' + group + '"' == found_value:
|
|
|
- <li class="facetItem"><strong>${ group }</strong> <a href="?collection=${ current_collection }&query=${ solr_query['q'] }&fq=${utf_quoter('|'.join(remove_list))}${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}"><i class="fa fa-times"></i></a></li>
|
|
|
- % endif
|
|
|
- % if fld['type'] == 'range' and '["' + group + '" TO "' + str(int(group) + int(fld['gap']) - 1) + '"]' == found_value:
|
|
|
- <li class="facetItem"><strong>${ group } - ${ str(int(group) + int(fld['gap']) - 1) }</strong> <a href="?collection=${ current_collection }&query=${ solr_query['q'] }&fq=${utf_quoter('|'.join(remove_list))}${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}"><i class="fa fa-times"></i></a></li>
|
|
|
- % endif
|
|
|
- % if fld['type'] == 'date' and found_value.startswith('[' + group + ' TO'):
|
|
|
- <li class="facetItem"><strong><span class="dateFacet" data-format="${fld['format']}">${ group }<span class="dateFacetGap hide">${ fld['gap'] }</span></span></strong> <a href="?collection=${ current_collection }&query=${ solr_query['q'] }&fq=${utf_quoter('|'.join(remove_list))}${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}"><i class="fa fa-times"></i></a></li>
|
|
|
- % endif
|
|
|
- % endif
|
|
|
- % endfor
|
|
|
- % endif
|
|
|
- % endfor
|
|
|
- </ul>
|
|
|
+
|
|
|
+<div data-bind="css: {'dashboard': true, 'with-top-margin': isEditing()}">
|
|
|
+ <div class="container-fluid">
|
|
|
+ <div class="row-fluid" data-bind="template: { name: 'column-template', foreach: columns}">
|
|
|
+ </div>
|
|
|
+ <div class="clearfix"></div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+<script type="text/html" id="column-template">
|
|
|
+ <div data-bind="css: klass">
|
|
|
+ <div class="container-fluid" data-bind="visible: $root.isEditing">
|
|
|
+ <div data-bind="css: {'add-row': true, 'is-editing': $root.isEditing}, sortable: { data: drops, isEnabled: $root.isEditing, options: {'placeholder': 'add-row-highlight', 'greedy': true, 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}, dragged: function(widget){var _r = $data.addEmptyRow(true); _r.addWidget(widget);$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});showAddFacetDemiModal(widget);viewModel.search()}}"></div>
|
|
|
+ </div>
|
|
|
+ <div data-bind="template: { name: 'row-template', foreach: rows}">
|
|
|
+ </div>
|
|
|
+ <div class="container-fluid" data-bind="visible: $root.isEditing">
|
|
|
+ <div data-bind="css: {'add-row': true, 'is-editing': $root.isEditing}, sortable: { data: drops, isEnabled: $root.isEditing, options: {'placeholder': 'add-row-highlight', 'greedy': true, 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});}}, dragged: function(widget){var _r = $data.addEmptyRow(); _r.addWidget(widget);$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});showAddFacetDemiModal(widget);viewModel.search()}}"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="row-template">
|
|
|
+ <div class="emptyRow" data-bind="visible: widgets().length == 0 && $index() == 0 && $root.isEditing() && $parent.size() > 4 && $parent.rows().length == 1">
|
|
|
+ <img src="/search/static/art/hint_arrow_flipped.png" style="float:left; margin-right: 10px"/>
|
|
|
+ <div style="float:left; text-align: center; width: 260px">${_('Drag any of the widgets inside your empty row')}</div>
|
|
|
+ <div class="clearfix"></div>
|
|
|
+ </div>
|
|
|
+ <div class="container-fluid">
|
|
|
+ <div class="row-header" data-bind="visible: $root.isEditing">
|
|
|
+ <span class="muted">${_('Row')}</span>
|
|
|
+ <div style="display: inline; margin-left: 60px">
|
|
|
+ <a href="javascript:void(0)" data-bind="visible: $index()<$parent.rows().length-1, click: function(){moveDown($parent, this)}"><i class="fa fa-chevron-down"></i></a>
|
|
|
+ <a href="javascript:void(0)" data-bind="visible: $index()>0, click: function(){moveUp($parent, this)}"><i class="fa fa-chevron-up"></i></a>
|
|
|
+ <a href="javascript:void(0)" data-bind="visible: $parent.rows().length > 1, click: function(){remove($parent, this)}"><i class="fa fa-times"></i></a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div data-bind="css: {'row-fluid': true, 'row-container':true, 'is-editing': $root.isEditing},
|
|
|
+ sortable: { template: 'widget-template', data: widgets, isEnabled: $root.isEditing,
|
|
|
+ options: {'handle': '.move-widget', 'opacity': 0.7, 'placeholder': 'row-highlight', 'greedy': true,
|
|
|
+ 'stop': function(event, ui){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});},
|
|
|
+ 'helper': function(event){lastWindowScrollPosition = $(window).scrollTop(); $('.card-body').slideUp('fast'); var _par = $('<div>');_par.addClass('card card-widget');var _title = $('<h2>');_title.addClass('card-heading simple');_title.text($(event.toElement).text());_title.appendTo(_par);_par.height(80);_par.width(180);return _par;}},
|
|
|
+ dragged: function(widget){$('.card-body').slideDown('fast', function(){$(window).scrollTop(lastWindowScrollPosition)});showAddFacetDemiModal(widget);viewModel.search()}}">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="widget-template">
|
|
|
+ <div data-bind="attr: {'id': 'wdg_'+ id(),}, css: klass">
|
|
|
+ <h2 class="card-heading simple">
|
|
|
+ <span data-bind="visible: $root.isEditing">
|
|
|
+ <a href="javascript:void(0)" class="move-widget"><i class="fa fa-arrows"></i></a>
|
|
|
+ <a href="javascript:void(0)" data-bind="click: compress, visible: size() > 1"><i class="fa fa-step-backward"></i></a>
|
|
|
+ <a href="javascript:void(0)" data-bind="click: expand, visible: size() < 12"><i class="fa fa-step-forward"></i></a>
|
|
|
+
|
|
|
+ </span>
|
|
|
+ <span data-bind="with: $root.collection.getFacetById(id())">
|
|
|
+ <span data-bind="editable: label, editableOptions: {enabled: $root.isEditing()}"></span>
|
|
|
+ </span>
|
|
|
+ <!-- ko ifnot: $root.collection.getFacetById(id()) -->
|
|
|
+ <span data-bind="editable: name, editableOptions: {enabled: $root.isEditing()}"></span>
|
|
|
+ <!-- /ko -->
|
|
|
+ <div class="inline pull-right" data-bind="visible: $root.isEditing">
|
|
|
+ <a href="javascript:void(0)" data-bind="click: function(){remove($parent, this)}"><i class="fa fa-times"></i></a>
|
|
|
+ </div>
|
|
|
+ </h2>
|
|
|
+ <div class="card-body" style="padding: 5px;">
|
|
|
+ <div data-bind="template: { name: function() { return widgetType(); } }" class="widget-main-section"></div>
|
|
|
</div>
|
|
|
- % endif
|
|
|
-
|
|
|
- % if response and 'response' in response and 'docs' in response['response'] and len(response['response']['docs']) > 0:
|
|
|
- % if response['normalized_facets'] and shown_facets > 0:
|
|
|
- <div class="span10 results">
|
|
|
- % else:
|
|
|
- <div class="span12 results">
|
|
|
- % endif
|
|
|
- <ul class="breadcrumb">
|
|
|
- <li class="pull-right">
|
|
|
- <div id="sortBy" style="display: inline" class="dropdown">
|
|
|
- Sort by <a data-toggle="dropdown" href="#"><strong></strong> <i class="fa fa-caret-down"></i></a>
|
|
|
- <ul class="dropdown-menu">
|
|
|
- </ul>
|
|
|
+ </div>
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="empty-widget">
|
|
|
+ ${ _('This is an empty widget.')}
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+<script type="text/html" id="hit-widget">
|
|
|
+ <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
|
|
|
+
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <!-- ko if: $root.getFacetFromQuery(id()) -->
|
|
|
+ <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
|
|
|
+ <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
|
|
|
+ ${ _('Label') }: <input type="text" data-bind="value: label" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span data-bind="text: query" />: <span data-bind="text: count" />
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="facet-toggle">
|
|
|
+ <!-- ko if: type() == 'range' -->
|
|
|
+ ${ _('Start') }:
|
|
|
+ <input type="text" class="input-large" data-bind="value: properties.start" />
|
|
|
+ <br/>
|
|
|
+ ${ _('End') }: <input type="text" class="input-large" data-bind="value: properties.end" />
|
|
|
+ <br/>
|
|
|
+ ${ _('Gap') }: <input type="text" class="input-small" data-bind="value: properties.gap" />
|
|
|
+ <br/>
|
|
|
+ ${ _('Min') }:
|
|
|
+ <input type="text" class="input-medium" data-bind="value: properties.min" />
|
|
|
+ <br/>
|
|
|
+ ${ _('Max') }: <input type="text" class="input-medium" data-bind="value: properties.max" />
|
|
|
+ <br/>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: type() == 'field' -->
|
|
|
+ ${ _('Limit') }: <input type="text" class="input-medium" data-bind="value: properties.limit" />
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <a href="javascript: void(0)" class="btn btn-loading" data-bind="visible: properties.canRange, click: $root.collection.toggleRangeFacet" data-loading-text="...">
|
|
|
+ <i class="fa" data-bind="css: { 'fa-arrows-h': type() == 'range', 'fa-circle': type() == 'field' }, attr: { title: type() == 'range' ? 'Range' : 'Term' }"></i>
|
|
|
+ </a>
|
|
|
+ <a href="javascript: void(0)" class="btn btn-loading" data-bind="click: $root.collection.toggleSortFacet" data-loading-text="...">
|
|
|
+ <i class="fa" data-bind="css: { 'fa-caret-down': properties.sort() == 'desc', 'fa-caret-up': properties.sort() == 'asc' }"></i>
|
|
|
+ </a>
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="facet-widget">
|
|
|
+ <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <div class="widget-spinner" data-bind="visible: isLoading()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ko if: $root.getFacetFromQuery(id()) -->
|
|
|
+ <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
|
|
|
+ <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
|
|
|
+ <span data-bind="template: { name: 'facet-toggle', afterRender: function(){ $root.getWidgetById($parent.id).isLoading(false); } }">
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div data-bind="with: $root.collection.getFacetById($parent.id())">
|
|
|
+ <!-- ko if: type() != 'range' -->
|
|
|
+ <div data-bind="foreach: $parent.counts">
|
|
|
+ <div>
|
|
|
+ <a href="javascript: void(0)">
|
|
|
+ <!-- ko if: $index() != $parent.properties.limit() -->
|
|
|
+ <!-- ko if: ! $data.selected -->
|
|
|
+ <span data-bind="text: $data.value, click: function(){ $root.query.toggleFacet({facet: $data, widget_id: $parent.id()}) }"></span>
|
|
|
+ <span class="counter" data-bind="text: ' (' + $data.count + ')', click: function(){ $root.query.toggleFacet({facet: $data, widget_id: $parent.id()}) }"></span>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: $data.selected -->
|
|
|
+ <span data-bind="click: function(){ $root.query.toggleFacet({facet: $data, widget_id: $parent.id()}) }">
|
|
|
+ <span data-bind="text: $data.value"></span>
|
|
|
+ <i class="fa fa-times"></i>
|
|
|
+ </span>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: $index() == $parent.properties.limit() -->
|
|
|
+ <!-- ko if: $parent.properties.prevLimit == undefined || $parent.properties.prevLimit == $parent.properties.limit() -->
|
|
|
+ <span data-bind="click: function(){ $root.collection.upDownFacetLimit($parent.id(), 'up') }">
|
|
|
+ ${ _('Show more...') }
|
|
|
+ </span>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: $parent.properties.prevLimit != undefined && $parent.properties.prevLimit != $parent.properties.limit() -->
|
|
|
+ <span data-bind="click: function(){ $root.collection.upDownFacetLimit($parent.id(), 'up') }">
|
|
|
+ ${ _('Show more') }
|
|
|
+ </span>
|
|
|
+ /
|
|
|
+ <span data-bind="click: function(){ $root.collection.upDownFacetLimit($parent.id(), 'down') }">
|
|
|
+ ${ _('less...') }
|
|
|
+ </span>
|
|
|
+ </span>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- /ko -->
|
|
|
+ </a>
|
|
|
</div>
|
|
|
- </li>
|
|
|
- <li class="active">
|
|
|
- <%
|
|
|
- end_record = int(solr_query["start"])+int(solr_query["rows"])
|
|
|
- if end_record > int(response['response']['numFound']):
|
|
|
- end_record = response['response']['numFound'];
|
|
|
- %>
|
|
|
- ${_('Page %s of %s. Showing %s results (%s seconds)') % (solr_query["current_page"], solr_query["total_pages"], response['response']['numFound'], float(solr_query["search_time"])/1000)}
|
|
|
- </li>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: type() == 'range' -->
|
|
|
+ <div data-bind="foreach: $parent.counts">
|
|
|
+ <div>
|
|
|
+ <a href="javascript: void(0)">
|
|
|
+ <!-- ko if: ! selected -->
|
|
|
+ <span data-bind="click: function(){ $root.query.selectRangeFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field}) }">
|
|
|
+ <span data-bind="text: $data.from + ' - ' + $data.to"></span>
|
|
|
+ <span class="counter" data-bind="text: ' (' + $data.value + ')'"></span>
|
|
|
+ </span>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: selected -->
|
|
|
+ <span data-bind="click: function(){ $root.query.selectRangeFacet({count: $data.value, widget_id: $parent.id(), from: $data.from, to: $data.to, cat: $data.field}) }">
|
|
|
+ <span data-bind="text: $data.from + ' - ' + $data.to"></span>
|
|
|
+ <i class="fa fa-times"></i>
|
|
|
+ </span>
|
|
|
+ <!-- /ko -->
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="resultset-widget">
|
|
|
+ <!-- ko if: $root.collection.template.isGridLayout() -->
|
|
|
+ <div style="float:left; margin-right: 10px" >
|
|
|
+ <div data-bind="visible: ! $root.collection.template.showFieldList()" style="padding-top: 5px; display: inline-block">
|
|
|
+ <a href="javascript: void(0)" data-bind="click: function(){ $root.collection.template.showFieldList(true) }">
|
|
|
+ <i class="fa fa-chevron-right"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div data-bind="visible: $root.collection.template.showFieldList()" style="float:left; margin-right: 10px; background-color: #F6F6F6; padding: 5px">
|
|
|
+ <span data-bind="visible: $root.collection.template.showFieldList()">
|
|
|
+ <div>
|
|
|
+ <a href="javascript: void(0)" class="pull-right" data-bind="click: function(){ $root.collection.template.showFieldList(false) }">
|
|
|
+ <i class="fa fa-chevron-left"></i>
|
|
|
+ </a>
|
|
|
+ <input type="text" data-bind="value: $root.collection.template.fieldsAttributesFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" style="width: 70%; margin-bottom: 10px" />
|
|
|
+ </div>
|
|
|
+ <div style="border-bottom: 1px solid #CCC; padding-bottom: 4px">
|
|
|
+ <a href="javascript: void(0)" class="btn btn-mini"
|
|
|
+ data-bind="click: toggleGridFieldsSelection, css: { 'btn-inverse': $root.collection.template.fields().length > 0 }"
|
|
|
+ style="margin-right: 2px;">
|
|
|
+ <i class="fa fa-square-o"></i>
|
|
|
+ </a>
|
|
|
+ <strong>${_('Field Name')}</strong>
|
|
|
+ </div>
|
|
|
+ <div class="fields-list" data-bind="foreach: $root.collection.template.filteredAttributeFields" style="max-height: 230px; overflow-y: auto; padding-left: 4px">
|
|
|
+ <label class="checkbox">
|
|
|
+ <input type="checkbox" data-bind="checkedValue: name, checked: $root.collection.template.fieldsSelected" />
|
|
|
+ <span data-bind="text: name"></span>
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <div data-bind="visible: !$root.isRetrievingResults() && $root.results().length == 0">
|
|
|
+ ${ _('Your search did not match any documents.') }
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ko if: $root.response().response -->
|
|
|
+ <div data-bind="template: {name: 'resultset-pagination', data: $root.response() }"></div>
|
|
|
+ <!-- /ko -->
|
|
|
+ <div style="overflow-x: auto">
|
|
|
+ <table id="result-container" data-bind="visible: !$root.isRetrievingResults()" style="margin-top: 0; width: 100%">
|
|
|
+ <thead>
|
|
|
+ <tr data-bind="visible: $root.results().length > 0">
|
|
|
+ <th style="width: 18px"> </th>
|
|
|
+ <!-- ko foreach: $root.collection.template.fieldsSelected -->
|
|
|
+ <th data-bind="with: $root.collection.getTemplateField($data), event: { mouseover: $root.enableGridlayoutResultChevron, mouseout: $root.disableGridlayoutResultChevron }" style="white-space: nowrap">
|
|
|
+ <div style="display: inline-block; width:20px;">
|
|
|
+ <a href="javascript: void(0)" data-bind="click: function(){ $root.collection.translateSelectedField($index(), 'left'); }">
|
|
|
+ <i class="fa fa-chevron-left" data-bind="visible: $root.toggledGridlayoutResultChevron() && $index() > 0"></i>
|
|
|
+ <i class="fa fa-chevron-left" style="color: #FFF" data-bind="visible: !$root.toggledGridlayoutResultChevron() || $index() == 0"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div style="display: inline-block;">
|
|
|
+ <a href="javascript: void(0)" title="${ _('Click to sort') }">
|
|
|
+ <span data-bind="text: name, click: $root.collection.toggleSortColumnGridLayout"></span>
|
|
|
+ <i class="fa" data-bind="visible: sort.direction() != null, css: { 'fa-chevron-down': sort.direction() == 'desc', 'fa-chevron-up': sort.direction() == 'asc' }"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ <div style="display: inline-block; width:20px;">
|
|
|
+ <a href="javascript: void(0)" data-bind="click: function(){ $root.collection.translateSelectedField($index(), 'right'); }">
|
|
|
+ <i class="fa fa-chevron-right" data-bind="visible: $root.toggledGridlayoutResultChevron() && $index() < $root.collection.template.fields().length - 1"></i>
|
|
|
+ <i class="fa fa-chevron-up" style="color: #FFF" data-bind="visible: !$root.toggledGridlayoutResultChevron() || $index() == $root.collection.template.fields().length - 1,"></i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </th>
|
|
|
+ <!-- /ko -->
|
|
|
+ </tr>
|
|
|
+ <tr data-bind="visible: $root.collection.template.fieldsSelected().length == 0">
|
|
|
+ <th style="width: 18px"> </th>
|
|
|
+ <th>${ ('Document') }</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody data-bind="foreach: { data: $root.results, as: 'documents' }" class="result-tbody">
|
|
|
+ <tr class="result-row" data-bind="attr: {'id': 'doc_' + $data['id']}">
|
|
|
+ <td><a href="javascript:void(0)" data-bind="click: toggleDocDetails"><i class="fa fa-caret-right"></i></a></td>
|
|
|
+ <!-- ko foreach: $data['row'] -->
|
|
|
+ <td data-bind="html: $data"></td>
|
|
|
+ <!-- /ko -->
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ <div class="widget-spinner" data-bind="visible: $root.isRetrievingResults()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="html-resultset-widget">
|
|
|
+ <!-- ko ifnot: $root.collection.template.isGridLayout() -->
|
|
|
+ <div data-bind="visible: $root.isEditing" style="margin-bottom: 20px">
|
|
|
+ <ul class="nav nav-pills">
|
|
|
+ <li class="active"><a href="javascript: void(0)" class="widget-editor-pill">${_('Editor')}</a></li>
|
|
|
+ <li><a href="javascript: void(0)" class="widget-html-pill">${_('HTML')}</a></li>
|
|
|
+ <li><a href="javascript: void(0)" class="widget-css-pill">${_('CSS & JS')}</a></li>
|
|
|
+ <li><a href="javascript: void(0)" class="widget-settings-pill">${_('Properties')}</a></li>
|
|
|
</ul>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ko if: $root.isEditing() -->
|
|
|
+ <div class="widget-section widget-editor-section">
|
|
|
+ <div class="row-fluid">
|
|
|
+ <div class="span9">
|
|
|
+ <div data-bind="freshereditor: {data: $root.collection.template.template}"></div>
|
|
|
+ </div>
|
|
|
+ <div class="span3">
|
|
|
+ <h5 class="editor-title">${_('Available Fields')}</h5>
|
|
|
+ <select data-bind="options: $root.collection.fields, optionsText: 'name', value: $root.collection.template.selectedVisualField" class="input-large chosen-select"></select>
|
|
|
+ <button title="${ _('Click on this button to add the field') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFieldToVisual">
|
|
|
+ <i class="fa fa-plus"></i>
|
|
|
+ </button>
|
|
|
|
|
|
- % for fld in response['normalized_facets']:
|
|
|
- %if fld['type'] == 'chart':
|
|
|
- <%
|
|
|
- values = ""
|
|
|
- for group, count in macros.pairwise(fld['counts']):
|
|
|
- values += "['" + group + "'," + str(count) + "],"
|
|
|
- %>
|
|
|
- <div class="chartComponent" data-values="[${values[:-1]}]" data-label="${fld['label']}" data-field="${fld['field']}" data-gap="${'gap' in fld and fld['gap'] or ''}">
|
|
|
- <!--[if lte IE 9]>
|
|
|
- <img src="/static/art/spinner-big.gif" />
|
|
|
- <![endif]-->
|
|
|
- <!--[if !IE]> -->
|
|
|
- <i class="fa fa-spinner fa-spin" style="font-size: 24px; color: #DDD"></i>
|
|
|
- <!-- <![endif]-->
|
|
|
+ <h5 class="editor-title" style="margin-top: 30px">${_('Available Functions')}</h2>
|
|
|
+ <select id="visualFunctions" data-bind="value: $root.collection.template.selectedVisualFunction" class="input-large chosen-select">
|
|
|
+ <option title="${ _('Formats date or timestamp in DD-MM-YYYY') }" value="{{#date}} {{/date}}">{{#date}}</option>
|
|
|
+ <option title="${ _('Formats date or timestamp in HH:mm:ss') }" value="{{#time}} {{/time}}">{{#time}}</option>
|
|
|
+ <option title="${ _('Formats date or timestamp in DD-MM-YYYY HH:mm:ss') }" value="{{#datetime}} {{/datetime}}">{{#datetime}}</option>
|
|
|
+ <option title="${ _('Formats a date in the full format') }" value="{{#fulldate}} {{/fulldate}}">{{#fulldate}}</option>
|
|
|
+ <option title="${ _('Formats a date as a Unix timestamp') }" value="{{#timestamp}} {{/timestamp}}">{{#timestamp}}</option>
|
|
|
+ <option title="${ _('Formats a Unix timestamp as Ns, Nmin, Ndays... ago') }" value="{{#fromnow}} {{/fromnow}}">{{#fromnow}}</option>
|
|
|
+ <option title="${ _('Downloads and embed the file in the browser') }" value="{{#embeddeddownload}} {{/embeddeddownload}}">{{#embeddeddownload}}</option>
|
|
|
+ <option title="${ _('Downloads the linked file') }" value="{{#download}} {{/download}}">{{#download}}</option>
|
|
|
+ <option title="${ _('Preview file in File Browser') }" value="{{#preview}} {{/preview}}">{{#preview}}</option>
|
|
|
+ <option title="${ _('Truncate a value after 100 characters') }" value="{{#truncate100}} {{/truncate100}}">{{#truncate100}}</option>
|
|
|
+ <option title="${ _('Truncate a value after 250 characters') }" value="{{#truncate250}} {{/truncate250}}">{{#truncate250}}</option>
|
|
|
+ <option title="${ _('Truncate a value after 500 characters') }" value="{{#truncate500}} {{/truncate500}}">{{#truncate500}}</option>
|
|
|
+ </select>
|
|
|
+ <button title="${ _('Click on this button to add the function') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFunctionToVisual">
|
|
|
+ <i class="fa fa-plus"></i>
|
|
|
+ </button>
|
|
|
+ <p class="muted" style="margin-top: 10px"></p>
|
|
|
</div>
|
|
|
- %endif
|
|
|
- % endfor
|
|
|
-
|
|
|
- <script src="/static/ext/js/mustache.js"></script>
|
|
|
-
|
|
|
- <div id="result-container"></div>
|
|
|
-
|
|
|
- <textarea id="mustacheTmpl" class="hide">${ hue_collection.result.get_template(with_highlighting=True) | n,unicode }</textarea>
|
|
|
- <script>
|
|
|
-
|
|
|
- <%
|
|
|
- docs = response['response']['docs']
|
|
|
- for doc in response['response']['docs']:
|
|
|
- # Beware, schema requires an 'id' field, silently do nothing
|
|
|
- if 'id' in doc and doc['id'] in response.get('highlighting', []):
|
|
|
- doc.update(response['highlighting'][doc['id']])
|
|
|
- %>
|
|
|
-
|
|
|
- var _mustacheTmpl = fixTemplateDotsAndFunctionNames($("#mustacheTmpl").text());
|
|
|
- $.each(${ json.dumps([result for result in docs]) | n,unicode }, function (index, item) {
|
|
|
- addTemplateFunctions(item);
|
|
|
- $("<div>").addClass("result-row").html(
|
|
|
- Mustache.render(_mustacheTmpl, item)
|
|
|
- ).appendTo($("#result-container"));
|
|
|
- });
|
|
|
- </script>
|
|
|
-
|
|
|
- <div class="pagination">
|
|
|
- <ul>
|
|
|
- <%
|
|
|
- pages_to_show = 5 # always use an odd number since we do it symmetrically
|
|
|
-
|
|
|
- beginning = 0
|
|
|
- previous = int(solr_query["start"]) - int(solr_query["rows"])
|
|
|
- next = int(solr_query["start"]) + int(solr_query["rows"])
|
|
|
-
|
|
|
- pages_after = (pages_to_show - 1) / 2
|
|
|
- pages_total = solr_query['total_pages']+1
|
|
|
- real_pages_after = pages_total - solr_query["current_page"]
|
|
|
- symmetric_start = solr_query["current_page"] < pages_total - pages_after
|
|
|
- symmetric_end = solr_query["current_page"] > pages_after
|
|
|
-
|
|
|
- pagination_start = solr_query["current_page"] > (pages_to_show - 1)/2 and (symmetric_start and solr_query["current_page"] - (pages_to_show - 1)/2 or solr_query["current_page"] - pages_to_show + real_pages_after ) or 1
|
|
|
- pagination_end = solr_query["current_page"] < solr_query['total_pages']+1-(pages_to_show - 1)/2 and (symmetric_end and solr_query["current_page"] + (pages_to_show - 1)/2 + 1 or solr_query["current_page"] + (pages_to_show - solr_query["current_page"]) + 1) or solr_query['total_pages']+1
|
|
|
- %>
|
|
|
- % if int(solr_query["start"]) > 0:
|
|
|
- <li>
|
|
|
- <a title="${_('Previous Page')}" href="?collection=${ current_collection }&query=${solr_query["q"]}&fq=${utf_quoter(solr_query["fq"])}${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}&rows=${solr_query["rows"]}&start=${previous}">${_('Previous Page')}</a>
|
|
|
- </li>
|
|
|
- % endif
|
|
|
- % for page in range(pagination_start, pagination_end):
|
|
|
- %if page > 0 and page < pages_total:
|
|
|
- <li
|
|
|
- %if solr_query["current_page"] == page:
|
|
|
- class="active"
|
|
|
- %endif
|
|
|
- >
|
|
|
- <a href="?collection=${ current_collection }&query=${solr_query["q"]}&fq=${utf_quoter(solr_query["fq"])}${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}&rows=${solr_query["rows"]}&start=${(int(page)-1)*int(solr_query["rows"])}">${page}</a>
|
|
|
- </li>
|
|
|
- %endif
|
|
|
- % endfor
|
|
|
- % if end_record < int(response["response"]["numFound"]):
|
|
|
- <li>
|
|
|
- <a title="Next page" href="?collection=${ current_collection }&query=${solr_query["q"]}&fq=${utf_quoter(solr_query["fq"])}${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}&rows=${solr_query["rows"]}&start=${next}">${_('Next Page')}</a>
|
|
|
- </li>
|
|
|
- % endif
|
|
|
- </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="widget-section widget-html-section" style="display: none">
|
|
|
+ <div class="row-fluid">
|
|
|
+ <div class="span9">
|
|
|
+ <textarea data-bind="codemirror: {data: $root.collection.template.template, lineNumbers: true, htmlMode: true, mode: 'text/html' }" data-template="true"></textarea>
|
|
|
+ </div>
|
|
|
+ <div class="span3">
|
|
|
+ <h5 class="editor-title">${_('Available Fields')}</h2>
|
|
|
+ <select data-bind="options: $root.collection.fields, optionsText: 'name', value: $root.collection.template.selectedSourceField" class="input-medium chosen-select"></select>
|
|
|
+ <button title="${ _('Click on this button to add the field') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFieldToSource">
|
|
|
+ <i class="fa fa-plus"></i>
|
|
|
+ </button>
|
|
|
+
|
|
|
+ <h5 class="editor-title" style="margin-top: 30px">${_('Available Functions')}</h2>
|
|
|
+ <select id="sourceFunctions" data-bind="value: $root.collection.template.selectedSourceFunction" class="input-medium chosen-select">
|
|
|
+ <option title="${ _('Formats a date in the DD-MM-YYYY format') }" value="{{#date}} {{/date}}">{{#date}}</option>
|
|
|
+ <option title="${ _('Formats a date in the HH:mm:ss format') }" value="{{#time}} {{/time}}">{{#time}}</option>
|
|
|
+ <option title="${ _('Formats a date in the DD-MM-YYYY HH:mm:ss format') }" value="{{#datetime}} {{/datetime}}">{{#datetime}}</option>
|
|
|
+ <option title="${ _('Formats a date in the full format') }" value="{{#fulldate}} {{/fulldate}}">{{#fulldate}}</option>
|
|
|
+ <option title="${ _('Formats a date as a Unix timestamp') }" value="{{#timestamp}} {{/timestamp}}">{{#timestamp}}</option>
|
|
|
+ <option title="${ _('Shows the relative time') }" value="{{#fromnow}} {{/fromnow}}">{{#fromnow}}</option>
|
|
|
+ <option title="${ _('Downloads and embed the file in the browser') }" value="{{#embeddeddownload}} {{/embeddeddownload}}">{{#embeddeddownload}}</option>
|
|
|
+ <option title="${ _('Downloads the linked file') }" value="{{#download}} {{/download}}">{{#download}}</option>
|
|
|
+ <option title="${ _('Preview file in File Browser') }" value="{{#preview}} {{/preview}}">{{#preview}}</option>
|
|
|
+ <option title="${ _('Truncate a value after 100 characters') }" value="{{#truncate100}} {{/truncate100}}">{{#truncate100}}</option>
|
|
|
+ <option title="${ _('Truncate a value after 250 characters') }" value="{{#truncate250}} {{/truncate250}}">{{#truncate250}}</option>
|
|
|
+ <option title="${ _('Truncate a value after 500 characters') }" value="{{#truncate500}} {{/truncate500}}">{{#truncate500}}</option>
|
|
|
+ </select>
|
|
|
+ <button title="${ _('Click on this button to add the function') }" class="btn plus-btn" data-bind="click: $root.collection.template.addFunctionToSource">
|
|
|
+ <i class="fa fa-plus"></i>
|
|
|
+ </button>
|
|
|
+ <p class="muted" style="margin-top: 10px"></p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="widget-section widget-css-section" style="display: none">
|
|
|
+ <textarea data-bind="codemirror: {data: $root.collection.template.extracode, lineNumbers: true, htmlMode: true, mode: 'text/html' }"></textarea>
|
|
|
+ </div>
|
|
|
+ <div class="widget-section widget-settings-section" style="display: none, min-height:200px">
|
|
|
+ ${ _('Sorting') }
|
|
|
+
|
|
|
+ <div data-bind="foreach: $root.collection.template.fieldsSelected">
|
|
|
+ <span data-bind="text: $data"></span>
|
|
|
+ </div>
|
|
|
+ <br/>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <div style="overflow-x: auto">
|
|
|
+ <div data-bind="visible: $root.results().length == 0">
|
|
|
+ ${ _('Your search did not match any documents.') }
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ko if: $root.response().response -->
|
|
|
+ <div data-bind="template: {name: 'resultset-pagination', data: $root.response() }"></div>
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <div id="result-container" data-bind="foreach: $root.results">
|
|
|
+ <div class="result-row" data-bind="html: $data"></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="widget-spinner" data-bind="visible: $root.isRetrievingResults()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
</div>
|
|
|
</div>
|
|
|
- % else:
|
|
|
- <div class="span2">
|
|
|
- </div>
|
|
|
- <div class="span10">
|
|
|
- <h4>
|
|
|
- ${_('Your search')} - <strong>${solr_query["q"]}</strong> - ${_('did not match any documents.')}
|
|
|
- </h4>
|
|
|
- ${_('Suggestions:')}
|
|
|
- <ul>
|
|
|
- <li>${_('Make sure all words are spelled correctly.')}</li>
|
|
|
- <li>${_('Try different keywords.')}</li>
|
|
|
- <li>${_('Try more general keywords.')}</li>
|
|
|
- <li>${_('Try fewer keywords.')}</li>
|
|
|
+ <!-- /ko -->
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="resultset-pagination">
|
|
|
+<div style="text-align: center; margin-top: 4px">
|
|
|
+ <a href="javascript: void(0)" title="${ _('Previous') }">
|
|
|
+ <span data-bind="text: name, click: $root.collection.toggleSortColumnGridLayout"></span>
|
|
|
+ <i class="fa fa-arrow-left" data-bind="
|
|
|
+ visible: $data.response.start * 1.0 >= $root.collection.template.rows() * 1.0,
|
|
|
+ click: function() { $root.query.paginate('prev') }">
|
|
|
+ </i></a>
|
|
|
+
|
|
|
+ ${ _('Showing') }
|
|
|
+ <span data-bind="text: ($data.response.start + 1)"></span>
|
|
|
+ ${ _('to') }
|
|
|
+ <span data-bind="text: ($data.response.start + $root.collection.template.rows())"></span>
|
|
|
+ ${ _('of') }
|
|
|
+ <span data-bind="text: $data.response.numFound"></span>
|
|
|
+ ${ _(' results.') }
|
|
|
+
|
|
|
+ ${ _('Show') }
|
|
|
+ <span data-bind="visible: $root.isEditing()" class="spinedit-pagination">
|
|
|
+ <input type="text" data-bind="spinedit: $root.collection.template.rows, valueUpdate:'afterkeydown'" style="text-align: center; margin-bottom: 0" />
|
|
|
+ </span>
|
|
|
+ ${ _('results per page.') }
|
|
|
+
|
|
|
+
|
|
|
+ <a href="javascript: void(0)" title="${ _('Next') }">
|
|
|
+ <span data-bind="text: name, click: $root.collection.toggleSortColumnGridLayout"></span>
|
|
|
+ <i class="fa fa-arrow-right" data-bind="
|
|
|
+ visible: ($root.collection.template.rows() * 1.0 + $data.response.start * 1.0) < $data.response.numFound,
|
|
|
+ click: function() { $root.query.paginate('next') }">
|
|
|
+ </i>
|
|
|
+ </a>
|
|
|
+
|
|
|
+ <!-- ko if: $data.response.numFound > 0 && $data.response.numFound <= 1000 -->
|
|
|
+ <span class="pull-right">
|
|
|
+ <form method="POST" action="${ url('search:download') }">
|
|
|
+ <input type="hidden" name="collection" data-bind="value: ko.mapping.toJSON($root.collection)"/>
|
|
|
+ <input type="hidden" name="query" data-bind="value: ko.mapping.toJSON($root.query)"/>
|
|
|
+ <button class="btn" type="submit" name="json" title="${ _('Download as JSON') }"><i class="hfo hfo-file-json"></i></button>
|
|
|
+ <button class="btn" type="submit" name="csv" title="${ _('Download as CSV') }"><i class="hfo hfo-file-csv"></i></button>
|
|
|
+ <button class="btn" type="submit" name="xls" title="${ _('Download as Excel') }"><i class="hfo hfo-file-xls"></i></button>
|
|
|
+ </form>
|
|
|
+ </span>
|
|
|
+ <!-- /ko -->
|
|
|
+</div>
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="histogram-widget">
|
|
|
+ <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <div class="widget-spinner" data-bind="visible: isLoading()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ko if: $root.getFacetFromQuery(id()) -->
|
|
|
+ <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
|
|
|
+ <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
|
|
|
+ <span data-bind="template: { name: 'facet-toggle' }">
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <a href="javascript:void(0)" data-bind="click: $root.collection.timeLineZoom"><i class="fa fa-search-minus"></i></a>
|
|
|
+ <span>
|
|
|
+ ${ _('Group By') }
|
|
|
+ <select class="input-medium" data-bind="options: $root.query.multiqs, optionsValue: 'id',optionsText: 'label', value: $root.query.selectedMultiq">
|
|
|
+ </select>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <div data-bind="timelineChart: {datum: {counts: counts, extraSeries: extraSeries, widget_id: $parent.id(), label: label}, stacked: $root.collection.getFacetById($parent.id()).properties.stacked(), field: field, label: label, transformer: timelineChartDataTransformer,
|
|
|
+ onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
|
|
|
+ onStateChange: function(state){ $root.collection.getFacetById($parent.id()).properties.stacked(state.stacked); },
|
|
|
+ onClick: function(d){ viewModel.query.selectRangeFacet({count: d.obj.value, widget_id: $parent.id(), from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
|
|
|
+ onComplete: function(){ viewModel.getWidgetById(id).isLoading(false) }}" />
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="bar-widget">
|
|
|
+ <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <div class="widget-spinner" data-bind="visible: isLoading()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ko if: $root.getFacetFromQuery(id()) -->
|
|
|
+ <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
|
|
|
+ <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
|
|
|
+ <span data-bind="template: { name: 'facet-toggle' }">
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div data-bind="barChart: {datum: {counts: counts, widget_id: $parent.id(), label: label}, stacked: false, field: field, label: label,
|
|
|
+ transformer: barChartDataTransformer,
|
|
|
+ onStateChange: function(state){ console.log(state); },
|
|
|
+ onClick: function(d){ viewModel.query.selectRangeFacet({count: d.obj.value, widget_id: d.obj.widget_id, from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
|
|
|
+ onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
|
|
|
+ onComplete: function(){ viewModel.getWidgetById(id).isLoading(false) } }"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="line-widget">
|
|
|
+ <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <div class="widget-spinner" data-bind="visible: isLoading()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ko if: $root.getFacetFromQuery(id()) -->
|
|
|
+ <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
|
|
|
+ <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
|
|
|
+ <span data-bind="template: { name: 'facet-toggle' }">
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div data-bind="lineChart: {datum: {counts: counts, widget_id: $parent.id(), label: label}, field: field, label: label,
|
|
|
+ transformer: lineChartDataTransformer,
|
|
|
+ onClick: function(d){ viewModel.query.selectRangeFacet({count: d.obj.value, widget_id: d.obj.widget_id, from: d.obj.from, to: d.obj.to, cat: d.obj.field}) },
|
|
|
+ onSelectRange: function(from, to){ viewModel.collection.selectTimelineFacet({from: from, to: to, cat: field, widget_id: $parent.id()}) },
|
|
|
+ onComplete: function(){ viewModel.getWidgetById(id).isLoading(false) } }"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+<script type="text/html" id="pie-widget">
|
|
|
+ <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <!-- ko if: $root.getFacetFromQuery(id()) -->
|
|
|
+ <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
|
|
|
+ <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
|
|
|
+ <span data-bind="template: { name: 'facet-toggle' }">
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div data-bind="with: $root.collection.getFacetById($parent.id())">
|
|
|
+ <!-- ko if: type() == 'range' -->
|
|
|
+ <div data-bind="pieChart: {data: {counts: $parent.counts, widget_id: $parent.id}, field: field, fqs: $root.query.fqs,
|
|
|
+ transformer: rangePieChartDataTransformer,
|
|
|
+ maxWidth: 250,
|
|
|
+ onClick: function(d){ viewModel.query.selectRangeFacet({count: d.data.obj.value, widget_id: d.data.obj.widget_id, from: d.data.obj.from, to: d.data.obj.to, cat: d.data.obj.field}) },
|
|
|
+ onComplete: function(){ viewModel.getWidgetById($parent.id).isLoading(false)} }" />
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: type() != 'range' -->
|
|
|
+ <div data-bind="pieChart: {data: {counts: $parent.counts, widget_id: $parent.id}, field: field, fqs: $root.query.fqs,
|
|
|
+ transformer: pieChartDataTransformer,
|
|
|
+ maxWidth: 250,
|
|
|
+ onClick: function(d){viewModel.query.toggleFacet({facet: d.data.obj, widget_id: d.data.obj.widget_id})},
|
|
|
+ onComplete: function(){viewModel.getWidgetById($parent.id).isLoading(false)}}" />
|
|
|
+ <!-- /ko -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+ <div class="widget-spinner" data-bind="visible: isLoading()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="filter-widget">
|
|
|
+ <div data-bind="visible: $root.query.fqs().length == 0" style="margin-top: 10px">${_('There are currently no filters applied.')}</div>
|
|
|
+ <div data-bind="foreach: { data: $root.query.fqs, afterRender: function(){ isLoading(false); } }">
|
|
|
+ <!-- ko if: $data.type() == 'field' -->
|
|
|
+ <div class="filter-box">
|
|
|
+ <a href="javascript:void(0)" class="pull-right" data-bind="click: function(){ viewModel.query.removeFilter($data); viewModel.search() }"><i class="fa fa-times"></i></a>
|
|
|
+ <strong>${_('field')}</strong>:
|
|
|
+ <span data-bind="text: $data.field"></span>
|
|
|
+ <br/>
|
|
|
+ <strong>${_('value')}</strong>:
|
|
|
+ <span data-bind="text: $data.filter"></span>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+ <!-- ko if: $data.type() == 'range' -->
|
|
|
+ <div class="filter-box">
|
|
|
+ <a href="javascript:void(0)" class="pull-right" data-bind="click: function(){ viewModel.query.removeFilter($data); viewModel.search() }"><i class="fa fa-times"></i></a>
|
|
|
+ <strong>${_('field')}</strong>:
|
|
|
+ <span data-bind="text: $data.field"></span>
|
|
|
+ <br/>
|
|
|
+ <span data-bind="foreach: $data.properties" style="font-weight: normal">
|
|
|
+ <strong>${_('from')}</strong>: <span data-bind="text: $data.from"></span>
|
|
|
+ <br/>
|
|
|
+ <strong>${_('to')}</strong>: <span data-bind="text: $data.from"></span>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+ </div>
|
|
|
+ <div class="clearfix"></div>
|
|
|
+ <div class="widget-spinner" data-bind="visible: isLoading() && $root.query.fqs().length > 0">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+</script>
|
|
|
+
|
|
|
+<script type="text/html" id="map-widget">
|
|
|
+ <!-- ko ifnot: $root.getFacetFromQuery(id()) -->
|
|
|
+ <!-- /ko -->
|
|
|
+
|
|
|
+ <!-- ko if: $root.getFacetFromQuery(id()) -->
|
|
|
+ <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
|
|
|
+ <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
|
|
|
+ ${ _('Scope') }:
|
|
|
+ <select data-bind="selectedOptions: properties.scope" class="input-small">
|
|
|
+ <option value="world">${ _("World") }</option>
|
|
|
+ <option value="usa">${ _("USA") }</option>
|
|
|
+ </select>
|
|
|
+ <span data-bind="template: { name: 'facet-toggle' }">
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div data-bind="with: $root.collection.getFacetById($parent.id())">
|
|
|
+ <div data-bind="mapChart: {data: {counts: $parent.counts, scope: $root.collection.getFacetById($parent.id).properties.scope()},
|
|
|
+ transformer: mapChartDataTransformer,
|
|
|
+ maxWidth: 750,
|
|
|
+ onClick: function(d){ viewModel.query.toggleFacet({facet: d, widget_id: $parent.id}) },
|
|
|
+ onComplete: function(){ viewModel.getWidgetById($parent.id).isLoading(false)} }" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- /ko -->
|
|
|
+ <div class="widget-spinner" data-bind="visible: isLoading()">
|
|
|
+ <!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+ <!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+ </div>
|
|
|
+</script>
|
|
|
+
|
|
|
+<div id="addFacetDemiModal" class="demi-modal hide" data-backdrop="false">
|
|
|
+ <div class="modal-body">
|
|
|
+ <a href="javascript: void(0)" data-dismiss="modal" data-bind="click: addFacetDemiModalFieldCancel" class="pull-right"><i class="fa fa-times"></i></a>
|
|
|
+ <div style="float: left; margin-right: 10px;text-align: center">
|
|
|
+ <input id="addFacetInput" type="text" data-bind="value: $root.collection.template.fieldsModalFilter, valueUpdate:'afterkeydown'" placeholder="${_('Filter fields')}" class="input" style="float: left" /><br/>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <ul data-bind="foreach: $root.collection.template.filteredModalFields().sort(function (l, r) { return l.name() > r.name() ? 1 : -1 }), visible: $root.collection.template.filteredModalFields().length > 0"
|
|
|
+ class="unstyled inline fields-chooser" style="height: 100px; overflow-y: auto">
|
|
|
+ <li data-bind="click: addFacetDemiModalFieldPreview">
|
|
|
+ <span class="badge badge-info"><span data-bind="text: name(), attr: {'title': type()}"></span>
|
|
|
+ </span>
|
|
|
+ </li>
|
|
|
</ul>
|
|
|
+ <div class="alert alert-info inline" data-bind="visible: $root.collection.template.filteredModalFields().length == 0" style="margin-left: 124px;height: 42px;line-height: 42px">
|
|
|
+ ${_('There are no fields matching your search term.')}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- % endif
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
-% endif
|
|
|
+<div id="genericLoader" style="display: none">
|
|
|
+<!--[if !IE]> --><i class="fa fa-spinner fa-spin"></i><!-- <![endif]-->
|
|
|
+<!--[if IE]><img src="/static/art/spinner.gif" /><![endif]-->
|
|
|
+</div>
|
|
|
|
|
|
-% if hue_collection:
|
|
|
- ${ hue_collection.result.get_extracode() | n,unicode }
|
|
|
-% endif
|
|
|
+<script id="document-details" type="x-tmpl-mustache">
|
|
|
+<div class="document-details">
|
|
|
+ <table>
|
|
|
+ <tbody>
|
|
|
+ {{#properties}}
|
|
|
+ <tr>
|
|
|
+ <th style="text-align: left; white-space: nobreak; vertical-align:top">{{key}}</th>
|
|
|
+ <td width="100%">{{value}}</td>
|
|
|
+ </tr>
|
|
|
+ {{/properties}}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+</script>
|
|
|
|
|
|
-<script>
|
|
|
- $(document).ready(function () {
|
|
|
+## Extra code for style and custom JS
|
|
|
+<span data-bind="html: $root.collection.template.extracode"></span>
|
|
|
|
|
|
- if ($(".errorlist").length > 0) {
|
|
|
- $(".errorlist li").each(function () {
|
|
|
- $(document).trigger("error", $(this).text());
|
|
|
- });
|
|
|
- }
|
|
|
+<link rel="stylesheet" href="/search/static/css/search.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/css/hue-filetypes.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/css/leaflet.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/css/hue-charts.css">
|
|
|
+<link rel="stylesheet" href="/static/css/freshereditor.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/css/codemirror.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/css/bootstrap-editable.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/css/bootstrap-slider.min.css">
|
|
|
+<link rel="stylesheet" href="/static/css/bootstrap-spinedit.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/css/nv.d3.min.css">
|
|
|
+<link rel="stylesheet" href="/static/ext/chosen/chosen.min.css">
|
|
|
|
|
|
- $(".decodeError").text($("<span>").html($(".decodeError").data("message")).text());
|
|
|
+<script src="/search/static/js/search.utils.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/knockout-min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/knockout.mapping-2.3.2.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/bootstrap-editable.min.js"></script>
|
|
|
+<script src="/static/ext/js/bootstrap-slider.min.js"></script>
|
|
|
+<script src="/static/js/bootstrap-spinedit.js"></script>
|
|
|
+<script src="/static/js/ko.editable.js"></script>
|
|
|
+<script src="/static/ext/js/shortcut.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/js/freshereditor.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/codemirror-3.11.js"></script>
|
|
|
+<script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/codemirror-xml.js"></script>
|
|
|
+<script src="/static/ext/js/mustache.js"></script>
|
|
|
+<script src="/static/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/jquery/plugins/jquery.flot.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/jquery/plugins/jquery.flot.categories.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/leaflet/leaflet.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/chosen/chosen.jquery.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
|
|
|
- $("#loader").hide();
|
|
|
- $("#mainContent").removeClass("hide");
|
|
|
- window.onbeforeunload = function (e) {
|
|
|
- $("#loader").show();
|
|
|
- $("#mainContent").addClass("hide");
|
|
|
- };
|
|
|
+<script src="/search/static/js/search.ko.js" type="text/javascript" charset="utf-8"></script>
|
|
|
|
|
|
- var collectionProperties = ${ hue_collection.facets.data | n,unicode }.properties;
|
|
|
- $(".facetHeader").each(function(cnt, section){
|
|
|
- var _added = 0;
|
|
|
- var _showMore = false;
|
|
|
- var _lastSection = null;
|
|
|
- $(section).nextUntil(".facetHeader").each(function(cnt, item){
|
|
|
- if (cnt < collectionProperties.limit*1){ // it's a string, *1 -> number
|
|
|
- $(item).show();
|
|
|
- _added++;
|
|
|
- if (cnt == (collectionProperties.limit*1) - 1){
|
|
|
- _lastSection = $(item);
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- _showMore = true;
|
|
|
- }
|
|
|
- });
|
|
|
- if (_added == 0){
|
|
|
- $(section).hide();
|
|
|
- }
|
|
|
- if (_showMore){
|
|
|
- $("<li>").addClass("facetShowMore").html('<a href="javascript:void(0)">${_('Show')} ' + ($(section).nextUntil(".facetHeader").length-(collectionProperties.limit*1)) + ' ${_('more...')}</a>').insertAfter(_lastSection);
|
|
|
- }
|
|
|
- });
|
|
|
+<script src="/static/js/hue.geo.js"></script>
|
|
|
+<script src="/static/js/hue.colors.js"></script>
|
|
|
|
|
|
- $(document).on("click", ".facetShowMore", function(){
|
|
|
- $(this).hide();
|
|
|
- $(this).nextUntil(".facetHeader").show();
|
|
|
- });
|
|
|
+<script src="/static/ext/js/d3.v3.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/nv.d3.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/topojson.v1.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/topo/world.topo.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/static/ext/js/topo/usa.topo.js" type="text/javascript" charset="utf-8"></script>
|
|
|
|
|
|
- $(".dateFacet").each(function () {
|
|
|
- var _m = moment($(this).text());
|
|
|
- var _em = moment($(this).text());
|
|
|
- var _format = $(this).data("format");
|
|
|
- var _gap = $(this).find(".dateFacetGap").text();
|
|
|
- var _how = _gap.match(/\d+/)[0];
|
|
|
- var _what = _gap.substring(_how.length + 1).toLowerCase();
|
|
|
- _em.add(_what, _how * 1);
|
|
|
-
|
|
|
- if (_format != null && _format != "") {
|
|
|
- if (_format.toLowerCase().indexOf("fromnow") > -1){
|
|
|
- $(this).text(_m.fromNow() + " - " + _em.fromNow());
|
|
|
- }
|
|
|
- else {
|
|
|
- $(this).text(_m.format(_format) + " - " + _em.format(_format));
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- $(this).text(_m.format() + " - " + _em.format());
|
|
|
- }
|
|
|
- $(this).parents(".dateFacetItem").data("epoch", _m.valueOf());
|
|
|
- });
|
|
|
+<script src="/search/static/js/nv.d3.datamaps.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.legend.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.multiBarWithBrushChart.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.lineWithBrushChart.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.growingDiscreteBar.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.growingDiscreteBarChart.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.growingMultiBar.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.growingMultiBarChart.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.growingPie.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/nv.d3.growingPieChart.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+<script src="/search/static/js/charts.ko.js" type="text/javascript" charset="utf-8"></script>
|
|
|
|
|
|
- var orderedDateFacets = $(".dateFacetItem");
|
|
|
- orderedDateFacets.sort(function (a, b) {
|
|
|
- a = $(a).data("epoch");
|
|
|
- b = $(b).data("epoch");
|
|
|
- if (a > b) {
|
|
|
- return -1;
|
|
|
- } else if (a < b) {
|
|
|
- return 1;
|
|
|
- } else {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- });
|
|
|
- $(".dateFacetHeader").after(orderedDateFacets);
|
|
|
-
|
|
|
- % if hue_collection:
|
|
|
- $(".current-collection").text("${ hue_collection.label }");
|
|
|
- $("#id_collection").val(${ hue_collection.id });
|
|
|
-
|
|
|
- % if user.is_superuser:
|
|
|
- var collectionUrl = $(".dropdown-collection[data-value=${ hue_collection.id }]").data("settings-url");
|
|
|
- $(".change-settings").attr("href", collectionUrl);
|
|
|
- % endif
|
|
|
- % endif
|
|
|
-
|
|
|
- $(document).on("click", ".dropdown-collection", function (e) {
|
|
|
- e.preventDefault();
|
|
|
- var collectionId = $(this).data("value");
|
|
|
- $("select[name='collection']").val(collectionId);
|
|
|
- % if user.is_superuser:
|
|
|
- $(".change-settings").attr("href", $(this).data("settings-url"));
|
|
|
- % endif
|
|
|
- $("form").find("input[type='hidden']").val("");
|
|
|
- $("form").submit();
|
|
|
- });
|
|
|
+<script src="/static/ext/js/less-1.7.0.min.js" type="text/javascript" charset="utf-8"></script>
|
|
|
+
|
|
|
+<style type="text/css">
|
|
|
+ .dashboard .container-fluid {
|
|
|
+ padding: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .row-container {
|
|
|
+ width: 100%;
|
|
|
+ min-height: 70px;
|
|
|
+ }
|
|
|
|
|
|
- $("#download-csv").on("click", function(e) {
|
|
|
- $("form").attr('action', "${ url('search:download', format='csv') }");
|
|
|
- $("form").attr('target', "_new");
|
|
|
- $("form").submit();
|
|
|
- $("form").removeAttr('action');
|
|
|
- $("form").removeAttr('target');
|
|
|
+ .row-container.is-editing {
|
|
|
+ border: 1px solid #e5e5e5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ui-sortable {
|
|
|
+ background-color: #F3F3F3;
|
|
|
+ min-height: 100px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ui-sortable h2 {
|
|
|
+ padding-left: 10px!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ui-sortable h2 ul {
|
|
|
+ float: left;
|
|
|
+ margin-right: 10px;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ui-sortable-disabled {
|
|
|
+ background-color: #FFF;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-column {
|
|
|
+ border: none;
|
|
|
+ min-height: 400px!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-widget {
|
|
|
+ padding-top: 0;
|
|
|
+ border: 0;
|
|
|
+ min-height: 100px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-widget .card-heading {
|
|
|
+ font-size: 12px!important;
|
|
|
+ font-weight: bold!important;
|
|
|
+ line-height: 24px!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-widget .card-body {
|
|
|
+ margin-top: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-toolbar {
|
|
|
+ margin: 0;
|
|
|
+ padding: 4px;
|
|
|
+ padding-top: 0;
|
|
|
+ top: 70px;
|
|
|
+ position: fixed;
|
|
|
+ width: 100%;
|
|
|
+ z-index: 1000;
|
|
|
+ }
|
|
|
+
|
|
|
+ .row-header {
|
|
|
+ background-color: #F6F6F6;
|
|
|
+ display: inline;
|
|
|
+ padding: 3px;
|
|
|
+ border: 1px solid #e5e5e5;
|
|
|
+ border-bottom: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .row-highlight {
|
|
|
+ background-color: #DDD;
|
|
|
+ min-height: 100px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #emptyDashboard {
|
|
|
+ position: absolute;
|
|
|
+ right: 164px;
|
|
|
+ top: 80px;
|
|
|
+ color: #666;
|
|
|
+ font-size: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .emptyRow {
|
|
|
+ margin-top: 10px;
|
|
|
+ margin-left: 140px;
|
|
|
+ color: #666;
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .preview-row {
|
|
|
+ background-color: #DDD;
|
|
|
+ min-height: 400px!important;
|
|
|
+ margin-top: 30px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .toolbar-label {
|
|
|
+ float: left;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #999;
|
|
|
+ padding-left: 8px;
|
|
|
+ padding-top: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .draggable-widget {
|
|
|
+ width: 60px;
|
|
|
+ text-align: center;
|
|
|
+ float: left;
|
|
|
+ border: 1px solid #CCC;
|
|
|
+ margin-top: 10px;
|
|
|
+ margin-left: 10px;
|
|
|
+ cursor: move;
|
|
|
+ }
|
|
|
+
|
|
|
+ .draggable-widget.disabled {
|
|
|
+ cursor: default;
|
|
|
+ }
|
|
|
+
|
|
|
+ .draggable-widget a {
|
|
|
+ font-size: 28px;
|
|
|
+ line-height: 46px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .draggable-widget.disabled a {
|
|
|
+ cursor: default;
|
|
|
+ color: #CCC;
|
|
|
+ }
|
|
|
+
|
|
|
+ .layout-container {
|
|
|
+ width: 100px;
|
|
|
+ float: left;
|
|
|
+ margin-top: 10px;
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .layout-box {
|
|
|
+ float: left;
|
|
|
+ height: 48px;
|
|
|
+ background-color: #DDD;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .layout-box i {
|
|
|
+ color: #333;
|
|
|
+ font-size: 28px;
|
|
|
+ line-height: 48px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .layout-container:hover .layout-box {
|
|
|
+ background-color: #CCC;
|
|
|
+ }
|
|
|
+
|
|
|
+ .with-top-margin {
|
|
|
+ margin-top: 60px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ui-sortable .card-heading {
|
|
|
+ -webkit-touch-callout: none;
|
|
|
+ -webkit-user-select: none;
|
|
|
+ -khtml-user-select: none;
|
|
|
+ -moz-user-select: none;
|
|
|
+ -ms-user-select: none;
|
|
|
+ user-select: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .search-bar {
|
|
|
+ padding-top: 6px;
|
|
|
+ padding-bottom: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .widget-settings-section {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ em {
|
|
|
+ font-weight: bold;
|
|
|
+ background-color: yellow;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nvd3 .nv-brush .extent {
|
|
|
+ fill-opacity: .225!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .nvd3 .nv-legend .disabled rect {
|
|
|
+ fill-opacity: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ .fields-chooser li {
|
|
|
+ cursor: pointer;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .fields-chooser li .badge {
|
|
|
+ font-weight: normal;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .widget-spinner {
|
|
|
+ padding: 10px;
|
|
|
+ font-size: 80px;
|
|
|
+ color: #CCC;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card {
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .badge-left {
|
|
|
+ border-radius: 9px 0px 0px 9px;
|
|
|
+ padding-right: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .badge-right {
|
|
|
+ border-radius: 0px 9px 9px 0px;
|
|
|
+ padding-left: 5px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .trash-filter {
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ .move-widget {
|
|
|
+ cursor: move;
|
|
|
+ }
|
|
|
+
|
|
|
+ body.modal-open {
|
|
|
+ overflow: auto!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .editable-click {
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ .CodeMirror {
|
|
|
+ border: 1px dotted #DDDDDD;
|
|
|
+ }
|
|
|
+
|
|
|
+ [contenteditable=true] {
|
|
|
+ border: 1px dotted #DDDDDD;
|
|
|
+ outline: 0;
|
|
|
+ margin-top: 20px;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ min-height: 150px;
|
|
|
+ }
|
|
|
+
|
|
|
+ [contenteditable=true] [class*="span"], .tmpl [class*="span"] {
|
|
|
+ background-color: #eee;
|
|
|
+ -webkit-border-radius: 3px;
|
|
|
+ -moz-border-radius: 3px;
|
|
|
+ border-radius: 3px;
|
|
|
+ min-height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ background-color: #F3F3F3;
|
|
|
+ border: 2px dashed #DDD;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tmpl {
|
|
|
+ margin: 10px;
|
|
|
+ height: 60px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tmpl [class*="span"] {
|
|
|
+ color: #999;
|
|
|
+ font-size: 12px;
|
|
|
+ text-align: center;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+ .preview-row:nth-child(odd) {
|
|
|
+ background-color: #f9f9f9;
|
|
|
+ }
|
|
|
+
|
|
|
+ .editor-title {
|
|
|
+ font-weight: bold;
|
|
|
+ color: #262626;
|
|
|
+ border-bottom: 1px solid #338bb8;
|
|
|
+ }
|
|
|
+
|
|
|
+ .add-row {
|
|
|
+ background-color: #F6F6F6;
|
|
|
+ min-height: 36px;
|
|
|
+ border: 2px dashed #DDD;
|
|
|
+ text-align: center;
|
|
|
+ padding: 4px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .add-row:before {
|
|
|
+ color:#DDD;
|
|
|
+ display: inline-block;
|
|
|
+ font-family: FontAwesome;
|
|
|
+ font-style: normal;
|
|
|
+ font-weight: normal;
|
|
|
+ font-size: 24px;
|
|
|
+ line-height: 1;
|
|
|
+ -webkit-font-smoothing: antialiased;
|
|
|
+ -moz-osx-font-smoothing: grayscale;
|
|
|
+ content: "\f055";
|
|
|
+ }
|
|
|
+
|
|
|
+ .add-row-highlight {
|
|
|
+ min-height: 10px;
|
|
|
+ background-color:#CCC;
|
|
|
+ }
|
|
|
+
|
|
|
+ .document-details {
|
|
|
+ background-color: #F6F6F6;
|
|
|
+ padding: 10px;
|
|
|
+ border: 1px solid #e5e5e5;
|
|
|
+ }
|
|
|
+
|
|
|
+ .result-row:nth-child(even) {
|
|
|
+ background-color: #F6F6F6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .demi-modal {
|
|
|
+ min-height: 80px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .filter-box {
|
|
|
+ float: left;
|
|
|
+ margin-right: 10px;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ background-color: #F6F6F6;
|
|
|
+ padding: 5px;
|
|
|
+ border:1px solid #d8d8d8;
|
|
|
+ -webkit-border-radius: 3px;
|
|
|
+ -moz-border-radius: 3px;
|
|
|
+ border-radius: 3px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .spinedit-pagination div.spinedit .fa-chevron-up {
|
|
|
+ top: -7px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .spinedit-pagination div.spinedit .fa-chevron-down {
|
|
|
+ top: 7px;
|
|
|
+ left: -4px;
|
|
|
+ }
|
|
|
+
|
|
|
+</style>
|
|
|
+
|
|
|
+<script type="text/javascript" charset="utf-8">
|
|
|
+var viewModel;
|
|
|
+
|
|
|
+nv.dev = false;
|
|
|
+
|
|
|
+var lastWindowScrollPosition = 0;
|
|
|
+
|
|
|
+function pieChartDataTransformer(data) {
|
|
|
+ var _data = [];
|
|
|
+ $(data.counts).each(function (cnt, item) {
|
|
|
+ item.widget_id = data.widget_id;
|
|
|
+ _data.push({
|
|
|
+ label: item.value,
|
|
|
+ value: item.count,
|
|
|
+ obj: item
|
|
|
});
|
|
|
- $("#download-xls").on("click", function(e) {
|
|
|
- $("form").attr('action', "${ url('search:download', format='xls') }");
|
|
|
- $("form").attr('target', "_new");
|
|
|
- $("form").submit();
|
|
|
- $("form").removeAttr('action');
|
|
|
- $("form").removeAttr('target');
|
|
|
+ });
|
|
|
+ return _data;
|
|
|
+}
|
|
|
+
|
|
|
+function rangePieChartDataTransformer(data) {
|
|
|
+ var _data = [];
|
|
|
+ $(data.counts).each(function (cnt, item) {
|
|
|
+ item.widget_id = data.widget_id;
|
|
|
+ _data.push({
|
|
|
+ label: item.from + ' - ' + item.to,
|
|
|
+ from: item.from,
|
|
|
+ to: item.to,
|
|
|
+ value: item.value,
|
|
|
+ obj: item
|
|
|
});
|
|
|
+ });
|
|
|
+ return _data;
|
|
|
+}
|
|
|
|
|
|
- function getCollectionPopoverContent() {
|
|
|
- var _html = "<ul class='unstyled'>";
|
|
|
- $("#collectionPopover ul li").each(function () {
|
|
|
- if ($(this).find("a").data("value") != $("#id_collection").val()) {
|
|
|
- _html += $(this).clone().wrap('<p>').parent().html();
|
|
|
- }
|
|
|
+function barChartDataTransformer(rawDatum) {
|
|
|
+ var _datum = [];
|
|
|
+ var _data = [];
|
|
|
+ $(rawDatum.counts).each(function (cnt, item) {
|
|
|
+ item.widget_id = rawDatum.widget_id;
|
|
|
+ if (typeof item.from != "undefined"){
|
|
|
+ _data.push({
|
|
|
+ series: 0,
|
|
|
+ x: item.from,
|
|
|
+ x_end: item.to,
|
|
|
+ y: item.value,
|
|
|
+ obj: item
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _data.push({
|
|
|
+ series: 0,
|
|
|
+ x: item.value,
|
|
|
+ y: item.count,
|
|
|
+ obj: item
|
|
|
});
|
|
|
- _html += "</ul>";
|
|
|
- return _html;
|
|
|
}
|
|
|
+ });
|
|
|
+ _datum.push({
|
|
|
+ key: rawDatum.label,
|
|
|
+ values: _data
|
|
|
+ });
|
|
|
+ return _datum;
|
|
|
+}
|
|
|
|
|
|
- $("#recordsPerPage").change(function () {
|
|
|
- $("input[name='rows']").val($(this).val());
|
|
|
- $("input[name='rows']").closest("form").submit();
|
|
|
- });
|
|
|
- $("#recordsPerPage").val($("input[name='rows']").val());
|
|
|
-
|
|
|
- var sortingData = ${ hue_collection and hue_collection.sorting.data or '[]' | n,unicode };
|
|
|
- if (sortingData && sortingData.fields && sortingData.fields.length > 0) {
|
|
|
- $.each(sortingData.fields, function (index, item) {
|
|
|
- var _dropDownOption= $("<li>");
|
|
|
- _dropDownOption.html('<a href="#" class="dropdown-sort" data-field="'+ item.field +'" data-asc="'+ item.asc +'">'+ item.label +'</a>');
|
|
|
- _dropDownOption.appendTo($("#sortBy .dropdown-menu"));
|
|
|
+function lineChartDataTransformer(rawDatum) {
|
|
|
+ var _datum = [];
|
|
|
+ var _data = [];
|
|
|
+ $(rawDatum.counts).each(function (cnt, item) {
|
|
|
+ item.widget_id = rawDatum.widget_id;
|
|
|
+ if (typeof item.from != "undefined"){
|
|
|
+ _data.push({
|
|
|
+ series: 0,
|
|
|
+ x: item.from,
|
|
|
+ x_end: item.to,
|
|
|
+ y: item.value,
|
|
|
+ obj: item
|
|
|
});
|
|
|
- var activeSorting = "${solr_query.get("sort", "")}";
|
|
|
- if (activeSorting == ""){
|
|
|
- // if the default sorting is just on one field, select that one
|
|
|
- var _defaultSorting = "";
|
|
|
- var _defaultSortingCnt = 0;
|
|
|
- $.each(sortingData.fields, function (index, item) {
|
|
|
- if (item.include) {
|
|
|
- _defaultSorting = item.label;
|
|
|
- _defaultSortingCnt++;
|
|
|
- }
|
|
|
- });
|
|
|
- if (_defaultSortingCnt == 1){
|
|
|
- $("#sortBy strong").text(_defaultSorting);
|
|
|
- }
|
|
|
- }
|
|
|
- if (activeSorting != "" && activeSorting.indexOf(" ") > -1) {
|
|
|
- $.each(sortingData.fields, function (index, item) {
|
|
|
- if (item.field == activeSorting.split(" ")[0] && item.asc == (activeSorting.split(" ")[1] == "asc")) {
|
|
|
- $("#sortBy strong").text(item.label);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
}
|
|
|
else {
|
|
|
- $("#sortBy").hide();
|
|
|
+ _data.push({
|
|
|
+ series: 0,
|
|
|
+ x: item.value,
|
|
|
+ y: item.count,
|
|
|
+ obj: item
|
|
|
+ });
|
|
|
}
|
|
|
+ });
|
|
|
+ _datum.push({
|
|
|
+ key: rawDatum.label,
|
|
|
+ values: _data
|
|
|
+ });
|
|
|
+ return _datum;
|
|
|
+}
|
|
|
|
|
|
- $(document).on("click", "#sortBy li a", function () {
|
|
|
- var _this = $(this);
|
|
|
- var _sort = _this.data("field") + "+" + (_this.data("asc") ? "asc" : "desc");
|
|
|
- if (typeof _this.data("field") == "undefined") {
|
|
|
- _sort = "";
|
|
|
- }
|
|
|
- location.href = "?collection=${ current_collection }&query=${solr_query["q"]}&fq=${solr_query["fq"]}&rows=${solr_query["rows"]}&start=${solr_query["start"]}" + (_sort != "" ? "&sort=" + _sort : "");
|
|
|
+function timelineChartDataTransformer(rawDatum) {
|
|
|
+ var _datum = [];
|
|
|
+ var _data = [];
|
|
|
+
|
|
|
+ $(rawDatum.counts).each(function (cnt, item) {
|
|
|
+ _data.push({
|
|
|
+ series: 0,
|
|
|
+ x: new Date(moment(item.from).valueOf()),
|
|
|
+ y: item.value,
|
|
|
+ obj: item
|
|
|
});
|
|
|
+ });
|
|
|
+
|
|
|
+ _datum.push({
|
|
|
+ key: rawDatum.label,
|
|
|
+ values: _data
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
- $("#id_query").focus();
|
|
|
+ // If multi query
|
|
|
+ $(rawDatum.extraSeries).each(function (cnt, item) {
|
|
|
+ if (cnt == 0) {
|
|
|
+ _datum = [];
|
|
|
+ }
|
|
|
+ var _data = [];
|
|
|
+ $(item.counts).each(function (cnt, item) {
|
|
|
+ _data.push({
|
|
|
+ series: cnt + 1,
|
|
|
+ x: new Date(moment(item.from).valueOf()),
|
|
|
+ y: item.value,
|
|
|
+ obj: item
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- $(document).on("keydown", function (e) {
|
|
|
- if (!e.ctrlKey && !e.altKey && !e.metaKey){
|
|
|
- if (!$("#id_query").is(":focus")) {
|
|
|
- $("#id_query").focus();
|
|
|
- $("#id_query").val($("#id_query").val());
|
|
|
- }
|
|
|
- }
|
|
|
+ _datum.push({
|
|
|
+ key: item.label,
|
|
|
+ values: _data
|
|
|
});
|
|
|
+ });
|
|
|
+
|
|
|
+ return _datum;
|
|
|
+}
|
|
|
|
|
|
- $("#id_query").on("click", function (e) {
|
|
|
- if (e.pageX - $(this).position().left >= $(this).width()) {
|
|
|
- $(this).val("");
|
|
|
- $("#id_query").removeClass("deletable");
|
|
|
- }
|
|
|
+function mapChartDataTransformer(data) {
|
|
|
+ var _data = [];
|
|
|
+ $(data.counts).each(function (cnt, item) {
|
|
|
+ _data.push({
|
|
|
+ label: item.value,
|
|
|
+ value: item.count,
|
|
|
+ obj: item
|
|
|
});
|
|
|
+ });
|
|
|
+ return _data;
|
|
|
+}
|
|
|
|
|
|
- $("#id_query").on("mousemove", function (e) {
|
|
|
- if (e.pageX - $(this).position().left >= $(this).width() && $(this).hasClass("deletable")) {
|
|
|
- $(this).css("cursor", "pointer");
|
|
|
- }
|
|
|
- else {
|
|
|
- $(this).css("cursor", "auto");
|
|
|
- }
|
|
|
- });
|
|
|
+function toggleDocDetails(doc){
|
|
|
+ var _docRow = $("#doc_" + doc[viewModel.collection.idField()]);
|
|
|
+ if (_docRow.data("expanded") != null && _docRow.data("expanded")){
|
|
|
+ $("#doc_" + doc[viewModel.collection.idField()] + "_details").parent().hide();
|
|
|
+ _docRow.find(".fa-caret-down").removeClass("fa-caret-down").addClass("fa-caret-right");
|
|
|
+ _docRow.data("expanded", false);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _docRow.data("expanded", true);
|
|
|
+ var _detailsRow = $("#doc_" + doc[viewModel.collection.idField()] + "_details");
|
|
|
+ if (_detailsRow.length > 0){
|
|
|
+ _detailsRow.parent().show();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var _newRow = $("<tr>");
|
|
|
+ var _newCell = $("<td>").attr("colspan", _docRow.find("td").length).attr("id", "doc_" + doc[viewModel.collection.idField()] + "_details").html($("#genericLoader").html());
|
|
|
+ _newCell.appendTo(_newRow);
|
|
|
+ _newRow.insertAfter(_docRow);
|
|
|
+ viewModel.getDocument(doc);
|
|
|
+ }
|
|
|
+ _docRow.find(".fa-caret-right").removeClass("fa-caret-right").addClass("fa-caret-down");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function resizeFieldsList() {
|
|
|
+ $(".fields-list").css("max-height", Math.max($("#result-container").height(), 230));
|
|
|
+}
|
|
|
|
|
|
- if ($("#id_query").val().trim() != "") {
|
|
|
- $("#id_query").addClass("deletable");
|
|
|
+$(document).ready(function () {
|
|
|
+
|
|
|
+ var _resizeTimeout = -1;
|
|
|
+ $(window).resize(function(){
|
|
|
+ window.clearTimeout(_resizeTimeout);
|
|
|
+ window.setTimeout(function(){
|
|
|
+ resizeFieldsList();
|
|
|
+ }, 200);
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("showDoc", function(e, doc){
|
|
|
+ viewModel.collection.selectedDocument(doc);
|
|
|
+ var _docDetailsRow = $("#doc_" + doc[viewModel.collection.idField()] + "_details");
|
|
|
+ var _doc = {
|
|
|
+ properties: []
|
|
|
+ };
|
|
|
+ for (var i=0; i< Object.keys(doc).length; i++){
|
|
|
+ _doc.properties.push({
|
|
|
+ key: Object.keys(doc)[i],
|
|
|
+ value: doc[Object.keys(doc)[i]]
|
|
|
+ });
|
|
|
}
|
|
|
+ var template = $("#document-details").html();
|
|
|
+ Mustache.parse(template);
|
|
|
+ var rendered = Mustache.render(template, _doc);
|
|
|
+ _docDetailsRow.html(rendered);
|
|
|
+ });
|
|
|
|
|
|
- % if hue_collection:
|
|
|
- $("#id_query").on("keyup", function() {
|
|
|
- var query = $("#id_query").val();
|
|
|
- if ($.trim(query) != "") {
|
|
|
- $("#id_query").addClass("deletable");
|
|
|
+ $(document).on("click", ".widget-settings-pill", function(){
|
|
|
+ $(this).parents(".card-body").find(".widget-section").hide();
|
|
|
+ $(this).parents(".card-body").find(".widget-settings-section").show();
|
|
|
+ $(this).parent().siblings().removeClass("active");
|
|
|
+ $(this).parent().addClass("active");
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", ".widget-editor-pill", function(){
|
|
|
+ $(this).parents(".card-body").find(".widget-section").hide();
|
|
|
+ $(this).parents(".card-body").find(".widget-editor-section").show();
|
|
|
+ $(this).parent().siblings().removeClass("active");
|
|
|
+ $(this).parent().addClass("active");
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", ".widget-html-pill", function(){
|
|
|
+ $(this).parents(".card-body").find(".widget-section").hide();
|
|
|
+ $(this).parents(".card-body").find(".widget-html-section").show();
|
|
|
+ $(document).trigger("refreshCodemirror");
|
|
|
+ $(this).parent().siblings().removeClass("active");
|
|
|
+ $(this).parent().addClass("active");
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", ".widget-css-pill", function(){
|
|
|
+ $(this).parents(".card-body").find(".widget-section").hide();
|
|
|
+ $(this).parents(".card-body").find(".widget-css-section").show();
|
|
|
+ $(document).trigger("refreshCodemirror");
|
|
|
+ $(this).parent().siblings().removeClass("active");
|
|
|
+ $(this).parent().addClass("active");
|
|
|
+ });
|
|
|
+
|
|
|
+ ko.bindingHandlers.slideVisible = {
|
|
|
+ init: function (element, valueAccessor) {
|
|
|
+ var value = valueAccessor();
|
|
|
+ $(element).toggle(ko.unwrap(value));
|
|
|
+ },
|
|
|
+ update: function (element, valueAccessor) {
|
|
|
+ var value = valueAccessor();
|
|
|
+ ko.unwrap(value) ? $(element).slideDown(100) : $(element).slideUp(100);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ ko.extenders.numeric = function (target, precision) {
|
|
|
+ var result = ko.computed({
|
|
|
+ read: target,
|
|
|
+ write: function (newValue) {
|
|
|
+ var current = target(),
|
|
|
+ roundingMultiplier = Math.pow(10, precision),
|
|
|
+ newValueAsNum = isNaN(newValue) ? 0 : parseFloat(+newValue),
|
|
|
+ valueToWrite = Math.round(newValueAsNum * roundingMultiplier) / roundingMultiplier;
|
|
|
+
|
|
|
+ if (valueToWrite !== current) {
|
|
|
+ target(valueToWrite);
|
|
|
+ } else {
|
|
|
+ if (newValue !== current) {
|
|
|
+ target.notifySubscribers(valueToWrite);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- else {
|
|
|
- $("#id_query").removeClass("deletable");
|
|
|
+ }).extend({ notify: 'always' });
|
|
|
+ result(target());
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ ko.bindingHandlers.freshereditor = {
|
|
|
+ init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
|
|
|
+ var _el = $(element);
|
|
|
+ var options = $.extend(valueAccessor(), {});
|
|
|
+ _el.html(options.data());
|
|
|
+ _el.freshereditor({
|
|
|
+ excludes: ['strikethrough', 'removeFormat', 'insertorderedlist', 'justifyfull', 'insertheading1', 'insertheading2', 'superscript', 'subscript']
|
|
|
+ });
|
|
|
+ _el.freshereditor("edit", true);
|
|
|
+ _el.on("mouseup", function () {
|
|
|
+ storeSelection();
|
|
|
+ updateValues();
|
|
|
+ });
|
|
|
+
|
|
|
+ var sourceDelay = -1;
|
|
|
+ _el.on("keyup", function () {
|
|
|
+ clearTimeout(sourceDelay);
|
|
|
+ storeSelection();
|
|
|
+ sourceDelay = setTimeout(function () {
|
|
|
+ updateValues();
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
+
|
|
|
+ $(".chosen-select").chosen({
|
|
|
+ disable_search_threshold: 10,
|
|
|
+ width: "75%"
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("addFieldToVisual", function(e, field){
|
|
|
+ _el.focus();
|
|
|
+ pasteHtmlAtCaret("{{" + field.name() + "}}");
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("addFunctionToVisual", function(e, fn){
|
|
|
+ _el.focus();
|
|
|
+ pasteHtmlAtCaret(fn);
|
|
|
+ });
|
|
|
+
|
|
|
+ function updateValues(){
|
|
|
+ $("[data-template]")[0].editor.setValue(stripHtmlFromFunctions(_el.html()));
|
|
|
+ valueAccessor().data(_el.html());
|
|
|
}
|
|
|
- });
|
|
|
- % endif
|
|
|
-
|
|
|
- % if hue_collection.autocomplete:
|
|
|
- $("#id_query").attr("autocomplete", "off");
|
|
|
-
|
|
|
- $("#id_query").jHueDelayedInput(function(){
|
|
|
- var query = $("#id_query").val();
|
|
|
- if (query) {
|
|
|
- $.ajax("${ url('search:query_suggest', collection_id=hue_collection.id) }" + query, {
|
|
|
- type: 'GET',
|
|
|
- success: function (data) {
|
|
|
- if (data.message.spellcheck && ! jQuery.isEmptyObject(data.message.spellcheck.suggestions)) {
|
|
|
- $('#id_query').typeahead({source: data.message.spellcheck.suggestions[1].suggestion});
|
|
|
- }
|
|
|
+
|
|
|
+ function storeSelection() {
|
|
|
+ if (window.getSelection) {
|
|
|
+ // IE9 and non-IE
|
|
|
+ sel = window.getSelection();
|
|
|
+ if (sel.getRangeAt && sel.rangeCount) {
|
|
|
+ range = sel.getRangeAt(0);
|
|
|
+ _el.data("range", range);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ else if (document.selection && document.selection.type != "Control") {
|
|
|
+ // IE < 9
|
|
|
+ _el.data("selection", document.selection);
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- % endif
|
|
|
-
|
|
|
- function getFq(existing, currentField, currentValue) {
|
|
|
- if (existing.indexOf(currentField) > -1) {
|
|
|
- var _pieces = existing.split("|");
|
|
|
- var _newPieces = [];
|
|
|
- $(_pieces).each(function (cnt, item) {
|
|
|
- if (item.indexOf(currentField) > -1) {
|
|
|
- _newPieces.push(currentField + currentValue);
|
|
|
+
|
|
|
+ function pasteHtmlAtCaret(html) {
|
|
|
+ var sel, range;
|
|
|
+ if (window.getSelection) {
|
|
|
+ // IE9 and non-IE
|
|
|
+ sel = window.getSelection();
|
|
|
+ if (sel.getRangeAt && sel.rangeCount) {
|
|
|
+ if (_el.data("range")) {
|
|
|
+ range = _el.data("range");
|
|
|
}
|
|
|
else {
|
|
|
- // !!! High trickery. Uses jquery to reconvert all html entities to text
|
|
|
- _newPieces.push($("<span>").html(item).text());
|
|
|
+ range = sel.getRangeAt(0);
|
|
|
}
|
|
|
- });
|
|
|
- return _newPieces.join("|");
|
|
|
- }
|
|
|
- else {
|
|
|
- return $("<span>").html(existing).text() + "|" + currentField + currentValue;
|
|
|
+ range.deleteContents();
|
|
|
+
|
|
|
+ // Range.createContextualFragment() would be useful here but is
|
|
|
+ // non-standard and not supported in all browsers (IE9, for one)
|
|
|
+ var el = document.createElement("div");
|
|
|
+ el.innerHTML = html;
|
|
|
+ var frag = document.createDocumentFragment(), node, lastNode;
|
|
|
+ while ((node = el.firstChild)) {
|
|
|
+ lastNode = frag.appendChild(node);
|
|
|
+ }
|
|
|
+ range.insertNode(frag);
|
|
|
+
|
|
|
+ // Preserve the selection
|
|
|
+ if (lastNode) {
|
|
|
+ range = range.cloneRange();
|
|
|
+ range.setStartAfter(lastNode);
|
|
|
+ range.collapse(true);
|
|
|
+ sel.removeAllRanges();
|
|
|
+ sel.addRange(range);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (document.selection && document.selection.type != "Control") {
|
|
|
+ // IE < 9
|
|
|
+ if (_el.data("selection")) {
|
|
|
+ _el.data("selection").createRange().pasteHTML(html);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ document.selection.createRange().pasteHTML(html);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- var _chartData = null;
|
|
|
+ ko.bindingHandlers.slider = {
|
|
|
+ init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
|
|
|
+ var _el = $(element);
|
|
|
+ var _options = $.extend(valueAccessor(), {});
|
|
|
+ _el.slider({
|
|
|
+ min: _options.min ? _options.min : 1,
|
|
|
+ max: _options.max ? _options.max : 10,
|
|
|
+ step: _options.step ? _options.step : 1,
|
|
|
+ handle: _options.handle ? _options.handle : 'circle',
|
|
|
+ value: _options.data(),
|
|
|
+ tooltip: 'always'
|
|
|
+ });
|
|
|
+ _el.on("slide", function (e) {
|
|
|
+ _options.data(e.value);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ update: function (element, valueAccessor, allBindingsAccessor) {
|
|
|
+ var _options = $.extend(valueAccessor(), {});
|
|
|
+ $(element).slider("setValue", _options.data());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if ($(".chartComponent").length > 0){
|
|
|
- _chartData = eval($(".chartComponent").data("values"));
|
|
|
+ ko.bindingHandlers.spinedit = {
|
|
|
+ init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
|
|
|
+ $(element).spinedit({
|
|
|
+ minimum: 0,
|
|
|
+ maximum: 10000,
|
|
|
+ step: 5,
|
|
|
+ value: ko.unwrap(valueAccessor()),
|
|
|
+ numberOfDecimals: 0
|
|
|
+ });
|
|
|
+ $(element).on("valueChanged", function (e) {
|
|
|
+ valueAccessor()(e.value);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ update: function (element, valueAccessor, allBindingsAccessor) {
|
|
|
+ $(element).spinedit("setValue", ko.unwrap(valueAccessor()));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // test the content of _chartData to see if it can be rendered as chart
|
|
|
- if (_chartData != null && _chartData.length > 0) {
|
|
|
- if ($.isArray(_chartData[0])) {
|
|
|
- if ($.isNumeric(_chartData[0][0]) || _chartData[0][0].match(/[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]T/)) {
|
|
|
- var _isDate = false;
|
|
|
- if (_chartData[0][0].match(/[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]T/) != null){
|
|
|
- _isDate = true;
|
|
|
- }
|
|
|
- $(".chartComponent").jHueBlueprint({
|
|
|
- data: _chartData,
|
|
|
- label: $(".chartComponent").data("label"),
|
|
|
- type: $.jHueBlueprint.TYPES.BARCHART,
|
|
|
- color: $.jHueBlueprint.COLORS.BLUE,
|
|
|
- isDateTime: _isDate,
|
|
|
- fill: true,
|
|
|
- enableSelection: true,
|
|
|
- height: 100,
|
|
|
- onSelect: function (range) {
|
|
|
- var _start = Math.floor(range.xaxis.from)
|
|
|
- var _end = Math.ceil(range.xaxis.to);
|
|
|
- if (_isDate){
|
|
|
- _start = moment(range.xaxis.from).utc().format("YYYY-MM-DD[T]HH:mm:ss[Z]");
|
|
|
- _end = moment(range.xaxis.to).utc().format("YYYY-MM-DD[T]HH:mm:ss[Z]");
|
|
|
- }
|
|
|
- location.href = '?collection=${ current_collection }&query=${ solr_query['q'] }&fq=' + getFq("${ solr_query['fq'] }", $(".chartComponent").data("field"), ':["' + _start + '" TO "' + _end + '"]') + '${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}';
|
|
|
- },
|
|
|
- onItemClick: function (pos, item) {
|
|
|
- if (item) {
|
|
|
- $(".chartComponent").data("plotObj").highlight(item.series, item.datapoint);
|
|
|
- var _point = item.datapoint[0];
|
|
|
- if (_isDate){
|
|
|
- var _momentDate = moment(item.datapoint[0]);
|
|
|
- var _gap = $(".chartComponent").data("gap");
|
|
|
- if (_gap != null && _gap != ""){
|
|
|
- var _futureMomentDate = moment(item.datapoint[0]);
|
|
|
- var _how = _gap.match(/\d+/)[0];
|
|
|
- var _what = _gap.substring(_how.length + 1).toLowerCase();
|
|
|
- _futureMomentDate.add(_what, _how * 1);
|
|
|
- var _start = _momentDate.utc().format("YYYY-MM-DD[T]HH:mm:ss[Z]");
|
|
|
- var _end = _futureMomentDate.utc().format("YYYY-MM-DD[T]HH:mm:ss[Z]");
|
|
|
- location.href = '?collection=${ current_collection }&query=${ solr_query['q'] }&fq=' + getFq("${ solr_query['fq'] }", $(".chartComponent").data("field"), ':["' + _start + '" TO "' + _end + '"]') + '${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}';
|
|
|
- }
|
|
|
- else {
|
|
|
- _point = '"' + _momentDate.utc().format("YYYY-MM-DD[T]HH:mm:ss[Z]") + '"';
|
|
|
- location.href = '?collection=${ current_collection }&query=${ solr_query['q'] }&fq=' + getFq("${ solr_query['fq'] }", $(".chartComponent").data("field"), ':' + _point) + '${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}';
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- location.href = '?collection=${ current_collection }&query=${ solr_query['q'] }&fq=' + getFq("${ solr_query['fq'] }", $(".chartComponent").data("field"), ':' + _point) + '${solr_query.get("sort") and '&sort=' + solr_query.get("sort") or ''}';
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ ko.bindingHandlers.codemirror = {
|
|
|
+ init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
|
|
|
+ var options = $.extend(valueAccessor(), {});
|
|
|
+ var editor = CodeMirror.fromTextArea(element, options);
|
|
|
+ element.editor = editor;
|
|
|
+ editor.setValue(options.data());
|
|
|
+ editor.refresh();
|
|
|
+ var wrapperElement = $(editor.getWrapperElement());
|
|
|
+
|
|
|
+ $(document).on("refreshCodemirror", function(){
|
|
|
+ editor.setSize("100%", 300);
|
|
|
+ editor.refresh();
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("addFieldToSource", function(e, field){
|
|
|
+ if ($(element).data("template")){
|
|
|
+ editor.replaceSelection("{{" + field.name() + "}}");
|
|
|
}
|
|
|
- else {
|
|
|
- $(".chartComponent").addClass("alert").text("${_('The graphical facets works just with numbers or dates. Please choose another field.')}")
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("addFunctionToSource", function(e, fn){
|
|
|
+ if ($(element).data("template")){
|
|
|
+ editor.replaceSelection(fn);
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
- $(".chartComponent").addClass("alert").text("${_('There was an error initializing the graphical facet component.')}")
|
|
|
- }
|
|
|
+ });
|
|
|
+
|
|
|
+ $(".chosen-select").chosen({
|
|
|
+ disable_search_threshold: 10,
|
|
|
+ width: "75%"
|
|
|
+ });
|
|
|
+ $('.chosen-select').trigger('chosen:updated');
|
|
|
+
|
|
|
+ var sourceDelay = -1;
|
|
|
+ editor.on("change", function (cm) {
|
|
|
+ clearTimeout(sourceDelay);
|
|
|
+ var _cm = cm;
|
|
|
+ sourceDelay = setTimeout(function () {
|
|
|
+ var _enc = $("<span>").html(_cm.getValue());
|
|
|
+ if (_enc.find("style").length > 0){
|
|
|
+ var parser = new less.Parser();
|
|
|
+ $(_enc.find("style")).each(function(cnt, item){
|
|
|
+ var _less = "#result-container {" + $(item).text() + "}";
|
|
|
+ try {
|
|
|
+ parser.parse(_less, function (err, tree) {
|
|
|
+ $(item).text(tree.toCSS());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (e){}
|
|
|
+ });
|
|
|
+ valueAccessor().data(_enc.html());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ valueAccessor().data(_cm.getValue());
|
|
|
+ }
|
|
|
+ if ($(".widget-html-pill").parent().hasClass("active")){
|
|
|
+ $("[contenteditable=true]").html(stripHtmlFromFunctions(valueAccessor().data()));
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
+
|
|
|
+ ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
|
|
|
+ wrapperElement.remove();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ update: function (element, valueAccessor, allBindingsAccessor) {
|
|
|
+ var editor = element.editor;
|
|
|
+ editor.refresh();
|
|
|
}
|
|
|
- else {
|
|
|
- $(".chartComponent").hide();
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ viewModel = new SearchViewModel(${ collection.get_c(user) | n,unicode }, ${ query | n,unicode }, ${ initial | n,unicode });
|
|
|
+ ko.applyBindings(viewModel);
|
|
|
+
|
|
|
+ viewModel.init(function(data){
|
|
|
+ $(".chosen-select").trigger("chosen:updated");
|
|
|
+ });
|
|
|
+ viewModel.isRetrievingResults.subscribe(function(value){
|
|
|
+ if (!value){
|
|
|
+ resizeFieldsList();
|
|
|
}
|
|
|
+ });
|
|
|
|
|
|
+ $("#addFacetDemiModal").on("hidden", function () {
|
|
|
+ if (typeof selectedWidget.hasBeenSelected == "undefined"){
|
|
|
+ addFacetDemiModalFieldCancel();
|
|
|
+ }
|
|
|
});
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+ function toggleGridFieldsSelection() {
|
|
|
+ if (viewModel.collection.template.fields().length > 0) {
|
|
|
+ viewModel.collection.template.fieldsSelected([])
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var _fields = [];
|
|
|
+ $.each(viewModel.collection.fields(), function (index, field) {
|
|
|
+ _fields.push(field.name());
|
|
|
+ });
|
|
|
+ viewModel.collection.template.fieldsSelected(_fields);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var selectedWidget = null;
|
|
|
+ function showAddFacetDemiModal(widget) {
|
|
|
+ if (["resultset-widget", "html-resultset-widget", "filter-widget"].indexOf(widget.widgetType()) == -1) {
|
|
|
+ viewModel.collection.template.fieldsModalFilter("");
|
|
|
+ viewModel.collection.template.fieldsModalType(widget.widgetType());
|
|
|
+ viewModel.collection.template.fieldsModalFilter.valueHasMutated();
|
|
|
+ $('#addFacetInput').typeahead({
|
|
|
+ 'source': viewModel.collection.template.availableWidgetFieldsNames(),
|
|
|
+ 'updater': function(item) {
|
|
|
+ addFacetDemiModalFieldPreview({'name': function(){return item}});
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ selectedWidget = widget;
|
|
|
+ $("#addFacetDemiModal").modal("show");
|
|
|
+ $("#addFacetDemiModal input[type='text']").focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function addFacetDemiModalFieldPreview(field) {
|
|
|
+ var _existingFacet = viewModel.collection.getFacetById(selectedWidget.id());
|
|
|
+ if (selectedWidget != null) {
|
|
|
+ selectedWidget.hasBeenSelected = true;
|
|
|
+ selectedWidget.isLoading(true);
|
|
|
+ viewModel.collection.addFacet({'name': field.name(), 'widget_id': selectedWidget.id(), 'widgetType': selectedWidget.widgetType()});
|
|
|
+ if (_existingFacet != null) {
|
|
|
+ _existingFacet.label(field.name());
|
|
|
+ _existingFacet.field(field.name());
|
|
|
+ }
|
|
|
+ $("#addFacetDemiModal").modal("hide");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function addFacetDemiModalFieldCancel() {
|
|
|
+ viewModel.removeWidget(selectedWidget);
|
|
|
+ }
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
${ commonfooter(messages) | n,unicode }
|