Archived
1
0
Fork 0

Merge branch 'admin'

This commit is contained in:
Henrik Hautakoski 2022-01-09 14:12:09 +01:00
commit a061c8b713
51 changed files with 1612 additions and 21 deletions

View file

@ -0,0 +1,20 @@
<x-layout name="admin">
@livewire('datatable', [
'model' => \App\Models\Admin::class,
'default_sort' => 'id',
'columns' => [
'id' => '#',
'username' => 'Username',
'created_at' => 'Created',
'updated_at' => 'Updated',
],
'sort_columns' => [
'id' => 'id',
'username' => 'username',
'created_at' => 'created_at',
'updated_at' => 'updated_at'
]
])
</x-layout>

View file

@ -0,0 +1,25 @@
<x-layout name="admin">
<div class="mb-4">
<x-button href="{{ route('admin.card.create') }}" type="info">{{ __('New') }}</x-button>
</div>
@livewire('datatable', [
'model' => \App\Models\Card::class,
'default_sort' => 'id',
'route_edit' => 'admin.card.edit',
'route_delete' => 'admin.card.delete',
'columns' => [
'id' => '#',
'body' => 'Body',
'subject' => 'Subject',
'subject_type' => 'Subject Type',
'raid.name' => 'Raid',
],
'sort_columns' => [
'id' => 'id',
'body' => 'body',
]
])
</x-layout>

View file

@ -0,0 +1,22 @@
<x-layout name="admin">
<div class="mb-4">
<x-button href="{{ route('admin.character.create') }}" type="info">{{ __('New') }}</x-button>
</div>
@livewire('datatable', [
'model' => \App\Models\Character::class,
'default_sort' => 'id',
'route_edit' => 'admin.character.edit',
'route_delete' => 'admin.character.delete',
'columns' => [
'id' => '#',
'name' => 'Name',
],
'sort_columns' => [
'id' => 'id',
'name' => 'name',
]
])
</x-layout>

View file

@ -0,0 +1,22 @@
<x-layout name="admin">
<div class="mb-4">
<x-button href="{{ route('admin.raid.create') }}" type="info">{{ __('New') }}</x-button>
</div>
@livewire('datatable', [
'model' => \App\Models\Raid::class,
'default_sort' => 'id',
'route_edit' => 'admin.raid.edit',
'route_delete' => 'admin.raid.delete',
'columns' => [
'id' => '#',
'name' => 'Name',
],
'sort_columns' => [
'id' => 'id',
'name' => 'name',
]
])
</x-layout>

View file

@ -0,0 +1,3 @@
<x-layout name="auth">
@livewire('form.login-form')
</x-layout>

View file

@ -1,4 +1,4 @@
@props(['href' => false, 'type' => 'default'])
@props(['href' => false, 'type' => 'default', 'element' => false])
@php
@ -22,6 +22,8 @@ default:
if ($href) {
$element = 'a';
$attributes = $attributes->merge([ 'href' => $href ]);
} else if ($element == 'input') {
$attributes = $attributes->merge([ 'type' => 'submit' ]);
} else {
$element = 'button';
}

View file

@ -0,0 +1 @@
<h2 {!! $attributes->merge(["class" => "text-2xl"]) !!}>{{ $slot }}</h2>

View file

@ -0,0 +1,27 @@
@props(['variant' => 'info', 'delay' => 2000])
@php
switch($variant) {
case 'success':
$variant_classes = 'text-green-800 bg-green-200 border-green-300';
break;
case 'warning':
$variant_classes = 'text-yellow-800 bg-yellow-200 border-yellow-300';
break;
case 'danger':
$variant_classes = 'text-red-800 bg-red-200 border-red-300';
break;
case 'info':
default:
$variant_classes = 'text-blue-800 bg-blue-200 border-blue-300';
}
@endphp
<div x-data="{ show: true }"
x-show="show"
x-init="setTimeout(() => show = false, {{ $delay }})"
{!! $attributes->merge(['class' => "w-full px-4 py-2 rounded border $variant_classes"]) !!}>
{{ $slot }}
</div>

