Commit 401c68dfde0af67f20824fbec8410ba236c3a681
Exists in
master
and in
2 other branches
Merge branch 'master' into 'master'
Master See merge request modulos-npm/foca-admin-seguimiento!5
Showing
4 changed files
Show diff stats
src/js/controller.js
| 1 | angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [ | 1 | angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [ |
| 2 | '$scope', 'focaAdminSeguimientoService', '$location', '$routeParams', | 2 | '$scope', 'focaAdminSeguimientoService', '$location', '$routeParams', |
| 3 | function($scope, focaAdminSeguimientoService, $location, $routeParams) { | 3 | function($scope, focaAdminSeguimientoService, $location, $routeParams) { |
| 4 | $scope.actividad = ''; | 4 | $scope.actividad = ''; |
| 5 | 5 | ||
| 6 | $scope.now = new Date(); | 6 | $scope.now = new Date(); |
| 7 | 7 | ||
| 8 | if ($routeParams.parametro === 'nota-pedido') { | 8 | if ($routeParams.parametro === 'nota-pedido') { |
| 9 | $scope.actividad = 'Nota de pedido'; | 9 | $scope.actividad = 'Nota de pedido'; |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | if ($routeParams.parametro === 'hoja-ruta') { | 12 | if ($routeParams.parametro === 'hoja-ruta') { |
| 13 | $scope.actividad = 'Entrega de producto'; | 13 | $scope.actividad = 'Entrega de producto'; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | $scope.general = true; | 16 | $scope.idUsuario = 0; |
| 17 | |||
| 18 | console.info($scope.actividad); | ||
| 19 | $scope.marcadores = []; | 17 | $scope.marcadores = []; |
| 20 | 18 | getSeguimiento(); | |
| 21 | focaAdminSeguimientoService.obtenerActividad().then(function(datos) { | ||
| 22 | $scope.marcadores = datos.data; | ||
| 23 | }); | ||
| 24 | 19 | ||
| 25 | $scope.general = function() { | 20 | $scope.general = function() { |
| 26 | $scope.general = true; | 21 | $scope.idUsuario = 0; |
| 22 | getSeguimiento(); | ||
| 27 | }; | 23 | }; |
| 28 | 24 | ||
| 29 | $scope.individual = function() { | 25 | $scope.individual = function() { |
| 30 | $scope.general = false; | 26 | $scope.idUsuario = -1; |
| 31 | |||
| 32 | }; | 27 | }; |
| 33 | 28 | ||
| 34 | $scope.salir = function() { | 29 | $scope.salir = function() { |
| 35 | $location.path('/'); | 30 | $location.path('/'); |
| 36 | }; | 31 | }; |
| 32 | |||
| 33 | $scope.search = function(key) { | ||
| 34 | if (key === 13) { | ||
| 35 | $scope.idUsuario = $scope.idUsuarioInput; | ||
| 36 | getSeguimiento(); | ||
| 37 | } | ||
| 38 | }; | ||
| 39 | |||
| 40 | $scope.fecha = function() { | ||
| 41 | getSeguimiento(); | ||
| 42 | }; | ||
| 43 | |||
| 44 | function getSeguimiento () { | ||
| 45 | var datos = { | ||
| 46 | actividad: $scope.actividad, | ||
| 47 | idUsuario: $scope.idUsuario, | ||
| 48 | fechaDesde: $scope.now, | ||
| 49 | fechaHasta: $scope.now | ||
| 50 | }; | ||
| 51 | |||
| 52 | focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) { |
src/js/osm-directive.js
| 1 | angular.module('focaAdminSeguimiento').directive('osm', function() { | 1 | angular.module('focaAdminSeguimiento').directive('osm', function() { |
| 2 | return { | 2 | return { |
| 3 | restrict: 'E', | 3 | restrict: 'E', |
| 4 | link: function(scope, el, attrs) { | 4 | link: function(scope, el, attrs) { |
| 5 | var contenedor = document.createElement('div'); | 5 | var contenedor = document.createElement('div'); |
| 6 | el.append(contenedor); | 6 | el.append(contenedor); |
| 7 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); | 7 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); |
| 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); | 8 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
| 9 | }, | 9 | }, |
| 10 | controller: ['$scope', '$filter', function($scope, $filter) { | 10 | controller: ['$scope', '$filter', function($scope, $filter) { |
| 11 | $scope.markers = []; | ||
| 11 | $scope.$watch('marcadores', function() { | 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 | angular.forEach($scope.marcadores, function(marcador) { | 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 | .bindPopup( | 21 | .bindPopup( |
| 15 | 'Actividad: ' + marcador.actividad + '<br/>' + | 22 | 'Actividad: ' + marcador.actividad + '<br/>' + |
| 16 | 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + | 23 | 'Fecha: ' + $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + |
| 17 | ' ' + marcador.fecha.slice(11,19) + '<br/>' + | 24 | ' ' + marcador.fecha.slice(11,19) + '<br/>' + |
| 18 | marcador.observaciones | 25 | marcador.observaciones |
| 19 | ).openPopup(); | 26 | ).openPopup() |
| 27 | ); | ||
| 20 | }); | 28 | }); |
| 21 | }); | 29 | }); |
| 22 | }], | 30 | }], |
| 23 | scope: { | 31 | scope: { |
| 24 | latitud: '=', | 32 | latitud: '=', |
| 25 | longitud: '=', | 33 | longitud: '=', |
| 26 | zoom: '=', | 34 | zoom: '=', |
| 27 | marcadores: '=' | 35 | marcadores: '=' |
| 28 | } | 36 | } |
| 29 | }; | 37 | }; |
| 30 | }); | 38 | }); |
| 31 | 39 |
src/js/service.js
| 1 | angular.module('focaAdminSeguimiento') | 1 | angular.module('focaAdminSeguimiento') |
| 2 | .service( | 2 | .service( |
| 3 | 'focaAdminSeguimientoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT | 3 | 'focaAdminSeguimientoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT |
| 4 | ) { | 4 | ) { |
| 5 | return { | 5 | return { |
| 6 | obtenerActividad: function() { | 6 | obtenerActividad: function(parametros) { |
| 7 | return $http.get(API_ENDPOINT.URL + '/seguimiento'); | 7 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); |
| 8 | } | 8 | } |
| 9 | }; | 9 | }; |
| 10 | }]); | 10 | }]); |
| 11 | 11 |
src/views/foca-admin-seguimiento.html
| 1 | <div class="foca-admin-seguimiento"> | 1 | <div class="foca-admin-seguimiento"> |
| 2 | <div class="row"> | 2 | <div class="row"> |
| 3 | <div class="offset-1 col-9"> | 3 | <div class="offset-1 col-9"> |
| 4 | <osm | 4 | <osm |
| 5 | latitud="-32.89214159952345" | 5 | latitud="-32.89214159952345" |
| 6 | longitud="-68.84572999101856" | 6 | longitud="-68.84572999101856" |
| 7 | zoom="14" | 7 | zoom="14" |
| 8 | marcadores="marcadores" | 8 | marcadores="marcadores" |
| 9 | /> | 9 | /> |
| 10 | </div> | 10 | </div> |
| 11 | <div class="col-2 pl-0"> | 11 | <div class="col-2 pl-0"> |
| 12 | <input | 12 | <input |
| 13 | type="date" | 13 | type="date" |
| 14 | ng-model="now" | 14 | ng-model="now" |
| 15 | class="btn col-12 my-1" | 15 | class="btn col-12 my-1" |
| 16 | foca-focus="true" | 16 | foca-focus="true" |
| 17 | ng-blur="fecha()" | ||
| 17 | hasta-hoy | 18 | hasta-hoy |
| 18 | /> | 19 | /> |
| 19 | <button | 20 | <button |
| 20 | type="button" | 21 | type="button" |
| 21 | ng-class="{'active': general}" | 22 | ng-class="{'active': idUsuario == 0}" |
| 22 | class="btn col-12 my-1" | 23 | class="btn col-12 my-1" |
| 23 | ng-click="general()" | 24 | ng-click="general()" |
| 24 | >General</button> | 25 | >General</button> |
| 25 | <button | 26 | <button |
| 26 | type="button" | 27 | type="button" |
| 27 | ng-class="{'active': !general}" | 28 | ng-class="{'active': idUsuario != 0}" |
| 28 | class="btn col-12 my-1" | 29 | class="btn col-12 my-1" |
| 29 | ng-click="individual()" | 30 | ng-click="individual()" |
| 30 | >Individual</button> | 31 | >Individual</button> |
| 32 | <div class="form-group"> | ||
| 33 | <input | ||
| 34 | type="text" | ||
| 35 | placeholder="Vendedor" | ||
| 36 | class="form-control" | ||
| 37 | ng-model="idUsuarioInput" | ||
| 38 | ng-show="idUsuario == -1" | ||
| 39 | ng-keypress="search($event.keyCode)" | ||
| 40 | foca-focus="idUsuario == -1" | ||
| 41 | > | ||
| 42 | </div> | ||
| 31 | <button | 43 | <button |
| 32 | type="button" | 44 | type="button" |
| 33 | class="btn col-12 my-1 boton-salir" | 45 | class="btn col-12 my-1 boton-salir" |
| 34 | ng-click="salir()" | 46 | ng-click="salir()" |
| 35 | > | 47 | > |
| 36 | Salir | 48 | Salir |
| 37 | </button> | 49 | </button> |
| 38 | </div> | 50 | </div> |
| 39 | </div> | 51 | </div> |
| 40 | </div> | 52 | </div> |
| 41 | 53 |