This commit is contained in:
Andras Bacsai 2023-06-16 12:00:36 +02:00
parent c4c2e81701
commit 8daad8f8b8
12 changed files with 78 additions and 30 deletions

View File

@ -12,6 +12,10 @@ class GithubApp extends BaseModel
'is_public' => 'boolean', 'is_public' => 'boolean',
'type' => 'string' 'type' => 'string'
]; ];
protected $hidden = [
'client_secret',
'webhook_secret',
];
protected static function booted(): void protected static function booted(): void
{ {
static::deleting(function (GithubApp $github_app) { static::deleting(function (GithubApp $github_app) {

View File

@ -4,6 +4,10 @@ namespace App\Models;
class GitlabApp extends BaseModel class GitlabApp extends BaseModel
{ {
protected $hidden = [
'webhook_token',
'app_secret',
];
public function applications() public function applications()
{ {
return $this->morphMany(Application::class, 'source'); return $this->morphMany(Application::class, 'source');

View File

@ -11,6 +11,9 @@ class PrivateKey extends BaseModel
'private_key', 'private_key',
'team_id', 'team_id',
]; ];
protected $hidden = [
'private_key',
];
static public function ownedByCurrentTeam() static public function ownedByCurrentTeam()
{ {
return PrivateKey::whereTeamId(session('currentTeam')->id); return PrivateKey::whereTeamId(session('currentTeam')->id);

View File

@ -74,9 +74,10 @@ class Server extends BaseModel
{ {
return $this->hasOne(ServerSetting::class); return $this->hasOne(ServerSetting::class);
} }
static public function ownedByCurrentTeam() static public function ownedByCurrentTeam(array $select = ['*'])
{ {
return Server::whereTeamId(session('currentTeam')->id); $selectArray = collect($select)->concat(['id']);
return Server::whereTeamId(session('currentTeam')->id)->with('settings')->select($selectArray->all());
} }
static public function validated() static public function validated()

View File

@ -15,7 +15,10 @@ body {
@apply pl-24 pr-10 mx-auto max-w-screen-xl pt-4; @apply pl-24 pr-10 mx-auto max-w-screen-xl pt-4;
} }
input { input {
@apply input input-sm h-7 outline-none placeholder:text-neutral-700 text-white rounded bg-coolgray-200 w-full read-only:bg-coolgray-200/50 read-only:text-opacity-25 border-none; @apply input input-sm h-7 outline-none placeholder:text-neutral-700 text-white rounded bg-coolgray-200 w-full read-only:bg-coolgray-200/50 read-only:text-opacity-25;
}
input && :not(input[type="checkbox"]) {
@apply border-none;
} }
input[type="checkbox"] { input[type="checkbox"] {
@apply toggle toggle-warning toggle-xs rounded; @apply toggle toggle-warning toggle-xs rounded;

View File

@ -15,20 +15,21 @@
<div class="w-full"> <div class="w-full">
@if ($type === 'password') @if ($type === 'password')
<div class="w-full join" x-data> <div class="w-full rounded join" x-data>
<input class="join-item" @readonly($readonly) @disabled($disabled || $errors->isNotEmpty()) type={{ $type }} <input class="join-item" wire:model.defer={{ $id }} wire:dirty.class="input-warning"
id={{ $id }} name={{ $name }} value={{ $value }} @readonly($readonly) @disabled($disabled || $errors->isNotEmpty()) type={{ $type }} id={{ $id }}
placeholder={{ $placeholder }}> name={{ $name }} @isset($value) value={{ $value }} @endisset
@if ($cannotPeakPassword) @isset($placeholder) placeholder={{ $placeholder }} @endisset>
<span x-on:click="changePasswordFieldType('{{ $id }}')" x-cloak @if (!$cannotPeakPassword)
@class([ <span x-on:click="changePasswordFieldType" x-cloak @class([
'border-l-0 border-none rounded-r no-animation h-7 btn join-item btn-xs', 'border-l-0 border-none rounded-r no-animation h-7 btn join-item btn-xs',
'bg-coolgray-200/50 hover:bg-coolgray-200/50 text-opacity-25' => 'bg-coolgray-200/50 hover:bg-coolgray-200/50 text-opacity-25' =>
$disabled || $readonly, $disabled || $readonly,
'bg-coolgray-200 hover:bg-coolgray-200' => !$disabled || !$readonly, 'bg-coolgray-200 hover:bg-coolgray-200' => !$disabled || !$readonly,
])><svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 icon" ])><svg
viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 icon" viewBox="0 0 24 24"
stroke-linecap="round" stroke-linejoin="round"> stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" /> <path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
<path <path

View File

@ -27,13 +27,28 @@
</main> </main>
<x-version class="fixed left-2 bottom-1" /> <x-version class="fixed left-2 bottom-1" />
<script> <script>
function changePasswordFieldType(id) { function changePasswordFieldType(event) {
console.log(id) const element = event.target.parentElement.parentElement.children[0];
const input = document.getElementById(id); if (element.nodeName === 'INPUT') {
if (input.type === 'password') { if (element.type === 'password') {
input.type = 'text'; element.type = 'text';
} else { } else {
input.type = 'password'; element.type = 'password';
}
}
if (element.nodeName === 'DIV') {
if (element.children[0].type === 'password') {
element.children[0].type = 'text';
} else {
element.children[0].type = 'password';
}
}
if (element.nodeName === 'svg') {
if (element.parentElement.parentElement.children[0].type === 'password') {
element.parentElement.parentElement.children[0].type = 'text';
} else {
element.parentElement.parentElement.children[0].type = 'password';
}
} }
} }
</script> </script>

View File

@ -40,6 +40,24 @@
let checkHealthInterval = null; let checkHealthInterval = null;
let checkIfIamDeadInterval = null; let checkIfIamDeadInterval = null;
function changePasswordFieldType(event) {
const element = event.target.parentElement.parentElement.children[0];
if (element.nodeName === 'INPUT') {
if (element.type === 'password') {
element.type = 'text';
} else {
element.type = 'password';
}
}
if (element.nodeName === 'DIV') {
if (element.children[0].type === 'password') {
element.children[0].type = 'text';
} else {
element.children[0].type = 'password';
}
}
}
function revive() { function revive() {
console.log('Checking server\'s health...') console.log('Checking server\'s health...')
checkHealthInterval = setInterval(() => { checkHealthInterval = setInterval(() => {

View File

@ -8,7 +8,7 @@
:env="$env" /> :env="$env" />
@endforeach @endforeach
<div class="pt-2 pb-8"> <div class="pt-2 pb-8">
<livewire:project.application.environment-varia /ble.add /> <livewire:project.application.environment-variable.add />
</div> </div>
<div> <div>
<h3>Preview Deployments</h3> <h3>Preview Deployments</h3>

View File

@ -1,7 +1,7 @@
<div x-data="{ deleteEnvironment: false }"> <div x-data="{ deleteEnvironment: false }">
<form wire:submit.prevent='submit' class="flex flex-col gap-2 xl:items-end xl:flex-row"> <form wire:submit.prevent='submit' class="flex flex-col gap-2 xl:items-end xl:flex-row">
<x-forms.input id="env.key" label="Name" /> <x-forms.input id="env.key" label="Name" />
<x-forms.input id="env.value" label="Value" /> <x-forms.input type="password" id="env.value" label="Value" />
<x-forms.checkbox disabled id="env.is_build_time" label="Build Variable?" /> <x-forms.checkbox disabled id="env.is_build_time" label="Build Variable?" />
<div class="flex gap-2"> <div class="flex gap-2">
<x-forms.button type="submit"> <x-forms.button type="submit">

View File

@ -7,7 +7,6 @@
<div wire:loading wire:target="checkProxySettingsInSync"> <div wire:loading wire:target="checkProxySettingsInSync">
<x-loading /> <x-loading />
</div> </div>
@isset($proxy_settings) @isset($proxy_settings)
@if ($selectedProxy->value === 'TRAEFIK_V2') @if ($selectedProxy->value === 'TRAEFIK_V2')
<form wire:submit.prevent='saveConfiguration({{ $server }})'> <form wire:submit.prevent='saveConfiguration({{ $server }})'>

View File

@ -70,17 +70,17 @@ Route::middleware(['auth'])->group(function () {
'private_keys' => PrivateKey::ownedByCurrentTeam()->get(), 'private_keys' => PrivateKey::ownedByCurrentTeam()->get(),
]))->name('server.create'); ]))->name('server.create');
Route::get('/server/{server_uuid}', fn () => view('server.show', [ Route::get('/server/{server_uuid}', fn () => view('server.show', [
'server' => Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail(), 'server' => Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user'])->whereUuid(request()->server_uuid)->firstOrFail(),
]))->name('server.show'); ]))->name('server.show');
Route::get('/server/{server_uuid}/proxy', fn () => view('server.proxy', [ Route::get('/server/{server_uuid}/proxy', fn () => view('server.proxy', [
'server' => Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail(), 'server' => Server::ownedByCurrentTeam(['name', 'extra_attributes'])->whereUuid(request()->server_uuid)->firstOrFail(),
]))->name('server.proxy'); ]))->name('server.proxy');
Route::get('/server/{server_uuid}/private-key', fn () => view('server.private-key', [ Route::get('/server/{server_uuid}/private-key', fn () => view('server.private-key', [
'server' => Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail(), 'server' => Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail(),
'privateKeys' => PrivateKey::ownedByCurrentTeam()->get(), 'privateKeys' => PrivateKey::ownedByCurrentTeam()->get(),
]))->name('server.private-key'); ]))->name('server.private-key');
Route::get('/server/{server_uuid}/destinations', fn () => view('server.destinations', [ Route::get('/server/{server_uuid}/destinations', fn () => view('server.destinations', [
'server' => Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail() 'server' => Server::ownedByCurrentTeam(['name'])->whereUuid(request()->server_uuid)->firstOrFail()
]))->name('server.destinations'); ]))->name('server.destinations');
}); });