|
|
@@ -11,86 +11,240 @@
|
|
|
|
|
|
<p class="padding">{{ t('logs.queue-page-description') }}</p>
|
|
|
|
|
|
- <div v-if="groups.length > 0" class="queue-groups padding">
|
|
|
- <section v-for="group in groups" :key="group.bindingId" class="queue-group">
|
|
|
- <header class="queue-group-header">
|
|
|
- <ActionIconGlyph class="icon" :glyph="group.actionIcon" />
|
|
|
- <div class="queue-group-title">
|
|
|
- <h3>{{ group.actionTitle }}</h3>
|
|
|
- <p v-if="group.entityPrefix" class="queue-entity">
|
|
|
- {{ t('logs.queue-entity') }}: {{ group.entityPrefix }}
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- <span class="queue-group-limit annotation">
|
|
|
- {{ t('logs.queue-group-active', { active: group.activeCount, max: group.maxConcurrent }) }}
|
|
|
- </span>
|
|
|
- </header>
|
|
|
-
|
|
|
- <table class="logs-table">
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th>{{ t('logs.timestamp') }}</th>
|
|
|
- <th>{{ t('logs.metadata') }}</th>
|
|
|
- <th>{{ t('logs.status') }}</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <tr v-for="(entry, index) in group.entries" :key="entry.executionTrackingId" class="log-row">
|
|
|
- <td class="timestamp">{{ formatTimestamp(entry.datetimeStarted) }}</td>
|
|
|
- <td class="tags">
|
|
|
- <span class="annotation">
|
|
|
- <span class="annotation-key">User:</span>
|
|
|
- <span class="annotation-val">{{ entry.user }}</span>
|
|
|
- </span>
|
|
|
- <span v-if="entry.tags && entry.tags.length > 0" class="tag-list">
|
|
|
- <span v-for="tag in entry.tags" :key="tag" class="tag">{{ tag }}</span>
|
|
|
- </span>
|
|
|
- <span class="annotation">
|
|
|
- <span class="annotation-key">ID:</span>
|
|
|
- <router-link :to="`/logs/${entry.executionTrackingId}`">
|
|
|
- {{ entry.executionTrackingId }}
|
|
|
- </router-link>
|
|
|
- </span>
|
|
|
- </td>
|
|
|
- <td class="exit-code">
|
|
|
- <span class="annotation">
|
|
|
- <span class="queue-position">{{ t('logs.queue-position', { position: index + 1 }) }}</span>
|
|
|
- <span :class="queueStatusClass(entry)">{{ queueStatusText(entry) }}</span>
|
|
|
- </span>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- </section>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div v-else-if="!loading" class="empty-state padding">
|
|
|
+ <div v-if="groups.length === 0 && !loading" class="empty-state padding">
|
|
|
<p>{{ t('logs.queue-empty') }}</p>
|
|
|
<router-link to="/logs">{{ t('logs.back-to-list') }}</router-link>
|
|
|
</div>
|
|
|
</Section>
|
|
|
+
|
|
|
+ <section
|
|
|
+ v-for="group in groups"
|
|
|
+ :key="group.bindingId"
|
|
|
+ class="with-header-and-content queue-group-section"
|
|
|
+ >
|
|
|
+ <div class="section-header flex-row">
|
|
|
+ <div class="fg1 queue-group-heading">
|
|
|
+ <ActionIconGlyph class="queue-group-icon" :glyph="group.actionIcon" />
|
|
|
+ <div class="queue-group-title">
|
|
|
+ <h2 :title="group.entityPrefix ? `${t('logs.queue-entity')}: ${group.entityPrefix}` : ''">
|
|
|
+ {{ group.actionTitle }}
|
|
|
+ </h2>
|
|
|
+ <p v-if="group.entityPrefix" class="queue-entity">
|
|
|
+ {{ t('logs.queue-entity') }}: {{ group.entityPrefix }}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div role="toolbar" class="queue-group-toolbar">
|
|
|
+ <router-link
|
|
|
+ v-if="group.bindingId"
|
|
|
+ :to="`/action/${group.bindingId}`"
|
|
|
+ class="button neutral"
|
|
|
+ :title="t('logs.queue-action-details')"
|
|
|
+ >
|
|
|
+ <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
|
|
|
+ <path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.31-8.86c-1.77-.45-2.34-.94-2.34-1.67 0-.84.79-1.43 2.1-1.43 1.38 0 1.9.66 1.94 1.64h1.71c-.05-1.34-.87-2.57-2.49-2.97V5H10.9v1.69c-1.51.32-2.72 1.3-2.72 2.81 0 1.79 1.49 2.69 3.66 3.21 1.95.46 2.34 1.22 2.34 1.8 0 .53-.39 1.39-2.1 1.39-1.6 0-2.05-.56-2.13-1.45H8.04c.08 1.5 1.18 2.37 2.82 2.69V19h2.34v-1.63c1.65-.35 2.48-1.24 2.48-2.77-.01-1.88-1.51-2.87-3.7-3.23z"/>
|
|
|
+ </svg>
|
|
|
+ {{ t('logs.queue-action-details') }}
|
|
|
+ </router-link>
|
|
|
+ <span class="queue-group-limit annotation">
|
|
|
+ {{ t('logs.queue-group-active', { active: group.activeCount, max: group.maxConcurrent }) }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="section-content">
|
|
|
+ <table class="logs-table row-hover">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>{{ t('logs.timestamp') }}</th>
|
|
|
+ <th>{{ t('logs.metadata') }}</th>
|
|
|
+ <th>{{ t('logs.status') }}</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr v-for="(entry, index) in group.entries" :key="entry.executionTrackingId" class="log-row">
|
|
|
+ <td class="timestamp">{{ formatTimestamp(entry.datetimeStarted) }}</td>
|
|
|
+ <td class="tags">
|
|
|
+ <span class="annotation">
|
|
|
+ <span class="annotation-key">User:</span>
|
|
|
+ <span class="annotation-val">{{ entry.user }}</span>
|
|
|
+ </span>
|
|
|
+ <span v-if="entry.tags && entry.tags.length > 0" class="tag-list">
|
|
|
+ <span v-for="tag in entry.tags" :key="tag" class="tag">{{ tag }}</span>
|
|
|
+ </span>
|
|
|
+ <span class="annotation">
|
|
|
+ <span class="annotation-key">ID:</span>
|
|
|
+ <router-link :to="`/logs/${entry.executionTrackingId}`">
|
|
|
+ {{ entry.executionTrackingId }}
|
|
|
+ </router-link>
|
|
|
+ </span>
|
|
|
+ </td>
|
|
|
+ <td class="exit-code">
|
|
|
+ <span v-if="!entry.executionFinished" class="queue-position">{{ t('logs.queue-position', { position: index + 1 }) }}</span>
|
|
|
+ <ActionStatusDisplay :logEntry="entry" />
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, onMounted, onUnmounted } from 'vue'
|
|
|
import Section from 'picocrank/vue/components/Section.vue'
|
|
|
import ActionIconGlyph from '../components/ActionIconGlyph.vue'
|
|
|
+import ActionStatusDisplay from '../components/ActionStatusDisplay.vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
+import { getExecutionLogEntry, cloneLogEntry, updateLogEntryInGroups } from '../utils/executionLogEvents.js'
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
const groups = ref([])
|
|
|
const loading = ref(false)
|
|
|
|
|
|
-function queueStatusText (entry) {
|
|
|
- if (entry.executionStarted) {
|
|
|
- return t('logs.queue-running')
|
|
|
+function collectCompletedEntries (currentGroups) {
|
|
|
+ const completed = []
|
|
|
+ for (const group of currentGroups || []) {
|
|
|
+ for (const entry of group.entries || []) {
|
|
|
+ if (entry.executionFinished) {
|
|
|
+ completed.push(cloneLogEntry(entry))
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return t('logs.queue-waiting')
|
|
|
+ return completed
|
|
|
+}
|
|
|
+
|
|
|
+function sortGroupEntries (entries) {
|
|
|
+ entries.sort((left, right) => {
|
|
|
+ if (left.executionFinished !== right.executionFinished) {
|
|
|
+ return left.executionFinished ? 1 : -1
|
|
|
+ }
|
|
|
+ return (left.datetimeStarted || '').localeCompare(right.datetimeStarted || '')
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-function queueStatusClass (entry) {
|
|
|
- return entry.executionStarted ? 'queue-status-running' : 'queue-status-waiting'
|
|
|
+function sortGroups (groupList) {
|
|
|
+ groupList.sort((left, right) => {
|
|
|
+ const byTitle = (left.actionTitle || '').localeCompare(right.actionTitle || '')
|
|
|
+ if (byTitle !== 0) {
|
|
|
+ return byTitle
|
|
|
+ }
|
|
|
+ return (left.entityPrefix || '').localeCompare(right.entityPrefix || '')
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function mergeCompletedEntries (apiGroups, completedEntries) {
|
|
|
+ const merged = (apiGroups || []).map(group => ({
|
|
|
+ ...group,
|
|
|
+ entries: [...(group.entries || [])]
|
|
|
+ }))
|
|
|
+
|
|
|
+ for (const entry of completedEntries) {
|
|
|
+ const alreadyPresent = merged.some(group =>
|
|
|
+ group.entries.some(item => item.executionTrackingId === entry.executionTrackingId)
|
|
|
+ )
|
|
|
+ if (alreadyPresent) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ let group = merged.find(item => item.bindingId === entry.bindingId)
|
|
|
+ if (!group) {
|
|
|
+ group = {
|
|
|
+ bindingId: entry.bindingId,
|
|
|
+ actionTitle: entry.actionTitle,
|
|
|
+ actionIcon: entry.actionIcon,
|
|
|
+ entityPrefix: '',
|
|
|
+ maxConcurrent: 0,
|
|
|
+ activeCount: 0,
|
|
|
+ entries: []
|
|
|
+ }
|
|
|
+ merged.push(group)
|
|
|
+ }
|
|
|
+
|
|
|
+ group.entries.push(entry)
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const group of merged) {
|
|
|
+ sortGroupEntries(group.entries)
|
|
|
+ }
|
|
|
+ sortGroups(merged)
|
|
|
+
|
|
|
+ return merged
|
|
|
+}
|
|
|
+
|
|
|
+function applyQueueEntryUpdate (logEntry, afterUpdate) {
|
|
|
+ const result = updateLogEntryInGroups(groups.value, logEntry)
|
|
|
+ if (!result) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (afterUpdate) {
|
|
|
+ afterUpdate(result)
|
|
|
+ }
|
|
|
+ sortGroupEntries(result.group.entries)
|
|
|
+ return true
|
|
|
+}
|
|
|
+
|
|
|
+function adjustActiveCountOnStart (group, previous, logEntry) {
|
|
|
+ const wasActive = !previous.executionFinished
|
|
|
+ const isActive = !logEntry.executionFinished
|
|
|
+ if (!wasActive && isActive) {
|
|
|
+ group.activeCount++
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function insertActiveQueueEntry (logEntry) {
|
|
|
+ if (!logEntry?.bindingId || !logEntry.executionTrackingId || logEntry.executionFinished) {
|
|
|
+ fetchQueue()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let group = groups.value.find(item => item.bindingId === logEntry.bindingId)
|
|
|
+ if (!group) {
|
|
|
+ group = {
|
|
|
+ bindingId: logEntry.bindingId,
|
|
|
+ actionTitle: logEntry.actionTitle || '',
|
|
|
+ actionIcon: logEntry.actionIcon || '',
|
|
|
+ entityPrefix: logEntry.entityPrefix || '',
|
|
|
+ maxConcurrent: 0,
|
|
|
+ activeCount: 0,
|
|
|
+ entries: []
|
|
|
+ }
|
|
|
+ groups.value.push(group)
|
|
|
+ }
|
|
|
+
|
|
|
+ group.entries.push(cloneLogEntry(logEntry))
|
|
|
+ adjustActiveCountOnStart(group, { executionFinished: true }, logEntry)
|
|
|
+ sortGroupEntries(group.entries)
|
|
|
+ sortGroups(groups.value)
|
|
|
+}
|
|
|
+
|
|
|
+function onExecutionStarted (evt) {
|
|
|
+ const logEntry = getExecutionLogEntry(evt)
|
|
|
+ if (!logEntry) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!applyQueueEntryUpdate(logEntry, ({ group, previous }) => {
|
|
|
+ adjustActiveCountOnStart(group, previous, logEntry)
|
|
|
+ })) {
|
|
|
+ insertActiveQueueEntry(logEntry)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function onExecutionFinished (evt) {
|
|
|
+ const logEntry = getExecutionLogEntry(evt)
|
|
|
+ if (!logEntry) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ applyQueueEntryUpdate(logEntry, ({ group, previous }) => {
|
|
|
+ const wasActive = !previous.executionFinished
|
|
|
+ if (wasActive && logEntry.executionFinished && group.activeCount > 0) {
|
|
|
+ group.activeCount--
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function formatTimestamp (timestamp) {
|
|
|
@@ -107,8 +261,9 @@ function formatTimestamp (timestamp) {
|
|
|
async function fetchQueue () {
|
|
|
loading.value = true
|
|
|
try {
|
|
|
+ const completedEntries = collectCompletedEntries(groups.value)
|
|
|
const response = await window.client.getExecutionQueue({})
|
|
|
- groups.value = response.groups || []
|
|
|
+ groups.value = mergeCompletedEntries(response.groups || [], completedEntries)
|
|
|
} catch (err) {
|
|
|
console.error('Failed to fetch execution queue:', err)
|
|
|
window.showBigError('fetch-queue', 'getting execution queue', err, false)
|
|
|
@@ -119,45 +274,37 @@ async function fetchQueue () {
|
|
|
|
|
|
onMounted(() => {
|
|
|
fetchQueue()
|
|
|
- window.addEventListener('EventExecutionStarted', fetchQueue)
|
|
|
- window.addEventListener('EventExecutionFinished', fetchQueue)
|
|
|
+ window.addEventListener('EventExecutionStarted', onExecutionStarted)
|
|
|
+ window.addEventListener('EventExecutionFinished', onExecutionFinished)
|
|
|
})
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
- window.removeEventListener('EventExecutionStarted', fetchQueue)
|
|
|
- window.removeEventListener('EventExecutionFinished', fetchQueue)
|
|
|
+ window.removeEventListener('EventExecutionStarted', onExecutionStarted)
|
|
|
+ window.removeEventListener('EventExecutionFinished', onExecutionFinished)
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.queue-groups {
|
|
|
+.queue-group-heading {
|
|
|
display: flex;
|
|
|
- flex-direction: column;
|
|
|
- gap: 1.5rem;
|
|
|
+ align-items: center;
|
|
|
+ gap: 0.75rem;
|
|
|
+ min-width: 0;
|
|
|
}
|
|
|
|
|
|
-.queue-group {
|
|
|
- border: 1px solid var(--border-color, #ccc);
|
|
|
- border-radius: 0.5rem;
|
|
|
- overflow: hidden;
|
|
|
+.queue-group-title h2 {
|
|
|
+ margin: 0;
|
|
|
}
|
|
|
|
|
|
-.queue-group-header {
|
|
|
- display: flex;
|
|
|
+.queue-group-toolbar {
|
|
|
+ display: inline-flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
align-items: center;
|
|
|
- gap: 0.75rem;
|
|
|
- padding: 0.75rem 1rem;
|
|
|
- background: var(--section-background, #f8f9fa);
|
|
|
- border-bottom: 1px solid var(--border-color, #ccc);
|
|
|
-}
|
|
|
-
|
|
|
-.queue-group-title {
|
|
|
- flex: 1;
|
|
|
+ gap: 0.5rem;
|
|
|
}
|
|
|
|
|
|
-.queue-group-title h3 {
|
|
|
- margin: 0;
|
|
|
- font-size: 1rem;
|
|
|
+.queue-group-limit {
|
|
|
+ white-space: nowrap;
|
|
|
}
|
|
|
|
|
|
.queue-entity {
|
|
|
@@ -166,12 +313,9 @@ onUnmounted(() => {
|
|
|
color: #666;
|
|
|
}
|
|
|
|
|
|
-.queue-group-limit {
|
|
|
- white-space: nowrap;
|
|
|
-}
|
|
|
-
|
|
|
-.icon {
|
|
|
+.queue-group-icon {
|
|
|
font-size: 1.5em;
|
|
|
+ flex-shrink: 0;
|
|
|
}
|
|
|
|
|
|
.timestamp {
|
|
|
@@ -185,16 +329,14 @@ onUnmounted(() => {
|
|
|
font-size: smaller;
|
|
|
}
|
|
|
|
|
|
-.queue-position {
|
|
|
- margin-right: 0.5rem;
|
|
|
-}
|
|
|
-
|
|
|
-.queue-status-running {
|
|
|
- color: var(--karma-warning-fg, #856404);
|
|
|
+.exit-code {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 0.5rem;
|
|
|
}
|
|
|
|
|
|
-.queue-status-waiting {
|
|
|
- color: #0d6efd;
|
|
|
+.queue-position {
|
|
|
+ white-space: nowrap;
|
|
|
}
|
|
|
|
|
|
.empty-state {
|