Skip to content

Commit cbc6c93

Browse files
authored
Merge pull request #3 from Advaith3600/ui
UI Update
2 parents 71d279c + 1c322a7 commit cbc6c93

File tree

137 files changed

+3105
-1147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+3105
-1147
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ A seamless Django-like admin panel setup for Laravel. Simple, non-cms table mana
66
[![License](http://poser.pugx.org/advaith/seamless-admin/license)](https://packagist.org/packages/advaith/seamless-admin)
77
![Tests](https://github.com/advaith3600/seamless-admin/actions/workflows/run-tests.yml/badge.svg?branch=main)
88

9+
![Screenshot](Screenshot.png)
10+
911
Laravel versions `6.*`, `7.*`, `8.*`, `9.*`, `10.*`, `11.*` are supported. Please ensure that you have a minimum of PHP `8.0.2` installed.
1012

1113
## Installation steps
@@ -60,8 +62,6 @@ class Post extends Model
6062

6163
Et Voila! That's all you have to do to get started. Visit `/admin` to access the admin dashboard after logging in.
6264
63-
![Screenshot](Screenshot.png)
64-
6565
## Configuration
6666
6767
### `seamless-admin.php` config file
@@ -83,7 +83,7 @@ All the model specific configuration should go inside the respective model file.
8383
- `public bool $hasAdminPage`: Set this to `false` to prevent the model from showing up on the admin page. Advantage of
8484
using this instead of removing the trait from the model is when other models try to check for foreign keys this will
8585
be used as a hint to fetch other columns.
86-
- `public string $adminIcon`: We use [feathericons](https://feathericons.com/) as the icon provider. Type in the name of
86+
- `public string $adminIcon`: We use [lucide](https://lucide.dev/) for the icons. Type in the name of
8787
the icon you want to use.
8888
- `public string $adminGroup`: Add a value to change the group in which the model should be displayed in the sidebar.
8989
@@ -227,7 +227,7 @@ The `add` method takes 3 arguments:
227227
2. Alias for the route. This is the name that will be displayed in the sidebar of the admin page.
228228
3. An optional array which consists of
229229
- `isAllowed`: Whether the route is visible to the current user
230-
- `icon`: Icon to be displayed in the sidebar. We use [feathericons](https://feathericons.com)
230+
- `icon`: Icon to be displayed in the sidebar. We use [lucide](https://lucide.dev/) for icons
231231
- `group`: Group in sidebar to which the custom route should be added.
232232

233233
To fully utilize the custom page, extend the layout `seamless::layout` in your blade file. Exmaple:

Screenshot.png

347 KB
Loading

components.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://shadcn-vue.com/schema.json",
3+
"style": "default",
4+
"typescript": true,
5+
"tailwind": {
6+
"config": "tailwind.config.js",
7+
"css": "src/resources/assets/src/scss/app.scss",
8+
"baseColor": "slate",
9+
"cssVariables": true
10+
},
11+
"framework": "laravel",
12+
"aliases": {
13+
"components": "/src/resources/assets/components",
14+
"utils": "/src/resources/assets/lib/utils"
15+
}
16+
}

package.json

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
"name": "seamless-admin",
33
"version": "1.0.0",
44
"description": "A seamless django like admin panel setup for Laravel",
5+
"type": "module",
56
"scripts": {
6-
"dev": "npm run development",
7-
"development": "mix",
8-
"watch": "mix watch",
9-
"watch-poll": "mix watch -- --watch-options-poll=1000",
10-
"hot": "mix watch --hot",
11-
"prod": "npm run production",
12-
"production": "mix --production"
7+
"dev": "vite",
8+
"build": "vite build"
139
},
1410
"keywords": [
1511
"laravel",
@@ -18,14 +14,22 @@
1814
"author": "Advaith A J",
1915
"license": "MIT",
2016
"devDependencies": {
21-
"autoprefixer": "^10.4.4",
22-
"laravel-mix": "^6.0.49",
23-
"postcss": "^8.4.12",
24-
"resolve-url-loader": "^5.0.0",
25-
"sass": "^1.67.0",
26-
"sass-loader": "^12.6.0",
27-
"tailwindcss": "^3.0.23",
28-
"vue": "^3.2.31",
29-
"vue-loader": "^16.2.0"
17+
"@tanstack/vue-table": "^8.13.2",
18+
"@vitejs/plugin-vue": "^5.0.4",
19+
"@vueuse/core": "^10.9.0",
20+
"autoprefixer": "^10.4.18",
21+
"class-variance-authority": "^0.7.0",
22+
"clsx": "^2.1.0",
23+
"laravel-vite-plugin": "^1.0.2",
24+
"lucide-vue-next": "^0.344.0",
25+
"postcss": "^8.4.35",
26+
"radix-vue": "^1.4.9",
27+
"sass": "^1.71.1",
28+
"tailwind-merge": "^2.2.1",
29+
"tailwindcss": "^3.4.1",
30+
"tailwindcss-animate": "^1.0.7",
31+
"typescript": "^5.3.3",
32+
"vite": "^5.1.4",
33+
"vue": "^3.4.21"
3034
}
3135
}

postcss.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module.exports = {
2-
plugins: [
3-
require('tailwindcss'),
4-
require('autoprefixer'),
5-
]
1+
export default {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {}
5+
}
66
}

src/ModelResolver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ public function getForeignKeys(string $type): array
265265

266266
if ($conn == 'mysql') {
267267
return DB::select(
268-
'SELECT column_name, referenced_table_name, referenced_column_name
268+
'SELECT
269+
column_name as column_name,
270+
referenced_table_name as referenced_table_name,
271+
referenced_column_name as referenced_column_name
269272
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
270273
WHERE (
271274
REFERENCED_TABLE_SCHEMA = ? AND

src/SeamlessAdminServiceProvider.php

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Advaith\SeamlessAdmin\Console\ClearCache;
66
use Illuminate\Support\ServiceProvider;
7+
use Illuminate\Support\Facades\Blade;
78

89
class SeamlessAdminServiceProvider extends ServiceProvider
910
{
@@ -15,8 +16,8 @@ class SeamlessAdminServiceProvider extends ServiceProvider
1516
public function register(): void
1617
{
1718
// registering services in the container
18-
$this->app->singleton('modelResolver', fn($app) => new ModelResolver());
19-
$this->app->singleton('seamlessAdmin', fn($app) => new SeamlessAdmin());
19+
$this->app->singleton('modelResolver', fn() => new ModelResolver());
20+
$this->app->singleton('seamlessAdmin', fn() => new SeamlessAdmin());
2021

2122
// registering routes
2223
$this->mergeConfigFrom(__DIR__ . '/config/config.php', 'seamless-admin');
@@ -34,8 +35,7 @@ public function boot()
3435
if ($this->app->runningInConsole()) {
3536
// publishing public assets
3637
$this->publishes([
37-
__DIR__ . '/resources/assets/css' => public_path('seamless-admin/css'),
38-
__DIR__ . '/resources/assets/js' => public_path('seamless-admin/js')
38+
__DIR__ . '/assets' => public_path('seamless-admin'),
3939
], 'seamless-admin-assets');
4040

4141
// publishing config file
@@ -46,5 +46,39 @@ public function boot()
4646
// registering console commands
4747
$this->commands([ClearCache::class]);
4848
}
49+
50+
$this->bootDirectives();
51+
}
52+
53+
private function bootDirectives()
54+
{
55+
Blade::directive('saSafeVite', function ($url) {
56+
$url = substr($url, 1, -1);
57+
$vite = \Illuminate\Foundation\Vite::class;
58+
if ($this->app->has($vite)) {
59+
return $this->app->make($vite)($url, 'seamless-admin');
60+
}
61+
62+
$manifest = json_decode(file_get_contents(__DIR__ . "/assets/manifest.json"), true);
63+
$scripts = "";
64+
65+
if (isset($manifest[$url]['imports'])) {
66+
foreach ($manifest[$url]['imports'] as $preload) {
67+
$location = asset("seamless-admin/" . $manifest[$preload]['file']);
68+
$scripts .= "<link rel=\"modulepreload\" href=\"{$location}\" />\n";
69+
}
70+
}
71+
72+
$location = asset("seamless-admin/" . $manifest[$url]['file']);
73+
if (strpos($url, 'css') !== false) {
74+
$scripts .= "<link rel=\"preload\" href=\"{$location}\" as=\"style\" />\n";
75+
$scripts .= "<link rel=\"stylesheet\" href=\"{$location}\" />";
76+
} else {
77+
$scripts .= "<link rel=\"modulepreload\" href=\"{$location}\" />\n";
78+
$scripts .= "<script type=\"module\" src=\"{$location}\"></script>";
79+
}
80+
81+
return $scripts;
82+
});
4983
}
5084
}

src/Traits/SeamlessAdmin.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44

55
trait SeamlessAdmin
66
{
7+
/**
8+
* Whether the key name should be visible for admins
9+
* Default: true
10+
*/
11+
public bool $keyNameVisibleForAdmins = true;
12+
713
/**
814
* Determines the information shown on the index page of the model listing
915
*
1016
* @return array
1117
*/
1218
public function adminIndexFields(): array
1319
{
14-
return array_diff($this->getFillable(), $this->getHidden());
20+
$fillable = $this->getFillable();
21+
if ($this->keyNameVisibleForAdmins && !in_array($this->getKeyName(), $fillable)) {
22+
array_unshift($fillable, $this->getKeyName());
23+
}
24+
25+
return array_diff($fillable, $this->getHidden());
1526
}
1627

1728
/**

src/assets/assets/DropdownMenuItem.vue_vue_type_script_setup_true_lang-CAWRjkcO.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/assets/app-BPfpuD7S.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)