chore: Refactor loadServices2 method and remove unused code
This commit is contained in:
@@ -49,11 +49,8 @@ class Select extends Component
|
|||||||
|
|
||||||
public ?string $existingPostgresqlUrl = null;
|
public ?string $existingPostgresqlUrl = null;
|
||||||
|
|
||||||
public ?string $search = null;
|
|
||||||
|
|
||||||
protected $queryString = [
|
protected $queryString = [
|
||||||
'server_id',
|
'server_id',
|
||||||
'search',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@@ -90,13 +87,13 @@ class Select extends Component
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function loadServices2()
|
public function loadServices()
|
||||||
{
|
{
|
||||||
$services = get_service_templates(true);
|
$services = get_service_templates(true);
|
||||||
$services = collect($services)->map(function ($service, $key) {
|
$services = collect($services)->map(function ($service, $key) {
|
||||||
return [
|
return [
|
||||||
'name' => str($key)->headline(),
|
'name' => str($key)->headline(),
|
||||||
'logo' => asset(data_get($service, 'logo', 'svgs/unknown.svg')),
|
'logo' => asset(data_get($service, 'logo', 'svgs/coolify.png')),
|
||||||
] + (array) $service;
|
] + (array) $service;
|
||||||
})->all();
|
})->all();
|
||||||
$gitBasedApplications = [
|
$gitBasedApplications = [
|
||||||
@@ -205,42 +202,6 @@ class Select extends Component
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatedSearch()
|
|
||||||
{
|
|
||||||
$this->loadServices();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function loadServices(bool $force = false)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->loadingServices = true;
|
|
||||||
if (count($this->allServices) > 0 && ! $force) {
|
|
||||||
if (! $this->search) {
|
|
||||||
$this->services = $this->allServices;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->services = $this->allServices->filter(function ($service, $key) {
|
|
||||||
$tags = collect(data_get($service, 'tags', []));
|
|
||||||
|
|
||||||
return str_contains(strtolower($key), strtolower($this->search)) || $tags->contains(function ($tag) {
|
|
||||||
return str_contains(strtolower($tag), strtolower($this->search));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$this->search = null;
|
|
||||||
$this->allServices = get_service_templates($force);
|
|
||||||
$this->services = $this->allServices->filter(function ($service, $key) {
|
|
||||||
return str_contains(strtolower($key), strtolower($this->search));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
} finally {
|
|
||||||
$this->loadingServices = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
if ($this->includeSwarm) {
|
if ($this->includeSwarm) {
|
||||||
|
@@ -10,13 +10,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pb-4">Deploy resources, like Applications, Databases, Services...</div>
|
<div class="pb-4">Deploy resources, like Applications, Databases, Services...</div>
|
||||||
<div class="flex flex-col gap-4 py-4" x-data="searchResources()">
|
<div x-data="searchResources()">
|
||||||
@if ($current_step === 'type')
|
@if ($current_step === 'type')
|
||||||
<div class="sticky top-0 z-50 py-2">
|
<div class="sticky top-0 z-50 py-2">
|
||||||
<input autocomplete="off" x-ref="searchInput" class="input w-full" x-model="search"
|
<input autocomplete="off" x-ref="searchInput" class="input w-full" x-model="search"
|
||||||
placeholder="Type / to search..." @keydown.window.slash.prevent="$refs.searchInput.focus()">
|
placeholder="Type / to search..." @keydown.window.slash.prevent="$refs.searchInput.focus()">
|
||||||
</div>
|
</div>
|
||||||
<div x-show="loading">Loading...</div>
|
<div x-show="loading">Loading...</div>
|
||||||
|
<div x-show="!loading" class="flex flex-col gap-4 py-4">
|
||||||
<h2 x-show="filteredGitBasedApplications.length > 0">Applications</h2>
|
<h2 x-show="filteredGitBasedApplications.length > 0">Applications</h2>
|
||||||
<h4 x-show="filteredGitBasedApplications.length > 0">Git Based</h4>
|
<h4 x-show="filteredGitBasedApplications.length > 0">Git Based</h4>
|
||||||
<div x-show="filteredGitBasedApplications.length > 0"
|
<div x-show="filteredGitBasedApplications.length > 0"
|
||||||
@@ -75,11 +76,13 @@
|
|||||||
<h2>Services</h2>
|
<h2>Services</h2>
|
||||||
<x-forms.button x-on:click="loadResources">Reload List</x-forms.button>
|
<x-forms.button x-on:click="loadResources">Reload List</x-forms.button>
|
||||||
</div>
|
</div>
|
||||||
<div class="pb-4 text-xs">Trademarks Policy: The respective trademarks mentioned here are owned by the
|
<div class="pb-4 text-xs">Trademarks Policy: The respective trademarks mentioned here are owned by
|
||||||
|
the
|
||||||
respective
|
respective
|
||||||
companies, and use of them does not imply any affiliation or endorsement.<br>Find more services <a
|
companies, and use of them does not imply any affiliation or endorsement.<br>Find more services
|
||||||
class="dark:text-white underline" target="_blank"
|
<a class="dark:text-white underline" target="_blank"
|
||||||
href="https://coolify.io/docs/services">here</a>.</div>
|
href="https://coolify.io/docs/services">here</a>.
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="grid justify-start grid-cols-1 gap-4 text-left xl:grid-cols-2">
|
<div class="grid justify-start grid-cols-1 gap-4 text-left xl:grid-cols-2">
|
||||||
<template x-for="service in filteredServices" :key="service.name">
|
<template x-for="service in filteredServices" :key="service.name">
|
||||||
@@ -121,6 +124,7 @@
|
|||||||
x-show="filteredGitBasedApplications.length === 0 && filteredDockerBasedApplications.length === 0 && filteredDatabases.length === 0 && filteredServices.length === 0 && loading === false">
|
x-show="filteredGitBasedApplications.length === 0 && filteredDockerBasedApplications.length === 0 && filteredDatabases.length === 0 && filteredServices.length === 0 && loading === false">
|
||||||
<div>No resources found.</div>
|
<div>No resources found.</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function sortFn(a, b) {
|
function sortFn(a, b) {
|
||||||
return a.name.localeCompare(b.name)
|
return a.name.localeCompare(b.name)
|
||||||
@@ -144,7 +148,7 @@
|
|||||||
gitBasedApplications,
|
gitBasedApplications,
|
||||||
dockerBasedApplications,
|
dockerBasedApplications,
|
||||||
databases
|
databases
|
||||||
} = await this.$wire.loadServices2();
|
} = await this.$wire.loadServices();
|
||||||
this.services = services;
|
this.services = services;
|
||||||
this.gitBasedApplications = gitBasedApplications;
|
this.gitBasedApplications = gitBasedApplications;
|
||||||
this.dockerBasedApplications = dockerBasedApplications;
|
this.dockerBasedApplications = dockerBasedApplications;
|
||||||
|
Reference in New Issue
Block a user