From 75290c77e09e2ac9abaa6a90e405608ca149cd82 Mon Sep 17 00:00:00 2001 From: ktalbi Date: Mon, 30 May 2016 09:59:44 +0200 Subject: [PATCH 1/6] ADD | indiv , positions filter --- Back/ecoreleve_server/Models/List.py | 2 +- Back/ecoreleve_server/Views/individual.py | 1 + .../modules/importFile/gpx/lyt-step2-gpx.js | 1 - .../layouts/lyt-individuals-detail.js | 138 ++++++++++++++---- .../templates/tpl-individuals-detail.html | 3 + .../ns_modules/ns_cell/bg-timestampCell.js | 2 +- .../app/ns_modules/ns_filter/model-filter.js | 5 +- Front/app/ns_modules/ns_map/ns_map.js | 37 ++++- Front/app/router.js | 2 +- 9 files changed, 151 insertions(+), 40 deletions(-) diff --git a/Back/ecoreleve_server/Models/List.py b/Back/ecoreleve_server/Models/List.py index ae1fc35ad..e84841cb3 100644 --- a/Back/ecoreleve_server/Models/List.py +++ b/Back/ecoreleve_server/Models/List.py @@ -415,4 +415,4 @@ def countQuery(self,criteria = None): queryExist = queryExist.where(eval_.eval_binary_expr(curEquipmentTable.c['FK_Individual'],obj['Operator'],obj['Value'])) query = query.where(exists(queryExist)) - return query \ No newline at end of file + return query diff --git a/Back/ecoreleve_server/Views/individual.py b/Back/ecoreleve_server/Views/individual.py index 12841b326..bc2044e2a 100644 --- a/Back/ecoreleve_server/Views/individual.py +++ b/Back/ecoreleve_server/Views/individual.py @@ -401,6 +401,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 **************** diff --git a/Front/app/modules/importFile/gpx/lyt-step2-gpx.js b/Front/app/modules/importFile/gpx/lyt-step2-gpx.js index 3a5596224..12d99e70a 100644 --- a/Front/app/modules/importFile/gpx/lyt-step2-gpx.js +++ b/Front/app/modules/importFile/gpx/lyt-step2-gpx.js @@ -43,7 +43,6 @@ define([ initialize: function(options) { this.com = new Com(); this.collection = options.model.attributes.data_FileContent; - this.deferred = $.Deferred(); }, diff --git a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js index ff5439744..4b4e74c77 100644 --- a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js +++ b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js @@ -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'; @@ -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', @@ -43,9 +47,9 @@ define([ 'mapContainer': '#indivRight', 'showHideCtr': '#showIndivDetails', 'formBtns': '#formBtns', - 'locationsGrid': '#locationsGrid', 'locationsPaginator': '#locationsPaginator', + 'locationsfilter' : '#locationsFilter' }, regions: { @@ -67,6 +71,8 @@ define([ }); } this.com = new Com(); + + }, reloadFromNavbar: function(model) { @@ -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) { @@ -169,6 +179,38 @@ define([ this.ui.paginatorEquipment.html(this.gridEquip.displayPaginator()); this.displayLocationsGrid(); + this.displayLocationsFilter(); + + }, + + displayLocationsFilter: function() { + var locfiltersList = { + 1: { + name: 'type_', + type: 'Text', + label: 'Types', + title: 'types' + }, + 2: { + name: 'fieldActivity_Name', + type: 'Text', + label: 'Fieldacivity ', + title: 'Fieldacivity' + }, + 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 + }); }, displayLocationsGrid: function() { @@ -183,7 +225,13 @@ define([ 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', @@ -254,26 +302,38 @@ 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' + }); + console.log(_this.locationsGrid.collection); + + _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('\ + '); + + 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('\ - '); }, //should be in the grid module @@ -293,15 +353,29 @@ define([ }, displayMap: function() { - this.map = new NsMap({ - url: config.coreUrl + 'individuals/' + this.indivId + '/locations?geo=true', - cluster: true, - zoom: 3, - 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, + zoom: 3, + element: 'map', + popup: true, + com: _this.com, + selection: true, + idName: 'ID', + latName: 'LAT', + lonName: 'LON' + }); + + + + }); + }, focus: function(e) { @@ -416,7 +490,9 @@ define([ this.swal(resp, 'error'); }); }, - + filter: function() { + this.locfilters.update(); + }, swal: function(opt, type, callback) { var btnColor; switch (type){ diff --git a/Front/app/modules/individuals/templates/tpl-individuals-detail.html b/Front/app/modules/individuals/templates/tpl-individuals-detail.html index 43eddb21b..622e4bbf3 100644 --- a/Front/app/modules/individuals/templates/tpl-individuals-detail.html +++ b/Front/app/modules/individuals/templates/tpl-individuals-detail.html @@ -38,6 +38,9 @@
+
+
diff --git a/Front/app/ns_modules/ns_cell/bg-timestampCell.js b/Front/app/ns_modules/ns_cell/bg-timestampCell.js index 7f563b0d1..47825fd08 100644 --- a/Front/app/ns_modules/ns_cell/bg-timestampCell.js +++ b/Front/app/ns_modules/ns_cell/bg-timestampCell.js @@ -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 ''; diff --git a/Front/app/ns_modules/ns_filter/model-filter.js b/Front/app/ns_modules/ns_filter/model-filter.js index 943be8743..30ad8899d 100644 --- a/Front/app/ns_modules/ns_filter/model-filter.js +++ b/Front/app/ns_modules/ns_filter/model-filter.js @@ -355,7 +355,6 @@ define([ var tmp = this.com.getMotherColl(); var mod = []; var filter; - var col, op, val; var result = []; var ctx = this; @@ -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) { @@ -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()) { diff --git a/Front/app/ns_modules/ns_map/ns_map.js b/Front/app/ns_modules/ns_map/ns_map.js index a9155c4f8..fffc016ab 100644 --- a/Front/app/ns_modules/ns_map/ns_map.js +++ b/Front/app/ns_modules/ns_map/ns_map.js @@ -55,6 +55,17 @@ define([ this.com.addModule(this); } + if (options.idName) { + this.idName = options.idName; + } + + if (options.lonName) { + this.lonName = options.lonName; + } + + if (options.latName) { + this.latName = options.latName; + } this.totalElt = options.totalElt || false; this.url = options.url; @@ -744,19 +755,39 @@ define([ //convert a BB collection to a feature collection (geoJson) coll2GeoJson: function(coll){ + var _this = this; var features = { 'features': [], 'type': 'FeatureCollection' }; - var feature, attr; + var feature, attr,id, lat, lon; + coll.each(function(m){ attr = m.attributes; + if (_this.idName) { + id = m.get(_this.idName); + } else { + id = m.attributes.id; + } + + if (_this.latName) { + lat = m.get(_this.latName); + } else { + lat = m.attributes.latitude; + } + + if (_this.lonName) { + lon = m.get(_this.lonName); + } else { + lon = m.attributes.longitude; + } + feature = { 'type': 'Feature', - 'id': attr.id, + 'id': id , 'geometry': { 'type': 'Point', - 'coordinates': [attr.latitude, attr.longitude], + 'coordinates': [lat, lon], }, 'properties': { //todo diff --git a/Front/app/router.js b/Front/app/router.js index 1542ee72b..2c6566928 100644 --- a/Front/app/router.js +++ b/Front/app/router.js @@ -57,7 +57,7 @@ define(['jquery', 'marionette', 'backbone', 'config', 'controller'], }).done(function() { callback.apply(this, args); }).fail(function(msg) { - if (msg.status === 502 || msg.status === 403) { + if ( msg.status === 403) { document.location.href = config.portalUrl; } }); From dc9047baa487a505562b56bdd37b966ccf4d9faf Mon Sep 17 00:00:00 2001 From: ktalbi Date: Tue, 31 May 2016 11:25:02 +0200 Subject: [PATCH 2/6] edit css + mask id indiv in grid --- .../modules/individuals/layouts/lyt-individuals-detail.js | 2 +- .../individuals/templates/tpl-individuals-detail.html | 3 ++- Front/app/styles/_general.less | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js index 4b4e74c77..2cfba26c4 100644 --- a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js +++ b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js @@ -219,7 +219,7 @@ define([ name: 'ID', label: 'ID', editable: false, - renderable: true, + renderable: false, cell: 'string' },{ name: 'Date', diff --git a/Front/app/modules/individuals/templates/tpl-individuals-detail.html b/Front/app/modules/individuals/templates/tpl-individuals-detail.html index 622e4bbf3..b4d00450e 100644 --- a/Front/app/modules/individuals/templates/tpl-individuals-detail.html +++ b/Front/app/modules/individuals/templates/tpl-individuals-detail.html @@ -39,8 +39,9 @@
- +
diff --git a/Front/app/styles/_general.less b/Front/app/styles/_general.less index 22e3a3011..4a2b870ab 100644 --- a/Front/app/styles/_general.less +++ b/Front/app/styles/_general.less @@ -271,3 +271,10 @@ textarea:focus, button:focus { outline: none!important; } + +.js-filter { + margin: 1em; +} +#locationsFilter .filter-form-Date { + margin-top: 1em; +} From 773fb29c135c69cbd47012c2eb8dcb33b70cd58b Mon Sep 17 00:00:00 2001 From: ktalbi Date: Thu, 2 Jun 2016 09:54:44 +0200 Subject: [PATCH 3/6] indiv location filter, add select field for fieldactivity --- .../layouts/lyt-individuals-detail.js | 34 +++++++++++++++---- Front/bower.json | 2 +- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js index 2cfba26c4..47a6ed6a8 100644 --- a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js +++ b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js @@ -184,6 +184,7 @@ define([ }, displayLocationsFilter: function() { + $(this.ui.locationsfilter).empty(); var locfiltersList = { 1: { name: 'type_', @@ -191,12 +192,15 @@ define([ label: 'Types', title: 'types' }, - 2: { - name: 'fieldActivity_Name', - type: 'Text', - label: 'Fieldacivity ', - title: 'Fieldacivity' - }, + 2: { + type: 'Select' , + title: 'Fieldacivity', + name: 'fieldActivity_Name', + editorClass: 'form-control', + options: [], + fieldClass: 'fieldactivity', + validators: [] + }, 3: { name: 'Date', type: 'DateTimePickerEditor', @@ -211,6 +215,7 @@ define([ clientSide: true, filterContainer: this.ui.locationsfilter }); + this.loadCollection(config.coreUrl + 'fieldActivity', 'select.fieldActivity_Name'); }, displayLocationsGrid: function() { @@ -531,6 +536,23 @@ define([ } }); }, + loadCollection: function(url, element) { + var collection = new Backbone.Collection(); + collection.url = url; + var elem = $(element); + elem.append(''); + 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(""); + } + } + }); + }, }); }); diff --git a/Front/bower.json b/Front/bower.json index 8dc0b6214..eb349074c 100644 --- a/Front/bower.json +++ b/Front/bower.json @@ -30,7 +30,7 @@ "tooltipster": "~3.3.0", "chartjs": "~1.0.2", "reneco-fonts": "*", - "NaturalJS_Filter":"1.0.5" + "NaturalJS_Filter":"1.0.6" }, "resolutions": { "jquery": "~1.10.2", From a496de1bf603751d3013fb4253ce0645cf9aed3b Mon Sep 17 00:00:00 2001 From: ktalbi Date: Fri, 3 Jun 2016 12:13:19 +0200 Subject: [PATCH 4/6] add | display filtred locations nb/total 115851233 --- .../layouts/lyt-individuals-detail.js | 25 ++++++++++++++++--- .../templates/tpl-individuals-detail.html | 3 +++ Front/app/ns_modules/ns_grid/model-grid.js | 5 +++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js index 47a6ed6a8..b99fe1602 100644 --- a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js +++ b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js @@ -71,8 +71,7 @@ define([ }); } this.com = new Com(); - - + this.nbLocations = []; }, reloadFromNavbar: function(model) { @@ -317,9 +316,27 @@ define([ collection : _this.locationsColl, rowClicked: true, com: _this.com, - idName: 'ID' + 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]); + } + } }); - console.log(_this.locationsGrid.collection); + + $('#totalLocations').html(_this.locationsColl.length); + _this.nbLocations[0] = _this.locationsColl.length; _this.locationsGrid.rowClicked = function(args) { _this.rowClicked(args); diff --git a/Front/app/modules/individuals/templates/tpl-individuals-detail.html b/Front/app/modules/individuals/templates/tpl-individuals-detail.html index b4d00450e..dd70c9be3 100644 --- a/Front/app/modules/individuals/templates/tpl-individuals-detail.html +++ b/Front/app/modules/individuals/templates/tpl-individuals-detail.html @@ -58,6 +58,9 @@
+
+ Locations : +
diff --git a/Front/app/ns_modules/ns_grid/model-grid.js b/Front/app/ns_modules/ns_grid/model-grid.js index caa664dac..de62a14f4 100644 --- a/Front/app/ns_modules/ns_grid/model-grid.js +++ b/Front/app/ns_modules/ns_grid/model-grid.js @@ -114,7 +114,9 @@ define([ if (options.filterCriteria) { this.filterCriteria = options.filterCriteria; } - + if(options.affectTotalRecords){ + this.affectTotalRecords = options.affectTotalRecords; + } this.initGrid(); this.eventHandler(); }, @@ -383,6 +385,7 @@ define([ this.grid.body.collection = args; this.grid.body.refresh(); } + this.affectTotalRecords(); } else { // Server side filter From ebaa2291562295b3725513dbd0bdf104722eb53c Mon Sep 17 00:00:00 2001 From: ktalbi Date: Fri, 3 Jun 2016 17:00:17 +0200 Subject: [PATCH 5/6] fix | refresh map data when navigate between indiv --- Front/app/modules/individuals/layouts/lyt-individuals-detail.js | 2 +- Front/app/ns_modules/ns_bbfe/bbfe-select.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js index b99fe1602..b017fa943 100644 --- a/Front/app/modules/individuals/layouts/lyt-individuals-detail.js +++ b/Front/app/modules/individuals/layouts/lyt-individuals-detail.js @@ -78,7 +78,7 @@ define([ 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(); Backbone.history.navigate(this.rootUrl + this.indivId, {trigger: false}); }, diff --git a/Front/app/ns_modules/ns_bbfe/bbfe-select.js b/Front/app/ns_modules/ns_bbfe/bbfe-select.js index 293b59337..cdda0e2d4 100644 --- a/Front/app/ns_modules/ns_bbfe/bbfe-select.js +++ b/Front/app/ns_modules/ns_bbfe/bbfe-select.js @@ -17,4 +17,4 @@ define([ } }, }); -}); +}); \ No newline at end of file From edb0f006515389e2fb5dc9131f06daa9a2cbbfd0 Mon Sep 17 00:00:00 2001 From: ktalbi Date: Fri, 10 Jun 2016 10:47:49 +0200 Subject: [PATCH 6/6] fix map scroll --- .../individuals/templates/tpl-individuals-detail.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Front/app/modules/individuals/templates/tpl-individuals-detail.html b/Front/app/modules/individuals/templates/tpl-individuals-detail.html index dd70c9be3..7602f40b4 100644 --- a/Front/app/modules/individuals/templates/tpl-individuals-detail.html +++ b/Front/app/modules/individuals/templates/tpl-individuals-detail.html @@ -61,9 +61,11 @@
Locations :
-
-
- +
+
+
+ +