mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-13 16:55:01 +00:00
- index method refactoret
- Added AppTest
This commit is contained in:
@@ -60,45 +60,28 @@ class AppFunctionsController extends Controller
|
||||
// Try to connect to database
|
||||
\DB::getPdo();
|
||||
|
||||
// Check settings table
|
||||
$settings_table = Schema::hasTable('settings');
|
||||
$users_table = Schema::hasTable('users');
|
||||
// Get setup status
|
||||
$setup_status = $this->get_setup_status();
|
||||
|
||||
// If settings table don't exist, then run migrations
|
||||
if ($users_table && !$settings_table) {
|
||||
Artisan::call('migrate', [
|
||||
'--force' => true
|
||||
]);
|
||||
}
|
||||
|
||||
// Get settings
|
||||
$upgraded = Setting::where('name', 'latest_upgrade')->first();
|
||||
|
||||
// Get connection string
|
||||
if ($upgraded && $upgraded->value !== '1.7') {
|
||||
$connection = 'quiet-update';
|
||||
} else if (!$upgraded) {
|
||||
$connection = 'quiet-update';
|
||||
} else {
|
||||
$connection = $this->get_setup_status();
|
||||
}
|
||||
// Get app pages
|
||||
$pages = Page::all();
|
||||
|
||||
// Get all settings
|
||||
$settings = Setting::all();
|
||||
|
||||
// Get legal pages
|
||||
$legal = Page::whereIn('slug', ['terms-of-service', 'privacy-policy', 'cookie-policy'])
|
||||
->get(['visibility', 'title', 'slug']);
|
||||
$settings = json_decode(
|
||||
Setting::all()
|
||||
->pluck('value', 'name')
|
||||
->toJson()
|
||||
);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$connection = 'setup-database';
|
||||
$settings = null;
|
||||
|
||||
$setup_status = 'setup-database';
|
||||
}
|
||||
|
||||
return view("index")
|
||||
->with('settings', $settings ? json_decode($settings->pluck('value', 'name')->toJson()) : null)
|
||||
->with('legal', isset($legal) ? $legal : null)
|
||||
->with('installation', $connection);
|
||||
->with('settings', $settings ?? null)
|
||||
->with('legal', $pages ?? null)
|
||||
->with('installation', $setup_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,9 +155,7 @@ class AppFunctionsController extends Controller
|
||||
{
|
||||
$setup_success = get_setting('setup_wizard_success');
|
||||
|
||||
$connection = boolval($setup_success) ? 'setup-done' : 'setup-disclaimer';
|
||||
|
||||
return $connection;
|
||||
return boolval($setup_success) ? 'setup-done' : 'setup-disclaimer';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-1
@@ -28,7 +28,8 @@
|
||||
"league/flysystem-aws-s3-v3": "^1.0",
|
||||
"league/flysystem-cached-adapter": "^1.0",
|
||||
"madnest/madzipper": "^1.1",
|
||||
"teamtnt/laravel-scout-tntsearch-driver": "^11.1"
|
||||
"teamtnt/laravel-scout-tntsearch-driver": "^11.1",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-json": "*",
|
||||
|
||||
+1
-1
@@ -21,8 +21,8 @@ Route::group(['prefix' => 'zip'], function () {
|
||||
|
||||
// Browse share content
|
||||
Route::group(['prefix' => 'browse'], function () {
|
||||
Route::get('/folders/{id}/public/{token}', [FileSharingController::class, 'get_public_folders']);
|
||||
Route::get('/navigation/public/{token}', [FileSharingController::class, 'get_public_navigation_tree']);
|
||||
Route::get('/folders/{id}/public/{token}', [FileSharingController::class, 'get_public_folders']);
|
||||
Route::post('/shared/authenticate/{token}', [FileSharingController::class, 'authenticate']);
|
||||
Route::get('/search/public/{token}', [FileSharingController::class, 'search_public']);
|
||||
Route::get('/files/{token}/public', [FileSharingController::class, 'file_public']);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\App;
|
||||
|
||||
use App\Services\SetupService;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AppTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setup = app()->make(SetupService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_index_page()
|
||||
{
|
||||
$this->setup->seed_default_pages();
|
||||
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$this->get('/')
|
||||
->assertStatus(200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user