Skip to content

Commit

Permalink
Merge pull request #281 from ktalbi/indiv_position_filter
Browse files Browse the repository at this point in the history
ADD | indiv , positions filter
  • Loading branch information
romfabbro authored Jun 10, 2016
2 parents 812bce4 + edb0f00 commit 34146c0
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 48 deletions.
4 changes: 3 additions & 1 deletion Back/ecoreleve_server/Models/List.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ def countQuery(self,criteria = None):
return query



class MonitoredSiteList(ListObjectWithDynProp):

def __init__(self,frontModule, typeObj = None, View = None) :
Expand Down Expand Up @@ -482,4 +483,5 @@ def whereInEquipement(self,fullQueryJoin,criteria):
,or_(table.c['EndDate'] >= func.now(),table.c['EndDate'] == None))
))
fullQueryJoin = fullQueryJoin.where(exists(subSelect))
return fullQueryJoin
return fullQueryJoin

1 change: 1 addition & 0 deletions Back/ecoreleve_server/Views/individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def getIndivLocation(request):
result = gene.search(criteria,offset=offset,per_page=per_page,order_by=['StationDate:desc'])
for row in result :
row['Date'] = row['Date'].strftime('%Y-%m-%d %H:%M:%S')
row['format'] = 'YYYY-MM-DD HH:mm:ss'


