mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-22 22:37:37 +01:00
feat: ✨ Completata pagina setup
This commit is contained in:
parent
0d53612db1
commit
a65468d124
1
.idea/inspectionProfiles/Project_Default.xml
generated
1
.idea/inspectionProfiles/Project_Default.xml
generated
@ -127,6 +127,7 @@
|
||||
<option name="myCustomValuesEnabled" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="JSXNamespaceValidation" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="MethodShouldBeFinalInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="NpmUsedModulesInstalled" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="PhpCSFixerValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="CODING_STANDARD" value="Custom" />
|
||||
|
1
.idea/osm_rewrite.iml
generated
1
.idea/osm_rewrite.iml
generated
@ -89,6 +89,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-debugbar" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/debug" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/storage" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/akaunting/laravel-setting" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
1
.idea/php.xml
generated
1
.idea/php.xml
generated
@ -116,6 +116,7 @@
|
||||
<path value="$PROJECT_DIR$/vendor/maximebf/debugbar" />
|
||||
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-debugbar" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/debug" />
|
||||
<path value="$PROJECT_DIR$/vendor/akaunting/laravel-setting" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.0">
|
||||
|
@ -9,5 +9,7 @@ use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SetupController extends Controller
|
||||
@ -86,4 +88,33 @@ class SetupController extends Controller
|
||||
'error' => __("L'utente del database non ha i seguenti permessi necessari: ", $requirements),
|
||||
], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo indirizzato al salvataggio della configurazione.
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$text = '<?php return '.var_export(config('database'), true).';';
|
||||
$result = File::put(config_path('database.php'), $text);
|
||||
|
||||
// Errore in caso di fallimento
|
||||
if ($result === false) {
|
||||
$chmodded = File::chmod(config_path('database.php'), 0644);
|
||||
$result = File::put(config_path('database.php'), $text);
|
||||
if ($result === false) {
|
||||
return response()->json([
|
||||
'error' => 'writing',
|
||||
'error_description' => __('Impossibile scrivere il file di configurazione. :action', ['action' => !$chmodded ? 'Controllare i permessi del file config/databasee.php' : '']),
|
||||
], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh della cache sulla configurazione
|
||||
Artisan::call('cache:clear');
|
||||
Artisan::call('config:cache');
|
||||
|
||||
setting($request->only(['timestamp_format', 'date_format', 'time_format', 'locale']));
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
"require": {
|
||||
"php": "^8",
|
||||
"ext-pdo": "*",
|
||||
"akaunting/laravel-setting": "^1.2.7",
|
||||
"fideloper/proxy": "^4",
|
||||
"fruitcake/laravel-cors": "^2",
|
||||
"guzzlehttp/guzzle": "^7",
|
||||
|
127
config/setting.php
Normal file
127
config/setting.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable / Disable auto save
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Auto-save every time the application shuts down
|
||||
|
|
||||
*/
|
||||
'auto_save' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Options for caching. Set whether to enable cache, its key, time to live
|
||||
| in seconds and whether to auto clear after save.
|
||||
|
|
||||
*/
|
||||
'cache' => [
|
||||
'enabled' => false,
|
||||
'key' => 'setting',
|
||||
'ttl' => 3600,
|
||||
'auto_clear' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setting driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Select where to store the settings.
|
||||
|
|
||||
| Supported: "database", "json", "memory"
|
||||
|
|
||||
*/
|
||||
'driver' => 'database',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Options for database driver. Enter which connection to use, null means
|
||||
| the default connection. Set the table and column names.
|
||||
|
|
||||
*/
|
||||
'database' => [
|
||||
'connection' => null,
|
||||
'table' => 'settings',
|
||||
'key' => 'key',
|
||||
'value' => 'value',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JSON driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Options for json driver. Enter the full path to the .json file.
|
||||
|
|
||||
*/
|
||||
'json' => [
|
||||
'path' => storage_path().'/settings.json',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Override application config values
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If defined, settings package will override these config values.
|
||||
|
|
||||
| Sample:
|
||||
| "app.locale" => "settings.locale",
|
||||
|
|
||||
*/
|
||||
'override' => [
|
||||
'app.locale' => 'settings.locale',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fallback
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Define fallback settings to be used in case the default is null
|
||||
|
|
||||
| Sample:
|
||||
| "currency" => "USD",
|
||||
|
|
||||
*/
|
||||
'fallback' => [
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Required Extra Columns
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The list of columns required to be set up
|
||||
|
|
||||
| Sample:
|
||||
| "user_id",
|
||||
| "tenant_id",
|
||||
|
|
||||
*/
|
||||
'required_extra_columns' => [
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Define the keys which should be crypt automatically.
|
||||
|
|
||||
| Sample:
|
||||
| "payment.key"
|
||||
|
|
||||
*/
|
||||
'encrypted_keys' => [
|
||||
],
|
||||
];
|
@ -20,7 +20,10 @@ import {Alert} from '../Components';
|
||||
import Card from '../Components/Card/Card.jsx';
|
||||
import Mdi from '../Components/Mdi.jsx';
|
||||
import Page from '../Components/Page.jsx';
|
||||
import {getFormData} from '../utils';
|
||||
import {
|
||||
getFormData,
|
||||
showSnackbar
|
||||
} from '../utils';
|
||||
|
||||
export default class SetupPage extends Page {
|
||||
languages() {
|
||||
@ -142,7 +145,7 @@ export default class SetupPage extends Page {
|
||||
</mwc-layout-grid-cell>
|
||||
<mwc-layout-grid-cell>
|
||||
<h4>{__('Lingua')}</h4>
|
||||
<mwc-select id="language-select">
|
||||
<mwc-select id="language-select" name="locale">
|
||||
{this.languages()}
|
||||
</mwc-select>
|
||||
<hr />
|
||||
@ -205,13 +208,7 @@ export default class SetupPage extends Page {
|
||||
|
||||
onSaveButtonClicked(event: Event) {
|
||||
const form = $(event.target).closest('form');
|
||||
form.requestSubmit();
|
||||
}
|
||||
|
||||
onFormSubmit(event: Event) {
|
||||
const form = $(event.target).closest('form');
|
||||
|
||||
this.saveDatabase(formData);
|
||||
this.save(getFormData(form));
|
||||
}
|
||||
|
||||
onLanguageSelected(event: Event) {
|
||||
@ -239,4 +236,21 @@ export default class SetupPage extends Page {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async save(data: {...}) {
|
||||
const test = this.testDatabase(true);
|
||||
if (!test) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await redaxios.put(window.route('setup.save'), data);
|
||||
} catch (error) {
|
||||
await showSnackbar(error.data.error_description);
|
||||
return;
|
||||
}
|
||||
|
||||
await showSnackbar(__('Impostazioni salvate correttamente'));
|
||||
window.location.href = window.route('auth.login');
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<meta name="csrf-token" content="{{csrf_token()}}">
|
||||
<title>@lang('OpenSTAManager')</title>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{vite_asset('images/favicon/apple-touch-icon.png')}}">
|
||||
|
@ -16,7 +16,13 @@ use Illuminate\Support\Facades\Route;
|
||||
|
|
||||
*/
|
||||
|
||||
Route::redirect('/', 'setup');
|
||||
Route::get('/', function () {
|
||||
if (!empty(DB::connection()->getDatabaseName())) {
|
||||
return route('setup');
|
||||
}
|
||||
|
||||
//return route('auth.login');
|
||||
});
|
||||
|
||||
// ----- PUBLIC ROUTES ----- //
|
||||
Route::inertia('setup', 'SetupPage', [
|
||||
@ -27,6 +33,7 @@ Route::inertia('setup', 'SetupPage', [
|
||||
'license' => cache()->rememberForever('app.license', fn () => file_get_contents(base_path('LICENSE'))),
|
||||
]);
|
||||
Route::options('setup/test', [SetupController::class, 'testDatabase'])->name('setup.test')->withoutMiddleware('csrf');
|
||||
Route::put('setup/save', [SetupController::class, 'save'])->name('setup.save');
|
||||
|
||||
Route::get('lang/{language}', function ($language) {
|
||||
app()->setLocale($language);
|
||||
|
Loading…
x
Reference in New Issue
Block a user