Commit f844f12876a9270996729afeb7b2bea6c1f50277
Exists in
master
Merge branch 'master' into 'master'
Master See merge request !1
Showing
10 changed files
Show diff stats
.gitignore
| File was created | 1 | /node_modules | |
| 2 | /dist | ||
| 3 | /tmp | ||
| 4 | package-lock\.json | ||
| 5 | src/etc/develop.js | ||
| 6 |
.jshintrc
| File was created | 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 | } | ||
| 65 |
gulpfile.js
| File was created | 1 | const templateCache = require('gulp-angular-templatecache'); | |
| 2 | const concat = require('gulp-concat'); | ||
| 3 | const htmlmin = require('gulp-htmlmin'); | ||
| 4 | const rename = require('gulp-rename'); | ||
| 5 | const uglify = require('gulp-uglify-es').default; | ||
| 6 | const gulp = require('gulp'); | ||
| 7 | const pump = require('pump'); | ||
| 8 | const jshint = require('gulp-jshint'); | ||
| 9 | const replace = require('gulp-replace'); | ||
| 10 | const connect = require('gulp-connect'); | ||
| 11 | const clean = require('gulp-clean'); | ||
| 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', function() { | ||
| 21 | return pump( | ||
| 22 | [ | ||
| 23 | gulp.src(paths.srcViews), | ||
| 24 | replace('views/', ''), | ||
| 25 | htmlmin(), | ||
| 26 | templateCache('views.js', { | ||
| 27 | module: 'focaConfigurarTerminal', | ||
| 28 | root: '' | ||
| 29 | }), | ||
| 30 | gulp.dest(paths.tmp) | ||
| 31 | ] | ||
| 32 | ); | ||
| 33 | }); | ||
| 34 | |||
| 35 | gulp.task('uglify', ['templates'], function() { | ||
| 36 | return pump( | ||
| 37 | [ | ||
| 38 | gulp.src([ | ||
| 39 | paths.srcJS, | ||
| 40 | 'tmp/views.js' | ||
| 41 | ]), | ||
| 42 | concat('foca-configurar-terminal.js'), | ||
| 43 | replace("['ngRoute', 'focaBotoneraLateral']", '[]'), | ||
| 44 | replace("src/views/", ''), | ||
| 45 | gulp.dest(paths.tmp), | ||
| 46 | rename('foca-configurar-terminal.min.js'), | ||
| 47 | uglify(), | ||
| 48 | gulp.dest(paths.dist) | ||
| 49 | ] | ||
| 50 | ); | ||
| 51 | }); | ||
| 52 | |||
| 53 | gulp.task('clean', function() { | ||
| 54 | return gulp.src(['tmp', 'dist'], {read: false}) | ||
| 55 | .pipe(clean()); | ||
| 56 | }); | ||
| 57 | |||
| 58 | gulp.task('pre-commit', function() { | ||
| 59 | pump( | ||
| 60 | [ | ||
| 61 | gulp.src(paths.srcJS), | ||
| 62 | jshint('.jshintrc'), | ||
| 63 | jshint.reporter('default'), | ||
| 64 | jshint.reporter('fail') | ||
| 65 | ] | ||
| 66 | ); | ||
| 67 | |||
| 68 | gulp.start('uglify'); | ||
| 69 | }); | ||
| 70 | |||
| 71 | gulp.task('clean-post-install', function() { | ||
| 72 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | ||
| 73 | 'index.html'], {read: false}) | ||
| 74 | .pipe(clean()); | ||
| 75 | }); | ||
| 76 | |||
| 77 | gulp.task('compile', ['templates', 'uglify']); | ||
| 78 | |||
| 79 | gulp.task('watch', function() { | ||
| 80 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | ||
| 81 | }); | ||
| 82 | |||
| 83 | gulp.task('webserver', function() { | ||
| 84 | pump [ | ||
| 85 | connect.server({port: 3000}) | ||
| 86 | ] | ||
| 87 | }); | ||
| 88 | |||
| 89 | gulp.task('default', ['webserver']); | ||
| 90 |
package.json
| File was created | 1 | { | |
| 2 | "name": "foca-configurar-terminal", | ||
| 3 | "version": "0.0.1", | ||
| 4 | "description": "foca-configurar-terminal", | ||
| 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 angular bootstrap font-awesome jquery gulp gulp-connect jasmine-core pre-commit gulp-angular-templatecache gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jshint pump" | ||
| 12 | }, | ||
| 13 | "repository": { | ||
| 14 | "type": "git", | ||
| 15 | "url": "git@git.focasoftware.com:npm/foca-configurar-terminal.git" | ||
| 16 | }, | ||
| 17 | "author": "", | ||
| 18 | "license": "ISC", | ||
| 19 | "devDependencies": { | ||
| 20 | "angular": "^1.7.5", | ||
| 21 | "angular-route": "^1.7.5", | ||
| 22 | "bootstrap": "^4.2.1", | ||
| 23 | "gulp": "^3.9.1", | ||
| 24 | "gulp-angular-templatecache": "^2.2.6", | ||
| 25 | "gulp-clean": "^0.4.0", | ||
| 26 | "gulp-connect": "^5.7.0", | ||
| 27 | "gulp-htmlmin": "^5.0.1", | ||
| 28 | "gulp-jshint": "^2.1.0", | ||
| 29 | "gulp-rename": "^1.4.0", | ||
| 30 | "gulp-replace": "^1.0.0", | ||
| 31 | "gulp-uglify": "^3.0.1", | ||
| 32 | "gulp-uglify-es": "^1.0.4", | ||
| 33 | "jasmine-core": "^3.3.0", | ||
| 34 | "jquery": "^3.3.1", | ||
| 35 | "jshint": "^2.9.7", | ||
| 36 | "pre-commit": "^1.2.2", | ||
| 37 | "pump": "^3.0.0" | ||
| 38 | } | ||
| 39 | } | ||
| 40 |
src/etc/develop.js.ejemplo
| File was created | 1 | angular.module('focaConfigurarTerminal') | |
| 2 | .constant("API_ENDPOINT", { | ||
| 3 | 'URL': '//127.0.0.1:9000' | ||
| 4 | }); | ||
| 5 |
src/js/app.js
| File was created | 1 | angular.module('focaConfigurarTerminal', [ | |
| 2 | 'ngRoute', | ||
| 3 | 'focaBotoneraLateral' | ||
| 4 | ]); | ||
| 5 |
src/js/controller.js
| File was created | 1 | angular.module('focaConfigurarTerminal') | |
| 2 | .controller('focaConfigurarTerminalController', [ | ||
| 3 | '$scope', | ||
| 4 | '$timeout', | ||
| 5 | '$location', | ||
| 6 | 'focaConfigurarTerminalService', | ||
| 7 | 'focaBotoneraLateralService', | ||
| 8 | function( | ||
| 9 | $scope, | ||
| 10 | $timeout, | ||
| 11 | $location, | ||
| 12 | focaConfigurarTerminalService, | ||
| 13 | focaBotoneraLateralService) { | ||
| 14 | $scope.now = new Date(); | ||
| 15 | $scope.focused = 1; | ||
| 16 | $scope.terminal = { | ||
| 17 | variable: 'terminalId' | ||
| 18 | }; | ||
| 19 | |||
| 20 | $timeout(function() { | ||
| 21 | focaBotoneraLateralService.showSalir(true); | ||
| 22 | focaBotoneraLateralService.showPausar(false); | ||
| 23 | focaBotoneraLateralService.showCancelar(false); | ||
| 24 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | ||
| 25 | }); | ||
| 26 | |||
| 27 | $scope.guardar = function() { | ||
| 28 | focaConfigurarTerminalService | ||
| 29 | .configTerminal($scope.terminal) | ||
| 30 | .then(function() { | ||
| 31 | $location.path('/'); | ||
| 32 | }); | ||
| 33 | }; | ||
| 34 | |||
| 35 | $scope.next = function(key) { | ||
| 36 | if(key === 13) $scope.focused ++; | ||
| 37 | }; | ||
| 38 | } | ||
| 39 | ]); | ||
| 40 |
src/js/route.js
| File was created | 1 | angular.module('focaConfigurarTerminal') | |
| 2 | .config([ | ||
| 3 | '$routeProvider', | ||
| 4 | function($routeProvider) { | ||
| 5 | $routeProvider.when('/terminal/config', { | ||
| 6 | controller: 'focaConfigurarTerminalController', | ||
| 7 | templateUrl: 'src/views/foca-configurar-terminal.html' | ||
| 8 | }); | ||
| 9 | } | ||
| 10 | ]); | ||
| 11 |
src/js/service.js
| File was created | 1 | angular.module('focaConfigurarTerminal') | |
| 2 | .factory('focaConfigurarTerminalService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | ||
| 3 | return { | ||
| 4 | configTerminal: function(terminal) { | ||
| 5 | return $http.post(API_ENDPOINT.URL + '/config/terminal', terminal); | ||
| 6 | } | ||
| 7 | }; | ||
| 8 | }]); | ||
| 9 |
src/views/foca-configurar-terminal.html
| File was created | 1 | <div class="row"> | |
| 2 | <foca-cabecera-facturador | ||
| 3 | titulo="'Configurar terminal'" | ||
| 4 | fecha="now" | ||
| 5 | class="mb-0 col-12" | ||
| 6 | ></foca-cabecera-facturador> | ||
| 7 | </div> | ||
| 8 | <div class="row"> | ||
| 9 | <form name="formTerminal" class="col-md-12"> | ||
| 10 | <div class="form-group row"> | ||
| 11 | <label class="offset-sm-1 col-sm-2 col-form-label">Terminal</label> | ||
| 12 | <div class="col-sm-4"> | ||
| 13 | <input | ||
| 14 | class="form-control" | ||
| 15 | type="text" | ||
| 16 | teclado-virtual | ||
| 17 | ng-model="terminal.terminalKey" | ||
| 18 | ng-required="true" | ||
| 19 | ng-keypress="next($event.keyCode)" | ||
| 20 | foca-focus="focused == 1" | ||
| 21 | ng-focus="focused = 1" | ||
| 22 | /> | ||
| 23 | </div> | ||
| 24 | </div> | ||
| 25 | <div class="form-group row"> | ||
| 26 | <label class="offset-sm-1 col-sm-2 col-form-label">Valor</label> | ||
| 27 | <div class="col-sm-4"> | ||
| 28 | <input | ||
| 29 | class="form-control" | ||
| 30 | type="number" | ||
| 31 | teclado-virtual | ||
| 32 | ng-model="terminal.valor" | ||
| 33 | ng-required="true" | ||
| 34 | ng-keypress="next($event.keyCode)" | ||
| 35 | foca-focus="focused == 2" | ||
| 36 | ng-focus="focused = 2" | ||
| 37 | /> | ||
| 38 | </div> | ||
| 39 | </div> | ||
| 40 | </form> | ||
| 41 | </div> | ||
| 42 |