dashboard alert box for new system upgrade

This commit is contained in:
Čarodej
2022-03-30 18:12:41 +02:00
parent dff804153e
commit 3f8fc1c9ce
19 changed files with 299 additions and 198 deletions

View File

@@ -61,6 +61,7 @@ return [
],
],
// The update versions which need to run upgrade process
'updates' => [
'2_0_10',
],

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('app_updates', function (Blueprint $table) {
$table->id();
$table->string('version');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('app_updates');
}
};

View File

@@ -1,7 +1,7 @@
{
"/js/main.js": "/js/main.js",
"/chunks/request.js": "/chunks/request.js?id=14b4eff14acc96f0",
"/chunks/request-upload.js": "/chunks/request-upload.js?id=5cf8338c7200a1bf",
"/chunks/request.js": "/chunks/request.js?id=53076a8a4ef4dc5a",
"/chunks/request-upload.js": "/chunks/request-upload.js?id=2a6e79fa8211e8dd",
"/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=19a0784e59d768ec",
"/chunks/status-check.js": "/chunks/status-check.js?id=51a75f0b3b260189",
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=df5bd89528649783",
@@ -9,14 +9,14 @@
"/chunks/environment-setup.js": "/chunks/environment-setup.js?id=e1ad83583367917a",
"/chunks/app-setup.js": "/chunks/app-setup.js?id=288594cd7f628cf8",
"/chunks/admin-account.js": "/chunks/admin-account.js?id=916450217130f3b8",
"/chunks/shared.js": "/chunks/shared.js?id=b493900394d77a9c",
"/chunks/shared/browser.js": "/chunks/shared/browser.js?id=09c2c58a5688eddb",
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=9ae0babfa7134c29",
"/chunks/shared.js": "/chunks/shared.js?id=11da834fce6ab9c3",
"/chunks/shared/browser.js": "/chunks/shared/browser.js?id=6b2316ea14852488",
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=70ee7ce098c77d54",
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=672e931a9fb0b672",
"/chunks/not-found.js": "/chunks/not-found.js?id=9f6ce23ce5d969f1",
"/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=f564565faa09d6d6",
"/chunks/admin.js": "/chunks/admin.js?id=a0c8318fb3480cb0",
"/chunks/dashboard.js": "/chunks/dashboard.js?id=ec5474f5a9da434c",
"/chunks/admin.js": "/chunks/admin.js?id=330579ff4d2878d1",
"/chunks/dashboard.js": "/chunks/dashboard.js?id=65471d4c175c7cf5",
"/chunks/invoices.js": "/chunks/invoices.js?id=1416cbf6d1a593ac",
"/chunks/subscriptions.js": "/chunks/subscriptions.js?id=5bf6704f5b599f36",
"/chunks/pages.js": "/chunks/pages.js?id=c8380d571e91e8be",
@@ -57,18 +57,18 @@
"/chunks/sign-up.js": "/chunks/sign-up.js?id=bb92bad614e60d45",
"/chunks/forgotten-password.js": "/chunks/forgotten-password.js?id=50a1bc5e4ed86ec9",
"/chunks/create-new-password.js": "/chunks/create-new-password.js?id=f652de052dba55c1",
"/chunks/settings.js": "/chunks/settings.js?id=9e0671d49295178e",
"/chunks/settings.js": "/chunks/settings.js?id=45c48f36b841bb77",
"/chunks/profile.js": "/chunks/profile.js?id=0eca231475e267ab",
"/chunks/settings-password.js": "/chunks/settings-password.js?id=11d4331650cac280",
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=994b669a56fd417b",
"/chunks/billing.js": "/chunks/billing.js?id=4ea77ab501b8c575",
"/chunks/platform.js": "/chunks/platform.js?id=9d926efeacb4d530",
"/chunks/files.js": "/chunks/files.js?id=053fc46f0a783697",
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=aefaf719fbafa603",
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=ea72dbc73a771e4a",
"/chunks/trash.js": "/chunks/trash.js?id=6bc564374cb24449",
"/chunks/team-folders.js": "/chunks/team-folders.js?id=f2c2722451de236c",
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=fcf601ec2d9e3318",
"/chunks/billing.js": "/chunks/billing.js?id=40e758c87bcf6e89",
"/chunks/platform.js": "/chunks/platform.js?id=018b4aa10f3627f8",
"/chunks/files.js": "/chunks/files.js?id=bed8debe238dd68f",
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=a27d80d1e54995ca",
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=c1379a64bd5fa0d3",
"/chunks/trash.js": "/chunks/trash.js?id=6c877d7ddc2654fb",
"/chunks/team-folders.js": "/chunks/team-folders.js?id=5873488d325a3309",
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=99ca76a487bca899",
"/chunks/invitation.js": "/chunks/invitation.js?id=9ed8456c9d6d5ce1",
"/css/tailwind.css": "/css/tailwind.css",
"/css/app.css": "/css/app.css"

View File

@@ -0,0 +1,40 @@
<template>
<div
class="mb-6 flex cursor-pointer items-center rounded-xl p-5 shadow-card"
:class="{
'dark:bg-green-700/30 bg-green-200': color === 'green',
'dark:bg-rose-700/30 bg-rose-200': color === 'rose',
}"
>
<alert-octagon-icon
size="18"
class="vue-feather mr-4 shrink-0"
:class="{
'text-green-700 dark:text-green-500': color === 'green',
'text-rose-700 dark:text-rose-500': color === 'rose',
}"
/>
<p
class="text-sm text-green-700 dark:text-green-500"
:class="{
'text-green-700 dark:text-green-500': color === 'green',
'text-rose-700 dark:text-rose-500': color === 'rose',
}"
>
<slot />
</p>
</div>
</template>
<script>
import {AlertOctagonIcon} from "vue-feather-icons";
export default {
name: 'AlertBox',
props: [
'color',
],
components: {
AlertOctagonIcon,
}
}
</script>

