mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-12 17:15:37 +00:00
chore: OliveTin 3k progress
This commit is contained in:
63
frontend/resources/vue/components/ActionStatusDisplay.vue
Normal file
63
frontend/resources/vue/components/ActionStatusDisplay.vue
Normal file
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<span>
|
||||
<span :class="['action-status', statusClass]">{{ statusText }}</span><span>{{ exitCodeText }}</span>
|
||||
</span>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
logEntry: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const statusText = computed(() => {
|
||||
const logEntry = props.logEntry
|
||||
if (!logEntry) return 'unknown'
|
||||
|
||||
if (logEntry.executionFinished) {
|
||||
if (logEntry.blocked) {
|
||||
return 'Blocked'
|
||||
} else if (logEntry.timedOut) {
|
||||
return 'Timed out'
|
||||
} else {
|
||||
return 'Completed'
|
||||
}
|
||||
} else {
|
||||
return 'Still running...'
|
||||
}
|
||||
})
|
||||
|
||||
const exitCodeText = computed(() => {
|
||||
const logEntry = props.logEntry
|
||||
if (!logEntry) return ''
|
||||
if (logEntry.executionFinished) {
|
||||
if (logEntry.blocked || logEntry.timedOut) {
|
||||
return ''
|
||||
}
|
||||
return ' Exit code: ' + logEntry.exitCode
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
const statusClass = computed(() => {
|
||||
const logEntry = props.logEntry
|
||||
if (!logEntry) return ''
|
||||
if (logEntry.executionFinished) {
|
||||
if (logEntry.blocked) {
|
||||
return 'action-blocked'
|
||||
} else if (logEntry.timedOut) {
|
||||
return 'action-timeout'
|
||||
} else if (logEntry.exitCode === 0) {
|
||||
return 'action-success'
|
||||
} else {
|
||||
return 'action-nonzero-exit'
|
||||
}
|
||||
}
|
||||
return ''
|
||||
})
|
||||
</script>
|
||||
254
frontend/resources/vue/components/Sidebar.vue
Normal file
254
frontend/resources/vue/components/Sidebar.vue
Normal file
@@ -0,0 +1,254 @@
|
||||
<template>
|
||||
<aside :class="{ 'shown': isOpen, 'stuck': isStuck }" class="sidebar">
|
||||
<button
|
||||
class="stick-toggle"
|
||||
:aria-pressed="isStuck"
|
||||
:title="isStuck ? 'Unstick sidebar' : 'Stick sidebar'"
|
||||
@click="toggleStick"
|
||||
>
|
||||
<span v-if="isStuck">📌 Unstick</span>
|
||||
<span v-else>📍 Stick</span>
|
||||
</button>
|
||||
<nav class="mainnav">
|
||||
<ul class="navigation-links">
|
||||
<li v-for="link in navigationLinks" :key="link.id" :title="link.title">
|
||||
<router-link :to="link.path" :class="{ active: isActive(link.path) }">
|
||||
<span v-if="link.icon" class="icon" v-html="link.icon"></span>
|
||||
<span class="title">{{ link.title }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="supplemental-links">
|
||||
<li v-for="link in supplementalLinks" :key="link.id" :title="link.title">
|
||||
<a :href="link.url" :target="link.target || '_self'">
|
||||
<span v-if="link.icon" class="icon" v-html="link.icon"></span>
|
||||
<span class="title">{{ link.title }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, getCurrentInstance } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const isOpen = ref(false)
|
||||
const isStuck = ref(false)
|
||||
const navigationLinks = ref([
|
||||
{
|
||||
id: 'actions',
|
||||
title: 'Actions',
|
||||
path: '/',
|
||||
icon: '⚡'
|
||||
},
|
||||
{
|
||||
id: 'logs',
|
||||
title: 'Logs',
|
||||
path: '/logs',
|
||||
icon: '📋'
|
||||
},
|
||||
{
|
||||
id: 'diagnostics',
|
||||
title: 'Diagnostics',
|
||||
path: '/diagnostics',
|
||||
icon: '🔧'
|
||||
}
|
||||
])
|
||||
const supplementalLinks = ref([])
|
||||
|
||||
const route = useRoute()
|
||||
const instance = getCurrentInstance()
|
||||
|
||||
function toggleStick() {
|
||||
isStuck.value = !isStuck.value
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
isOpen.value = !isOpen.value
|
||||
}
|
||||
|
||||
function open() {
|
||||
isOpen.value = true
|
||||
}
|
||||
|
||||
function close() {
|
||||
isOpen.value = false
|
||||
}
|
||||
|
||||
function isActive(path) {
|
||||
return route.path === path
|
||||
}
|
||||
|
||||
// Method to add navigation links from other components
|
||||
function addNavigationLink(link) {
|
||||
const existingIndex = navigationLinks.value.findIndex(l => l.id === link.id)
|
||||
if (existingIndex >= 0) {
|
||||
navigationLinks.value[existingIndex] = { ...link }
|
||||
} else {
|
||||
navigationLinks.value.push({ ...link })
|
||||
}
|
||||
}
|
||||
|
||||
// Method to add supplemental links from other components
|
||||
function addSupplementalLink(link) {
|
||||
const existingIndex = supplementalLinks.value.findIndex(l => l.id === link.id)
|
||||
if (existingIndex >= 0) {
|
||||
supplementalLinks.value[existingIndex] = { ...link }
|
||||
} else {
|
||||
supplementalLinks.value.push({ ...link })
|
||||
}
|
||||
}
|
||||
|
||||
// Method to remove links
|
||||
function removeNavigationLink(linkId) {
|
||||
navigationLinks.value = navigationLinks.value.filter(link => link.id !== linkId)
|
||||
}
|
||||
|
||||
function removeSupplementalLink(linkId) {
|
||||
supplementalLinks.value = supplementalLinks.value.filter(link => link.id !== linkId)
|
||||
}
|
||||
|
||||
// Method to clear all links
|
||||
function clearNavigationLinks() {
|
||||
navigationLinks.value = []
|
||||
}
|
||||
|
||||
function clearSupplementalLinks() {
|
||||
supplementalLinks.value = []
|
||||
}
|
||||
|
||||
// Method to get all links
|
||||
function getNavigationLinks() {
|
||||
return [...navigationLinks.value]
|
||||
}
|
||||
|
||||
function getSupplementalLinks() {
|
||||
return [...supplementalLinks.value]
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// Make the sidebar globally accessible
|
||||
window.sidebar = {
|
||||
get isOpen() { return isOpen.value },
|
||||
set isOpen(val) { isOpen.value = val },
|
||||
toggle,
|
||||
open,
|
||||
close,
|
||||
addNavigationLink,
|
||||
addSupplementalLink,
|
||||
removeNavigationLink,
|
||||
removeSupplementalLink,
|
||||
clearNavigationLinks,
|
||||
clearSupplementalLinks,
|
||||
getNavigationLinks,
|
||||
getSupplementalLinks
|
||||
}
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
isOpen,
|
||||
navigationLinks,
|
||||
supplementalLinks,
|
||||
toggle,
|
||||
open,
|
||||
close,
|
||||
isActive,
|
||||
addNavigationLink,
|
||||
addSupplementalLink,
|
||||
removeNavigationLink,
|
||||
removeSupplementalLink,
|
||||
clearNavigationLinks,
|
||||
clearSupplementalLinks,
|
||||
getNavigationLinks,
|
||||
getSupplementalLinks
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mainnav {
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.navigation-links,
|
||||
.supplemental-links {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.navigation-links li,
|
||||
.supplemental-links li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.navigation-links a,
|
||||
.supplemental-links a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 1rem;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
transition: background-color 0.2s ease;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
.navigation-links a:hover,
|
||||
.supplemental-links a:hover {
|
||||
background: #f8f9fa;
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.navigation-links a.active {
|
||||
background: #e3f2fd;
|
||||
color: #007bff;
|
||||
border-left-color: #007bff;
|
||||
}
|
||||
|
||||
.navigation-links a.router-link-active {
|
||||
background: #e3f2fd;
|
||||
color: #007bff;
|
||||
border-left-color: #007bff;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 1.2em;
|
||||
width: 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.supplemental-links {
|
||||
border-top: 1px solid #eee;
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.supplemental-links a {
|
||||
font-size: 0.9rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.supplemental-links a:hover {
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
/* Responsive design */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
left: -100%;
|
||||
}
|
||||
|
||||
.sidebar.shown {
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
179
frontend/resources/vue/components/SidebarExample.vue
Normal file
179
frontend/resources/vue/components/SidebarExample.vue
Normal file
@@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<div class="sidebar-example">
|
||||
<h3>Sidebar Management Example</h3>
|
||||
|
||||
<div class="controls">
|
||||
<button @click="addCustomNavLink" class="btn btn-primary">
|
||||
Add Custom Nav Link
|
||||
</button>
|
||||
|
||||
<button @click="addCustomSupplementalLink" class="btn btn-secondary">
|
||||
Add Custom Supplemental Link
|
||||
</button>
|
||||
|
||||
<button @click="removeCustomLinks" class="btn btn-danger">
|
||||
Remove Custom Links
|
||||
</button>
|
||||
|
||||
<button @click="toggleSidebar" class="btn btn-info">
|
||||
Toggle Sidebar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
<p><strong>Available Sidebar Methods:</strong></p>
|
||||
<ul>
|
||||
<li><code>window.sidebar.addNavigationLink(link)</code> - Add navigation link</li>
|
||||
<li><code>window.sidebar.addSupplementalLink(link)</code> - Add supplemental link</li>
|
||||
<li><code>window.sidebar.removeNavigationLink(id)</code> - Remove navigation link</li>
|
||||
<li><code>window.sidebar.removeSupplementalLink(id)</code> - Remove supplemental link</li>
|
||||
<li><code>window.sidebar.toggle()</code> - Toggle sidebar visibility</li>
|
||||
<li><code>window.sidebar.open()</code> - Open sidebar</li>
|
||||
<li><code>window.sidebar.close()</code> - Close sidebar</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SidebarExample',
|
||||
data() {
|
||||
return {
|
||||
customLinkId: 1
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addCustomNavLink() {
|
||||
if (window.sidebar) {
|
||||
window.sidebar.addNavigationLink({
|
||||
id: `custom-nav-${this.customLinkId}`,
|
||||
title: `Custom Nav ${this.customLinkId}`,
|
||||
path: `/custom-${this.customLinkId}`,
|
||||
icon: '🔗'
|
||||
})
|
||||
this.customLinkId++
|
||||
} else {
|
||||
console.warn('Sidebar not available')
|
||||
}
|
||||
},
|
||||
|
||||
addCustomSupplementalLink() {
|
||||
if (window.sidebar) {
|
||||
window.sidebar.addSupplementalLink({
|
||||
id: `custom-supplemental-${this.customLinkId}`,
|
||||
title: `Custom Link ${this.customLinkId}`,
|
||||
url: `https://example.com/custom-${this.customLinkId}`,
|
||||
target: '_blank',
|
||||
icon: '🔗'
|
||||
})
|
||||
this.customLinkId++
|
||||
} else {
|
||||
console.warn('Sidebar not available')
|
||||
}
|
||||
},
|
||||
|
||||
removeCustomLinks() {
|
||||
if (window.sidebar) {
|
||||
// Remove all custom links
|
||||
for (let i = 1; i < this.customLinkId; i++) {
|
||||
window.sidebar.removeNavigationLink(`custom-nav-${i}`)
|
||||
window.sidebar.removeSupplementalLink(`custom-supplemental-${i}`)
|
||||
}
|
||||
this.customLinkId = 1
|
||||
} else {
|
||||
console.warn('Sidebar not available')
|
||||
}
|
||||
},
|
||||
|
||||
toggleSidebar() {
|
||||
if (window.sidebar) {
|
||||
window.sidebar.toggle()
|
||||
} else {
|
||||
console.warn('Sidebar not available')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sidebar-example {
|
||||
padding: 1rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 0.5rem 1rem;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #0056b3;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #545b62;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #c82333;
|
||||
}
|
||||
|
||||
.btn-info {
|
||||
background: #17a2b8;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-info:hover {
|
||||
background: #138496;
|
||||
}
|
||||
|
||||
.info {
|
||||
background: white;
|
||||
padding: 1rem;
|
||||
border-radius: 4px;
|
||||
border-left: 4px solid #007bff;
|
||||
}
|
||||
|
||||
.info ul {
|
||||
margin: 0.5rem 0;
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
|
||||
.info code {
|
||||
background: #f1f3f4;
|
||||
padding: 0.125rem 0.25rem;
|
||||
border-radius: 3px;
|
||||
font-family: monospace;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user