[build/dist][s]: regular build.
This commit is contained in:
25
dist/recline.dataset.js
vendored
25
dist/recline.dataset.js
vendored
@@ -380,6 +380,9 @@ my.Field = Backbone.Model.extend({
|
|||||||
if (this.attributes.label === null) {
|
if (this.attributes.label === null) {
|
||||||
this.set({label: this.id});
|
this.set({label: this.id});
|
||||||
}
|
}
|
||||||
|
if (this.attributes.type.toLowerCase() in this._typeMap) {
|
||||||
|
this.attributes.type = this._typeMap[this.attributes.type.toLowerCase()];
|
||||||
|
}
|
||||||
if (options) {
|
if (options) {
|
||||||
this.renderer = options.renderer;
|
this.renderer = options.renderer;
|
||||||
this.deriver = options.deriver;
|
this.deriver = options.deriver;
|
||||||
@@ -389,6 +392,17 @@ my.Field = Backbone.Model.extend({
|
|||||||
}
|
}
|
||||||
this.facets = new my.FacetList();
|
this.facets = new my.FacetList();
|
||||||
},
|
},
|
||||||
|
_typeMap: {
|
||||||
|
'text': 'string',
|
||||||
|
'double': 'number',
|
||||||
|
'float': 'number',
|
||||||
|
'numeric': 'number',
|
||||||
|
'int': 'integer',
|
||||||
|
'datetime': 'date-time',
|
||||||
|
'bool': 'boolean',
|
||||||
|
'timestamp': 'date-time',
|
||||||
|
'json': 'object'
|
||||||
|
},
|
||||||
defaultRenderers: {
|
defaultRenderers: {
|
||||||
object: function(val, field, doc) {
|
object: function(val, field, doc) {
|
||||||
return JSON.stringify(val);
|
return JSON.stringify(val);
|
||||||
@@ -396,7 +410,7 @@ my.Field = Backbone.Model.extend({
|
|||||||
geo_point: function(val, field, doc) {
|
geo_point: function(val, field, doc) {
|
||||||
return JSON.stringify(val);
|
return JSON.stringify(val);
|
||||||
},
|
},
|
||||||
'float': function(val, field, doc) {
|
'number': function(val, field, doc) {
|
||||||
var format = field.get('format');
|
var format = field.get('format');
|
||||||
if (format === 'percentage') {
|
if (format === 'percentage') {
|
||||||
return val + '%';
|
return val + '%';
|
||||||
@@ -704,12 +718,19 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
function range(record, filter) {
|
function range(record, filter) {
|
||||||
|
var startnull = (filter.start == null || filter.start === '');
|
||||||
|
var stopnull = (filter.stop == null || filter.stop === '');
|
||||||
var parse = getDataParser(filter);
|
var parse = getDataParser(filter);
|
||||||
var value = parse(record[filter.field]);
|
var value = parse(record[filter.field]);
|
||||||
var start = parse(filter.start);
|
var start = parse(filter.start);
|
||||||
var stop = parse(filter.stop);
|
var stop = parse(filter.stop);
|
||||||
|
|
||||||
return (value >= start && value <= stop);
|
// if at least one end of range is set do not allow '' to get through
|
||||||
|
// note that for strings '' <= {any-character} e.g. '' <= 'a'
|
||||||
|
if ((!startnull || !stopnull) && value === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ((startnull || value >= start) && (stopnull || value <= stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
function geo_distance() {
|
function geo_distance() {
|
||||||
|
|||||||
105
dist/recline.js
vendored
105
dist/recline.js
vendored
@@ -9,17 +9,38 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
|
|||||||
//
|
//
|
||||||
// General notes
|
// General notes
|
||||||
//
|
//
|
||||||
|
// We need 2 things to make most requests:
|
||||||
|
//
|
||||||
|
// 1. CKAN API endpoint
|
||||||
|
// 2. ID of resource for which request is being made
|
||||||
|
//
|
||||||
|
// There are 2 ways to specify this information.
|
||||||
|
//
|
||||||
|
// EITHER (checked in order):
|
||||||
|
//
|
||||||
// * Every dataset must have an id equal to its resource id on the CKAN instance
|
// * Every dataset must have an id equal to its resource id on the CKAN instance
|
||||||
// * You should set the CKAN API endpoint for requests by setting API_ENDPOINT value on this module (recline.Backend.Ckan.API_ENDPOINT)
|
// * The dataset has an endpoint attribute pointing to the CKAN API endpoint
|
||||||
|
//
|
||||||
|
// OR:
|
||||||
|
//
|
||||||
|
// Set the url attribute of the dataset to point to the Resource on the CKAN instance. The endpoint and id will then be automatically computed.
|
||||||
|
|
||||||
my.__type__ = 'ckan';
|
my.__type__ = 'ckan';
|
||||||
|
|
||||||
// Default CKAN API endpoint used for requests (you can change this but it will affect every request!)
|
// Default CKAN API endpoint used for requests (you can change this but it will affect every request!)
|
||||||
|
//
|
||||||
|
// DEPRECATION: this will be removed in v0.7. Please set endpoint attribute on dataset instead
|
||||||
my.API_ENDPOINT = 'http://datahub.io/api';
|
my.API_ENDPOINT = 'http://datahub.io/api';
|
||||||
|
|
||||||
// ### fetch
|
// ### fetch
|
||||||
my.fetch = function(dataset) {
|
my.fetch = function(dataset) {
|
||||||
var wrapper = my.DataStore();
|
if (dataset.endpoint) {
|
||||||
|
var wrapper = my.DataStore(dataset.endpoint);
|
||||||
|
} else {
|
||||||
|
var out = my._parseCkanResourceUrl(dataset.url);
|
||||||
|
dataset.id = out.resource_id;
|
||||||
|
var wrapper = my.DataStore(out.endpoint);
|
||||||
|
}
|
||||||
var dfd = $.Deferred();
|
var dfd = $.Deferred();
|
||||||
var jqxhr = wrapper.search({resource_id: dataset.id, limit: 0});
|
var jqxhr = wrapper.search({resource_id: dataset.id, limit: 0});
|
||||||
jqxhr.done(function(results) {
|
jqxhr.done(function(results) {
|
||||||
@@ -55,8 +76,14 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
my.query = function(queryObj, dataset) {
|
my.query = function(queryObj, dataset) {
|
||||||
|
if (dataset.endpoint) {
|
||||||
|
var wrapper = my.DataStore(dataset.endpoint);
|
||||||
|
} else {
|
||||||
|
var out = my._parseCkanResourceUrl(dataset.url);
|
||||||
|
dataset.id = out.resource_id;
|
||||||
|
var wrapper = my.DataStore(out.endpoint);
|
||||||
|
}
|
||||||
var actualQuery = my._normalizeQuery(queryObj, dataset);
|
var actualQuery = my._normalizeQuery(queryObj, dataset);
|
||||||
var wrapper = my.DataStore();
|
|
||||||
var dfd = $.Deferred();
|
var dfd = $.Deferred();
|
||||||
var jqxhr = wrapper.search(actualQuery);
|
var jqxhr = wrapper.search(actualQuery);
|
||||||
jqxhr.done(function(results) {
|
jqxhr.done(function(results) {
|
||||||
@@ -89,15 +116,24 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Parse a normal CKAN resource URL and return API endpoint etc
|
||||||
|
//
|
||||||
|
// Normal URL is something like http://demo.ckan.org/dataset/some-dataset/resource/eb23e809-ccbb-4ad1-820a-19586fc4bebd
|
||||||
|
my._parseCkanResourceUrl = function(url) {
|
||||||
|
parts = url.split('/');
|
||||||
|
var len = parts.length;
|
||||||
|
return {
|
||||||
|
resource_id: parts[len-1],
|
||||||
|
endpoint: parts.slice(0,[len-4]).join('/') + '/api'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var CKAN_TYPES_MAP = {
|
var CKAN_TYPES_MAP = {
|
||||||
'int4': 'integer',
|
'int4': 'integer',
|
||||||
'int8': 'integer',
|
'int8': 'integer',
|
||||||
'float8': 'float',
|
'float8': 'float'
|
||||||
'text': 'string',
|
|
||||||
'json': 'object',
|
|
||||||
'timestamp': 'date'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}(jQuery, this.recline.Backend.Ckan));
|
}(jQuery, this.recline.Backend.Ckan));
|
||||||
@@ -1027,12 +1063,19 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
function range(record, filter) {
|
function range(record, filter) {
|
||||||
|
var startnull = (filter.start == null || filter.start === '');
|
||||||
|
var stopnull = (filter.stop == null || filter.stop === '');
|
||||||
var parse = getDataParser(filter);
|
var parse = getDataParser(filter);
|
||||||
var value = parse(record[filter.field]);
|
var value = parse(record[filter.field]);
|
||||||
var start = parse(filter.start);
|
var start = parse(filter.start);
|
||||||
var stop = parse(filter.stop);
|
var stop = parse(filter.stop);
|
||||||
|
|
||||||
return (value >= start && value <= stop);
|
// if at least one end of range is set do not allow '' to get through
|
||||||
|
// note that for strings '' <= {any-character} e.g. '' <= 'a'
|
||||||
|
if ((!startnull || !stopnull) && value === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ((startnull || value >= start) && (stopnull || value <= stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
function geo_distance() {
|
function geo_distance() {
|
||||||
@@ -1637,6 +1680,9 @@ my.Field = Backbone.Model.extend({
|
|||||||
if (this.attributes.label === null) {
|
if (this.attributes.label === null) {
|
||||||
this.set({label: this.id});
|
this.set({label: this.id});
|
||||||
}
|
}
|
||||||
|
if (this.attributes.type.toLowerCase() in this._typeMap) {
|
||||||
|
this.attributes.type = this._typeMap[this.attributes.type.toLowerCase()];
|
||||||
|
}
|
||||||
if (options) {
|
if (options) {
|
||||||
this.renderer = options.renderer;
|
this.renderer = options.renderer;
|
||||||
this.deriver = options.deriver;
|
this.deriver = options.deriver;
|
||||||
@@ -1646,6 +1692,17 @@ my.Field = Backbone.Model.extend({
|
|||||||
}
|
}
|
||||||
this.facets = new my.FacetList();
|
this.facets = new my.FacetList();
|
||||||
},
|
},
|
||||||
|
_typeMap: {
|
||||||
|
'text': 'string',
|
||||||
|
'double': 'number',
|
||||||
|
'float': 'number',
|
||||||
|
'numeric': 'number',
|
||||||
|
'int': 'integer',
|
||||||
|
'datetime': 'date-time',
|
||||||
|
'bool': 'boolean',
|
||||||
|
'timestamp': 'date-time',
|
||||||
|
'json': 'object'
|
||||||
|
},
|
||||||
defaultRenderers: {
|
defaultRenderers: {
|
||||||
object: function(val, field, doc) {
|
object: function(val, field, doc) {
|
||||||
return JSON.stringify(val);
|
return JSON.stringify(val);
|
||||||
@@ -1653,7 +1710,7 @@ my.Field = Backbone.Model.extend({
|
|||||||
geo_point: function(val, field, doc) {
|
geo_point: function(val, field, doc) {
|
||||||
return JSON.stringify(val);
|
return JSON.stringify(val);
|
||||||
},
|
},
|
||||||
'float': function(val, field, doc) {
|
'number': function(val, field, doc) {
|
||||||
var format = field.get('format');
|
var format = field.get('format');
|
||||||
if (format === 'percentage') {
|
if (format === 'percentage') {
|
||||||
return val + '%';
|
return val + '%';
|
||||||
@@ -1972,7 +2029,8 @@ my.Graph = Backbone.View.extend({
|
|||||||
var xfield = self.model.fields.get(self.state.attributes.group);
|
var xfield = self.model.fields.get(self.state.attributes.group);
|
||||||
|
|
||||||
// time series
|
// time series
|
||||||
var isDateTime = xfield.get('type') === 'date';
|
var xtype = xfield.get('type');
|
||||||
|
var isDateTime = (xtype === 'date' || xtype === 'date-time' || xtype === 'time');
|
||||||
|
|
||||||
if (self.model.records.models[parseInt(x)]) {
|
if (self.model.records.models[parseInt(x)]) {
|
||||||
x = self.model.records.models[parseInt(x)].get(self.state.attributes.group);
|
x = self.model.records.models[parseInt(x)].get(self.state.attributes.group);
|
||||||
@@ -2086,7 +2144,8 @@ my.Graph = Backbone.View.extend({
|
|||||||
var x = doc.getFieldValue(xfield);
|
var x = doc.getFieldValue(xfield);
|
||||||
|
|
||||||
// time series
|
// time series
|
||||||
var isDateTime = xfield.get('type') === 'date';
|
var xtype = xfield.get('type');
|
||||||
|
var isDateTime = (xtype === 'date' || xtype === 'date-time' || xtype === 'time');
|
||||||
|
|
||||||
if (isDateTime) {
|
if (isDateTime) {
|
||||||
// datetime
|
// datetime
|
||||||
@@ -3778,7 +3837,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Order them if there is ordering info on the state
|
// Order them if there is ordering info on the state
|
||||||
if (this.state.get('columnsOrder')){
|
if (this.state.get('columnsOrder') && this.state.get('columnsOrder').length > 0) {
|
||||||
visibleColumns = visibleColumns.sort(function(a,b){
|
visibleColumns = visibleColumns.sort(function(a,b){
|
||||||
return _.indexOf(self.state.get('columnsOrder'),a.id) > _.indexOf(self.state.get('columnsOrder'),b.id) ? 1 : -1;
|
return _.indexOf(self.state.get('columnsOrder'),a.id) > _.indexOf(self.state.get('columnsOrder'),b.id) ? 1 : -1;
|
||||||
});
|
});
|
||||||
@@ -4520,18 +4579,18 @@ my.FilterEditor = Backbone.View.extend({
|
|||||||
<a href="#" class="js-add-filter">Add filter</a> \
|
<a href="#" class="js-add-filter">Add filter</a> \
|
||||||
<form class="form-stacked js-add" style="display: none;"> \
|
<form class="form-stacked js-add" style="display: none;"> \
|
||||||
<fieldset> \
|
<fieldset> \
|
||||||
<label>Filter type</label> \
|
|
||||||
<select class="filterType"> \
|
|
||||||
<option value="term">Term (text)</option> \
|
|
||||||
<option value="range">Range</option> \
|
|
||||||
<option value="geo_distance">Geo distance</option> \
|
|
||||||
</select> \
|
|
||||||
<label>Field</label> \
|
<label>Field</label> \
|
||||||
<select class="fields"> \
|
<select class="fields"> \
|
||||||
{{#fields}} \
|
{{#fields}} \
|
||||||
<option value="{{id}}">{{label}}</option> \
|
<option value="{{id}}">{{label}}</option> \
|
||||||
{{/fields}} \
|
{{/fields}} \
|
||||||
</select> \
|
</select> \
|
||||||
|
<label>Filter type</label> \
|
||||||
|
<select class="filterType"> \
|
||||||
|
<option value="term">Value</option> \
|
||||||
|
<option value="range">Range</option> \
|
||||||
|
<option value="geo_distance">Geo distance</option> \
|
||||||
|
</select> \
|
||||||
<button type="submit" class="btn">Add</button> \
|
<button type="submit" class="btn">Add</button> \
|
||||||
</fieldset> \
|
</fieldset> \
|
||||||
</form> \
|
</form> \
|
||||||
@@ -4551,7 +4610,7 @@ my.FilterEditor = Backbone.View.extend({
|
|||||||
<fieldset> \
|
<fieldset> \
|
||||||
<legend> \
|
<legend> \
|
||||||
{{field}} <small>{{type}}</small> \
|
{{field}} <small>{{type}}</small> \
|
||||||
<a class="js-remove-filter" href="#" title="Remove this filter">×</a> \
|
<a class="js-remove-filter" href="#" title="Remove this filter" data-filter-id="{{id}}">×</a> \
|
||||||
</legend> \
|
</legend> \
|
||||||
<input type="text" value="{{term}}" name="term" data-filter-field="{{field}}" data-filter-id="{{id}}" data-filter-type="{{type}}" /> \
|
<input type="text" value="{{term}}" name="term" data-filter-field="{{field}}" data-filter-id="{{id}}" data-filter-type="{{type}}" /> \
|
||||||
</fieldset> \
|
</fieldset> \
|
||||||
@@ -4562,7 +4621,7 @@ my.FilterEditor = Backbone.View.extend({
|
|||||||
<fieldset> \
|
<fieldset> \
|
||||||
<legend> \
|
<legend> \
|
||||||
{{field}} <small>{{type}}</small> \
|
{{field}} <small>{{type}}</small> \
|
||||||
<a class="js-remove-filter" href="#" title="Remove this filter">×</a> \
|
<a class="js-remove-filter" href="#" title="Remove this filter" data-filter-id="{{id}}">×</a> \
|
||||||
</legend> \
|
</legend> \
|
||||||
<label class="control-label" for="">From</label> \
|
<label class="control-label" for="">From</label> \
|
||||||
<input type="text" value="{{start}}" name="start" data-filter-field="{{field}}" data-filter-id="{{id}}" data-filter-type="{{type}}" /> \
|
<input type="text" value="{{start}}" name="start" data-filter-field="{{field}}" data-filter-id="{{id}}" data-filter-type="{{type}}" /> \
|
||||||
@@ -4576,7 +4635,7 @@ my.FilterEditor = Backbone.View.extend({
|
|||||||
<fieldset> \
|
<fieldset> \
|
||||||
<legend> \
|
<legend> \
|
||||||
{{field}} <small>{{type}}</small> \
|
{{field}} <small>{{type}}</small> \
|
||||||
<a class="js-remove-filter" href="#" title="Remove this filter">×</a> \
|
<a class="js-remove-filter" href="#" title="Remove this filter" data-filter-id="{{id}}">×</a> \
|
||||||
</legend> \
|
</legend> \
|
||||||
<label class="control-label" for="">Longitude</label> \
|
<label class="control-label" for="">Longitude</label> \
|
||||||
<input type="text" value="{{point.lon}}" name="lon" data-filter-field="{{field}}" data-filter-id="{{id}}" data-filter-type="{{type}}" /> \
|
<input type="text" value="{{point.lon}}" name="lon" data-filter-field="{{field}}" data-filter-id="{{id}}" data-filter-type="{{type}}" /> \
|
||||||
@@ -4636,7 +4695,7 @@ my.FilterEditor = Backbone.View.extend({
|
|||||||
onRemoveFilter: function(e) {
|
onRemoveFilter: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
var filterId = $target.closest('.filter').attr('data-filter-id');
|
var filterId = $target.attr('data-filter-id');
|
||||||
this.model.queryState.removeFilter(filterId);
|
this.model.queryState.removeFilter(filterId);
|
||||||
},
|
},
|
||||||
onTermFiltersUpdate: function(e) {
|
onTermFiltersUpdate: function(e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user