Warranty phase 2: real Dell provider + settings UI + PC hero badge
- DellProvider: real Dell TechDirect lookup. OAuth2 via HTTP Basic auth, asset-entitlements under /PROD/sbil/eapi/v5 (the device.warranty path 404s for this account), map latest dated entitlement to service level + dates. Cache the token process-wide; Dell rate-limits the token endpoint and a fresh request per refresh trips a 401 cooldown. Verified against live Dell. - Lenovo/HP stay config-shaped stubs. - Settings: warranty_dell_* keys (category integrations); Dell Warranty Lookup block in System Settings > Integrations (enable + client id/secret masked + optional token/API URL overrides). - WarrantyPanel takes optional pre-fetched items; PCDetail fetches once and feeds both the panel and a new hero warranty-status/end-date badge. - tools/mock_dell.py for offline testing of the provider flow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,10 @@
|
||||
<span class="badge badge-lg" :style="colorStyle(computer.statuscolor)">
|
||||
{{ computer.statusname || 'Unknown' }}
|
||||
</span>
|
||||
<span v-if="heroWarranty" class="badge badge-lg" :style="colorStyle(heroWarranty.statuscolor)"
|
||||
:title="heroWarranty.enddate ? `Warranty ends ${formatWarrantyDate(heroWarranty.enddate)}` : 'Warranty'">
|
||||
{{ heroWarranty.label }}<template v-if="heroWarranty.enddate"> - {{ formatWarrantyDate(heroWarranty.enddate) }}</template>
|
||||
</span>
|
||||
</div>
|
||||
<div class="hero-details">
|
||||
<div class="hero-detail" v-if="computer.computer?.computertypename">
|
||||
@@ -223,7 +227,7 @@
|
||||
<CustomFieldsSection :assetid="computer.assetid" />
|
||||
|
||||
<!-- Warranty -->
|
||||
<WarrantyPanel :assetid="computer.assetid" />
|
||||
<WarrantyPanel :assetid="computer.assetid" :items="warranties" />
|
||||
|
||||
<!-- Notes -->
|
||||
<div class="section-card" v-if="computer.notes">
|
||||
@@ -250,7 +254,7 @@
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { colorStyle } from "@/utils/colorStyle"
|
||||
import { useRoute } from 'vue-router'
|
||||
import { computersApi, applicationsApi, assetsApi } from '../../api'
|
||||
import { computersApi, applicationsApi, assetsApi, warrantyApi } from '../../api'
|
||||
import LocationMapTooltip from '../../components/LocationMapTooltip.vue'
|
||||
import CustomFieldsSection from '../../components/CustomFieldsSection.vue'
|
||||
import WarrantyPanel from '../../components/WarrantyPanel.vue'
|
||||
@@ -263,6 +267,21 @@ const loading = ref(true)
|
||||
const computer = ref(null)
|
||||
const relationships = ref({ incoming: [], outgoing: [] })
|
||||
const installedApps = ref([])
|
||||
const warranties = ref([])
|
||||
|
||||
// Worst-case warranty for the hero badge: expired > expiring > active > unknown.
|
||||
const heroWarranty = computed(() => {
|
||||
if (!warranties.value.length) return null
|
||||
const rank = { expired: 0, expiring: 1, active: 2, unknown: 3 }
|
||||
const worst = [...warranties.value].sort((a, b) => (rank[a.status] ?? 9) - (rank[b.status] ?? 9))[0]
|
||||
const labels = { active: 'Under Warranty', expiring: 'Warranty Expiring', expired: 'Warranty Expired', unknown: 'Warranty' }
|
||||
return { ...worst, label: labels[worst.status] || 'Warranty' }
|
||||
})
|
||||
|
||||
function formatWarrantyDate(d) {
|
||||
if (!d) return ''
|
||||
return new Date(d + 'T00:00:00').toLocaleDateString()
|
||||
}
|
||||
|
||||
const controlledEquipment = computed(() => {
|
||||
// For computers, find related equipment in any "Controls" relationship
|
||||
@@ -315,6 +334,16 @@ onMounted(async () => {
|
||||
} catch (appError) {
|
||||
console.log('No installed apps data:', appError.message)
|
||||
}
|
||||
|
||||
// Load warranties (one fetch; feeds both the hero badge and the panel)
|
||||
if (computer.value?.assetid) {
|
||||
try {
|
||||
const warrantyResponse = await warrantyApi.forAsset(computer.value.assetid)
|
||||
warranties.value = warrantyResponse.data.data || []
|
||||
} catch (warrantyError) {
|
||||
console.log('No warranty data:', warrantyError.message)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading computer:', error)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user