Compare commits
No commits in common. "437791b58109d42002e6498960bf9fe39fb52419" and "a3235c70e70f8330ed174bc4600367ef27369623" have entirely different histories.
437791b581
...
a3235c70e7
@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire\Settings;
|
|
||||||
|
|
||||||
use App\Models\Settings;
|
|
||||||
use Livewire\Component;
|
|
||||||
|
|
||||||
class Synapse extends Component
|
|
||||||
{
|
|
||||||
public string $synapseEndpoint;
|
|
||||||
|
|
||||||
public string $synapseAccessToken;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mount the component.
|
|
||||||
*/
|
|
||||||
public function mount(): void
|
|
||||||
{
|
|
||||||
$this->synapseEndpoint = Settings::get('synapse_endpoint', '');
|
|
||||||
$this->synapseAccessToken = Settings::get('synapse_access_token', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(): void
|
|
||||||
{
|
|
||||||
Settings::set('synapse_endpoint', $this->synapseEndpoint);
|
|
||||||
Settings::set('synapse_access_token', $this->synapseAccessToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
return view('livewire.settings.synapse');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class Settings extends Model
|
|
||||||
{
|
|
||||||
protected $fillable = [
|
|
||||||
'key',
|
|
||||||
'value'
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function get($key, $default = null)
|
|
||||||
{
|
|
||||||
return static::where('key', $key)->value('value') ?? $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function set($key, $value)
|
|
||||||
{
|
|
||||||
return static::updateOrCreate(['key' => $key], ['value' => $value]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Models\Settings;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@ -11,8 +9,8 @@ class SynapseService
|
|||||||
{
|
{
|
||||||
public function createRegistrationToken(): ?string
|
public function createRegistrationToken(): ?string
|
||||||
{
|
{
|
||||||
$token = Settings::get('synapse_access_token', '');
|
$token = config('synapse.admin_api_token');
|
||||||
$endpoint = Settings::get('synapse_endpoint', '');
|
$endpoint = config('synapse.admin_api_url');
|
||||||
|
|
||||||
$response = Http::withHeaders([
|
$response = Http::withHeaders([
|
||||||
'Authorization' => "Bearer $token",
|
'Authorization' => "Bearer $token",
|
||||||
|
27
config/synapse.php
Normal file
27
config/synapse.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Admin API Token
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This variable contains the authorization bearer for synapse.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'admin_api_token' => env('SYNAPSE_ADMIN_API_TOKEN'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Admin API Endpoint
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This variable contains the admin endpoint for synapse.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'admin_api_url' => env('SYNAPSE_ADMIN_API_URL'),
|
||||||
|
|
||||||
|
];
|
@ -1,29 +0,0 @@
|
|||||||
<?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::create('settings', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->string('key')->unique();
|
|
||||||
$table->string('value');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('settings');
|
|
||||||
}
|
|
||||||
};
|
|
@ -10,7 +10,6 @@
|
|||||||
<flux:navlist variant="outline">
|
<flux:navlist variant="outline">
|
||||||
<flux:navlist.group :heading="__('Platform')" class="grid">
|
<flux:navlist.group :heading="__('Platform')" class="grid">
|
||||||
<flux:navlist.item icon="document-text" :href="route('dashboard')" :current="request()->routeIs('dashboard')" wire:navigate>{{ __('Applications') }}</flux:navlist.item>
|
<flux:navlist.item icon="document-text" :href="route('dashboard')" :current="request()->routeIs('dashboard')" wire:navigate>{{ __('Applications') }}</flux:navlist.item>
|
||||||
<flux:navlist.item icon="wrench-screwdriver" :href="route('settings.synapse')" :current="request()->routeIs('settings.synapse')" wire:navigate>{{ __('Synapse') }}</flux:navlist.item>
|
|
||||||
</flux:navlist.group>
|
</flux:navlist.group>
|
||||||
</flux:navlist>
|
</flux:navlist>
|
||||||
|
|
||||||
|
@ -9,13 +9,6 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if ($error)
|
|
||||||
<flux:callout variant="danger" icon="x-circle" class="mb-4">
|
|
||||||
<flux:callout.heading>Something went wrong. Most likely your synapse access token is invalid or expired!
|
|
||||||
</flux:callout.heading>
|
|
||||||
</flux:callout>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<table class="w-full border-collapse border border-gray-300 dark:border-neutral-950 rounded-lg">
|
<table class="w-full border-collapse border border-gray-300 dark:border-neutral-950 rounded-lg">
|
||||||
<thead class="bg-gray-100 dark:bg-neutral-900">
|
<thead class="bg-gray-100 dark:bg-neutral-900">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<div class="flex items-start max-md:flex-col">
|
|
||||||
|
|
||||||
<div class="flex-1 self-stretch max-md:pt-6">
|
|
||||||
<div class="relative mb-6 w-full">
|
|
||||||
<flux:heading size="xl" level="1">{{ __('Settings') }}</flux:heading>
|
|
||||||
<flux:subheading size="lg" class="mb-6">{{ __('Manage synapse endpoint and access token') }}
|
|
||||||
</flux:subheading>
|
|
||||||
<flux:separator variant="subtle" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex flex-col gap-4 mt-5 w-full max-w-lg">
|
|
||||||
<flux:input wire:model="synapseEndpoint" placeholder="https://matrix.tld" label="Synapse Endpoint"
|
|
||||||
clearable />
|
|
||||||
|
|
||||||
<flux:input wire:model="synapseAccessToken" type="password" value="password" label="Access Token"
|
|
||||||
viewable />
|
|
||||||
|
|
||||||
<flux:button variant="primary" class="w-full" wire:click="save">Save</flux:button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -3,7 +3,6 @@
|
|||||||
use App\Livewire\Settings\Appearance;
|
use App\Livewire\Settings\Appearance;
|
||||||
use App\Livewire\Settings\Password;
|
use App\Livewire\Settings\Password;
|
||||||
use App\Livewire\Settings\Profile;
|
use App\Livewire\Settings\Profile;
|
||||||
use App\Livewire\Settings\Synapse;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', App\Livewire\ApplicationForm::class)->name('home');
|
Route::get('/', App\Livewire\ApplicationForm::class)->name('home');
|
||||||
@ -19,7 +18,6 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
Route::get('settings/profile', Profile::class)->name('settings.profile');
|
Route::get('settings/profile', Profile::class)->name('settings.profile');
|
||||||
Route::get('settings/password', Password::class)->name('settings.password');
|
Route::get('settings/password', Password::class)->name('settings.password');
|
||||||
Route::get('settings/appearance', Appearance::class)->name('settings.appearance');
|
Route::get('settings/appearance', Appearance::class)->name('settings.appearance');
|
||||||
Route::get('settings/synapse', Synapse::class)->name('settings.synapse');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
require __DIR__ . '/auth.php';
|
require __DIR__ . '/auth.php';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user