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
| 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 | if ($routeParams.parametro === 'nota-pedido') { | 6 | if ($routeParams.parametro === 'nota-pedido') { | 
| 7 | $scope.actividad = 'Nota de pedido'; | 7 | $scope.actividad = 'Nota de pedido'; | 
| 8 | } | 8 | } | 
| 9 | 9 | ||
| 10 | if ($routeParams.parametro === 'hoja-ruta') { | 10 | if ($routeParams.parametro === 'hoja-ruta') { | 
| 11 | $scope.actividad = 'Entrega de producto'; | 11 | $scope.actividad = 'Entrega de producto'; | 
| 12 | } | 12 | } | 
| 13 | 13 | ||
| 14 | $scope.general = true; | 14 | $scope.idUsuario = 0; | 
| 15 | |||
| 16 | console.info($scope.actividad); | ||
| 17 | $scope.marcadores = []; | 15 | $scope.marcadores = []; | 
| 18 | 16 | getSeguimiento(); | |
| 19 | focaAdminSeguimientoService.obtenerActividad().then(function(datos) { | ||
| 20 | $scope.marcadores = datos.data; | ||
| 21 | }); | ||
| 22 | 17 | ||
| 23 | $scope.general = function() { | 18 | $scope.general = function() { | 
| 24 | $scope.general = true; | 19 | $scope.idUsuario = 0; | 
| 20 | getSeguimiento(); | ||
| 25 | }; | 21 | }; | 
| 26 | 22 | ||
| 27 | $scope.individual = function() { | 23 | $scope.individual = function() { | 
| 28 | $scope.general = false; | 24 | $scope.idUsuario = -1; | 
| 29 | |||
| 30 | }; | 25 | }; | 
| 31 | 26 | ||
| 32 | $scope.salir = function() { | 27 | $scope.salir = function() { | 
| 33 | $location.path('/'); | 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) { | 
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 | <button | 12 | <button | 
| 13 | type="button" | 13 | type="button" | 
| 14 | ng-class="{'active': general}" | 14 | ng-class="{'active': idUsuario == 0}" | 
| 15 | class="btn col-12 my-1" | 15 | class="btn col-12 my-1" | 
| 16 | ng-click="general()" | 16 | ng-click="general()" | 
| 17 | >General</button> | 17 | >General</button> | 
| 18 | <button | 18 | <button | 
| 19 | type="button" | 19 | type="button" | 
| 20 | ng-class="{'active': !general}" | 20 | ng-class="{'active': idUsuario != 0}" | 
| 21 | class="btn col-12 my-1" | 21 | class="btn col-12 my-1" | 
| 22 | ng-click="individual()" | 22 | ng-click="individual()" | 
| 23 | >Individual</button> | 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 | <button | 35 | <button | 
| 25 | type="button" | 36 | type="button" | 
| 26 | class="btn col-12 my-1 boton-salir" | 37 | class="btn col-12 my-1 boton-salir" | 
| 27 | ng-click="salir()" | 38 | ng-click="salir()" | 
| 28 | > | 39 | > | 
| 29 | Salir | 40 | Salir | 
| 30 | </button> | 41 | </button> | 
| 31 | </div> | 42 | </div> | 
| 32 | </div> | 43 | </div> | 
| 33 | </div> | 44 | </div> | 
| 34 | 45 |