fix(magic): robust device parsing, dashboard only protects current device
This commit is contained in:
parent
37f3173539
commit
026c319b30
@ -86,12 +86,11 @@
|
||||
<div class="w-16 h-16 mx-auto rounded-2xl bg-blue-50 flex items-center justify-center mb-4">
|
||||
<UIcon name="i-heroicons-shield-exclamation" class="w-8 h-8 text-[var(--rebreak-primary)]" />
|
||||
</div>
|
||||
<h3 class="text-lg font-bold text-gray-900">Dieses Gerät ist nicht registriert</h3>
|
||||
<p class="text-sm text-gray-500 mt-1 mb-4">Füge es hinzu, um den Schutz zu aktivieren.</p>
|
||||
<div class="flex justify-center gap-3">
|
||||
<UButton color="primary" icon="i-heroicons-device-phone-mobile" to="/detect">iPhone / iPad</UButton>
|
||||
<UButton color="neutral" variant="soft" icon="i-heroicons-computer-desktop" to="/desktop-enroll">Diesen Computer</UButton>
|
||||
</div>
|
||||
<h3 class="text-lg font-bold text-gray-900">Dieses Gerät ist nicht geschützt</h3>
|
||||
<p class="text-sm text-gray-500 mt-1 mb-4">Aktiviere den Schutz für das Gerät, auf dem Magic läuft.</p>
|
||||
<UButton color="primary" icon="i-heroicons-shield-check" to="/desktop-enroll">
|
||||
Dieses Gerät schützen
|
||||
</UButton>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -133,29 +132,6 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Add device shortcuts -->
|
||||
<section class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<UButton
|
||||
color="primary"
|
||||
variant="soft"
|
||||
size="lg"
|
||||
block
|
||||
icon="i-heroicons-device-phone-mobile"
|
||||
to="/detect"
|
||||
>
|
||||
iPhone / iPad hinzufügen
|
||||
</UButton>
|
||||
<UButton
|
||||
color="neutral"
|
||||
variant="soft"
|
||||
size="lg"
|
||||
block
|
||||
icon="i-heroicons-computer-desktop"
|
||||
to="/desktop-enroll"
|
||||
>
|
||||
Diesen Computer schützen
|
||||
</UButton>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<DeviceDetailSheet
|
||||
|
||||
@ -55,13 +55,18 @@ pub struct MagicDeviceInfo {
|
||||
pub release_requested_at: Option<String>,
|
||||
#[serde(rename = "releaseAvailableAt")]
|
||||
pub release_available_at: Option<String>,
|
||||
#[serde(rename = "cooldownUntil")]
|
||||
#[serde(default, rename = "cooldownUntil")]
|
||||
pub cooldown_until: Option<String>,
|
||||
#[serde(default = "default_active_status")]
|
||||
pub status: String,
|
||||
#[serde(rename = "lastSeenAt")]
|
||||
#[serde(default, rename = "lastSeenAt")]
|
||||
pub last_seen_at: Option<String>,
|
||||
}
|
||||
|
||||
fn default_active_status() -> String {
|
||||
"active".to_string()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct StatusResponse {
|
||||
pub active: bool,
|
||||
@ -338,17 +343,19 @@ impl MagicApiClient {
|
||||
response: reqwest::Response,
|
||||
) -> AppResult<T> {
|
||||
let status = response.status();
|
||||
if status.is_success() {
|
||||
response
|
||||
.json::<T>()
|
||||
.await
|
||||
.map_err(|e| AppError::new(format!("Failed to parse response: {}", e)))
|
||||
} else {
|
||||
let text = response
|
||||
let body = response
|
||||
.text()
|
||||
.await
|
||||
.unwrap_or_else(|_| "Unknown error".to_string());
|
||||
Err(AppError::new(format!("HTTP {}: {}", status, text)))
|
||||
.unwrap_or_else(|_| "<failed to read body>".to_string());
|
||||
if status.is_success() {
|
||||
serde_json::from_str::<T>(&body).map_err(|e| {
|
||||
AppError::new(format!(
|
||||
"Failed to parse response: {} | body={}",
|
||||
e, body
|
||||
))
|
||||
})
|
||||
} else {
|
||||
Err(AppError::new(format!("HTTP {}: {}", status, body)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user