From edda17d1a5d32bd4d22f841982694cae70b7f6bb Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Tue, 10 Aug 2021 16:18:54 -0600 Subject: [PATCH 1/7] Add XLSX export as Excel --- package-lock.json | 281 ++++++++++++++++++ package.json | 3 + .../dashboard-admin.component.html | 1 + .../dashboard-admin.component.ts | 47 +++ 4 files changed, 332 insertions(+) diff --git a/package-lock.json b/package-lock.json index 82ef242..d63d325 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "angularx-social-login": "^4.0.1", "bootstrap": "4.6.0", "dayjs": "1.10.5", + "file-saver": "^2.0.5", "jquery": "^3.6.0", "ngx-infinite-scroll": "10.0.1", "ngx-webstorage": "8.0.0", @@ -36,6 +37,7 @@ "swiper": "^6.7.5", "tslib": "2.3.0", "webstomp-client": "1.2.6", + "xlsx": "^0.17.0", "zone.js": "0.11.4" }, "devDependencies": { @@ -46,6 +48,7 @@ "@angular/compiler-cli": "12.0.5", "@angular/service-worker": "12.0.5", "@types/bootstrap": "^5.0.17", + "@types/file-saver": "^2.0.3", "@types/jest": "26.0.23", "@types/jquery": "^3.5.6", "@types/node": "15.12.2", @@ -4243,6 +4246,12 @@ "integrity": "sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==", "dev": true }, + "node_modules/@types/file-saver": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.3.tgz", + "integrity": "sha512-MBIou8pd/41jkff7s97B47bc9+p0BszqqDJsO51yDm49uUxeKzrfuNl5fSLC6BpLEWKA8zlwyqALVmXrFwoBHQ==", + "dev": true + }, "node_modules/@types/form-data": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz", @@ -5042,6 +5051,21 @@ "node": ">=8.9" } }, + "node_modules/adler-32": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", + "integrity": "sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=", + "dependencies": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + }, + "bin": { + "adler32": "bin/adler32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/after": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", @@ -6665,6 +6689,19 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, + "node_modules/cfb": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.0.tgz", + "integrity": "sha512-sXMvHsKCICVR3Naq+J556K+ExBo9n50iKl6LGarlnvuA2035uMlGA/qVrc0wQtow5P1vJEw9UyrKLCbtIKz+TQ==", + "dependencies": { + "adler-32": "~1.2.0", + "crc-32": "~1.2.0", + "printj": "~1.1.2" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -7058,6 +7095,26 @@ "node": ">=0.10.0" } }, + "node_modules/codepage": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.14.0.tgz", + "integrity": "sha1-jL4lSBMjVZ19MHVxsP/5HnodL5k=", + "dependencies": { + "commander": "~2.14.1", + "exit-on-epipe": "~1.0.1" + }, + "bin": { + "codepage": "bin/codepage.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/codepage/node_modules/commander": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz", + "integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==" + }, "node_modules/collect-v8-coverage": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", @@ -7668,6 +7725,21 @@ "node": ">=10" } }, + "node_modules/crc-32": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.0.tgz", + "integrity": "sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==", + "dependencies": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + }, + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -10062,6 +10134,14 @@ "node": ">= 0.8.0" } }, + "node_modules/exit-on-epipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", + "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -10555,6 +10635,11 @@ "integrity": "sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q==", "dev": true }, + "node_modules/fflate": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.3.11.tgz", + "integrity": "sha512-Rr5QlUeGN1mbOHlaqcSYMKVpPbgLy0AWT/W0EHxA6NGI12yO1jpoui2zBBvU2G824ltM6Ut8BFgfHSBGfkmS0A==" + }, "node_modules/figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -10582,6 +10667,11 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -10829,6 +10919,14 @@ "node": ">= 0.6" } }, + "node_modules/frac": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -21062,6 +21160,17 @@ "node": ">=8" } }, + "node_modules/printj": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", + "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==", + "bin": { + "printj": "bin/printj.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/proc-log": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-1.0.0.tgz", @@ -23305,6 +23414,17 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "node_modules/ssf": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "dependencies": { + "frac": "~1.1.2" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", @@ -26832,6 +26952,22 @@ "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==", "dev": true }, + "node_modules/wmf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/word": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -26925,6 +27061,34 @@ } } }, + "node_modules/xlsx": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.0.tgz", + "integrity": "sha512-bZ36FSACiAyjoldey1+7it50PMlDp1pcAJrZKcVZHzKd8BC/z6TQ/QAN8onuqcepifqSznR6uKnjPhaGt6ig9A==", + "dependencies": { + "adler-32": "~1.2.0", + "cfb": "^1.1.4", + "codepage": "~1.14.0", + "commander": "~2.17.1", + "crc-32": "~1.2.0", + "exit-on-epipe": "~1.0.1", + "fflate": "^0.3.8", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "bin": { + "xlsx": "bin/xlsx.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/xlsx/node_modules/commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" + }, "node_modules/xml": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", @@ -30397,6 +30561,12 @@ "integrity": "sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==", "dev": true }, + "@types/file-saver": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.3.tgz", + "integrity": "sha512-MBIou8pd/41jkff7s97B47bc9+p0BszqqDJsO51yDm49uUxeKzrfuNl5fSLC6BpLEWKA8zlwyqALVmXrFwoBHQ==", + "dev": true + }, "@types/form-data": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz", @@ -31023,6 +31193,15 @@ "regex-parser": "^2.2.11" } }, + "adler-32": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", + "integrity": "sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=", + "requires": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + } + }, "after": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", @@ -32299,6 +32478,16 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, + "cfb": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.0.tgz", + "integrity": "sha512-sXMvHsKCICVR3Naq+J556K+ExBo9n50iKl6LGarlnvuA2035uMlGA/qVrc0wQtow5P1vJEw9UyrKLCbtIKz+TQ==", + "requires": { + "adler-32": "~1.2.0", + "crc-32": "~1.2.0", + "printj": "~1.1.2" + } + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -32609,6 +32798,22 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, + "codepage": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.14.0.tgz", + "integrity": "sha1-jL4lSBMjVZ19MHVxsP/5HnodL5k=", + "requires": { + "commander": "~2.14.1", + "exit-on-epipe": "~1.0.1" + }, + "dependencies": { + "commander": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz", + "integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==" + } + } + }, "collect-v8-coverage": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", @@ -33113,6 +33318,15 @@ "yaml": "^1.10.0" } }, + "crc-32": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.0.tgz", + "integrity": "sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==", + "requires": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + } + }, "create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -34906,6 +35120,11 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "exit-on-epipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", + "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" + }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -35326,6 +35545,11 @@ "integrity": "sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q==", "dev": true }, + "fflate": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.3.11.tgz", + "integrity": "sha512-Rr5QlUeGN1mbOHlaqcSYMKVpPbgLy0AWT/W0EHxA6NGI12yO1jpoui2zBBvU2G824ltM6Ut8BFgfHSBGfkmS0A==" + }, "figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -35344,6 +35568,11 @@ "flat-cache": "^3.0.4" } }, + "file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -35539,6 +35768,11 @@ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", "dev": true }, + "frac": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==" + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -43266,6 +43500,11 @@ } } }, + "printj": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", + "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" + }, "proc-log": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-1.0.0.tgz", @@ -45077,6 +45316,14 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "ssf": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "requires": { + "frac": "~1.1.2" + } + }, "sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", @@ -47792,6 +48039,16 @@ } } }, + "wmf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==" + }, + "word": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==" + }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -47854,6 +48111,30 @@ "integrity": "sha512-2c6faOUH/nhoQN6abwMloF7Iyl0ZS2E9HGtsiLrWn0zOOMWlhtDmdf/uihDt6jnuCxgtwGBNy6Onsoy2s2O2Ow==", "dev": true }, + "xlsx": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.0.tgz", + "integrity": "sha512-bZ36FSACiAyjoldey1+7it50PMlDp1pcAJrZKcVZHzKd8BC/z6TQ/QAN8onuqcepifqSznR6uKnjPhaGt6ig9A==", + "requires": { + "adler-32": "~1.2.0", + "cfb": "^1.1.4", + "codepage": "~1.14.0", + "commander": "~2.17.1", + "crc-32": "~1.2.0", + "exit-on-epipe": "~1.0.1", + "fflate": "^0.3.8", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "dependencies": { + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" + } + } + }, "xml": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", diff --git a/package.json b/package.json index 2cceb89..9ff8336 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "angularx-social-login": "^4.0.1", "bootstrap": "4.6.0", "dayjs": "1.10.5", + "file-saver": "^2.0.5", "jquery": "^3.6.0", "ngx-infinite-scroll": "10.0.1", "ngx-webstorage": "8.0.0", @@ -93,6 +94,7 @@ "swiper": "^6.7.5", "tslib": "2.3.0", "webstomp-client": "1.2.6", + "xlsx": "^0.17.0", "zone.js": "0.11.4" }, "devDependencies": { @@ -103,6 +105,7 @@ "@angular/compiler-cli": "12.0.5", "@angular/service-worker": "12.0.5", "@types/bootstrap": "^5.0.17", + "@types/file-saver": "^2.0.3", "@types/jest": "26.0.23", "@types/jquery": "^3.5.6", "@types/node": "15.12.2", diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html index c452af6..b1ed5e0 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html @@ -1 +1,2 @@

dashboard-admin works!

+ diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts index 74c742e..dd2de7a 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts @@ -1,4 +1,6 @@ import { Component, OnInit } from '@angular/core'; +import * as FileSaver from 'file-saver'; +import * as XLSX from 'xlsx'; @Component({ selector: 'jhi-dashboard-admin', @@ -8,5 +10,50 @@ import { Component, OnInit } from '@angular/core'; export class DashboardAdminComponent implements OnInit { constructor() {} + EXCEL_TYPE: string = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'; + EXCEL_EXTENSION: string = '.xlsx'; + ngOnInit(): void {} + + exportAsExcelFile = (sheetNames: string[], arrayOfData: any[], excelFileName: any) => { + const workbook = XLSX.utils.book_new(); + + arrayOfData.forEach((data, index) => { + let sheetName = sheetNames[index]; + let worksheet = XLSX.utils.json_to_sheet([data]); + XLSX.utils.book_append_sheet(workbook, worksheet, sheetName); + }); + + const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); + this.saveAsExcelFile(excelBuffer, excelFileName); + }; + + saveAsExcelFile = (buffer: any, fileName: any) => { + const data = new Blob([buffer], { type: this.EXCEL_TYPE }); + FileSaver.saveAs( + data, + fileName + + '_' + + new Date().toLocaleDateString().substr(0, 10).split('/').join('-') + + '_' + + Math.random().toString().substring(2) + + this.EXCEL_EXTENSION + ); + }; + + exportReportesGeneralesAdministrador(): void { + /* + Cantidad de usuarios activos + Cantidad de usuarios bloqueados + Cantidad de encuestas publicadas por categoría + Cantidad de encuestas finalizadas por categoría + Cantidad de encuestas publicadas por mes y año + */ + + const _sheets = ['reportes generales']; + const _reporteUsuarios = { usuarios_activos: 100, usuarios_bloqueados: 50 }; + + const _excelFinalData = [_reporteUsuarios]; + this.exportAsExcelFile(_sheets, _excelFinalData, 'reporte_general'); + } } From 6267ff50715aa76d7379b97466f65f89d5afaae6 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Tue, 10 Aug 2021 18:07:25 -0600 Subject: [PATCH 2/7] Add jsPDF export as PDF --- package-lock.json | 289 +++++++++++++++++- package.json | 1 + .../dashboard-admin.component.html | 3 +- .../dashboard-admin.component.ts | 58 ++-- .../dashboard/export/export_common.ts | 10 + .../entities/dashboard/export/export_excel.ts | 26 ++ .../entities/dashboard/export/export_pdf.ts | 35 +++ 7 files changed, 380 insertions(+), 42 deletions(-) create mode 100644 src/main/webapp/app/entities/dashboard/export/export_common.ts create mode 100644 src/main/webapp/app/entities/dashboard/export/export_excel.ts create mode 100644 src/main/webapp/app/entities/dashboard/export/export_pdf.ts diff --git a/package-lock.json b/package-lock.json index d63d325..ca1294a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "dayjs": "1.10.5", "file-saver": "^2.0.5", "jquery": "^3.6.0", + "jspdf": "^2.3.1", "ngx-infinite-scroll": "10.0.1", "ngx-webstorage": "8.0.0", "rxjs": "6.6.7", @@ -2573,6 +2574,19 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/runtime-corejs3": { + "version": "7.14.9", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.14.9.tgz", + "integrity": "sha512-64RiH2ON4/y8qYtoa8rUiyam/tUVyGqRyNYhe+vCRGmjnV4bUlZvY+mwd0RrmLoCpJpdq3RsrNqKb7SJdw/4kw==", + "optional": true, + "dependencies": { + "core-js-pure": "^3.16.0", + "regenerator-runtime": "^0.13.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", @@ -4384,6 +4398,12 @@ "integrity": "sha512-0/HnwIfW4ki2D8L8c9GVcG5I72s9jP5GSLVF0VIXDW00kmIpA6O33G7a8n59Tmh7Nz0WUC3rSb7PTY/sdW2JzA==", "dev": true }, + "node_modules/@types/raf": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.0.tgz", + "integrity": "sha512-taW5/WYqo36N7V39oYyHP9Ipfd5pNFvGTIQsNGj86xV88YQ7GnI30/yMfKDF7Zgin0m3e+ikX88FvImnK4RjGw==", + "optional": true + }, "node_modules/@types/sizzle": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz", @@ -5478,7 +5498,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true, "bin": { "atob": "bin/atob.js" }, @@ -6538,6 +6557,17 @@ "node-int64": "^0.4.0" } }, + "node_modules/btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==", + "bin": { + "btoa": "bin/btoa.js" + }, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/buffer": { "version": "4.9.2", "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", @@ -6683,6 +6713,23 @@ "integrity": "sha512-feylzsbDxi1gPZ1IjystzIQZagYYLvfKrSuygUCgf7z6x790VEzze5QEkdSV1U58RA7Hi0+v6fv4K54atOzATg==", "dev": true }, + "node_modules/canvg": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.7.tgz", + "integrity": "sha512-4sq6iL5Q4VOXS3PL1BapiXIZItpxYyANVzsAKpTPS5oq4u3SKbGfUcbZh2gdLCQ3jWpG/y5wRkMlBBAJhXeiZA==", + "optional": true, + "dependencies": { + "@babel/runtime-corejs3": "^7.9.6", + "@types/raf": "^3.4.0", + "raf": "^3.4.1", + "rgbcolor": "^1.0.1", + "stackblur-canvas": "^2.0.0", + "svg-pathdata": "^5.0.5" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -7673,7 +7720,7 @@ "version": "3.15.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.15.1.tgz", "integrity": "sha512-h8VbZYnc9pDzueiS2610IULDkpFFPunHwIpl8yRwFahAEEdSpHlTy3h3z3rKq5h11CaUdBEeRViu9AYvbxiMeg==", - "dev": true, + "devOptional": true, "hasInstallScript": true, "funding": { "type": "opencollective", @@ -7703,6 +7750,17 @@ "semver": "bin/semver.js" } }, + "node_modules/core-js-pure": { + "version": "3.16.1", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.16.1.tgz", + "integrity": "sha512-TyofCdMzx0KMhi84mVRS8rL1XsRk2SPUNz2azmth53iRN0/08Uim9fdhQTaZTG1LqaXHYVci4RDHka6WrXfnvg==", + "hasInstallScript": true, + "optional": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -8013,6 +8071,24 @@ "node": ">=6" } }, + "node_modules/css-line-break": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.0.1.tgz", + "integrity": "sha512-gwKYIMUn7xodIcb346wgUhE2Dt5O1Kmrc16PWi8sL4FTfyDj8P5095rzH7+O8CTZudJr+uw2GCI/hwEkDJFI2w==", + "optional": true, + "dependencies": { + "base64-arraybuffer": "^0.2.0" + } + }, + "node_modules/css-line-break/node_modules/base64-arraybuffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.2.0.tgz", + "integrity": "sha512-7emyCsu1/xiBXgQZrscw/8KPRT44I4Yq9Pe6EGs3aPRTsWuggML1/1DTuZUuIaJPIm1FTDUVXl4x/yW8s0kQDQ==", + "optional": true, + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/css-loader": { "version": "5.2.6", "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-5.2.6.tgz", @@ -9121,6 +9197,12 @@ "url": "https://github.com/fb55/domhandler?sponsor=1" } }, + "node_modules/dompurify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.0.tgz", + "integrity": "sha512-VV5C6Kr53YVHGOBKO/F86OYX6/iLTw2yVSI721gKetxpHCK/V5TaLEf9ODjRgl1KLSWRMY6cUhAbv/c+IUnwQw==", + "optional": true + }, "node_modules/domutils": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz", @@ -11729,6 +11811,18 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "node_modules/html2canvas": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.2.2.tgz", + "integrity": "sha512-cxZR1bGxtmhxeoCxM+s1WfRzDtpKPuHHZ7ExX01EdhgdEQCvMDZLDj3aknE8ywSoed8JM8AXhQiuD1KFwMm3Gw==", + "optional": true, + "dependencies": { + "css-line-break": "2.0.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/http-basic": { "version": "8.1.3", "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-8.1.3.tgz", @@ -15833,6 +15927,27 @@ "node >= 0.2.0" ] }, + "node_modules/jspdf": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/jspdf/-/jspdf-2.3.1.tgz", + "integrity": "sha512-1vp0USP1mQi1h7NKpwxjFgQkJ5ncZvtH858aLpycUc/M+r/RpWJT8PixAU7Cw/3fPd4fpC8eB/Bj42LnsR21YQ==", + "dependencies": { + "atob": "^2.1.2", + "btoa": "^1.2.1", + "fflate": "^0.4.8" + }, + "optionalDependencies": { + "canvg": "^3.0.6", + "core-js": "^3.6.0", + "dompurify": "^2.2.0", + "html2canvas": "^1.0.0-rc.5" + } + }, + "node_modules/jspdf/node_modules/fflate": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.8.tgz", + "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==" + }, "node_modules/jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -18469,7 +18584,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true + "devOptional": true }, "node_modules/picomatch": { "version": "2.3.0", @@ -21339,6 +21454,15 @@ } ] }, + "node_modules/raf": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", + "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", + "optional": true, + "dependencies": { + "performance-now": "^2.1.0" + } + }, "node_modules/randexp": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz", @@ -21659,7 +21783,7 @@ "version": "0.13.7", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==", - "dev": true + "devOptional": true }, "node_modules/regenerator-transform": { "version": "0.14.5", @@ -22103,6 +22227,15 @@ "integrity": "sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=", "dev": true }, + "node_modules/rgbcolor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", + "integrity": "sha1-1lBezbMEplldom+ktDMHMGd1lF0=", + "optional": true, + "engines": { + "node": ">= 0.8.15" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -23503,6 +23636,15 @@ "node": ">=8" } }, + "node_modules/stackblur-canvas": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.5.0.tgz", + "integrity": "sha512-EeNzTVfj+1In7aSLPKDD03F/ly4RxEuF/EX0YcOG0cKoPXs+SLZxDawQbexQDBzwROs4VKLWTOaZQlZkGBFEIQ==", + "optional": true, + "engines": { + "node": ">=0.1.14" + } + }, "node_modules/static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -24011,6 +24153,15 @@ "node": ">=8" } }, + "node_modules/svg-pathdata": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-5.0.5.tgz", + "integrity": "sha512-TAAvLNSE3fEhyl/Da19JWfMAdhSXTYeviXsLSoDT1UM76ADj5ndwAPX1FKQEgB/gFMPavOy6tOqfalXKUiXrow==", + "optional": true, + "engines": { + "node": ">=6.9.5" + } + }, "node_modules/svgo": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.3.1.tgz", @@ -29215,6 +29366,16 @@ "regenerator-runtime": "^0.13.4" } }, + "@babel/runtime-corejs3": { + "version": "7.14.9", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.14.9.tgz", + "integrity": "sha512-64RiH2ON4/y8qYtoa8rUiyam/tUVyGqRyNYhe+vCRGmjnV4bUlZvY+mwd0RrmLoCpJpdq3RsrNqKb7SJdw/4kw==", + "optional": true, + "requires": { + "core-js-pure": "^3.16.0", + "regenerator-runtime": "^0.13.4" + } + }, "@babel/template": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", @@ -30699,6 +30860,12 @@ "integrity": "sha512-0/HnwIfW4ki2D8L8c9GVcG5I72s9jP5GSLVF0VIXDW00kmIpA6O33G7a8n59Tmh7Nz0WUC3rSb7PTY/sdW2JzA==", "dev": true }, + "@types/raf": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.0.tgz", + "integrity": "sha512-taW5/WYqo36N7V39oYyHP9Ipfd5pNFvGTIQsNGj86xV88YQ7GnI30/yMfKDF7Zgin0m3e+ikX88FvImnK4RjGw==", + "optional": true + }, "@types/sizzle": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz", @@ -31521,8 +31688,7 @@ "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" }, "atomically": { "version": "1.7.0", @@ -32349,6 +32515,11 @@ "node-int64": "^0.4.0" } }, + "btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==" + }, "buffer": { "version": "4.9.2", "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", @@ -32472,6 +32643,20 @@ "integrity": "sha512-feylzsbDxi1gPZ1IjystzIQZagYYLvfKrSuygUCgf7z6x790VEzze5QEkdSV1U58RA7Hi0+v6fv4K54atOzATg==", "dev": true }, + "canvg": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.7.tgz", + "integrity": "sha512-4sq6iL5Q4VOXS3PL1BapiXIZItpxYyANVzsAKpTPS5oq4u3SKbGfUcbZh2gdLCQ3jWpG/y5wRkMlBBAJhXeiZA==", + "optional": true, + "requires": { + "@babel/runtime-corejs3": "^7.9.6", + "@types/raf": "^3.4.0", + "raf": "^3.4.1", + "rgbcolor": "^1.0.1", + "stackblur-canvas": "^2.0.0", + "svg-pathdata": "^5.0.5" + } + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -33279,7 +33464,7 @@ "version": "3.15.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.15.1.tgz", "integrity": "sha512-h8VbZYnc9pDzueiS2610IULDkpFFPunHwIpl8yRwFahAEEdSpHlTy3h3z3rKq5h11CaUdBEeRViu9AYvbxiMeg==", - "dev": true + "devOptional": true }, "core-js-compat": { "version": "3.15.2", @@ -33299,6 +33484,12 @@ } } }, + "core-js-pure": { + "version": "3.16.1", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.16.1.tgz", + "integrity": "sha512-TyofCdMzx0KMhi84mVRS8rL1XsRk2SPUNz2azmth53iRN0/08Uim9fdhQTaZTG1LqaXHYVci4RDHka6WrXfnvg==", + "optional": true + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -33534,6 +33725,23 @@ } } }, + "css-line-break": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.0.1.tgz", + "integrity": "sha512-gwKYIMUn7xodIcb346wgUhE2Dt5O1Kmrc16PWi8sL4FTfyDj8P5095rzH7+O8CTZudJr+uw2GCI/hwEkDJFI2w==", + "optional": true, + "requires": { + "base64-arraybuffer": "^0.2.0" + }, + "dependencies": { + "base64-arraybuffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.2.0.tgz", + "integrity": "sha512-7emyCsu1/xiBXgQZrscw/8KPRT44I4Yq9Pe6EGs3aPRTsWuggML1/1DTuZUuIaJPIm1FTDUVXl4x/yW8s0kQDQ==", + "optional": true + } + } + }, "css-loader": { "version": "5.2.6", "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-5.2.6.tgz", @@ -34361,6 +34569,12 @@ "domelementtype": "^2.2.0" } }, + "dompurify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.3.0.tgz", + "integrity": "sha512-VV5C6Kr53YVHGOBKO/F86OYX6/iLTw2yVSI721gKetxpHCK/V5TaLEf9ODjRgl1KLSWRMY6cUhAbv/c+IUnwQw==", + "optional": true + }, "domutils": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz", @@ -36406,6 +36620,15 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "html2canvas": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.2.2.tgz", + "integrity": "sha512-cxZR1bGxtmhxeoCxM+s1WfRzDtpKPuHHZ7ExX01EdhgdEQCvMDZLDj3aknE8ywSoed8JM8AXhQiuD1KFwMm3Gw==", + "optional": true, + "requires": { + "css-line-break": "2.0.1" + } + }, "http-basic": { "version": "8.1.3", "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-8.1.3.tgz", @@ -39529,6 +39752,27 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, + "jspdf": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/jspdf/-/jspdf-2.3.1.tgz", + "integrity": "sha512-1vp0USP1mQi1h7NKpwxjFgQkJ5ncZvtH858aLpycUc/M+r/RpWJT8PixAU7Cw/3fPd4fpC8eB/Bj42LnsR21YQ==", + "requires": { + "atob": "^2.1.2", + "btoa": "^1.2.1", + "canvg": "^3.0.6", + "core-js": "^3.6.0", + "dompurify": "^2.2.0", + "fflate": "^0.4.8", + "html2canvas": "^1.0.0-rc.5" + }, + "dependencies": { + "fflate": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.8.tgz", + "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==" + } + } + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -41563,7 +41807,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true + "devOptional": true }, "picomatch": { "version": "2.3.0", @@ -43631,6 +43875,15 @@ "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true }, + "raf": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", + "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", + "optional": true, + "requires": { + "performance-now": "^2.1.0" + } + }, "randexp": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz", @@ -43882,7 +44135,7 @@ "version": "0.13.7", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==", - "dev": true + "devOptional": true }, "regenerator-transform": { "version": "0.14.5", @@ -44223,6 +44476,12 @@ "integrity": "sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=", "dev": true }, + "rgbcolor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", + "integrity": "sha1-1lBezbMEplldom+ktDMHMGd1lF0=", + "optional": true + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -45384,6 +45643,12 @@ } } }, + "stackblur-canvas": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.5.0.tgz", + "integrity": "sha512-EeNzTVfj+1In7aSLPKDD03F/ly4RxEuF/EX0YcOG0cKoPXs+SLZxDawQbexQDBzwROs4VKLWTOaZQlZkGBFEIQ==", + "optional": true + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -45761,6 +46026,12 @@ } } }, + "svg-pathdata": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-5.0.5.tgz", + "integrity": "sha512-TAAvLNSE3fEhyl/Da19JWfMAdhSXTYeviXsLSoDT1UM76ADj5ndwAPX1FKQEgB/gFMPavOy6tOqfalXKUiXrow==", + "optional": true + }, "svgo": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.3.1.tgz", diff --git a/package.json b/package.json index 9ff8336..d25a4a9 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "dayjs": "1.10.5", "file-saver": "^2.0.5", "jquery": "^3.6.0", + "jspdf": "^2.3.1", "ngx-infinite-scroll": "10.0.1", "ngx-webstorage": "8.0.0", "rxjs": "6.6.7", diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html index b1ed5e0..ae29458 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html @@ -1,2 +1,3 @@

dashboard-admin works!

- + + diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts index dd2de7a..721f6a7 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts @@ -1,6 +1,9 @@ import { Component, OnInit } from '@angular/core'; -import * as FileSaver from 'file-saver'; import * as XLSX from 'xlsx'; +import * as FileSaver from 'file-saver'; +import { jsPDF } from 'jspdf'; +import { exportAsExcelFile } from '../export/export_excel'; +import { generatePDFTableData, createPDFTableHeaders, generatePDFTable } from '../export/export_pdf'; @Component({ selector: 'jhi-dashboard-admin', @@ -10,38 +13,9 @@ import * as XLSX from 'xlsx'; export class DashboardAdminComponent implements OnInit { constructor() {} - EXCEL_TYPE: string = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'; - EXCEL_EXTENSION: string = '.xlsx'; - ngOnInit(): void {} - exportAsExcelFile = (sheetNames: string[], arrayOfData: any[], excelFileName: any) => { - const workbook = XLSX.utils.book_new(); - - arrayOfData.forEach((data, index) => { - let sheetName = sheetNames[index]; - let worksheet = XLSX.utils.json_to_sheet([data]); - XLSX.utils.book_append_sheet(workbook, worksheet, sheetName); - }); - - const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); - this.saveAsExcelFile(excelBuffer, excelFileName); - }; - - saveAsExcelFile = (buffer: any, fileName: any) => { - const data = new Blob([buffer], { type: this.EXCEL_TYPE }); - FileSaver.saveAs( - data, - fileName + - '_' + - new Date().toLocaleDateString().substr(0, 10).split('/').join('-') + - '_' + - Math.random().toString().substring(2) + - this.EXCEL_EXTENSION - ); - }; - - exportReportesGeneralesAdministrador(): void { + exportReportesGeneralesAdministradorExcel(): void { /* Cantidad de usuarios activos Cantidad de usuarios bloqueados @@ -54,6 +28,26 @@ export class DashboardAdminComponent implements OnInit { const _reporteUsuarios = { usuarios_activos: 100, usuarios_bloqueados: 50 }; const _excelFinalData = [_reporteUsuarios]; - this.exportAsExcelFile(_sheets, _excelFinalData, 'reporte_general'); + exportAsExcelFile(_sheets, _excelFinalData, 'reporte_general'); + } + + exportReportesGeneralesAdministradorPDF(): void { + /* + Cantidad de usuarios activos + Cantidad de usuarios bloqueados + Cantidad de encuestas publicadas por categoría + Cantidad de encuestas finalizadas por categoría + Cantidad de encuestas publicadas por mes y año + */ + + const doc = new jsPDF(); + + const _reporteUsuarios = [{ usuarios_activos: '100', usuarios_bloqueados: '50' }]; + const _docData = generatePDFTableData(_reporteUsuarios); + + const _headers = ['usuarios_activos', 'usuarios_bloqueados']; + const _docHeaders = createPDFTableHeaders(_headers); + + generatePDFTable(doc, _docData, _docHeaders); } } diff --git a/src/main/webapp/app/entities/dashboard/export/export_common.ts b/src/main/webapp/app/entities/dashboard/export/export_common.ts new file mode 100644 index 0000000..d3a083e --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/export/export_common.ts @@ -0,0 +1,10 @@ +export const generateFileName = (fileName: string, extension: string): string => { + return ( + fileName + + '_' + + new Date().toLocaleDateString().substr(0, 10).split('/').join('-') + + '_' + + Math.random().toString().substring(2) + + extension + ); +}; diff --git a/src/main/webapp/app/entities/dashboard/export/export_excel.ts b/src/main/webapp/app/entities/dashboard/export/export_excel.ts new file mode 100644 index 0000000..8f549af --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/export/export_excel.ts @@ -0,0 +1,26 @@ +import * as XLSX from 'xlsx'; +import * as FileSaver from 'file-saver'; +import { generateFileName } from './export_common'; + +const EXCEL_TYPE: string = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'; +const EXCEL_EXTENSION: string = '.xlsx'; + +export const exportAsExcelFile = (sheetNames: string[], arrayOfData: any[], excelFileName: any) => { + const workbook = XLSX.utils.book_new(); + + arrayOfData.forEach((data, index) => { + let sheetName = sheetNames[index]; + let worksheet = XLSX.utils.json_to_sheet([data]); + XLSX.utils.book_append_sheet(workbook, worksheet, sheetName); + }); + + const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); + saveAsExcelFile(excelBuffer, excelFileName); +}; + +const saveAsExcelFile = (buffer: any, fileName: any) => { + const data = new Blob([buffer], { type: EXCEL_EXTENSION }); + const generatedFileName = generateFileName(fileName, EXCEL_EXTENSION); + + FileSaver.saveAs(data, generatedFileName); +}; diff --git a/src/main/webapp/app/entities/dashboard/export/export_pdf.ts b/src/main/webapp/app/entities/dashboard/export/export_pdf.ts new file mode 100644 index 0000000..1f5132f --- /dev/null +++ b/src/main/webapp/app/entities/dashboard/export/export_pdf.ts @@ -0,0 +1,35 @@ +import { jsPDF } from 'jspdf'; +import { generateFileName } from './export_common'; + +const PDF_EXTENSION: string = '.pdf'; + +export const generatePDFTableData = (data: any): any => { + const result: any = []; + + data.forEach((item: any) => { + result.push(Object.assign({}, item)); + }); + + return result; +}; + +export const createPDFTableHeaders = (keys: any): any[] => { + let result = []; + for (let i = 0; i < keys.length; i += 1) { + result.push({ + id: keys[i], + name: keys[i], + prompt: keys[i], + width: 65, + align: 'center', + padding: 0, + }); + } + return result; +}; + +export const generatePDFTable = (doc: jsPDF, _docData: any, _docHeaders: string[]): void => { + doc.table(1, 1, _docData, _docHeaders, { autoSize: true }); + const generatedFileName = generateFileName('reporte_general', PDF_EXTENSION); + doc.save(generatedFileName); +}; From e5c679570a18501a93a9ef9dd63e2cbcdf495f85 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Tue, 10 Aug 2021 18:22:01 -0600 Subject: [PATCH 3/7] Add PDF title --- .../dashboard-admin/dashboard-admin.component.ts | 7 +++++-- .../webapp/app/entities/dashboard/export/export_pdf.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts index 721f6a7..0cce762 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts @@ -28,7 +28,8 @@ export class DashboardAdminComponent implements OnInit { const _reporteUsuarios = { usuarios_activos: 100, usuarios_bloqueados: 50 }; const _excelFinalData = [_reporteUsuarios]; - exportAsExcelFile(_sheets, _excelFinalData, 'reporte_general'); + const _fileName = 'reporte_general'; + exportAsExcelFile(_sheets, _excelFinalData, _fileName); } exportReportesGeneralesAdministradorPDF(): void { @@ -47,7 +48,9 @@ export class DashboardAdminComponent implements OnInit { const _headers = ['usuarios_activos', 'usuarios_bloqueados']; const _docHeaders = createPDFTableHeaders(_headers); + const _fileName = 'reporte_general'; + const _docTitle = 'Reportes Generales de la Aplicación'; - generatePDFTable(doc, _docData, _docHeaders); + generatePDFTable(doc, _docData, _docHeaders, _fileName, _docTitle); } } diff --git a/src/main/webapp/app/entities/dashboard/export/export_pdf.ts b/src/main/webapp/app/entities/dashboard/export/export_pdf.ts index 1f5132f..a5431aa 100644 --- a/src/main/webapp/app/entities/dashboard/export/export_pdf.ts +++ b/src/main/webapp/app/entities/dashboard/export/export_pdf.ts @@ -28,8 +28,11 @@ export const createPDFTableHeaders = (keys: any): any[] => { return result; }; -export const generatePDFTable = (doc: jsPDF, _docData: any, _docHeaders: string[]): void => { - doc.table(1, 1, _docData, _docHeaders, { autoSize: true }); - const generatedFileName = generateFileName('reporte_general', PDF_EXTENSION); +export const generatePDFTable = (doc: jsPDF, _docData: any, _docHeaders: string[], _fileName: string, _docTitle: string): void => { + doc.setFontSize(20); + doc.setFont('helvetica', 'bold'); + doc.text(_docTitle, 20, 20); + doc.table(20, 30, _docData, _docHeaders, { autoSize: true }); + const generatedFileName = generateFileName(_fileName, PDF_EXTENSION); doc.save(generatedFileName); }; From a39ad439a54d4b518066b0e198d64b1412cae297 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Wed, 11 Aug 2021 19:18:18 -0600 Subject: [PATCH 4/7] Add export admin. reports as an Excel file --- package-lock.json | 2 +- .../dashboard-admin.component.html | 7 +- .../dashboard-admin.component.ts | 71 +++++++++++++++++-- .../entities/dashboard/export/export_excel.ts | 13 +++- 4 files changed, 81 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6444173..1eeeaec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,8 +57,8 @@ "@angular/compiler-cli": "12.0.5", "@angular/service-worker": "12.0.5", "@types/bootstrap": "^5.0.17", - "@types/file-saver": "^2.0.3", "@types/chartist": "^0.11.1", + "@types/file-saver": "^2.0.3", "@types/jest": "26.0.23", "@types/jquery": "^3.5.6", "@types/node": "15.12.2", diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html index 06056dd..3269324 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.html @@ -1,4 +1,7 @@
+ + +
@@ -13,7 +16,7 @@

Ganancias por plantillas

- {{ gananciasTotales | currency: 'CR' }} + ${{ gananciasTotales | number: '1.2' }}
@@ -137,5 +140,3 @@
- - diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts index ac14613..1768424 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import * as XLSX from 'xlsx'; import * as FileSaver from 'file-saver'; import { jsPDF } from 'jspdf'; -import { exportAsExcelFile } from '../export/export_excel'; +import { exportAsExcelFile, exportAsExcelTable } from '../export/export_excel'; import { generatePDFTableData, createPDFTableHeaders, generatePDFTable } from '../export/export_pdf'; import { FacturaService } from '../../factura/service/factura.service'; @@ -99,11 +99,11 @@ export class DashboardAdminComponent implements OnInit { .subscribe(res => { const tmpCategorias = res.body; this.categorias = tmpCategorias?.filter(c => c.estado === 'ACTIVE'); - let cantPublicadas = 0; - let cantFinalizadas = 0; const publicadas: number[] | null = []; const finalizadas: number[] | null = []; this.categorias?.forEach(c => { + let cantPublicadas = 0; + let cantFinalizadas = 0; this.encuestas?.forEach(e => { if (e.categoria?.id === c.id && e.estado === 'ACTIVE') { cantPublicadas = cantPublicadas + 1; @@ -198,13 +198,63 @@ export class DashboardAdminComponent implements OnInit { Cantidad de encuestas publicadas por categoría Cantidad de encuestas finalizadas por categoría Cantidad de encuestas publicadas por mes y año + + Cantidad de encuestas + Cantidad de personas que han completado sus encuestas + Cantidad de encuestas activas + Cantidad de encuestas finalizadas + Cantidad de comentarios de retroalimentación */ - const _sheets = ['reportes generales']; - const _reporteUsuarios = { usuarios_activos: 100, usuarios_bloqueados: 50 }; + const _sheets = ['reportes generales', 'enc. publicadas', 'enc. publicadas categoría', 'enc. finalizadas categoría']; - const _excelFinalData = [_reporteUsuarios]; - const _fileName = 'reporte_general'; + const _reporteUsuarios = [ + { + ganancias_plantillas: this.gananciasTotales, + usuarios_activos: this.cantUsuarioActivos, + usuarios_bloqueados: this.cantUsuarioBloqueados, + }, + ]; + + // listaMesesAnnos + // encuestasPublicadasMesAnno + const _reporteEncuestasPublicadas: any[] = []; + this.listaMesesAnnos.forEach((date: any, index) => { + let _report: any = {}; + _report['fecha'] = date; + _report['cantidad'] = this.encuestasPublicadasMesAnno[index]; + _reporteEncuestasPublicadas.push(_report); + }); + + // this.categorias + // this.encuestasPublicadasCategoria + const _reporteCantidadEncuestasPublicadasCategoria: any[] = []; + this.categorias!.forEach((categoria: any, index) => { + let _report: any = {}; + _report['categoria'] = categoria.nombre; + _report['cantidad'] = this.encuestasPublicadasCategoria[index]; + _reporteCantidadEncuestasPublicadasCategoria.push(_report); + }); + + // this.categorias + // this.encuestasFinalzadasCategoria + const _reporteCantidadEncuestasFinalizadasCategoria: any[] = []; + this.categorias!.forEach((categoria: any, index) => { + let _report: any = {}; + _report['categoria'] = categoria.nombre; + _report['cantidad'] = this.encuestasFinalzadasCategoria[index]; + _reporteCantidadEncuestasFinalizadasCategoria.push(_report); + }); + + // exportAsExcelTable(); + + const _excelFinalData = [ + _reporteUsuarios, + _reporteEncuestasPublicadas, + _reporteCantidadEncuestasPublicadasCategoria, + _reporteCantidadEncuestasFinalizadasCategoria, + ]; + const _fileName = 'reportes_datasurvey'; exportAsExcelFile(_sheets, _excelFinalData, _fileName); } @@ -215,6 +265,13 @@ export class DashboardAdminComponent implements OnInit { Cantidad de encuestas publicadas por categoría Cantidad de encuestas finalizadas por categoría Cantidad de encuestas publicadas por mes y año + + Cantidad de encuestas + Cantidad de personas que han completado sus encuestas + Cantidad de encuestas activas + Cantidad de encuestas finalizadas + Cantidad de comentarios de retroalimentación + */ const doc = new jsPDF(); diff --git a/src/main/webapp/app/entities/dashboard/export/export_excel.ts b/src/main/webapp/app/entities/dashboard/export/export_excel.ts index 8f549af..8054a73 100644 --- a/src/main/webapp/app/entities/dashboard/export/export_excel.ts +++ b/src/main/webapp/app/entities/dashboard/export/export_excel.ts @@ -10,7 +10,7 @@ export const exportAsExcelFile = (sheetNames: string[], arrayOfData: any[], exce arrayOfData.forEach((data, index) => { let sheetName = sheetNames[index]; - let worksheet = XLSX.utils.json_to_sheet([data]); + let worksheet = XLSX.utils.json_to_sheet(data); XLSX.utils.book_append_sheet(workbook, worksheet, sheetName); }); @@ -24,3 +24,14 @@ const saveAsExcelFile = (buffer: any, fileName: any) => { FileSaver.saveAs(data, generatedFileName); }; + +export const exportAsExcelTable = () => { + const workbook = XLSX.utils.book_new(); + + let worksheet = XLSX.utils.json_to_sheet([{ test: 1 }, { test: 2 }]); + + XLSX.utils.book_append_sheet(workbook, worksheet, 'test'); + + const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); + saveAsExcelFile(excelBuffer, 'test'); +}; From 25e38f1945a2065ffafab5c7381df8460faf2b9c Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Wed, 11 Aug 2021 20:16:23 -0600 Subject: [PATCH 5/7] Add survey template preview in edit survey template --- .../app/entities/plantilla/list/plantilla.component.html | 4 ++-- .../entities/plantilla/update/plantilla-update.component.html | 1 + .../entities/plantilla/update/plantilla-update.component.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html index 8ea63f7..4c2782e 100644 --- a/src/main/webapp/app/entities/plantilla/list/plantilla.component.html +++ b/src/main/webapp/app/entities/plantilla/list/plantilla.component.html @@ -91,7 +91,7 @@ {{ plantilla.categoria?.nombre }}
- + -->

Creada el día {{ plantilla!.fechaCreacion | formatShortDatetime | lowercase }}

diff --git a/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts b/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts index 3ccf1f5..5e11b79 100644 --- a/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts +++ b/src/main/webapp/app/entities/plantilla/update/plantilla-update.component.ts @@ -186,7 +186,7 @@ export class PlantillaUpdateComponent implements OnInit, AfterViewChecked { openPreview() { const surveyId = this.plantilla?.id; - this.router.navigate(['/plantilla', surveyId, 'preview']); + this.router.navigate(['/plantilla', surveyId, 'view']); } resetForm(event: any): void { From 987160727c0f60279971968c60d729e4e2b3d03e Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Wed, 11 Aug 2021 20:45:11 -0600 Subject: [PATCH 6/7] Add new rating display --- .../encuesta/detail/encuesta-detail.component.ts | 5 +++++ .../app/entities/encuesta/list/encuesta.component.ts | 9 ++++++++- .../app/pagina-principal/pagina-principal.component.ts | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts index d2445a1..0cfb0f2 100644 --- a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts +++ b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts @@ -72,6 +72,11 @@ export class EncuestaDetailComponent implements OnInit { this.activatedRoute.data.subscribe(({ encuesta }) => { if (encuesta) { this.encuesta = encuesta; + + // Fix calificacion + const _calificacion = encuesta.calificacion; + this.encuesta!.calificacion = Number(_calificacion?.toString().split('.')[0]); + this.loadAll(); } else { this.previousState(); diff --git a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts index 6761b1a..09e79e8 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts @@ -177,6 +177,13 @@ export class EncuestaComponent implements OnInit, AfterViewInit { (res: HttpResponse) => { this.isLoading = false; const tmpEncuestas = res.body ?? []; + + // Fix calificacion + tmpEncuestas.forEach(encuesta => { + const _calificacion = encuesta.calificacion; + encuesta.calificacion = Number(_calificacion?.toString().split('.')[0]); + }); + if (this.isAdmin()) { this.encuestas = tmpEncuestas.filter(e => e.estado !== EstadoEncuesta.DELETED); @@ -418,7 +425,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { nombre: this.editForm.get(['nombre'])!.value, descripcion: this.editForm.get(['descripcion'])!.value, fechaCreacion: dayjs(now, DATE_TIME_FORMAT), - calificacion: 5, + calificacion: 5.1, acceso: this.editForm.get(['acceso'])!.value, contrasenna: undefined, estado: EstadoEncuesta.DRAFT, diff --git a/src/main/webapp/app/pagina-principal/pagina-principal.component.ts b/src/main/webapp/app/pagina-principal/pagina-principal.component.ts index df5a08f..6aeee95 100644 --- a/src/main/webapp/app/pagina-principal/pagina-principal.component.ts +++ b/src/main/webapp/app/pagina-principal/pagina-principal.component.ts @@ -86,6 +86,13 @@ export class PaginaPrincipalComponent implements OnInit { (res: HttpResponse) => { this.isLoading = false; const tmpEncuestas = res.body ?? []; + + // Fix calificacion + tmpEncuestas.forEach(encuesta => { + const _calificacion = encuesta.calificacion; + encuesta.calificacion = Number(_calificacion?.toString().split('.')[0]); + }); + this.encuestas = tmpEncuestas.filter(e => e.estado === 'ACTIVE' && e.acceso === 'PUBLIC'); }, () => { From 911f45ea018fe8e7a82620c85547150c029f5f69 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Wed, 11 Aug 2021 20:49:34 -0600 Subject: [PATCH 7/7] Update rating initialization on create survey based on a template --- .../usuario-plantillas/list/usuario-plantillas.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts index 22fe062..bdffc05 100644 --- a/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts +++ b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.ts @@ -83,7 +83,7 @@ export class UsuarioPlantillasComponent implements OnInit { nombre: 'This is a survey', descripcion: 'This is a survey', fechaCreacion: dayjs(now, DATE_TIME_FORMAT), - calificacion: 5, + calificacion: 5.1, acceso: AccesoEncuesta.PUBLIC, contrasenna: undefined, estado: EstadoEncuesta.DRAFT,