From 82945a6c9667829403981852a94b3c77dbbe793e Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 5 Aug 2021 21:43:02 +0200 Subject: [PATCH 01/62] install vue apollo --- frontend/.env.dist | 3 +- frontend/package.json | 3 + frontend/src/config/index.js | 1 + frontend/src/main.js | 12 ++ frontend/src/plugins/dashboard-plugin.js | 3 + frontend/yarn.lock | 185 ++++++++++++++++++++++- 6 files changed, 205 insertions(+), 2 deletions(-) diff --git a/frontend/.env.dist b/frontend/.env.dist index ffe4869fa..62ef359f3 100644 --- a/frontend/.env.dist +++ b/frontend/.env.dist @@ -1,3 +1,4 @@ LOGIN_API_URL=http://localhost/login_api/ COMMUNITY_API_URL=http://localhost/api/ -ALLOW_REGISTER=true \ No newline at end of file +ALLOW_REGISTER=true +GRAPHQL_URI=http://localhost:4000 diff --git a/frontend/package.json b/frontend/package.json index e29c6647c..0288df486 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,6 +17,7 @@ "@babel/preset-env": "^7.13.12", "@vue/cli-plugin-unit-jest": "^4.5.12", "@vue/test-utils": "^1.1.3", + "apollo-boost": "^0.4.9", "axios": "^0.21.1", "babel-core": "^7.0.0-bridge.0", "babel-jest": "^26.6.3", @@ -45,6 +46,7 @@ "flush-promises": "^1.0.2", "fuse.js": "^3.2.0", "google-maps": "^3.2.1", + "graphql": "^15.5.1", "identity-obj-proxy": "^3.0.0", "jest": "^26.6.3", "jest-canvas-mock": "^2.3.1", @@ -59,6 +61,7 @@ "sweetalert2": "^9.5.4", "vee-validate": "^3.4.5", "vue": "^2.6.11", + "vue-apollo": "^3.0.7", "vue-bootstrap-typeahead": "^0.2.6", "vue-chartjs": "^3.5.0", "vue-cli-plugin-i18n": "^1.0.1", diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index db60d2b84..1a4805cdf 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -13,6 +13,7 @@ const environment = { const server = { LOGIN_API_URL: process.env.LOGIN_API_URL || 'http://localhost/login_api/', COMMUNITY_API_URL: process.env.COMMUNITY_API_URL || 'http://localhost/api/', + GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000', } const CONFIG = { diff --git a/frontend/src/main.js b/frontend/src/main.js index 9e1b4c06b..31ccd8de7 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -3,11 +3,22 @@ import DashboardPlugin from './plugins/dashboard-plugin' import App from './App.vue' import i18n from './i18n.js' import { loadAllRules } from './validation-rules' +import ApolloClient from 'apollo-boost' +import VueApollo from 'vue-apollo' +import CONFIG from './config' import { store } from './store/store' import router from './routes/router' +const apolloClient = new ApolloClient({ + uri: CONFIG.GRAPHQL_URI, +}) + +const apolloProvider = new VueApollo({ + defaultClient: apolloClient, +}) + // plugin setup Vue.use(DashboardPlugin) Vue.config.productionTip = false @@ -28,5 +39,6 @@ new Vue({ router, store, i18n, + apolloProvider, render: (h) => h(App), }) diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index b32bb20cd..448675d20 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -25,6 +25,8 @@ import VueMoment from 'vue-moment' import Loading from 'vue-loading-overlay' import 'vue-loading-overlay/dist/vue-loading.css' +import VueApollo from 'vue-apollo' + export default { install(Vue) { Vue.use(GlobalComponents) @@ -38,6 +40,7 @@ export default { Vue.use(VueQrcode) Vue.use(FlatPickr) Vue.use(Loading) + Vue.use(VueApollo) Vue.use(Toasted, { position: 'top-center', duration: 5000, diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 7f689a72c..1e12bd647 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1811,6 +1811,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.31.tgz#72286bd33d137aa0d152d47ec7c1762563d34055" integrity sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g== +"@types/node@>=6": + version "16.4.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.12.tgz#961e3091f263e6345d2d84afab4e047a60b4b11b" + integrity sha512-zxrTNFl9Z8boMJXs6ieqZP0wAhvkdzmHSxTlJabM16cf5G9xBc1uPRH5Bbv2omEDDiM8MzTfqTJXBf0Ba4xFWA== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -1865,6 +1870,11 @@ dependencies: "@types/yargs-parser" "*" +"@types/zen-observable@^0.8.0": + version "0.8.3" + resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.8.3.tgz#781d360c282436494b32fe7d9f7f8e64b3118aa3" + integrity sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw== + "@typescript-eslint/experimental-utils@^4.0.1": version "4.19.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.19.0.tgz#9ca379919906dc72cb0fcd817d6cb5aa2d2054c6" @@ -2349,6 +2359,21 @@ "@webassemblyjs/wast-parser" "1.9.0" "@xtuc/long" "4.2.2" +"@wry/context@^0.4.0": + version "0.4.4" + resolved "https://registry.yarnpkg.com/@wry/context/-/context-0.4.4.tgz#e50f5fa1d6cfaabf2977d1fda5ae91717f8815f8" + integrity sha512-LrKVLove/zw6h2Md/KZyWxIkFM6AoyKp71OqpH9Hiip1csjPVoD3tPxlbQUNxEnHENks3UGgNpSBCAfq9KWuag== + dependencies: + "@types/node" ">=6" + tslib "^1.9.3" + +"@wry/equality@^0.1.2": + version "0.1.11" + resolved "https://registry.yarnpkg.com/@wry/equality/-/equality-0.1.11.tgz#35cb156e4a96695aa81a9ecc4d03787bc17f1790" + integrity sha512-mwEVBDUVODlsQQ5dfuLUS5/Tf7jqUKyhKYHmVi4fPB6bDMOfWvUPJmKgS1Z7Za/sOI3vzWt4+O7yCiL/70MogA== + dependencies: + tslib "^1.9.3" + "@xtuc/ieee754@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" @@ -2587,6 +2612,101 @@ anymatch@^3.0.3, anymatch@~3.1.1: normalize-path "^3.0.0" picomatch "^2.0.4" +apollo-boost@^0.4.9: + version "0.4.9" + resolved "https://registry.yarnpkg.com/apollo-boost/-/apollo-boost-0.4.9.tgz#ab3ba539c2ca944e6fd156583a1b1954b17a6791" + integrity sha512-05y5BKcDaa8w47f8d81UVwKqrAjn8uKLv6QM9fNdldoNzQ+rnOHgFlnrySUZRz9QIT3vPftQkEz2UEASp1Mi5g== + dependencies: + apollo-cache "^1.3.5" + apollo-cache-inmemory "^1.6.6" + apollo-client "^2.6.10" + apollo-link "^1.0.6" + apollo-link-error "^1.0.3" + apollo-link-http "^1.3.1" + graphql-tag "^2.4.2" + ts-invariant "^0.4.0" + tslib "^1.10.0" + +apollo-cache-inmemory@^1.6.6: + version "1.6.6" + resolved "https://registry.yarnpkg.com/apollo-cache-inmemory/-/apollo-cache-inmemory-1.6.6.tgz#56d1f2a463a6b9db32e9fa990af16d2a008206fd" + integrity sha512-L8pToTW/+Xru2FFAhkZ1OA9q4V4nuvfoPecBM34DecAugUZEBhI2Hmpgnzq2hTKZ60LAMrlqiASm0aqAY6F8/A== + dependencies: + apollo-cache "^1.3.5" + apollo-utilities "^1.3.4" + optimism "^0.10.0" + ts-invariant "^0.4.0" + tslib "^1.10.0" + +apollo-cache@1.3.5, apollo-cache@^1.3.5: + version "1.3.5" + resolved "https://registry.yarnpkg.com/apollo-cache/-/apollo-cache-1.3.5.tgz#9dbebfc8dbe8fe7f97ba568a224bca2c5d81f461" + integrity sha512-1XoDy8kJnyWY/i/+gLTEbYLnoiVtS8y7ikBr/IfmML4Qb+CM7dEEbIUOjnY716WqmZ/UpXIxTfJsY7rMcqiCXA== + dependencies: + apollo-utilities "^1.3.4" + tslib "^1.10.0" + +apollo-client@^2.6.10: + version "2.6.10" + resolved "https://registry.yarnpkg.com/apollo-client/-/apollo-client-2.6.10.tgz#86637047b51d940c8eaa771a4ce1b02df16bea6a" + integrity sha512-jiPlMTN6/5CjZpJOkGeUV0mb4zxx33uXWdj/xQCfAMkuNAC3HN7CvYDyMHHEzmcQ5GV12LszWoQ/VlxET24CtA== + dependencies: + "@types/zen-observable" "^0.8.0" + apollo-cache "1.3.5" + apollo-link "^1.0.0" + apollo-utilities "1.3.4" + symbol-observable "^1.0.2" + ts-invariant "^0.4.0" + tslib "^1.10.0" + zen-observable "^0.8.0" + +apollo-link-error@^1.0.3: + version "1.1.13" + resolved "https://registry.yarnpkg.com/apollo-link-error/-/apollo-link-error-1.1.13.tgz#c1a1bb876ffe380802c8df0506a32c33aad284cd" + integrity sha512-jAZOOahJU6bwSqb2ZyskEK1XdgUY9nkmeclCrW7Gddh1uasHVqmoYc4CKdb0/H0Y1J9lvaXKle2Wsw/Zx1AyUg== + dependencies: + apollo-link "^1.2.14" + apollo-link-http-common "^0.2.16" + tslib "^1.9.3" + +apollo-link-http-common@^0.2.16: + version "0.2.16" + resolved "https://registry.yarnpkg.com/apollo-link-http-common/-/apollo-link-http-common-0.2.16.tgz#756749dafc732792c8ca0923f9a40564b7c59ecc" + integrity sha512-2tIhOIrnaF4UbQHf7kjeQA/EmSorB7+HyJIIrUjJOKBgnXwuexi8aMecRlqTIDWcyVXCeqLhUnztMa6bOH/jTg== + dependencies: + apollo-link "^1.2.14" + ts-invariant "^0.4.0" + tslib "^1.9.3" + +apollo-link-http@^1.3.1: + version "1.5.17" + resolved "https://registry.yarnpkg.com/apollo-link-http/-/apollo-link-http-1.5.17.tgz#499e9f1711bf694497f02c51af12d82de5d8d8ba" + integrity sha512-uWcqAotbwDEU/9+Dm9e1/clO7hTB2kQ/94JYcGouBVLjoKmTeJTUPQKcJGpPwUjZcSqgYicbFqQSoJIW0yrFvg== + dependencies: + apollo-link "^1.2.14" + apollo-link-http-common "^0.2.16" + tslib "^1.9.3" + +apollo-link@^1.0.0, apollo-link@^1.0.6, apollo-link@^1.2.14: + version "1.2.14" + resolved "https://registry.yarnpkg.com/apollo-link/-/apollo-link-1.2.14.tgz#3feda4b47f9ebba7f4160bef8b977ba725b684d9" + integrity sha512-p67CMEFP7kOG1JZ0ZkYZwRDa369w5PIjtMjvrQd/HnIV8FRsHRqLqK+oAZQnFa1DDdZtOtHTi+aMIW6EatC2jg== + dependencies: + apollo-utilities "^1.3.0" + ts-invariant "^0.4.0" + tslib "^1.9.3" + zen-observable-ts "^0.8.21" + +apollo-utilities@1.3.4, apollo-utilities@^1.3.0, apollo-utilities@^1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/apollo-utilities/-/apollo-utilities-1.3.4.tgz#6129e438e8be201b6c55b0f13ce49d2c7175c9cf" + integrity sha512-pk2hiWrCXMAy2fRPwEyhvka+mqwzeP60Jr1tRYi5xru+3ko94HI9o6lK0CT33/w4RDlxWchmdhDCrvdr+pHCig== + dependencies: + "@wry/equality" "^0.1.2" + fast-json-stable-stringify "^2.0.0" + ts-invariant "^0.4.0" + tslib "^1.10.0" + aproba@^1.0.3, aproba@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -6796,6 +6916,18 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6 resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== +graphql-tag@^2.4.2: + version "2.12.5" + resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.5.tgz#5cff974a67b417747d05c8d9f5f3cb4495d0db8f" + integrity sha512-5xNhP4063d16Pz3HBtKprutsPrmHZi5IdUGOWRxA2B6VF7BIRGOHZ5WQvDmJXZuPcBg7rYwaFxvQYjqkSdR3TQ== + dependencies: + tslib "^2.1.0" + +graphql@^15.5.1: + version "15.5.1" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.5.1.tgz#f2f84415d8985e7b84731e7f3536f8bb9d383aad" + integrity sha512-FeTRX67T3LoE3LWAxxOlW2K3Bz+rMYAC18rRguK4wgXaTZMiJwSUwDmPFo3UadAKbzirKIg5Qy+sNJXbpPRnQw== + growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" @@ -9979,6 +10111,13 @@ opn@^5.5.0: dependencies: is-wsl "^1.1.0" +optimism@^0.10.0: + version "0.10.3" + resolved "https://registry.yarnpkg.com/optimism/-/optimism-0.10.3.tgz#163268fdc741dea2fb50f300bedda80356445fd7" + integrity sha512-9A5pqGoQk49H6Vhjb9kPgAeeECfUDF6aIICbMDL23kDLStBn1MWk3YvcZ4xWF9CsSf6XEgvRLkXy4xof/56vVw== + dependencies: + "@wry/context" "^0.4.0" + optimist@0.3: version "0.3.7" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.3.7.tgz#c90941ad59e4273328923074d2cf2e7cbc6ec0d9" @@ -12548,6 +12687,11 @@ sweetalert2@^9.5.4: resolved "https://registry.yarnpkg.com/sweetalert2/-/sweetalert2-9.17.2.tgz#7f33ce157a64c303d2ca98863c9a3f437e5f1187" integrity sha512-HkpPZVMYsnhFUBLdy/LvkU9snggKP3VAuSVnPhVXjxdg02lWbFx0W8H3m7A+WMWw2diXZS1wIa4m67XkNxdvew== +symbol-observable@^1.0.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" + integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== + symbol-tree@^3.2.2, symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" @@ -12680,6 +12824,11 @@ throat@^5.0.0: resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b" integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA== +throttle-debounce@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-2.3.0.tgz#fd31865e66502071e411817e241465b3e9c372e2" + integrity sha512-H7oLPV0P7+jgvrk+6mwwwBDmxTaxnu9HMXmloNLXwnNO0ZxZ31Orah2n8lU1eMPvsaowP2CX+USCgyovXfdOFQ== + through2@^2.0.0, through2@~2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" @@ -12853,6 +13002,13 @@ tryer@^1.0.1: resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== +ts-invariant@^0.4.0: + version "0.4.4" + resolved "https://registry.yarnpkg.com/ts-invariant/-/ts-invariant-0.4.4.tgz#97a523518688f93aafad01b0e80eb803eb2abd86" + integrity sha512-uEtWkFM/sdZvRNNDL3Ehu4WVpwaulhwQszV8mrtcdeE8nN00BV9mAmQ88RkrBhFgl9gMgvjJLAQcZbnPXI9mlA== + dependencies: + tslib "^1.9.3" + ts-jest@^24.2.0: version "24.3.0" resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-24.3.0.tgz#b97814e3eab359ea840a1ac112deae68aa440869" @@ -12889,11 +13045,16 @@ tsconfig@^7.0.0: strip-bom "^3.0.0" strip-json-comments "^2.0.0" -tslib@^1.8.1, tslib@^1.9.0: +tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" + integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== + tsutils@^3.17.1: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -13268,6 +13429,15 @@ vm-browserify@^1.0.1: resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== +vue-apollo@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/vue-apollo/-/vue-apollo-3.0.7.tgz#97a031d45641faa4888a6d5a7f71c40834359704" + integrity sha512-EUfIn4cJmoflnDJiSNP8gH4fofIEzd0I2AWnd9nhHB8mddmzIfgSNjIRihDcRB10wypYG1OG0GcU335CFgZRfA== + dependencies: + chalk "^2.4.2" + serialize-javascript "^4.0.0" + throttle-debounce "^2.1.0" + vue-bootstrap-typeahead@^0.2.6: version "0.2.6" resolved "https://registry.yarnpkg.com/vue-bootstrap-typeahead/-/vue-bootstrap-typeahead-0.2.6.tgz#8c1999a00bf4bf9fc906bae3a462482482cbc297" @@ -14019,3 +14189,16 @@ yorkie@^2.0.0: is-ci "^1.0.10" normalize-path "^1.0.0" strip-indent "^2.0.0" + +zen-observable-ts@^0.8.21: + version "0.8.21" + resolved "https://registry.yarnpkg.com/zen-observable-ts/-/zen-observable-ts-0.8.21.tgz#85d0031fbbde1eba3cd07d3ba90da241215f421d" + integrity sha512-Yj3yXweRc8LdRMrCC8nIc4kkjWecPAUVh0TI0OUrWXx6aX790vLcDlWca6I4vsyCGH3LpWxq0dJRcMOFoVqmeg== + dependencies: + tslib "^1.9.3" + zen-observable "^0.8.0" + +zen-observable@^0.8.0: + version "0.8.15" + resolved "https://registry.yarnpkg.com/zen-observable/-/zen-observable-0.8.15.tgz#96415c512d8e3ffd920afd3889604e30b9eaac15" + integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ== From aa7ec7d8be6e19251586453a46d1809f0a13f593 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 5 Aug 2021 23:31:40 +0200 Subject: [PATCH 02/62] login via graphql --- frontend/.env.dist | 2 +- frontend/src/config/index.js | 2 +- frontend/src/graphql/queries.js | 17 ++++++++++++++ frontend/src/views/Pages/Login.spec.js | 31 ++++++++++++++----------- frontend/src/views/Pages/Login.vue | 32 ++++++++++++++++---------- 5 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 frontend/src/graphql/queries.js diff --git a/frontend/.env.dist b/frontend/.env.dist index 62ef359f3..a22b31307 100644 --- a/frontend/.env.dist +++ b/frontend/.env.dist @@ -1,4 +1,4 @@ LOGIN_API_URL=http://localhost/login_api/ COMMUNITY_API_URL=http://localhost/api/ ALLOW_REGISTER=true -GRAPHQL_URI=http://localhost:4000 +GRAPHQL_URI=http://localhost:4000/graphql diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index 1a4805cdf..dd35eb185 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -13,7 +13,7 @@ const environment = { const server = { LOGIN_API_URL: process.env.LOGIN_API_URL || 'http://localhost/login_api/', COMMUNITY_API_URL: process.env.COMMUNITY_API_URL || 'http://localhost/api/', - GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000', + GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000/graphql', } const CONFIG = { diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js new file mode 100644 index 000000000..6a51b3858 --- /dev/null +++ b/frontend/src/graphql/queries.js @@ -0,0 +1,17 @@ +import gql from 'graphql-tag' + +export const login = gql` + query($email: String!, $password: String!) { + login(email: $email, password: $password) { + sessionId + user { + email + firstName + lastName + language + username + description + } + } + } +` diff --git a/frontend/src/views/Pages/Login.spec.js b/frontend/src/views/Pages/Login.spec.js index 8fe428020..7cbe5f003 100644 --- a/frontend/src/views/Pages/Login.spec.js +++ b/frontend/src/views/Pages/Login.spec.js @@ -1,18 +1,13 @@ import { mount, RouterLinkStub } from '@vue/test-utils' import flushPromises from 'flush-promises' -import loginAPI from '../../apis/loginAPI' import Login from './Login' -jest.mock('../../apis/loginAPI') - const localVue = global.localVue -const mockLoginCall = jest.fn() -mockLoginCall.mockReturnValue({ - success: true, - result: { - data: { - session_id: 1, +const loginQueryMock = jest.fn().mockResolvedValue({ + data: { + login: { + sessionId: 1, user: { name: 'Peter Lustig', }, @@ -20,8 +15,6 @@ mockLoginCall.mockReturnValue({ }, }) -loginAPI.login = mockLoginCall - const toastErrorMock = jest.fn() const mockStoreDispach = jest.fn() const mockRouterPush = jest.fn() @@ -52,6 +45,9 @@ describe('Login', () => { $toasted: { error: toastErrorMock, }, + $apollo: { + query: loginQueryMock, + }, } const stubs = { @@ -147,7 +143,14 @@ describe('Login', () => { }) it('calls the API with the given data', () => { - expect(mockLoginCall).toBeCalledWith('user@example.org', '1234') + expect(loginQueryMock).toBeCalledWith( + expect.objectContaining({ + variables: { + email: 'user@example.org', + password: '1234', + }, + }), + ) }) it('creates a spinner', () => { @@ -173,7 +176,9 @@ describe('Login', () => { describe('login fails', () => { beforeEach(() => { - mockLoginCall.mockReturnValue({ success: false }) + loginQueryMock.mockRejectedValue({ + message: 'Ouch!', + }) }) it('hides the spinner', () => { diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue index 6d4b6d6e9..5d1072d45 100755 --- a/frontend/src/views/Pages/Login.vue +++ b/frontend/src/views/Pages/Login.vue @@ -55,10 +55,10 @@ - From 572abb9e3fd581ccb190f23835cb7954e23fa7b2 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 6 Aug 2021 18:28:12 +0200 Subject: [PATCH 04/62] transaction list query in graphql, include decayStartBlock in model, transactionId optional --- backend/src/graphql/models/Decay.ts | 4 ++ backend/src/graphql/models/Transaction.ts | 4 +- .../graphql/resolvers/TransactionResolver.ts | 1 + frontend/src/components/DecayInformation.vue | 25 ++++++----- frontend/src/graphql/queries.js | 31 +++++++++++++ .../src/views/Layout/DashboardLayout_gdd.vue | 44 +++++++++++-------- .../AccountOverview/GddTransactionList.vue | 4 +- 7 files changed, 78 insertions(+), 35 deletions(-) diff --git a/backend/src/graphql/models/Decay.ts b/backend/src/graphql/models/Decay.ts index c6ce85548..e0234f588 100644 --- a/backend/src/graphql/models/Decay.ts +++ b/backend/src/graphql/models/Decay.ts @@ -9,6 +9,7 @@ export class Decay { this.decayStart = json.decay_start this.decayEnd = json.decay_end this.decayDuration = json.decay_duration + this.decayStartBlock = json.decay_start_block } @Field(() => Number) @@ -22,4 +23,7 @@ export class Decay { @Field(() => String, { nullable: true }) decayDuration?: string + + @Field(() => Int, { nullable: true }) + decayStartBlock?: number } diff --git a/backend/src/graphql/models/Transaction.ts b/backend/src/graphql/models/Transaction.ts index fb17866c4..7e1102cce 100644 --- a/backend/src/graphql/models/Transaction.ts +++ b/backend/src/graphql/models/Transaction.ts @@ -43,8 +43,8 @@ export class Transaction { @Field(() => String) memo: string - @Field(() => Number) - transactionId: number + @Field(() => Number, { nullable: true }) + transactionId?: number @Field({ nullable: true }) name?: string diff --git a/backend/src/graphql/resolvers/TransactionResolver.ts b/backend/src/graphql/resolvers/TransactionResolver.ts index a2853f08a..a9e38bdb4 100644 --- a/backend/src/graphql/resolvers/TransactionResolver.ts +++ b/backend/src/graphql/resolvers/TransactionResolver.ts @@ -10,6 +10,7 @@ export class TransactionResolver { async transactionList( @Args() { sessionId, firstPage = 1, items = 25, order = 'DESC' }: TransactionListInput, ): Promise { + const result = await apiGet( `${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`, ) diff --git a/frontend/src/components/DecayInformation.vue b/frontend/src/components/DecayInformation.vue index 81654be94..4a543e573 100644 --- a/frontend/src/components/DecayInformation.vue +++ b/frontend/src/components/DecayInformation.vue @@ -19,16 +19,17 @@ {{ $t('decay.last_transaction') }}
-
+ {{ decay.decayStartBlock }} +
{{ $t('decay.Starting_block_decay') }}
{{ $t('decay.decay_introduced') }} : - {{ $d($moment.unix(decay.decay_start), 'long') }} + {{ $d($moment.unix(decay.decayStart), 'long') }}
- {{ $d($moment.unix(decay.decay_start), 'long') }} + {{ $d($moment.unix(decay.decayStart), 'long') }} {{ $i18n.locale === 'de' ? 'Uhr' : '' }}
@@ -40,7 +41,7 @@ {{ $t('decay.past_time') }}
-
{{ $t('decay.since_introduction') }}
+
{{ $t('decay.since_introduction') }}
{{ duration.years }} {{ $t('decay.year') }}, {{ duration.months }} {{ $t('decay.months') }}, @@ -62,24 +63,24 @@ export default { props: { decay: { balance: '', - decay_duration: '', - decay_start: 0, - decay_end: 0, - decay_start_block: 0, + decayDuration: '', + decayStart: 0, + decayEnd: 0, + decayStartBlock: 0, }, decaytyp: { type: String, default: '' }, }, computed: { decayStartBlockTextShort() { - return this.decay.decay_start_block - ? ' - Startblock Decay am: ' + this.$d(this.$moment.unix(this.decay.decay_start_block)) + return this.decay.decayStartBlock + ? ' - Startblock Decay am: ' + this.$d(this.$moment.unix(this.decay.decayStartBlock)) : '' }, duration() { return this.$moment.duration( this.$moment - .unix(new Date(this.decay.decay_end)) - .diff(this.$moment.unix(new Date(this.decay.decay_start))), + .unix(new Date(this.decay.decayEnd)) + .diff(this.$moment.unix(new Date(this.decay.decayStart))), )._data }, }, diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index e02e7fcdf..5f7d52570 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -20,3 +20,34 @@ export const logout = gql` logout(sessionId: $sessionId) } ` + +export const transactionsQuery = gql` + query($sessionId: Float!, $firstPage: Int = 1, $items: Int = 25, $order: String = "DESC") { + transactionList(sessionId: $sessionId, firstPage: $firstPage, items: $items, order: $order) { + gdtSum + count + balance + decay + decayDate + transactions { + type + balance + decayStart + decayEnd + decayDuration + memo + transactionId + name + email + date + decay { + balance + decayStart + decayEnd + decayDuration + decayStartBlock + } + } + } + } +` diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index 7a04e39ab..8884cd47f 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -66,11 +66,9 @@