Refactor/upgrade backend and frontend parts (#2)

* ♻️ Refactor and simplify backend code

* ♻️ Refactor frontend state, integrate typesafe-vuex accessors into state files

* ♻️ Use new state accessors and standardize layout

* 🔒 Upgrade and fix npm security audit

* 🔧 Update local re-generation scripts

* 🔊 Log startup exceptions to detect errors early

* ✏️ Fix password reset token content

* 🔥 Remove unneeded Dockerfile directives

* 🔥 Remove unnecessary print

* 🔥 Remove unnecessary code, upgrade dependencies in backend

* ✏️ Fix typos in docstrings and comments

* 🏗️ Improve user Depends utilities to simplify and remove code

* 🔥 Remove deprecated SQLAlchemy parameter
This commit is contained in:
Sebastián Ramírez
2019-03-11 13:36:42 +04:00
committed by GitHub
parent 9e0b826618
commit cd112bd683
54 changed files with 492 additions and 371 deletions

View File

@@ -858,24 +858,12 @@
"integrity": "sha512-ePl4l+7dLLmCucIwgQHAgjiepY++qcI6nb8eAwGNkB6OxmTe3Z9rQU3rSpomqu42PCCnlThZbOoxsf+qylJsLA==",
"dev": true
},
"@types/node": {
"version": "10.12.20",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.20.tgz",
"integrity": "sha512-9spv6SklidqxevvZyOUGjZVz4QRXGu2dNaLyXIFzFYZW0AGDykzPRIUFJXTlQXyfzAucddwTcGtJNim8zqSOPA==",
"dev": true
},
"@types/q": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.1.tgz",
"integrity": "sha512-eqz8c/0kwNi/OEHQfvIuJVLTst3in0e7uTKeuY+WL/zfKn0xVujOTp42bS/vUUokhK5P2BppLd9JXMOMHcgbjA==",
"dev": true
},
"@types/semver": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz",
"integrity": "sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==",
"dev": true
},
"@types/strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz",
@@ -1034,18 +1022,95 @@
}
},
"@vue/cli-plugin-unit-jest": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@vue/cli-plugin-unit-jest/-/cli-plugin-unit-jest-3.3.0.tgz",
"integrity": "sha512-Y/WkrO95vdvjVjeNO1vZRQUAxlZ6ngdgAzvMzCeEaujbRG4b8M6W7ePSAe8C9yfoVcJtbnoHcBv2er31sPwtyQ==",
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/@vue/cli-plugin-unit-jest/-/cli-plugin-unit-jest-3.5.0.tgz",
"integrity": "sha512-JFKiuLil1ayzTZCYk1DgoUFYb0F3nfbdVH3C7CN39EOfNgvEMvtavgS2Pb6MU+xx1f2J71bwVHQYY0HIx8zWJw==",
"dev": true,
"requires": {
"@vue/cli-shared-utils": "^3.3.0",
"@vue/cli-shared-utils": "^3.5.0",
"babel-jest": "^23.6.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"jest": "^23.6.0",
"jest-serializer-vue": "^2.0.2",
"jest-transform-stub": "^1.0.0",
"vue-jest": "^3.0.2"
"jest-transform-stub": "^2.0.0",
"vue-jest": "^3.0.3"
},
"dependencies": {
"@vue/cli-shared-utils": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/@vue/cli-shared-utils/-/cli-shared-utils-3.5.0.tgz",
"integrity": "sha512-+EIwVMTjdfRQVEtcIhpRjNsPB2ZlopiUktlPpx6oLQdlJXwBWkFQVwuXdXHtPYxB5Kzs3VPyUfhHxnPIbNw1+Q==",
"dev": true,
"requires": {
"chalk": "^2.4.1",
"execa": "^1.0.0",
"joi": "^14.3.0",
"launch-editor": "^2.2.1",
"lru-cache": "^5.1.1",
"node-ipc": "^9.1.1",
"opn": "^5.3.0",
"ora": "^3.1.0",
"request": "^2.87.0",
"request-promise-native": "^1.0.7",
"semver": "^5.5.0",
"string.prototype.padstart": "^3.0.0"
}
},
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"cli-spinners": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.0.0.tgz",
"integrity": "sha512-yiEBmhaKPPeBj7wWm4GEdtPZK940p9pl3EANIrnJ3JnvWyrPjcFcsEq6qRUuQ7fzB0+Y82ld3p6B34xo95foWw==",
"dev": true
},
"ora": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/ora/-/ora-3.2.0.tgz",
"integrity": "sha512-XHMZA5WieCbtg+tu0uPF8CjvwQdNzKCX6BVh3N6GFsEXH40mTk5dsw/ya1lBTUGJslcEFJFQ8cBhOgkkZXQtMA==",
"dev": true,
"requires": {
"chalk": "^2.4.2",
"cli-cursor": "^2.1.0",
"cli-spinners": "^2.0.0",
"log-symbols": "^2.2.0",
"strip-ansi": "^5.0.0",
"wcwidth": "^1.0.1"
}
},
"request-promise-core": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz",
"integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==",
"dev": true,
"requires": {
"lodash": "^4.17.11"
}
},
"request-promise-native": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.7.tgz",
"integrity": "sha512-rIMnbBdgNViL37nZ1b3L/VfPOpSi0TqVDQPAvO6U14lMzOLrt5nilxCQqtDKhZeDiW0/hkCXGoQjhgJd/tCh6w==",
"dev": true,
"requires": {
"request-promise-core": "1.1.2",
"stealthy-require": "^1.1.1",
"tough-cookie": "^2.3.3"
}
},
"strip-ansi": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.1.0.tgz",
"integrity": "sha512-TjxrkPONqO2Z8QDCpeE2j6n0M6EwxzyDgzEeGp+FbdvaJAt//ClYi6W5my+3ROlC/hZX2KACUwDfK49Ka5eDvg==",
"dev": true,
"requires": {
"ansi-regex": "^4.1.0"
}
}
}
},
"@vue/cli-service": {
@@ -1467,9 +1532,9 @@
},
"dependencies": {
"acorn": {
"version": "6.0.6",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.6.tgz",
"integrity": "sha512-5M3G/A4uBSMIlfJ+h9W125vJvPFH/zirISsW5qfxF5YzEvXJCtolLoQvM5yZft0DvMcUrPGKPOlgEu55I6iUtA==",
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
"integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==",
"dev": true
}
}
@@ -3806,15 +3871,15 @@
}
},
"cssom": {
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.4.tgz",
"integrity": "sha512-+7prCSORpXNeR4/fUP3rL+TzqtiFfhMvTd7uEqMdgPvLPt4+uzFUeufx5RHjGTACCargg/DiEt/moMQmvnfkog==",
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.6.tgz",
"integrity": "sha512-DtUeseGk9/GBW0hl0vVPpU22iHL6YB5BUX7ml1hB+GMpo0NX5G4voX3kdWiMSEguFtcW3Vh3djqNF4aIe6ne0A==",
"dev": true
},
"cssstyle": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.1.1.tgz",
"integrity": "sha512-364AI1l/M5TYcFH83JnOH/pSqgaNnKmYgKrm0didZMGKWjQB60dymwWy1rKUgL3J1ffdq9xVi2yGLHdSjjSNog==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.2.1.tgz",
"integrity": "sha512-7DYm8qe+gPx/h77QlCyFmX80+fGaE/6A/Ekl0zaszYOubvySO2saYFdQ78P29D0UsULxFKCetDGNaNRUdSF+2A==",
"dev": true,
"requires": {
"cssom": "0.3.x"
@@ -4266,15 +4331,13 @@
}
},
"editorconfig": {
"version": "0.15.2",
"resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.2.tgz",
"integrity": "sha512-GWjSI19PVJAM9IZRGOS+YKI8LN+/sjkSjNyvxL5ucqP9/IqtYNXBaQ/6c/hkPNYQHyOHra2KoXZI/JVpuqwmcQ==",
"version": "0.15.3",
"resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.3.tgz",
"integrity": "sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g==",
"dev": true,
"requires": {
"@types/node": "^10.11.7",
"@types/semver": "^5.5.0",
"commander": "^2.19.0",
"lru-cache": "^4.1.3",
"lru-cache": "^4.1.5",
"semver": "^5.6.0",
"sigmund": "^1.0.1"
},
@@ -4433,9 +4496,9 @@
"dev": true
},
"escodegen": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.0.tgz",
"integrity": "sha512-IeMV45ReixHS53K/OmfKAIztN/igDHzTJUhZM3k1jMhIZWjk45SMwAtBsEXiJp3vSPmTcu6CXn7mDvFHRN66fw==",
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.1.tgz",
"integrity": "sha512-JwiqFD9KdGVVpeuRa68yU3zZnBEOcPs0nKW7wZzXky8Z7tffdYUHbe11bPCV5jYlK6DVdKLWLm0f5I/QlL0Kmw==",
"dev": true,
"requires": {
"esprima": "^3.1.3",
@@ -5010,9 +5073,9 @@
}
},
"find-babel-config": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/find-babel-config/-/find-babel-config-1.1.0.tgz",
"integrity": "sha1-rMAQQ6Z0n+w0Qpvmtk9ULrtdY1U=",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/find-babel-config/-/find-babel-config-1.2.0.tgz",
"integrity": "sha512-jB2CHJeqy6a820ssiqwrKMeyC6nNdmrcgkKWJWmpoxpE8RKciYJXCcXRq1h2AzCo5I5BJeN2tkGEO3hLTuePRA==",
"dev": true,
"requires": {
"json5": "^0.5.1",
@@ -5280,14 +5343,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -5302,20 +5363,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@@ -5432,8 +5490,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@@ -5445,7 +5502,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -5460,7 +5516,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -5468,14 +5523,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -5494,7 +5547,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -5575,8 +5627,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@@ -5588,7 +5639,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@@ -5710,7 +5760,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -5951,9 +6000,9 @@
"dev": true
},
"handlebars": {
"version": "4.0.12",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.12.tgz",
"integrity": "sha512-RhmTekP+FZL+XNhwS1Wf+bTTZpdLougwt5pcgA1tuz6Jcx0fpH/7z0qd71RKnZHBCxIRBHfBOnio4gViPemNzA==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.0.tgz",
"integrity": "sha512-l2jRuU1NAWK6AW5qqcTATWQJvNPEwkM7NEKSiv/gqOsoSQbVoWyqVEY5GS+XPQ88zLNmqASRpzfdm8d79hJS+w==",
"dev": true,
"requires": {
"async": "^2.5.0",
@@ -8321,9 +8370,9 @@
}
},
"jest-transform-stub": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/jest-transform-stub/-/jest-transform-stub-1.0.0.tgz",
"integrity": "sha512-7eilMk4sxi2Fiy223I+BYTS5wJQEGEBqR3D8dy5A6RWmMTnmjipw2ImGDfXzEUBieebyrnitzkJfpNOJSFklLQ==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/jest-transform-stub/-/jest-transform-stub-2.0.0.tgz",
"integrity": "sha512-lspHaCRx/mBbnm3h4uMMS3R5aZzMwyNpNIJLXj4cEsV0mIUtS4IjYJLSoyjRCtnxb6RIGJ4NL2quZzfIeNhbkg==",
"dev": true
},
"jest-util": {
@@ -8394,9 +8443,9 @@
}
},
"js-beautify": {
"version": "1.8.9",
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.8.9.tgz",
"integrity": "sha512-MwPmLywK9RSX0SPsUJjN7i+RQY9w/yC17Lbrq9ViEefpLRgqAR2BgrMN2AbifkUuhDV8tRauLhLda/9+bE0YQA==",
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.9.0.tgz",
"integrity": "sha512-P0skmY4IDjfLiVrx+GLDeme8w5G0R1IGXgccVU5HP2VM3lRblH7qN2LTea5vZAxrDjpZBD0Jv+ahpjwVcbz/rw==",
"dev": true,
"requires": {
"config-chain": "^1.1.12",
@@ -9310,12 +9359,13 @@
}
},
"node-notifier": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.3.0.tgz",
"integrity": "sha512-AhENzCSGZnZJgBARsUjnQ7DnZbzyP+HxlVXuD0xqAnvL8q+OqtSX7lGg9e8nHzwXkMMXNdVeqq4E2M3EUAqX6Q==",
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.0.tgz",
"integrity": "sha512-SUDEb+o71XR5lXSTyivXd9J7fCloE3SyP4lSgt3lU2oSANiox+SxlNRGPjDKrwU1YN3ix2KN/VGGCg0t01rttQ==",
"dev": true,
"requires": {
"growly": "^1.3.0",
"is-wsl": "^1.1.0",
"semver": "^5.5.0",
"shellwords": "^0.1.1",
"which": "^1.3.0"
@@ -9404,9 +9454,9 @@
"dev": true
},
"nwsapi": {
"version": "2.0.9",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.9.tgz",
"integrity": "sha512-nlWFSCTYQcHk/6A9FFnfhKc14c3aFhfdNBXgo8Qgi9QTBu/qg3Ww+Uiz9wMzXd1T8GFxPc2QIHB6Qtf2XFryFQ==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.1.tgz",
"integrity": "sha512-T5GaA1J/d34AC8mkrFD2O0DR17kwJ702ZOtJOsS8RpbsQZVOC2/xYFb1i/cw+xdM54JIlMuojjDOYct8GIWtwg==",
"dev": true
},
"oauth-sign": {
@@ -10891,9 +10941,9 @@
}
},
"realpath-native": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/realpath-native/-/realpath-native-1.0.2.tgz",
"integrity": "sha512-+S3zTvVt9yTntFrBpm7TQmQ3tzpCrnA1a/y+3cUHAc9ZR6aIjG0WNLR+Rj79QpJktY+VeW/TQtFlQ1bzsehI8g==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/realpath-native/-/realpath-native-1.1.0.tgz",
"integrity": "sha512-wlgPA6cCIIg9gKz0fgAPjnzh4yR/LnXovwuo9hvyGvx3h8nX4+/iLZplfUWasXpqD8BdnGnP5njOFjkUwPzvjA==",
"dev": true,
"requires": {
"util.promisify": "^1.0.0"
@@ -13049,9 +13099,9 @@
"dev": true
},
"vue-jest": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/vue-jest/-/vue-jest-3.0.2.tgz",
"integrity": "sha512-5XIQ1xQFW0ZnWxHWM7adVA2IqbDsdw1vhgZfGFX4oWd75J38KIS3YT41PtiE7lpMLmNM6+VJ0uprT2mhHjUgkA==",
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/vue-jest/-/vue-jest-3.0.4.tgz",
"integrity": "sha512-PY9Rwt4OyaVlA+KDJJ0614CbEvNOkffDI9g9moLQC/2DDoo0YrqZm7dHi13Q10uoK5Nt5WCYFdeAheOExPah0w==",
"dev": true,
"requires": {
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",

View File

@@ -26,7 +26,7 @@
"@vue/cli-plugin-babel": "^3.3.0",
"@vue/cli-plugin-pwa": "^3.3.0",
"@vue/cli-plugin-typescript": "^3.3.0",
"@vue/cli-plugin-unit-jest": "^3.3.0",
"@vue/cli-plugin-unit-jest": "^3.5.0",
"@vue/cli-service": "^3.3.1",
"@vue/test-utils": "^1.0.0-beta.28",
"babel-core": "7.0.0-bridge.0",

View File

@@ -21,8 +21,9 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { dispatchCheckLoggedIn, readIsLoggedIn, commitAddNotification } from '@/store/main/accessors';
import NotificationsManager from '@/components/NotificationsManager.vue';
import { readIsLoggedIn } from '@/store/main/getters';
import { dispatchCheckLoggedIn } from '@/store/main/actions';
@Component({
components: {

View File

@@ -8,8 +8,10 @@
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { readFirstNotification, dispatchRemoveNotification, commitRemoveNotification } from '@/store/main/accessors';
import { AppNotification } from '@/store/main/state';
import { commitRemoveNotification } from '@/store/main/mutations';
import { readFirstNotification } from '@/store/main/getters';
import { dispatchRemoveNotification } from '@/store/main/actions';
@Component
export default class NotificationsManager extends Vue {

View File

@@ -1,9 +0,0 @@
import { getStoreAccessors } from 'typesafe-vuex';
import { State } from '@/store/state';
import { mutations } from '../mutations';
import { AdminState } from '../state';
const {commit} = getStoreAccessors<AdminState, State>('');
export const commitSetUser = commit(mutations.setUser);
export const commitSetUsers = commit(mutations.setUsers);

View File

@@ -1,10 +0,0 @@
import { getStoreAccessors } from 'typesafe-vuex';
import { AdminState } from '../state';
import { State } from '@/store/state';
import { actions } from '../actions';
const {dispatch} = getStoreAccessors<AdminState, State>('');
export const dispatchCreateUser = dispatch(actions.actionCreateUser);
export const dispatchGetUsers = dispatch(actions.actionGetUsers);
export const dispatchUpdateUser = dispatch(actions.actionUpdateUser);

View File

@@ -1,3 +0,0 @@
export * from './commit';
export * from './dispatch';
export * from './read';

View File

@@ -1,9 +0,0 @@
import { getStoreAccessors } from 'typesafe-vuex';
import { AdminState } from '../state';
import { State } from '@/store/state';
import { getters } from '../getters';
const { read } = getStoreAccessors<AdminState, State>('');
export const readAdminOneUser = read(getters.adminOneUser);
export const readAdminUsers = read(getters.adminUsers);

View File

@@ -1,13 +1,12 @@
import { api } from '@/api';
import { ActionContext } from 'vuex';
import {
commitSetUsers,
commitSetUser,
} from './accessors/commit';
import { IUserProfileCreate, IUserProfileUpdate } from '@/interfaces';
import { State } from '../state';
import { AdminState } from './state';
import { dispatchCheckApiError, commitAddNotification, commitRemoveNotification } from '../main/accessors';
import { getStoreAccessors } from 'typesafe-vuex';
import { commitSetUsers, commitSetUser } from './mutations';
import { dispatchCheckApiError } from '../main/actions';
import { commitAddNotification, commitRemoveNotification } from '../main/mutations';
type MainContext = ActionContext<AdminState, State>;
@@ -32,7 +31,7 @@ export const actions = {
]))[0];
commitSetUser(context, response.data);
commitRemoveNotification(context, loadingNotification);
commitAddNotification(context, {content: 'User successfully updated', color: 'success'});
commitAddNotification(context, { content: 'User successfully updated', color: 'success' });
} catch (error) {
await dispatchCheckApiError(context, error);
}
@@ -53,3 +52,9 @@ export const actions = {
}
},
};
const { dispatch } = getStoreAccessors<AdminState, State>('');
export const dispatchCreateUser = dispatch(actions.actionCreateUser);
export const dispatchGetUsers = dispatch(actions.actionGetUsers);
export const dispatchUpdateUser = dispatch(actions.actionUpdateUser);

