dealroom/templates/audit.templ

74 lines
3.3 KiB
Plaintext

package templates
import "dealroom/internal/model"
import "fmt"
templ AuditLogPage(profile *model.Profile, activities []*model.DealActivity, deals []*model.Deal, selectedDealID string) {
@Layout(profile, "audit") {
<div class="space-y-5">
<div class="flex items-center justify-between">
<div>
<h1 class="text-2xl font-bold">Audit Log</h1>
<p class="text-sm text-gray-500 mt-1">Complete activity timeline across all deal rooms.</p>
</div>
<div>
<select onchange="window.location.href='/audit?deal_id='+this.value" class="px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-gray-100 focus:border-teal-500 focus:outline-none">
<option value="">All Deals</option>
for _, deal := range deals {
<option value={ deal.ID } selected?={ deal.ID == selectedDealID }>{ deal.Name }</option>
}
</select>
</div>
</div>
<div class="bg-gray-900 rounded-lg border border-gray-800 p-6">
<div class="space-y-6">
for _, act := range activities {
<div class="flex items-start gap-4 relative">
<!-- Timeline line -->
<div class="flex flex-col items-center">
@activityDot(act.ActivityType)
<div class="w-px h-full bg-gray-800 absolute top-6 left-3"></div>
</div>
<div class="flex-1 pb-6">
<div class="flex items-center gap-2">
<span class="text-sm font-medium">{ act.UserName }</span>
<span class={ "text-xs px-1.5 py-0.5 rounded font-medium",
templ.KV("bg-teal-500/10 text-teal-400", act.ActivityType == "upload"),
templ.KV("bg-blue-500/10 text-blue-400", act.ActivityType == "view"),
templ.KV("bg-amber-500/10 text-amber-400", act.ActivityType == "edit"),
templ.KV("bg-purple-500/10 text-purple-400", act.ActivityType == "download"),
templ.KV("bg-gray-700 text-gray-400", act.ActivityType != "upload" && act.ActivityType != "view" && act.ActivityType != "edit" && act.ActivityType != "download") }>
{ act.ActivityType }
</span>
if act.DealName != "" {
<a href={ templ.SafeURL(fmt.Sprintf("/deals/%s", act.DealID)) } class="text-xs text-teal-400 hover:underline">{ act.DealName }</a>
}
</div>
<p class="text-sm text-gray-400 mt-0.5">{ act.ResourceType }: { act.ResourceName }</p>
<p class="text-xs text-gray-600 mt-1">{ act.CreatedAt.Format("Jan 2, 2006 3:04 PM") }</p>
</div>
</div>
}
</div>
</div>
</div>
}
}
templ activityDot(actType string) {
<div class={ "w-6 h-6 rounded-full flex items-center justify-center shrink-0 z-10",
templ.KV("bg-teal-500/20", actType == "upload"),
templ.KV("bg-blue-500/20", actType == "view"),
templ.KV("bg-amber-500/20", actType == "edit"),
templ.KV("bg-purple-500/20", actType == "download"),
templ.KV("bg-gray-700", actType != "upload" && actType != "view" && actType != "edit" && actType != "download") }>
<div class={ "w-2 h-2 rounded-full",
templ.KV("bg-teal-400", actType == "upload"),
templ.KV("bg-blue-400", actType == "view"),
templ.KV("bg-amber-400", actType == "edit"),
templ.KV("bg-purple-400", actType == "download"),
templ.KV("bg-gray-400", actType != "upload" && actType != "view" && actType != "edit" && actType != "download") }></div>
</div>
}