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

71 lines
2.3 KiB
PHP
Raw Normal View History

2023-03-20 12:04:22 +00:00
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
2023-03-20 12:04:22 +00:00
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ $title ?? 'Coolify' }}</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
@vite(['resources/js/app.js', 'resources/css/app.css'])
2023-04-25 08:06:45 +00:00
<style>
[x-cloak] {
display: none !important;
}
</style>
2023-03-20 12:04:22 +00:00
@livewireStyles
</head>
<body x-data="confirmModal">
2023-04-27 09:29:02 +00:00
@auth
<x-navbar />
@endauth
<main>
2023-03-20 12:04:22 +00:00
{{ $slot }}
</main>
<x-confirm-modal />
2023-03-20 12:04:22 +00:00
@livewireScripts
2023-04-28 09:54:01 +00:00
@auth
<script>
2023-04-28 13:08:48 +00:00
function checkIfIamDead() {
checkIfIamDeadInterval = setInterval(async () => {
console.log('Checking server\'s pulse...')
const res = await fetch('/api/health');
if (!res.ok) {
console.log('I\'m dead. Charging... Standby... Bzz... Bzz...')
checkHealth();
if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
2023-04-28 13:32:50 +00:00
} else {
console.log('I\'m alive. Waiting for server to be dead...');
2023-04-28 13:08:48 +00:00
}
return;
}, 2000);
}
function checkHealth() {
checkHealthInterval = setInterval(async () => {
console.log('Checking server\'s health...')
2023-04-28 09:54:01 +00:00
const res = await fetch('/api/health');
if (res.ok) {
2023-04-28 13:08:48 +00:00
console.log('Server is back online. Reloading...')
if (checkHealthInterval) clearInterval(checkHealthInterval);
2023-04-28 09:54:01 +00:00
window.location.reload();
} else {
2023-04-28 13:08:48 +00:00
console.log('Waiting for server to come back from dead...');
2023-04-28 09:54:01 +00:00
}
return;
}, 2000);
2023-04-28 13:08:48 +00:00
}
Livewire.on('updateInitiated', () => {
let checkHealthInterval = null;
let checkIfIamDeadInterval = null;
console.log('Update initiated. Waiting for server to be dead...')
checkIfIamDead();
2023-04-28 09:54:01 +00:00
})
</script>
@endauth
2023-03-20 12:04:22 +00:00
</body>
</html>