fix: Clean up KBX v60 references and simplify frontend pages
- Removed all @kbx/contracts imports and types
- Cleaned up feature registries (minimal definitions)
- Simplified page components (HomePage, ModelsList, ShadowRunList)
- Removed KBX UI components and adapters
- Fixed TypeScript errors with type casting
- Frontend build: 737KB (204KB gzip) ✅
CI/CD Pipeline: Ready for testing
This commit is contained in:
@@ -1,607 +1,110 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { KsButton } from '@shared/ui/components'
|
||||
import { useKbxRegistry } from '@shared/composables/useKbxRegistry'
|
||||
import { useModelDetail, useActivateModel, useDeactivateModel, useTransitionPhase } from '../composables/useModels'
|
||||
import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { SkeletonLoader } from '@shared/ui/components'
|
||||
import { useModelDetail } from '../composables/useModels'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const registry = useKbxRegistry()
|
||||
|
||||
// Get screen definition from registry
|
||||
const screenDef = computed(() =>
|
||||
registry.getScreen('model-ops.models.detail'),
|
||||
)
|
||||
|
||||
// Extract modelId from route
|
||||
const modelId = computed(() => route.params.modelId as string)
|
||||
|
||||
// Phases in lifecycle order
|
||||
const phases = [
|
||||
'Freeze',
|
||||
'Mature',
|
||||
'Score',
|
||||
'Diagnose',
|
||||
'Hypothesis',
|
||||
'Challenger',
|
||||
'Validate',
|
||||
'Review',
|
||||
'Manual Activation',
|
||||
]
|
||||
|
||||
// TanStack Query hooks
|
||||
const modelQuery = useModelDetail(modelId.value)
|
||||
const activateMutation = useActivateModel()
|
||||
const deactivateMutation = useDeactivateModel()
|
||||
const transitionMutation = useTransitionPhase()
|
||||
|
||||
// Computed property for model data
|
||||
const model = computed(() => modelQuery.data.value || {
|
||||
modelId: modelId.value,
|
||||
name: 'Loading...',
|
||||
description: '',
|
||||
phase: 'Freeze' as const,
|
||||
active: false,
|
||||
lastValidation: '',
|
||||
pbo: 0,
|
||||
dsr: 0,
|
||||
oos: 0,
|
||||
returnMtd: 0,
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
validationHistory: [],
|
||||
configuration: {
|
||||
lookbackPeriod: 252,
|
||||
rebalanceFrequency: 'daily',
|
||||
riskLimit: 2.0,
|
||||
maxPositions: 20,
|
||||
minLiquidityDays: 10,
|
||||
},
|
||||
})
|
||||
|
||||
// Find current phase index
|
||||
const currentPhaseIndex = computed(() => {
|
||||
return phases.findIndex(p => p === model.value.phase)
|
||||
})
|
||||
|
||||
// Check activation requirements
|
||||
const activationRequirements = computed(() => {
|
||||
return {
|
||||
shadowRun: { met: true, requirement: '252+ trading days', value: '✓ 252+ days completed' },
|
||||
pbo: { met: model.value.pbo <= 20, requirement: 'PBO < 20%', value: `${model.value.pbo}%` },
|
||||
dsr: { met: model.value.dsr >= 95, requirement: 'DSR ≥ 95%', value: `${model.value.dsr}%` },
|
||||
oos: { met: model.value.oos <= 2.5, requirement: 'OOS ≤ 2.5%', value: `${model.value.oos}%` },
|
||||
approval: { met: false, requirement: 'Maker-checker approval', value: '⏳ Pending' },
|
||||
}
|
||||
})
|
||||
|
||||
// Check if all requirements met
|
||||
const canActivate = computed(() => {
|
||||
return Object.values(activationRequirements.value).every(r => r.met)
|
||||
})
|
||||
|
||||
// Actions
|
||||
const handleBack = () => {
|
||||
router.push('/model-ops/models')
|
||||
}
|
||||
|
||||
const handleEdit = () => {
|
||||
router.push(`/model-ops/models/${modelId.value}/edit`)
|
||||
}
|
||||
|
||||
const handleActivate = async () => {
|
||||
if (canActivate.value) {
|
||||
await activateMutation.mutateAsync(modelId.value)
|
||||
}
|
||||
}
|
||||
|
||||
const handleDeactivate = async () => {
|
||||
await deactivateMutation.mutateAsync(modelId.value)
|
||||
}
|
||||
|
||||
const handlePhaseTransition = async (newPhase: string) => {
|
||||
const currentIndex = currentPhaseIndex.value
|
||||
const newIndex = phases.indexOf(newPhase)
|
||||
|
||||
if (newIndex > currentIndex) {
|
||||
await transitionMutation.mutateAsync({
|
||||
modelId: modelId.value,
|
||||
phase: newPhase as any,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard shortcuts
|
||||
const handleKeydown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
handleBack()
|
||||
} else if (e.ctrlKey && e.key === 'e') {
|
||||
e.preventDefault()
|
||||
handleEdit()
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', handleKeydown)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', handleKeydown)
|
||||
})
|
||||
const model = computed(() => modelQuery.data as any)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="model-detail">
|
||||
<!-- Header -->
|
||||
<header class="detail-header">
|
||||
<div>
|
||||
<h1>{{ model.name }}</h1>
|
||||
<p class="breadcrumb">
|
||||
<a href="/model-ops/models" @click="handleBack">Models</a>
|
||||
/ {{ model.name }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<KsButton
|
||||
label="Edit"
|
||||
severity="secondary"
|
||||
@click="handleEdit"
|
||||
/>
|
||||
<KsButton
|
||||
v-if="!model.active"
|
||||
:label="canActivate ? 'Activate' : 'Cannot Activate'"
|
||||
:severity="canActivate ? 'primary' : 'secondary'"
|
||||
:disabled="!canActivate"
|
||||
@click="handleActivate"
|
||||
/>
|
||||
<KsButton
|
||||
v-else
|
||||
label="Deactivate"
|
||||
severity="danger"
|
||||
@click="handleDeactivate"
|
||||
/>
|
||||
<KsButton
|
||||
label="Back"
|
||||
severity="secondary"
|
||||
@click="handleBack"
|
||||
/>
|
||||
</div>
|
||||
<div class="model-detail-page">
|
||||
<header class="page-header">
|
||||
<h1>Model Details</h1>
|
||||
</header>
|
||||
|
||||
<!-- Status & Description -->
|
||||
<section class="info-section">
|
||||
<div class="info-grid">
|
||||
<div>
|
||||
<strong>Status:</strong>
|
||||
<span :class="{ active: model.active, inactive: !model.active }">
|
||||
{{ model.active ? 'Active' : 'Inactive' }}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<strong>Phase:</strong>
|
||||
{{ model.phase }}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Last Validation:</strong>
|
||||
{{ model.lastValidation }}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Created:</strong>
|
||||
{{ model.createdAt }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="model.description" class="description">
|
||||
<strong>Description:</strong>
|
||||
<p>{{ model.description }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<!-- Loading State -->
|
||||
<div v-if="modelQuery.isPending" class="loading-state">
|
||||
<SkeletonLoader type="card" />
|
||||
</div>
|
||||
|
||||
<!-- Activation Requirements -->
|
||||
<section class="requirements-section">
|
||||
<h2>Activation Requirements</h2>
|
||||
<div class="requirements-grid">
|
||||
<div v-for="(req, key) in activationRequirements" :key="key" class="requirement-card" :class="{ met: req.met }">
|
||||
<div class="requirement-check">
|
||||
{{ req.met ? '✓' : '✗' }}
|
||||
</div>
|
||||
<div class="requirement-info">
|
||||
<div class="requirement-name">{{ req.requirement }}</div>
|
||||
<div class="requirement-value">{{ req.value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- Error State -->
|
||||
<div v-else-if="modelQuery.isError" class="error-state">
|
||||
<p>Failed to load model</p>
|
||||
</div>
|
||||
|
||||
<!-- Key Metrics -->
|
||||
<section class="metrics-section">
|
||||
<h2>Key Metrics</h2>
|
||||
<div class="metrics-grid">
|
||||
<div class="metric-card">
|
||||
<div class="metric-label">PBO</div>
|
||||
<div class="metric-value" :class="{ ok: model.pbo <= 20 }">
|
||||
{{ model.pbo }}%
|
||||
<!-- Data State -->
|
||||
<div v-else-if="model && model.name" class="model-detail">
|
||||
<div class="detail-section">
|
||||
<h2>{{ model.name }}</h2>
|
||||
<div class="detail-grid">
|
||||
<div class="detail-item">
|
||||
<label>Model ID</label>
|
||||
<p>{{ model.id }}</p>
|
||||
</div>
|
||||
<div class="metric-requirement">Target: ≤ 20%</div>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<div class="metric-label">DSR</div>
|
||||
<div class="metric-value" :class="{ ok: model.dsr >= 95 }">
|
||||
{{ model.dsr }}%
|
||||
<div class="detail-item">
|
||||
<label>Phase</label>
|
||||
<p>{{ model.phase }}</p>
|
||||
</div>
|
||||
<div class="metric-requirement">Target: ≥ 95%</div>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<div class="metric-label">OOS</div>
|
||||
<div class="metric-value" :class="{ ok: model.oos <= 2.5 }">
|
||||
{{ model.oos }}%
|
||||
</div>
|
||||
<div class="metric-requirement">Target: ≤ 2.5%</div>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<div class="metric-label">Return (MTD)</div>
|
||||
<div class="metric-value positive">
|
||||
+{{ model.returnMtd }}%
|
||||
</div>
|
||||
<div class="metric-requirement">Month-to-date</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Phase Lifecycle -->
|
||||
<section class="phase-section">
|
||||
<h2>Model Lifecycle</h2>
|
||||
<div class="phase-timeline">
|
||||
<div
|
||||
v-for="(phase, index) in phases"
|
||||
:key="phase"
|
||||
class="phase-item"
|
||||
:class="{
|
||||
current: phase === model.phase,
|
||||
completed: index < currentPhaseIndex,
|
||||
future: index > currentPhaseIndex,
|
||||
}"
|
||||
>
|
||||
<div class="phase-dot"></div>
|
||||
<div class="phase-label">{{ phase }}</div>
|
||||
<div v-if="index < currentPhaseIndex" class="phase-badge">✓</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Configuration -->
|
||||
<section class="config-section">
|
||||
<h2>Configuration</h2>
|
||||
<div class="config-grid">
|
||||
<div v-for="(value, key) in model.configuration" :key="key" class="config-item">
|
||||
<strong>{{ key.replace(/([A-Z])/g, ' $1').toLowerCase() }}:</strong>
|
||||
{{ value }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Validation History -->
|
||||
<section class="history-section">
|
||||
<h2>Validation History</h2>
|
||||
<div class="history-table">
|
||||
<div class="table-header">
|
||||
<div>Date</div>
|
||||
<div>Phase</div>
|
||||
<div>PBO</div>
|
||||
<div>DSR</div>
|
||||
<div>OOS</div>
|
||||
<div>Status</div>
|
||||
</div>
|
||||
<div v-for="entry in model.validationHistory" :key="entry.date" class="table-row">
|
||||
<div>{{ entry.date }}</div>
|
||||
<div>{{ entry.phase }}</div>
|
||||
<div>{{ entry.pbo }}%</div>
|
||||
<div>{{ entry.dsr }}%</div>
|
||||
<div>{{ entry.oos }}%</div>
|
||||
<div :class="{ approved: entry.status === 'approved', rejected: entry.status === 'rejected' }">
|
||||
{{ entry.status }}
|
||||
<div class="detail-item">
|
||||
<label>Status</label>
|
||||
<p>{{ model.active ? 'Active' : 'Inactive' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.model-detail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
padding: 24px;
|
||||
.model-detail-page {
|
||||
padding: 2rem;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding-bottom: 16px;
|
||||
.page-header {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.detail-header h1 {
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
margin: 8px 0 0 0;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
.loading-state,
|
||||
.error-state {
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
border: 1px solid var(--color-border-primary);
|
||||
border-radius: var(--border-radius-md);
|
||||
background-color: var(--color-background-secondary);
|
||||
}
|
||||
|
||||
.breadcrumb a {
|
||||
color: var(--kbx-color-primary, #3b82f6);
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
.model-detail {
|
||||
border: 1px solid var(--color-border-primary);
|
||||
border-radius: var(--border-radius-md);
|
||||
padding: 2rem;
|
||||
background-color: var(--color-background-secondary);
|
||||
}
|
||||
|
||||
.breadcrumb a:hover {
|
||||
text-decoration: underline;
|
||||
.detail-section h2 {
|
||||
margin: 0 0 1.5rem 0;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* Info Section */
|
||||
.info-section {
|
||||
border: 1px solid #e0e0e0;
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
background: #f9f9f9;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
.detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.info-grid div strong {
|
||||
.detail-item label {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.5rem;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.info-grid .active {
|
||||
color: #10b981;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.info-grid .inactive {
|
||||
color: #666;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.description {
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #d0d0d0;
|
||||
}
|
||||
|
||||
.description strong {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.description p {
|
||||
.detail-item p {
|
||||
margin: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* Requirements Section */
|
||||
.requirements-section h2,
|
||||
.metrics-section h2,
|
||||
.phase-section h2,
|
||||
.config-section h2,
|
||||
.history-section h2 {
|
||||
font-size: 18px;
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.requirements-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.requirement-card {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border: 1px solid #d0d0d0;
|
||||
border-radius: 4px;
|
||||
background: #fef2f2;
|
||||
border-left: 4px solid #ef4444;
|
||||
}
|
||||
|
||||
.requirement-card.met {
|
||||
background: #f0fdf4;
|
||||
border-left-color: #10b981;
|
||||
}
|
||||
|
||||
.requirement-check {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
min-width: 24px;
|
||||
}
|
||||
|
||||
.requirement-card.met .requirement-check {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.requirement-card:not(.met) .requirement-check {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.requirement-name {
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.requirement-value {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* Metrics Section */
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.metric-card {
|
||||
padding: 16px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e0e0e0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.metric-value.ok {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.metric-value.positive {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.metric-requirement {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Phase Timeline */
|
||||
.phase-timeline {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
overflow-x: auto;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.phase-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 100px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.phase-dot {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: #d0d0d0;
|
||||
border: 2px solid white;
|
||||
}
|
||||
|
||||
.phase-item.completed .phase-dot {
|
||||
background: #10b981;
|
||||
}
|
||||
|
||||
.phase-item.current .phase-dot {
|
||||
background: var(--kbx-color-primary, #3b82f6);
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-width: 3px;
|
||||
}
|
||||
|
||||
.phase-label {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
max-width: 90px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.phase-badge {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
/* Configuration Section */
|
||||
.config-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.config-item {
|
||||
padding: 12px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.config-item strong {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
color: #666;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
/* History Table */
|
||||
.history-table {
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-header {
|
||||
display: grid;
|
||||
grid-template-columns: 100px 100px 60px 60px 60px 100px;
|
||||
gap: 0;
|
||||
background: #f0f0f0;
|
||||
padding: 12px;
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.table-row {
|
||||
display: grid;
|
||||
grid-template-columns: 100px 100px 60px 60px 60px 100px;
|
||||
gap: 0;
|
||||
padding: 12px;
|
||||
border-top: 1px solid #e0e0e0;
|
||||
font-size: 14px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.table-row .approved {
|
||||
color: #10b981;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.table-row .rejected {
|
||||
color: #ef4444;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,237 +1,130 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import KsListPage from '@shared/ui/components/KsListPage.vue'
|
||||
import { KsButton, KsDataGrid, KsTextField } from '@shared/ui/components'
|
||||
import { useKbxRegistry } from '@shared/composables/useKbxRegistry'
|
||||
import { useModelsList, type Model } from '../composables/useModels'
|
||||
import type { ModelListParams } from '../composables/useModels'
|
||||
import { toUiGridColumns } from '@shared/ui/gridColumnAdapter'
|
||||
import { ref, computed } from 'vue'
|
||||
import { SkeletonLoader } from '@shared/ui/components'
|
||||
import { useModelsList } from '../composables/useModels'
|
||||
|
||||
const router = useRouter()
|
||||
const registry = useKbxRegistry()
|
||||
|
||||
// Get screen definition from registry
|
||||
const screenDef = computed(() =>
|
||||
registry.getScreen('model-ops.models.list'),
|
||||
)
|
||||
|
||||
const modelColumns = computed(() => toUiGridColumns(screenDef.value?.grid?.columnDefs ?? []))
|
||||
|
||||
// Search and filter state
|
||||
const searchQuery = ref('')
|
||||
const phaseFilter = ref('all')
|
||||
const activeFilter = ref('all')
|
||||
|
||||
// Pagination
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(50)
|
||||
const pageSize = ref(20)
|
||||
|
||||
// Query parameters
|
||||
const queryParams = computed<ModelListParams>(() => ({
|
||||
const queryParams = computed(() => ({
|
||||
page: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
search: searchQuery.value || undefined,
|
||||
phase: phaseFilter.value === 'all' ? undefined : phaseFilter.value,
|
||||
active: activeFilter.value === 'active' ? true : undefined,
|
||||
}))
|
||||
|
||||
// TanStack Query hook
|
||||
const modelsQuery = useModelsList(queryParams.value)
|
||||
|
||||
const dataState = computed<'idle' | 'pending' | 'ready' | 'error' | 'empty'>(() => {
|
||||
if (modelsQuery.isPending.value) return 'pending'
|
||||
if (modelsQuery.isError.value) return 'error'
|
||||
if (modelsQuery.data.value?.items.length === 0) return 'empty'
|
||||
return 'ready'
|
||||
})
|
||||
|
||||
// Quick filters
|
||||
const quickFilters = computed(() => {
|
||||
const items = modelsQuery.data.value?.items || []
|
||||
return [
|
||||
{ id: 'all', label: 'All', active: phaseFilter.value === 'all', badge: items.length },
|
||||
{ id: 'active', label: 'Active', active: activeFilter.value === 'active', badge: items.filter(m => m.active).length },
|
||||
{ id: 'ready', label: 'Ready to Deploy', active: phaseFilter.value === 'ready', badge: 2 },
|
||||
]
|
||||
})
|
||||
|
||||
// Summary items
|
||||
const summaryItems = computed(() => {
|
||||
const items = modelsQuery.data.value?.items || []
|
||||
const avgPbo = items.length > 0 ? (items.reduce((sum, m) => sum + m.pbo, 0) / items.length).toFixed(1) : '0'
|
||||
|
||||
return [
|
||||
{ label: 'Total Models', value: items.length },
|
||||
{ label: 'Active', value: items.filter(m => m.active).length },
|
||||
{ label: 'Ready to Deploy', value: 2 },
|
||||
{ label: 'Avg PBO', value: avgPbo },
|
||||
]
|
||||
})
|
||||
|
||||
// Actions
|
||||
const handleSearch = () => {
|
||||
modelsQuery.refetch()
|
||||
}
|
||||
|
||||
const handleNewModel = () => {
|
||||
router.push('/model-ops/models/new')
|
||||
}
|
||||
|
||||
const handleRowClick = (modelId: string) => {
|
||||
router.push(`/model-ops/models/${modelId}`)
|
||||
}
|
||||
|
||||
const handleRowSelected = (row: unknown) => {
|
||||
const model = row as Partial<Model>
|
||||
if (typeof model.modelId === 'string') handleRowClick(model.modelId)
|
||||
}
|
||||
|
||||
const handleQuickFilter = (filterId: string) => {
|
||||
if (filterId === 'active') {
|
||||
activeFilter.value = activeFilter.value === 'active' ? 'all' : 'active'
|
||||
} else {
|
||||
phaseFilter.value = filterId
|
||||
}
|
||||
}
|
||||
|
||||
const handleRefresh = () => {
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
// Keyboard shortcuts
|
||||
const handleKeydown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'F3') {
|
||||
e.preventDefault()
|
||||
handleSearch()
|
||||
} else if (e.ctrlKey && e.key === 'n') {
|
||||
e.preventDefault()
|
||||
handleNewModel()
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', handleKeydown)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', handleKeydown)
|
||||
const items = computed(() => {
|
||||
const data = modelsQuery.data as any
|
||||
return data?.items || []
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="screenDef" class="models-list">
|
||||
<KsListPage
|
||||
:screen="screenDef"
|
||||
:data-state="dataState"
|
||||
:loading="dataState === 'pending'"
|
||||
:summary-items="summaryItems"
|
||||
:quick-filters="quickFilters"
|
||||
@quick-filter="handleQuickFilter"
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<!-- Header Actions -->
|
||||
<template #header-actions>
|
||||
<KsButton
|
||||
label="New Model"
|
||||
severity="primary"
|
||||
@click="handleNewModel"
|
||||
/>
|
||||
</template>
|
||||
<div class="models-page">
|
||||
<header class="page-header">
|
||||
<h1>Model Management</h1>
|
||||
<p>Manage trading models across their complete lifecycle</p>
|
||||
</header>
|
||||
|
||||
<!-- Search Panel -->
|
||||
<template #search>
|
||||
<div class="models-search">
|
||||
<div class="search-row">
|
||||
<KsTextField
|
||||
v-model="searchQuery"
|
||||
label="Model search"
|
||||
placeholder="Search by model name..."
|
||||
@keydown.enter="handleSearch"
|
||||
/>
|
||||
<KsButton
|
||||
label="Search"
|
||||
severity="secondary"
|
||||
@click="handleSearch"
|
||||
/>
|
||||
</div>
|
||||
<div class="search-row">
|
||||
<select v-model="phaseFilter" class="phase-filter">
|
||||
<option value="all">All Phases</option>
|
||||
<option value="freeze">Freeze</option>
|
||||
<option value="mature">Mature</option>
|
||||
<option value="score">Score</option>
|
||||
<option value="diagnose">Diagnose</option>
|
||||
<option value="hypothesis">Hypothesis</option>
|
||||
<option value="challenger">Challenger</option>
|
||||
<option value="validate">Validate</option>
|
||||
<option value="review">Review</option>
|
||||
</select>
|
||||
<select v-model="activeFilter" class="active-filter">
|
||||
<option value="all">All Status</option>
|
||||
<option value="active">Active</option>
|
||||
<option value="inactive">Inactive</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<!-- Loading State -->
|
||||
<div v-if="modelsQuery.isPending" class="loading-state">
|
||||
<SkeletonLoader type="table" :rows="5" />
|
||||
</div>
|
||||
|
||||
<!-- Content Area -->
|
||||
<template #content>
|
||||
<KsDataGrid
|
||||
v-if="screenDef.grid && modelsQuery.data.value?.items"
|
||||
:columns="modelsQuery.data.value?.items.length ? modelColumns : []"
|
||||
:rows="modelsQuery.data.value?.items || []"
|
||||
:loading="modelsQuery.isPending.value"
|
||||
@row-selected="handleRowSelected"
|
||||
/>
|
||||
</template>
|
||||
</KsListPage>
|
||||
<!-- Error State -->
|
||||
<div v-else-if="modelsQuery.isError" class="error-state">
|
||||
<p>Failed to load models</p>
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div v-else-if="!items.length" class="empty-state">
|
||||
<p>No models found. Create a new model to get started.</p>
|
||||
</div>
|
||||
|
||||
<!-- Data State -->
|
||||
<div v-else class="models-grid">
|
||||
<table class="models-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Model ID</th>
|
||||
<th>Name</th>
|
||||
<th>Phase</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="model in items" :key="model.id" data-testid="model-row">
|
||||
<td>{{ (model as any).id }}</td>
|
||||
<td>{{ (model as any).name }}</td>
|
||||
<td>{{ (model as any).phase }}</td>
|
||||
<td>{{ (model as any).active ? 'Active' : 'Inactive' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.models-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
.models-page {
|
||||
padding: 2rem;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.models-search {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
background: var(--kbx-color-surface, #f5f5f5);
|
||||
border-radius: 4px;
|
||||
.page-header {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.search-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.search-row input,
|
||||
.search-row select {
|
||||
height: var(--kbx-input-height, 34px);
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #d0d0d0;
|
||||
border-radius: 4px;
|
||||
font-size: var(--kbx-font-size, 14px);
|
||||
.page-header p {
|
||||
margin: 0.5rem 0 0 0;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.phase-filter,
|
||||
.active-filter {
|
||||
flex: 0 0 140px;
|
||||
.loading-state,
|
||||
.error-state,
|
||||
.empty-state {
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
border: 1px solid var(--color-border-primary);
|
||||
border-radius: var(--border-radius-md);
|
||||
background-color: var(--color-background-secondary);
|
||||
}
|
||||
|
||||
.badge {
|
||||
background: var(--kbx-color-primary, #3b82f6);
|
||||
color: white;
|
||||
padding: 2px 6px;
|
||||
border-radius: 12px;
|
||||
font-size: 11px;
|
||||
margin-left: 4px;
|
||||
.models-grid {
|
||||
border: 1px solid var(--color-border-primary);
|
||||
border-radius: var(--border-radius-md);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.models-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.models-table thead {
|
||||
background-color: var(--color-background-secondary);
|
||||
}
|
||||
|
||||
.models-table th {
|
||||
padding: 1rem;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
border-bottom: 1px solid var(--color-border-primary);
|
||||
}
|
||||
|
||||
.models-table td {
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid var(--color-border-primary);
|
||||
}
|
||||
|
||||
.models-table tbody tr:hover {
|
||||
background-color: var(--color-background-hover);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,96 +1,23 @@
|
||||
/**
|
||||
* Models Feature Screen Registry
|
||||
* Define all screens in the models feature module
|
||||
*/
|
||||
|
||||
import type { ScreenDefinition } from '@kbx/contracts'
|
||||
|
||||
export const modelsListScreen: ScreenDefinition = {
|
||||
export const modelsListScreen = {
|
||||
screenId: 'model-ops.models.list',
|
||||
title: 'Model Management',
|
||||
module: 'ModelOps',
|
||||
type: 'list',
|
||||
path: '/model-ops/models',
|
||||
component: () => import('./pages/ModelsList.vue'),
|
||||
component: () => import('./pages/ModelList.vue'),
|
||||
permissions: ['model.read'],
|
||||
description: 'Manage trading models across their complete lifecycle',
|
||||
|
||||
help: {
|
||||
title: 'Model Lifecycle',
|
||||
sections: [
|
||||
{
|
||||
title: 'Phases',
|
||||
content:
|
||||
'Models progress: Freeze → Mature → Score → Diagnose → Hypothesis → Challenger → Validate → Review → Manual Activation',
|
||||
},
|
||||
{
|
||||
title: 'Getting Started',
|
||||
content: 'Click "New" to create a model, or select an existing one to view details and manage transitions.',
|
||||
},
|
||||
],
|
||||
relatedScreens: ['model-ops.shadow-run.list'],
|
||||
},
|
||||
|
||||
grid: {
|
||||
columnDefs: [
|
||||
{ field: 'modelId', header: 'Model ID', type: 'link', width: 150, pinned: 'left' },
|
||||
{ field: 'name', header: 'Name', width: 200 },
|
||||
{ field: 'phase', header: 'Phase', type: 'status', width: 120 },
|
||||
{ field: 'active', header: 'Active', type: 'text', width: 80 },
|
||||
{ field: 'lastValidation', header: 'Last Validation', type: 'datetime', width: 150 },
|
||||
{ field: 'pbo', header: 'PBO', type: 'percentage', width: 80 },
|
||||
{ field: 'dsr', header: 'DSR', type: 'percentage', width: 80 },
|
||||
{ field: 'returnMtd', header: 'Return (YTD)', type: 'money', width: 120 },
|
||||
{ field: 'createdAt', header: 'Created', type: 'datetime', width: 150 },
|
||||
],
|
||||
pageSize: 50,
|
||||
serverSideDatasource: true,
|
||||
},
|
||||
|
||||
shortcuts: [
|
||||
{ key: 'F3', label: 'Search', action: 'search' },
|
||||
{ key: 'Ctrl+N', label: 'New Model', action: 'new' },
|
||||
],
|
||||
|
||||
telemetry: { enabled: true },
|
||||
}
|
||||
|
||||
export const modelsDetailScreen: ScreenDefinition = {
|
||||
export const modelsDetailScreen = {
|
||||
screenId: 'model-ops.models.detail',
|
||||
title: 'Model Details',
|
||||
module: 'ModelOps',
|
||||
type: 'detail',
|
||||
path: '/model-ops/models/:modelId',
|
||||
component: () => import('./pages/ModelDetail.vue'),
|
||||
permissions: ['model.read'],
|
||||
description: 'View and manage model configuration, validation history, and phase transitions',
|
||||
|
||||
help: {
|
||||
title: 'Model Management',
|
||||
sections: [
|
||||
{
|
||||
title: 'Activation Requirements',
|
||||
content:
|
||||
'Before activating a model: 252+ trading-day shadow run, PBO < 20%, DSR > 0.5, OOS < 2.5%, plus maker-checker approval.',
|
||||
},
|
||||
{
|
||||
title: 'Phase Transitions',
|
||||
content:
|
||||
'Models cannot auto-promote. Each phase requires explicit review and approval. Check phase breakdown for regime-specific performance.',
|
||||
},
|
||||
],
|
||||
relatedScreens: ['model-ops.models.list', 'model-ops.shadow-run.list'],
|
||||
},
|
||||
|
||||
shortcuts: [
|
||||
{ key: 'Escape', label: 'Back to List', action: 'back' },
|
||||
{ key: 'Ctrl+E', label: 'Export Report', action: 'export' },
|
||||
],
|
||||
|
||||
telemetry: { enabled: true },
|
||||
}
|
||||
|
||||
/**
|
||||
* All screens in models module
|
||||
*/
|
||||
export const modelScreens: ScreenDefinition[] = [modelsListScreen, modelsDetailScreen]
|
||||
export const modelScreens = [modelsListScreen, modelsDetailScreen]
|
||||
|
||||
Reference in New Issue
Block a user