diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76a3502 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/dist +package-lock\.json +/src/etc/develop.js + +tmp/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..d8cbb07 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": false, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..21677f0 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +Admin seguimiento +================= diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..05e4802 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,86 @@ +const templateCache = require('gulp-angular-templatecache'); +const clean = require('gulp-clean'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); +const connect = require('gulp-connect'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', ['clean'], function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaAdminSeguimiento', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-admin-seguimiento.js'), + replace('src/views/', ''), + gulp.dest(paths.tmp), + rename('foca-admin-seguimiento.min.js'), + uglify(), + replace('"ngRoute","ui.bootstrap"', ''), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function(){ + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('pre-commit', function() { + return pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); + + gulp.start('uglify'); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3300, host: '0.0.0.0'}) + ] +}); + +gulp.task('clean-post-install', function() { + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', + 'index.html'], {read: false}) + .pipe(clean()); +}); + +gulp.task('default', ['webserver']); + +gulp.task('watch', function() { + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..688886b --- /dev/null +++ b/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/package.json b/package.json new file mode 100644 index 0000000..40ea227 --- /dev/null +++ b/package.json @@ -0,0 +1,47 @@ +{ + "name": "foca-admin-seguimiento", + "version": "0.0.1", + "description": "Seguimiento de actividad", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify", + "gulp-pre-commit": "gulp pre-commit", + "postinstall": "npm run compile && gulp clean-post-install", + "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" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "https://debo.suite.repo/modulos-npm/foca-admin-seguimiento.git" + }, + "author": "Foca Software", + "license": "ISC", + "devDependencies": { + "angular": "1.7.5", + "angular-route": "1.7.5", + "bootstrap": "4.1.3", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "2.2.3", + "gulp-clean": "^0.4.0", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "5.0.1", + "gulp-jshint": "2.1.0", + "gulp-rename": "1.4.0", + "gulp-replace": "1.0.0", + "gulp-sequence": "^1.0.0", + "gulp-uglify": "3.0.1", + "gulp-uglify-es": "^1.0.4", + "jasmine-core": "^3.3.0", + "jquery": "3.3.1", + "jshint": "2.9.6", + "leaflet": "^1.3.4" + "pre-commit": "^1.2.2", + "pump": "3.0.0", + "ui-bootstrap4": "3.0.5" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..349dc58 --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaAdminSeguimiento') + .constant("API_ENDPOINT", { + 'URL': 'http://127.0.0.1:9000' + }); diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..da5db76 --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,4 @@ +angular.module('focaAdminSeguimiento', [ + 'ngRoute', + 'ui.bootstrap' +]); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..0ce7a85 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,12 @@ +angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [ + '$scope', 'focaAdminSeguimientoService', '$location', + function($scope, focaAdminSeguimientoService, $location) { + $scope.marcadores = []; + focaAdminSeguimientoService.obtenerActividad().then(function(datos) { + $scope.marcadores = datos.data; + }); + $scope.salir = function() { + $location.path('/'); + }; + } +]); diff --git a/src/js/osm-directive.js b/src/js/osm-directive.js new file mode 100644 index 0000000..a06926d --- /dev/null +++ b/src/js/osm-directive.js @@ -0,0 +1,30 @@ +angular.module('focaAdminSeguimiento').directive('osm', function() { + return { + restrict: 'E', + link: function(scope, el, attrs) { + var contenedor = document.createElement('div'); + el.append(contenedor); + scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); + }, + controller: function($scope) { + $scope.$watch('marcadores', function(valorNuevo) { + marcadores = $scope.marcadores; + mapa = $scope.map; + angular.forEach($scope.marcadores, function(marcador) { + L.marker([marcador.latitud, marcador.longitud]).addTo($scope.map) + .bindPopup( + "Actividad: " + marcador.actividad + '
' + + 'Fecha: ' + marcador.fecha + ).openPopup(); + }); + }); + }, + scope: { + latitud: '=', + longitud: '=', + zoom: '=', + marcadores: '=' + } + }; +}); diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..cccd2a2 --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,7 @@ +angular.module('focaAdminSeguimiento') + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/admin-seguimiento', { + controller: 'focaAdminSeguimientoController', + templateUrl: 'src/views/foca-admin-seguimiento.html' + }); + }]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..a95537b --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,10 @@ +angular.module('focaAdminSeguimiento') + .service( + 'focaAdminSeguimientoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT + ) { + return { + obtenerActividad: function() { + return $http.get(API_ENDPOINT.URL + '/seguimiento'); + } + }; + }]); diff --git a/src/views/foca-admin-seguimiento.html b/src/views/foca-admin-seguimiento.html new file mode 100644 index 0000000..7df5a3c --- /dev/null +++ b/src/views/foca-admin-seguimiento.html @@ -0,0 +1,15 @@ +
+
+
+ +
+
+ +
+
+