View file

@ -0,0 +1,5 @@
@props(['name', 'column', 'dir'])
@if ($name === $column)
<x-icon name="{{ $dir == 'asc' ? 'heroicon-s-sort-ascending' : 'heroicon-s-sort-descending' }}" {{ $attributes->only('class') }} />
@endif

View file

@ -0,0 +1,32 @@
<div class="space-y-4">
<x-header>{{ __(($this->isNew() ? 'Create' : 'Edit') . ' card') }}</x-header>
<form class="space-y-4" wire:submit.prevent="submit">
<div>
<x-ignite-label for="record.body">{{ __('Body') }}</x-ignite-label>
<x-ignite-input name="record.body" wire:model="record.body" />
</div>
<div class="grid grid-cols-3 space-x-4">
<div>
<x-ignite-label for="record.raid_id">{{ __('Raid') }}</x-ignite-label>
<x-ignite-select name="record.raid_id" wire:model="record.raid_id" :options="$raids" placeholder="{{ __('Select a raid') }}" />
</div>
<div>
<x-ignite-label for="record.character_id">{{ __('Character') }}</x-ignite-label>
<x-ignite-select name="record.character_id" wire:model="record.character_id" :options="$characters" placeholder="{{ __('Select a character') }}" />
</div>
<div>
<x-ignite-label for="record.class">{{ __('Class') }}</x-ignite-label>
<x-ignite-select name="record.class" wire:model="record.class" :options="$classes" placeholder="{{ __('Select a class') }}" />
</div>
</div>
<x-button type="info">{{ __('Save') }}</x-button>
<x-button href="{{ route('admin.card.index') }}" type="warning">{{ __('Back') }}</x-button>
</form>
</div>

View file

@ -0,0 +1,17 @@
<div class="space-y-4">
<x-header>{{ __(($this->isNew() ? 'Create' : 'Edit') . ' character') }}</x-header>
<form class="space-y-4" wire:submit.prevent="submit">
<div>
<x-ignite-label for="record.name">{{ __('Name') }}</x-ignite-label>
<x-ignite-input name="record.name" wire:model="record.name" />
</div>
<x-button type="info">{{ __('Save') }}</x-button>
<x-button href="{{ route('admin.character.index') }}" type="warning">{{ __('Back') }}</x-button>
</form>
</div>

View file

@ -0,0 +1,17 @@
<form class="space-y-4" wire:submit.prevent="submit">
@if (Session::has('message'))
<p class="text-center text-red-400">{{ Session::get('message') }}</p>
@endif
<div>
<x-ignite-label class="sr-only" for="username">Username</x-ignite-label>
<x-ignite-input name="username" wire:model="username" placeholder="Username" class="" />
</div>
<div>
<label class="sr-only" for="password">Password</label>
<x-ignite-input name="password" wire:model="password" type="password" placeholder="Password" />
</div>
<x-button element="input" wire:click="submit" class="w-full" type="info" value="Login" />
</form>

View file

@ -0,0 +1,17 @@
<div class="space-y-4">
<x-header>{{ __(($this->isNew() ? 'Create' : 'Edit') . ' raid') }}</x-header>
<form class="space-y-4" wire:submit.prevent="submit">
<div>
<x-ignite-label for="record.name">{{ __('Name') }}</x-ignite-label>
<x-ignite-input name="record.name" wire:model="record.name" />
</div>
<x-button type="info">{{ __('Save') }}</x-button>
<x-button href="{{ route('admin.raid.index') }}" type="warning">{{ __('Back') }}</x-button>
</form>
</div>

View file

