Sprint 2 : moteur de documents + sanctuaire
Backend: - CRUD complet documents/items/versions (update, delete, accept, reject, reorder) - Service IPFS (upload/retrieve/pin via kubo HTTP API) - Service sanctuaire : pipeline SHA-256 + IPFS + on-chain (system.remark) - Verification integrite des entrees sanctuaire - Recherche par reference (document -> entrees sanctuaire) - Serialisation deterministe des documents pour archivage - 14 tests unitaires supplementaires (document service) Frontend: - 9 composants : StatusBadge, MarkdownRenderer, DiffView, ItemCard, ItemVersionDiff, DocumentList, SanctuaryEntry, IPFSLink, ChainAnchor - Page detail item avec historique des versions et diff - Page detail sanctuaire avec verification integrite - Modal de creation de document + proposition de version - Archivage document vers sanctuaire depuis la page detail Documentation: - API reference mise a jour (9 nouveaux endpoints) - Guides utilisateur documents et sanctuaire enrichis Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,20 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { SanctuaryEntryOut } from '~/components/sanctuary/SanctuaryEntry.vue'
|
||||
|
||||
const { $api } = useApi()
|
||||
|
||||
interface SanctuaryEntry {
|
||||
id: string
|
||||
entry_type: string
|
||||
reference_id: string
|
||||
title: string | null
|
||||
content_hash: string
|
||||
ipfs_cid: string | null
|
||||
chain_tx_hash: string | null
|
||||
chain_block: number | null
|
||||
metadata_json: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
const entries = ref<SanctuaryEntry[]>([])
|
||||
const entries = ref<SanctuaryEntryOut[]>([])
|
||||
const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
@@ -27,6 +16,10 @@ const typeOptions = [
|
||||
{ label: 'Resultat de vote', value: 'vote_result' },
|
||||
]
|
||||
|
||||
// Verification state
|
||||
const verifying = ref<string | null>(null)
|
||||
const verifyResult = ref<{ id: string; match: boolean; message: string } | null>(null)
|
||||
|
||||
async function loadEntries() {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
@@ -35,7 +28,7 @@ async function loadEntries() {
|
||||
const query: Record<string, string> = {}
|
||||
if (filterType.value) query.entry_type = filterType.value
|
||||
|
||||
entries.value = await $api<SanctuaryEntry[]>('/sanctuary/', { query })
|
||||
entries.value = await $api<SanctuaryEntryOut[]>('/sanctuary/', { query })
|
||||
} catch (err: any) {
|
||||
error.value = err?.data?.detail || err?.message || 'Erreur lors du chargement des entrees'
|
||||
} finally {
|
||||
@@ -43,6 +36,26 @@ async function loadEntries() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleVerify(id: string) {
|
||||
verifying.value = id
|
||||
verifyResult.value = null
|
||||
|
||||
try {
|
||||
const result = await $api<{ match: boolean; message: string }>(
|
||||
`/sanctuary/${id}/verify`,
|
||||
)
|
||||
verifyResult.value = { id, ...result }
|
||||
} catch (err: any) {
|
||||
verifyResult.value = {
|
||||
id,
|
||||
match: false,
|
||||
message: err?.data?.detail || err?.message || 'Erreur lors de la verification',
|
||||
}
|
||||
} finally {
|
||||
verifying.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadEntries()
|
||||
})
|
||||
@@ -50,40 +63,6 @@ onMounted(() => {
|
||||
watch(filterType, () => {
|
||||
loadEntries()
|
||||
})
|
||||
|
||||
const typeLabel = (entryType: string) => {
|
||||
switch (entryType) {
|
||||
case 'document': return 'Document'
|
||||
case 'decision': return 'Decision'
|
||||
case 'vote_result': return 'Resultat de vote'
|
||||
default: return entryType
|
||||
}
|
||||
}
|
||||
|
||||
const typeColor = (entryType: string) => {
|
||||
switch (entryType) {
|
||||
case 'document': return 'primary'
|
||||
case 'decision': return 'success'
|
||||
case 'vote_result': return 'info'
|
||||
default: return 'neutral'
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string): string {
|
||||
return new Date(dateStr).toLocaleDateString('fr-FR', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})
|
||||
}
|
||||
|
||||
function truncateHash(hash: string | null, length: number = 16): string {
|
||||
if (!hash) return '-'
|
||||
if (hash.length <= length * 2) return hash
|
||||
return hash.slice(0, length) + '...' + hash.slice(-8)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -108,10 +87,35 @@ function truncateHash(hash: string | null, length: number = 16): string {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Verification result banner -->
|
||||
<UCard v-if="verifyResult">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<UIcon
|
||||
:name="verifyResult.match ? 'i-lucide-check-circle' : 'i-lucide-alert-triangle'"
|
||||
:class="verifyResult.match ? 'text-green-500 text-xl' : 'text-red-500 text-xl'"
|
||||
/>
|
||||
<div>
|
||||
<p :class="verifyResult.match ? 'text-green-700 dark:text-green-400 font-medium' : 'text-red-700 dark:text-red-400 font-medium'">
|
||||
{{ verifyResult.match ? 'Integrite verifiee' : 'Verification echouee' }}
|
||||
</p>
|
||||
<p class="text-sm text-gray-500">{{ verifyResult.message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<UButton
|
||||
icon="i-lucide-x"
|
||||
variant="ghost"
|
||||
color="neutral"
|
||||
size="xs"
|
||||
@click="verifyResult = null"
|
||||
/>
|
||||
</div>
|
||||
</UCard>
|
||||
|
||||
<!-- Loading state -->
|
||||
<template v-if="loading">
|
||||
<div class="space-y-3">
|
||||
<USkeleton v-for="i in 4" :key="i" class="h-24 w-full" />
|
||||
<USkeleton v-for="i in 4" :key="i" class="h-48 w-full" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -138,104 +142,25 @@ function truncateHash(hash: string | null, length: number = 16): string {
|
||||
</UCard>
|
||||
</template>
|
||||
|
||||
<!-- Entries list -->
|
||||
<!-- Entries list using SanctuaryEntry component -->
|
||||
<template v-else>
|
||||
<div class="space-y-4">
|
||||
<UCard
|
||||
v-for="entry in entries"
|
||||
:key="entry.id"
|
||||
>
|
||||
<div class="space-y-4">
|
||||
<!-- Entry header -->
|
||||
<div class="flex items-start justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<UIcon name="i-lucide-shield-check" class="text-xl text-primary" />
|
||||
<div>
|
||||
<h3 class="font-semibold text-gray-900 dark:text-white">
|
||||
{{ entry.title || 'Entree sans titre' }}
|
||||
</h3>
|
||||
<p class="text-xs text-gray-500">
|
||||
{{ formatDate(entry.created_at) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<UBadge :color="typeColor(entry.entry_type)" variant="subtle" size="xs">
|
||||
{{ typeLabel(entry.entry_type) }}
|
||||
</UBadge>
|
||||
</div>
|
||||
|
||||
<!-- Hashes and anchors -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<!-- Content hash -->
|
||||
<div class="p-3 bg-gray-50 dark:bg-gray-800/50 rounded-lg">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<UIcon name="i-lucide-hash" class="text-gray-400 text-sm" />
|
||||
<span class="text-xs font-semibold text-gray-500 uppercase">SHA-256</span>
|
||||
</div>
|
||||
<p class="font-mono text-xs text-gray-700 dark:text-gray-300 break-all">
|
||||
{{ truncateHash(entry.content_hash) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- IPFS CID -->
|
||||
<div class="p-3 bg-gray-50 dark:bg-gray-800/50 rounded-lg">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<UIcon name="i-lucide-hard-drive" class="text-gray-400 text-sm" />
|
||||
<span class="text-xs font-semibold text-gray-500 uppercase">IPFS CID</span>
|
||||
</div>
|
||||
<template v-if="entry.ipfs_cid">
|
||||
<p class="font-mono text-xs text-gray-700 dark:text-gray-300 break-all">
|
||||
{{ truncateHash(entry.ipfs_cid) }}
|
||||
</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<p class="text-xs text-gray-400 italic">En attente d'epinglage</p>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Chain anchor -->
|
||||
<div class="p-3 bg-gray-50 dark:bg-gray-800/50 rounded-lg">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<UIcon name="i-lucide-link" class="text-gray-400 text-sm" />
|
||||
<span class="text-xs font-semibold text-gray-500 uppercase">On-chain</span>
|
||||
</div>
|
||||
<template v-if="entry.chain_tx_hash">
|
||||
<p class="font-mono text-xs text-gray-700 dark:text-gray-300 break-all">
|
||||
{{ truncateHash(entry.chain_tx_hash) }}
|
||||
</p>
|
||||
<p v-if="entry.chain_block" class="text-xs text-gray-400 mt-0.5">
|
||||
Bloc #{{ entry.chain_block.toLocaleString('fr-FR') }}
|
||||
</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<p class="text-xs text-gray-400 italic">En attente d'ancrage</p>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Verification status -->
|
||||
<div class="flex items-center gap-4 text-xs">
|
||||
<div class="flex items-center gap-1">
|
||||
<UIcon
|
||||
:name="entry.ipfs_cid ? 'i-lucide-check-circle' : 'i-lucide-clock'"
|
||||
:class="entry.ipfs_cid ? 'text-green-500' : 'text-gray-400'"
|
||||
/>
|
||||
<span :class="entry.ipfs_cid ? 'text-green-600' : 'text-gray-400'">
|
||||
IPFS {{ entry.ipfs_cid ? 'epingle' : 'en attente' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<UIcon
|
||||
:name="entry.chain_tx_hash ? 'i-lucide-check-circle' : 'i-lucide-clock'"
|
||||
:class="entry.chain_tx_hash ? 'text-green-500' : 'text-gray-400'"
|
||||
/>
|
||||
<span :class="entry.chain_tx_hash ? 'text-green-600' : 'text-gray-400'">
|
||||
Chain {{ entry.chain_tx_hash ? 'ancre' : 'en attente' }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-for="entry in entries" :key="entry.id" class="relative">
|
||||
<SanctuarySanctuaryEntry
|
||||
:entry="entry"
|
||||
@verify="handleVerify"
|
||||
/>
|
||||
<!-- Loading overlay for verification -->
|
||||
<div
|
||||
v-if="verifying === entry.id"
|
||||
class="absolute inset-0 bg-white/50 dark:bg-gray-900/50 flex items-center justify-center rounded-lg"
|
||||
>
|
||||
<div class="flex items-center gap-2 text-sm text-gray-500">
|
||||
<UIcon name="i-lucide-loader-2" class="animate-spin" />
|
||||
<span>Verification en cours...</span>
|
||||
</div>
|
||||
</div>
|
||||
</UCard>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user