mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-24 13:44:42 +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
|
// Try to connect to database
|
||||||
\DB::getPdo();
|
\DB::getPdo();
|
||||||
|
|
||||||
// Check settings table
|
// Get setup status
|
||||||
$settings_table = Schema::hasTable('settings');
|
$setup_status = $this->get_setup_status();
|
||||||
$users_table = Schema::hasTable('users');
|
|
||||||
|
|
||||||
// If settings table don't exist, then run migrations
|
// Get app pages
|
||||||
if ($users_table && !$settings_table) {
|
$pages = Page::all();
|
||||||
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 all settings
|
// Get all settings
|
||||||
$settings = Setting::all();
|
$settings = json_decode(
|
||||||
|
Setting::all()
|
||||||
// Get legal pages
|
->pluck('value', 'name')
|
||||||
$legal = Page::whereIn('slug', ['terms-of-service', 'privacy-policy', 'cookie-policy'])
|
->toJson()
|
||||||
->get(['visibility', 'title', 'slug']);
|
);
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
$connection = 'setup-database';
|
|
||||||
$settings = null;
|
$setup_status = 'setup-database';
|
||||||
}
|
}
|
||||||
|
|
||||||
return view("index")
|
return view("index")
|
||||||
->with('settings', $settings ? json_decode($settings->pluck('value', 'name')->toJson()) : null)
|
->with('settings', $settings ?? null)
|
||||||
->with('legal', isset($legal) ? $legal : null)
|
->with('legal', $pages ?? null)
|
||||||
->with('installation', $connection);
|
->with('installation', $setup_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,9 +155,7 @@ class AppFunctionsController extends Controller
|
|||||||
{
|
{
|
||||||
$setup_success = get_setting('setup_wizard_success');
|
$setup_success = get_setting('setup_wizard_success');
|
||||||
|
|
||||||
$connection = boolval($setup_success) ? 'setup-done' : 'setup-disclaimer';
|
return boolval($setup_success) ? 'setup-done' : 'setup-disclaimer';
|
||||||
|
|
||||||
return $connection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-1
@@ -28,7 +28,8 @@
|
|||||||
"league/flysystem-aws-s3-v3": "^1.0",
|
"league/flysystem-aws-s3-v3": "^1.0",
|
||||||
"league/flysystem-cached-adapter": "^1.0",
|
"league/flysystem-cached-adapter": "^1.0",
|
||||||
"madnest/madzipper": "^1.1",
|
"madnest/madzipper": "^1.1",
|
||||||
"teamtnt/laravel-scout-tntsearch-driver": "^11.1"
|
"teamtnt/laravel-scout-tntsearch-driver": "^11.1",
|
||||||
|
"ext-json": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
|
|||||||
+1
-1
@@ -21,8 +21,8 @@ Route::group(['prefix' => 'zip'], function () {
|
|||||||
|
|
||||||
// Browse share content
|
// Browse share content
|
||||||
Route::group(['prefix' => 'browse'], function () {
|
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('/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::post('/shared/authenticate/{token}', [FileSharingController::class, 'authenticate']);
|
||||||
Route::get('/search/public/{token}', [FileSharingController::class, 'search_public']);
|
Route::get('/search/public/{token}', [FileSharingController::class, 'search_public']);
|
||||||
Route::get('/files/{token}/public', [FileSharingController::class, 'file_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