@ -0,0 +1,37 @@
@php
$item_classes = "flex items-center inline-block w-full px-4 py-2 rounded-lg hover:bg-blue-800";
@endphp
<x-layout>
<div class="flex min-h-screen">
<div class="bg-gray-800 w-2/12 px-4 divide-y divide-gray-600">
<ul class="py-4 space-y-2 text-white">
<li><a class="{{ $item_classes }}" href="{{ url('/admin') }}"><x-heroicon-o-user-group class="h-8 mr-2"/> {{ __('Admins') }}</a></li>
</ul>
<ul class="py-4 space-y-2 text-white">
<li><a class="{{ $item_classes }}" href="{{ url('/admin/cards') }}"><x-heroicon-o-collection class="h-8 mr-2"/> {{ __('Cards') }}</a></li>
<li><a class="{{ $item_classes }}" href="{{ url('/admin/characters') }}"><x-heroicon-o-identification class="h-8 mr-2"/> {{ __('Characters') }}</a></li>
<li><a class="{{ $item_classes }}" href="{{ url('/admin/raids') }}"><x-heroicon-o-globe class="h-8 mr-2"/> {{ __('Raids') }}</a></li>
</ul>
<ul class="py-4 space-y-2 text-white">
<x-ignite-form action="{{ url('/admin/logout') }}">
<li>
<a class="{{ $item_classes }}" href="#" onclick="event.preventDefault();this.closest('form').submit();">
<x-heroicon-o-logout class="h-8 mr-2"/> {{ __('Logout') }}
</a>
</li>
</x-ignite-form>
</ul>
</div>
<div class="w-10/12 m-8">
{{ $slot }}
</div>
</div>
</x-layout>

View file

@ -6,11 +6,15 @@
<title>Bingo!</title>
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
@livewireStyles
<script defer src="https://unpkg.com/alpinejs@3.2.4/dist/cdn.min.js"></script>
</head>
<body>
<body class="h-full">
<livewire:alert-container />
{{ $slot }}
@livewireScripts
@igniteScripts
</body>
</html>

View file

@ -0,0 +1,5 @@
<x-layout>
<div class="w-96 mx-auto mt-28 p-4 bg-blue-100 border border-blue-200 rounded">
{{ $slot }}
</div>
</x-layout>

View file

@ -0,0 +1,5 @@
<div class="absolute z-50 top-0 w-full px-4 sm:px-8 space-y-2 mt-2">
@foreach($messages as $message)
<x-notification variant="{{ $message[0] }}">{{ $message[1] }}</x-notification>
@endforeach
</div>

View file

@ -0,0 +1,59 @@
<div>
<table class="table-auto w-full">
<tr class="text-left border-b-2">
@foreach($columns as $key => $name)
<th class="border px-6 py-3 w-24">
@if (isset($sort_columns[$key]))
<div class="flex items-center justify-between cursor-pointer" wire:click="sort('{{ $key }}')">
<span class="hover:underline">{{ __($name) }}</span>
<x-sort-link name="{{ $key }}" :column="$sort" :dir="$dir" class="ml-2 text-gray-600 h-5" />
</div>
@else
{{ $name }}
@endif
</th>
@endforeach
@if($route_delete || $route_edit)
<th class="border px-6 py-3 w-4">{{ __('Actions') }}</th>
@endif
</tr>
<tbody>
@foreach($items as $item)
<tr class="odd:bg-gray-50">
@foreach(array_keys($columns) as $key)
<td class="border px-4 py-2">{{ Arr::get($item, $key) }}</td>
@endforeach
@if ($route_edit || $route_delete)
<td class="border px-4 py-2">
@if($route_edit)
<a href="{{ route($route_edit, [ $item ]) }}">
<x-icon name="heroicon-o-pencil" class="inline-block w-6 text-yellow-500"/>
</a>
@endif
@if($route_delete)
<x-ignite-form class="inline-block" id="dt-delete-{{$_instance->id}}-{{ $item->id }}" method="DELETE" action="{{ route($route_delete, [ $item ]) }}">
<a href="javascript:document.getElementById('dt-delete-{{$_instance->id}}-{{ $item->id }}').submit();">
<x-icon name="heroicon-o-trash" class="inline-block w-6 text-red-500"/>
</a>
</x-ignite-form>
@endif
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
@if ($items->hasPages())
<div class="mt-4">
{{ $items->links() }}
</div>
@endif
</div>