mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-07-22 23:38:10 -07:00
* add `auto_check_updates` config value * add `auto_check_updates` to dist config * add `Update` `NotificationType` * implement update checker and worker * add endpoint, add to documentation, add worker * clone update_status_lock Arc * fmt * add more tests * remove todo * add to docs * frontend update notice * improve name in documentation * add user-agent to update check request * add update check request timeout * openapi trait bound * do not enable `auto_check_updates` by default * remove redundant documentation * surface fetch of update status error * fail on version with pre-release for now, add additional test cases * Update configuration.md --------- Co-authored-by: Markus Unterwaditzer <markus-tarpit+git@unterwaditzer.net>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
get_wifi_status,
|
||||
scan_wifi_networks,
|
||||
GpsMode,
|
||||
enabled_notifications,
|
||||
type Config,
|
||||
type WifiStatus,
|
||||
type WifiNetwork,
|
||||
@@ -214,6 +215,22 @@
|
||||
<div class="border-t border-gray-200 pt-4 mt-6 space-y-3">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-4">Notification Settings</h3>
|
||||
|
||||
<div class="flex items-center">
|
||||
<input
|
||||
id="auto_check_updates"
|
||||
type="checkbox"
|
||||
bind:checked={config.auto_check_updates}
|
||||
class="h-4 w-4 text-rayhunter-blue focus:ring-rayhunter-blue border-gray-300 rounded-sm"
|
||||
/>
|
||||
<label for="auto_check_updates" class="ml-2 block text-sm text-gray-700">
|
||||
Automatically check for software updates
|
||||
</label>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500">
|
||||
When enabled, Rayhunter periodically checks GitHub for new releases and
|
||||
shows an update notice in the web UI.
|
||||
</p>
|
||||
|
||||
<ExpandableInput
|
||||
bind:value={config.ntfy_url}
|
||||
checkboxId="ntfy_enabled"
|
||||
@@ -295,6 +312,20 @@
|
||||
Low Battery
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="enable_update_notifications"
|
||||
value={enabled_notifications.Update}
|
||||
bind:group={config.enabled_notifications}
|
||||
/>
|
||||
<label
|
||||
for="enable_update_notifications"
|
||||
class="ml-2 block text-sm text-gray-700"
|
||||
>
|
||||
Software Updates
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</ExpandableInput>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import type { UpdateStatus } from '$lib/utils.svelte';
|
||||
|
||||
let { status = null }: { status: UpdateStatus | null } = $props();
|
||||
|
||||
let is_visible = $derived(
|
||||
Boolean(status?.update_available && status.latest_version && status.latest_release_url)
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if is_visible && status}
|
||||
<div class="bg-sky-100 border-sky-300 drop-shadow-sm p-4 flex flex-col gap-2 border rounded-md">
|
||||
<span class="text-xl font-bold flex flex-row items-center gap-2 text-sky-800">
|
||||
<svg
|
||||
class="w-6 h-6 text-sky-700"
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm11-4a1 1 0 1 0-2 0v5a1 1 0 1 0 2 0V8Zm-1 7a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2H12Z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
Software Update Available
|
||||
</span>
|
||||
<p>
|
||||
A new version of Rayhunter is available! You are currently running version {status.current_version},
|
||||
and the latest release is version {status.latest_version}.
|
||||
</p>
|
||||
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<span class="text-sm text-sky-900/80">
|
||||
View the latest release on GitHub to see what's new and download the update.
|
||||
</span>
|
||||
<a
|
||||
class="inline-flex items-center justify-center rounded-md bg-sky-700 px-4 py-2 text-white font-semibold hover:bg-sky-800"
|
||||
href={status.latest_release_url}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
aria-label="View latest release on GitHub"
|
||||
>
|
||||
View Release
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -16,6 +16,7 @@ export interface AnalyzerConfig {
|
||||
export enum enabled_notifications {
|
||||
Warning = 'Warning',
|
||||
LowBattery = 'LowBattery',
|
||||
Update = 'Update',
|
||||
}
|
||||
|
||||
export interface WebdavConfig {
|
||||
@@ -52,6 +53,7 @@ export interface Config {
|
||||
key_input_mode: number;
|
||||
ntfy_url: string | null;
|
||||
enabled_notifications: enabled_notifications[];
|
||||
auto_check_updates: boolean;
|
||||
analyzers: AnalyzerConfig;
|
||||
min_space_to_start_recording_mb: number;
|
||||
min_space_to_continue_recording_mb: number;
|
||||
@@ -170,10 +172,23 @@ export interface TimeResponse {
|
||||
offset_seconds: number;
|
||||
}
|
||||
|
||||
export interface UpdateStatus {
|
||||
current_version: string;
|
||||
latest_version?: string | null;
|
||||
latest_release_url?: string | null;
|
||||
update_available: boolean;
|
||||
last_checked?: string | null;
|
||||
last_error?: string | null;
|
||||
}
|
||||
|
||||
export async function get_daemon_time(): Promise<TimeResponse> {
|
||||
return JSON.parse(await req('GET', '/api/time'));
|
||||
}
|
||||
|
||||
export async function get_update_status(): Promise<UpdateStatus> {
|
||||
return JSON.parse(await req('GET', '/api/update-status'));
|
||||
}
|
||||
|
||||
export interface GpsData {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
|
||||
Reference in New Issue
Block a user