fedi-feed-router/resources/views/pages/routing/create.blade.php

127 lines
7.3 KiB
PHP
Raw Normal View History

2025-07-05 18:26:04 +02:00
@extends('layouts.app')
@section('content')
<div class="max-w-2xl mx-auto py-6 sm:px-6 lg:px-8">
<div class="px-4 py-6 sm:px-0">
<div class="mb-6">
<h1 class="text-2xl font-semibold text-gray-900">Create Feed Routing</h1>
<p class="mt-1 text-sm text-gray-600">Route a feed to one or more channels.</p>
</div>
<div class="bg-white shadow sm:rounded-lg">
<form action="{{ route('routing.store') }}" method="POST" class="px-4 py-5 sm:p-6">
@csrf
<div class="grid grid-cols-1 gap-6">
<div>
<label for="feed_id" class="block text-sm font-medium text-gray-700">Feed</label>
<select name="feed_id"
id="feed_id"
class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm @error('feed_id') border-red-300 @enderror">
<option value="">Select a feed...</option>
@foreach($feeds as $feed)
<option value="{{ $feed->id }}" {{ old('feed_id') == $feed->id ? 'selected' : '' }}>
{{ $feed->name }} ({{ $feed->type_display }})
</option>
@endforeach
</select>
@error('feed_id')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-3">Target Channels</label>
<div class="space-y-2 max-h-64 overflow-y-auto border border-gray-200 rounded-md p-3">
@forelse($channels as $channel)
<div class="flex items-center">
<input type="checkbox"
name="channel_ids[]"
value="{{ $channel->id }}"
id="channel_{{ $channel->id }}"
{{ in_array($channel->id, old('channel_ids', [])) ? 'checked' : '' }}
class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
<label for="channel_{{ $channel->id }}" class="ml-2 block text-sm text-gray-900">
<span class="font-medium">{{ $channel->name }}</span>
<span class="text-gray-500">({{ $channel->platformInstance->name }})</span>
</label>
</div>
@empty
<p class="text-sm text-gray-500">No active channels available. Please create channels first.</p>
@endforelse
</div>
@error('channel_ids')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
@error('channel_ids.*')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="priority" class="block text-sm font-medium text-gray-700">Priority</label>
<input type="number"
name="priority"
id="priority"
min="0"
max="100"
value="{{ old('priority', 0) }}"
class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm @error('priority') border-red-300 @enderror"
placeholder="0">
<p class="mt-1 text-sm text-gray-500">Higher numbers = higher priority (0-100)</p>
@error('priority')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="filters" class="block text-sm font-medium text-gray-700">Filters (Optional)</label>
<textarea name="filters"
id="filters"
rows="4"
class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm @error('filters') border-red-300 @enderror"
placeholder='{"keywords": ["technology", "AI"], "exclude_keywords": ["sports"]}'>{{ old('filters') }}</textarea>
<p class="mt-1 text-sm text-gray-500">JSON format for content filtering rules</p>
@error('filters')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
</div>
<div class="mt-6 flex items-center justify-end space-x-3">
<a href="{{ route('routing.index') }}" class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Cancel
</a>
<button type="submit" class="bg-indigo-600 py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Create Routing
</button>
</div>
</form>
</div>
@if($feeds->isEmpty() || $channels->isEmpty())
<div class="mt-6 bg-yellow-50 border border-yellow-200 rounded-md p-4">
<div class="flex">
<div class="flex-shrink-0">
<i class="fas fa-exclamation-triangle text-yellow-400"></i>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-yellow-800">Prerequisites Missing</h3>
<div class="mt-2 text-sm text-yellow-700">
<p>To create routing, you need:</p>
<ul class="list-disc list-inside mt-1">
@if($feeds->isEmpty())
<li>At least one active <a href="{{ route('feeds.create') }}" class="underline">feed</a></li>
@endif
@if($channels->isEmpty())
<li>At least one active <a href="{{ route('channels.create') }}" class="underline">channel</a></li>
@endif
</ul>
</div>
</div>
</div>
</div>
@endif
</div>
</div>
@endsection