# ************ POC Indiv location PLayer ****************
Expand Down
1 change: 0 additions & 1 deletion Front/app/modules/importFile/gpx/lyt-step2-gpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ define([
initialize: function(options) {
this.com = new Com();
this.collection = options.model.attributes.data_FileContent;

this.deferred = $.Deferred();
},

Expand Down
197 changes: 163 additions & 34 deletions Front/app/modules/individuals/layouts/lyt-individuals-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ define([
'ns_form/NSFormsModuleGit',
'ns_navbar/ns_navbar',
'ns_modules/ns_com',
'ns_filter_bower',
'backbone.paginator'

], function($, _, Backbone, Marionette, Swal, Translater, config,
NsGrid, NsMap, NsForm, Navbar, Com
NsGrid, NsMap, NsForm, Navbar, Com,NsFilter,PageColl
) {

'use strict';
Expand All @@ -30,7 +32,9 @@ define([

'click table.backgrid th input': 'checkSelectAll',

'click button#deleteLocations': 'warnDeleteLocations'
'click button#deleteLocations': 'warnDeleteLocations',
'click button#filter': 'filter',

},
ui: {
'grid': '#grid',
Expand All @@ -43,9 +47,9 @@ define([
'mapContainer': '#indivRight',
'showHideCtr': '#showIndivDetails',
'formBtns': '#formBtns',

'locationsGrid': '#locationsGrid',
'locationsPaginator': '#locationsPaginator',
'locationsfilter' : '#locationsFilter'
},

regions: {
Expand All @@ -67,14 +71,16 @@ define([
});
}
this.com = new Com();
this.nbLocations = [];
},

reloadFromNavbar: function(model) {
this.display(model);
this.com.addModule(this.map)
this.map.com = this.com;
this.map.url = config.coreUrl + 'individuals/' + this.indivId + '?geo=true';
this.map.url = config.coreUrl + 'individuals/' + this.indivId + '/locations?geo=true';
this.map.updateFromServ();
this.map.url = false;
Backbone.history.navigate(this.rootUrl + this.indivId, {trigger: false});
},

Expand Down Expand Up @@ -103,9 +109,13 @@ define([
display: function(model) {
this.com = new Com();
this.model = model;

this.indivId = parseInt(this.model.get('ID'));
this.displayForm(this.indivId);


this.displayGrid(this.indivId);

},

displayGrid: function(id) {
Expand Down Expand Up @@ -169,6 +179,43 @@ define([
this.ui.paginatorEquipment.html(this.gridEquip.displayPaginator());

this.displayLocationsGrid();
this.displayLocationsFilter();

},

displayLocationsFilter: function() {
$(this.ui.locationsfilter).empty();
var locfiltersList = {
1: {
name: 'type_',
type: 'Text',
label: 'Types',
title: 'types'
},
2: {
type: 'Select' ,
title: 'Fieldacivity',
name: 'fieldActivity_Name',
editorClass: 'form-control',
options: [],
fieldClass: 'fieldactivity',
validators: []
},
3: {
name: 'Date',
type: 'DateTimePickerEditor',
label: 'Date',
title: 'Date',
options:{isInterval: 1}
}
};
this.locfilters = new NsFilter({
filters: locfiltersList,
com: this.com,
clientSide: true,
filterContainer: this.ui.locationsfilter
});
this.loadCollection(config.coreUrl + 'fieldActivity', 'select.fieldActivity_Name');
},

displayLocationsGrid: function() {
Expand All @@ -177,13 +224,19 @@ define([
name: 'ID',
label: 'ID',
editable: false,
renderable: true,
renderable: false,
cell: 'string'
},{
name: 'Date',
label: 'date',
editable: false,
cell: 'stringDate'
//cell: 'stringDate'
cell:Backgrid.Extension.MomentCell.extend({
displayFormat: "DD/MM/YYYY HH:mm",
//modelFormat : "DD/MM/YYYY HH:mm",
//modelInUnixTimestamp: true,
displayInUTC: false
}),
},/*{
name: 'timestamp',
label: 'date',
Expand Down Expand Up @@ -254,26 +307,56 @@ define([
headerCell: 'select-all'
}];

this.locationsGrid = new NsGrid({
pagingServerSide: false,
pageSize: 10,
columns: locationsCols,
url: config.coreUrl + 'individuals/' + this.indivId + '/locations',
rowClicked: true,
com: this.com,
idName: 'ID'
this.locationsColl = new Backbone.Collection();
this.locationsColl.url = config.coreUrl + 'individuals/' + this.indivId + '/locations';
this.locationsColl.fetch({data : $.param({ criteria: {} }) }).done(function(data){
_this.locationsGrid = new NsGrid({
pagingServerSide: false,
pageSize: 10,
columns: locationsCols,
collection : _this.locationsColl,
rowClicked: true,
com: _this.com,
idName: 'ID',
affectTotalRecords : function(){
var nbobs;
if(this.paginator || this.pagingServerSide){
nbobs = this.grid.collection.state.totalRecords || 0;
}else{
nbobs =this.grid.collection.length || 0;
}

if(_this.nbLocations.length == 0) {
$('#totalLocations').html(nbobs);
_this.nbLocations[0] = nbobs;
} else {
_this.nbLocations[1] = nbobs;
$('#totalLocations').html( nbobs + "/" + _this.nbLocations[0]);
}
}
});

$('#totalLocations').html(_this.locationsColl.length);
_this.nbLocations[0] = _this.locationsColl.length;

_this.locationsGrid.rowClicked = function(args) {
_this.rowClicked(args);
};

_this.ui.locationsGrid.html(_this.locationsGrid.displayGrid());
_this.ui.locationsPaginator.html(_this.locationsGrid.displayPaginator());
_this.$el.find('.select-all-header-cell').html('\
<button id="deleteLocations" class="btn btn-danger btn-sm">\
<span class="reneco reneco-trash"></span>\
</button>');

var tmp = _.clone(_this.locationsGrid.grid.collection.fullCollection);
_this.com.setMotherColl(tmp);

});

this.locationsGrid.rowClicked = function(args) {
_this.rowClicked(args);
};
//url: config.coreUrl + 'individuals/' + this.indivId + '/locations',

this.ui.locationsGrid.html(this.locationsGrid.displayGrid());
this.ui.locationsPaginator.html(this.locationsGrid.displayPaginator());
this.$el.find('.select-all-header-cell').html('\
<button id="deleteLocations" class="btn btn-danger btn-sm">\
<span class="reneco reneco-trash"></span>\
</button>');
},

//should be in the grid module
Expand All @@ -293,16 +376,43 @@ define([
},

displayMap: function() {
this.map = new NsMap({
url: config.coreUrl + 'individuals/' + this.indivId + '/locations?geo=true',
cluster: true,
zoom: 3,
legend: true,
element: 'map',
popup: true,
com: this.com,
selection: true
});

var _this = this;
/* this.mapCollection = new Backbone.Collection();
this.mapCollection.url = config.coreUrl + 'individuals/' + this.indivId + '/locations?geo=true';
this.mapCollection.fetch({ data : {geo:true}}
).done(function(data){
_this.map = new NsMap({
//url: config.coreUrl + 'individuals/' + this.indivId + '/locations?geo=true',
geoJson : data,
cluster: true,
legend: true,
zoom: 3,
element: 'map',
popup: true,
com: _this.com,
selection: true,
idName: 'ID',
latName: 'LAT',
lonName: 'LON'
});
});*/

this.map = new NsMap({
url: config.coreUrl + 'individuals/' + this.indivId + '/locations?geo=true',
//geoJson : data,
cluster: true,
legend: true,
zoom: 3,
element: 'map',
popup: true,
com: _this.com,
selection: true,
idName: 'ID',
latName: 'LAT',
lonName: 'LON'
});
this.map.url = false;
},

focus: function(e) {
Expand Down Expand Up @@ -417,7 +527,9 @@ define([
this.swal(resp, 'error');
});
},

filter: function() {
this.locfilters.update();
},
swal: function(opt, type, callback) {
var btnColor;
switch (type){
Expand Down Expand Up @@ -456,6 +568,23 @@ define([
}
});
},
loadCollection: function(url, element) {
var collection = new Backbone.Collection();
collection.url = url;
var elem = $(element);
elem.append('<option></option>');
collection.fetch({
success: function(data) {
//could be a collectionView
for (var i in data.models) {
var current = data.models[i];
var value = current.get('value') || current.get('PK_id');
var label = current.get('label') || current.get('fullname');
elem.append("<option value ='" + label + "'>"+ label + "</option>");
}
}
});
},

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
</div>

<div id="locations" class="tab-pane fade">
<div id="locationsFilter"></div>
<button id="filter" class="btn btn-success pull-right js-filter"><span class="reneco reneco-search"></span>&nbsp;Search
</button>
<br/>
<div id="locationsGrid"></div>
<div id="locationsPaginator"></div>
</div>
Expand All @@ -54,9 +58,14 @@
</div>

<div id="mapContainer" class=" no-padding col-xs-12 col-md-7 ns-full-height">
<div id="map">
<div id="showDetails" class="masqued">
<span class="glyphicon glyphicon-chevron-right big"/>
<div class="toolbar top dark">
<legend class="pull-left">Locations : <span id="totalLocations"></span></legend>
</div>
<div class = "crop1 overflowXH full-height">
<div id="map" >
<div id="showDetails" class="masqued">
<span class="glyphicon glyphicon-chevron-right big"/>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion Front/app/ns_modules/ns_cell/bg-timestampCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define([
var hours_ = rawValue.split(' ');
var date_ = hours_[0].split('-');
var displayDate = date_[2]+'/'+date_[1]+'/'+date_[0]+' '+hours_[1];

model.set('format','YYYY-MM-DD HH:mm:ss');
return displayDate;
} else {
return '';
Expand Down
5 changes: 3 additions & 2 deletions Front/app/ns_modules/ns_filter/model-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ define([
var tmp = this.com.getMotherColl();
var mod = [];
var filter;
var col, op, val;
var result = [];
var ctx = this;

Expand All @@ -366,6 +365,7 @@ define([
_.filter(coll.models, function (obj) {

pass = true;
var col, op, val;

for (var i = filters.length - 1; i >= 0; i--) {
if (pass) {
Expand Down Expand Up @@ -460,7 +460,8 @@ define([
},

testDate: function (filterVal, op, colVal) {
var filterDate = moment(filterVal, 'DD/MM/YYYY HH:mm:ss');
//var filterDate = moment(filterVal, 'DD/MM/YYYY HH:mm:ss');
var filterDate = moment(filterVal);
var colDate = moment(colVal);

switch (op.toLowerCase()) {
Expand Down
Loading

0 comments on commit 34146c0

Please sign in to comment.