View File

@@ -54,56 +54,24 @@
</div>
<!--New language strings alert-->
<div
v-if="true"
class="mb-6 flex items-center rounded-xl dark:bg-green-700/30 bg-green-200 p-5 shadow-card cursor-pointer"
@click="upgradeSystem"
>
<alert-octagon-icon size="18" class="vue-feather mr-4 shrink-0 dark:text-green-500 text-green-700" />
<p class="text-sm dark:text-green-500 text-green-700">
There is a new update that need upgrade some stuff on your backend. Please click on this box to upgrade.
</p>
</div>
<AlertBox v-if="data.app.shouldUpgrade" @click.native.once="upgradeSystem" color="green">
There is a new update that needs to upgrade some stuff on your backend. Please click on this box to upgrade.
</AlertBox>
<!--New language strings alert-->
<div
v-if="data.app.shouldUpgradeTranslations"
class="mb-6 flex items-center rounded-xl dark:bg-green-700/30 bg-green-200 p-5 shadow-card cursor-pointer"
@click="upgradeTranslations"
>
<alert-octagon-icon size="18" class="vue-feather mr-4 shrink-0 dark:text-green-500 text-green-700" />
<p class="text-sm dark:text-green-500 text-green-700">
We detect new language strings. You should <b class="dark:text-green-500 text-green-600 text-sm font-bold underline">upgrade your translations</b>. After that, you can find new translations at the bottom page of your translations in language editor. Please click on this box.
</p>
</div>
<AlertBox v-if="data.app.shouldUpgradeTranslations" @click.native.once="upgradeTranslations" color="green">
We detect new language strings. You should <b class="dark:text-green-500 text-green-600 text-sm font-bold underline">upgrade your translations</b>. After that, you can find new translations at the bottom page of your translations in language editor. Please click on this box.
</AlertBox>
<!--Create metered plan alert-->
<div
v-if="config.subscriptionType === 'metered' && config.isEmptyPlans"
class="mb-6 flex items-center rounded-xl dark:bg-rose-700/30 bg-rose-200 p-5 shadow-card"
>
<alert-octagon-icon size="18" class="vue-feather mr-4 shrink-0 dark:text-rose-500 text-rose-700" />
<p class="text-sm dark:text-rose-500 text-rose-700">
As you installed app with metered subscription type, you have to
<router-link :to="{ name: 'CreateMeteredPlan' }" class="dark:text-rose-500 text-sm font-bold underline"
>create your plan</router-link
>
as soon as possible to prevent new user registration without automatically assigned subscription
plan.
</p>
</div>
<AlertBox v-if="config.subscriptionType === 'metered' && config.isEmptyPlans" color="rose">
As you installed app with metered subscription type, you have to <router-link :to="{ name: 'CreateMeteredPlan' }" class="dark:text-rose-500 text-sm font-bold underline">create your plan</router-link> as soon as possible to prevent new user registration without automatically assigned subscription plan.
</AlertBox>
<!--Cron Alert-->
<div
v-if="!data.app.isRunningCron && !config.isDev"
class="mb-6 flex items-center rounded-xl dark:bg-rose-700/30 bg-rose-200 p-5 shadow-card"
>
<alert-octagon-icon size="18" class="vue-feather mr-4 shrink-0 dark:text-rose-500 text-rose-700" />
<p class="text-sm dark:text-rose-500 text-rose-700">
We detect your cron jobs probably doesn't work correctly, please check it, you need it for running
app correctly. If you set your cron job, please get back one minute later.
</p>
</div>
<AlertBox v-if="!data.app.isRunningCron && !config.isDev" color="rose">
We detect your cron jobs probably doesn't work correctly, please check it, you need it for running app correctly. If you set your cron job, please get back one minute later.
</AlertBox>
<!--Metric widgets-->
<div class="mb-2 md:mb-6 md:flex md:space-x-6">
@@ -221,26 +189,24 @@
<script>
import WidgetLatestRegistrations from '../../components/Admin/WidgetLatestRegistrations'
import ColorLabel from '../../components/Others/ColorLabel'
import { AlertOctagonIcon, ChevronRightIcon, ThumbsUpIcon } from 'vue-feather-icons'
import WidgetWrapper from '../../components/Admin/WidgetWrapper'
import {AlertOctagonIcon, ChevronRightIcon, ThumbsUpIcon} from 'vue-feather-icons'
import Spinner from '../../components/FilesView/Spinner'
import FormLabel from '../../components/Others/Forms/FormLabel'
import BarChart from '../../components/UI/BarChart'
import { mapGetters } from 'vuex'
import {mapGetters} from 'vuex'
import axios from 'axios'
import WidgetLatestTransactions from '../../components/Admin/WidgetLatestTransactions'
import InfoBox from '../../components/Others/Forms/InfoBox'
import {events} from "../../bus";
import AlertBox from "./AlertBox";
export default {
name: 'Dashboard',
components: {
InfoBox,
AlertBox,
WidgetLatestTransactions,
WidgetLatestRegistrations,
ChevronRightIcon,
AlertOctagonIcon,
WidgetWrapper,
ThumbsUpIcon,
ColorLabel,
FormLabel,
@@ -277,6 +243,8 @@ export default {
upgradeSystem() {
axios.get('/upgrade/system')
.then(() => {
this.data.app.shouldUpgrade = false
events.$emit('toaster', {
type: 'success',
message: this.$t('Your app was upgraded successfully.'),

View File

@@ -1,8 +1,8 @@
<?php
use Domain\Maintenance\Controllers\UpgradeTranslationsController;
use Domain\Maintenance\Controllers\MaintenanceModeController;
use Domain\Maintenance\Controllers\UpgradeSystemController;
use Domain\Maintenance\Controllers\MaintenanceModeController;
use Domain\Maintenance\Controllers\UpgradeTranslationsController;
Route::group(['middleware' => ['auth:sanctum']], function () {
Route::get('/down', [MaintenanceModeController::class, 'down']);

View File

@@ -1,5 +1,4 @@
<?php
namespace App\Console\Commands;
use App\Users\Models\User;
@@ -880,15 +879,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $teamGallery->id,
'user_id' => $user->id,
'parent_id' => $teamGallery->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -903,15 +902,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $presentationMaterial->id,
'user_id' => $user->id,
'parent_id' => $presentationMaterial->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -951,15 +950,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $financeDocumentsFolder->id,
'user_id' => $user->id,
'parent_id' => $financeDocumentsFolder->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -974,15 +973,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $reserves->id,
'user_id' => $user->id,
'parent_id' => $reserves->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -1025,15 +1024,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $folder->id,
'user_id' => $user->id,
'parent_id' => $folder->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -1067,15 +1066,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $destinationGallery->id,
'user_id' => $user->id,
'parent_id' => $destinationGallery->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -1107,15 +1106,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $holiday2022Folder->id,
'user_id' => $user->id,
'parent_id' => $holiday2022Folder->id,
'user_id' => $user->id,
'creator_id' => $author->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -1135,7 +1134,7 @@ class SetupDevEnvironment extends Command
collect([$members[0]->id, $members[1]->id, $members[5]->id])
->each(
fn($id) => DB::table('team_folder_members')
fn ($id) => DB::table('team_folder_members')
->insert([
'parent_id' => $companyProjectFolder->id,
'user_id' => $id,
@@ -1145,7 +1144,7 @@ class SetupDevEnvironment extends Command
collect([$members[3]->id, $members[2]->id])
->each(
fn($id) => DB::table('team_folder_members')
fn ($id) => DB::table('team_folder_members')
->insert([
'parent_id' => $financeDocumentsFolder->id,
'user_id' => $id,
@@ -1155,7 +1154,7 @@ class SetupDevEnvironment extends Command
collect([$members[2]->id, $members[3]->id, $members[5]->id, $members[0]->id])
->each(
fn($id) => DB::table('team_folder_members')
fn ($id) => DB::table('team_folder_members')
->insert([
'parent_id' => $holiday2022Folder->id,
'user_id' => $id,
@@ -1166,7 +1165,7 @@ class SetupDevEnvironment extends Command
// Create invitations
collect([$members[4], $members[5]])
->each(
fn($user) => TeamFolderInvitation::factory()
fn ($user) => TeamFolderInvitation::factory()
->create([
'email' => $user->email,
'parent_id' => $companyProjectFolder->id,
@@ -1247,15 +1246,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $videos->id,
'user_id' => $owner->id,
'parent_id' => $videos->id,
'user_id' => $owner->id,
'creator_id' => $author->id,
'name' => $file,
'basename' => $basename,
'type' => 'video',
'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $file,
'basename' => $basename,
'type' => 'video',
'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -1276,15 +1275,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $folder->id,
'user_id' => $owner->id,
'parent_id' => $folder->id,
'user_id' => $owner->id,
'creator_id' => $author->id,
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $file['name'],
'basename' => $basename,
'type' => 'file',
'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -1318,15 +1317,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $folder->id,
'user_id' => $owner->id,
'parent_id' => $folder->id,
'user_id' => $owner->id,
'creator_id' => $johan->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
@@ -1339,15 +1338,15 @@ class SetupDevEnvironment extends Command
// Create file record
File::create([
'parent_id' => $hug->id,
'user_id' => $owner->id,
'parent_id' => $hug->id,
'user_id' => $owner->id,
'creator_id' => $member->id,
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'],
'type' => 'image',
'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)),
]);
});
}
@@ -1568,7 +1567,7 @@ class SetupDevEnvironment extends Command
foreach (range(0, 45) as $day) {
$user
->each(
fn($user) => DB::table('traffic')
fn ($user) => DB::table('traffic')
->insert([
'id' => Str::uuid(),
'user_id' => $user->id,
@@ -1664,7 +1663,7 @@ class SetupDevEnvironment extends Command
// Create thumbnail only if image is larger than predefined image sizes
if ($intervention->getWidth() > $size['size']) {
// Generate thumbnail
$intervention->resize($size['size'], null, fn($constraint) => $constraint->aspectRatio())->stream();
$intervention->resize($size['size'], null, fn ($constraint) => $constraint->aspectRatio())->stream();
// Store thumbnail to disk
Storage::put("files/$user->id/{$size['name']}-{$file_name}", $intervention);

View File

@@ -1,11 +1,13 @@
<?php
namespace Domain\Admin\Controllers\Dashboard;
use Schema;
use ByteUnits\Metric;
use App\Users\Models\User;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use Domain\Maintenance\Models\AppUpdate;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
@@ -14,6 +16,10 @@ class GetDashboardDataController extends Controller
{
public function __invoke(): Application|ResponseFactory|Response
{
// Get app update data
$shouldUpgrade = $this->getUpgradeData();
// Get translations data
list($originalTranslations, $activeTranslations) = $this->countTranslations();
// Get bandwidth data
@@ -42,6 +48,7 @@ class GetDashboardDataController extends Controller
],
],
'app' => [
'shouldUpgrade' => count($shouldUpgrade) > 0,
'shouldUpgradeTranslations' => $activeTranslations !== $originalTranslations,
'isRunningCron' => isRunningCron(),
'license' => get_settings('license'),
@@ -105,9 +112,6 @@ class GetDashboardDataController extends Controller
return [$upload, $download, $uploadTotal, $downloadTotal, $storageUsage];
}
/**
* @return array
*/
private function countTranslations(): array
{
$default_translations = [
@@ -130,4 +134,17 @@ class GetDashboardDataController extends Controller
return [$originalTranslationCount, $activeTranslationsCount];
}
private function getUpgradeData(): array
{
// Get already updated versions
$alreadyUpdated = Schema::hasTable('app_updates')
? AppUpdate::all()
->pluck('version')
->toArray()
: [];
// Get versions which has to be upgraded
return array_diff(config('vuefilemanager.updates'), $alreadyUpdated);
}
}

View File

@@ -88,13 +88,13 @@ class UploadFileAction
// Create new file
$item = UserFile::create([
'mimetype' => get_file_type_from_mimetype($fileMimetype),
'type' => get_file_type($fileMimetype),
'parent_id' => ($this->getFileParentId)($request, $user->id),
'name' => $request->input('filename'),
'basename' => $fileName,
'filesize' => $fileSize,
'user_id' => $user->id,
'mimetype' => get_file_type_from_mimetype($fileMimetype),
'type' => get_file_type($fileMimetype),
'parent_id' => ($this->getFileParentId)($request, $user->id),
'name' => $request->input('filename'),
'basename' => $fileName,
'filesize' => $fileSize,
'user_id' => $user->id,
'creator_id' => auth()->id(),
]);

View File

@@ -2,7 +2,6 @@
namespace Domain\Files\Models;
use App\Users\Models\User;
use Domain\Traffic\Actions\RecordUploadAction;
use Illuminate\Support\Str;
use Laravel\Scout\Searchable;
use Domain\Sharing\Models\Share;
@@ -13,6 +12,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
use \Illuminate\Database\Eloquent\SoftDeletes;
use Domain\Traffic\Actions\RecordUploadAction;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

View File

@@ -3,7 +3,6 @@ namespace Domain\Folders\Actions;
use Domain\Sharing\Models\Share;
use Domain\Folders\Models\Folder;
use Illuminate\Support\Facades\Auth;
use Domain\Folders\Requests\CreateFolderRequest;
use App\Users\Exceptions\InvalidUserActionException;
@@ -42,7 +41,7 @@ class CreateFolderAction
'user_id' => $user->id,
'team_folder' => $isFilledParentId
? Folder::find($parentId)->getLatestParent()->team_folder
: false
: false,
]);
}
}

View File

@@ -1,15 +1,17 @@
<?php
namespace Domain\Maintenance\Controllers;
use App\Http\Controllers\Controller;
use DB;
use Domain\Files\Models\File;
use Domain\Folders\Models\Folder;
use Domain\Maintenance\Actions\UpgradeDatabaseAction;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Schema;
use Storage;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Domain\Files\Models\File;
use Illuminate\Http\Response;
use Domain\Folders\Models\Folder;
use App\Http\Controllers\Controller;
use Domain\Maintenance\Models\AppUpdate;
use Domain\Maintenance\Actions\UpgradeDatabaseAction;
ini_set('max_execution_time', -1);
@@ -17,26 +19,33 @@ class UpgradeSystemController extends Controller
{
public function __construct(
public UpgradeDatabaseAction $upgradeDatabase,
) {}
) {
}
public function __invoke(Request $request)
public function __invoke(Request $request): Response
{
// Get already updated versions
// TODO: get from database
$alreadyUpdated = ['2_0_8', '2_0_7'];
$alreadyUpdated = Schema::hasTable('app_updates')
? AppUpdate::all()
->pluck('version')
->toArray()
: [];
// Get versions which has to be upgraded
$needToUpgrade = array_diff(config('vuefilemanager.updates'), $alreadyUpdated);
// Iterate and upgrade
foreach ($needToUpgrade as $version) {
// Get method name
$method = "upgrade_to_$version";
if (method_exists($this, $method)) {
// Run update
$this->{$method}($request);
// Store update record
AppUpdate::create(['version' => $version]);
return response('Done', 201);
}
}
@@ -48,11 +57,11 @@ class UpgradeSystemController extends Controller
{
($this->upgradeDatabase)();
// Upgrade team folder content ownership
Folder::where('parent_id', null)
->where('team_folder', true)
->cursor()
->each(function ($teamFolder) {
// Get all inherited folder from team folder
$childrenFolderIds = Folder::with('folders:id,parent_id')
->where('id', $teamFolder->id)
@@ -91,7 +100,7 @@ class UpgradeSystemController extends Controller
// Update file permission
File::find($file->id)->update([
'user_id' => $teamFolder->user_id,
'user_id' => $teamFolder->user_id,
'creator_id' => $teamFolder->user_id !== $file->user_id ? $file->user_id : null,
]);
});
@@ -102,4 +111,4 @@ class UpgradeSystemController extends Controller
->update(['user_id' => $teamFolder->user_id]);
});
}
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Domain\Maintenance\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int id
* @property string version
*/
class AppUpdate extends Model
{
public $guarded = [
'id',
];
}

View File

@@ -2,6 +2,7 @@
namespace Domain\Settings\Actions;
use Domain\Settings\Models\Setting;
use Domain\Maintenance\Models\AppUpdate;
class SeedDefaultSettingsAction
{
@@ -11,6 +12,7 @@ class SeedDefaultSettingsAction
public function __invoke(
string $license
): void {
// Set default settings
collect(
config('content.content.' . strtolower($license))
)->each(fn ($content) => Setting::updateOrCreate([
@@ -18,5 +20,9 @@ class SeedDefaultSettingsAction
], [
'value' => $content['value'],
]));
// Set update records
collect(config('vuefilemanager.updates'))
->each(fn ($version) => AppUpdate::create(['version' => $version]));
}
}

View File

@@ -4,10 +4,10 @@ namespace Domain\Teams\Controllers;
use Gate;
use Illuminate\Http\Response;
use Domain\Folders\Models\Folder;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Support\Facades\DB;
class LeaveTeamFolderController extends Controller
{

View File

@@ -24,7 +24,8 @@ class DashboardTest extends TestCase
->getJson('/api/admin/dashboard')
->assertStatus(200)
->assertJsonFragment([
'app' => [
'app' => [
'shouldUpgrade' => true,
'shouldUpgradeTranslations' => true,
'earnings' => '$0.00',
'isRunningCron' => false,

View File

@@ -59,4 +59,22 @@ class AppUpgradeTest extends TestCase
]);
});
}
/**
* @test
*/
public function it_upgrade_app()
{
$user = User::factory()
->create(['role' => 'admin']);
$this
->actingAs($user)
->get('/upgrade/system')
->assertStatus(201);
$this->assertDatabaseHas('app_updates', [
'version' => '2_0_10',
]);
}
}

View File

@@ -5,11 +5,8 @@ use Str;
use Notification;
use Tests\TestCase;
use App\Users\Models\User;
use Domain\Files\Models\File;
use Domain\Folders\Models\Folder;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Domain\Teams\Models\TeamFolderInvitation;
use Domain\Teams\Notifications\InvitationIntoTeamFolder;

View File

@@ -1,13 +1,12 @@
<?php
namespace Tests\Domain\Teams;
use Illuminate\Http\UploadedFile;
use Notification;
use Tests\TestCase;
use App\Users\Models\User;
use Domain\Files\Models\File;
use Domain\Folders\Models\Folder;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Domain\Teams\Notifications\InvitationIntoTeamFolder;