Consolidate asset relationships onto the shared card
The curated Controlled Machines (PC detail) and Connected PC (machine detail) cards duplicated what the generic relationships card already shows with type badges and inline add/remove - and hid every non-controls relationship type. Removed the curated cards and their plumbing (~105 lines of orphaned CSS included); the MachineForm controlling-PC picker stays as the write path. Also theme-variable fixes on the shared card styling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -180,28 +180,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Controlled Machines -->
|
||||
<div class="section-card" v-if="controlledEquipment.length > 0">
|
||||
<h3 class="section-title">Controlled Machines</h3>
|
||||
<div class="equipment-list">
|
||||
<router-link
|
||||
v-for="item in controlledEquipment"
|
||||
:key="item.relationshipid"
|
||||
:to="`/machines/${item.pluginid || item.assetid}`"
|
||||
class="equipment-item"
|
||||
>
|
||||
<div class="equipment-info">
|
||||
<span class="equipment-name">{{ item.assetnumber }}</span>
|
||||
<span class="equipment-alias" v-if="item.name">{{ item.name }}</span>
|
||||
</div>
|
||||
<div class="equipment-meta">
|
||||
<span class="category-tag">{{ item.assettypename }}</span>
|
||||
<span class="connection-tag">{{ item.relationshipType }}</span>
|
||||
</div>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Installed Applications -->
|
||||
<div class="section-card" v-if="installedApps.length > 0">
|
||||
<h3 class="section-title">Installed Applications</h3>
|
||||
@@ -254,10 +232,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { colorStyle } from "@/utils/colorStyle"
|
||||
import { useRoute } from 'vue-router'
|
||||
import { computersApi, applicationsApi, assetsApi } from '../../api'
|
||||
import { computersApi, applicationsApi } from '../../api'
|
||||
import { useWarrantyBadge } from '../../composables/warrantyBadge'
|
||||
import LocationMapTooltip from '../../components/LocationMapTooltip.vue'
|
||||
import CustomFieldsSection from '../../components/CustomFieldsSection.vue'
|
||||
@@ -270,61 +248,18 @@ const { isEnabled } = useIdentifierFlags()
|
||||
|
||||
const loading = ref(true)
|
||||
const computer = ref(null)
|
||||
const relationships = ref({ incoming: [], outgoing: [] })
|
||||
const installedApps = ref([])
|
||||
|
||||
// Warranty fetch + hero badge (shared across asset detail pages).
|
||||
const { warranties, heroWarranty, warrantyDate: formatWarrantyDate } = useWarrantyBadge(() => computer.value?.assetid)
|
||||
|
||||
// type name is data, sites may seed 'controls' or 'Controls' - compare folded
|
||||
function isControls(rel) {
|
||||
return (rel.relationshiptypename || '').toLowerCase() === 'controls'
|
||||
}
|
||||
|
||||
const controlledEquipment = computed(() => {
|
||||
// For computers, find related equipment in any "Controls" relationship
|
||||
const items = []
|
||||
|
||||
// Check outgoing - computer controls equipment
|
||||
for (const rel of relationships.value.outgoing || []) {
|
||||
if (rel.targetasset?.assettypename === 'machine' && isControls(rel)) {
|
||||
items.push({
|
||||
...rel.targetasset,
|
||||
relationshipid: rel.relationshipid,
|
||||
relationshipType: rel.relationshiptypename
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Also check incoming - legacy data may have equipment -> computer Controls relationships
|
||||
for (const rel of relationships.value.incoming || []) {
|
||||
if (rel.sourceasset?.assettypename === 'machine' && isControls(rel)) {
|
||||
items.push({
|
||||
...rel.sourceasset,
|
||||
relationshipid: rel.relationshipid,
|
||||
relationshipType: rel.relationshiptypename
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return items
|
||||
})
|
||||
// relationships render via the shared AssetRelationships card
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const response = await computersApi.get(route.params.id)
|
||||
computer.value = response.data.data
|
||||
|
||||
// Load relationships using asset ID
|
||||
if (computer.value?.assetid) {
|
||||
try {
|
||||
const relResponse = await assetsApi.getRelationships(computer.value.assetid)
|
||||
relationships.value = relResponse.data.data || { incoming: [], outgoing: [] }
|
||||
} catch (e) {
|
||||
console.log('Relationships not available')
|
||||
}
|
||||
}
|
||||
|
||||
// Load installed applications
|
||||
try {
|
||||
const appsResponse = await applicationsApi.getMachineApps(route.params.id)
|
||||
@@ -434,21 +369,6 @@ function formatDate(dateStr) {
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
/* Equipment meta */
|
||||
.equipment-meta {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.category-tag {
|
||||
padding: 0.3rem 0.625rem;
|
||||
font-size: 0.875rem;
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/* Network details */
|
||||
.network-details {
|
||||
margin-top: 0.5rem;
|
||||
|
||||
Reference in New Issue
Block a user