mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
connect mail settings to api
This commit is contained in:
@ -57,13 +57,30 @@ class EnvironmentController extends Controller
|
||||
*/
|
||||
public function saveMailEnvironment(MailEnvironmentRequest $request)
|
||||
{
|
||||
$setting = Setting::getSetting('profile_complete');
|
||||
$results = $this->EnvironmentManager->saveMailVariables($request);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<input
|
||||
ref="baseInput"
|
||||
v-model="inputValue"
|
||||
:type="type"
|
||||
:type="toggleType"
|
||||
:disabled="disabled"
|
||||
:readonly="readOnly"
|
||||
:name="name"
|
||||
@ -19,6 +19,9 @@
|
||||
@keydown="handleKeyDownEnter"
|
||||
@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" />
|
||||
</div>
|
||||
</template>
|
||||
@ -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: {
|
||||
|
||||
@ -66,8 +66,9 @@
|
||||
<base-input
|
||||
:invalid="$v.mailConfigData.mail_password.$error"
|
||||
v-model.trim="mailConfigData.mail_password"
|
||||
type="mail_password"
|
||||
type="password"
|
||||
name="name"
|
||||
show-password
|
||||
@input="$v.mailConfigData.mail_password.$touch()"
|
||||
/>
|
||||
<div v-if="$v.mailConfigData.mail_password.$error">
|
||||
@ -121,7 +122,7 @@
|
||||
color="theme"
|
||||
type="submit"
|
||||
>
|
||||
{{ $t('wizard.save_cont') }}
|
||||
{{ $t('general.save') }}
|
||||
</base-button>
|
||||
</form>
|
||||
</div>
|
||||
@ -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 {
|
||||
|
||||
@ -61,7 +61,8 @@
|
||||
<base-input
|
||||
:invalid="$v.mailConfigData.mail_password.$error"
|
||||
v-model.trim="mailConfigData.mail_password"
|
||||
type="mail_password"
|
||||
type="password"
|
||||
show-password
|
||||
name="name"
|
||||
@input="$v.mailConfigData.mail_password.$touch()"
|
||||
/>
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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'
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user