mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 13:41:09 -04:00 
			
		
		
		
	Merge branch 'mail-settings' into 'master'
connect mail settings to api See merge request mohit.panjvani/crater-web!7
This commit is contained in:
		| @ -57,13 +57,30 @@ class EnvironmentController extends Controller | |||||||
|      */ |      */ | ||||||
|     public function saveMailEnvironment(MailEnvironmentRequest $request) |     public function saveMailEnvironment(MailEnvironmentRequest $request) | ||||||
|     { |     { | ||||||
|  |         $setting = Setting::getSetting('profile_complete'); | ||||||
|         $results = $this->EnvironmentManager->saveMailVariables($request); |         $results = $this->EnvironmentManager->saveMailVariables($request); | ||||||
|  |  | ||||||
|         Setting::setSetting('profile_complete', 4); |         if ($setting !== 'COMPLETED') | ||||||
|  |         { | ||||||
|  |             Setting::setSetting('profile_complete', 4); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         return response()->json($results); |         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); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * |      * | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ | |||||||
|     <input |     <input | ||||||
|       ref="baseInput" |       ref="baseInput" | ||||||
|       v-model="inputValue" |       v-model="inputValue" | ||||||
|       :type="type" |       :type="toggleType" | ||||||
|       :disabled="disabled" |       :disabled="disabled" | ||||||
|       :readonly="readOnly" |       :readonly="readOnly" | ||||||
|       :name="name" |       :name="name" | ||||||
| @ -19,6 +19,9 @@ | |||||||
|       @keydown="handleKeyDownEnter" |       @keydown="handleKeyDownEnter" | ||||||
|       @blur="handleFocusOut" |       @blur="handleFocusOut" | ||||||
|     > |     > | ||||||
|  |     <div v-if="showPassword && isAlignLeftIcon" style="cursor: pointer" @click="showPass = !showPass" > | ||||||
|  |       <font-awesome-icon :icon="!showPass ?'eye-slash': 'eye'" class="right-icon" /> | ||||||
|  |     </div> | ||||||
|     <font-awesome-icon v-if="icon && !isAlignLeftIcon" :icon="icon" class="right-icon" /> |     <font-awesome-icon v-if="icon && !isAlignLeftIcon" :icon="icon" class="right-icon" /> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| @ -77,12 +80,17 @@ export default { | |||||||
|     autocomplete: { |     autocomplete: { | ||||||
|       type: String, |       type: String, | ||||||
|       default: 'on' |       default: 'on' | ||||||
|  |     }, | ||||||
|  |     showPassword: { | ||||||
|  |       type: Boolean, | ||||||
|  |       default: false | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   data () { |   data () { | ||||||
|     return { |     return { | ||||||
|       inputValue: this.value, |       inputValue: this.value, | ||||||
|       focus: false |       focus: false, | ||||||
|  |       showPass: false | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   computed: { |   computed: { | ||||||
| @ -94,6 +102,12 @@ export default { | |||||||
|         return true |         return true | ||||||
|       } |       } | ||||||
|       return false |       return false | ||||||
|  |     }, | ||||||
|  |     toggleType () { | ||||||
|  |       if (this.showPass) { | ||||||
|  |         return 'text' | ||||||
|  |       } | ||||||
|  |       return this.type | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   watch: { |   watch: { | ||||||
|  | |||||||
| @ -66,8 +66,9 @@ | |||||||
|             <base-input |             <base-input | ||||||
|               :invalid="$v.mailConfigData.mail_password.$error" |               :invalid="$v.mailConfigData.mail_password.$error" | ||||||
|               v-model.trim="mailConfigData.mail_password" |               v-model.trim="mailConfigData.mail_password" | ||||||
|               type="mail_password" |               type="password" | ||||||
|               name="name" |               name="name" | ||||||
|  |               show-password | ||||||
|               @input="$v.mailConfigData.mail_password.$touch()" |               @input="$v.mailConfigData.mail_password.$touch()" | ||||||
|             /> |             /> | ||||||
|             <div v-if="$v.mailConfigData.mail_password.$error"> |             <div v-if="$v.mailConfigData.mail_password.$error"> | ||||||
| @ -141,12 +142,12 @@ export default { | |||||||
|   data () { |   data () { | ||||||
|     return { |     return { | ||||||
|       mailConfigData: { |       mailConfigData: { | ||||||
|         mail_driver: 'smtp', |         mail_driver: '', | ||||||
|         mail_host: 'mailtrap.io', |         mail_host: '', | ||||||
|         mail_port: 2525, |         mail_port: null, | ||||||
|         mail_username: 'cc3c64516febd4', |         mail_username: '', | ||||||
|         mail_password: 'e6a0176301f587', |         mail_password: '', | ||||||
|         mail_encryption: 'tls' |         mail_encryption: '' | ||||||
|       }, |       }, | ||||||
|       loading: false, |       loading: false, | ||||||
|       mail_drivers: [] |       mail_drivers: [] | ||||||
| @ -176,18 +177,22 @@ export default { | |||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   mounted () { |   mounted () { | ||||||
|     // this.getMailDrivers() |     this.loadData() | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|     async getMailDrivers () { |     async loadData () { | ||||||
|       this.loading = true |       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) { |       if (mailDrivers.data) { | ||||||
|         this.mail_drivers = response.data |         this.mail_drivers = mailDrivers.data | ||||||
|         this.loading = false |  | ||||||
|       } |       } | ||||||
|  |       if (mailData.data) { | ||||||
|  |         this.mailConfigData = mailData.data | ||||||
|  |       } | ||||||
|  |       this.loading = false | ||||||
|     }, |     }, | ||||||
|     async saveEmailConfig () { |     async saveEmailConfig () { | ||||||
|       this.$v.mailConfigData.$touch() |       this.$v.mailConfigData.$touch() | ||||||
| @ -196,7 +201,7 @@ export default { | |||||||
|       } |       } | ||||||
|       this.loading = true |       this.loading = true | ||||||
|       try { |       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) { |         if (response.data.success) { | ||||||
|           window.toastr['success'](this.$t('wizard.success.' + response.data.success)) |           window.toastr['success'](this.$t('wizard.success.' + response.data.success)) | ||||||
|         } else { |         } else { | ||||||
|  | |||||||
| @ -61,7 +61,8 @@ | |||||||
|           <base-input |           <base-input | ||||||
|             :invalid="$v.mailConfigData.mail_password.$error" |             :invalid="$v.mailConfigData.mail_password.$error" | ||||||
|             v-model.trim="mailConfigData.mail_password" |             v-model.trim="mailConfigData.mail_password" | ||||||
|             type="mail_password" |             type="password" | ||||||
|  |             show-password | ||||||
|             name="name" |             name="name" | ||||||
|             @input="$v.mailConfigData.mail_password.$touch()" |             @input="$v.mailConfigData.mail_password.$touch()" | ||||||
|           /> |           /> | ||||||
|  | |||||||
| @ -51,6 +51,7 @@ import { | |||||||
|   faEllipsisH, |   faEllipsisH, | ||||||
|   faCopy, |   faCopy, | ||||||
|   faPaperPlane, |   faPaperPlane, | ||||||
|  |   faEyeSlash, | ||||||
|   faSyncAlt |   faSyncAlt | ||||||
| } from '@fortawesome/free-solid-svg-icons' | } from '@fortawesome/free-solid-svg-icons' | ||||||
| import { far } from '@fortawesome/free-regular-svg-icons' | import { far } from '@fortawesome/free-regular-svg-icons' | ||||||
| @ -109,6 +110,7 @@ library.add( | |||||||
|   faFilePdf, |   faFilePdf, | ||||||
|   faEnvelope, |   faEnvelope, | ||||||
|   faEye, |   faEye, | ||||||
|  |   faEyeSlash, | ||||||
|   faShare, |   faShare, | ||||||
|   faEllipsisH, |   faEllipsisH, | ||||||
|   faCopy, |   faCopy, | ||||||
|  | |||||||
| @ -323,6 +323,21 @@ Route::group(['middleware' => 'api'], function () { | |||||||
|                 'uses' => 'CompanyController@updateSetting' |                 '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' | ||||||
|  |             ]); | ||||||
|  |  | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|     }); |     }); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user