View File

@@ -1,4 +1,6 @@
import { AdminState } from './state';
import { getStoreAccessors } from 'typesafe-vuex';
import { State } from '../state';
export const getters = {
adminUsers: (state: AdminState) => state.users,
@@ -9,3 +11,8 @@ export const getters = {
}
},
};
const { read } = getStoreAccessors<AdminState, State>('');
export const readAdminOneUser = read(getters.adminOneUser);
export const readAdminUsers = read(getters.adminUsers);

View File

@@ -1,5 +1,7 @@
import { IUserProfile } from '@/interfaces';
import { AdminState } from './state';
import { getStoreAccessors } from 'typesafe-vuex';
import { State } from '../state';
export const mutations = {
setUsers(state: AdminState, payload: IUserProfile[]) {
@@ -11,3 +13,8 @@ export const mutations = {
state.users = users;
},
};
const { commit } = getStoreAccessors<AdminState, State>('');
export const commitSetUser = commit(mutations.setUser);
export const commitSetUsers = commit(mutations.setUsers);

View File

@@ -1,15 +0,0 @@
import { getStoreAccessors } from 'typesafe-vuex';
import { MainState } from '../state';
import { State } from '@/store/state';
import { mutations } from '../mutations';
const {commit} = getStoreAccessors<MainState | any, State>('');
export const commitSetDashboardMiniDrawer = commit(mutations.setDashboardMiniDrawer);
export const commitSetDashboardShowDrawer = commit(mutations.setDashboardShowDrawer);
export const commitSetLoggedIn = commit(mutations.setLoggedIn);
export const commitSetLogInError = commit(mutations.setLogInError);
export const commitSetToken = commit(mutations.setToken);
export const commitSetUserProfile = commit(mutations.setUserProfile);
export const commitAddNotification = commit(mutations.addNotification);
export const commitRemoveNotification = commit(mutations.removeNotification);

View File

@@ -1,20 +0,0 @@
import { getStoreAccessors } from 'typesafe-vuex';
import { MainState } from '../state';
import { State } from '@/store/state';
import { actions } from '../actions';
const {dispatch} = getStoreAccessors<MainState | any, State>('');
export const dispatchCheckApiError = dispatch(actions.actionCheckApiError);
export const dispatchCheckLoggedIn = dispatch(actions.actionCheckLoggedIn);
export const dispatchGetUserProfile = dispatch(actions.actionGetUserProfile);
export const dispatchLogIn = dispatch(actions.actionLogIn);
export const dispatchLogOut = dispatch(actions.actionLogOut);
export const dispatchUserLogOut = dispatch(actions.actionUserLogOut);
export const dispatchRemoveLogIn = dispatch(actions.actionRemoveLogIn);
export const dispatchRouteLoggedIn = dispatch(actions.actionRouteLoggedIn);
export const dispatchRouteLogOut = dispatch(actions.actionRouteLogOut);
export const dispatchUpdateUserProfile = dispatch(actions.actionUpdateUserProfile);
export const dispatchRemoveNotification = dispatch(actions.removeNotification);
export const dispatchPasswordRecovery = dispatch(actions.passwordRecovery);
export const dispatchResetPassword = dispatch(actions.resetPassword);

View File

@@ -1,3 +0,0 @@
export * from './commit';
export * from './dispatch';
export * from './read';

View File

@@ -1,15 +0,0 @@
import { getStoreAccessors } from 'typesafe-vuex';
import { MainState } from '../state';
import { State } from '@/store/state';
import { getters } from '../getters';
const {read} = getStoreAccessors<MainState, State>('');
export const readDashboardMiniDrawer = read(getters.dashboardMiniDrawer);
export const readDashboardShowDrawer = read(getters.dashboardShowDrawer);
export const readHasAdminAccess = read(getters.hasAdminAccess);
export const readIsLoggedIn = read(getters.isLoggedIn);
export const readLoginError = read(getters.loginError);
export const readToken = read(getters.token);
export const readUserProfile = read(getters.userProfile);
export const readFirstNotification = read(getters.firstNotification);

View File

@@ -1,24 +1,19 @@
import { api } from '@/api';
import { saveLocalToken, getLocalToken, removeLocalToken } from '@/utils';
import router from '@/router';
import { getLocalToken, removeLocalToken, saveLocalToken } from '@/utils';
import { AxiosError } from 'axios';
import { getStoreAccessors } from 'typesafe-vuex';
import { ActionContext } from 'vuex';
import { State } from '../state';
import {
commitSetToken,
commitAddNotification,
commitRemoveNotification,
commitSetLoggedIn,
commitSetLogInError,
dispatchGetUserProfile,
dispatchRouteLoggedIn,
dispatchLogOut,
commitSetToken,
commitSetUserProfile,
dispatchCheckApiError,
dispatchRemoveLogIn,
dispatchRouteLogOut,
commitRemoveNotification,
commitAddNotification,
} from './accessors';
import { AxiosError } from 'axios';
import { State } from '../state';
import { MainState, AppNotification } from './state';
} from './mutations';
import { AppNotification, MainState } from './state';
type MainContext = ActionContext<MainState, State>;
@@ -160,3 +155,19 @@ export const actions = {
}
},
};
const { dispatch } = getStoreAccessors<MainState | any, State>('');
export const dispatchCheckApiError = dispatch(actions.actionCheckApiError);
export const dispatchCheckLoggedIn = dispatch(actions.actionCheckLoggedIn);
export const dispatchGetUserProfile = dispatch(actions.actionGetUserProfile);
export const dispatchLogIn = dispatch(actions.actionLogIn);
export const dispatchLogOut = dispatch(actions.actionLogOut);
export const dispatchUserLogOut = dispatch(actions.actionUserLogOut);
export const dispatchRemoveLogIn = dispatch(actions.actionRemoveLogIn);
export const dispatchRouteLoggedIn = dispatch(actions.actionRouteLoggedIn);
export const dispatchRouteLogOut = dispatch(actions.actionRouteLogOut);
export const dispatchUpdateUserProfile = dispatch(actions.actionUpdateUserProfile);
export const dispatchRemoveNotification = dispatch(actions.removeNotification);
export const dispatchPasswordRecovery = dispatch(actions.passwordRecovery);
export const dispatchResetPassword = dispatch(actions.resetPassword);

