-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #270 - refresh inidicator added * #270 - added last update component * #270 - update * #270 - configurable refresh time * #270 -c csf * #270 - added calendar to refreshable pages * #270 - fix connected with previous PR
- Loading branch information
1 parent
eb00bd2
commit b66edef
Showing
16 changed files
with
172 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Toby\Domain\Listeners; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Cache\CacheManager; | ||
use Toby\Domain\Events\VacationRequestChanged; | ||
|
||
class UpdateLastUpdateCache | ||
{ | ||
public function __construct( | ||
protected CacheManager $cacheManager, | ||
) {} | ||
|
||
public function handle(VacationRequestChanged $event): void | ||
{ | ||
$this->cacheManager->set("last_update", Carbon::now()->toIso8601String()); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Infrastructure/Http/Controllers/Api/LastUpdateController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Toby\Infrastructure\Http\Controllers\Api; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Cache\CacheManager; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
|
||
class LastUpdateController | ||
{ | ||
public function __invoke(CacheManager $cache): JsonResponse | ||
{ | ||
return new JsonResponse([ | ||
"lastUpdate" => $cache->get("last_update", Carbon::now()->toIso8601String()), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
version: "3.8" | ||
|
||
services: | ||
app: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_LAST_UPDATE_TIMEOUT=300000 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script setup> | ||
import { onMounted } from 'vue' | ||
import axios from 'axios' | ||
import { updateFavicon } from '@/Shared/updateFavicon' | ||
const props = defineProps({ | ||
lastUpdate: String, | ||
}) | ||
const emit = defineEmits(['lastUpdateUpdated']) | ||
const fetchLastUpdate = async () => { | ||
try { | ||
const response = await axios.get('/api/last-update') | ||
if (response.data.lastUpdate !== props.lastUpdate) { | ||
emit('lastUpdateUpdated') | ||
updateFavicon('/images/icon-alert.png') | ||
} | ||
} catch (error) { | ||
console.error('Failed to fetch last update.') | ||
} | ||
} | ||
onMounted(() => { | ||
fetchLastUpdate() | ||
setInterval(fetchLastUpdate, import.meta.env.VITE_LAST_UPDATE_TIMEOUT) | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.