fix: services

This commit is contained in:
Andras Bacsai
2023-09-27 21:51:06 +02:00
parent fe8a7fc54f
commit d609fcaee1
5 changed files with 51 additions and 23 deletions

View File

@@ -23,6 +23,7 @@ class Select extends Component
public array $parameters;
public Collection|array $services = [];
public bool $loadingServices = true;
public bool $loading = false;
public ?string $existingPostgresqlUrl = null;
@@ -61,19 +62,19 @@ class Select extends Component
}
if (isDev()) {
$cached = Cache::remember('services', 3600, function () {
$services = File::get(base_path('examples/service-templates.json'));
$services = collect(json_decode($services));
$services = File::get(base_path('templates/service-templates.json'));
$services = collect(json_decode($services))->sortKeys();
$this->emit('success', 'Successfully reloaded services from filesystem (development mode).');
return $services;
});
} else {
$cached = Cache::remember('services', 3600, function () {
$services = Http::get(config('constants.services.offical'));
$services = Http::get(config('constants.services.official'));
if ($services->failed()) {
throw new \Exception($services->body());
}
$services = collect($services->json());
$services = collect($services->json())->sortKeys();
$this->emit('success', 'Successfully reloaded services from the internet.');
return $services;
});
@@ -89,6 +90,8 @@ class Select extends Component
public function setType(string $type)
{
$this->type = $type;
if ($this->loading) return;
$this->loading = true;
if ($type === "existing-postgresql") {
$this->current_step = $type;
return;