Commit c23e5fd7fb9ac7766222e08e3f68c4f3fbaef8f1
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Va componente See merge request !1
Showing
9 changed files
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": true, | |
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 | +} |
gulpfile.js
... | ... | @@ -0,0 +1,95 @@ |
1 | +const clean = require('gulp-clean'); | |
2 | +const concat = require('gulp-concat'); | |
3 | +const connect = require('gulp-connect'); | |
4 | +const gulp = require('gulp'); | |
5 | +const htmlmin = require('gulp-htmlmin'); | |
6 | +const jshint = require('gulp-jshint'); | |
7 | +const pump = require('pump'); | |
8 | +const rename = require('gulp-rename'); | |
9 | +const replace = require('gulp-replace'); | |
10 | +const templateCache = require('gulp-angular-templatecache'); | |
11 | +const uglify = require('gulp-uglify-es').default; | |
12 | +const sass = require('gulp-sass'); | |
13 | + | |
14 | +var paths = { | |
15 | + dist: 'dist/', | |
16 | + srcJS: 'src/js/*.js', | |
17 | + srcViews: 'src/views/*.html', | |
18 | + tmp: 'tmp' | |
19 | +}; | |
20 | + | |
21 | +gulp.task('templates', function() { | |
22 | + return pump( | |
23 | + [ | |
24 | + gulp.src(paths.srcViews), | |
25 | + htmlmin(), | |
26 | + templateCache('views.js', { | |
27 | + module: 'focaNombreEmpresa', | |
28 | + root: '' | |
29 | + }), | |
30 | + gulp.dest(paths.tmp) | |
31 | + ] | |
32 | + ); | |
33 | +}); | |
34 | + | |
35 | +gulp.task('sass', function() { | |
36 | + return gulp.src('src/sass/*.scss') | |
37 | + .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) | |
38 | + .pipe(gulp.dest('css')); | |
39 | +}); | |
40 | + | |
41 | +gulp.task('uglify', ['templates'], function() { | |
42 | + return pump( | |
43 | + [ | |
44 | + gulp.src([ | |
45 | + paths.srcJS, | |
46 | + 'tmp/views.js' | |
47 | + ]), | |
48 | + concat('foca-nombre-empresa.js'), | |
49 | + replace('src/views/', ''), | |
50 | + replace("'ngSanitize', 'onScreenKeyboard'", ''), | |
51 | + gulp.dest(paths.tmp), | |
52 | + rename('foca-nombre-empresa.min.js'), | |
53 | + uglify(), | |
54 | + gulp.dest(paths.dist) | |
55 | + ] | |
56 | + ); | |
57 | +}); | |
58 | + | |
59 | +gulp.task('clean', function() { | |
60 | + return gulp.src(['tmp', 'dist'], {read: false}) | |
61 | + .pipe(clean()); | |
62 | +}); | |
63 | + | |
64 | +gulp.task('pre-commit', function() { | |
65 | + pump( | |
66 | + [ | |
67 | + gulp.src(paths.srcJS), | |
68 | + jshint('.jshintrc'), | |
69 | + jshint.reporter('default'), | |
70 | + jshint.reporter('fail') | |
71 | + ] | |
72 | + ); | |
73 | +}); | |
74 | + | |
75 | +gulp.task('webserver', function() { | |
76 | + pump [ | |
77 | + connect.server( | |
78 | + { | |
79 | + port: 3000 | |
80 | + } | |
81 | + ) | |
82 | + ] | |
83 | +}); | |
84 | + | |
85 | +gulp.task('clean-post-install', function() { | |
86 | + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | |
87 | + 'index.html'], {read: false}) | |
88 | + .pipe(clean()); | |
89 | +}); | |
90 | + | |
91 | +gulp.task('default', ['webserver']); | |
92 | + | |
93 | +gulp.task('watch', function() { | |
94 | + gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
95 | +}); |
index.html
... | ... | @@ -0,0 +1,25 @@ |
1 | +<html ng-app="focaModalEmpresa"> | |
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/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | |
9 | + | |
10 | + <!--VENDOR JS--> | |
11 | + <script src="node_modules/jquery/dist/jquery.min.js"></script> | |
12 | + <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | |
13 | + <script src="node_modules/angular/angular.min.js"></script> | |
14 | + <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | |
15 | + | |
16 | + <!-- BUILD --> | |
17 | + <script src="src/js/app.js"></script> | |
18 | + <script src="src/js/controller.js"></script> | |
19 | + <!-- /BUILD --> | |
20 | + | |
21 | + </head> | |
22 | + <body> | |
23 | + <foca-nombre-empresa> | |
24 | + </body> | |
25 | +</html> |
package.json
... | ... | @@ -0,0 +1,52 @@ |
1 | +{ | |
2 | + "name": "foca-nombre-empresa", | |
3 | + "version": "0.0.1", | |
4 | + "description": "Componente de nombre de la empresa", | |
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 angular bootstrap font-awesome gulp gulp-angular-templatecache gulp-clean gulp-concat gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify-es jasmine-core jquery jshint pre-commit pump && npm install angular-sanitize" | |
12 | + }, | |
13 | + "author": "Foca Software", | |
14 | + "license": "ISC", | |
15 | + "peerDependencies": { | |
16 | + "angular": "^1.7.x", | |
17 | + "bootstrap": "^4.1.x", | |
18 | + "jquery": "^3.3.x", | |
19 | + "font-awesome": "^4.7.x", | |
20 | + "gulp": "^3.9.x", | |
21 | + "gulp-concat": "2.6.x", | |
22 | + "gulp-jshint": "^2.1.x", | |
23 | + "gulp-rename": "^1.4.x", | |
24 | + "gulp-replace": "^1.0.x", | |
25 | + "gulp-uglify-es": "^1.0.x", | |
26 | + "jshint": "^2.9.x", | |
27 | + "pump": "^3.0.x" | |
28 | + }, | |
29 | + "devDependencies": { | |
30 | + "angular": "1.7.5", | |
31 | + "angular-route": "^1.7.5", | |
32 | + "angular-sanitize": "1.7.5", | |
33 | + "bootstrap": "4.1.3", | |
34 | + "font-awesome": "4.7.0", | |
35 | + "gulp": "3.9.1", | |
36 | + "gulp-angular-templatecache": "2.2.5", | |
37 | + "gulp-clean": "0.4.0", | |
38 | + "gulp-concat": "2.6.1", | |
39 | + "gulp-connect": "5.6.1", | |
40 | + "gulp-htmlmin": "5.0.1", | |
41 | + "gulp-jshint": "2.1.0", | |
42 | + "gulp-rename": "1.4.0", | |
43 | + "gulp-replace": "1.0.0", | |
44 | + "gulp-sass": "4.0.2", | |
45 | + "gulp-uglify-es": "1.0.4", | |
46 | + "jasmine-core": "3.3.0", | |
47 | + "jquery": "3.3.1", | |
48 | + "jshint": "2.9.6", | |
49 | + "pre-commit": "1.2.2", | |
50 | + "pump": "3.0.0" | |
51 | + } | |
52 | +} |
src/js/app.js
src/js/controller.js
... | ... | @@ -0,0 +1,19 @@ |
1 | +angular.module('focaNombreEmpresa') | |
2 | + .controller('focaNombreEmpresaController', [ | |
3 | + '$scope', | |
4 | + 'focaNombreEmpresaService', | |
5 | + function($scope, focaNombreEmpresaService) { | |
6 | + $scope.nombre = ''; | |
7 | + $scope.direccion = ''; | |
8 | + | |
9 | + var init = function() { | |
10 | + //ID EMPRESA HARDCODEADO | |
11 | + focaNombreEmpresaService.getEmpresa(1).then(function(res) { | |
12 | + $scope.nombre = res.data.NOM; | |
13 | + $scope.direccion = res.data.DIR; | |
14 | + }); | |
15 | + }; | |
16 | + | |
17 | + init(); | |
18 | + }]); | |
19 | + | |
0 | 20 | \ No newline at end of file |
src/js/service.js
... | ... | @@ -0,0 +1,13 @@ |
1 | +angular.module('focaNombreEmpresa') | |
2 | + .service('focaNombreEmpresaService', [ | |
3 | + '$http', | |
4 | + 'API_ENDPOINT', | |
5 | + function($http, API_ENDPOINT) { | |
6 | + return { | |
7 | + getEmpresa: function(id) { | |
8 | + return $http.get(API_ENDPOINT.URL + '/empresa/' + id); | |
9 | + } | |
10 | + }; | |
11 | + } | |
12 | + ]); | |
13 | + | |
0 | 14 | \ No newline at end of file |
src/views/nombre-empresa.html