-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
462 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
database/migrations/2024_01_22_202432_update_settings_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('settings', function (Blueprint $table) { | ||
$table->string('group')->after('id')->default('cachet'); | ||
$table->boolean('locked')->default(false)->after('name'); | ||
$table->json('payload')->after('locked'); | ||
|
||
$table->text('value')->nullable()->change(); | ||
|
||
$table->unique(['group', 'name']); | ||
}); | ||
} | ||
}; |
52 changes: 52 additions & 0 deletions
52
database/migrations/2024_01_22_205002_migrate_settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Str; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
// If there are no settings, then there's nothing to migrate. | ||
if (DB::table('settings')->count() === 0) { | ||
return; | ||
} | ||
|
||
DB::table('settings') | ||
->get() | ||
->each(function ($setting) { | ||
DB::table('settings')->select('id', 'name', 'value')->where('id', $setting->id)->update([ | ||
'name' => $this->settingName($setting->name), | ||
'group' => $this->settingGroup($setting->name), | ||
'payload' => json_encode($setting->value), | ||
]); | ||
}); | ||
} | ||
|
||
private function settingName(string $name): string | ||
{ | ||
return match (true) { | ||
Str::startsWith($name, ['app_']) => Str::replaceFirst('app_', '', $name), | ||
Str::startsWith($name, ['style_']) => Str::replaceFirst('style_', '', $name), | ||
Str::startsWith($name, ['analytics_']) => Str::replaceFirst('analytics_', '', $name), | ||
default => $name, | ||
}; | ||
} | ||
|
||
private function settingGroup(string $name): string | ||
{ | ||
return match (true) { | ||
Str::startsWith($name, ['app_', 'show_support', 'display_graphs', 'enable_subscribers', 'dashboard_']) => 'app', | ||
Str::contains($name, ['header', 'footer', 'stylesheet']) => 'customization', | ||
Str::startsWith($name, ['style_']) => 'theme', | ||
Str::contains($name, ['date_format', 'automatic_localization']) => 'localization', | ||
Str::contains($name, ['always_authenticate', 'allowed_domains']) => 'security', | ||
Str::contains($name, ['analytics_']) => 'analytics', | ||
default => 'cachet', | ||
}; | ||
} | ||
}; |
35 changes: 35 additions & 0 deletions
35
database/migrations/2024_01_22_205110_create_default_settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Str; | ||
use Spatie\LaravelSettings\Migrations\SettingsMigration; | ||
|
||
return new class extends SettingsMigration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
// Cachet settings... | ||
rescue(fn () => $this->migrator->add('app.install_id', Str::random(40))); | ||
rescue(fn () => $this->migrator->add('app.name', 'Cachet')); | ||
rescue(fn () => $this->migrator->add('app.domain')); | ||
rescue(fn () => $this->migrator->add('app.about')); | ||
rescue(fn () => $this->migrator->add('app.timezone', 'UTC')); | ||
rescue(fn () => $this->migrator->add('app.locale', 'en')); | ||
rescue(fn () => $this->migrator->add('app.incident_days', 7)); | ||
rescue(fn () => $this->migrator->add('app.refresh_rate')); | ||
rescue(fn () => $this->migrator->add('app.display_graphs', true)); | ||
rescue(fn () => $this->migrator->add('app.show_support', true)); | ||
rescue(fn () => $this->migrator->add('app.show_timezone', false)); | ||
rescue(fn () => $this->migrator->add('app.only_disrupted_days', false)); | ||
|
||
// Customization settings... | ||
rescue(fn () => $this->migrator->add('customization.header')); | ||
rescue(fn () => $this->migrator->add('customization.footer')); | ||
rescue(fn () => $this->migrator->add('customization.stylesheet')); | ||
|
||
// Theme settings... | ||
rescue(fn () => $this->migrator->add('theme.app_banner')); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div> | ||
<h2 class="text-3xl font-semibold">{{ __('About This Site') }}</h2> | ||
<div class="prose-sm md:prose prose-zinc mt-1 dark:prose-invert prose-a:text-primary-500 prose-a:underline"> | ||
{!! $about !!} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,23 @@ | ||
<x-cachet::cachet> | ||
<x-cachet::header/> | ||
<x-cachet::header /> | ||
|
||
<div class="mx-auto max-w-5xl px-4 py-10 sm:px-6 lg:px-8"> | ||
<div> | ||
<h2 class="text-3xl font-semibold">About This Site</h2> | ||
<div class="prose prose-zinc mt-1 dark:prose-invert prose-a:text-primary-500 prose-a:underline"> | ||
{{-- format-ignore-start --}} | ||
<p> | ||
This is the demo instance of <a href="https://cachethq.io/" target="_blank">Cachet</a>. The | ||
open-source status page system. | ||
</p> | ||
{{-- format-ignore-end --}} | ||
</div> | ||
</div> | ||
<x-cachet::about /> | ||
|
||
<div class="mt-6 space-y-10"> | ||
<x-cachet::status-bar/> | ||
<x-cachet::status-bar /> | ||
|
||
@foreach($componentGroups as $componentGroup) | ||
<x-cachet::component-group :component-group="$componentGroup"/> | ||
<x-cachet::component-group :component-group="$componentGroup"/> | ||
@endforeach | ||
|
||
@if($schedules->isNotEmpty()) | ||
<x-cachet::schedules :schedules="$schedules" /> | ||
@endif | ||
|
||
<x-cachet::incidents/> | ||
<x-cachet::incidents /> | ||
</div> | ||
</div> | ||
|
||
<x-cachet::footer/> | ||
<x-cachet::footer /> | ||
</x-cachet::cachet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Cachet\Filament\Pages; | ||
|
||
use Cachet\Settings\AppSettings; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Pages\SettingsPage; | ||
use Illuminate\Support\Str; | ||
|
||
class ManageCachet extends SettingsPage | ||
{ | ||
protected static string $settings = AppSettings::class; | ||
|
||
protected static ?string $navigationGroup = 'Settings'; | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\Section::make()->columns(2)->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->label(__('Site Name')) | ||
->maxLength(255), | ||
Forms\Components\MarkdownEditor::make('about') | ||
->label(__('About This Site')) | ||
->columnSpanFull(), | ||
|
||
Forms\Components\Select::make('timezone') | ||
->label(__('Timezone')) | ||
->options(fn () => collect(timezone_identifiers_list()) | ||
->mapToGroups( | ||
fn($timezone) => [ | ||
Str::of($timezone) | ||
->before("/") | ||
->toString() => [$timezone => $timezone] | ||
] | ||
) | ||
->map(fn($group) => $group->collapse())) | ||
->searchable() | ||
->suffixIcon('heroicon-o-globe-alt'), | ||
|
||
Forms\Components\TextInput::make('incident_days') | ||
->numeric() | ||
->label(__('Incident Days')) | ||
->minValue(1) | ||
->maxValue(365) | ||
->step(1), | ||
|
||
Forms\Components\TextInput::make('refresh_rate') | ||
->numeric() | ||
->label(__('Automatically Refresh Page')) | ||
->minValue(0) | ||
->nullable() | ||
->step(1) | ||
->suffix(__('seconds')), | ||
|
||
Forms\Components\Grid::make(2) | ||
->schema([ | ||
Forms\Components\Toggle::make('show_support') | ||
->label(__('Support Cachet')), | ||
Forms\Components\Toggle::make('display_graphs') | ||
->label(__('Display Graphs')), | ||
]), | ||
Forms\Components\Toggle::make('show_timezone') | ||
->label(__('Show Timezone')), | ||
Forms\Components\Toggle::make('only_disrupted_days') | ||
->label(__('Only Show Disrupted Days')), | ||
]), | ||
]); | ||
} | ||
} |
Oops, something went wrong.