|
|
|
@ -0,0 +1,92 @@ |
|
|
|
<template> |
|
|
|
<div v-if="loading">Loading...</div> |
|
|
|
<div v-else-if="error">Error: {{ error }}</div> |
|
|
|
<div v-else class="system-links-container p-3 border overflow-auto" style="max-height: 340px; width: 420px;"> |
|
|
|
<div |
|
|
|
v-for="(link, index) in links" |
|
|
|
:key="index" |
|
|
|
class="mb-2" |
|
|
|
> |
|
|
|
<a |
|
|
|
:href="link.url" |
|
|
|
class="btn d-flex align-items-center text-start w-100 px-4 py-3" |
|
|
|
:class="getButtonClass(link.type)" |
|
|
|
:style="{ borderRadius: buttonRadius }" |
|
|
|
target="_blank" |
|
|
|
> |
|
|
|
<i :class="getIconClass(link.icon)" class="me-2"></i> |
|
|
|
{{ link.text }} |
|
|
|
</a> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { ref, onMounted, defineProps } from 'vue'; |
|
|
|
import linkData from '@/mocks/systemLinksMockData.json'; |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
elementId: { |
|
|
|
type: String, |
|
|
|
required: true |
|
|
|
}, |
|
|
|
metrics: { |
|
|
|
type: [String, Object, Array], |
|
|
|
default: null |
|
|
|
}, |
|
|
|
buttonRadius: { |
|
|
|
type: String, |
|
|
|
default: '0.0rem' |
|
|
|
}, |
|
|
|
useMockedData: { |
|
|
|
type: Boolean, |
|
|
|
default: false |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
const links = ref([]); |
|
|
|
const loading = ref(true); |
|
|
|
const error = ref(null); |
|
|
|
|
|
|
|
const getButtonClass = (type) => { |
|
|
|
switch (type?.toLowerCase()) { |
|
|
|
case 'internal': return 'btn-secondary opacity-75'; |
|
|
|
case 'external': return 'btn-success opacity-75'; |
|
|
|
case 'admin': return 'btn-warning opacity-75'; |
|
|
|
case 'system': return 'btn-light opacity-75'; |
|
|
|
default: return 'btn-info opacity-75'; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const getIconClass = (icon) => `bi bi-${icon}`; |
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
try { |
|
|
|
if (props.useMockedData) { |
|
|
|
// Use mock |
|
|
|
links.value = linkData; |
|
|
|
loading.value = false; |
|
|
|
} else { |
|
|
|
// Fetch from API - this part should never run when using mock data |
|
|
|
const response = await fetch(`https://TODO-replace-with-API`); |
|
|
|
if (!response.ok) { |
|
|
|
throw new Error(`HTTP error! status: ${response.status}`); |
|
|
|
} |
|
|
|
links.value = await response.json(); |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
error.value = err.message; |
|
|
|
} finally { |
|
|
|
loading.value = false; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
.system-links-container { |
|
|
|
background-color: #f8f9fa; |
|
|
|
border: 1px solid #ddd; |
|
|
|
overflow-y: auto; |
|
|
|
} |
|
|
|
</style> |