coolify/resources/views/components/layout.blade.php

93 lines
2.9 KiB
PHP
Raw Normal View History

2023-03-20 13:04:22 +01:00
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
2023-03-20 13:04:22 +01:00
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
2023-05-04 08:33:06 +02:00
@env('local')
<title>Coolify - localhost</title>
@endenv
@env('production')
2023-03-20 13:04:22 +01:00
<title>{{ $title ?? 'Coolify' }}</title>
2023-05-04 08:33:06 +02:00
@endenv
2023-03-20 13:04:22 +01:00
<meta name="csrf-token" content="{{ csrf_token() }}">
@vite(['resources/js/app.js', 'resources/css/app.css'])
2023-04-25 10:06:45 +02:00
<style>
[x-cloak] {
display: none !important;
}
</style>
2023-03-20 13:04:22 +01:00
@livewireStyles
</head>
2023-05-04 22:39:40 +02:00
<body>
2023-05-08 21:56:44 +02:00
@livewireScripts
2023-04-27 11:29:02 +02:00
@auth
<x-navbar />
@endauth
<main>
2023-03-20 13:04:22 +01:00
{{ $slot }}
</main>
2023-04-28 11:54:01 +02:00
@auth
<script>
2023-04-28 15:08:48 +02:00
function checkIfIamDead() {
2023-04-28 15:37:09 +02:00
console.log('Checking server\'s pulse...')
2023-04-28 15:08:48 +02:00
checkIfIamDeadInterval = setInterval(async () => {
2023-04-28 15:37:09 +02:00
try {
const res = await fetch('/api/health');
if (res.ok) {
console.log('I\'m alive. Waiting for server to be dead...');
}
} catch (error) {
2023-04-28 15:08:48 +02:00
console.log('I\'m dead. Charging... Standby... Bzz... Bzz...')
checkHealth();
if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
}
return;
}, 2000);
}
function checkHealth() {
2023-04-28 15:37:09 +02:00
console.log('Checking server\'s health...')
2023-04-28 15:08:48 +02:00
checkHealthInterval = setInterval(async () => {
2023-04-28 15:37:09 +02:00
try {
const res = await fetch('/api/health');
if (res.ok) {
console.log('Server is back online. Reloading...')
if (checkHealthInterval) clearInterval(checkHealthInterval);
window.location.reload();
}
} catch (error) {
2023-04-28 15:08:48 +02:00
console.log('Waiting for server to come back from dead...');
2023-04-28 11:54:01 +02:00
}
2023-04-28 15:37:09 +02:00
2023-04-28 11:54:01 +02:00
return;
}, 2000);
2023-04-28 15:08:48 +02:00
}
Livewire.on('updateInitiated', () => {
let checkHealthInterval = null;
let checkIfIamDeadInterval = null;
console.log('Update initiated. Waiting for server to be dead...')
checkIfIamDead();
2023-04-28 11:54:01 +02:00
})
2023-05-04 15:45:53 +02:00
Livewire.on('reloadWindow', () => {
window.location.reload();
})
2023-05-04 22:29:14 +02:00
Livewire.on('error', (message) => {
2023-05-08 13:36:49 +02:00
console.log(message);
2023-05-10 11:02:59 +02:00
alert(message);
2023-05-04 22:29:14 +02:00
})
2023-05-09 09:54:43 +02:00
Livewire.on('saved', (message) => {
if (message) console.log(message);
else console.log('saved');
})
2023-04-28 11:54:01 +02:00
</script>
@endauth
2023-05-08 21:56:44 +02:00
2023-03-20 13:04:22 +01:00
</body>
</html>