Skip to content

Commit

Permalink
User Device V0.0.3 (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrolli authored Apr 24, 2024
1 parent cc3d3ca commit 729daa0
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/user-device/resources/lang/de/translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
'navigation_label' => 'User Device',
'navigation_group' => 'Moox User',
'created_at' => 'Created at',
'active' => 'active',
'active' => 'Active',
];
9 changes: 8 additions & 1 deletion packages/user-device/resources/lang/en/translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
'title' => 'Device',
'navigation_label' => 'User Device',
'navigation_group' => 'Moox User',
'totalone' => 'Devices',
'totaltwo' => 'Users',
'totalthree' => 'Active',
'created_at' => 'Created at',
'active' => 'active',
'updated_at' => 'Last login',
'active' => 'Active',
'user_type' => 'Model',
'username' => 'Username',
'slug' => 'Slug',
];
46 changes: 34 additions & 12 deletions packages/user-device/src/Resources/UserDeviceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
use Filament\Forms\Set;
use Filament\Resources\Resource;
use Filament\Tables\Actions\DeleteBulkAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Support\Facades\Config;
use Moox\UserDevice\Models\UserDevice;
use Moox\UserDevice\Resources\UserDeviceResource\Pages\ListPage;
use Moox\UserDevice\Resources\UserDeviceResource\Pages\ViewPage;
use Moox\UserDevice\Resources\UserDeviceResource\Widgets\UserDeviceWidgets;

class UserDeviceResource extends Resource
Expand All @@ -29,7 +31,12 @@ public static function form(Form $form): Form
return $form
->schema([
TextInput::make('title')
->label(__('user-device::translations.title'))
->maxLength(255),
TextInput::make('slug')
->label(__('user-device::translations.slug'))
->maxLength(255),
DateTimePicker::make('updated_at'),
DateTimePicker::make('created_at'),

Select::make('user_type')
Expand Down Expand Up @@ -64,29 +71,43 @@ public static function table(Table $table): Table
{
return $table
->columns([
IconColumn::make('platform')
->label('')
->icon(function ($record) {
switch ($record->platform) {
case 'Mobile':
return 'heroicon-o-device-mobile';
case 'Desktop':
return 'heroicon-o-computer-desktop';
default:
return 'heroicon-o-computer-desktop';
}
}),
TextColumn::make('title')
->label(__('user-device::translations.title'))
->sortable(),
TextColumn::make('created_at')
->label(__('user-device::translations.created_at'))
->since()
->sortable(),
TextColumn::make('active')
->label(__('user-device::translations.active'))
->sortable(),
TextColumn::make('user_type')
->label(__('user-device::translations.user_type'))
->sortable(),
TextColumn::make('user_id')
->label(__('user-device::translations.username'))
->getStateUsing(function ($record) {
return optional($record->user)->name ?? 'unknown';
})
->sortable(),
IconColumn::make('active')
->label(__('user-device::translations.active'))
->toggleable()
->boolean(),
TextColumn::make('updated_at')
->label(__('user-device::translations.updated_at'))
->since()
->sortable(),
TextColumn::make('created_at')
->label(__('user-device::translations.created_at'))
->since()
->sortable(),
])
->defaultSort('title', 'desc')
->actions([
EditAction::make(),
ViewAction::make(),
])
->bulkActions([
DeleteBulkAction::make(),
Expand All @@ -104,6 +125,7 @@ public static function getPages(): array
{
return [
'index' => ListPage::route('/'),
//'view' => ViewPage::route('/{record}'),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Moox\UserDevice\Resources\UserDeviceResource\Pages;

use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Moox\UserDevice\Models\UserDevice;
use Moox\UserDevice\Resources\UserDeviceResource;
use Moox\UserDevice\Resources\UserDeviceResource\Widgets\UserDeviceWidgets;

Expand Down Expand Up @@ -32,10 +30,7 @@ public function getTitle(): string
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->using(function (array $data, string $model): UserDevice {
return $model::create($data);
}),
// none by now
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Moox\UserDevice\Resources\UserDeviceResource\Pages;

use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\ViewRecord;
use Moox\UserDevice\Resources\UserDeviceResource;

class ViewPage extends ViewRecord
{
protected static string $resource = UserDeviceResource::class;

protected function getHeaderActions(): array
{
return [DeleteAction::make()];
}
}
1 change: 0 additions & 1 deletion public/build/assets/app-CeNvSt55.css

This file was deleted.

1 change: 1 addition & 0 deletions public/build/assets/app-DbPkHKf7.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resources/css/app.css": {
"file": "assets/app-CeNvSt55.css",
"file": "assets/app-DbPkHKf7.css",
"src": "resources/css/app.css",
"isEntry": true
},
Expand Down

0 comments on commit 729daa0

Please sign in to comment.