Update regex pages

This commit is contained in:
DariusIII
2025-10-07 15:27:55 +02:00
parent 7eff8fab38
commit eac0a5650d
3 changed files with 445 additions and 309 deletions
@@ -1,130 +1,158 @@
@extends('layouts.admin')
@section('title', $title ?? 'Release Naming Regex Edit')
@section('content')
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between align-items-center">
<div>
<h4 class="mb-0">{{ $title }}</h4>
</div>
<div>
<a href="{{ url('/admin/release_naming_regexes-list') }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-arrow-left me-2"></i>Back to List
<div class="container mx-auto px-4 py-6">
<div class="bg-white rounded-lg shadow-sm">
<!-- Header -->
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex justify-between items-center">
<h1 class="text-2xl font-semibold text-gray-800">
<i class="fa fa-edit mr-2"></i>{{ $title ?? 'Release Naming Regex Edit' }}
</h1>
<a href="{{ url('/admin/release_naming_regexes-list') }}" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200">
<i class="fa fa-arrow-left mr-2"></i>Back to List
</a>
</div>
</div>
</div>
<div class="card-body">
@if($error)
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="fa fa-exclamation-triangle me-2"></i>{{ $error }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
<form action="{{ url('/admin/release_naming_regexes-edit?action=submit') }}" method="POST" id="regexForm" class="needs-validation">
<!-- Form -->
<form action="{{ url('/admin/release_naming_regexes-edit?action=submit') }}" method="POST" id="regexForm" class="px-6 py-6">
@csrf
<input type="hidden" name="id" value="{{ $regex->id ?? '' }}"/>
<div class="row mb-4">
<div class="col-lg-3 col-md-4">
<label for="group_regex" class="form-label fw-bold">Group:</label>
</div>
<div class="col-lg-9 col-md-8">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-users"></i></span>
<input type="text" id="group_regex" name="group_regex" class="form-control" value="{{ htmlspecialchars($regex->group_regex ?? '') }}" required>
<!-- Error Message -->
@if($error)
<div class="mb-6 p-4 bg-red-50 border border-red-200 rounded-lg">
<div class="flex">
<i class="fa fa-exclamation-triangle text-red-500 mr-3"></i>
<p class="text-red-800">{{ $error }}</p>
</div>
<small class="text-muted mt-1">
Regex to match against a group or multiple groups. Delimiters are already added, and PCRE_CASELESS is added after for case insensitivity.<br>
Example of matching a single group: <code>alt\.binaries\.example</code><br>
Example of matching multiple groups: <code>alt\.binaries.*</code>
</small>
</div>
@endif
<!-- Group -->
<div class="mb-6">
<label for="group_regex" class="block text-sm font-medium text-gray-700 mb-2">
Group: <span class="text-red-500">*</span>
</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i class="fa fa-users text-gray-400"></i>
</div>
<input type="text"
id="group_regex"
name="group_regex"
class="pl-10 w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
value="{{ htmlspecialchars($regex->group_regex ?? '') }}"
required>
</div>
<p class="mt-2 text-sm text-gray-500">
Regex to match against a group or multiple groups. Delimiters are already added, and PCRE_CASELESS is added after for case insensitivity.<br>
Example of matching a single group: <code class="bg-gray-100 px-2 py-1 rounded">alt\.binaries\.example</code><br>
Example of matching multiple groups: <code class="bg-gray-100 px-2 py-1 rounded">alt\.binaries.*</code>
</p>
</div>
<div class="row mb-4">
<div class="col-lg-3 col-md-4">
<label for="regex" class="form-label fw-bold">Regex:</label>
</div>
<div class="col-lg-9 col-md-8">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-code"></i></span>
<textarea id="regex" name="regex" class="form-control" rows="4" required>{{ htmlspecialchars($regex->regex ?? '') }}</textarea>
<!-- Regex -->
<div class="mb-6">
<label for="regex" class="block text-sm font-medium text-gray-700 mb-2">
Regex: <span class="text-red-500">*</span>
</label>
<div class="relative">
<div class="absolute top-3 left-3 pointer-events-none">
<i class="fa fa-code text-gray-400"></i>
</div>
<small class="text-muted mt-1">
Regex to use when renaming releases.<br>
The regex delimiters are not added, you MUST add them. See <a href="http://php.net/manual/en/regexp.reference.delimiters" target="_blank">this</a> page.<br>
To make the regex case insensitive, add <code>i</code> after the last delimiter.
</small>
<textarea id="regex"
name="regex"
class="pl-10 w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 font-mono text-sm"
rows="4"
required>{{ htmlspecialchars($regex->regex ?? '') }}</textarea>
</div>
<p class="mt-2 text-sm text-gray-500">
Regex to use when renaming releases.<br>
The regex delimiters are not added, you MUST add them. See <a href="http://php.net/manual/en/regexp.reference.delimiters" target="_blank" class="text-blue-600 hover:text-blue-800">this</a> page.<br>
To make the regex case insensitive, add <code class="bg-gray-100 px-2 py-1 rounded">i</code> after the last delimiter.
</p>
</div>
<div class="row mb-4">
<div class="col-lg-3 col-md-4">
<label for="description" class="form-label fw-bold">Description:</label>
</div>
<div class="col-lg-9 col-md-8">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-align-left"></i></span>
<textarea id="description" name="description" class="form-control" rows="3">{{ htmlspecialchars($regex->description ?? '') }}</textarea>
<!-- Description -->
<div class="mb-6">
<label for="description" class="block text-sm font-medium text-gray-700 mb-2">
Description:
</label>
<div class="relative">
<div class="absolute top-3 left-3 pointer-events-none">
<i class="fa fa-align-left text-gray-400"></i>
</div>
<small class="text-muted mt-1">
Description for this regex. You can include an example release name this regex would match on.
</small>
<textarea id="description"
name="description"
class="pl-10 w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
rows="3">{{ htmlspecialchars($regex->description ?? '') }}</textarea>
</div>
<p class="mt-2 text-sm text-gray-500">
Description for this regex. You can include an example release name this regex would match on.
</p>
</div>
<div class="row mb-4">
<div class="col-lg-3 col-md-4">
<label for="ordinal" class="form-label fw-bold">Ordinal:</label>
</div>
<div class="col-lg-9 col-md-8">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-sort-numeric-asc"></i></span>
<input type="number" id="ordinal" name="ordinal" class="form-control" value="{{ $regex->ordinal ?? 0 }}" min="0" required>
<!-- Ordinal -->
<div class="mb-6">
<label for="ordinal" class="block text-sm font-medium text-gray-700 mb-2">
Ordinal: <span class="text-red-500">*</span>
</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i class="fa fa-sort-numeric-asc text-gray-400"></i>
</div>
<small class="text-muted mt-1">
The order to run this regex in. Must be a number, 0 or higher.<br>
If multiple regex have the same ordinal, MySQL will randomly sort them.
</small>
<input type="number"
id="ordinal"
name="ordinal"
class="pl-10 w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
value="{{ $regex->ordinal ?? 0 }}"
min="0"
required>
</div>
<p class="mt-2 text-sm text-gray-500">
The order to run this regex in. Must be a number, 0 or higher.<br>
If multiple regex have the same ordinal, MySQL will randomly sort them.
</p>
</div>
<div class="row mb-4">
<div class="col-lg-3 col-md-4">
<label class="form-label fw-bold">Active:</label>
</div>
<div class="col-lg-9 col-md-8">
<div class="border rounded p-3 bg-light">
@foreach($status_ids as $k => $id)
<div class="form-check {{ $loop->last ? 'mb-0' : 'mb-2' }}">
<input class="form-check-input" type="radio" name="status" id="status{{ $id }}" value="{{ $id }}" {{ ($regex->status ?? 1) == $id ? 'checked' : '' }}>
<label class="form-check-label" for="status{{ $id }}">
{{ $status_names[$k] }}
</label>
</div>
@endforeach
</div>
<small class="text-muted mt-1">
Only active regex are used during the release naming process.
</small>
<!-- Active Status -->
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 mb-2">
Active:
</label>
<div class="bg-gray-50 border border-gray-200 rounded-lg p-4">
@foreach($status_ids as $k => $id)
<div class="flex items-center {{ $loop->last ? '' : 'mb-3' }}">
<input type="radio"
name="status"
id="status{{ $id }}"
value="{{ $id }}"
class="w-4 h-4 text-blue-600 border-gray-300 focus:ring-blue-500"
{{ ($regex->status ?? 1) == $id ? 'checked' : '' }}>
<label for="status{{ $id }}" class="ml-3 text-sm text-gray-700">
{{ $status_names[$k] }}
</label>
</div>
@endforeach
</div>
<p class="mt-2 text-sm text-gray-500">
Only active regex are used during the release naming process.
</p>
</div>
</form>
</div>
<div class="card-footer">
<div class="d-flex justify-content-between">
<a href="{{ url('/admin/release_naming_regexes-list') }}" class="btn btn-outline-secondary">
<i class="fa fa-times me-2"></i>Cancel
</a>
<button type="submit" form="regexForm" class="btn btn-success">
<i class="fa fa-save me-2"></i>Save Changes
</button>
<!-- Footer -->
<div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
<div class="flex justify-between">
<a href="{{ url('/admin/release_naming_regexes-list') }}" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300">
<i class="fa fa-times mr-2"></i>Cancel
</a>
<button type="submit" form="regexForm" class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700">
<i class="fa fa-save mr-2"></i>Save Changes
</button>
</div>
</div>
</div>
</div>
@@ -135,11 +163,15 @@ document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('regexForm');
if (form) {
form.addEventListener('submit', function(event) {
if (!form.checkValidity()) {
const groupRegex = document.getElementById('group_regex');
const regex = document.getElementById('regex');
const ordinal = document.getElementById('ordinal');
if (!groupRegex.value.trim() || !regex.value.trim() || !ordinal.value) {
event.preventDefault();
event.stopPropagation();
alert('Please fill in all required fields.');
return false;
}
form.classList.add('was-validated');
});
}
});
@@ -1,98 +1,126 @@
@extends('layouts.admin')
@section('title', $title ?? 'Release Naming Regex List')
@section('content')
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between align-items-center">
<div>
<h4 class="mb-0">{{ $title }}</h4>
</div>
<div>
<a href="{{ url('/admin/release_naming_regexes-edit') }}" class="btn btn-sm btn-primary">
<i class="fa fa-plus me-2"></i>Add New Regex
<div class="max-w-full px-4 py-6">
<div class="bg-white rounded-lg shadow-sm">
<!-- Header -->
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex justify-between items-center">
<h1 class="text-2xl font-semibold text-gray-800">
<i class="fa fa-tag mr-2"></i>{{ $title ?? 'Release Naming Regex List' }}
</h1>
<a href="{{ url('/admin/release_naming_regexes-edit') }}" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
<i class="fa fa-plus mr-2"></i>Add New Regex
</a>
</div>
</div>
</div>
<div class="card-body">
<div class="alert alert-info mb-4">
<div class="d-flex">
<div class="me-3">
<i class="fa fa-info-circle fa-2x"></i>
<!-- Info Alert -->
<div class="px-6 py-4 bg-blue-50 border-b border-blue-100">
<div class="flex">
<div class="flex-shrink-0">
<i class="fa fa-info-circle text-blue-500 text-2xl"></i>
</div>
<div>
<p class="mb-0">
<div class="ml-3">
<p class="text-sm text-blue-700">
This page lists regular expressions used for renaming releases based on their names.<br>
You can test your regex patterns to see how they will rename releases.
You can test your regex patterns using the <a href="{{ url('/admin/release_naming_regexes-test') }}" class="font-semibold underline hover:text-blue-900">test feature</a>.
</p>
</div>
</div>
</div>
<div id="message"></div>
<!-- Messages -->
<div id="message" class="px-6"></div>
<div class="row mb-4">
<div class="col-md-6">
<form name="groupsearch" action="" method="get">
@csrf
<div class="input-group">
<span class="input-group-text"><i class="fa fa-search"></i></span>
<input id="group" type="text" name="group" value="{{ $group }}" class="form-control" placeholder="Search a group...">
<button class="btn btn-primary" type="submit">Search</button>
<!-- Search Form -->
<div class="px-6 py-4 bg-gray-50 border-b border-gray-200">
<form name="groupsearch" action="" method="get" class="max-w-md">
@csrf
<label for="group" class="block text-sm font-medium text-gray-700 mb-2">Search by Group:</label>
<div class="flex gap-2">
<div class="relative flex-1">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i class="fa fa-search text-gray-400"></i>
</div>
<input id="group"
type="text"
name="group"
value="{{ $group }}"
class="pl-10 w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
placeholder="Search a group...">
</div>
</form>
</div>
<button class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700" type="submit">
Search
</button>
</div>
</form>
</div>
<!-- Table -->
@if($regex && count($regex) > 0)
<!-- Pagination Top -->
@if(method_exists($regex, 'links'))
<div class="mb-3">
<div class="px-6 py-3 border-b border-gray-200">
{{ $regex->onEachSide(5)->links() }}
</div>
@endif
<div class="table-responsive">
<table class="table table-striped table-hover align-middle">
<thead class="thead-light">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th style="width: 70px">ID</th>
<th>Group</th>
<th>Description</th>
<th>Regex</th>
<th style="width: 90px">Ordinal</th>
<th style="width: 100px">Status</th>
<th style="width: 120px" class="text-end">Actions</th>
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider w-20">ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Group</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Description</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Regex</th>
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider w-24">Ordinal</th>
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider w-24">Status</th>
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider w-28">Actions</th>
</tr>
</thead>
<tbody>
<tbody class="bg-white divide-y divide-gray-200">
@foreach($regex as $row)
<tr id="row-{{ $row->id }}">
<td>{{ $row->id }}</td>
<td>
<code class="text-primary">{{ $row->group_regex }}</code>
<tr id="row-{{ $row->id }}" class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-center text-sm font-semibold text-gray-900">{{ $row->id }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<code class="bg-blue-50 text-blue-700 px-2 py-1 rounded text-xs">{{ $row->group_regex }}</code>
</td>
<td>
<span data-bs-toggle="tooltip" title="{{ $row->description }}">{{ \Illuminate\Support\Str::limit($row->description, 50) }}</span>
<td class="px-6 py-4 text-sm text-gray-500">
<span class="inline-block max-w-[200px] truncate" title="{{ $row->description }}">
{{ $row->description }}
</span>
</td>
<td>
<code class="regex-code" data-bs-toggle="tooltip" title="{{ htmlspecialchars($row->regex) }}">{{ \Illuminate\Support\Str::limit(htmlspecialchars($row->regex), 50) }}</code>
<td class="px-6 py-4 text-sm">
<div class="max-w-[200px] break-words">
<code class="bg-gray-100 px-2 py-1 rounded text-xs break-all" title="{{ htmlspecialchars($row->regex) }}">
{{ htmlspecialchars($row->regex) }}
</code>
</div>
</td>
<td class="text-center">{{ $row->ordinal }}</td>
<td class="text-center">
<td class="px-6 py-4 whitespace-nowrap text-center text-sm text-gray-900">{{ $row->ordinal }}</td>
<td class="px-6 py-4 whitespace-nowrap text-center">
@if($row->status == 1)
<span class="badge bg-success"><i class="fa fa-check-circle me-1"></i>Active</span>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
<i class="fa fa-check-circle mr-1"></i>Active
</span>
@else
<span class="badge bg-danger"><i class="fa fa-times-circle me-1"></i>Disabled</span>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
<i class="fa fa-times-circle mr-1"></i>Disabled
</span>
@endif
</td>
<td class="text-end">
<div class="btn-group">
<a href="{{ url('/admin/release_naming_regexes-edit?id=' . $row->id) }}" class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip" title="Edit this regex">
<td class="px-6 py-4 whitespace-nowrap text-center text-sm font-medium">
<div class="flex gap-2 justify-center">
<a href="{{ url('/admin/release_naming_regexes-edit?id=' . $row->id) }}"
class="text-blue-600 hover:text-blue-900"
title="Edit this regex">
<i class="fa fa-edit"></i>
</a>
<button type="button" class="btn btn-sm btn-outline-danger" onclick="confirmDelete({{ $row->id }})" data-bs-toggle="tooltip" title="Delete this regex">
<button type="button"
class="text-red-600 hover:text-red-900"
onclick="confirmDelete({{ $row->id }})"
title="Delete this regex">
<i class="fa fa-trash"></i>
</button>
</div>
@@ -102,22 +130,28 @@
</tbody>
</table>
</div>
<!-- Pagination Bottom -->
@if(method_exists($regex, 'links'))
<div class="mt-4">
<div class="px-6 py-4 border-t border-gray-200">
{{ $regex->onEachSide(5)->links() }}
</div>
@endif
@else
<div class="alert alert-warning">
<i class="fa fa-exclamation-triangle me-2"></i>No regex patterns found. Try a different search term or add a new regex.
<div class="px-6 py-12 text-center">
<i class="fa fa-exclamation-triangle text-gray-400 text-5xl mb-4"></i>
<h3 class="text-lg font-medium text-gray-900 mb-2">No regex patterns found</h3>
<p class="text-gray-500 mb-4">Try a different search term or add a new regex.</p>
<a href="{{ url('/admin/release_naming_regexes-edit') }}" class="inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
<i class="fa fa-plus mr-2"></i>Add New Regex
</a>
</div>
@endif
</div>
<div class="card-footer">
<div class="d-flex justify-content-between align-items-center">
<div>
<span class="text-muted">
<!-- Footer -->
<div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
<div class="flex justify-between items-center">
<span class="text-sm text-gray-600">
@if($regex && method_exists($regex, 'total'))
Total entries: {{ $regex->total() }}
@elseif($regex)
@@ -126,30 +160,14 @@
No entries
@endif
</span>
</div>
<div>
<a href="{{ url('/admin/release_naming_regexes-edit') }}" class="btn btn-sm btn-primary">
<i class="fa fa-plus me-2"></i>Add New Regex
</a>
</div>
</div>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Confirm Deletion</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this regex? This action cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="confirmDeleteBtn">Delete</button>
<div class="flex gap-2">
<a href="{{ url('/admin/release_naming_regexes-test') }}" class="px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 text-sm">
<i class="fa fa-flask mr-2"></i>Test Regex
</a>
<a href="{{ url('/admin/release_naming_regexes-edit') }}" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-sm">
<i class="fa fa-plus mr-2"></i>Add New Regex
</a>
</div>
</div>
</div>
</div>
@@ -157,52 +175,53 @@
@push('scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
});
let deleteId = null;
function confirmDelete(id) {
deleteId = id;
const modal = new bootstrap.Modal(document.getElementById('deleteModal'));
modal.show();
if (confirm('Are you sure you want to delete this regex? This action cannot be undone.')) {
deleteRegex(id);
}
}
document.getElementById('confirmDeleteBtn').addEventListener('click', function() {
if (deleteId) {
fetch('{{ url("/admin/release_naming_regexes-delete") }}?id=' + deleteId, {
method: 'GET',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('row-' + deleteId).remove();
showMessage('Regex deleted successfully', 'success');
bootstrap.Modal.getInstance(document.getElementById('deleteModal')).hide();
} else {
showMessage('Error deleting regex', 'danger');
}
})
.catch(error => {
showMessage('Error deleting regex', 'danger');
});
}
});
function deleteRegex(id) {
fetch('{{ url("/admin/release_naming_regexes-delete") }}?id=' + id, {
method: 'GET',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
const row = document.getElementById('row-' + id);
row.style.transition = 'opacity 0.3s';
row.style.opacity = '0';
setTimeout(() => row.remove(), 300);
showMessage('Regex deleted successfully', 'success');
} else {
showMessage('Error deleting regex', 'error');
}
})
.catch(error => {
showMessage('Error deleting regex', 'error');
});
}
function showMessage(message, type = 'success') {
const messageDiv = document.getElementById('message');
const bgColor = type === 'success' ? 'bg-green-50 border-green-200' : 'bg-red-50 border-red-200';
const textColor = type === 'success' ? 'text-green-800' : 'text-red-800';
const icon = type === 'success' ? 'check-circle' : 'exclamation-circle';
messageDiv.innerHTML = `
<div class="alert alert-${type} alert-dismissible fade show" role="alert">
<i class="fa fa-${type === 'success' ? 'check' : 'exclamation'}-circle me-2"></i>${message}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
<div class="mt-4 p-4 ${bgColor} border rounded-lg">
<div class="flex items-center justify-between">
<p class="${textColor}">
<i class="fa fa-${icon} mr-2"></i>${message}
</p>
<button type="button" class="${textColor} hover:opacity-75" onclick="this.parentElement.parentElement.remove()">
<i class="fa fa-times"></i>
</button>
</div>
</div>
`;
setTimeout(() => {
@@ -1,106 +1,191 @@
@extends('layouts.admin')
@section('title', $title ?? 'Release Naming Regex Test')
@section('content')
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between align-items-center">
<div>
<h4 class="mb-0">{{ $title }}</h4>
</div>
<div>
<a href="{{ url('/admin/release_naming_regexes-list') }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-arrow-left me-2"></i>Back to List
<div class="container mx-auto px-4 py-6">
<div class="bg-white rounded-lg shadow-sm">
<!-- Header -->
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex justify-between items-center">
<h1 class="text-2xl font-semibold text-gray-800">
<i class="fa fa-flask mr-2"></i>{{ $title ?? 'Release Naming Regex Test' }}
</h1>
<a href="{{ url('/admin/release_naming_regexes-list') }}" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200">
<i class="fa fa-arrow-left mr-2"></i>Back to List
</a>
</div>
</div>
</div>
<div class="card-body">
<div class="alert alert-info mb-4">
<i class="fa fa-info-circle me-2"></i>Test your release naming regex patterns against actual release data from your database.
<!-- Info Alert -->
<div class="px-6 py-4 bg-blue-50 border-b border-blue-100">
<div class="flex">
<i class="fa fa-info-circle text-blue-500 text-xl mr-3"></i>
<p class="text-sm text-blue-700">
Test your release naming regex patterns against actual release data from your database.
</p>
</div>
</div>
<form method="GET" action="{{ url('/admin/release_naming_regexes-test') }}" class="mb-4">
<div class="row mb-3">
<div class="col-md-6">
<label for="group" class="form-label fw-bold">Group:</label>
<input type="text" id="group" name="group" class="form-control" value="{{ $group }}" placeholder="alt.binaries.teevee" required>
<small class="text-muted">Enter a newsgroup name to test against</small>
<!-- Test Form -->
<form method="GET" action="{{ url('/admin/release_naming_regexes-test') }}" class="px-6 py-6">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
<!-- Group Field -->
<div class="md:col-span-1">
<label for="group" class="block text-sm font-medium text-gray-700 mb-2">
Group: <span class="text-red-500">*</span>
</label>
<input type="text"
id="group"
name="group"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
value="{{ $group }}"
placeholder="alt.binaries.teevee"
required>
<p class="mt-2 text-sm text-gray-500">
Enter a newsgroup name to test against
</p>
</div>
<div class="col-md-3">
<label for="showlimit" class="form-label fw-bold">Show Limit:</label>
<input type="number" id="showlimit" name="showlimit" class="form-control" value="{{ $showlimit }}" min="1" max="1000">
<small class="text-muted">Results to display</small>
<!-- Show Limit Field -->
<div>
<label for="showlimit" class="block text-sm font-medium text-gray-700 mb-2">
Show Limit:
</label>
<input type="number"
id="showlimit"
name="showlimit"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
value="{{ $showlimit }}"
min="1"
max="1000">
<p class="mt-2 text-sm text-gray-500">
Results to display
</p>
</div>
<div class="col-md-3">
<label for="querylimit" class="form-label fw-bold">Query Limit:</label>
<input type="number" id="querylimit" name="querylimit" class="form-control" value="{{ $querylimit }}" min="1" max="500000">
<small class="text-muted">Max releases to query</small>
<!-- Query Limit Field -->
<div>
<label for="querylimit" class="block text-sm font-medium text-gray-700 mb-2">
Query Limit:
</label>
<input type="number"
id="querylimit"
name="querylimit"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
value="{{ $querylimit }}"
min="1"
max="500000">
<p class="mt-2 text-sm text-gray-500">
Max releases to query
</p>
</div>
</div>
<div class="mb-3">
<label for="regex" class="form-label fw-bold">Regex:</label>
<textarea id="regex" name="regex" class="form-control" rows="4" required placeholder="/^(?P<name>.*?)([\. ]S\d{1,3}[\. ]?E\d{1,3})/i">{{ $regex }}</textarea>
<small class="text-muted">Enter the regex pattern to test. Include delimiters and flags.</small>
<!-- Regex Field -->
<div class="mb-6">
<label for="regex" class="block text-sm font-medium text-gray-700 mb-2">
Regex: <span class="text-red-500">*</span>
</label>
<textarea id="regex"
name="regex"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 font-mono text-sm"
rows="4"
required
placeholder="/^(?P<name>.*?)([\. ]S\d{1,3}[\. ]?E\d{1,3})/i">{{ $regex }}</textarea>
<p class="mt-2 text-sm text-gray-500">
Enter the regex pattern to test. Include delimiters and flags.
</p>
</div>
<button type="submit" class="btn btn-primary">
<i class="fa fa-play me-2"></i>Test Regex
<!-- Submit Button -->
<button type="submit" class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
<i class="fa fa-play mr-2"></i>Test Regex
</button>
</form>
<!-- Results Section -->
@if($data)
<hr class="my-4">
<h5 class="mb-3">Test Results:</h5>
<div class="px-6 py-6 border-t border-gray-200">
<h2 class="text-xl font-semibold text-gray-800 mb-4">
<i class="fa fa-chart-bar mr-2"></i>Test Results:
</h2>
@if(count($data) > 0)
<div class="table-responsive">
<table class="table table-sm table-striped table-hover">
<thead>
<tr>
<th style="width: 80px">Release ID</th>
<th>Original Name</th>
<th>New Name</th>
<th style="width: 100px">Match</th>
</tr>
</thead>
<tbody>
@foreach($data as $row)
@if(count($data) > 0)
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<td>{{ $row['releaseID'] ?? $row['id'] ?? 'N/A' }}</td>
<td><small>{{ \Illuminate\Support\Str::limit($row['oldName'] ?? $row['name'] ?? '', 80) }}</small></td>
<td>
@if(isset($row['newName']) && $row['newName'])
<small class="text-success fw-bold">{{ \Illuminate\Support\Str::limit($row['newName'], 80) }}</small>
@else
<small class="text-muted"></small>
@endif
</td>
<td class="text-center">
@if(isset($row['match']) && $row['match'])
<span class="badge bg-success"><i class="fa fa-check me-1"></i>Match</span>
@else
<span class="badge bg-danger"><i class="fa fa-times me-1"></i>No Match</span>
@endif
</td>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-24">Release ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Original Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">New Name</th>
<th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider w-28">Match</th>
</tr>
@endforeach
</tbody>
</table>
</div>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach($data as $row)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm font-semibold text-gray-900">
{{ $row['releaseID'] ?? $row['id'] ?? 'N/A' }}
</td>
<td class="px-6 py-4 text-sm text-gray-500">
<div class="max-w-xl break-words">
{{ $row['oldName'] ?? $row['name'] ?? '' }}
</div>
</td>
<td class="px-6 py-4 text-sm">
@if(isset($row['newName']) && $row['newName'])
<div class="max-w-xl break-words font-semibold text-green-600">
{{ $row['newName'] }}
</div>
@else
<span class="text-gray-400"></span>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap text-center">
@if(isset($row['match']) && $row['match'])
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-800">
<i class="fa fa-check mr-1"></i>Match
</span>
@else
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-800">
<i class="fa fa-times mr-1"></i>No Match
</span>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="alert alert-success mt-3">
<i class="fa fa-check-circle me-2"></i>
Tested {{ count($data) }} releases. Review the matches above.
</div>
@else
<div class="alert alert-warning">
<i class="fa fa-exclamation-triangle me-2"></i>No releases found for the specified group or no matches found.
</div>
@endif
<!-- Success Summary -->
<div class="mt-6 p-4 bg-green-50 border border-green-200 rounded-lg">
<div class="flex">
<i class="fa fa-check-circle text-green-500 text-xl mr-3"></i>
<div>
<p class="text-green-800 font-medium">
Tested {{ count($data) }} releases
</p>
<p class="text-sm text-green-700 mt-1">
Review the matches above to verify your regex pattern is working correctly.
</p>
</div>
</div>
</div>
@else
<!-- No Results Warning -->
<div class="p-4 bg-yellow-50 border border-yellow-200 rounded-lg">
<div class="flex">
<i class="fa fa-exclamation-triangle text-yellow-500 text-xl mr-3"></i>
<div>
<p class="text-yellow-800 font-medium">No releases found</p>
<p class="text-sm text-yellow-700 mt-1">
No releases found for the specified group or no matches found. Try a different group or regex pattern.
</p>
</div>
</div>
</div>
@endif
</div>
@endif
</div>
</div>