This commit is contained in:
Andras Bacsai 2023-06-07 17:24:37 +02:00
parent 881bae0a15
commit 1fa077fc8a
11 changed files with 43 additions and 37 deletions

View File

@ -17,7 +17,7 @@ class DiscordSettings extends Component
'model.extra_attributes.discord_webhook' => 'required|url', 'model.extra_attributes.discord_webhook' => 'required|url',
]; ];
protected $validationAttributes = [ protected $validationAttributes = [
'model.extra_attributes.discord_webhook' => '', 'model.extra_attributes.discord_webhook' => 'Discord Webhook',
]; ];
public function instantSave() public function instantSave()

View File

@ -2,7 +2,10 @@
namespace App\Http\Livewire\Notifications; namespace App\Http\Livewire\Notifications;
use App\Models\InstanceSettings;
use App\Models\Team; use App\Models\Team;
use App\Notifications\TestNotification;
use Illuminate\Support\Facades\Notification;
use Livewire\Component; use Livewire\Component;
class EmailSettings extends Component class EmailSettings extends Component
@ -33,6 +36,22 @@ class EmailSettings extends Component
'model.extra_attributes.smtp_password' => '', 'model.extra_attributes.smtp_password' => '',
'model.extra_attributes.smtp_test_recipients' => '', 'model.extra_attributes.smtp_test_recipients' => '',
]; ];
public function copySMTP()
{
$settings = InstanceSettings::get();
$this->model->extra_attributes->smtp_active = true;
$this->model->extra_attributes->smtp_from_address = $settings->extra_attributes->smtp_from_address;
$this->model->extra_attributes->smtp_from_name = $settings->extra_attributes->smtp_from_name;
$this->model->extra_attributes->smtp_recipients = $settings->extra_attributes->smtp_recipients;
$this->model->extra_attributes->smtp_host = $settings->extra_attributes->smtp_host;
$this->model->extra_attributes->smtp_port = $settings->extra_attributes->smtp_port;
$this->model->extra_attributes->smtp_encryption = $settings->extra_attributes->smtp_encryption;
$this->model->extra_attributes->smtp_username = $settings->extra_attributes->smtp_username;
$this->model->extra_attributes->smtp_password = $settings->extra_attributes->smtp_password;
$this->model->extra_attributes->smtp_timeout = $settings->extra_attributes->smtp_timeout;
$this->model->extra_attributes->smtp_test_recipients = $settings->extra_attributes->smtp_test_recipients;
$this->saveModel();
}
public function submit() public function submit()
{ {
$this->resetErrorBag(); $this->resetErrorBag();
@ -48,6 +67,10 @@ private function saveModel()
session(['currentTeam' => $this->model]); session(['currentTeam' => $this->model]);
} }
} }
public function sendTestNotification()
{
Notification::send($this->model, new TestNotification);
}
public function instantSave() public function instantSave()
{ {
try { try {

View File

@ -1,19 +0,0 @@
<?php
namespace App\Http\Livewire\Notifications;
use App\Models\Server;
use App\Models\Team;
use App\Notifications\TestNotification;
use Livewire\Component;
use Notification;
class Test extends Component
{
public Team $model;
public function sendTestNotification()
{
Notification::send($this->model, new TestNotification);
$this->emit('saved', 'Test notification sent.');
}
}

View File

@ -2,7 +2,8 @@
<h1>Team</h1> <h1>Team</h1>
<div class="text-sm breadcrumbs pb-11"> <div class="text-sm breadcrumbs pb-11">
<ul> <ul>
<li>{{ session('currentTeam.name') }}</li> <li>Currently Active Team</li>
<li class="font-bold">{{ session('currentTeam.name') }}</li>
</ul> </ul>
</div> </div>
<nav class="flex items-center gap-4 py-2 border-b-2 border-solid border-coolgray-200"> <nav class="flex items-center gap-4 py-2 border-b-2 border-solid border-coolgray-200">

View File

@ -1,2 +1,2 @@
Use the magic <br><br>Use the magic
bar (press <span class="kbd-custom">/</span>) to create a new one. bar (press <span class="kbd-custom">/</span>) to create a new one.

View File

@ -5,6 +5,10 @@
<x-forms.button type="submit"> <x-forms.button type="submit">
Save Save
</x-forms.button> </x-forms.button>
<x-forms.button class="text-white normal-case btn btn-xs no-animation btn-primary"
wire:click="sendTestNotification">
Send Test Notifications
</x-forms.button>
</div> </div>
<div class="flex flex-col gap-2 xl:flex-row w-96"> <div class="flex flex-col gap-2 xl:flex-row w-96">
<x-forms.checkbox instantSave id="model.extra_attributes.discord_active" label="Notification Enabled" /> <x-forms.checkbox instantSave id="model.extra_attributes.discord_active" label="Notification Enabled" />

View File

@ -5,6 +5,15 @@
<x-forms.button type="submit"> <x-forms.button type="submit">
Save Save
</x-forms.button> </x-forms.button>
@if (auth()->user()->isAdmin())
<x-forms.button wire:click='copySMTP'>
Copy from Instance Settings
</x-forms.button>
@endif
<x-forms.button class="text-white normal-case btn btn-xs no-animation btn-primary"
wire:click="sendTestNotification">
Send Test Notifications
</x-forms.button>
</div> </div>
<div class="flex flex-col w-96"> <div class="flex flex-col w-96">
<x-forms.checkbox instantSave id="model.extra_attributes.smtp_active" label="Notification Enabled" /> <x-forms.checkbox instantSave id="model.extra_attributes.smtp_active" label="Notification Enabled" />

View File

@ -1,6 +0,0 @@
<div class="flex items-center gap-2">
<h2>Notifications</h2>
<x-forms.button class="text-white normal-case btn btn-xs no-animation btn-primary" wire:click="sendTestNotification">
Send Test Notifications
</x-forms.button>
</div>

View File

@ -16,10 +16,6 @@ class="box">{{ $project->name }}</a>
No project found. No project found.
<x-use-magic-bar /> <x-use-magic-bar />
</div> </div>
<div>
If you do not have a project yet, just create a resource (application, database, etc.) first, it will
create a new project for you automatically.
</div>
@endforelse @endforelse
</div> </div>
</x-layout> </x-layout>

View File

@ -19,10 +19,9 @@
</div> </div>
</a> </a>
@empty @empty
<div class="flex flex-col"> <div>
<div>Without a server, you won't be able to do much.</div> <div>No servers found. Without a server, you won't be able to do much.</div>
<div>Let's <a class="text-lg underline text-warning" href="{{ route('server.create') }}">create</a> your <x-use-magic-bar />
first one.</div>
</div> </div>
@endforelse @endforelse
</div> </div>

View File

@ -1,6 +1,5 @@
<x-layout> <x-layout>
<x-team.navbar :team="session('currentTeam')" /> <x-team.navbar :team="session('currentTeam')" />
{{-- <livewire:notifications.test :model="session('currentTeam')" /> --}}
<div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'email' }" class="flex h-full"> <div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'email' }" class="flex h-full">
<div class="flex flex-col gap-4 min-w-fit"> <div class="flex flex-col gap-4 min-w-fit">
<a :class="activeTab === 'email' && 'text-white'" <a :class="activeTab === 'email' && 'text-white'"