View File

@@ -1,4 +1,6 @@
import { MainState } from './state';
import { getStoreAccessors } from 'typesafe-vuex';
import { State } from '../state';
export const getters = {
hasAdminAccess: (state: MainState) => {
@@ -14,3 +16,14 @@ export const getters = {
isLoggedIn: (state: MainState) => state.isLoggedIn,
firstNotification: (state: MainState) => state.notifications.length > 0 && state.notifications[0],
};
const {read} = getStoreAccessors<MainState, State>('');
export const readDashboardMiniDrawer = read(getters.dashboardMiniDrawer);
export const readDashboardShowDrawer = read(getters.dashboardShowDrawer);
export const readHasAdminAccess = read(getters.hasAdminAccess);
export const readIsLoggedIn = read(getters.isLoggedIn);
export const readLoginError = read(getters.loginError);
export const readToken = read(getters.token);
export const readUserProfile = read(getters.userProfile);
export const readFirstNotification = read(getters.firstNotification);

View File

@@ -1,5 +1,7 @@
import { IUserProfile } from '@/interfaces';
import { MainState, AppNotification } from './state';
import { getStoreAccessors } from 'typesafe-vuex';
import { State } from '../state';
export const mutations = {
@@ -28,3 +30,14 @@ export const mutations = {
state.notifications = state.notifications.filter((notification) => notification !== payload);
},
};
const {commit} = getStoreAccessors<MainState | any, State>('');
export const commitSetDashboardMiniDrawer = commit(mutations.setDashboardMiniDrawer);
export const commitSetDashboardShowDrawer = commit(mutations.setDashboardShowDrawer);
export const commitSetLoggedIn = commit(mutations.setLoggedIn);
export const commitSetLogInError = commit(mutations.setLogInError);
export const commitSetToken = commit(mutations.setToken);
export const commitSetUserProfile = commit(mutations.setUserProfile);
export const commitAddNotification = commit(mutations.addNotification);
export const commitRemoveNotification = commit(mutations.removeNotification);

View File

@@ -35,7 +35,8 @@
import { Component, Vue } from 'vue-property-decorator';
import { api } from '@/api';
import { appName } from '@/env';
import { readLoginError, dispatchLogIn } from '@/store/main/accessors';
import { readLoginError } from '@/store/main/getters';
import { dispatchLogIn } from '@/store/main/actions';
@Component
export default class Login extends Vue {

View File

@@ -30,7 +30,7 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { appName } from '@/env';
import { dispatchLogIn, dispatchPasswordRecovery } from '@/store/main/accessors';
import { dispatchPasswordRecovery } from '@/store/main/actions';
@Component
export default class Login extends Vue {

View File

@@ -33,13 +33,9 @@
import { Component, Vue } from 'vue-property-decorator';
import { Store } from 'vuex';
import { IUserProfileUpdate } from '@/interfaces';
import {
dispatchUpdateUserProfile,
readUserProfile,
dispatchResetPassword,
commitAddNotification,
} from '@/store/main/accessors';
import { appName } from '@/env';
import { commitAddNotification } from '@/store/main/mutations';
import { dispatchResetPassword } from '@/store/main/actions';
@Component
export default class UserProfileEdit extends Vue {

View File

@@ -6,10 +6,12 @@
</v-card-title>
<v-card-text>
<div class="headline font-weight-light ma-5">Welcome {{greetedUser}}</div>
</v-card-text>
<v-card-actions>
<v-btn to="/main/profile/view">View Profile</v-btn>
<v-btn to="/main/profile/edit">Edit Profile</v-btn>
<v-btn to="/main/profile/password">Change Password</v-btn>
</v-card-text>
</v-card-actions>
</v-card>
</v-container>
</template>
@@ -17,7 +19,7 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { Store } from 'vuex';
import { readUserProfile } from '@/store/main/accessors';
import { readUserProfile } from '@/store/main/getters';
@Component
export default class Dashboard extends Vue {

View File

@@ -121,14 +121,9 @@
import { Vue, Component } from 'vue-property-decorator';
import { appName } from '@/env';
import {
commitSetDashboardShowDrawer,
readDashboardShowDrawer,
commitSetDashboardMiniDrawer,
readDashboardMiniDrawer,
dispatchUserLogOut,
readHasAdminAccess,
} from '@/store/main/accessors';
import { readDashboardMiniDrawer, readDashboardShowDrawer, readHasAdminAccess } from '@/store/main/getters';
import { commitSetDashboardShowDrawer, commitSetDashboardMiniDrawer } from '@/store/main/mutations';
import { dispatchUserLogOut } from '@/store/main/actions';
const routeGuardMain = async (to, from, next) => {
if (to.path === '/main') {

View File

@@ -4,8 +4,9 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { dispatchCheckLoggedIn, readIsLoggedIn } from '@/store/main/accessors';
import { store } from '@/store';
import { dispatchCheckLoggedIn } from '@/store/main/actions';
import { readIsLoggedIn } from '@/store/main/getters';
const startRouteGuard = async (to, from, next) => {
await dispatchCheckLoggedIn(store);

View File

@@ -5,7 +5,7 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { store } from '@/store';
import { readHasAdminAccess } from '@/store/main/accessors';
import { readHasAdminAccess } from '@/store/main/getters';
const routeGuardAdmin = async (to, from, next) => {
if (!readHasAdminAccess(store)) {

View File

@@ -31,7 +31,8 @@
import { Component, Vue } from 'vue-property-decorator';
import { Store } from 'vuex';
import { IUserProfile } from '@/interfaces';
import { readAdminUsers, dispatchGetUsers } from '@/store/admin/accessors';
import { readAdminUsers } from '@/store/admin/getters';
import { dispatchGetUsers } from '@/store/admin/actions';
@Component
export default class AdminUsers extends Vue {

View File

@@ -21,14 +21,17 @@
</v-text-field>
</v-flex>
</v-layout>
<v-btn @click="submit" :disabled="!valid">
Save
</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn @click="cancel">Cancel</v-btn>
</v-form>
</template>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="cancel">Cancel</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn @click="submit" :disabled="!valid">
Save
</v-btn>
</v-card-actions>
</v-card>
</v-container>
</template>
@@ -40,7 +43,7 @@ import {
IUserProfileUpdate,
IUserProfileCreate,
} from '@/interfaces';
import { dispatchGetUsers, dispatchCreateUser } from '@/store/admin/accessors';
import { dispatchGetUsers, dispatchCreateUser } from '@/store/admin/actions';
@Component
export default class CreateUser extends Vue {

View File

@@ -8,37 +8,92 @@
<template>
<div class="my-3">
<div class="subheading secondary--text text--lighten-2">Username</div>
<div class="title primary--text text--darken-2" v-if="user">{{user.email}}</div>
<div class="title primary--text text--darken-2" v-else>-----</div>
<div
class="title primary--text text--darken-2"
v-if="user"
>{{user.email}}</div>
<div
class="title primary--text text--darken-2"
v-else
>-----</div>
</div>
<v-form v-model="valid" ref="form" lazy-validation>
<v-text-field label="Full Name" v-model="fullName" required></v-text-field>
<v-text-field label="E-mail" type="email" v-model="email" v-validate="'required|email'" data-vv-name="email" :error-messages="errors.collect('email')" required></v-text-field>
<v-form
v-model="valid"
ref="form"
lazy-validation
>
<v-text-field
label="Full Name"
v-model="fullName"
required
></v-text-field>
<v-text-field
label="E-mail"
type="email"
v-model="email"
v-validate="'required|email'"
data-vv-name="email"
:error-messages="errors.collect('email')"
required
></v-text-field>
<div class="subheading secondary--text text--lighten-2">User is superuser <span v-if="isSuperuser">(currently is a superuser)</span><span v-else>(currently is not a superuser)</span></div>
<v-checkbox label="Is Superuser" v-model="isSuperuser"></v-checkbox>
<v-checkbox
label="Is Superuser"
v-model="isSuperuser"
></v-checkbox>
<div class="subheading secondary--text text--lighten-2">User is active <span v-if="isActive">(currently active)</span><span v-else>(currently not active)</span></div>
<v-checkbox label="Is Active" v-model="isActive"></v-checkbox>
<v-checkbox
label="Is Active"
v-model="isActive"
></v-checkbox>
<v-layout align-center>
<v-flex shrink>
<v-checkbox v-model="setPassword" class="mr-2"></v-checkbox>
<v-checkbox
v-model="setPassword"
class="mr-2"
></v-checkbox>
</v-flex>
<v-flex>
<v-text-field :disabled="!setPassword" type="password" ref="password" label="Set Password" data-vv-name="password" data-vv-delay="100" v-validate="{required: setPassword}" v-model="password1" :error-messages="errors.first('password')">
<v-text-field
:disabled="!setPassword"
type="password"
ref="password"
label="Set Password"
data-vv-name="password"
data-vv-delay="100"
v-validate="{required: setPassword}"
v-model="password1"
:error-messages="errors.first('password')"
>
</v-text-field>
<v-text-field v-show="setPassword" type="password" label="Confirm Password" data-vv-name="password_confirmation" data-vv-delay="100" data-vv-as="password" v-validate="{required: setPassword, confirmed: 'password'}" v-model="password2" :error-messages="errors.first('password_confirmation')">
<v-text-field
v-show="setPassword"
type="password"
label="Confirm Password"
data-vv-name="password_confirmation"
data-vv-delay="100"
data-vv-as="password"
v-validate="{required: setPassword, confirmed: 'password'}"
v-model="password2"
:error-messages="errors.first('password_confirmation')"
>
</v-text-field>
</v-flex>
</v-layout>
<v-btn @click="submit" :disabled="!valid">
Save
</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn @click="cancel">Cancel</v-btn>
</v-form>
</template>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="cancel">Cancel</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn
@click="submit"
:disabled="!valid"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</v-container>
</template>
@@ -46,11 +101,8 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { IUserProfile, IUserProfileUpdate } from '@/interfaces';
import {
dispatchGetUsers,
dispatchUpdateUser,
readAdminOneUser,
} from '@/store/admin/accessors';
import { dispatchGetUsers, dispatchUpdateUser } from '@/store/admin/actions';
import { readAdminOneUser } from '@/store/admin/getters';
@Component
export default class EditUser extends Vue {

View File

@@ -27,7 +27,7 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { Store } from 'vuex';
import { readUserProfile } from '@/store/main/accessors';
import { readUserProfile } from '@/store/main/getters';
@Component
export default class UserProfile extends Vue {

View File

@@ -6,17 +6,39 @@
</v-card-title>
<v-card-text>
<template>
<v-form v-model="valid" ref="form" lazy-validation>
<v-text-field label="Full Name" v-model="fullName" required></v-text-field>
<v-text-field label="E-mail" type="email" v-model="email" v-validate="'required|email'" data-vv-name="email" :error-messages="errors.collect('email')" required></v-text-field>
<v-btn @click="submit" :disabled="!valid">
Save
</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn @click="cancel">Cancel</v-btn>
<v-form
v-model="valid"
ref="form"
lazy-validation
>
<v-text-field
label="Full Name"
v-model="fullName"
required
></v-text-field>
<v-text-field
label="E-mail"
type="email"
v-model="email"
v-validate="'required|email'"
data-vv-name="email"
:error-messages="errors.collect('email')"
required
></v-text-field>
</v-form>
</template>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="cancel">Cancel</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn
@click="submit"
:disabled="!valid"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</v-container>
</template>
@@ -25,7 +47,8 @@
import { Component, Vue } from 'vue-property-decorator';
import { Store } from 'vuex';
import { IUserProfileUpdate } from '@/interfaces';
import { dispatchUpdateUserProfile, readUserProfile } from '@/store/main/accessors';
import { readUserProfile } from '@/store/main/getters';
import { dispatchUpdateUserProfile } from '@/store/main/actions';
@Component
export default class UserProfileEdit extends Vue {

View File

@@ -34,12 +34,15 @@
v-model="password2"
:error-messages="errors.first('password_confirmation')">
</v-text-field>
<v-btn @click="cancel">Cancel</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn @click="submit" :disabled="!valid">Save</v-btn>
</v-form>
</template>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="cancel">Cancel</v-btn>
<v-btn @click="reset">Reset</v-btn>
<v-btn @click="submit" :disabled="!valid">Save</v-btn>
</v-card-actions>
</v-card>
</v-container>
</template>
@@ -48,7 +51,8 @@
import { Component, Vue } from 'vue-property-decorator';
import { Store } from 'vuex';
import { IUserProfileUpdate } from '@/interfaces';
import { dispatchUpdateUserProfile, readUserProfile } from '@/store/main/accessors';
import { readUserProfile } from '@/store/main/getters';
import { dispatchUpdateUserProfile } from '@/store/main/actions';
@Component
export default class UserProfileEdit extends Vue {