From 4839e57791f7a1b5409564ed9734fa140dd604a4 Mon Sep 17 00:00:00 2001 From: yogesh_gohil Date: Tue, 12 Nov 2019 17:21:06 +0530 Subject: [PATCH] connect mail settings to api --- .../Controllers/EnvironmentController.php | 19 +++++++++- .../assets/js/components/base/BaseInput.vue | 18 ++++++++-- .../assets/js/views/settings/MailConfig.vue | 35 +++++++++++-------- .../js/views/wizard/EmailConfiguration.vue | 3 +- .../assets/plugins/vue-font-awesome/index.js | 4 ++- routes/api.php | 15 ++++++++ 6 files changed, 74 insertions(+), 20 deletions(-) diff --git a/app/Http/Controllers/EnvironmentController.php b/app/Http/Controllers/EnvironmentController.php index 2ce919e9..0ef07962 100755 --- a/app/Http/Controllers/EnvironmentController.php +++ b/app/Http/Controllers/EnvironmentController.php @@ -57,13 +57,30 @@ class EnvironmentController extends Controller */ public function saveMailEnvironment(MailEnvironmentRequest $request) { + $setting = Setting::getSetting('profile_complete'); $results = $this->EnvironmentManager->saveMailVariables($request); - Setting::setSetting('profile_complete', 4); + if ($setting !== 'COMPLETED') + { + Setting::setSetting('profile_complete', 4); + } return response()->json($results); } + public function getMailEnvironment() + { + $MailData = [ + 'mail_driver' => config('mail.driver'), + 'mail_host' => config('mail.host'), + 'mail_port' => config('mail.port'), + 'mail_username' => config('mail.username'), + 'mail_password' => config('mail.password'), + 'mail_encryption' => config('mail.encryption') + ]; + + return response()->json($MailData); + } /** * diff --git a/resources/assets/js/components/base/BaseInput.vue b/resources/assets/js/components/base/BaseInput.vue index 08a85bfd..09936d55 100644 --- a/resources/assets/js/components/base/BaseInput.vue +++ b/resources/assets/js/components/base/BaseInput.vue @@ -4,7 +4,7 @@ +
+ +
@@ -77,12 +80,17 @@ export default { autocomplete: { type: String, default: 'on' + }, + showPassword: { + type: Boolean, + default: false } }, data () { return { inputValue: this.value, - focus: false + focus: false, + showPass: false } }, computed: { @@ -94,6 +102,12 @@ export default { return true } return false + }, + toggleType () { + if (this.showPass) { + return 'text' + } + return this.type } }, watch: { diff --git a/resources/assets/js/views/settings/MailConfig.vue b/resources/assets/js/views/settings/MailConfig.vue index e3f83ac6..418803fa 100644 --- a/resources/assets/js/views/settings/MailConfig.vue +++ b/resources/assets/js/views/settings/MailConfig.vue @@ -66,8 +66,9 @@
@@ -121,7 +122,7 @@ color="theme" type="submit" > - {{ $t('wizard.save_cont') }} + {{ $t('general.save') }}
@@ -141,12 +142,12 @@ export default { data () { return { mailConfigData: { - mail_driver: 'smtp', - mail_host: 'mailtrap.io', - mail_port: 2525, - mail_username: 'cc3c64516febd4', - mail_password: 'e6a0176301f587', - mail_encryption: 'tls' + mail_driver: '', + mail_host: '', + mail_port: null, + mail_username: '', + mail_password: '', + mail_encryption: '' }, loading: false, mail_drivers: [] @@ -176,18 +177,22 @@ export default { } }, mounted () { - // this.getMailDrivers() + this.loadData() }, methods: { - async getMailDrivers () { + async loadData () { this.loading = true - let response = await window.axios.get('/api/admin/onboarding/environment/mail') + let mailDrivers = await window.axios.get('/api/settings/environment/mail') + let mailData = await window.axios.get('/api/settings/environment/mail-env') - if (response.data) { - this.mail_drivers = response.data - this.loading = false + if (mailDrivers.data) { + this.mail_drivers = mailDrivers.data } + if (mailData.data) { + this.mailConfigData = mailData.data + } + this.loading = false }, async saveEmailConfig () { this.$v.mailConfigData.$touch() @@ -196,7 +201,7 @@ export default { } this.loading = true try { - let response = await window.axios.post('/api/admin/onboarding/environment/mail', this.mailConfigData) + let response = await window.axios.post('/api/settings/environment/mail', this.mailConfigData) if (response.data.success) { window.toastr['success'](this.$t('wizard.success.' + response.data.success)) } else { diff --git a/resources/assets/js/views/wizard/EmailConfiguration.vue b/resources/assets/js/views/wizard/EmailConfiguration.vue index f90c6a04..ecc92ad5 100644 --- a/resources/assets/js/views/wizard/EmailConfiguration.vue +++ b/resources/assets/js/views/wizard/EmailConfiguration.vue @@ -61,7 +61,8 @@ diff --git a/resources/assets/plugins/vue-font-awesome/index.js b/resources/assets/plugins/vue-font-awesome/index.js index fd85606a..f2cfac9b 100644 --- a/resources/assets/plugins/vue-font-awesome/index.js +++ b/resources/assets/plugins/vue-font-awesome/index.js @@ -50,7 +50,8 @@ import { faShare, faEllipsisH, faCopy, - faPaperPlane + faPaperPlane, + faEyeSlash } from '@fortawesome/free-solid-svg-icons' import { far } from '@fortawesome/free-regular-svg-icons' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' @@ -108,6 +109,7 @@ library.add( faFilePdf, faEnvelope, faEye, + faEyeSlash, faShare, faEllipsisH, faCopy, diff --git a/routes/api.php b/routes/api.php index 4fa230ff..6fca466d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -323,6 +323,21 @@ Route::group(['middleware' => 'api'], function () { 'uses' => 'CompanyController@updateSetting' ]); + Route::get('/environment/mail', [ + 'as' => 'admin.environment.mail', + 'uses' => 'EnvironmentController@getMailDrivers' + ]); + + Route::get('/environment/mail-env', [ + 'as' => 'admin.mail.env', + 'uses' => 'EnvironmentController@getMailEnvironment' + ]); + + Route::post('/environment/mail', [ + 'as' => 'admin.environment.mail.save', + 'uses' => 'EnvironmentController@saveMailEnvironment' + ]); + }); });