1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Remove mail config from setup

This commit is contained in:
David Bomba 2024-04-08 08:51:33 +10:00
parent 73608fedf4
commit a62302b655
8 changed files with 73 additions and 148 deletions

View File

@ -201,11 +201,12 @@ class SystemHealth
private static function simpleDbCheck(): bool
{
$result = true;
$result = false;
try {
$pdo = DB::connection()->getPdo();
$result = DB::connection()->getPdo();
$result = true;
$result = DB::connection()->getDatabaseName() && strlen(DB::connection()->getDatabaseName()) > 1;
} catch (Exception $e) {
$result = false;
}

View File

@ -1,9 +0,0 @@
import{A as s}from"./index-08e160a7.js";import"./_commonjsHelpers-725317a4.js";/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/class a{constructor(){this.checkDbButton=document.getElementById("test-db-connection"),this.checkDbAlert=document.getElementById("database-response"),this.checkSmtpButton=document.getElementById("test-smtp-connection"),this.checkSmtpAlert=document.getElementById("smtp-response"),this.checkPdfButton=document.getElementById("test-pdf"),this.checkPdfAlert=document.getElementById("test-pdf-response")}handleDatabaseCheck(){let t=document.querySelector("meta[name=setup-db-check]").content,e={};document.querySelector('input[name="db_host"]')&&(e={db_host:document.querySelector('input[name="db_host"]').value,db_port:document.querySelector('input[name="db_port"]').value,db_database:document.querySelector('input[name="db_database"]').value,db_username:document.querySelector('input[name="db_username"]').value,db_password:document.querySelector('input[name="db_password"]').value}),this.checkDbButton.disabled=!0,s.post(t,e).then(c=>this.handleSuccess(this.checkDbAlert,"mail-wrapper")).catch(c=>this.handleFailure(this.checkDbAlert,c.response.data.message)).finally(()=>this.checkDbButton.disabled=!1)}handleSmtpCheck(){let t=document.querySelector("meta[name=setup-email-check]").content,e={mail_driver:document.querySelector('select[name="mail_driver"]').value,mail_name:document.querySelector('input[name="mail_name"]').value,mail_address:document.querySelector('input[name="mail_address"]').value,mail_username:document.querySelector('input[name="mail_username"]').value,mail_host:document.querySelector('input[name="mail_host"]').value,mail_port:document.querySelector('input[name="mail_port"]').value,encryption:document.querySelector('select[name="encryption"]').value,mail_password:document.querySelector('input[name="mail_password"]').value};if(this.checkSmtpButton.disabled=!0,e.mail_driver==="log")return this.handleSuccess(this.checkSmtpAlert,"account-wrapper"),this.handleSuccess(this.checkSmtpAlert,"submit-wrapper"),this.checkSmtpButton.disabled=!1;s.post(t,e).then(c=>{this.handleSuccess(this.checkSmtpAlert,"account-wrapper"),this.handleSuccess(this.checkSmtpAlert,"submit-wrapper")}).catch(c=>this.handleFailure(this.checkSmtpAlert,c.response.data.message)).finally(()=>this.checkSmtpButton.disabled=!1)}handleTestPdfCheck(){let t=document.querySelector("meta[name=setup-pdf-check]").content;this.checkPdfButton.disabled=!0,s.post(t,{}).then(e=>{try{return this.handleSuccess(this.checkPdfAlert,"database-wrapper")}catch{this.handleSuccess(this.checkPdfAlert,"database-wrapper"),this.checkPdfAlert.textContent="Success! PDF was generated succesfully."}}).catch(e=>{console.log(e),this.handleFailure(this.checkPdfAlert)}).finally(()=>this.checkPdfButton.disabled=!1)}handleSuccess(t,e=null){t.classList.remove("alert-failure"),t.innerText="Success!",t.classList.add("alert-success"),e&&(document.getElementById(e).classList.remove("hidden"),document.getElementById(e).scrollIntoView({behavior:"smooth",block:"center"}))}handleFailure(t,e=null){t.classList.remove("alert-success"),t.innerText=e||"Oops, looks like something isn't correct!",t.classList.add("alert-failure")}handle(){this.checkDbButton.addEventListener("click",()=>this.handleDatabaseCheck()),this.checkSmtpButton.addEventListener("click",()=>this.handleSmtpCheck()),this.checkPdfButton.addEventListener("click",()=>this.handleTestPdfCheck())}}new a().handle();

View File

@ -231,7 +231,7 @@
"src": "resources/js/clients/statements/view.js"
},
"resources/js/setup/setup.js": {
"file": "assets/setup-81f58464.js",
"file": "assets/setup-66b6b3c0.js",
"imports": [
"_index-08e160a7.js",
"__commonjsHelpers-725317a4.js"

View File

@ -14,12 +14,6 @@ class Setup {
constructor() {
this.checkDbButton = document.getElementById('test-db-connection');
this.checkDbAlert = document.getElementById('database-response');
this.checkSmtpButton = document.getElementById('test-smtp-connection');
this.checkSmtpAlert = document.getElementById('smtp-response');
this.checkPdfButton = document.getElementById('test-pdf');
this.checkPdfAlert = document.getElementById('test-pdf-response');
}
handleDatabaseCheck() {
@ -42,78 +36,16 @@ class Setup {
this.checkDbButton.disabled = true;
Axios.post(url, data)
.then((response) =>
this.handleSuccess(this.checkDbAlert, 'mail-wrapper')
.then((response) =>{
this.handleSuccess(this.checkDbAlert, 'account-wrapper');
this.handleSuccess(this.checkDbAlert, 'submit-wrapper');
}
)
.catch((e) =>
this.handleFailure(this.checkDbAlert, e.response.data.message)
).finally(() => this.checkDbButton.disabled = false);
}
handleSmtpCheck() {
let url = document.querySelector('meta[name=setup-email-check]').content;
let data = {
mail_driver: document.querySelector('select[name="mail_driver"]')
.value,
mail_name: document.querySelector('input[name="mail_name"]').value,
mail_address: document.querySelector('input[name="mail_address"]')
.value,
mail_username: document.querySelector('input[name="mail_username"]')
.value,
mail_host: document.querySelector('input[name="mail_host"]').value,
mail_port: document.querySelector('input[name="mail_port"]').value,
encryption: document.querySelector('select[name="encryption"]')
.value,
mail_password: document.querySelector('input[name="mail_password"]')
.value,
};
this.checkSmtpButton.disabled = true;
if (data.mail_driver === 'log') {
this.handleSuccess(this.checkSmtpAlert, 'account-wrapper');
this.handleSuccess(this.checkSmtpAlert, 'submit-wrapper');
return (this.checkSmtpButton.disabled = false);
}
Axios.post(url, data)
.then((response) => {
this.handleSuccess(this.checkSmtpAlert, 'account-wrapper');
this.handleSuccess(this.checkSmtpAlert, 'submit-wrapper');
})
.catch((e) =>
this.handleFailure(this.checkSmtpAlert, e.response.data.message)
)
.finally(() => (this.checkSmtpButton.disabled = false));
}
handleTestPdfCheck() {
let url = document.querySelector('meta[name=setup-pdf-check]').content;
this.checkPdfButton.disabled = true;
Axios.post(url, {})
.then((response) => {
try {
//let win = window.open(response.data.url, '_blank');
//win.focus();
return this.handleSuccess(
this.checkPdfAlert,
'database-wrapper'
);
} catch (error) {
this.handleSuccess(this.checkPdfAlert, 'database-wrapper');
this.checkPdfAlert.textContent = `Success! PDF was generated succesfully.`;
}
})
.catch((error) => {
console.log(error);
this.handleFailure(this.checkPdfAlert);
})
.finally(() => (this.checkPdfButton.disabled = false));
}
handleSuccess(element, nextStep = null) {
element.classList.remove('alert-failure');
@ -140,14 +72,6 @@ class Setup {
this.checkDbButton.addEventListener('click', () =>
this.handleDatabaseCheck()
);
this.checkSmtpButton.addEventListener('click', () =>
this.handleSmtpCheck()
);
this.checkPdfButton.addEventListener('click', () =>
this.handleTestPdfCheck()
);
}
}

View File

@ -1,48 +0,0 @@
<div class="bg-white shadow overflow-hidden rounded-lg mt-8">
<div class="px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.application_settings') }}
</h3>
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
{{ ctrans('texts.application_settings_label') }}
</p>
</div>
<div>
<dl>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.url') }}*
</dt>
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input
type="url" class="input w-full" name="url" placeholder="https://example.com"
pattern="https?://.*" size="45" value="{{ old('url', 'https://') }}" required>
<small>(including http:// or https://)</small>
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.https') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="checkbox" class="form-checkbox mr-1" name="https"
{{ old('https') ? 'checked': '' }} checked>
<span>{{ ctrans('texts.require') }}</span>
<span class="text-gray-600 text-xs ml-2">({{ ctrans('texts.recommended_in_production') }})</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.reports') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="checkbox" class="form-checkbox mr-1"
name="send_logs" {{ old('send_logs' ? 'checked': '') }}>
<span>{{ ctrans('texts.send_fail_logs_to_our_server') }}</span>
<a class="button-link mt-1 block" target="_blank" href="https://www.invoiceninja.com/privacy-policy/">Read more
about how we use this.</a>
</dd>
</div>
</dl>
</div>
</div>

View File

@ -1,4 +1,52 @@
<div class="bg-white shadow overflow-hidden rounded-lg mt-6 hidden" id="database-wrapper">
<div class="bg-white shadow overflow-hidden rounded-lg mt-8">
<div class="px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.application_settings') }}
</h3>
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
{{ ctrans('texts.application_settings_label') }}
</p>
</div>
<div>
<dl>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.url') }}*
</dt>
<dd class="text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input
type="url" class="input w-full" name="url" placeholder="https://example.com"
pattern="https?://.*" size="45" value="{{ old('url', 'https://') }}" required>
<small>(including http:// or https://)</small>
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.https') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="checkbox" class="form-checkbox mr-1" name="https"
{{ old('https') ? 'checked': '' }} checked>
<span>{{ ctrans('texts.require') }}</span>
<span class="text-gray-600 text-xs ml-2">({{ ctrans('texts.recommended_in_production') }})</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:flex sm:items-center">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.reports') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<input type="checkbox" class="form-checkbox mr-1"
name="send_logs" {{ old('send_logs' ? 'checked': '') }}>
<span>{{ ctrans('texts.send_fail_logs_to_our_server') }}</span>
<a class="button-link mt-1 block" target="_blank" href="https://www.invoiceninja.com/privacy-policy/">Read more
about how we use this.</a>
</dd>
</div>
</dl>
</div>
</div>
<div class="bg-white shadow overflow-hidden rounded-lg mt-6">
<div class="px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.database_connection') }}

View File

@ -51,7 +51,6 @@
</div>
@endif
@include('setup._application')
@include('setup._database')
@include('setup._account')

View File

@ -158,21 +158,31 @@ Route::get('.env', function () {
Route::fallback(function () {
if (Ninja::isSelfHost() && Account::first()?->set_react_as_default_ap) {
if (Ninja::isSelfHost()) {
$result = false;
try {
$result = DB::connection()->getPdo();
$result = DB::connection()->getDatabaseName();
} catch(\Exception $e) {
$result = false;
}
if(!$result) {
return redirect('/setup');
}
$account = Account::first();
return response()->view('react.index', [
return $account->set_react_as_default_ap ? response()->view('react.index', [
'rc' => request()->input('rc', ''),
'login' => request()->input('login', ''),
'signup' => request()->input('signup', ''),
'report_errors' => $account->report_errors,
'user_agent' => request()->server('HTTP_USER_AGENT'),
])->header('X-Frame-Options', 'SAMEORIGIN', false);
])->header('X-Frame-Options', 'SAMEORIGIN', false) : abort(404);
}
abort(404);
})->middleware('throttle:404');
// Fix me: Move into invite_db middleware group.
})->middleware('throttle:404');