Update pagination in code-quality-violations to match companies/vendors: - Add numbered page buttons with ellipsis for large page counts - Add startIndex and endIndex computed properties - Add goToPage(pageNum) method for direct page navigation - Use consistent grid layout (col-span-3, col-span-9) This standardizes pagination UI across all admin tables. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
258 lines
14 KiB
HTML
258 lines
14 KiB
HTML
{# app/templates/admin/code-quality-violations.html #}
|
|
{% extends "admin/base.html" %}
|
|
|
|
{% block title %}Violations List{% endblock %}
|
|
|
|
{% block alpine_data %}codeQualityViolations(){% endblock %}
|
|
|
|
{% block extra_scripts %}
|
|
<script src="/static/admin/js/code-quality-violations.js"></script>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- Page Header -->
|
|
<div class="flex items-center justify-between my-6">
|
|
<div>
|
|
<h2 class="text-2xl font-semibold text-gray-700 dark:text-gray-200">
|
|
Architecture Violations
|
|
</h2>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
|
|
Review and manage code quality violations
|
|
</p>
|
|
</div>
|
|
<a href="/admin/code-quality"
|
|
class="flex items-center px-4 py-2 text-sm font-medium leading-5 text-gray-700 dark:text-gray-300 transition-colors duration-150 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:shadow-outline-gray">
|
|
<span x-html="$icon('arrow-left', 'w-4 h-4 mr-2')"></span>
|
|
Back to Dashboard
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Loading State -->
|
|
<div x-show="loading" class="text-center py-12">
|
|
<span x-html="$icon('spinner', 'inline w-8 h-8 text-purple-600')"></span>
|
|
<p class="mt-2 text-gray-600 dark:text-gray-400">Loading violations...</p>
|
|
</div>
|
|
|
|
<!-- Error State -->
|
|
<div x-show="error && !loading" class="mb-6 p-4 bg-red-100 border border-red-400 text-red-700 rounded-lg flex items-start">
|
|
<span x-html="$icon('exclamation', 'w-5 h-5 mr-3 mt-0.5 flex-shrink-0')"></span>
|
|
<div>
|
|
<p class="font-semibold">Error loading violations</p>
|
|
<p class="text-sm" x-text="error"></p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Content -->
|
|
<div x-show="!loading">
|
|
<!-- Filters -->
|
|
<div class="mb-6 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<h3 class="mb-4 text-lg font-semibold text-gray-700 dark:text-gray-200">Filters</h3>
|
|
<div class="grid gap-4 md:grid-cols-4">
|
|
<!-- Severity Filter -->
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-2">
|
|
Severity
|
|
</label>
|
|
<select x-model="filters.severity"
|
|
@change="applyFilters()"
|
|
class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-select rounded-md">
|
|
<option value="">All</option>
|
|
<option value="error">Error</option>
|
|
<option value="warning">Warning</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Status Filter -->
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-2">
|
|
Status
|
|
</label>
|
|
<select x-model="filters.status"
|
|
@change="applyFilters()"
|
|
class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-select rounded-md">
|
|
<option value="">All</option>
|
|
<option value="open">Open</option>
|
|
<option value="assigned">Assigned</option>
|
|
<option value="resolved">Resolved</option>
|
|
<option value="ignored">Ignored</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Rule ID Filter -->
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-2">
|
|
Rule ID
|
|
</label>
|
|
<input x-model="filters.rule_id"
|
|
@input.debounce.500ms="applyFilters()"
|
|
type="text"
|
|
placeholder="e.g. API-001"
|
|
class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-input rounded-md">
|
|
</div>
|
|
|
|
<!-- File Path Filter -->
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-2">
|
|
File Path
|
|
</label>
|
|
<input x-model="filters.file_path"
|
|
@input.debounce.500ms="applyFilters()"
|
|
type="text"
|
|
placeholder="e.g. app/api"
|
|
class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray form-input rounded-md">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Violations Table -->
|
|
<div class="w-full overflow-hidden rounded-lg shadow-xs">
|
|
<div class="w-full overflow-x-auto">
|
|
<table class="w-full whitespace-no-wrap">
|
|
<thead>
|
|
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
|
|
<th class="px-4 py-3">Rule</th>
|
|
<th class="px-4 py-3">Severity</th>
|
|
<th class="px-4 py-3">File</th>
|
|
<th class="px-4 py-3">Line</th>
|
|
<th class="px-4 py-3">Message</th>
|
|
<th class="px-4 py-3">Status</th>
|
|
<th class="px-4 py-3">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
|
<template x-if="violations.length === 0">
|
|
<tr>
|
|
<td colspan="7" class="px-4 py-8 text-center text-gray-500 dark:text-gray-400">
|
|
No violations found
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
<template x-for="violation in violations" :key="violation.id">
|
|
<tr class="text-gray-700 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
<!-- Rule ID -->
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center text-sm">
|
|
<div>
|
|
<p class="font-semibold" x-text="violation.rule_id"></p>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
|
|
<!-- Severity Badge -->
|
|
<td class="px-4 py-3 text-xs">
|
|
<span class="px-2 py-1 font-semibold leading-tight rounded-full"
|
|
:class="{
|
|
'text-red-700 bg-red-100 dark:bg-red-700 dark:text-red-100': violation.severity === 'error',
|
|
'text-yellow-700 bg-yellow-100 dark:text-yellow-100 dark:bg-yellow-700': violation.severity === 'warning'
|
|
}"
|
|
x-text="violation.severity">
|
|
</span>
|
|
</td>
|
|
|
|
<!-- File Path -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<p class="truncate max-w-xs" :title="violation.file_path" x-text="violation.file_path"></p>
|
|
</td>
|
|
|
|
<!-- Line Number -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<p x-text="violation.line_number"></p>
|
|
</td>
|
|
|
|
<!-- Message -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<p class="truncate max-w-md" :title="violation.message" x-text="violation.message"></p>
|
|
</td>
|
|
|
|
<!-- Status Badge -->
|
|
<td class="px-4 py-3 text-xs">
|
|
<span class="px-2 py-1 font-semibold leading-tight rounded-full"
|
|
:class="{
|
|
'text-gray-700 bg-gray-100 dark:text-gray-100 dark:bg-gray-700': violation.status === 'open',
|
|
'text-blue-700 bg-blue-100 dark:text-blue-100 dark:bg-blue-700': violation.status === 'assigned',
|
|
'text-green-700 bg-green-100 dark:text-green-100 dark:bg-green-700': violation.status === 'resolved',
|
|
'text-orange-700 bg-orange-100 dark:text-orange-100 dark:bg-orange-700': violation.status === 'ignored'
|
|
}"
|
|
x-text="violation.status">
|
|
</span>
|
|
</td>
|
|
|
|
<!-- Actions -->
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center space-x-2">
|
|
<a :href="'/admin/code-quality/violations/' + violation.id"
|
|
class="flex items-center justify-center p-2 text-purple-600 rounded-lg hover:bg-purple-50 dark:text-purple-400 dark:hover:bg-gray-700 focus:outline-none transition-colors"
|
|
title="View Details">
|
|
<span x-html="$icon('eye', 'w-5 h-5')"></span>
|
|
</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pagination Footer -->
|
|
<div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800">
|
|
<!-- Results Info -->
|
|
<span class="flex items-center col-span-3">
|
|
Showing <span class="mx-1 font-bold" x-text="startIndex"></span>-<span class="mx-1 font-bold" x-text="endIndex"></span> of <span class="mx-1 font-bold" x-text="pagination.total"></span>
|
|
</span>
|
|
<span class="col-span-2"></span>
|
|
|
|
<!-- Pagination Controls -->
|
|
<span class="flex col-span-4 mt-2 sm:mt-auto sm:justify-end">
|
|
<nav aria-label="Table navigation">
|
|
<ul class="inline-flex items-center">
|
|
<!-- Previous Button -->
|
|
<li>
|
|
<button
|
|
@click="previousPage()"
|
|
:disabled="pagination.page === 1"
|
|
class="px-3 py-1 rounded-md rounded-l-lg focus:outline-none focus:shadow-outline-purple"
|
|
:class="pagination.page === 1 ? 'opacity-50 cursor-not-allowed' : 'hover:bg-gray-100 dark:hover:bg-gray-700'"
|
|
aria-label="Previous"
|
|
>
|
|
<svg class="w-4 h-4 fill-current" aria-hidden="true" viewBox="0 0 20 20">
|
|
<path d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" fill-rule="evenodd"></path>
|
|
</svg>
|
|
</button>
|
|
</li>
|
|
|
|
<!-- Page Numbers -->
|
|
<template x-for="pageNum in pageNumbers" :key="pageNum">
|
|
<li>
|
|
<button
|
|
x-show="pageNum !== '...'"
|
|
@click="goToPage(pageNum)"
|
|
class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple"
|
|
:class="pagination.page === pageNum ? 'text-white bg-purple-600 border border-purple-600' : 'hover:bg-gray-100 dark:hover:bg-gray-700'"
|
|
x-text="pageNum"
|
|
></button>
|
|
<span x-show="pageNum === '...'" class="px-3 py-1">...</span>
|
|
</li>
|
|
</template>
|
|
|
|
<!-- Next Button -->
|
|
<li>
|
|
<button
|
|
@click="nextPage()"
|
|
:disabled="pagination.page === totalPages"
|
|
class="px-3 py-1 rounded-md rounded-r-lg focus:outline-none focus:shadow-outline-purple"
|
|
:class="pagination.page === totalPages ? 'opacity-50 cursor-not-allowed' : 'hover:bg-gray-100 dark:hover:bg-gray-700'"
|
|
aria-label="Next"
|
|
>
|
|
<svg class="w-4 h-4 fill-current" aria-hidden="true" viewBox="0 0 20 20">
|
|
<path d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" fill-rule="evenodd"></path>
|
|
</svg>
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|