From db020da38701c52e46f59c0c187caf00466274c4 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 16:14:39 +0200 Subject: [PATCH 01/53] add commit hash with link to github into frontend --- .env.shell | 1 + deployment/bare_metal/build_frontend.sh | 4 +++- frontend/src/views/Layout/ContentFooter.vue | 5 +++++ frontend/vue.config.js | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .env.shell diff --git a/.env.shell b/.env.shell new file mode 100644 index 000000000..ac6181fc5 --- /dev/null +++ b/.env.shell @@ -0,0 +1 @@ +BUILD_COMMIT="$(git rev-parse HEAD)" \ No newline at end of file diff --git a/deployment/bare_metal/build_frontend.sh b/deployment/bare_metal/build_frontend.sh index fc0feb747..2e7e59381 100755 --- a/deployment/bare_metal/build_frontend.sh +++ b/deployment/bare_metal/build_frontend.sh @@ -2,7 +2,9 @@ # For that to work, node v12.19.0 needs to be installed with nvm for root # or NPM_BIN Path and NVM_DIR must be adjusted -cd /var/www/html/gradido/frontend +cd /var/www/html/gradido +eval "echo \"$(cat .env.shell)\"" > .env +cd frontend NPM_BIN=/root/.nvm/versions/node/v12.19.0/bin/npm diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 09a2418fd..2584747b1 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -15,6 +15,9 @@ App version {{ version }} + + {{ shortHash }} + @@ -59,6 +62,8 @@ export default { return { year: new Date().getFullYear(), version: CONFIG.APP_VERSION, + hash: process.env.VUE_APP_BUILD_COMMIT, + shortHash: process.env.VUE_APP_BUILD_COMMIT.substr(0, 8), } }, } diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 9fffda28c..698aca1de 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,6 +1,8 @@ const path = require('path') const dotenv = require('dotenv-webpack') +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT + // vue.config.js module.exports = { devServer: { From 0413e13ee0efe9a1be979228a3fb425547678be9 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:12:53 +0200 Subject: [PATCH 02/53] add BUILD_COMMIT to test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4606566df..04b004ae3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -297,7 +297,7 @@ jobs: ########################################################################## - name: frontend | Unit tests run: | - docker run -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test + docker run -e BUILD_COMMIT="$(git rev-parse HEAD)" -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test cp -r ~/coverage ./coverage ########################################################################## # COVERAGE REPORT FRONTEND ################################################ From 761bd17290c55fd42632f47d5d9fea5913987680 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:27:51 +0200 Subject: [PATCH 03/53] next try --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04b004ae3..b12e1c152 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: ########################################################################## - name: Frontend | Build `test` image run: | - docker build --target test -t "gradido/frontend:test" frontend/ + docker build -e BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ docker save "gradido/frontend:test" > /tmp/frontend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 From 2937fc7c07c1058bb66f5db34b952e407791574a Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:32:23 +0200 Subject: [PATCH 04/53] replace -e with --build-arg in docker build call --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b12e1c152..f79959234 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: ########################################################################## - name: Frontend | Build `test` image run: | - docker build -e BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ + docker build --build-arg BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ docker save "gradido/frontend:test" > /tmp/frontend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 From e7c1771d2adca5a52afd41cb34bd80f17d868e3a Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:44:44 +0200 Subject: [PATCH 05/53] try with default value --- .github/workflows/test.yml | 4 ++-- frontend/vue.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f79959234..4606566df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: ########################################################################## - name: Frontend | Build `test` image run: | - docker build --build-arg BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ + docker build --target test -t "gradido/frontend:test" frontend/ docker save "gradido/frontend:test" > /tmp/frontend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 @@ -297,7 +297,7 @@ jobs: ########################################################################## - name: frontend | Unit tests run: | - docker run -e BUILD_COMMIT="$(git rev-parse HEAD)" -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test + docker run -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test cp -r ~/coverage ./coverage ########################################################################## # COVERAGE REPORT FRONTEND ################################################ diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 698aca1de..dc406c98a 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT ? process.env.BUILD_COMMIT : '000000000' // vue.config.js module.exports = { From e355271ea80a30026d775354209aa1a9c61a3863 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 7 Sep 2021 11:36:11 +0200 Subject: [PATCH 06/53] update default --- frontend/vue.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/vue.config.js b/frontend/vue.config.js index dc406c98a..5a8495cc2 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT ? process.env.BUILD_COMMIT : '000000000' +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '000000000' // vue.config.js module.exports = { From e24c3e21a689f47ed025498c6d18d62cd64ef645 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 7 Sep 2021 11:48:42 +0200 Subject: [PATCH 07/53] additional zero check for fixing broken tests --- frontend/src/views/Layout/ContentFooter.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 2584747b1..6bf24af23 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -63,7 +63,10 @@ export default { year: new Date().getFullYear(), version: CONFIG.APP_VERSION, hash: process.env.VUE_APP_BUILD_COMMIT, - shortHash: process.env.VUE_APP_BUILD_COMMIT.substr(0, 8), + shortHash: + process.env.VUE_APP_BUILD_COMMIT !== undefined + ? process.env.VUE_APP_BUILD_COMMIT.substr(0, 8) + : '00000000', } }, } From 434fbb6d2f9f93ea4543c4df25ba6e9faf6e14be Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 9 Sep 2021 12:52:54 +0200 Subject: [PATCH 08/53] adding moritz suggestion to don't show the commit hash link if no commit hash was given --- frontend/src/views/Layout/ContentFooter.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 6bf24af23..97c27230f 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -15,7 +15,11 @@ App version {{ version }} - + {{ shortHash }} From 27e99fbd03f256362d81c4132ad0431db7971399 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 9 Sep 2021 13:04:04 +0200 Subject: [PATCH 09/53] make it possible to use additional local .env entries --- .env.local.dist | 1 + deployment/bare_metal/build_frontend.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .env.local.dist diff --git a/.env.local.dist b/.env.local.dist new file mode 100644 index 000000000..951a04b94 --- /dev/null +++ b/.env.local.dist @@ -0,0 +1 @@ +// for local .env entries \ No newline at end of file diff --git a/deployment/bare_metal/build_frontend.sh b/deployment/bare_metal/build_frontend.sh index 2e7e59381..2e968179d 100755 --- a/deployment/bare_metal/build_frontend.sh +++ b/deployment/bare_metal/build_frontend.sh @@ -3,7 +3,8 @@ # or NPM_BIN Path and NVM_DIR must be adjusted cd /var/www/html/gradido -eval "echo \"$(cat .env.shell)\"" > .env +eval "echo \"$(cat .env.local)\"" > .env +eval "echo \"$(cat .env.shell)\"" >> .env cd frontend NPM_BIN=/root/.nvm/versions/node/v12.19.0/bin/npm From a1db1153368a42daf921e3dc5fb8c4a8bf1c0761 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 10 Sep 2021 15:38:05 +0200 Subject: [PATCH 10/53] encapsulate --- frontend/src/config/index.js | 1 + frontend/src/views/Layout/ContentFooter.vue | 7 ++----- frontend/vue.config.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index dd35eb185..fbef2abbb 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -20,6 +20,7 @@ const CONFIG = { ...environment, ...server, APP_VERSION: pkg.version, + COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT, } export default CONFIG diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 97c27230f..c18608545 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -66,11 +66,8 @@ export default { return { year: new Date().getFullYear(), version: CONFIG.APP_VERSION, - hash: process.env.VUE_APP_BUILD_COMMIT, - shortHash: - process.env.VUE_APP_BUILD_COMMIT !== undefined - ? process.env.VUE_APP_BUILD_COMMIT.substr(0, 8) - : '00000000', + hash: CONFIG.COMMIT_HASH, + shortHash: CONFIG.COMMIT_HASH.substr(0, 8), } }, } diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 5a8495cc2..79917948c 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '000000000' +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '00000000' // vue.config.js module.exports = { From b5eaf30ee44a53cf985eff64a26cb32563e3a25a Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 10 Sep 2021 18:05:11 +0200 Subject: [PATCH 11/53] add additional check --- frontend/src/config/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index fbef2abbb..a7807b57c 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -20,7 +20,7 @@ const CONFIG = { ...environment, ...server, APP_VERSION: pkg.version, - COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT, + COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT || '00000000', } export default CONFIG From 6e1b0e8586c4be11aa39ff79f8e4ee7f15f608f0 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 14 Sep 2021 11:23:41 +0200 Subject: [PATCH 12/53] ... --- frontend/src/config/index.js | 8 +++++++- frontend/vue.config.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index a7807b57c..878ed3c55 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -16,11 +16,17 @@ const server = { GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000/graphql', } +// eslint-disable-next-line no-console +console.log('hash: %o', process.env.VUE_APP_BUILD_COMMIT) + const CONFIG = { ...environment, ...server, APP_VERSION: pkg.version, - COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT || '00000000', + COMMIT_HASH: + process.env.VUE_APP_BUILD_COMMIT === 'undefined' + ? '00000000' + : process.env.VUE_APP_BUILD_COMMIT, } export default CONFIG diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 79917948c..698aca1de 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '00000000' +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT // vue.config.js module.exports = { From 980e6e0a1cde1a32efb2f511aa4a4965a239f812 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 16:14:39 +0200 Subject: [PATCH 13/53] add commit hash with link to github into frontend --- .env.shell | 1 + deployment/bare_metal/build_frontend.sh | 4 +++- frontend/src/views/Layout/ContentFooter.vue | 5 +++++ frontend/vue.config.js | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .env.shell diff --git a/.env.shell b/.env.shell new file mode 100644 index 000000000..ac6181fc5 --- /dev/null +++ b/.env.shell @@ -0,0 +1 @@ +BUILD_COMMIT="$(git rev-parse HEAD)" \ No newline at end of file diff --git a/deployment/bare_metal/build_frontend.sh b/deployment/bare_metal/build_frontend.sh index fc0feb747..2e7e59381 100755 --- a/deployment/bare_metal/build_frontend.sh +++ b/deployment/bare_metal/build_frontend.sh @@ -2,7 +2,9 @@ # For that to work, node v12.19.0 needs to be installed with nvm for root # or NPM_BIN Path and NVM_DIR must be adjusted -cd /var/www/html/gradido/frontend +cd /var/www/html/gradido +eval "echo \"$(cat .env.shell)\"" > .env +cd frontend NPM_BIN=/root/.nvm/versions/node/v12.19.0/bin/npm diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 09a2418fd..2584747b1 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -15,6 +15,9 @@ App version {{ version }} + + {{ shortHash }} + @@ -59,6 +62,8 @@ export default { return { year: new Date().getFullYear(), version: CONFIG.APP_VERSION, + hash: process.env.VUE_APP_BUILD_COMMIT, + shortHash: process.env.VUE_APP_BUILD_COMMIT.substr(0, 8), } }, } diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 9fffda28c..698aca1de 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,6 +1,8 @@ const path = require('path') const dotenv = require('dotenv-webpack') +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT + // vue.config.js module.exports = { devServer: { From 2cbe284069e2942f1303f35395eb5f3e71ca21c1 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:12:53 +0200 Subject: [PATCH 14/53] add BUILD_COMMIT to test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4606566df..04b004ae3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -297,7 +297,7 @@ jobs: ########################################################################## - name: frontend | Unit tests run: | - docker run -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test + docker run -e BUILD_COMMIT="$(git rev-parse HEAD)" -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test cp -r ~/coverage ./coverage ########################################################################## # COVERAGE REPORT FRONTEND ################################################ From 49d6d75f6338e5e09b0412aae5ba0d457503f008 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:27:51 +0200 Subject: [PATCH 15/53] next try --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04b004ae3..b12e1c152 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: ########################################################################## - name: Frontend | Build `test` image run: | - docker build --target test -t "gradido/frontend:test" frontend/ + docker build -e BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ docker save "gradido/frontend:test" > /tmp/frontend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 From 97b6ef0ac219349af886ab1951e83cb5558ab887 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:32:23 +0200 Subject: [PATCH 16/53] replace -e with --build-arg in docker build call --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b12e1c152..f79959234 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: ########################################################################## - name: Frontend | Build `test` image run: | - docker build -e BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ + docker build --build-arg BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ docker save "gradido/frontend:test" > /tmp/frontend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 From a29ade293068b76a398f328795b211086952ba15 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 6 Sep 2021 17:44:44 +0200 Subject: [PATCH 17/53] try with default value --- .github/workflows/test.yml | 4 ++-- frontend/vue.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f79959234..4606566df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: ########################################################################## - name: Frontend | Build `test` image run: | - docker build --build-arg BUILD_COMMIT="$(git rev-parse HEAD)" --target test -t "gradido/frontend:test" frontend/ + docker build --target test -t "gradido/frontend:test" frontend/ docker save "gradido/frontend:test" > /tmp/frontend.tar - name: Upload Artifact uses: actions/upload-artifact@v2 @@ -297,7 +297,7 @@ jobs: ########################################################################## - name: frontend | Unit tests run: | - docker run -e BUILD_COMMIT="$(git rev-parse HEAD)" -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test + docker run -v ~/coverage:/app/coverage --rm gradido/frontend:test yarn run test cp -r ~/coverage ./coverage ########################################################################## # COVERAGE REPORT FRONTEND ################################################ diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 698aca1de..dc406c98a 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT ? process.env.BUILD_COMMIT : '000000000' // vue.config.js module.exports = { From d4ca210e8f5d93c604f2513c86460af4fb922b38 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 7 Sep 2021 11:36:11 +0200 Subject: [PATCH 18/53] update default --- frontend/vue.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/vue.config.js b/frontend/vue.config.js index dc406c98a..5a8495cc2 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT ? process.env.BUILD_COMMIT : '000000000' +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '000000000' // vue.config.js module.exports = { From 9787764e6c840a50e497b3803c028e131844438c Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 7 Sep 2021 11:48:42 +0200 Subject: [PATCH 19/53] additional zero check for fixing broken tests --- frontend/src/views/Layout/ContentFooter.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 2584747b1..6bf24af23 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -63,7 +63,10 @@ export default { year: new Date().getFullYear(), version: CONFIG.APP_VERSION, hash: process.env.VUE_APP_BUILD_COMMIT, - shortHash: process.env.VUE_APP_BUILD_COMMIT.substr(0, 8), + shortHash: + process.env.VUE_APP_BUILD_COMMIT !== undefined + ? process.env.VUE_APP_BUILD_COMMIT.substr(0, 8) + : '00000000', } }, } From 47e283ac6599d0e69725decfff5e637592e509db Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 9 Sep 2021 12:52:54 +0200 Subject: [PATCH 20/53] adding moritz suggestion to don't show the commit hash link if no commit hash was given --- frontend/src/views/Layout/ContentFooter.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 6bf24af23..97c27230f 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -15,7 +15,11 @@ App version {{ version }} - + {{ shortHash }} From 6569ec0743eedf415c62189e336a0651083bd8f9 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 9 Sep 2021 13:04:04 +0200 Subject: [PATCH 21/53] make it possible to use additional local .env entries --- .env.local.dist | 1 + deployment/bare_metal/build_frontend.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .env.local.dist diff --git a/.env.local.dist b/.env.local.dist new file mode 100644 index 000000000..951a04b94 --- /dev/null +++ b/.env.local.dist @@ -0,0 +1 @@ +// for local .env entries \ No newline at end of file diff --git a/deployment/bare_metal/build_frontend.sh b/deployment/bare_metal/build_frontend.sh index 2e7e59381..2e968179d 100755 --- a/deployment/bare_metal/build_frontend.sh +++ b/deployment/bare_metal/build_frontend.sh @@ -3,7 +3,8 @@ # or NPM_BIN Path and NVM_DIR must be adjusted cd /var/www/html/gradido -eval "echo \"$(cat .env.shell)\"" > .env +eval "echo \"$(cat .env.local)\"" > .env +eval "echo \"$(cat .env.shell)\"" >> .env cd frontend NPM_BIN=/root/.nvm/versions/node/v12.19.0/bin/npm From abdbbab2ea2503266e69522ccbb04fe99ece2198 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 10 Sep 2021 15:38:05 +0200 Subject: [PATCH 22/53] encapsulate --- frontend/src/config/index.js | 1 + frontend/src/views/Layout/ContentFooter.vue | 7 ++----- frontend/vue.config.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index dd35eb185..fbef2abbb 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -20,6 +20,7 @@ const CONFIG = { ...environment, ...server, APP_VERSION: pkg.version, + COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT, } export default CONFIG diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index 97c27230f..c18608545 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -66,11 +66,8 @@ export default { return { year: new Date().getFullYear(), version: CONFIG.APP_VERSION, - hash: process.env.VUE_APP_BUILD_COMMIT, - shortHash: - process.env.VUE_APP_BUILD_COMMIT !== undefined - ? process.env.VUE_APP_BUILD_COMMIT.substr(0, 8) - : '00000000', + hash: CONFIG.COMMIT_HASH, + shortHash: CONFIG.COMMIT_HASH.substr(0, 8), } }, } diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 5a8495cc2..79917948c 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '000000000' +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '00000000' // vue.config.js module.exports = { From 133a394158a2645d566172865e2df75f0b95dca8 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 10 Sep 2021 18:05:11 +0200 Subject: [PATCH 23/53] add additional check --- frontend/src/config/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index fbef2abbb..a7807b57c 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -20,7 +20,7 @@ const CONFIG = { ...environment, ...server, APP_VERSION: pkg.version, - COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT, + COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT || '00000000', } export default CONFIG From 01cb8fae90d3043d0a625f6a3434e516cfa93e6d Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 14 Sep 2021 11:23:41 +0200 Subject: [PATCH 24/53] ... --- frontend/src/config/index.js | 8 +++++++- frontend/vue.config.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index a7807b57c..878ed3c55 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -16,11 +16,17 @@ const server = { GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000/graphql', } +// eslint-disable-next-line no-console +console.log('hash: %o', process.env.VUE_APP_BUILD_COMMIT) + const CONFIG = { ...environment, ...server, APP_VERSION: pkg.version, - COMMIT_HASH: process.env.VUE_APP_BUILD_COMMIT || '00000000', + COMMIT_HASH: + process.env.VUE_APP_BUILD_COMMIT === 'undefined' + ? '00000000' + : process.env.VUE_APP_BUILD_COMMIT, } export default CONFIG diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 79917948c..698aca1de 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,7 @@ const path = require('path') const dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT || '00000000' +process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT // vue.config.js module.exports = { From 489b62b27a05eae16248e6c352917a0c088909c2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 00:11:56 +0200 Subject: [PATCH 25/53] added .env(docker) to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 02347691f..a5dadd281 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ messages.pot .skeema nbproject .metadata +/.env From 5b6d1b4ca29a4ed6050d78d8afc851ceb8d1094a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 00:32:22 +0200 Subject: [PATCH 26/53] updated yarn lock(?) --- frontend/yarn.lock | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/frontend/yarn.lock b/frontend/yarn.lock index c910ea9de..eff78ada1 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -13576,13 +13576,6 @@ vue-jest@^3.0.5, vue-jest@^3.0.7: tsconfig "^7.0.0" vue-template-es2015-compiler "^1.6.0" -vue-jwt-decode@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/vue-jwt-decode/-/vue-jwt-decode-0.1.0.tgz#f9caf7b9030d5459cc567b1c3117d9d1f291458f" - integrity sha512-4iP0NzYHkAF7G13tYPc/nudk4oNpB8GCVZupc7lekxXok1XKEgefNaGTpDT14g7RKe5H9GaMphPduDj4UVfZwQ== - dependencies: - vue "^2.3.3" - vue-loader@^15.7.0: version "15.9.6" resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.9.6.tgz#f4bb9ae20c3a8370af3ecf09b8126d38ffdb6b8b" @@ -13662,11 +13655,6 @@ vue@^2.2.6, vue@^2.5.17, vue@^2.6.11: resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.12.tgz#f5ebd4fa6bd2869403e29a896aed4904456c9123" integrity sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg== -vue@^2.3.3: - version "2.6.14" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.14.tgz#e51aa5250250d569a3fbad3a8a5a687d6036e235" - integrity sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ== - vuex-persistedstate@^4.0.0-beta.3: version "4.0.0-beta.3" resolved "https://registry.yarnpkg.com/vuex-persistedstate/-/vuex-persistedstate-4.0.0-beta.3.tgz#89dd712de72d28e85cc95467d066002c1405f277" From 871d0fc76df15c98274a9aac18feab919a4a3ede Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 02:36:00 +0200 Subject: [PATCH 27/53] default value for BUILD_COMMIT in .env in frontend, but not active --- frontend/.env.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/.env.dist b/frontend/.env.dist index a22b31307..1252faf5b 100644 --- a/frontend/.env.dist +++ b/frontend/.env.dist @@ -2,3 +2,4 @@ LOGIN_API_URL=http://localhost/login_api/ COMMUNITY_API_URL=http://localhost/api/ ALLOW_REGISTER=true GRAPHQL_URI=http://localhost:4000/graphql +//BUILD_COMMIT=0000000 \ No newline at end of file From f9021a8b2e47b5a7ba3dab62af17b5218cca37b9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 10:19:01 +0200 Subject: [PATCH 28/53] remove .env.local.dist since this is a structure relevant for vue, but this is a docker .env --- .env.local.dist | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .env.local.dist diff --git a/.env.local.dist b/.env.local.dist deleted file mode 100644 index 951a04b94..000000000 --- a/.env.local.dist +++ /dev/null @@ -1 +0,0 @@ -// for local .env entries \ No newline at end of file From 32c69a376065ab8ad8c1d52d782dbe8f731cbfe1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 10:19:28 +0200 Subject: [PATCH 29/53] removed .env.local from eval shell --- deployment/bare_metal/build_frontend.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deployment/bare_metal/build_frontend.sh b/deployment/bare_metal/build_frontend.sh index 2e968179d..2e7e59381 100755 --- a/deployment/bare_metal/build_frontend.sh +++ b/deployment/bare_metal/build_frontend.sh @@ -3,8 +3,7 @@ # or NPM_BIN Path and NVM_DIR must be adjusted cd /var/www/html/gradido -eval "echo \"$(cat .env.local)\"" > .env -eval "echo \"$(cat .env.shell)\"" >> .env +eval "echo \"$(cat .env.shell)\"" > .env cd frontend NPM_BIN=/root/.nvm/versions/node/v12.19.0/bin/npm From 4a2ee3d16207a9a632032aa155568de811d90e4b Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 10:20:00 +0200 Subject: [PATCH 30/53] remove nuxt reference, we do not use nuxt --- docker-compose.override.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 5eb808b99..84906a5a9 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -13,7 +13,6 @@ services: environment: - NODE_ENV="development" # - DEBUG=true - - NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/` volumes: # This makes sure the docker container has its own node modules. # Therefore it is possible to have a different node version on the host machine From 9024534eaca7591866eba404b7ee8d94c91328e9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 10:24:36 +0200 Subject: [PATCH 31/53] restructured config, refactor BUILD_COMMIT --- frontend/src/config/index.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index 878ed3c55..1409db9ad 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -1,13 +1,31 @@ -// ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env) +// ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env). +// The whole contents is exposed to the client // Load Package Details for some default values const pkg = require('../../package') +const version = { + APP_VERSION: pkg.version, + BUILD_COMMIT: + process.env.BUILD_COMMIT || + // the check for undefined is because of a conflict between webpack-dotenv and vue cli env filtering + (process.env.VUE_APP_BUILD_COMMIT !== 'undefined' ? process.env.VUE_APP_BUILD_COMMIT : null) || + null, + // self reference of `version.BUILD_COMMIT` is not possible at this point, hence the duplicate code + BUILD_COMMIT_SHORT: ( + process.env.BUILD_COMMIT || + (process.env.VUE_APP_BUILD_COMMIT !== 'undefined' ? process.env.VUE_APP_BUILD_COMMIT : null) || + '0000000' + ).substr(0, 7), + // unused + // BUILD_DATE: process.env.BUILD_DATE || process.env.VUE_APP_BUILD_DATE || '1970-01-01T00:00:00.00Z', + // BUILD_VERSION: process.env.BUILD_VERSION || process.env.VUE_APP_BUILD_VERSION || '0.0.0.0', +} + const environment = { NODE_ENV: process.env.NODE_ENV, DEBUG: process.env.NODE_ENV !== 'production' || false, PRODUCTION: process.env.NODE_ENV === 'production' || false, - ALLOW_REGISTER: process.env.ALLOW_REGISTER !== 'false', } const server = { @@ -16,17 +34,15 @@ const server = { GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000/graphql', } -// eslint-disable-next-line no-console -console.log('hash: %o', process.env.VUE_APP_BUILD_COMMIT) +const options = { + ALLOW_REGISTER: process.env.ALLOW_REGISTER !== 'false', +} const CONFIG = { + ...version, ...environment, ...server, - APP_VERSION: pkg.version, - COMMIT_HASH: - process.env.VUE_APP_BUILD_COMMIT === 'undefined' - ? '00000000' - : process.env.VUE_APP_BUILD_COMMIT, + ...options, } export default CONFIG From 3eb2e4b5414b4375aa519d2bcb8aef0d35c6d843 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 10:25:41 +0200 Subject: [PATCH 32/53] Contentfooter - brackets - use BUILD_COMMIT and BUILD_COMMIT_SHORT - check for null value instead of 0000000 --- frontend/src/views/Layout/ContentFooter.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index c18608545..4350e3f55 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -16,11 +16,11 @@ App version {{ version }} - {{ shortHash }} + ({{ shortHash }}) @@ -66,8 +66,8 @@ export default { return { year: new Date().getFullYear(), version: CONFIG.APP_VERSION, - hash: CONFIG.COMMIT_HASH, - shortHash: CONFIG.COMMIT_HASH.substr(0, 8), + hash: CONFIG.BUILD_COMMIT, + shortHash: CONFIG.BUILD_COMMIT_SHORT, } }, } From f3e7917d415cd0b6e36a57df385ed1dbcb283bfe Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 10:27:24 +0200 Subject: [PATCH 33/53] remove empty default values and reference the .env file instead --- docker-compose.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 70d36521e..8fdab9f17 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,14 +22,13 @@ services: # Envs used in Dockerfile # - DOCKER_WORKDIR="/app" # - PORT=3000 - - BUILD_DATE - - BUILD_VERSION - - BUILD_COMMIT + # - BUILD_DATE="1970-01-01T00:00:00.00Z" + # - BUILD_VERSION="0.0.0.0" + # - BUILD_COMMIT="0000000" - NODE_ENV="production" - # Application only envs - #- HOST=0.0.0.0 # This is nuxt specific, alternative value is HOST=webapp - #env_file: - # - ./frontend/.env + env_file: + - ./.env + # - ./frontend/.env ######################################################### ## MARIADB ############################################## From 9cf1221040f65415e19114b6e5bda180b2742d7d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 10:28:10 +0200 Subject: [PATCH 34/53] update docker file to properly transmit cli parameters to vue --- frontend/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 5ec90fe81..b222d7f1a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -8,14 +8,18 @@ FROM node:12.19.0-alpine3.10 as base ENV DOCKER_WORKDIR="/app" ## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0 ENV BUILD_DATE="1970-01-01T00:00:00.00Z" +ENV VUE_APP_BUILD_DATE="${BUILD_DATE}" ## We cannot do $(npm run version).${BUILD_NUMBER} here so we default to 0.0.0.0 ENV BUILD_VERSION="0.0.0.0" +ENV VUE_APP_BUILD_VERSION="${BUILD_VERSION}" ## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000 ENV BUILD_COMMIT="0000000" +ENV VUE_APP_BUILD_COMMIT="${BUILD_COMMIT}" ## SET NODE_ENV ENV NODE_ENV="production" ## App relevant Envs ENV PORT="3000" +# TODO ENV VUE_APP_PORT="${PORT}" # Labels LABEL org.label-schema.build-date="${BUILD_DATE}" From f9af5f961f3b48d9c31060c8c00da144d14b127d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 14:30:11 +0200 Subject: [PATCH 35/53] env/process.env working in docker & without --- frontend/Dockerfile | 4 ---- frontend/src/config/index.js | 15 ++------------- frontend/vue.config.js | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b222d7f1a..5ec90fe81 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -8,18 +8,14 @@ FROM node:12.19.0-alpine3.10 as base ENV DOCKER_WORKDIR="/app" ## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0 ENV BUILD_DATE="1970-01-01T00:00:00.00Z" -ENV VUE_APP_BUILD_DATE="${BUILD_DATE}" ## We cannot do $(npm run version).${BUILD_NUMBER} here so we default to 0.0.0.0 ENV BUILD_VERSION="0.0.0.0" -ENV VUE_APP_BUILD_VERSION="${BUILD_VERSION}" ## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000 ENV BUILD_COMMIT="0000000" -ENV VUE_APP_BUILD_COMMIT="${BUILD_COMMIT}" ## SET NODE_ENV ENV NODE_ENV="production" ## App relevant Envs ENV PORT="3000" -# TODO ENV VUE_APP_PORT="${PORT}" # Labels LABEL org.label-schema.build-date="${BUILD_DATE}" diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index 1409db9ad..54c2c7aeb 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -6,20 +6,9 @@ const pkg = require('../../package') const version = { APP_VERSION: pkg.version, - BUILD_COMMIT: - process.env.BUILD_COMMIT || - // the check for undefined is because of a conflict between webpack-dotenv and vue cli env filtering - (process.env.VUE_APP_BUILD_COMMIT !== 'undefined' ? process.env.VUE_APP_BUILD_COMMIT : null) || - null, + BUILD_COMMIT: process.env.BUILD_COMMIT || null, // self reference of `version.BUILD_COMMIT` is not possible at this point, hence the duplicate code - BUILD_COMMIT_SHORT: ( - process.env.BUILD_COMMIT || - (process.env.VUE_APP_BUILD_COMMIT !== 'undefined' ? process.env.VUE_APP_BUILD_COMMIT : null) || - '0000000' - ).substr(0, 7), - // unused - // BUILD_DATE: process.env.BUILD_DATE || process.env.VUE_APP_BUILD_DATE || '1970-01-01T00:00:00.00Z', - // BUILD_VERSION: process.env.BUILD_VERSION || process.env.VUE_APP_BUILD_VERSION || '0.0.0.0', + BUILD_COMMIT_SHORT: (process.env.BUILD_COMMIT || '0000000').substr(0, 7), } const environment = { diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 698aca1de..45903e9cf 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,7 +1,6 @@ const path = require('path') -const dotenv = require('dotenv-webpack') - -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT +const webpack = require('webpack') +const Dotenv = require('dotenv-webpack') // vue.config.js module.exports = { @@ -25,8 +24,17 @@ module.exports = { assets: path.join(__dirname, 'src/assets'), }, }, - // eslint-disable-next-line new-cap - plugins: [new dotenv()], + plugins: [ + new Dotenv(), + new webpack.DefinePlugin({ + // Those are Environment Variables transmitted via Docker + // 'process.env.DOCKER_WORKDIR': JSON.stringify(process.env.DOCKER_WORKDIR), + // 'process.env.BUILD_DATE': JSON.stringify(process.env.BUILD_DATE), + // 'process.env.BUILD_VERSION': JSON.stringify(process.env.BUILD_VERSION), + 'process.env.BUILD_COMMIT': JSON.stringify(process.env.BUILD_COMMIT), + // 'process.env.PORT': JSON.stringify(process.env.PORT), + }), + ], }, css: { // Enable CSS source maps. From afcfe1d913921f06b57c3e6457d2cce4d8b8c790 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 15 Sep 2021 14:47:55 +0200 Subject: [PATCH 36/53] do not reference the .env file at given point - in development mode we will have 0000000 as hash displayed --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8fdab9f17..652daae13 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,8 +26,8 @@ services: # - BUILD_VERSION="0.0.0.0" # - BUILD_COMMIT="0000000" - NODE_ENV="production" - env_file: - - ./.env + # env_file: + # - ./.env # - ./frontend/.env ######################################################### From ba1f3c0fc6d7c57c5ed9cb13a8447edde004f0f9 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 15 Sep 2021 15:06:52 +0200 Subject: [PATCH 37/53] removed old code --- frontend/src/config/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index e372a033f..54c2c7aeb 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -32,10 +32,6 @@ const CONFIG = { ...environment, ...server, ...options, - COMMIT_HASH: - process.env.VUE_APP_BUILD_COMMIT === 'undefined' - ? '00000000' - : process.env.VUE_APP_BUILD_COMMIT, } export default CONFIG From de750e79a2a51167fba7bce07657c4e4e821597f Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 15 Sep 2021 15:13:05 +0200 Subject: [PATCH 38/53] add as env on shell --- deployment/bare_metal/build_frontend.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/bare_metal/build_frontend.sh b/deployment/bare_metal/build_frontend.sh index 2e7e59381..4b3a8a444 100755 --- a/deployment/bare_metal/build_frontend.sh +++ b/deployment/bare_metal/build_frontend.sh @@ -4,6 +4,7 @@ cd /var/www/html/gradido eval "echo \"$(cat .env.shell)\"" > .env +export BUILD_COMMIT="$(git rev-parse HEAD)" cd frontend NPM_BIN=/root/.nvm/versions/node/v12.19.0/bin/npm From 827cdd636f9564a55aede36315a1980a6a2b091f Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 16 Sep 2021 13:01:00 +0200 Subject: [PATCH 39/53] remove old code --- frontend/vue.config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/vue.config.js b/frontend/vue.config.js index fa12f8200..45903e9cf 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -2,8 +2,6 @@ const path = require('path') const webpack = require('webpack') const Dotenv = require('dotenv-webpack') -process.env.VUE_APP_BUILD_COMMIT = process.env.BUILD_COMMIT - // vue.config.js module.exports = { devServer: { From db15a5da4e5ccf64775674e6e3746025ccf2e06a Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 17 Sep 2021 13:19:10 +0200 Subject: [PATCH 40/53] add tests for commit hash --- frontend/src/views/Layout/ContentFooter.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/src/views/Layout/ContentFooter.spec.js b/frontend/src/views/Layout/ContentFooter.spec.js index 8d0c6dfbd..368b6c743 100644 --- a/frontend/src/views/Layout/ContentFooter.spec.js +++ b/frontend/src/views/Layout/ContentFooter.spec.js @@ -59,6 +59,16 @@ describe('ContentFooter', () => { 'https://github.com/gradido/gradido/releases/latest', ) }) + + it('git commit hash and link', async () => { + wrapper.setData({ shortHash: 'ACCEDED' }) + wrapper.setData({ hash: 'ACCEDEDC001D00DC001D00DC001D00DC001CAFA' }) + await wrapper.vm.$nextTick() + expect(wrapper.find('div.copyright').findAll('a').at(2).text()).toEqual('(ACCEDED)') + expect(wrapper.find('div.copyright').findAll('a').at(2).attributes('href')).toEqual( + 'https://github.com/gradido/gradido/commit/ACCEDEDC001D00DC001D00DC001D00DC001CAFA', + ) + }) }) describe('links to gradido.net', () => { From 675917a8c0a2e111731a69c5240bbb739123cd72 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 17 Sep 2021 16:37:39 +0200 Subject: [PATCH 41/53] split test in two --- frontend/src/views/Layout/ContentFooter.spec.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Layout/ContentFooter.spec.js b/frontend/src/views/Layout/ContentFooter.spec.js index 368b6c743..4b360d581 100644 --- a/frontend/src/views/Layout/ContentFooter.spec.js +++ b/frontend/src/views/Layout/ContentFooter.spec.js @@ -60,11 +60,16 @@ describe('ContentFooter', () => { ) }) - it('git commit hash and link', async () => { + it('has last commit hash', async () => { wrapper.setData({ shortHash: 'ACCEDED' }) wrapper.setData({ hash: 'ACCEDEDC001D00DC001D00DC001D00DC001CAFA' }) await wrapper.vm.$nextTick() expect(wrapper.find('div.copyright').findAll('a').at(2).text()).toEqual('(ACCEDED)') + }) + + it('links to last release commit', async () => { + wrapper.setData({ hash: 'ACCEDEDC001D00DC001D00DC001D00DC001CAFA' }) + await wrapper.vm.$nextTick() expect(wrapper.find('div.copyright').findAll('a').at(2).attributes('href')).toEqual( 'https://github.com/gradido/gradido/commit/ACCEDEDC001D00DC001D00DC001D00DC001CAFA', ) From 3286835f44f1d1c45b0111b499030e92b3538a25 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Mon, 20 Sep 2021 11:36:01 +0200 Subject: [PATCH 42/53] mount sql files folder dynamic --- docker-compose.override.yml | 2 ++ skeema/Dockerfile | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 5eb808b99..91dd55297 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -145,6 +145,8 @@ services: - mariadb networks: - internal-net + volumes: + - ./login_server/skeema/gradido_login:/skeema/gradido_login volumes: frontend_node_modules: diff --git a/skeema/Dockerfile b/skeema/Dockerfile index 98bee5812..3c3cabcff 100644 --- a/skeema/Dockerfile +++ b/skeema/Dockerfile @@ -17,7 +17,7 @@ RUN mkdir -p ${DOCKER_WORKDIR} WORKDIR ${DOCKER_WORKDIR} COPY ./skeema/.skeema . -COPY ./login_server/skeema/ . -COPY ./mariadb/.skeema.login ./gradido_login/.skeema +#COPY ./login_server/skeema/ . +COPY ./mariadb/.skeema.login . -CMD skeema push --allow-unsafe \ No newline at end of file +CMD cp .skeema.login ./gradido_login/.skeema && skeema push --allow-unsafe && rm ./gradido_login/.skeema \ No newline at end of file From f0cbed81f3df8fd342f4a5c80659acb74e6b24b6 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 20 Sep 2021 12:22:56 +0200 Subject: [PATCH 43/53] disable auto-resend of not finished transactions on login-server restart --- login_server/src/cpp/ServerConfig.cpp | 19 ++----------------- login_server/src/cpp/ServerConfig.h | 1 + .../src/cpp/model/gradido/Transaction.cpp | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/login_server/src/cpp/ServerConfig.cpp b/login_server/src/cpp/ServerConfig.cpp index 81a7b2511..23cfba76a 100644 --- a/login_server/src/cpp/ServerConfig.cpp +++ b/login_server/src/cpp/ServerConfig.cpp @@ -57,6 +57,7 @@ namespace ServerConfig { int g_FakeLoginSleepTime = 820; std::string g_versionString = ""; bool g_disableEmail = false; + bool g_resendTransactionOnStart = false; ServerSetupType g_ServerSetupType = SERVER_TYPE_PRODUCTION; std::string g_devDefaultGroup = ""; std::string g_gRPCRelayServerFullURL; @@ -259,23 +260,7 @@ namespace ServerConfig { g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_ALLOW_ALL_PASSWORDS); } - - g_gRPCRelayServerFullURL = cfg.getString("grpc.server", ""); - - // unsecure flags - //g_AllowUnsecureFlags - if (cfg.getInt("unsecure.allow_passwort_via_json_request", 0) == 1) { - g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_PASSWORD_REQUESTS); - } - if (cfg.getInt("unsecure.allow_auto_sign_transactions", 0) == 1) { - g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_AUTO_SIGN_TRANSACTIONS); - } - if (cfg.getInt("unsecure.allow_cors_all", 0) == 1) { - g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_CORS_ALL); - } - if (cfg.getInt("unsecure.allow_all_passwords", 0) == 1) { - g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_ALLOW_ALL_PASSWORDS); - } + g_resendTransactionOnStart = cfg.getBool("dev.resend_unfinished_transactions_on_start", false); return true; } diff --git a/login_server/src/cpp/ServerConfig.h b/login_server/src/cpp/ServerConfig.h index a5d4a7a38..7202cd62e 100644 --- a/login_server/src/cpp/ServerConfig.h +++ b/login_server/src/cpp/ServerConfig.h @@ -73,6 +73,7 @@ namespace ServerConfig { extern int g_FakeLoginSleepTime; extern std::string g_versionString; extern bool g_disableEmail; + extern bool g_resendTransactionOnStart; extern ServerSetupType g_ServerSetupType; extern std::string g_devDefaultGroup; extern std::string g_gRPCRelayServerFullURL; diff --git a/login_server/src/cpp/model/gradido/Transaction.cpp b/login_server/src/cpp/model/gradido/Transaction.cpp index 253d7b5f4..2bdbb9410 100644 --- a/login_server/src/cpp/model/gradido/Transaction.cpp +++ b/login_server/src/cpp/model/gradido/Transaction.cpp @@ -204,7 +204,7 @@ namespace model { } } // try not finished but signed transactions again - if (!finished) { + if (!finished && ServerConfig::g_resendTransactionOnStart) { transaction->ifEnoughSignsProceed(nullptr); } From 102fc586e9264965911be4217a597782ff7a1cdc Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 20 Sep 2021 18:51:05 +0200 Subject: [PATCH 44/53] change variable name according to name in config --- login_server/src/cpp/ServerConfig.cpp | 4 ++-- login_server/src/cpp/ServerConfig.h | 2 +- login_server/src/cpp/model/gradido/Transaction.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/login_server/src/cpp/ServerConfig.cpp b/login_server/src/cpp/ServerConfig.cpp index 23cfba76a..081d16768 100644 --- a/login_server/src/cpp/ServerConfig.cpp +++ b/login_server/src/cpp/ServerConfig.cpp @@ -57,7 +57,7 @@ namespace ServerConfig { int g_FakeLoginSleepTime = 820; std::string g_versionString = ""; bool g_disableEmail = false; - bool g_resendTransactionOnStart = false; + bool g_resendUnfinishedTransactionOnStart = false; ServerSetupType g_ServerSetupType = SERVER_TYPE_PRODUCTION; std::string g_devDefaultGroup = ""; std::string g_gRPCRelayServerFullURL; @@ -260,7 +260,7 @@ namespace ServerConfig { g_AllowUnsecureFlags = (AllowUnsecure)(g_AllowUnsecureFlags | UNSECURE_ALLOW_ALL_PASSWORDS); } - g_resendTransactionOnStart = cfg.getBool("dev.resend_unfinished_transactions_on_start", false); + g_resendUnfinishedTransactionOnStart = cfg.getBool("dev.resend_unfinished_transactions_on_start", false); return true; } diff --git a/login_server/src/cpp/ServerConfig.h b/login_server/src/cpp/ServerConfig.h index 7202cd62e..15ad52b2c 100644 --- a/login_server/src/cpp/ServerConfig.h +++ b/login_server/src/cpp/ServerConfig.h @@ -73,7 +73,7 @@ namespace ServerConfig { extern int g_FakeLoginSleepTime; extern std::string g_versionString; extern bool g_disableEmail; - extern bool g_resendTransactionOnStart; + extern bool g_resendUnfinishedTransactionOnStart; extern ServerSetupType g_ServerSetupType; extern std::string g_devDefaultGroup; extern std::string g_gRPCRelayServerFullURL; diff --git a/login_server/src/cpp/model/gradido/Transaction.cpp b/login_server/src/cpp/model/gradido/Transaction.cpp index 2bdbb9410..a1fd5790c 100644 --- a/login_server/src/cpp/model/gradido/Transaction.cpp +++ b/login_server/src/cpp/model/gradido/Transaction.cpp @@ -204,7 +204,7 @@ namespace model { } } // try not finished but signed transactions again - if (!finished && ServerConfig::g_resendTransactionOnStart) { + if (!finished && ServerConfig::g_resendUnfinishedTransactionOnStart) { transaction->ifEnoughSignsProceed(nullptr); } From 39ef88d8e736036912c0219d6bbd8247303c351f Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Mon, 20 Sep 2021 19:21:33 +0200 Subject: [PATCH 45/53] update skeema for working also in test and production --- docker-compose.override.yml | 2 +- docker-compose.yml | 13 +++++++++++++ skeema/Dockerfile | 24 ++++++++++++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 91dd55297..a69ec5645 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -140,7 +140,7 @@ services: build: context: . dockerfile: ./skeema/Dockerfile - target: skeema_run + target: skeema_dev_run depends_on: - mariadb networks: diff --git a/docker-compose.yml b/docker-compose.yml index 70d36521e..09a070ea0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -157,6 +157,19 @@ services: volumes: - ./community_server/config/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini + ######################################################### + ## skeema for updating dbs if changes happend ########### + ######################################################### + skeema: + build: + context: . + dockerfile: ./skeema/Dockerfile + target: skeema_run + depends_on: + - mariadb + networks: + - internal-net + ######################################################### ## GRADIDO NODE v1 ###################################### ######################################################### diff --git a/skeema/Dockerfile b/skeema/Dockerfile index 3c3cabcff..bbc95f2d0 100644 --- a/skeema/Dockerfile +++ b/skeema/Dockerfile @@ -7,7 +7,22 @@ WORKDIR /go/src/github.com/skeema/skeema RUN go install github.com/skeema/skeema@v1.5.3 ######################################################################################################### -# Run skeema +# Run skeema for dev (dynamic) +######################################################################################################### +FROM skeema_build as skeema_dev_run + +ENV DOCKER_WORKDIR="/skeema" + +RUN mkdir -p ${DOCKER_WORKDIR} +WORKDIR ${DOCKER_WORKDIR} + +COPY ./skeema/.skeema . +COPY ./mariadb/.skeema.login . + +CMD cp .skeema.login ./gradido_login/.skeema && skeema push --allow-unsafe && rm ./gradido_login/.skeema + +######################################################################################################### +# Run skeema ######################################################################################################### FROM skeema_build as skeema_run @@ -17,7 +32,8 @@ RUN mkdir -p ${DOCKER_WORKDIR} WORKDIR ${DOCKER_WORKDIR} COPY ./skeema/.skeema . -#COPY ./login_server/skeema/ . -COPY ./mariadb/.skeema.login . +COPY ./login_server/skeema/ . +COPY ./mariadb/.skeema.login ./gradido_login/.skeema + +CMD skeema push --allow-unsafe -CMD cp .skeema.login ./gradido_login/.skeema && skeema push --allow-unsafe && rm ./gradido_login/.skeema \ No newline at end of file From 94424f17a271f92ebdd827380c93debe4355ba2a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 21 Sep 2021 10:24:43 +0200 Subject: [PATCH 46/53] Fixed database tool to read .env config when built. --- database/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/package.json b/database/package.json index 4656dab43..172253cea 100644 --- a/database/package.json +++ b/database/package.json @@ -10,9 +10,9 @@ "scripts": { "build": "tsc --build", "clean": "tsc --build --clean", - "up": "cd build && node src/index.js up", - "down": "cd build && node src/index.js down", - "reset": "cd build && node src/index.js reset", + "up": "node build/src/index.js up", + "down": "node build/src/index.js down", + "reset": "node build/src/index.js reset", "dev_up": "nodemon -w ./ --ext ts --exec ts-node src/index.ts up", "dev_down": "nodemon -w ./ --ext ts --exec ts-node src/index.ts down", "dev_reset": "nodemon -w ./ --ext ts --exec ts-node src/index.ts reset", From cebf92c451fbc5c525019a9102a7a44beecb6e23 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 21 Sep 2021 10:34:56 +0200 Subject: [PATCH 47/53] fixed migrations directory to default to the production version. This is the downside of this patch - the .env file has to be different in dev and production version --- database/.env.dist | 5 ++++- database/src/config/index.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/database/.env.dist b/database/.env.dist index 8488fb1bf..07db5fd17 100644 --- a/database/.env.dist +++ b/database/.env.dist @@ -4,4 +4,7 @@ DB_USER=root DB_PASSWORD= DB_DATABASE=gradido_community MIGRATIONS_TABLE=migrations -MIGRATIONS_DIRECTORY=./migrations/ \ No newline at end of file +// This value is set to the default for the built version. +// Therefore you need to overwrite this when using the dev version +// MIGRATIONS_DIRECTORY=./migrations/ +MIGRATIONS_DIRECTORY=./build/migrations/ \ No newline at end of file diff --git a/database/src/config/index.ts b/database/src/config/index.ts index 908d40311..a6a7a3385 100644 --- a/database/src/config/index.ts +++ b/database/src/config/index.ts @@ -13,7 +13,7 @@ const database = { const migrations = { MIGRATIONS_TABLE: process.env.MIGRATIONS_TABLE || 'migrations', - MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './migrations/', + MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './build/migrations/', } const CONFIG = { ...database, ...migrations } From f9a40be53926270250777e9b732e5b36078680f0 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 21 Sep 2021 19:18:08 +0200 Subject: [PATCH 48/53] use another .env file, else things get too complicated since production and dev .env's are no longer compatible to eachother --- database/.env.dist | 5 +---- database/build/.env.dist | 2 ++ database/package.json | 6 +++--- database/src/config/index.ts | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 database/build/.env.dist diff --git a/database/.env.dist b/database/.env.dist index 07db5fd17..8488fb1bf 100644 --- a/database/.env.dist +++ b/database/.env.dist @@ -4,7 +4,4 @@ DB_USER=root DB_PASSWORD= DB_DATABASE=gradido_community MIGRATIONS_TABLE=migrations -// This value is set to the default for the built version. -// Therefore you need to overwrite this when using the dev version -// MIGRATIONS_DIRECTORY=./migrations/ -MIGRATIONS_DIRECTORY=./build/migrations/ \ No newline at end of file +MIGRATIONS_DIRECTORY=./migrations/ \ No newline at end of file diff --git a/database/build/.env.dist b/database/build/.env.dist new file mode 100644 index 000000000..505546e1b --- /dev/null +++ b/database/build/.env.dist @@ -0,0 +1,2 @@ +// For production you need to put your env file in here. +// Please copy the dist file from the root folder in here and rename it to .env \ No newline at end of file diff --git a/database/package.json b/database/package.json index 172253cea..4656dab43 100644 --- a/database/package.json +++ b/database/package.json @@ -10,9 +10,9 @@ "scripts": { "build": "tsc --build", "clean": "tsc --build --clean", - "up": "node build/src/index.js up", - "down": "node build/src/index.js down", - "reset": "node build/src/index.js reset", + "up": "cd build && node src/index.js up", + "down": "cd build && node src/index.js down", + "reset": "cd build && node src/index.js reset", "dev_up": "nodemon -w ./ --ext ts --exec ts-node src/index.ts up", "dev_down": "nodemon -w ./ --ext ts --exec ts-node src/index.ts down", "dev_reset": "nodemon -w ./ --ext ts --exec ts-node src/index.ts reset", diff --git a/database/src/config/index.ts b/database/src/config/index.ts index a6a7a3385..908d40311 100644 --- a/database/src/config/index.ts +++ b/database/src/config/index.ts @@ -13,7 +13,7 @@ const database = { const migrations = { MIGRATIONS_TABLE: process.env.MIGRATIONS_TABLE || 'migrations', - MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './build/migrations/', + MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './migrations/', } const CONFIG = { ...database, ...migrations } From a404be1cfbc7ec9d70240caf9026b400ae5bb8d9 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 22 Sep 2021 11:02:20 +0200 Subject: [PATCH 49/53] Added Email as parameter for the change language updateUserInfos. --- frontend/src/views/Pages/UserProfile/UserCard_Language.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue index 7bd02cf4c..87a52d1a4 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue @@ -93,6 +93,7 @@ export default { .query({ query: updateUserInfos, variables: { + email: this.$store.email, language: this.$store.state.language, }, }) From 8a5b552a11d1f2a80c9b53fffc82fe1cede96173 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 22 Sep 2021 11:32:46 +0200 Subject: [PATCH 50/53] In case of language switch success change language in store. --- .../views/Pages/UserProfile/UserCard_Language.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue index 87a52d1a4..e0b5c3a72 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue @@ -23,13 +23,13 @@ {{ $t('language') }} - {{ $store.state.language }} + {{ $t(buildLanguage()) }}
- + @@ -93,17 +93,22 @@ export default { .query({ query: updateUserInfos, variables: { - email: this.$store.email, - language: this.$store.state.language, + email: this.$store.state.email, + locale: this.language, }, }) .then(() => { + this.$store.commit('language', this.language) this.cancelEdit() }) .catch((error) => { this.$toasted.error(error.message) }) }, + + buildLanguage() { + return 'languages.' + this.$store.state.language + }, }, } From a0b35dad239cc7b83965401e64b7f1f6339d597d Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 22 Sep 2021 11:36:30 +0200 Subject: [PATCH 51/53] Changed the method name to something a bit more meaningfull. --- frontend/src/views/Pages/UserProfile/UserCard_Language.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue index e0b5c3a72..055441aec 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue @@ -23,7 +23,7 @@ {{ $t('language') }} - {{ $t(buildLanguage()) }} + {{ $t(buildTagFromLanguageString()) }}
@@ -106,7 +106,7 @@ export default { }) }, - buildLanguage() { + buildTagFromLanguageString() { return 'languages.' + this.$store.state.language }, }, From 3ca200bb96b9cc3dcc3a8e6c656e5d0b2df9c11f Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 22 Sep 2021 12:12:28 +0200 Subject: [PATCH 52/53] Added a success message in case where language has been switched. --- frontend/src/locales/de.json | 3 ++- frontend/src/locales/en.json | 3 ++- frontend/src/views/Pages/UserProfile/UserCard_Language.vue | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 851f2a376..5db1c0a82 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -105,7 +105,8 @@ "language": "Sprache", "languages": { "de": "Deutsch", - "en": "English" + "en": "English", + "success": "Deine Sprache wurde erfolgreich geƤndert." }, "login": "Anmeldung", "logout": "Abmelden", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 4edf8e72d..9ca544440 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -105,7 +105,8 @@ "language": "Language", "languages": { "de": "Deutsch", - "en": "English" + "en": "English", + "success": "Your language has been successfully updated." }, "login": "Login", "logout": "Logout", diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue index 055441aec..1bf9a8415 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue @@ -100,6 +100,7 @@ export default { .then(() => { this.$store.commit('language', this.language) this.cancelEdit() + this.$toasted.success(this.$t('languages.success')) }) .catch((error) => { this.$toasted.error(error.message) From 09e87526def054991b354132ee1a2314c7b2b5f1 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 22 Sep 2021 12:29:21 +0200 Subject: [PATCH 53/53] Added a success message for language switch in profile. --- frontend/src/views/Pages/UserProfile/UserCard_Language.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue index 1bf9a8415..d7a059715 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_Language.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_Language.vue @@ -62,6 +62,7 @@