mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 02:33:48 +00:00
controller refactoring part 12
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
reader.readAsDataURL(file)
|
||||
|
||||
// Update user avatar
|
||||
this.$updateImage('/user/relationships/settings', 'avatar', event.target.files[0])
|
||||
this.$updateImage('/user/settings', 'avatar', event.target.files[0])
|
||||
} else {
|
||||
alert( this.$t('validation_errors.wrong_image') )
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>GMT:</label>
|
||||
<div class="input-wrapper">
|
||||
<SelectInput @input="$updateText('/user/relationships/settings', 'timezone', userInfo.timezone)"
|
||||
<SelectInput @input="$updateText('/user/settings', 'timezone', userInfo.timezone)"
|
||||
v-model="userInfo.timezone"
|
||||
:default="userInfo.timezone"
|
||||
:options="timezones"
|
||||
@@ -49,7 +49,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('user_settings.name') }}:</label>
|
||||
<div class="input-wrapper">
|
||||
<input @keyup="$updateText('/user/relationships/settings', 'name', billingInfo.name)"
|
||||
<input @keyup="$updateText('/user/settings', 'name', billingInfo.name)"
|
||||
v-model="billingInfo.name"
|
||||
:placeholder="$t('user_settings.name_plac')"
|
||||
type="text"
|
||||
@@ -60,7 +60,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('user_settings.address') }}:</label>
|
||||
<div class="input-wrapper">
|
||||
<input @keyup="$updateText('/user/relationships/settings', 'address', billingInfo.address)"
|
||||
<input @keyup="$updateText('/user/settings', 'address', billingInfo.address)"
|
||||
v-model="billingInfo.address"
|
||||
:placeholder="$t('user_settings.address_plac')"
|
||||
type="text"
|
||||
@@ -72,7 +72,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('user_settings.city') }}:</label>
|
||||
<div class="input-wrapper">
|
||||
<input @keyup="$updateText('/user/relationships/settings', 'city', billingInfo.city)"
|
||||
<input @keyup="$updateText('/user/settings', 'city', billingInfo.city)"
|
||||
v-model="billingInfo.city"
|
||||
:placeholder="$t('user_settings.city_plac')"
|
||||
type="text"
|
||||
@@ -83,7 +83,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('user_settings.postal_code') }}:</label>
|
||||
<div class="input-wrapper">
|
||||
<input @keyup="$updateText('/user/relationships/settings', 'postal_code', billingInfo.postal_code)"
|
||||
<input @keyup="$updateText('/user/settings', 'postal_code', billingInfo.postal_code)"
|
||||
v-model="billingInfo.postal_code"
|
||||
:placeholder="$t('user_settings.postal_code_plac')"
|
||||
type="text"
|
||||
@@ -95,7 +95,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('user_settings.country') }}:</label>
|
||||
<div class="input-wrapper">
|
||||
<SelectInput @input="$updateText('/user/relationships/settings', 'country', billingInfo.country)"
|
||||
<SelectInput @input="$updateText('/user/settings', 'country', billingInfo.country)"
|
||||
v-model="billingInfo.country"
|
||||
:default="billingInfo.country"
|
||||
:options="countries"
|
||||
@@ -106,7 +106,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('user_settings.state') }}:</label>
|
||||
<div class="input-wrapper">
|
||||
<input @keyup="$updateText('/user/relationships/settings', 'state', billingInfo.state)"
|
||||
<input @keyup="$updateText('/user/settings', 'state', billingInfo.state)"
|
||||
v-model="billingInfo.state"
|
||||
:placeholder="$t('user_settings.state_plac')"
|
||||
type="text"
|
||||
@@ -120,7 +120,7 @@
|
||||
<div class="block-wrapper">
|
||||
<label>{{ $t('user_settings.phone_number') }}:</label>
|
||||
<div class="input-wrapper">
|
||||
<input @keyup="$updateText('/user/relationships/settings', 'phone_number', billingInfo.phone_number)"
|
||||
<input @keyup="$updateText('/user/settings', 'phone_number', billingInfo.phone_number)"
|
||||
v-model="billingInfo.phone_number"
|
||||
:placeholder="$t('user_settings.phone_number_plac')"
|
||||
type="text"
|
||||
@@ -178,7 +178,7 @@
|
||||
methods: {
|
||||
changeUserName() {
|
||||
this.$store.commit('UPDATE_NAME', this.userInfo.name)
|
||||
this.$updateText('/user/relationships/settings', 'name', this.userInfo.name)
|
||||
this.$updateText('/user/settings', 'name', this.userInfo.name)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Domain\Maintenance\Controllers\MaintenanceController;
|
||||
use Domain\Maintenance\Controllers\MaintenanceModeController;
|
||||
use Domain\Maintenance\Controllers\UpgradeDatabaseController;
|
||||
use Domain\Maintenance\Controllers\UpgradeTranslationsController;
|
||||
|
||||
Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
Route::get('/down', [MaintenanceController::class, 'down']);
|
||||
Route::get('/up', [MaintenanceController::class, 'up']);
|
||||
Route::get('/down', [MaintenanceModeController::class, 'down']);
|
||||
Route::get('/up', [MaintenanceModeController::class, 'up']);
|
||||
|
||||
Route::group(['prefix' => 'upgrade'], function () {
|
||||
Route::get('/translations', [MaintenanceController::class, 'upgrade_translations']);
|
||||
Route::get('/database', [MaintenanceController::class, 'upgrade_database']);
|
||||
Route::get('/translations', UpgradeTranslationsController::class);
|
||||
Route::get('/database', UpgradeDatabaseController::class);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,15 +27,15 @@ Route::post('/email/verify/resend', ResendVerificationEmail::class)
|
||||
->name('verification.send');
|
||||
|
||||
Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
// User Access Token
|
||||
Route::apiResource('/tokens', AccountAccessTokenController::class);
|
||||
|
||||
// Account
|
||||
Route::patch('/relationships/settings', UpdateProfileSettingsController::class);
|
||||
Route::patch('/settings', UpdateProfileSettingsController::class);
|
||||
Route::post('/password', UpdatePasswordController::class);
|
||||
Route::get('/storage', StorageCapacityController::class);
|
||||
Route::get('/', AccountDetailsController::class);
|
||||
|
||||
// User Access Token
|
||||
Route::apiResource('/tokens', AccountAccessTokenController::class);
|
||||
|
||||
// Subscription
|
||||
Route::group(['prefix' => 'subscription'], function () {
|
||||
Route::get('/setup-intent', GetSetupIntentController::class);
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
namespace Domain\Maintenance\Controllers;
|
||||
|
||||
use Gate;
|
||||
use Artisan;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Domain\Localization\Services\LanguageService;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
class MaintenanceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Start maintenance mode
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('up');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in production mode';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End maintenance mode
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('down');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in maintenance mode';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get new language translations from default translations
|
||||
* and insert it into database
|
||||
*
|
||||
* @return Application|ResponseFactory|Response
|
||||
*/
|
||||
public function upgrade_translations()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
resolve(LanguageService::class)
|
||||
->upgrade_language_translations();
|
||||
|
||||
return response('Done.', 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function upgrade_database()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('migrate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'Operation was successful.';
|
||||
}
|
||||
|
||||
if ($command === 1) {
|
||||
echo 'Operation failed.';
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Maintenance\Controllers;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Artisan;
|
||||
use Gate;
|
||||
|
||||
class MaintenanceModeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Start maintenance mode
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('up');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in production mode';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End maintenance mode
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('down');
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'System is in maintenance mode';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Maintenance\Controllers;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Artisan;
|
||||
use Gate;
|
||||
|
||||
class UpgradeDatabaseController extends Controller
|
||||
{
|
||||
public function __invoke(): mixed
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
$command = Artisan::call('migrate', [
|
||||
'--force' => true,
|
||||
]);
|
||||
|
||||
if ($command === 0) {
|
||||
echo 'Operation was successful.';
|
||||
}
|
||||
|
||||
if ($command === 1) {
|
||||
echo 'Operation failed.';
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Domain\Maintenance\Controllers;
|
||||
|
||||
use Gate;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Localization\Services\LanguageService;
|
||||
|
||||
class UpgradeTranslationsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get new language translations from default translations
|
||||
* and insert it into database
|
||||
*/
|
||||
public function __invoke(): Response
|
||||
{
|
||||
// Check admin permission
|
||||
Gate::authorize('maintenance');
|
||||
|
||||
resolve(LanguageService::class)
|
||||
->upgrade_language_translations();
|
||||
|
||||
return response('Done.', 201);
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class UserAccountTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson('/api/user/relationships/settings', [
|
||||
->patchJson('/api/user/settings', [
|
||||
'name' => 'address',
|
||||
'value' => 'Jantar',
|
||||
])->assertStatus(204);
|
||||
@@ -91,7 +91,7 @@ class UserAccountTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson('/api/user/relationships/settings', [
|
||||
->patchJson('/api/user/settings', [
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(204);
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ class AdminTest extends TestCase
|
||||
$avatar = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$this->patchJson('/api/user/relationships/settings', [
|
||||
$this->patchJson('/api/user/settings', [
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(204);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user