Commit d0dd33ae49c6223f7ecc1bb70830c1f0b000fa18
1 parent
f3ed67c517
Exists in
master
and in
1 other branch
seguimiento
Showing
4 changed files
with
48 additions
and
16 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -11,26 +11,39 @@ angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoControll |
11 | 11 | $scope.actividad = 'Entrega de producto'; |
12 | 12 | } |
13 | 13 | |
14 | - $scope.general = true; | |
15 | - | |
16 | - console.info($scope.actividad); | |
14 | + $scope.idUsuario = 0; | |
17 | 15 | $scope.marcadores = []; |
18 | - | |
19 | - focaAdminSeguimientoService.obtenerActividad().then(function(datos) { | |
20 | - $scope.marcadores = datos.data; | |
21 | - }); | |
16 | + getSeguimiento(); | |
22 | 17 | |
23 | 18 | $scope.general = function() { |
24 | - $scope.general = true; | |
19 | + $scope.idUsuario = 0; | |
20 | + getSeguimiento(); | |
25 | 21 | }; |
26 | 22 | |
27 | 23 | $scope.individual = function() { |
28 | - $scope.general = false; | |
29 | - | |
24 | + $scope.idUsuario = -1; | |
30 | 25 | }; |
31 | 26 | |
32 | 27 | $scope.salir = function() { |
33 | 28 | $location.path('/'); |
34 | 29 | }; |
30 | + | |
31 | + $scope.search = function(key) { | |
32 | + if (key === 13) { | |
33 | + $scope.idUsuario = $scope.idUsuarioInput; | |
34 | + getSeguimiento(); | |
35 | + } | |
36 | + }; | |
37 | + | |
38 | + function getSeguimiento () { | |
39 | + var datos = { | |
40 | + actividad: $scope.actividad, | |
41 | + idUsuario: $scope.idUsuario | |
42 | + }; | |
43 | + | |
44 | + focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) { | |
45 | + $scope.marcadores = datos.data; | |
46 | + }); | |
47 | + } | |
35 | 48 | } |
36 | 49 | ]); |
src/js/osm-directive.js
... | ... | @@ -8,15 +8,23 @@ angular.module('focaAdminSeguimiento').directive('osm', function() { |
8 | 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
9 | 9 | }, |
10 | 10 | controller: ['$scope', '$filter', function($scope, $filter) { |
11 | + $scope.markers = []; | |
11 | 12 | $scope.$watch('marcadores', function() { |
13 | + for(var i in $scope.markers) { | |
14 | + $scope.map.removeLayer($scope.markers[i]); | |
15 | + } | |
16 | + | |
17 | + $scope.markers = []; | |
12 | 18 | angular.forEach($scope.marcadores, function(marcador) { |
13 | - L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) | |
19 | + $scope.markers.push( | |
20 | + L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) | |
14 | 21 | .bindPopup( |
15 | 22 | 'Actividad: ' + marcador.actividad + '<br/>' + |
16 | 23 | 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + |
17 | 24 | ' ' + marcador.fecha.slice(11,19) + '<br/>' + |
18 | 25 | marcador.observaciones |
19 | - ).openPopup(); | |
26 | + ).openPopup() | |
27 | + ); | |
20 | 28 | }); |
21 | 29 | }); |
22 | 30 | }], |
src/js/service.js
... | ... | @@ -3,8 +3,8 @@ angular.module('focaAdminSeguimiento') |
3 | 3 | 'focaAdminSeguimientoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT |
4 | 4 | ) { |
5 | 5 | return { |
6 | - obtenerActividad: function() { | |
7 | - return $http.get(API_ENDPOINT.URL + '/seguimiento'); | |
6 | + obtenerActividad: function(parametros) { | |
7 | + return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); | |
8 | 8 | } |
9 | 9 | }; |
10 | 10 | }]); |
src/views/foca-admin-seguimiento.html
... | ... | @@ -11,16 +11,27 @@ |
11 | 11 | <div class="col-2 pl-0"> |
12 | 12 | <button |
13 | 13 | type="button" |
14 | - ng-class="{'active': general}" | |
14 | + ng-class="{'active': idUsuario == 0}" | |
15 | 15 | class="btn col-12 my-1" |
16 | 16 | ng-click="general()" |
17 | 17 | >General</button> |
18 | 18 | <button |
19 | 19 | type="button" |
20 | - ng-class="{'active': !general}" | |
20 | + ng-class="{'active': idUsuario != 0}" | |
21 | 21 | class="btn col-12 my-1" |
22 | 22 | ng-click="individual()" |
23 | 23 | >Individual</button> |
24 | + <div class="form-group"> | |
25 | + <input | |
26 | + type="text" | |
27 | + placeholder="Vendedor" | |
28 | + class="form-control" | |
29 | + ng-model="idUsuarioInput" | |
30 | + ng-show="idUsuario == -1" | |
31 | + ng-keypress="search($event.keyCode)" | |
32 | + foca-focus="idUsuario == -1" | |
33 | + > | |
34 | + </div> | |
24 | 35 | <button |
25 | 36 | type="button" |
26 | 37 | class="btn col-12 my-1 boton-salir" |