Compare commits

...

7 Commits

Author SHA1 Message Date
lexx a737c2d571 configurable disks 2024-08-23 20:58:45 +03:00
lexx c43c29eb14 modal save button 2024-08-23 19:37:20 +03:00
lexx 0c00f76657 fix tools and layhout 2024-08-23 18:15:18 +03:00
lexx 4165bfb95d build controller 2024-08-23 17:29:08 +03:00
lexx 570dbf747e channel 2024-08-23 17:23:43 +03:00
lexx 14cbd0a845 manifest fix 2024-08-23 17:15:40 +03:00
lexx c99634bb46 query 2024-08-23 16:54:33 +03:00
18 changed files with 117 additions and 113 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
{ {
"main.js": { "main.js": {
"file": "assets/main-B-nfEWyS.js", "file": "assets/main-BtcBvcC_.js",
"name": "main", "name": "main",
"src": "main.js", "src": "main.js",
"isEntry": true, "isEntry": true,
"css": [ "css": [
"assets/main-CaexgiEy.css" "assets/main-BWRwkaBb.css"
] ]
} }
} }
@@ -4,10 +4,10 @@
const channel = getContext("channel"); const channel = getContext("channel");
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
export let inModal; export let inModal;
export let modalUrl; export let modalUrl;
const url = new URL(modalUrl ?? window.location.href); const url = new URL(modalUrl ?? window.location.href);
function removeFilter(k) { function removeFilter(k) {
const url = new URL(modalUrl ?? window.location.href); const url = new URL(modalUrl ?? window.location.href);
+10 -9
View File
@@ -135,13 +135,13 @@
</div> </div>
{#if Object.entries(filter).length > 0} <div class="applied-filters">
<div class="applied-filters"> <AppliedFilterNotLinked
<AppliedFilterNotLinked {inModal}
{inModal} {modalUrl}
{modalUrl} on:refresh
on:refresh ></AppliedFilterNotLinked>
/> {#if Object.entries(filter).length > 0}
{#each Object.entries(filter) as [k, v]} {#each Object.entries(filter) as [k, v]}
<AppliedFilter <AppliedFilter
{schema} {schema}
@@ -154,6 +154,7 @@
on:refresh on:refresh
/> />
{/each} {/each}
</div> {/if}
{/if} </div>
@@ -100,9 +100,9 @@
<DialogRecord bind:this={dialogRecord}> <DialogRecord bind:this={dialogRecord}>
{#if inLineCreateRecord} {#if inLineCreateRecord}
<InlineEdit <InlineEdit
{...inLineCreateRecord} {...inLineCreateRecord}
isCreateMode={true}
on:cancel={(e) => (inLineCreateRecord = null)} on:cancel={(e) => (inLineCreateRecord = null)}
on:inlinesaved={save} on:inlinesaved={save}
/> />
+4 -2
View File
@@ -44,7 +44,7 @@
margin: 6px 0; margin: 6px 0;
border-color: transparent; border-color: transparent;
.button { .button:not(.primary) {
background: var(--p30); background: var(--p30);
&:hover { &:hover {
@@ -53,9 +53,10 @@
} }
dialog { dialog {
.button { .button:not(.primary) {
background: var(--p20); background: var(--p20);
&:hover { &:hover {
background: var(--p30); background: var(--p30);
} }
@@ -143,3 +144,4 @@
} }
} }
+1 -1
View File
@@ -19,7 +19,7 @@
background: var(--p20); background: var(--p20);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 3px; gap: 4px;
} }
.sidebar-header { .sidebar-header {
+1 -1
View File
@@ -9,7 +9,7 @@
@if(config("lucent.env") === "production") @if(config("lucent.env") === "production")
<!-- if production --> <!-- if production -->
<link rel="stylesheet" href="/vendor/lucent/dist/{{ $manifest['main.css']["file"] }}"/> <link rel="stylesheet" href="/vendor/lucent/dist/{{ $manifest['main.js']["css"][0] }}"/>
<script type="module" src="/vendor/lucent/dist/{{ $manifest['main.js']["file"] }}"></script> <script type="module" src="/vendor/lucent/dist/{{ $manifest['main.js']["file"] }}"></script>
@else @else
<!-- if development --> <!-- if development -->
+1 -1
View File
@@ -8,7 +8,7 @@
<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.css']["file"] }}"/> <link rel="stylesheet" href="/vendor/lucent/dist/{{ $manifest['main.js']["css"][0] }}"/>
<script type="module" src="/vendor/lucent/dist/{{ $manifest['main.js']["file"] }}"></script> <script type="module" src="/vendor/lucent/dist/{{ $manifest['main.js']["file"] }}"></script>
@else @else
<!-- if development --> <!-- if development -->
+1 -1
View File
@@ -10,7 +10,7 @@ export default defineConfig({
outDir: '../dist', outDir: '../dist',
emptyOutDir: true, emptyOutDir: true,
manifest: true, manifest: "manifest.json",
rollupOptions: { rollupOptions: {
// overwrite default .html entry // overwrite default .html entry
input: path.resolve(__dirname, 'js/main.js') input: path.resolve(__dirname, 'js/main.js')
+12 -2
View File
@@ -25,8 +25,18 @@ final class Channel
) )
{ {
$this->lucentUrl = $url . "/lucent"; $this->lucentUrl = $url . "/lucent";
$this->filesUrl = $url . "/storage"; $this->filesUrl = $this->makeFilesUrl();
$this->previewTargetUrl = $url . "/". $previewTarget; $this->previewTargetUrl = $url . "/" . $previewTarget;
}
private function makeFilesUrl(): string
{
return match (config("filesystems.disks.lucent.driver")) {
"s3" => config("filesystems.disks.lucent.endpoint") . "/" . config("filesystems.disks.lucent.bucket"),
"local" => $this->url . "/storage" . config("filesystems.disks.lucent.endpoint"),
};
} }
} }
+2 -1
View File
@@ -3,6 +3,7 @@
namespace Lucent\Channel; namespace Lucent\Channel;
use Lucent\File\FileService;
use Lucent\Primitive\Collection; use Lucent\Primitive\Collection;
use Lucent\Schema\Schema; use Lucent\Schema\Schema;
use Lucent\Schema\SchemaService; use Lucent\Schema\SchemaService;
@@ -13,7 +14,7 @@ final class ChannelService
public Channel $channel; public Channel $channel;
private function __construct( private function __construct(
public SchemaService $schemaService public SchemaService $schemaService,
) )
{ {
+10 -11
View File
@@ -14,7 +14,6 @@ use Lucent\LucentException;
use Lucent\Record\FileData as RecordFile; use Lucent\Record\FileData as RecordFile;
use Lucent\Record\QueryRecord; use Lucent\Record\QueryRecord;
use Lucent\Schema\FilesSchema; use Lucent\Schema\FilesSchema;
use Lucent\Schema\Schema;
use Spatie\ImageOptimizer\OptimizerChainFactory; use Spatie\ImageOptimizer\OptimizerChainFactory;
class FileService class FileService
@@ -28,7 +27,7 @@ class FileService
public function getPath(QueryRecord $file): string public function getPath(QueryRecord $file): string
{ {
return $this->channelService->channel->url . "/storage/" . $file->_file->path; return $this->channelService->channel->filesUrl . "/" . $file->_file->path;
} }
public function createFromUrl(FilesSchema $schema, string $url): FileUploadResult public function createFromUrl(FilesSchema $schema, string $url): FileUploadResult
@@ -111,15 +110,16 @@ class FileService
public function loadDisk(): Filesystem public function loadDisk(): Filesystem
{ {
return Storage::disk('lucent');
return Storage::build([ return Storage::build([
'driver' => 'local', 'driver' => 'lucent',
// 'key' => config("filesystems.disks.s3.key"), // 'key' => config("filesystems.disks.s3.key"),
// 'secret' => config("filesystems.disks.s3.secret"), // 'secret' => config("filesystems.disks.s3.secret"),
// 'region' => config("filesystems.disks.s3.region"), // 'region' => config("filesystems.disks.s3.region"),
// 'bucket' => config("filesystems.disks.s3.bucket"), // 'bucket' => config("filesystems.disks.s3.bucket"),
// // 'url' => $schema->objectStorageUrl, // // 'url' => $schema->objectStorageUrl,
// 'endpoint' => $schema->objectStorageEndpoint, // 'endpoint' => $schema->objectStorageEndpoint,
'use_path_style_endpoint' => false, // 'use_path_style_endpoint' => false,
'visibility' => 'public', // now managed by aws policy 'visibility' => 'public', // now managed by aws policy
'root' => storage_path('app/public'), 'root' => storage_path('app/public'),
'throw' => true, 'throw' => true,
@@ -140,12 +140,10 @@ class FileService
private function createThumbnail(Filesystem $disk, string $schemaPath, string $filename, UploadedFile $file): void private function createThumbnail(Filesystem $disk, string $schemaPath, string $filename, UploadedFile $file): void
{ {
$thumbDir = "thumbs/" . $schemaPath . "/";
// if (!file_exists($thumbDir)) {
$thumbDir = storage_path("app/public/thumbs/" . $schemaPath . "/"); // make_dir_r($thumbDir);
if (!file_exists($thumbDir)) { // }
make_dir_r($thumbDir);
}
try { try {
ImageManagerStatic::configure(['driver' => 'imagick']); ImageManagerStatic::configure(['driver' => 'imagick']);
@@ -157,7 +155,8 @@ class FileService
$image->fit(300, 300); $image->fit(300, 300);
try { try {
$image->encode('webp', 75)->save($thumbDir . $filename); $this->loadDisk()->put($thumbDir . $filename, $image->encode('webp', 75));
// $image->encode('webp', 75)->save($thumbDir . $filename);
} catch (Exception $e) { } catch (Exception $e) {
logger($e->getMessage()); logger($e->getMessage());
} }
+5 -20
View File
@@ -15,6 +15,7 @@ class ImageService
public function __construct( public function __construct(
public ImageManager $imageManager, public ImageManager $imageManager,
public FileService $fileService,
public ChannelService $channelService, public ChannelService $channelService,
public Logger $logger public Logger $logger
) )
@@ -50,28 +51,18 @@ class ImageService
private function createTemplate(string $originalPath, string $template): string private function createTemplate(string $originalPath, string $template): string
{ {
$originalFilePath = public_path("storage/" . $originalPath);
$templateUri = "/templates/" . $template . "/" . $originalPath;
$templateFilePath = public_path("storage/" . $templateUri);
if (!file_exists($originalFilePath)) {
return $this->notFoundImage;
}
if (!file_exists(pathinfo($templateFilePath, PATHINFO_DIRNAME))) {
$this->make_dir(pathinfo($templateFilePath, PATHINFO_DIRNAME));
}
try { try {
$image = $this->imageManager->make($originalFilePath); $image = $this->imageManager->make( $this->fileService->loadDisk()->get($originalPath));
} catch (Exception $e) { } catch (Exception $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());
return $this->notFoundImage; return $originalPath;
} }
$image = $image->filter(new $this->channelService->channel->imageFilters[$template]); $image = $image->filter(new $this->channelService->channel->imageFilters[$template]);
try { try {
$image = $this->imageManager->make((string)$image->encode('webp', 75)); $templateUri = "/templates/" . $template . "/" . $originalPath;
$image->save($templateFilePath); $this->fileService->loadDisk()->put($templateUri, $image->encode('webp', 75));
} catch (Exception $e) { } catch (Exception $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());
return $this->notFoundImage; return $this->notFoundImage;
@@ -80,10 +71,4 @@ class ImageService
return $templateUri; return $templateUri;
} }
private function make_dir(string $path): void
{
is_dir($path) || mkdir($path, 0777, true);
}
} }
+1 -1
View File
@@ -28,7 +28,7 @@ class BuildController extends Controller
unlink($buildLogFile); unlink($buildLogFile);
} }
exec("cd " . base_path() . " && php8.2 artisan {$this->channelService->channel->generateCommand} > " . $buildLogFile . " 2>&1 & echo $!", $op); exec("cd " . base_path() . " && php8.3 artisan {$this->channelService->channel->generateCommand} > " . $buildLogFile . " 2>&1 & echo $!", $op);
$pid = (int)$op[0]; $pid = (int)$op[0];
return redirect($this->channelService->channel->lucentUrl . "/build-report"); return redirect($this->channelService->channel->lucentUrl . "/build-report");
} }
+6
View File
@@ -261,6 +261,12 @@ final class Query
return $this; return $this;
} }
public function onlyPublished(): Query
{
$this->options->status = ["published"];
return $this;
}
public public
function orderByQuery(Builder $query): Builder function orderByQuery(Builder $query): Builder
{ {