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

87 lines
2.7 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">
2023-05-04 06:33:06 +00:00
@env('local')
<title>Coolify - localhost</title>
@endenv
@env('production')
2023-03-20 12:04:22 +00:00
<title>{{ $title ?? 'Coolify' }}</title>
2023-05-04 06:33:06 +00:00
@endenv
2023-03-20 12:04:22 +00:00
<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() {
2023-04-28 13:37:09 +00:00
console.log('Checking server\'s pulse...')
2023-04-28 13:08:48 +00:00
checkIfIamDeadInterval = setInterval(async () => {
2023-04-28 13:37:09 +00: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 13:08:48 +00:00
console.log('I\'m dead. Charging... Standby... Bzz... Bzz...')
checkHealth();
if (checkIfIamDeadInterval) clearInterval(checkIfIamDeadInterval);
}
return;
}, 2000);
}
function checkHealth() {
2023-04-28 13:37:09 +00:00
console.log('Checking server\'s health...')
2023-04-28 13:08:48 +00:00
checkHealthInterval = setInterval(async () => {
2023-04-28 13:37:09 +00: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 13:08:48 +00:00
console.log('Waiting for server to come back from dead...');
2023-04-28 09:54:01 +00:00
}
2023-04-28 13:37:09 +00:00
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
})
2023-05-04 13:45:53 +00:00
Livewire.on('reloadWindow', () => {
window.location.reload();
})
2023-05-04 20:29:14 +00:00
Livewire.on('error', (message) => {
alert(message);
})
2023-04-28 09:54:01 +00:00
</script>
@endauth
2023-03-20 12:04:22 +00:00
</body>
</html>