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
+1
View File
@@ -61,6 +61,7 @@ return [
], ],
], ],
// The update versions which need to run upgrade process
'updates' => [ 'updates' => [
'2_0_10', '2_0_10',
], ],
@@ -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');
}
};
+16 -16
View File
@@ -1,7 +1,7 @@
{ {
"/js/main.js": "/js/main.js", "/js/main.js": "/js/main.js",
"/chunks/request.js": "/chunks/request.js?id=14b4eff14acc96f0", "/chunks/request.js": "/chunks/request.js?id=53076a8a4ef4dc5a",
"/chunks/request-upload.js": "/chunks/request-upload.js?id=5cf8338c7200a1bf", "/chunks/request-upload.js": "/chunks/request-upload.js?id=2a6e79fa8211e8dd",
"/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=19a0784e59d768ec", "/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=19a0784e59d768ec",
"/chunks/status-check.js": "/chunks/status-check.js?id=51a75f0b3b260189", "/chunks/status-check.js": "/chunks/status-check.js?id=51a75f0b3b260189",
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=df5bd89528649783", "/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/environment-setup.js": "/chunks/environment-setup.js?id=e1ad83583367917a",
"/chunks/app-setup.js": "/chunks/app-setup.js?id=288594cd7f628cf8", "/chunks/app-setup.js": "/chunks/app-setup.js?id=288594cd7f628cf8",
"/chunks/admin-account.js": "/chunks/admin-account.js?id=916450217130f3b8", "/chunks/admin-account.js": "/chunks/admin-account.js?id=916450217130f3b8",
"/chunks/shared.js": "/chunks/shared.js?id=b493900394d77a9c", "/chunks/shared.js": "/chunks/shared.js?id=11da834fce6ab9c3",
"/chunks/shared/browser.js": "/chunks/shared/browser.js?id=09c2c58a5688eddb", "/chunks/shared/browser.js": "/chunks/shared/browser.js?id=6b2316ea14852488",
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=9ae0babfa7134c29", "/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=70ee7ce098c77d54",
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=672e931a9fb0b672", "/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=672e931a9fb0b672",
"/chunks/not-found.js": "/chunks/not-found.js?id=9f6ce23ce5d969f1", "/chunks/not-found.js": "/chunks/not-found.js?id=9f6ce23ce5d969f1",
"/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=f564565faa09d6d6", "/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=f564565faa09d6d6",
"/chunks/admin.js": "/chunks/admin.js?id=a0c8318fb3480cb0", "/chunks/admin.js": "/chunks/admin.js?id=330579ff4d2878d1",
"/chunks/dashboard.js": "/chunks/dashboard.js?id=ec5474f5a9da434c", "/chunks/dashboard.js": "/chunks/dashboard.js?id=65471d4c175c7cf5",
"/chunks/invoices.js": "/chunks/invoices.js?id=1416cbf6d1a593ac", "/chunks/invoices.js": "/chunks/invoices.js?id=1416cbf6d1a593ac",
"/chunks/subscriptions.js": "/chunks/subscriptions.js?id=5bf6704f5b599f36", "/chunks/subscriptions.js": "/chunks/subscriptions.js?id=5bf6704f5b599f36",
"/chunks/pages.js": "/chunks/pages.js?id=c8380d571e91e8be", "/chunks/pages.js": "/chunks/pages.js?id=c8380d571e91e8be",
@@ -57,18 +57,18 @@
"/chunks/sign-up.js": "/chunks/sign-up.js?id=bb92bad614e60d45", "/chunks/sign-up.js": "/chunks/sign-up.js?id=bb92bad614e60d45",
"/chunks/forgotten-password.js": "/chunks/forgotten-password.js?id=50a1bc5e4ed86ec9", "/chunks/forgotten-password.js": "/chunks/forgotten-password.js?id=50a1bc5e4ed86ec9",
"/chunks/create-new-password.js": "/chunks/create-new-password.js?id=f652de052dba55c1", "/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/profile.js": "/chunks/profile.js?id=0eca231475e267ab",
"/chunks/settings-password.js": "/chunks/settings-password.js?id=11d4331650cac280", "/chunks/settings-password.js": "/chunks/settings-password.js?id=11d4331650cac280",
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=994b669a56fd417b", "/chunks/settings-storage.js": "/chunks/settings-storage.js?id=994b669a56fd417b",
"/chunks/billing.js": "/chunks/billing.js?id=4ea77ab501b8c575", "/chunks/billing.js": "/chunks/billing.js?id=40e758c87bcf6e89",
"/chunks/platform.js": "/chunks/platform.js?id=9d926efeacb4d530", "/chunks/platform.js": "/chunks/platform.js?id=018b4aa10f3627f8",
"/chunks/files.js": "/chunks/files.js?id=053fc46f0a783697", "/chunks/files.js": "/chunks/files.js?id=bed8debe238dd68f",
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=aefaf719fbafa603", "/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=a27d80d1e54995ca",
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=ea72dbc73a771e4a", "/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=c1379a64bd5fa0d3",
"/chunks/trash.js": "/chunks/trash.js?id=6bc564374cb24449", "/chunks/trash.js": "/chunks/trash.js?id=6c877d7ddc2654fb",
"/chunks/team-folders.js": "/chunks/team-folders.js?id=f2c2722451de236c", "/chunks/team-folders.js": "/chunks/team-folders.js?id=5873488d325a3309",
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=fcf601ec2d9e3318", "/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=99ca76a487bca899",
"/chunks/invitation.js": "/chunks/invitation.js?id=9ed8456c9d6d5ce1", "/chunks/invitation.js": "/chunks/invitation.js?id=9ed8456c9d6d5ce1",
"/css/tailwind.css": "/css/tailwind.css", "/css/tailwind.css": "/css/tailwind.css",
"/css/app.css": "/css/app.css" "/css/app.css": "/css/app.css"
+40
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>
+18 -50
View File
@@ -54,56 +54,24 @@
</div> </div>
<!--New language strings alert--> <!--New language strings alert-->
<div <AlertBox v-if="data.app.shouldUpgrade" @click.native.once="upgradeSystem" color="green">
v-if="true" There is a new update that needs to upgrade some stuff on your backend. Please click on this box to upgrade.
class="mb-6 flex items-center rounded-xl dark:bg-green-700/30 bg-green-200 p-5 shadow-card cursor-pointer" </AlertBox>
@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>
<!--New language strings alert--> <!--New language strings alert-->
<div <AlertBox v-if="data.app.shouldUpgradeTranslations" @click.native.once="upgradeTranslations" color="green">
v-if="data.app.shouldUpgradeTranslations" 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.
class="mb-6 flex items-center rounded-xl dark:bg-green-700/30 bg-green-200 p-5 shadow-card cursor-pointer" </AlertBox>
@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>
<!--Create metered plan alert--> <!--Create metered plan alert-->
<div <AlertBox v-if="config.subscriptionType === 'metered' && config.isEmptyPlans" color="rose">
v-if="config.subscriptionType === 'metered' && config.isEmptyPlans" 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.
class="mb-6 flex items-center rounded-xl dark:bg-rose-700/30 bg-rose-200 p-5 shadow-card" </AlertBox>
>
<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>
<!--Cron Alert--> <!--Cron Alert-->
<div <AlertBox v-if="!data.app.isRunningCron && !config.isDev" color="rose">
v-if="!data.app.isRunningCron && !config.isDev" 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.
class="mb-6 flex items-center rounded-xl dark:bg-rose-700/30 bg-rose-200 p-5 shadow-card" </AlertBox>
>
<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>
<!--Metric widgets--> <!--Metric widgets-->
<div class="mb-2 md:mb-6 md:flex md:space-x-6"> <div class="mb-2 md:mb-6 md:flex md:space-x-6">
@@ -221,26 +189,24 @@
<script> <script>
import WidgetLatestRegistrations from '../../components/Admin/WidgetLatestRegistrations' import WidgetLatestRegistrations from '../../components/Admin/WidgetLatestRegistrations'
import ColorLabel from '../../components/Others/ColorLabel' import ColorLabel from '../../components/Others/ColorLabel'
import { AlertOctagonIcon, ChevronRightIcon, ThumbsUpIcon } from 'vue-feather-icons' import {AlertOctagonIcon, ChevronRightIcon, ThumbsUpIcon} from 'vue-feather-icons'
import WidgetWrapper from '../../components/Admin/WidgetWrapper'
import Spinner from '../../components/FilesView/Spinner' import Spinner from '../../components/FilesView/Spinner'
import FormLabel from '../../components/Others/Forms/FormLabel' import FormLabel from '../../components/Others/Forms/FormLabel'
import BarChart from '../../components/UI/BarChart' import BarChart from '../../components/UI/BarChart'
import { mapGetters } from 'vuex' import {mapGetters} from 'vuex'
import axios from 'axios' import axios from 'axios'
import WidgetLatestTransactions from '../../components/Admin/WidgetLatestTransactions' import WidgetLatestTransactions from '../../components/Admin/WidgetLatestTransactions'
import InfoBox from '../../components/Others/Forms/InfoBox'
import {events} from "../../bus"; import {events} from "../../bus";
import AlertBox from "./AlertBox";
export default { export default {
name: 'Dashboard', name: 'Dashboard',
components: { components: {
InfoBox, AlertBox,
WidgetLatestTransactions, WidgetLatestTransactions,
WidgetLatestRegistrations, WidgetLatestRegistrations,
ChevronRightIcon, ChevronRightIcon,
AlertOctagonIcon, AlertOctagonIcon,
WidgetWrapper,
ThumbsUpIcon, ThumbsUpIcon,
ColorLabel, ColorLabel,
FormLabel, FormLabel,
@@ -277,6 +243,8 @@ export default {
upgradeSystem() { upgradeSystem() {
axios.get('/upgrade/system') axios.get('/upgrade/system')
.then(() => { .then(() => {
this.data.app.shouldUpgrade = false
events.$emit('toaster', { events.$emit('toaster', {
type: 'success', type: 'success',
message: this.$t('Your app was upgraded successfully.'), message: this.$t('Your app was upgraded successfully.'),
+2 -2
View File
@@ -1,8 +1,8 @@
<?php <?php
use Domain\Maintenance\Controllers\UpgradeTranslationsController;
use Domain\Maintenance\Controllers\MaintenanceModeController;
use Domain\Maintenance\Controllers\UpgradeSystemController; use Domain\Maintenance\Controllers\UpgradeSystemController;
use Domain\Maintenance\Controllers\MaintenanceModeController;
use Domain\Maintenance\Controllers\UpgradeTranslationsController;
Route::group(['middleware' => ['auth:sanctum']], function () { Route::group(['middleware' => ['auth:sanctum']], function () {
Route::get('/down', [MaintenanceModeController::class, 'down']); Route::get('/down', [MaintenanceModeController::class, 'down']);
@@ -1,5 +1,4 @@
<?php <?php
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Users\Models\User; use App\Users\Models\User;
@@ -880,15 +879,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $teamGallery->id, 'parent_id' => $teamGallery->id,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $thumbnail['name'], 'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'], 'basename' => $thumbnail['basename'],
'type' => 'image', 'type' => 'image',
'mimetype' => 'jpg', 'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -903,15 +902,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $presentationMaterial->id, 'parent_id' => $presentationMaterial->id,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $thumbnail['name'], 'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'], 'basename' => $thumbnail['basename'],
'type' => 'image', 'type' => 'image',
'mimetype' => 'jpg', 'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -951,15 +950,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $financeDocumentsFolder->id, 'parent_id' => $financeDocumentsFolder->id,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $thumbnail['name'], 'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'], 'basename' => $thumbnail['basename'],
'type' => 'image', 'type' => 'image',
'mimetype' => 'jpg', 'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -974,15 +973,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $reserves->id, 'parent_id' => $reserves->id,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $thumbnail['name'], 'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'], 'basename' => $thumbnail['basename'],
'type' => 'image', 'type' => 'image',
'mimetype' => 'jpg', 'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -1025,15 +1024,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $folder->id, 'parent_id' => $folder->id,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $file['name'], 'name' => $file['name'],
'basename' => $basename, 'basename' => $basename,
'type' => 'file', 'type' => 'file',
'mimetype' => $file['mimetype'], 'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -1067,15 +1066,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $destinationGallery->id, 'parent_id' => $destinationGallery->id,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $thumbnail['name'], 'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'], 'basename' => $thumbnail['basename'],
'type' => 'image', 'type' => 'image',
'mimetype' => 'jpg', 'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -1107,15 +1106,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $holiday2022Folder->id, 'parent_id' => $holiday2022Folder->id,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $file['name'], 'name' => $file['name'],
'basename' => $basename, 'basename' => $basename,
'type' => 'file', 'type' => 'file',
'mimetype' => $file['mimetype'], 'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), '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]) collect([$members[0]->id, $members[1]->id, $members[5]->id])
->each( ->each(
fn($id) => DB::table('team_folder_members') fn ($id) => DB::table('team_folder_members')
->insert([ ->insert([
'parent_id' => $companyProjectFolder->id, 'parent_id' => $companyProjectFolder->id,
'user_id' => $id, 'user_id' => $id,
@@ -1145,7 +1144,7 @@ class SetupDevEnvironment extends Command
collect([$members[3]->id, $members[2]->id]) collect([$members[3]->id, $members[2]->id])
->each( ->each(
fn($id) => DB::table('team_folder_members') fn ($id) => DB::table('team_folder_members')
->insert([ ->insert([
'parent_id' => $financeDocumentsFolder->id, 'parent_id' => $financeDocumentsFolder->id,
'user_id' => $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]) collect([$members[2]->id, $members[3]->id, $members[5]->id, $members[0]->id])
->each( ->each(
fn($id) => DB::table('team_folder_members') fn ($id) => DB::table('team_folder_members')
->insert([ ->insert([
'parent_id' => $holiday2022Folder->id, 'parent_id' => $holiday2022Folder->id,
'user_id' => $id, 'user_id' => $id,
@@ -1166,7 +1165,7 @@ class SetupDevEnvironment extends Command
// Create invitations // Create invitations
collect([$members[4], $members[5]]) collect([$members[4], $members[5]])
->each( ->each(
fn($user) => TeamFolderInvitation::factory() fn ($user) => TeamFolderInvitation::factory()
->create([ ->create([
'email' => $user->email, 'email' => $user->email,
'parent_id' => $companyProjectFolder->id, 'parent_id' => $companyProjectFolder->id,
@@ -1247,15 +1246,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $videos->id, 'parent_id' => $videos->id,
'user_id' => $owner->id, 'user_id' => $owner->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $file, 'name' => $file,
'basename' => $basename, 'basename' => $basename,
'type' => 'video', 'type' => 'video',
'mimetype' => 'mp4', 'mimetype' => 'mp4',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -1276,15 +1275,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $folder->id, 'parent_id' => $folder->id,
'user_id' => $owner->id, 'user_id' => $owner->id,
'creator_id' => $author->id, 'creator_id' => $author->id,
'name' => $file['name'], 'name' => $file['name'],
'basename' => $basename, 'basename' => $basename,
'type' => 'file', 'type' => 'file',
'mimetype' => $file['mimetype'], 'mimetype' => $file['mimetype'],
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -1318,15 +1317,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $folder->id, 'parent_id' => $folder->id,
'user_id' => $owner->id, 'user_id' => $owner->id,
'creator_id' => $johan->id, 'creator_id' => $johan->id,
'name' => $thumbnail['name'], 'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'], 'basename' => $thumbnail['basename'],
'type' => 'image', 'type' => 'image',
'mimetype' => 'jpg', 'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
@@ -1339,15 +1338,15 @@ class SetupDevEnvironment extends Command
// Create file record // Create file record
File::create([ File::create([
'parent_id' => $hug->id, 'parent_id' => $hug->id,
'user_id' => $owner->id, 'user_id' => $owner->id,
'creator_id' => $member->id, 'creator_id' => $member->id,
'name' => $thumbnail['name'], 'name' => $thumbnail['name'],
'basename' => $thumbnail['basename'], 'basename' => $thumbnail['basename'],
'type' => 'image', 'type' => 'image',
'mimetype' => 'jpg', 'mimetype' => 'jpg',
'filesize' => rand(1000000, 4000000), 'filesize' => rand(1000000, 4000000),
'created_at' => now()->subMinutes(rand(1, 5)), 'created_at' => now()->subMinutes(rand(1, 5)),
]); ]);
}); });
} }
@@ -1568,7 +1567,7 @@ class SetupDevEnvironment extends Command
foreach (range(0, 45) as $day) { foreach (range(0, 45) as $day) {
$user $user
->each( ->each(
fn($user) => DB::table('traffic') fn ($user) => DB::table('traffic')
->insert([ ->insert([
'id' => Str::uuid(), 'id' => Str::uuid(),
'user_id' => $user->id, 'user_id' => $user->id,
@@ -1664,7 +1663,7 @@ class SetupDevEnvironment extends Command
// Create thumbnail only if image is larger than predefined image sizes // Create thumbnail only if image is larger than predefined image sizes
if ($intervention->getWidth() > $size['size']) { if ($intervention->getWidth() > $size['size']) {
// Generate thumbnail // 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 // Store thumbnail to disk
Storage::put("files/$user->id/{$size['name']}-{$file_name}", $intervention); Storage::put("files/$user->id/{$size['name']}-{$file_name}", $intervention);
@@ -1,11 +1,13 @@
<?php <?php
namespace Domain\Admin\Controllers\Dashboard; namespace Domain\Admin\Controllers\Dashboard;
use Schema;
use ByteUnits\Metric; use ByteUnits\Metric;
use App\Users\Models\User; use App\Users\Models\User;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Domain\Maintenance\Models\AppUpdate;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Contracts\Routing\ResponseFactory;
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription; use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
@@ -14,6 +16,10 @@ class GetDashboardDataController extends Controller
{ {
public function __invoke(): Application|ResponseFactory|Response public function __invoke(): Application|ResponseFactory|Response
{ {
// Get app update data
$shouldUpgrade = $this->getUpgradeData();
// Get translations data
list($originalTranslations, $activeTranslations) = $this->countTranslations(); list($originalTranslations, $activeTranslations) = $this->countTranslations();
// Get bandwidth data // Get bandwidth data
@@ -42,6 +48,7 @@ class GetDashboardDataController extends Controller
], ],
], ],
'app' => [ 'app' => [
'shouldUpgrade' => count($shouldUpgrade) > 0,
'shouldUpgradeTranslations' => $activeTranslations !== $originalTranslations, 'shouldUpgradeTranslations' => $activeTranslations !== $originalTranslations,
'isRunningCron' => isRunningCron(), 'isRunningCron' => isRunningCron(),
'license' => get_settings('license'), 'license' => get_settings('license'),
@@ -105,9 +112,6 @@ class GetDashboardDataController extends Controller
return [$upload, $download, $uploadTotal, $downloadTotal, $storageUsage]; return [$upload, $download, $uploadTotal, $downloadTotal, $storageUsage];
} }
/**
* @return array
*/
private function countTranslations(): array private function countTranslations(): array
{ {
$default_translations = [ $default_translations = [
@@ -130,4 +134,17 @@ class GetDashboardDataController extends Controller
return [$originalTranslationCount, $activeTranslationsCount]; 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);
}
} }
@@ -88,13 +88,13 @@ class UploadFileAction
// Create new file // Create new file
$item = UserFile::create([ $item = UserFile::create([
'mimetype' => get_file_type_from_mimetype($fileMimetype), 'mimetype' => get_file_type_from_mimetype($fileMimetype),
'type' => get_file_type($fileMimetype), 'type' => get_file_type($fileMimetype),
'parent_id' => ($this->getFileParentId)($request, $user->id), 'parent_id' => ($this->getFileParentId)($request, $user->id),
'name' => $request->input('filename'), 'name' => $request->input('filename'),
'basename' => $fileName, 'basename' => $fileName,
'filesize' => $fileSize, 'filesize' => $fileSize,
'user_id' => $user->id, 'user_id' => $user->id,
'creator_id' => auth()->id(), 'creator_id' => auth()->id(),
]); ]);
+1 -1
View File
@@ -2,7 +2,6 @@
namespace Domain\Files\Models; namespace Domain\Files\Models;
use App\Users\Models\User; use App\Users\Models\User;
use Domain\Traffic\Actions\RecordUploadAction;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Laravel\Scout\Searchable; use Laravel\Scout\Searchable;
use Domain\Sharing\Models\Share; use Domain\Sharing\Models\Share;
@@ -13,6 +12,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use TeamTNT\TNTSearch\Indexer\TNTIndexer; use TeamTNT\TNTSearch\Indexer\TNTIndexer;
use \Illuminate\Database\Eloquent\SoftDeletes; use \Illuminate\Database\Eloquent\SoftDeletes;
use Domain\Traffic\Actions\RecordUploadAction;
use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -3,7 +3,6 @@ namespace Domain\Folders\Actions;
use Domain\Sharing\Models\Share; use Domain\Sharing\Models\Share;
use Domain\Folders\Models\Folder; use Domain\Folders\Models\Folder;
use Illuminate\Support\Facades\Auth;
use Domain\Folders\Requests\CreateFolderRequest; use Domain\Folders\Requests\CreateFolderRequest;
use App\Users\Exceptions\InvalidUserActionException; use App\Users\Exceptions\InvalidUserActionException;
@@ -42,7 +41,7 @@ class CreateFolderAction
'user_id' => $user->id, 'user_id' => $user->id,
'team_folder' => $isFilledParentId 'team_folder' => $isFilledParentId
? Folder::find($parentId)->getLatestParent()->team_folder ? Folder::find($parentId)->getLatestParent()->team_folder
: false : false,
]); ]);
} }
} }
@@ -1,15 +1,17 @@
<?php <?php
namespace Domain\Maintenance\Controllers; namespace Domain\Maintenance\Controllers;
use App\Http\Controllers\Controller;
use DB; use DB;
use Domain\Files\Models\File; use Schema;
use Domain\Folders\Models\Folder;
use Domain\Maintenance\Actions\UpgradeDatabaseAction;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Storage; 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); ini_set('max_execution_time', -1);
@@ -17,26 +19,33 @@ class UpgradeSystemController extends Controller
{ {
public function __construct( public function __construct(
public UpgradeDatabaseAction $upgradeDatabase, public UpgradeDatabaseAction $upgradeDatabase,
) {} ) {
}
public function __invoke(Request $request) public function __invoke(Request $request): Response
{ {
// Get already updated versions // Get already updated versions
// TODO: get from database $alreadyUpdated = Schema::hasTable('app_updates')
$alreadyUpdated = ['2_0_8', '2_0_7']; ? AppUpdate::all()
->pluck('version')
->toArray()
: [];
// Get versions which has to be upgraded // Get versions which has to be upgraded
$needToUpgrade = array_diff(config('vuefilemanager.updates'), $alreadyUpdated); $needToUpgrade = array_diff(config('vuefilemanager.updates'), $alreadyUpdated);
// Iterate and upgrade // Iterate and upgrade
foreach ($needToUpgrade as $version) { foreach ($needToUpgrade as $version) {
// Get method name // Get method name
$method = "upgrade_to_$version"; $method = "upgrade_to_$version";
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
// Run update
$this->{$method}($request); $this->{$method}($request);
// Store update record
AppUpdate::create(['version' => $version]);
return response('Done', 201); return response('Done', 201);
} }
} }
@@ -48,11 +57,11 @@ class UpgradeSystemController extends Controller
{ {
($this->upgradeDatabase)(); ($this->upgradeDatabase)();
// Upgrade team folder content ownership
Folder::where('parent_id', null) Folder::where('parent_id', null)
->where('team_folder', true) ->where('team_folder', true)
->cursor() ->cursor()
->each(function ($teamFolder) { ->each(function ($teamFolder) {
// Get all inherited folder from team folder // Get all inherited folder from team folder
$childrenFolderIds = Folder::with('folders:id,parent_id') $childrenFolderIds = Folder::with('folders:id,parent_id')
->where('id', $teamFolder->id) ->where('id', $teamFolder->id)
@@ -91,7 +100,7 @@ class UpgradeSystemController extends Controller
// Update file permission // Update file permission
File::find($file->id)->update([ 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, 'creator_id' => $teamFolder->user_id !== $file->user_id ? $file->user_id : null,
]); ]);
}); });
@@ -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',
];
}
@@ -2,6 +2,7 @@
namespace Domain\Settings\Actions; namespace Domain\Settings\Actions;
use Domain\Settings\Models\Setting; use Domain\Settings\Models\Setting;
use Domain\Maintenance\Models\AppUpdate;
class SeedDefaultSettingsAction class SeedDefaultSettingsAction
{ {
@@ -11,6 +12,7 @@ class SeedDefaultSettingsAction
public function __invoke( public function __invoke(
string $license string $license
): void { ): void {
// Set default settings
collect( collect(
config('content.content.' . strtolower($license)) config('content.content.' . strtolower($license))
)->each(fn ($content) => Setting::updateOrCreate([ )->each(fn ($content) => Setting::updateOrCreate([
@@ -18,5 +20,9 @@ class SeedDefaultSettingsAction
], [ ], [
'value' => $content['value'], 'value' => $content['value'],
])); ]));
// Set update records
collect(config('vuefilemanager.updates'))
->each(fn ($version) => AppUpdate::create(['version' => $version]));
} }
} }
@@ -4,10 +4,10 @@ namespace Domain\Teams\Controllers;
use Gate; use Gate;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Domain\Folders\Models\Folder; use Domain\Folders\Models\Folder;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Support\Facades\DB;
class LeaveTeamFolderController extends Controller class LeaveTeamFolderController extends Controller
{ {
+2 -1
View File
@@ -24,7 +24,8 @@ class DashboardTest extends TestCase
->getJson('/api/admin/dashboard') ->getJson('/api/admin/dashboard')
->assertStatus(200) ->assertStatus(200)
->assertJsonFragment([ ->assertJsonFragment([
'app' => [ 'app' => [
'shouldUpgrade' => true,
'shouldUpgradeTranslations' => true, 'shouldUpgradeTranslations' => true,
'earnings' => '$0.00', 'earnings' => '$0.00',
'isRunningCron' => false, 'isRunningCron' => false,
@@ -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',
]);
}
} }
@@ -5,11 +5,8 @@ use Str;
use Notification; use Notification;
use Tests\TestCase; use Tests\TestCase;
use App\Users\Models\User; use App\Users\Models\User;
use Domain\Files\Models\File;
use Domain\Folders\Models\Folder; use Domain\Folders\Models\Folder;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Domain\Teams\Models\TeamFolderInvitation; use Domain\Teams\Models\TeamFolderInvitation;
use Domain\Teams\Notifications\InvitationIntoTeamFolder; use Domain\Teams\Notifications\InvitationIntoTeamFolder;
+1 -2
View File
@@ -1,13 +1,12 @@
<?php <?php
namespace Tests\Domain\Teams; namespace Tests\Domain\Teams;
use Illuminate\Http\UploadedFile;
use Notification; use Notification;
use Tests\TestCase; use Tests\TestCase;
use App\Users\Models\User; use App\Users\Models\User;
use Domain\Files\Models\File; use Domain\Files\Models\File;
use Domain\Folders\Models\Folder; use Domain\Folders\Models\Folder;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Domain\Teams\Notifications\InvitationIntoTeamFolder; use Domain\Teams\Notifications\InvitationIntoTeamFolder;