Commit 52fffa1bb89de77f4f13533a348e730e99ae3c8f
0 parents
Exists in
master
Primera versión estable.
Showing
13 changed files
with
325 additions
and
0 deletions
Show diff stats
.gitignore
.jshintrc
... | ... | @@ -0,0 +1,64 @@ |
1 | +{ | |
2 | + /* | |
3 | + * ENVIRONMENTS | |
4 | + * ================= | |
5 | + */ | |
6 | + | |
7 | + // Define globals exposed by modern browsers. | |
8 | + "browser": true, | |
9 | + | |
10 | + // Define globals exposed by jQuery. | |
11 | + "jquery": true, | |
12 | + | |
13 | + // Define globals exposed by Node.js. | |
14 | + "node": true, | |
15 | + | |
16 | + // Allow ES6. | |
17 | + "esversion": 6, | |
18 | + | |
19 | + /* | |
20 | + * ENFORCING OPTIONS | |
21 | + * ================= | |
22 | + */ | |
23 | + | |
24 | + // Force all variable names to use either camelCase style or UPPER_CASE | |
25 | + // with underscores. | |
26 | + "camelcase": true, | |
27 | + | |
28 | + // Prohibit use of == and != in favor of === and !==. | |
29 | + "eqeqeq": true, | |
30 | + | |
31 | + // Enforce tab width of 2 spaces. | |
32 | + "indent": 4, | |
33 | + | |
34 | + // Prohibit use of a variable before it is defined. | |
35 | + "latedef": false, | |
36 | + | |
37 | + // Enforce line length to 100 characters | |
38 | + "maxlen": 100, | |
39 | + | |
40 | + // Require capitalized names for constructor functions. | |
41 | + "newcap": true, | |
42 | + | |
43 | + // Enforce use of single quotation marks for strings. | |
44 | + "quotmark": "single", | |
45 | + | |
46 | + // Enforce placing 'use strict' at the top function scope | |
47 | + "strict": false, | |
48 | + | |
49 | + // Prohibit use of explicitly undeclared variables. | |
50 | + "undef": true, | |
51 | + | |
52 | + // Warn when variables are defined but never used. | |
53 | + "unused": true, | |
54 | + | |
55 | + // Para que funcione en angular | |
56 | + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | |
57 | + /* | |
58 | + * RELAXING OPTIONS | |
59 | + * ================= | |
60 | + */ | |
61 | + | |
62 | + // Suppress warnings about == null comparisons. | |
63 | + "eqnull": true | |
64 | +} |
README.md
gulpfile.js
... | ... | @@ -0,0 +1,86 @@ |
1 | +const templateCache = require('gulp-angular-templatecache'); | |
2 | +const clean = require('gulp-clean'); | |
3 | +const concat = require('gulp-concat'); | |
4 | +const htmlmin = require('gulp-htmlmin'); | |
5 | +const rename = require('gulp-rename'); | |
6 | +const uglify = require('gulp-uglify'); | |
7 | +const gulp = require('gulp'); | |
8 | +const pump = require('pump'); | |
9 | +const jshint = require('gulp-jshint'); | |
10 | +const replace = require('gulp-replace'); | |
11 | +const connect = require('gulp-connect'); | |
12 | + | |
13 | +var paths = { | |
14 | + srcJS: 'src/js/*.js', | |
15 | + srcViews: 'src/views/*.html', | |
16 | + tmp: 'tmp', | |
17 | + dist: 'dist/' | |
18 | +}; | |
19 | + | |
20 | +gulp.task('templates', ['clean'], function() { | |
21 | + return pump( | |
22 | + [ | |
23 | + gulp.src(paths.srcViews), | |
24 | + htmlmin(), | |
25 | + templateCache('views.js', { | |
26 | + module: 'focaAdminSeguimiento', | |
27 | + root: '' | |
28 | + }), | |
29 | + gulp.dest(paths.tmp) | |
30 | + ] | |
31 | + ); | |
32 | +}); | |
33 | + | |
34 | +gulp.task('uglify', ['templates'], function() { | |
35 | + return pump( | |
36 | + [ | |
37 | + gulp.src([ | |
38 | + paths.srcJS, | |
39 | + 'tmp/views.js' | |
40 | + ]), | |
41 | + concat('foca-admin-seguimiento.js'), | |
42 | + replace('src/views/', ''), | |
43 | + gulp.dest(paths.tmp), | |
44 | + rename('foca-admin-seguimiento.min.js'), | |
45 | + uglify(), | |
46 | + replace('"ngRoute","ui.bootstrap"', ''), | |
47 | + gulp.dest(paths.dist) | |
48 | + ] | |
49 | + ); | |
50 | +}); | |
51 | + | |
52 | +gulp.task('clean', function(){ | |
53 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
54 | + .pipe(clean()); | |
55 | +}); | |
56 | + | |
57 | +gulp.task('pre-commit', function() { | |
58 | + return pump( | |
59 | + [ | |
60 | + gulp.src(paths.srcJS), | |
61 | + jshint('.jshintrc'), | |
62 | + jshint.reporter('default'), | |
63 | + jshint.reporter('fail') | |
64 | + ] | |
65 | + ); | |
66 | + | |
67 | + gulp.start('uglify'); | |
68 | +}); | |
69 | + | |
70 | +gulp.task('webserver', function() { | |
71 | + pump [ | |
72 | + connect.server({port: 3300, host: '0.0.0.0'}) | |
73 | + ] | |
74 | +}); | |
75 | + | |
76 | +gulp.task('clean-post-install', function() { | |
77 | + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | |
78 | + 'index.html'], {read: false}) | |
79 | + .pipe(clean()); | |
80 | +}); | |
81 | + | |
82 | +gulp.task('default', ['webserver']); | |
83 | + | |
84 | +gulp.task('watch', function() { | |
85 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
86 | +}); |
index.html
... | ... | @@ -0,0 +1,38 @@ |
1 | +<html ng-app="focaAdminSeguimiento"> | |
2 | + <head> | |
3 | + <meta charset="UTF-8"/> | |
4 | + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
5 | + | |
6 | + <!--CSS--> | |
7 | + <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | |
8 | + <link href="node_modules/leaflet/dist/leaflet.css" rel="stylesheet"/> | |
9 | + <style> | |
10 | + osm>div { | |
11 | + width: 100%; | |
12 | + height: 576px; | |
13 | + } | |
14 | + </style> | |
15 | + | |
16 | + <!--VENDOR JS--> | |
17 | + <script src="node_modules/jquery/dist/jquery.min.js"></script> | |
18 | + <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | |
19 | + <script src="node_modules/angular/angular.min.js"></script> | |
20 | + <script src="node_modules/angular-route/angular-route.min.js"></script> | |
21 | + <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | |
22 | + <script src="node_modules/leaflet/dist/leaflet.js"></script> | |
23 | + | |
24 | + <!-- BUILD --> | |
25 | + <script src="src/js/app.js"></script> | |
26 | + <script src="src/js/controller.js"></script> | |
27 | + <script src="src/js/route.js"></script> | |
28 | + <script src="src/js/service.js"></script> | |
29 | + <script src="src/js/osm-directive.js"></script> | |
30 | + <!-- /BUILD --> | |
31 | + | |
32 | + <!-- CONFIG PARA DEVELOP --> | |
33 | + <script src="src/etc/develop.js"></script> | |
34 | + </head> | |
35 | + <body> | |
36 | + <div ng-view class="container-fluid"></div> | |
37 | + </body> | |
38 | +</html> |
package.json
... | ... | @@ -0,0 +1,47 @@ |
1 | +{ | |
2 | + "name": "foca-admin-seguimiento", | |
3 | + "version": "0.0.1", | |
4 | + "description": "Seguimiento de actividad", | |
5 | + "main": "index.js", | |
6 | + "scripts": { | |
7 | + "test": "echo \"Error: no test specified\" && exit 1", | |
8 | + "compile": "gulp uglify", | |
9 | + "gulp-pre-commit": "gulp pre-commit", | |
10 | + "postinstall": "npm run compile && gulp clean-post-install", | |
11 | + "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint leaflet pump" | |
12 | + }, | |
13 | + "pre-commit": [ | |
14 | + "gulp-pre-commit" | |
15 | + ], | |
16 | + "repository": { | |
17 | + "type": "git", | |
18 | + "url": "https://debo.suite.repo/modulos-npm/foca-admin-seguimiento.git" | |
19 | + }, | |
20 | + "author": "Foca Software", | |
21 | + "license": "ISC", | |
22 | + "devDependencies": { | |
23 | + "angular": "1.7.5", | |
24 | + "angular-route": "1.7.5", | |
25 | + "bootstrap": "4.1.3", | |
26 | + "font-awesome": "^4.7.0", | |
27 | + "gulp": "^3.9.1", | |
28 | + "gulp-angular-templatecache": "2.2.3", | |
29 | + "gulp-clean": "^0.4.0", | |
30 | + "gulp-concat": "^2.6.1", | |
31 | + "gulp-connect": "^5.6.1", | |
32 | + "gulp-htmlmin": "5.0.1", | |
33 | + "gulp-jshint": "2.1.0", | |
34 | + "gulp-rename": "1.4.0", | |
35 | + "gulp-replace": "1.0.0", | |
36 | + "gulp-sequence": "^1.0.0", | |
37 | + "gulp-uglify": "3.0.1", | |
38 | + "gulp-uglify-es": "^1.0.4", | |
39 | + "jasmine-core": "^3.3.0", | |
40 | + "jquery": "3.3.1", | |
41 | + "jshint": "2.9.6", | |
42 | + "leaflet": "^1.3.4" | |
43 | + "pre-commit": "^1.2.2", | |
44 | + "pump": "3.0.0", | |
45 | + "ui-bootstrap4": "3.0.5" | |
46 | + } | |
47 | +} |
src/etc/develop.js.ejemplo
src/js/app.js
src/js/controller.js
... | ... | @@ -0,0 +1,12 @@ |
1 | +angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [ | |
2 | + '$scope', 'focaAdminSeguimientoService', '$location', | |
3 | + function($scope, focaAdminSeguimientoService, $location) { | |
4 | + $scope.marcadores = []; | |
5 | + focaAdminSeguimientoService.obtenerActividad().then(function(datos) { | |
6 | + $scope.marcadores = datos.data; | |
7 | + }); | |
8 | + $scope.salir = function() { | |
9 | + $location.path('/'); | |
10 | + }; | |
11 | + } | |
12 | +]); |
src/js/osm-directive.js
... | ... | @@ -0,0 +1,30 @@ |
1 | +angular.module('focaAdminSeguimiento').directive('osm', function() { | |
2 | + return { | |
3 | + restrict: 'E', | |
4 | + link: function(scope, el, attrs) { | |
5 | + var contenedor = document.createElement('div'); | |
6 | + el.append(contenedor); | |
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); | |
9 | + }, | |
10 | + controller: function($scope) { | |
11 | + $scope.$watch('marcadores', function(valorNuevo) { | |
12 | + marcadores = $scope.marcadores; | |
13 | + mapa = $scope.map; | |
14 | + angular.forEach($scope.marcadores, function(marcador) { | |
15 | + L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) | |
16 | + .bindPopup( | |
17 | + "Actividad: " + marcador.actividad + '<br/>' + | |
18 | + 'Fecha: ' + marcador.fecha | |
19 | + ).openPopup(); | |
20 | + }); | |
21 | + }); | |
22 | + }, | |
23 | + scope: { | |
24 | + latitud: '=', | |
25 | + longitud: '=', | |
26 | + zoom: '=', | |
27 | + marcadores: '=' | |
28 | + } | |
29 | + }; | |
30 | +}); |
src/js/route.js
src/js/service.js
... | ... | @@ -0,0 +1,10 @@ |
1 | +angular.module('focaAdminSeguimiento') | |
2 | + .service( | |
3 | + 'focaAdminSeguimientoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT | |
4 | + ) { | |
5 | + return { | |
6 | + obtenerActividad: function() { | |
7 | + return $http.get(API_ENDPOINT.URL + '/seguimiento'); | |
8 | + } | |
9 | + }; | |
10 | + }]); |
src/views/foca-admin-seguimiento.html
... | ... | @@ -0,0 +1,15 @@ |
1 | +<div class="foca-admin-seguimiento"> | |
2 | + <div class="row"> | |
3 | + <div class="offset-1 col-10"> | |
4 | + <osm | |
5 | + latitud="-32.89214159952345" | |
6 | + longitud="-68.84572999101856" | |
7 | + zoom="14" | |
8 | + marcadores="marcadores" | |
9 | + /> | |
10 | + </div> | |
11 | + <div class="col-1"> | |
12 | + <button type="button" class="btn btn-default" ng-click="salir()">Salir</button> | |
13 | + </div> | |
14 | + </div> | |
15 | +</div> |