mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
add validation on installation wizard
This commit is contained in:
@ -35,9 +35,7 @@ class EnvironmentController extends Controller
|
|||||||
{
|
{
|
||||||
$results = $this->EnvironmentManager->saveDatabaseVariables($request);
|
$results = $this->EnvironmentManager->saveDatabaseVariables($request);
|
||||||
|
|
||||||
|
|
||||||
if(array_key_exists("success", $results)) {
|
if(array_key_exists("success", $results)) {
|
||||||
|
|
||||||
Artisan::call('config:clear');
|
Artisan::call('config:clear');
|
||||||
Artisan::call('migrate --seed');
|
Artisan::call('migrate --seed');
|
||||||
Artisan::call('migrate', ['--path' => 'vendor/laravel/passport/database/migrations']);
|
Artisan::call('migrate', ['--path' => 'vendor/laravel/passport/database/migrations']);
|
||||||
|
|||||||
@ -203,7 +203,7 @@ class OnboardingController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting::setSetting('version','1.0.0');
|
Setting::setSetting('version', config('crater.version'));
|
||||||
|
|
||||||
Artisan::call('passport:install --force');
|
Artisan::call('passport:install --force');
|
||||||
|
|
||||||
|
|||||||
@ -49,12 +49,20 @@ class EnvironmentManager
|
|||||||
'DB_PASSWORD='.$request->database_password."\n\n";
|
'DB_PASSWORD='.$request->database_password."\n\n";
|
||||||
|
|
||||||
if (! $this->checkDatabaseConnection($request)) {
|
if (! $this->checkDatabaseConnection($request)) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'error' => 'connection_failed'
|
'error' => 'connection_failed'
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
if(count(DB::connection()->select('SHOW TABLES'))) {
|
||||||
|
return [
|
||||||
|
'error' => 'database_should_be_empty'
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
file_put_contents($this->envPath, str_replace(
|
file_put_contents($this->envPath, str_replace(
|
||||||
$oldDatabaseData,
|
$oldDatabaseData,
|
||||||
$newDatabaseData,
|
$newDatabaseData,
|
||||||
@ -101,7 +109,7 @@ class EnvironmentManager
|
|||||||
'MAIL_USERNAME='.$request->mail_username."\n".
|
'MAIL_USERNAME='.$request->mail_username."\n".
|
||||||
'MAIL_PASSWORD='.$request->mail_password."\n".
|
'MAIL_PASSWORD='.$request->mail_password."\n".
|
||||||
'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n";
|
'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n";
|
||||||
// dd($newMailData);
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
file_put_contents($this->envPath, str_replace(
|
file_put_contents($this->envPath, str_replace(
|
||||||
|
|||||||
14
config/crater.php
Normal file
14
config/crater.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Crater Requirements
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'version' => '1.0.0',
|
||||||
|
|
||||||
|
];
|
||||||
@ -1,9 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<button :type="type" :class="btnClass" :disabled="disabled" @click="handleClick">
|
<button
|
||||||
<font-awesome-icon v-if="icon && !loading && !rightIcon" :class="iconClass" :icon="icon" class="vue-icon icon-left" />
|
:type="type"
|
||||||
<font-awesome-icon v-if="loading" :class="iconClass" icon="spinner" class="fa-spin"/>
|
:class="btnClass"
|
||||||
|
:disabled="disabled || loading"
|
||||||
|
@click="handleClick"
|
||||||
|
>
|
||||||
|
<font-awesome-icon
|
||||||
|
v-if="icon && !loading && !rightIcon"
|
||||||
|
:class="iconClass"
|
||||||
|
:icon="icon"
|
||||||
|
class="vue-icon icon-left"
|
||||||
|
/>
|
||||||
|
<font-awesome-icon
|
||||||
|
v-if="loading"
|
||||||
|
:class="iconClass"
|
||||||
|
icon="spinner"
|
||||||
|
class="fa-spin"
|
||||||
|
/>
|
||||||
<slot />
|
<slot />
|
||||||
<font-awesome-icon v-if="icon && !loading && rightIcon" :class="iconClass" :icon="icon" class="vue-icon icon-right" />
|
<font-awesome-icon
|
||||||
|
v-if="icon && !loading && rightIcon"
|
||||||
|
:class="iconClass"
|
||||||
|
:icon="icon"
|
||||||
|
class="vue-icon icon-right"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@ -740,7 +740,8 @@ export default {
|
|||||||
migrate_failed: 'Migrate Failed',
|
migrate_failed: 'Migrate Failed',
|
||||||
database_variables_save_error: 'Unable to connect to the DB with Provided Values.',
|
database_variables_save_error: 'Unable to connect to the DB with Provided Values.',
|
||||||
mail_variables_save_error: 'Email configuration failed.',
|
mail_variables_save_error: 'Email configuration failed.',
|
||||||
connection_failed: 'Database Connection Failed'
|
connection_failed: 'Database connection failed',
|
||||||
|
database_should_be_empty: 'Database should be empty'
|
||||||
},
|
},
|
||||||
success: {
|
success: {
|
||||||
mail_variables_save_successfully: 'Email configured successfully',
|
mail_variables_save_successfully: 'Email configured successfully',
|
||||||
|
|||||||
@ -97,7 +97,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label class="form-label">{{ $t('wizard.database.password') }}</label>
|
<label class="form-label">{{ $t('wizard.database.password') }}</label>
|
||||||
<span class="text-danger"> *</span>
|
|
||||||
<base-input
|
<base-input
|
||||||
v-model.trim="databaseData.database_password"
|
v-model.trim="databaseData.database_password"
|
||||||
type="password"
|
type="password"
|
||||||
@ -154,7 +153,7 @@ export default {
|
|||||||
database_name: null,
|
database_name: null,
|
||||||
database_username: null,
|
database_username: null,
|
||||||
database_password: null,
|
database_password: null,
|
||||||
app_url: null
|
app_url: window.location.origin
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
connections: [
|
connections: [
|
||||||
@ -207,8 +206,8 @@ export default {
|
|||||||
}
|
}
|
||||||
this.loading = false
|
this.loading = false
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e.response)
|
||||||
window.toastr['error']('Something went wrong')
|
window.toastr['error'](e.response.data.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@
|
|||||||
<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"
|
||||||
@input="$v.mailConfigData.mail_password.$touch()"
|
@input="$v.mailConfigData.mail_password.$touch()"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -67,8 +67,8 @@ export default {
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
tab: 'step_1',
|
tab: 'step_3',
|
||||||
step: 1
|
step: 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<base-button
|
<base-button
|
||||||
v-if="requirements"
|
v-if="hasNext"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
class="pull-right mt-4"
|
class="pull-right mt-4"
|
||||||
icon="arrow-right"
|
icon="arrow-right"
|
||||||
@ -46,7 +46,7 @@
|
|||||||
{{ $t('wizard.continue') }}
|
{{ $t('wizard.continue') }}
|
||||||
</base-button>
|
</base-button>
|
||||||
<base-button
|
<base-button
|
||||||
v-else
|
v-if="!requirements"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
class="pull-right mt-4"
|
class="pull-right mt-4"
|
||||||
color="theme"
|
color="theme"
|
||||||
@ -74,6 +74,20 @@ export default {
|
|||||||
isShow: true
|
isShow: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
hasNext () {
|
||||||
|
if (this.requirements) {
|
||||||
|
let isRequired = true
|
||||||
|
for (const key in this.requirements) {
|
||||||
|
if (!this.requirements[key]) {
|
||||||
|
isRequired = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.requirements && this.phpSupportInfo.supported && isRequired
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
listToggle () {
|
listToggle () {
|
||||||
this.isShow = !this.isShow
|
this.isShow = !this.isShow
|
||||||
|
|||||||
Reference in New Issue
Block a user