alpha v1.7 alpha.1

This commit is contained in:
carodej
2020-07-14 17:31:04 +02:00
parent c9d300769c
commit b1860eac21
33 changed files with 587 additions and 81 deletions
@@ -44,7 +44,7 @@ class DashboardController extends Controller
$license = Setting::where('name', 'license')->first();
return [
'license' => $license->value,
'license' => $license ? $license->value : null,
'app_version' => config('vuefilemanager.version'),
'total_users' => $total_users,
'total_used_space' => Metric::bytes($total_used_space)->format(),
@@ -192,7 +192,7 @@ class UserController extends Controller
]);
// Create settings
$settings = UserSettings::forceCreate([
UserSettings::forceCreate([
'user_id' => $user->id,
'storage_capacity' => $request->storage_capacity,
]);
+43 -24
View File
@@ -8,13 +8,11 @@ use App\Http\Resources\PageResource;
use App\Mail\SendSupportForm;
use App\Page;
use App\Setting;
use Artisan;
use Doctrine\DBAL\Driver\PDOException;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Schema;
class AppFunctionsController extends Controller
{
@@ -56,9 +54,30 @@ class AppFunctionsController extends Controller
// Try to connect to database
\DB::getPdo();
$connection = $this->get_setup_status();
$settings = json_decode(Setting::all()->pluck('value', 'name')->toJson());
$legal = Page::whereIn('slug', ['terms-of-service', 'privacy-policy', 'cookie-policy'])->get(['visibility', 'title', 'slug']);
// Check settings table
$settings_table = Schema::hasTable('settings');
// If settings table don't exist, then run migrations
if (! $settings_table) {
Artisan::call('migrate');
}
// Get settings
$setup_wizard_success = Setting::where('name', 'setup_wizard_success')->first();
// Get connection string
if (! $setup_wizard_success) {
$connection = 'quiet-update';
} else {
$connection = $this->get_setup_status();
}
// Get all settings
$settings = Setting::all();
// Get legal pages
$legal = Page::whereIn('slug', ['terms-of-service', 'privacy-policy', 'cookie-policy'])
->get(['visibility', 'title', 'slug']);
} catch (PDOException $e) {
$connection = 'setup-database';
@@ -66,11 +85,25 @@ class AppFunctionsController extends Controller
}
return view("index")
->with('settings', $settings)
->with('settings', $settings ? json_decode($settings->pluck('value', 'name')->toJson()) : null)
->with('legal', isset($legal) ? $legal : null)
->with('installation', $connection);
}
/**
* Check if setup wizard was passed
*
* @return string
*/
private function get_setup_status(): string
{
$setup_success = get_setting('setup_wizard_success');
$connection = boolval($setup_success) ? 'setup-done' : 'setup-disclaimer';
return $connection;
}
/**
* Send contact message from pages
*
@@ -116,28 +149,14 @@ class AppFunctionsController extends Controller
$columns = collect(explode('|', $column));
$columns->each(function ($column) {
if (! in_array($column, $this->whitelist)) abort(401);
if (!in_array($column, $this->whitelist)) abort(401);
});
return Setting::whereIn('name', $columns)->pluck('value', 'name');
}
if (! in_array($column, $this->whitelist)) abort(401);
if (!in_array($column, $this->whitelist)) abort(401);
return Setting::where('name', $column)->pluck('value', 'name');
}
/**
* Check if setup wizard was passed
*
* @return string
*/
private function get_setup_status(): string
{
$setup_success = Setting::where('name', 'setup_wizard_success')->first();
$connection = $setup_success ? 'setup-done' : 'setup-disclaimer';
return $connection;
}
}
@@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers\General;
use App\Http\Controllers\Controller;
use App\Setting;
use Artisan;
use Illuminate\Http\Request;
class UpgradeAppController extends Controller
{
/**
* Upgrade account from 1.6 to 1.7
*
* @param Request $request
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
*/
public function upgrade(Request $request)
{
$upgraded = Setting::where('name', 'latest_upgrade')->first();
if ($upgraded && $upgraded->value === '1.7') abort(401);
// Create legal pages and index content
if ($request->license === 'Extended') {
Artisan::call('db:seed --class=PageSeeder');
Artisan::call('db:seed --class=ContentSeeder');
}
// Store Logo
if ($request->hasFile('logo')) {
$logo = store_system_image($request->file('logo'), 'system');
}
// Store Logo horizontal
if ($request->hasFile('logo_horizontal')) {
$logo_horizontal = store_system_image($request->file('logo_horizontal'), 'system');
}
// Store favicon
if ($request->hasFile('favicon')) {
$favicon = store_system_image($request->file('favicon'), 'system');
}
// Get options
$settings = collect([
[
'name' => 'setup_wizard_database',
'value' => 1,
],
[
'name' => 'setup_wizard_success',
'value' => 1,
],
[
'name' => 'license',
'value' => $request->license,
],
[
'name' => 'purchase_code',
'value' => $request->purchase_code,
],
[
'name' => 'app_title',
'value' => $request->title,
],
[
'name' => 'app_description',
'value' => $request->description,
],
[
'name' => 'app_logo',
'value' => $request->hasFile('logo') ? $logo : null,
],
[
'name' => 'app_logo_horizontal',
'value' => $request->hasFile('logo_horizontal') ? $logo_horizontal : null,
],
[
'name' => 'app_favicon',
'value' => $request->hasFile('favicon') ? $favicon : null,
],
[
'name' => 'google_analytics',
'value' => $request->googleAnalytics,
],
[
'name' => 'contact_email',
'value' => $request->contactMail,
],
[
'name' => 'registration',
'value' => $request->userRegistration,
],
[
'name' => 'storage_limitation',
'value' => $request->storageLimitation,
],
[
'name' => 'storage_default',
'value' => $request->defaultStorage ? $request->defaultStorage : 5,
],
[
'name' => 'latest_upgrade',
'value' => '1.7',
],
]);
// Store options
$settings->each(function ($col) {
Setting::updateOrCreate(['name' => $col['name']], $col);
});
return response('Done', 200);
}
}