mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 11:04:45 +02:00
show update info on dashboard, show git commit (when using git)
This commit is contained in:
parent
b9d1ce4438
commit
93f059025c
@ -26,7 +26,7 @@ class InfoCommand extends Command
|
||||
{
|
||||
$this->output->title('Version Information');
|
||||
$this->table([], [
|
||||
['Panel Version', config('app.version')],
|
||||
['Panel Version', $this->versionService->versionData()['version']],
|
||||
['Latest Version', $this->versionService->getPanel()],
|
||||
['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')],
|
||||
], 'compact');
|
||||
|
@ -7,6 +7,7 @@ use App\Models\Egg;
|
||||
use App\Models\Node;
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
use App\Services\Helpers\SoftwareVersionService;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Pages\Page;
|
||||
|
||||
@ -29,8 +30,14 @@ class Dashboard extends Page
|
||||
|
||||
public function getViewData(): array
|
||||
{
|
||||
/** @var SoftwareVersionService $softwareVersionService */
|
||||
$softwareVersionService = app(SoftwareVersionService::class);
|
||||
|
||||
return [
|
||||
'inDevelopment' => config('app.version') === 'canary',
|
||||
'version' => $softwareVersionService->versionData()['version'],
|
||||
'latestVersion' => $softwareVersionService->getPanel(),
|
||||
'isLatest' => $softwareVersionService->isLatestPanel(),
|
||||
'eggsCount' => Egg::query()->count(),
|
||||
'nodesList' => ListNodes::getUrl(),
|
||||
'nodesCount' => Node::query()->count(),
|
||||
@ -43,6 +50,12 @@ class Dashboard extends Page
|
||||
->icon('tabler-brand-github')
|
||||
->url('https://github.com/pelican-dev/panel/discussions', true),
|
||||
],
|
||||
'updateActions' => [
|
||||
CreateAction::make()
|
||||
->label('Read Documentation')
|
||||
->icon('tabler-clipboard-text')
|
||||
->url('https://pelican.dev/docs/panel/update', true),
|
||||
],
|
||||
'nodeActions' => [
|
||||
CreateAction::make()
|
||||
->label(trans('dashboard/index.sections.intro-first-node.button_label'))
|
||||
@ -53,7 +66,7 @@ class Dashboard extends Page
|
||||
CreateAction::make()
|
||||
->label(trans('dashboard/index.sections.intro-support.button_donate'))
|
||||
->icon('tabler-cash')
|
||||
->url('https://pelican.dev/donate', true)
|
||||
->url($softwareVersionService->getDonations(), true)
|
||||
->color('success'),
|
||||
],
|
||||
'helpActions' => [
|
||||
|
@ -6,6 +6,7 @@ use App\Extensions\Themes\Theme;
|
||||
use App\Models;
|
||||
use App\Models\ApiKey;
|
||||
use App\Models\Node;
|
||||
use App\Services\Helpers\SoftwareVersionService;
|
||||
use Dedoc\Scramble\Scramble;
|
||||
use Dedoc\Scramble\Support\Generator\OpenApi;
|
||||
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
||||
@ -30,8 +31,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
View::share('appVersion', $this->versionData()['version'] ?? 'undefined');
|
||||
View::share('appIsGit', $this->versionData()['is_git'] ?? false);
|
||||
$versionData = app(SoftwareVersionService::class)->versionData();
|
||||
View::share('appVersion', $versionData['version'] ?? 'undefined');
|
||||
View::share('appIsGit', $versionData['is_git'] ?? false);
|
||||
|
||||
Paginator::useBootstrap();
|
||||
|
||||
@ -96,34 +98,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
Scramble::ignoreDefaultRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return version information for the footer.
|
||||
*/
|
||||
protected function versionData(): array
|
||||
{
|
||||
return cache()->remember('git-version', 5, function () {
|
||||
if (file_exists(base_path('.git/HEAD'))) {
|
||||
$head = explode(' ', file_get_contents(base_path('.git/HEAD')));
|
||||
|
||||
if (array_key_exists(1, $head)) {
|
||||
$path = base_path('.git/' . trim($head[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($path) && file_exists($path)) {
|
||||
return [
|
||||
'version' => substr(file_get_contents($path), 0, 8),
|
||||
'is_git' => true,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'version' => config('app.version'),
|
||||
'is_git' => false,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function bootAuth(): void
|
||||
{
|
||||
Sanctum::usePersonalAccessTokenModel(ApiKey::class);
|
||||
|
@ -49,6 +49,14 @@ class SoftwareVersionService
|
||||
return Arr::get(self::$result, 'discord') ?? 'https://pelican.dev/discord';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the donation URL.
|
||||
*/
|
||||
public function getDonations(): string
|
||||
{
|
||||
return Arr::get(self::$result, 'donate') ?? 'https://pelican.dev/donate';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current version of the panel is the latest.
|
||||
*/
|
||||
@ -93,8 +101,28 @@ class SoftwareVersionService
|
||||
});
|
||||
}
|
||||
|
||||
public function getDonations(): string
|
||||
public function versionData(): array
|
||||
{
|
||||
return 'https://github.com';
|
||||
return cache()->remember('git-version', 5, function () {
|
||||
if (file_exists(base_path('.git/HEAD'))) {
|
||||
$head = explode(' ', file_get_contents(base_path('.git/HEAD')));
|
||||
|
||||
if (array_key_exists(1, $head)) {
|
||||
$path = base_path('.git/' . trim($head[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($path) && file_exists($path)) {
|
||||
return [
|
||||
'version' => 'canary (' . substr(file_get_contents($path), 0, 8) . ')',
|
||||
'is_git' => true,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'version' => config('app.version'),
|
||||
'is_git' => false,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ return [
|
||||
'button_issues' => 'Create Issue',
|
||||
'button_features' => 'Discuss Features',
|
||||
],
|
||||
'intro-update' => [
|
||||
'heading' => 'Update available',
|
||||
'content' => ':latestVersion is available! Read our documentation to update your Panel.',
|
||||
],
|
||||
'intro-first-node' => [
|
||||
'heading' => 'No Nodes Detected',
|
||||
'content' => "It looks like you don't have any Nodes set up yet, but don't worry because you click the action button to create your first one!",
|
||||
|
@ -4,7 +4,7 @@
|
||||
:actions="$this->getCachedHeaderActions()"
|
||||
:breadcrumbs="filament()->hasBreadcrumbs() ? $this->getBreadcrumbs() : []"
|
||||
:heading=" trans('dashboard/index.heading')"
|
||||
:subheading="trans('strings.version', ['version' => config('app.version')])"
|
||||
:subheading="trans('strings.version', ['version' => $version])"
|
||||
></x-filament-panels::header>
|
||||
|
||||
<p>{{ trans('dashboard/index.expand_sections') }}</p>
|
||||
@ -30,6 +30,22 @@
|
||||
</x-filament::section>
|
||||
@endif
|
||||
|
||||
@if (!$isLatest)
|
||||
<x-filament::section
|
||||
icon="tabler-info-circle"
|
||||
icon-color="primary"
|
||||
id="intro-update"
|
||||
collapsible
|
||||
persist-collapsed
|
||||
:header-actions="$updateActions"
|
||||
>
|
||||
<x-slot name="heading">{{ trans('dashboard/index.sections.intro-update.heading') }}</x-slot>
|
||||
|
||||
<p>{{ trans('dashboard/index.sections.intro-update.content', ['latestVersion' => $latestVersion]) }}</p>
|
||||
|
||||
</x-filament::section>
|
||||
@endif
|
||||
|
||||
{{-- No Nodes Created --}}
|
||||
@if ($nodesCount <= 0)
|
||||
<x-filament::section
|
||||
|
Loading…
x
Reference in New Issue
Block a user