Compare commits

...

7 Commits

Author SHA1 Message Date
lexx a482ab3c7e login urls 2025-03-20 21:06:40 +02:00
lexx c580882ec0 fix url 2025-03-20 20:57:47 +02:00
lexx 2cf8379cbe urls update 2025-03-20 20:53:51 +02:00
lexx c39ec469df files bug 2025-01-22 20:03:12 +02:00
lexx 232fcc8845 csv render title 2024-12-18 13:02:09 +02:00
lexx 9d5d4dd930 csv relations 2024-12-14 18:56:04 +02:00
lexx c507dc6031 upload fix 2024-10-23 19:34:41 +03:00
9 changed files with 58 additions and 22 deletions
+2 -1
View File
@@ -14,7 +14,8 @@
"intervention/image": "^2.7", "intervention/image": "^2.7",
"phpoption/phpoption": "^1.9", "phpoption/phpoption": "^1.9",
"spatie/image-optimizer": "^1.6", "spatie/image-optimizer": "^1.6",
"staudenmeir/laravel-cte": "^1.0" "staudenmeir/laravel-cte": "^1.0",
"mustache/mustache": "^2.14"
}, },
"require-dev": { "require-dev": {
Generated
+3 -3
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "71cf4c1de3d614ce2f9607763bf5687f", "content-hash": "e8fb1bee28ad339453d50110f7fea2f5",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
@@ -5729,8 +5729,8 @@
"ext-zip": "*", "ext-zip": "*",
"ext-sqlite3": "*", "ext-sqlite3": "*",
"ext-imagick": "*", "ext-imagick": "*",
"php": "^8.3", "ext-pdo": "*",
"ext-pdo": "*" "php": "^8.3"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.3.0"
+1 -1
View File
@@ -9,7 +9,7 @@
<div class="form"> <div class="form">
<h2 class="mb-5">Enter Lucent</h2> <h2 class="mb-5">Enter Lucent</h2>
<form hx-post="/lucent/login" > <form hx-post="{{url('lucent/login')}}" >
@csrf @csrf
<p>Submit your email address and you will receive a <b>login link</b> to your email</p> <p>Submit your email address and you will receive a <b>login link</b> to your email</p>
<p>Don't forget to check your spam folder</p> <p>Don't forget to check your spam folder</p>
+1 -1
View File
@@ -9,7 +9,7 @@
<div class="form"> <div class="form">
<h2 class="mb-5">Welcome to Lucent</h2> <h2 class="mb-5">Welcome to Lucent</h2>
<form hx-post="/lucent/verify" hx-redirect="/lucent" hx-target-error=".form-errors" > <form hx-post="{{url('lucent/verify')}}" hx-redirect="{{url('lucent')}}" hx-target-error=".form-errors" >
<input type="hidden" value="{{$email}}" name="email" /> <input type="hidden" value="{{$email}}" name="email" />
<input type="hidden" value="{{$token}}" name="token" /> <input type="hidden" value="{{$token}}" name="token" />
@csrf @csrf
+3 -3
View File
@@ -9,8 +9,8 @@
@if(config("lucent.env") === "production") @if(config("lucent.env") === "production")
<!-- if production --> <!-- if production -->
<link rel="stylesheet" href="/vendor/lucent/dist/{{ $manifest['main.js']["css"][0] }}"/> <link rel="stylesheet" href="{{url('vendor/lucent/dist/'.$manifest['main.js']["css"][0])}}"/>
<script type="module" src="/vendor/lucent/dist/{{ $manifest['main.js']["file"] }}"></script> <script type="module" src="{{url('vendor/lucent/dist/'.$manifest['main.js']["file"])}}"></script>
@else @else
<!-- if development --> <!-- if development -->
@php @php
@@ -20,7 +20,7 @@
@endif @endif
{{-- <link rel="icon" type="image/x-icon" href="/favicon.ico"/>--}} <link rel="icon" type="image/x-icon" href="{{url('favicon.ico')}}">
</head> </head>
+5 -7
View File
@@ -8,8 +8,8 @@
<title>@yield('title') - Lucent Data Platform</title> <title>@yield('title') - Lucent Data Platform</title>
@if(config("lucent.env") == "production") @if(config("lucent.env") == "production")
<!-- if production --> <!-- if production -->
<link rel="stylesheet" href="/vendor/lucent/dist/{{ $manifest['main.js']["css"][0] }}"/> <link rel="stylesheet" href="{{url('vendor/lucent/dist/'.$manifest['main.js']["css"][0])}}"/>
<script type="module" src="/vendor/lucent/dist/{{ $manifest['main.js']["file"] }}"></script> <script type="module" src="{{url('vendor/lucent/dist/'.$manifest['main.js']["file"])}}"></script>
@else @else
<!-- if development --> <!-- if development -->
@php @php
@@ -18,16 +18,14 @@
<script type="module" crossorigin src="http://127.0.0.1:5173/main.js"></script> <script type="module" crossorigin src="http://127.0.0.1:5173/main.js"></script>
@endif @endif
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link rel="icon" type="image/x-icon" href="{{url('favicon.ico')}}">
</head> </head>
<body> <body>
@yield('content') @yield('content')
</body> </body>
</html> </html>
+6 -2
View File
@@ -79,7 +79,10 @@ class FileService
throw new LucentException("File $filename not uploaded"); throw new LucentException("File $filename not uploaded");
} }
$this->createTemplates($disk, $path, $file); if($this->isImage($mimetype)){
$this->createTemplates($disk, $path);
}
list($width, $height) = $this->isImage($mimetype) ? getimagesize($file) : [0, 0]; list($width, $height) = $this->isImage($mimetype) ? getimagesize($file) : [0, 0];
$recordFile = new RecordFile( $recordFile = new RecordFile(
@@ -133,7 +136,8 @@ class FileService
{ {
$originalImage = $this->imageManager->make($disk->get($path)); $originalImage = $this->imageManager->make($disk->get($path));
foreach (config("lucent.imageFilters") as $preset => $filterClass) { foreach (config("lucent.imageFilters") as $preset => $filterClass) {
$image = $originalImage->filter(new $filterClass); $imageClone = clone $originalImage;
$image = $imageClone->filter(new $filterClass);
$templateUri = "/templates/" . $preset . "/" . $path; $templateUri = "/templates/" . $preset . "/" . $path;
$disk->put($templateUri, $image->encode('webp', 75)); $disk->put($templateUri, $image->encode('webp', 75));
} }
+36 -3
View File
@@ -17,8 +17,10 @@ use Lucent\Record\QueryRecord;
use Lucent\Record\RecordService; use Lucent\Record\RecordService;
use Lucent\Record\Status; use Lucent\Record\Status;
use Lucent\Schema\System; use Lucent\Schema\System;
use Lucent\Schema\Ui\Reference;
use Lucent\Schema\Validator\ValidatorException; use Lucent\Schema\Validator\ValidatorException;
use Lucent\Svelte\Svelte; use Lucent\Svelte\Svelte;
use Lucent\ViewModel\ViewModel;
use function Lucent\Response\fail; use function Lucent\Response\fail;
use function Lucent\Response\ok; use function Lucent\Response\ok;
@@ -31,7 +33,8 @@ class RecordController extends Controller
private readonly Svelte $svelte, private readonly Svelte $svelte,
private readonly Query $query, private readonly Query $query,
private readonly Manager $recordManager, private readonly Manager $recordManager,
private readonly OperatorRegistry $operatorRegistry private readonly OperatorRegistry $operatorRegistry,
private readonly ViewModel $viewModel,
) )
{ {
} }
@@ -134,18 +137,22 @@ class RecordController extends Controller
->filter($arguments) ->filter($arguments)
->limit(-1) ->limit(-1)
->status(explode(",", $arguments["status_in"])) ->status(explode(",", $arguments["status_in"]))
->childrenDepth(1)
// ->skip($skip) // ->skip($skip)
->sort($sort) ->sort($sort)
->run() ->run()
->records; ->tree();
header('Content-Type: application/csv'); header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="' . $schemaName . '.csv";'); header('Content-Disposition: attachment; filename="' . $schemaName . '.csv";');
$handle = fopen('php://output', 'w'); $handle = fopen('php://output', 'w');
$csvRow = ["id", ...array_keys($records[0]->data->toArray())]; $relationColumns = $this->makeCsvRelationColumns($schema);
$csvRow = ["id", ...array_keys($records[0]->data->toArray()),...$relationColumns];
fputcsv($handle, $csvRow, ','); fputcsv($handle, $csvRow, ',');
foreach ($records as $record) { foreach ($records as $record) {
$csvRow = [$record->id, ...$record->data->toArray()]; $csvRow = [$record->id, ...$record->data->toArray()];
$csvRow = array_merge($csvRow,$this->makeCsvRelationColumnValues($schema,$record->_children));
$csvRow = array_values($csvRow); $csvRow = array_values($csvRow);
fputcsv($handle, $csvRow, ','); fputcsv($handle, $csvRow, ',');
} }
@@ -154,6 +161,32 @@ class RecordController extends Controller
exit; exit;
} }
private function makeCsvRelationColumns($schema):array{
return $schema->fields->filter(fn($f) => get_class($f) === Reference::class)->reduce(function($c,$f){
$c[] = $f->name." id";
$c[] = $f->name." name";
return $c;
},[]);
}
private function makeCsvRelationColumnValues($schema, $children):array{
return $schema->fields->filter(fn($f) => get_class($f) === Reference::class)->reduce(function($c,$f) use($children){
$fieldRecords = data_get($children,$f->name);
if(empty($fieldRecords)){
$c[] = "";
$c[] = "";
}elseif (count($fieldRecords) === 1){
$c[] = data_get($fieldRecords,"0.id");
$c[] = $this->viewModel->getRecordName($fieldRecords[0]);
}else{
$c[] = collect($fieldRecords)->pluck("id")->join("::");
$c[] = collect($fieldRecords)->pluck("data.name")->join("::");
}
return $c;
},[]);
}
public function new(Request $request) public function new(Request $request)
{ {
if (!in_array($request->input("schema"), $this->accountService->currentWritableSchemas())) { if (!in_array($request->input("schema"), $this->accountService->currentWritableSchemas())) {
+1 -1
View File
@@ -21,7 +21,7 @@ class ViewModel
public function getRecordName(QueryRecord $record): string public function getRecordName(QueryRecord $record): string
{ {
$schema = $this->channelService->getSchema($record->schema)->get(); $schema = $this->channelService->getSchema($record->schema)->get();
if (empty($schema->titleTemplate)) { if (empty($schema->cardTitle)) {
$title = match (get_class($schema)) { $title = match (get_class($schema)) {
CollectionSchema::class => $record->data[$schema->fields->filter(fn(FieldInterface $f) => $f->info->name === "text")->first()->name], CollectionSchema::class => $record->data[$schema->fields->filter(fn(FieldInterface $f) => $f->info->name === "text")->first()->name],
FilesSchema::class => $record->_file->path, FilesSchema::class => $record->_file->path,