From 88b0bee640122458081780947e7236d8ea6fc094 Mon Sep 17 00:00:00 2001 From: Hossein Date: Sat, 24 Sep 2022 12:14:37 +0330 Subject: [PATCH 1/2] #114, Add env file --- .env.example | 14 +++++++++++++- public/index.html | 4 ++-- src/i18n/i18n.js | 4 ++-- .../Pages/UserPanel/Sections/Footer/Footer.js | 13 +++++++++---- src/store/reducers/globalReducer.js | 2 +- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 6a529f70..e4e48798 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,16 @@ +#UI ENV +REACT_APP_TITLE= +REACT_APP_DESCRIPTION_CONTENT= +#MANIFEST +REACT_APP_MANIFEST_FILE= +#API CONFIG REACT_APP_API_BASE_URL= REACT_APP_CLIENT_ID= REACT_APP_LOGIN_CLIENT_ID= -REACT_APP_CLIENT_SECRET= \ No newline at end of file +REACT_APP_CLIENT_SECRET= +#LANGUAGES +REACT_APP_MULTI_LANGS_SUPPORT= +REACT_APP_PRELOAD_LANG= +REACT_APP_LANGS_SUPPORT= +#DEFAULT THEME +REACT_APP_DEFAULT_THEME= diff --git a/public/index.html b/public/index.html index e5d9c664..a7cd2876 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ - + @@ -33,7 +33,7 @@ - Opex + %REACT_APP_TITLE% diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js index aa260c3e..130cdacc 100644 --- a/src/i18n/i18n.js +++ b/src/i18n/i18n.js @@ -9,8 +9,8 @@ i18n .use(Backend) .use(initReactI18next) .init({ - preload: ["fa"], - fallbackLng: "fa", + preload: [process.env.REACT_APP_PRELOAD_LANG], + fallbackLng: process.env.REACT_APP_PRELOAD_LANG, debug: process.env.NODE_ENV === "development", detection: { order: ["localStorage"], diff --git a/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js b/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js index 1483ee19..e1978ba8 100644 --- a/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js +++ b/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js @@ -61,12 +61,17 @@ const Footer = () => { {t("footer.darkMode")}: dispatch(setThemeInitiate(e.target.checked))} checked={isDark}/> +
- i18n.changeLanguage("fa")}>{t("Languages.Persian")} - i18n.changeLanguage("en")}>{t("Languages.English")} + { + process.env.REACT_APP_MULTI_LANGS_SUPPORT === 'TRUE' && <> + i18n.changeLanguage("fa")}>{t("Languages.Persian")} + i18n.changeLanguage("en")}>{t("Languages.English")} + + }
diff --git a/src/store/reducers/globalReducer.js b/src/store/reducers/globalReducer.js index a8b7c7c7..ac0eb6e3 100644 --- a/src/store/reducers/globalReducer.js +++ b/src/store/reducers/globalReducer.js @@ -1,7 +1,7 @@ import * as actionTypes from "../actions/actionTypes"; const initialState = { - isDark: true, + isDark: process.env.REACT_APP_DEFAULT_THEME === 'DARK', isLoading: true, hasError: false, marketInterval: "24h", From c0fd85736a6aa8e0017539995b948eef15754263 Mon Sep 17 00:00:00 2001 From: Benyamin001 <23664159+Benyamin001@users.noreply.github.com> Date: Mon, 10 Oct 2022 13:16:32 +0330 Subject: [PATCH 2/2] #114,Config Env --- .env.example | 2 ++ Dockerfile | 3 ++- docker-compose.yml | 8 ++++++++ env-map.js | 10 +++++++++- public/locales/en/translation.json | 3 ++- public/locales/fa/translation.json | 3 ++- src/i18n/i18n.js | 4 ++-- src/index.js | 5 +++++ .../Login/components/RegisterForm/RegisterForm.js | 5 ++++- .../Browser/Pages/UserPanel/Sections/Footer/Footer.js | 2 +- src/store/reducers/globalReducer.js | 2 +- 11 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index e4e48798..4d15358c 100644 --- a/.env.example +++ b/.env.example @@ -14,3 +14,5 @@ REACT_APP_PRELOAD_LANG= REACT_APP_LANGS_SUPPORT= #DEFAULT THEME REACT_APP_DEFAULT_THEME= +#SYSTEM_EMAIL +REACT_APP_SYSTEM_EMAIL_ADDRESS= \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9dda0e40..8001b6a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM node:lts-fermium AS build COPY . /web-app WORKDIR /web-app ENV NODE_ENV production +RUN yarn cache clean RUN yarn install --immutable ARG GENERATE_SOURCEMAP='false' ENV GENERATE_SOURCEMAP $GENERATE_SOURCEMAP @@ -13,4 +14,4 @@ COPY --from=build /web-app/build /var/www/opex/html WORKDIR /var/www/opex/html COPY env-map.js . CMD cat env-map.js | envsubst > env.js && nginx -g "daemon off;" -EXPOSE 80 +EXPOSE 80 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index bb530d00..fadf22f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,9 +4,17 @@ services: image: ghcr.io/opexdev/web-app environment: - ENV=$WEB_APP_ENV + - APP_TITLE=$WEB_APP_TITLE + - DESCRIPTION=$WEB_APP_DESCRIPTION - API_BASE_URL=$API_BASE_URL - CLIENT_ID=$CLIENT_ID + - LOGIN_CLIENT_ID=$CLIENT_LOGIN_ID - CLIENT_SECRET=$CLIENT_SECRET + - MULTI_LANGS_SUPPORT=$MULTI_LANGS_SUPPORT + - PRELOAD_LANG=$PRELOAD_LANG + - LANGS_SUPPORT=$LANGS_SUPPORT + - DEFAULT_THEME=$DEFAULT_THEME + - REGISTER_EMAIL_ADDRESS=$REGISTER_EMAIL_ADDRESS networks: - default deploy: diff --git a/env-map.js b/env-map.js index 3b469afa..461a485c 100644 --- a/env-map.js +++ b/env-map.js @@ -1,6 +1,14 @@ window.env = { REACT_APP_ENV: "$ENV", + REACT_APP_TITLE: "$APP_TITLE", + REACT_APP_DESCRIPTION_CONTENT: "$DESCRIPTION", REACT_APP_API_BASE_URL: "$API_BASE_URL", + REACT_APP_LOGIN_CLIENT_ID: "$CLIENT_ID", REACT_APP_CLIENT_ID: "$CLIENT_ID", - REACT_APP_CLIENT_SECRET: "$CLIENT_SECRET" + REACT_APP_CLIENT_SECRET: "$CLIENT_SECRET", + REACT_APP_MULTI_LANGS_SUPPORT : "$MULTI_LANGS_SUPPORT", + REACT_APP_PRELOAD_LANG : "$PRELOAD_LANG", + REACT_APP_LANGS_SUPPORT : "$LANGS_SUPPORT", + REACT_APP_DEFAULT_THEME : "$DEFAULT_THEME", + REACT_APP_SYSTEM_EMAIL_ADDRESS : "$REGISTER_EMAIL_ADDRESS", } \ No newline at end of file diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 9076006c..65041b88 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -482,7 +482,7 @@ "registerFinished": "Registration completed successfully!", "forgetPasswordFinished": "Password recovery request sent successfully!", "registerFinishedGoToMail": "Please go to {{email}} inbox to complete the registration.", - "registerFinishedSpamMail": "Email sent from for.demo.purpose.only@opex.dev may be in your spam folder!", + "registerFinishedSpamMail": "Email sent from {{email}} may be in your spam folder!", "register": "Register", "wrongEmail": "The entered email is invalid!", "emptyEmail": "Enter your email.", @@ -500,6 +500,7 @@ "minCaptcha": "Captcha must be 5 characters!", "emptyCaptcha": "Captcha required!", "forgetPassServerError": "Error recovering password, try again!", + "UserAlreadyExists": "User with this email is already registered", "forgetPassEmailForgetError": "Email format is incorrect!" }, "userPage": { diff --git a/public/locales/fa/translation.json b/public/locales/fa/translation.json index e45711b3..4d2f6010 100644 --- a/public/locales/fa/translation.json +++ b/public/locales/fa/translation.json @@ -482,7 +482,7 @@ "registerFinished": "ثبت نام با موفقیت انجام شد.", "forgetPasswordFinished": "درخواست بازیابی رمز عبور با موفقیت ارسال شد.", "registerFinishedGoToMail": "برای تکمیل ثبت نام به {{email}} مراجعه فرمایید.", - "registerFinishedSpamMail": "ایمیل دریافتی از آدرس for.demo.purpose.only@opex.dev ممکن است در بخش spam باشد.", + "registerFinishedSpamMail": "ایمیل دریافتی از آدرس {{email}} ممکن است در بخش spam باشد.", "register": "ثبت نام", "wrongEmail": "ایمیل وارد شده معتبر نیست.", "emptyEmail": "ایمیل را وارد کنید.", @@ -500,6 +500,7 @@ "minCaptcha": "Captcha باید ۵ کاراکتر باشد!", "emptyCaptcha": "وارد کردن Captcha الزامی است", "forgetPassServerError": "خطا در بازیابی رمز، دوباره تلاش کنید", + "UserAlreadyExists": "ایمل واردشده تکراری است", "forgetPassEmailForgetError": "فرمت ایمیل صحیح نیست." }, "userPage": { diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js index 130cdacc..e551c12b 100644 --- a/src/i18n/i18n.js +++ b/src/i18n/i18n.js @@ -9,8 +9,8 @@ i18n .use(Backend) .use(initReactI18next) .init({ - preload: [process.env.REACT_APP_PRELOAD_LANG], - fallbackLng: process.env.REACT_APP_PRELOAD_LANG, + preload: [window.env.REACT_APP_PRELOAD_LANG], + fallbackLng: window.env.REACT_APP_PRELOAD_LANG, debug: process.env.NODE_ENV === "development", detection: { order: ["localStorage"], diff --git a/src/index.js b/src/index.js index 0c5720c2..1dd0befa 100644 --- a/src/index.js +++ b/src/index.js @@ -25,6 +25,11 @@ const rootReducer = combineReducers({ auth: authReducer, }); +//add custom title & meta +const meta = document.getElementsByTagName('meta') +document.title = window.env.REACT_APP_TITLE; +meta.description.content = window.env.REACT_APP_DESCRIPTION_CONTENT + /** * Base URL of the website. * diff --git a/src/main/Browser/Pages/Login/components/RegisterForm/RegisterForm.js b/src/main/Browser/Pages/Login/components/RegisterForm/RegisterForm.js index 6415537b..daf39fbf 100644 --- a/src/main/Browser/Pages/Login/components/RegisterForm/RegisterForm.js +++ b/src/main/Browser/Pages/Login/components/RegisterForm/RegisterForm.js @@ -74,7 +74,10 @@ const RegisterForm = () => { }} /> - {t('login.registerFinishedSpamMail')} + } diff --git a/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js b/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js index e1978ba8..66a5dddb 100644 --- a/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js +++ b/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js @@ -65,7 +65,7 @@ const Footer = () => {
{ - process.env.REACT_APP_MULTI_LANGS_SUPPORT === 'TRUE' && <> + window.env.REACT_APP_MULTI_LANGS_SUPPORT === 'TRUE' && <> i18n.changeLanguage("fa")}>{t("Languages.Persian")}