schema index
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||||
import { post } from "../../modules/remote";
|
import { post } from "../../modules/remote";
|
||||||
import { getApp } from "../../app";
|
import { getApp } from "../../app";
|
||||||
let { channel, user, data, newRank } = $props();
|
let { channel, user, data, newRank } = $props();
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||||
{#snippet body()}
|
{#snippet body()}
|
||||||
<h3 class="header-small mb-4 mt-5">Create a <em>{data.type}</em> field</h3>
|
<h3 class="header-small mb-4 mt-5">Create a <em>{data.type}</em> field</h3>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||||
import TextFieldProps from "./TextFieldProps.svelte";
|
import TextFieldProps from "./TextFieldProps.svelte";
|
||||||
import DeleteButton from "../../common/DeleteButton.svelte";
|
import DeleteButton from "../../common/DeleteButton.svelte";
|
||||||
import { post } from "../../modules/remote";
|
import { post } from "../../modules/remote";
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||||
{#snippet body()}
|
{#snippet body()}
|
||||||
<h3 class="header-small mb-4 mt-5">
|
<h3 class="header-small mb-4 mt-5">
|
||||||
Edit <em>{data.field.type}</em> field {data.field.name}
|
Edit <em>{data.field.type}</em> field {data.field.name}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import RecordRow from "./RecordRow.svelte";
|
import RecordRow from "./RecordRow.svelte";
|
||||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
||||||
import { get } from "../../modules/remote";
|
import { get } from "../../modules/remote";
|
||||||
let { channel, user } = $props();
|
let { channel, user, data } = $props();
|
||||||
let records = $state([]);
|
let records = $state([]);
|
||||||
let graph = $state(null);
|
let graph = $state(null);
|
||||||
let users = $state([]);
|
let users = $state([]);
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
<ChannelLayout {body} {channel} schemas={data.schemas} {user}></ChannelLayout>
|
||||||
{#snippet body()}
|
{#snippet body()}
|
||||||
<h3 class="header-small mb-4 mt-5">Latest Content changes</h3>
|
<h3 class="header-small mb-4 mt-5">Latest Content changes</h3>
|
||||||
{#if records.length > 0}
|
{#if records.length > 0}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||||
import Sortable from "../../common/Sortable.svelte";
|
import Sortable from "../../common/Sortable.svelte";
|
||||||
import DeleteButton from "../../common/DeleteButton.svelte";
|
import DeleteButton from "../../common/DeleteButton.svelte";
|
||||||
import { post } from "../../modules/remote";
|
import { post } from "../../modules/remote";
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||||
{#snippet body()}
|
{#snippet body()}
|
||||||
<h3>Edit Schema</h3>
|
<h3>Edit Schema</h3>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||||
import Sortable from "../../common/Sortable.svelte";
|
import Sortable from "../../common/Sortable.svelte";
|
||||||
import { post } from "../../modules/remote";
|
import { post } from "../../modules/remote";
|
||||||
import { getApp } from "../../app";
|
import { getApp } from "../../app";
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||||
{#snippet body()}
|
{#snippet body()}
|
||||||
<h3 class="header-small mb-4 mt-5">Schemas</h3>
|
<h3 class="header-small mb-4 mt-5">Schemas</h3>
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<script>
|
<script>
|
||||||
import Header from "./Header.svelte";
|
import Header from "./Header.svelte";
|
||||||
import Navbar from "./Navbar.svelte";
|
import Navbar from "./Navbar.svelte";
|
||||||
let { body, channel, user } = $props();
|
let { body, channel, user, schemas } = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header {channel} {user}></Header>
|
<Header {channel} {user}></Header>
|
||||||
<main>
|
<main>
|
||||||
<aside class="sidebar-content">
|
<aside class="sidebar-content">
|
||||||
<Navbar {channel}></Navbar>
|
<Navbar {channel} {schemas}></Navbar>
|
||||||
</aside>
|
</aside>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
{@render body()}
|
{@render body()}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<div class="top-nav">
|
<div class="top-nav">
|
||||||
<a class="top-nav-item" href="{channel.lucentUrl}/members">Members</a>
|
<a class="top-nav-item" href="{channel.lucentUrl}/members">Members</a>
|
||||||
|
<a class="top-nav-item" href="{channel.lucentUrl}/">Content</a>
|
||||||
<a class="top-nav-item" href="{channel.lucentUrl}/schemas">Schemas</a>
|
<a class="top-nav-item" href="{channel.lucentUrl}/schemas">Schemas</a>
|
||||||
|
|
||||||
<!-- {#if channel.commands.length > 0}
|
<!-- {#if channel.commands.length > 0}
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
<script>
|
<script>
|
||||||
let { channel } = $props();
|
import { getApp } from "../app";
|
||||||
|
let { channel, schemas } = $props();
|
||||||
|
const app = getApp();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<details name="example" open>
|
||||||
|
<summary>Content</summary>
|
||||||
|
{#each schemas as schema}
|
||||||
|
<div><a href={app.url("content/" + schema.id)}>{schema.name}</a></div>
|
||||||
|
{/each}
|
||||||
|
</details>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
import Header from "./Header.svelte";
|
||||||
|
let { body, channel, user } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Header {channel} {user}></Header>
|
||||||
|
<main>
|
||||||
|
<div class="main-content">
|
||||||
|
{@render body()}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
@@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
namespace Lucent\Http\Controller;
|
namespace Lucent\Http\Controller;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Lucent\Account\AccountService;
|
use Lucent\Account\AccountService;
|
||||||
|
use Lucent\Core\Repository\SchemaRepo;
|
||||||
use Lucent\Query\Query;
|
use Lucent\Query\Query;
|
||||||
use Lucent\Svelte\Svelte;
|
use Lucent\Svelte\Svelte;
|
||||||
use function Lucent\Response\ok;
|
use function Lucent\Response\ok;
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly AccountService $accountService,
|
private readonly AccountService $accountService,
|
||||||
@@ -20,7 +20,11 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
public function home()
|
public function home()
|
||||||
{
|
{
|
||||||
return Svelte::view("homeIndex", "Records", []);
|
$schemas = SchemaRepo::all();
|
||||||
|
|
||||||
|
return Svelte::view("homeIndex", "Records", [
|
||||||
|
"schemas" => $schemas,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function records(Request $request): Response
|
public function records(Request $request): Response
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace Lucent\Http\Controller;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Lucent\Account\AccountService;
|
use Lucent\Account\AccountService;
|
||||||
use Lucent\Account\AuthService;
|
|
||||||
use Lucent\Channel\ChannelService;
|
use Lucent\Channel\ChannelService;
|
||||||
use Lucent\LucentException;
|
use Lucent\LucentException;
|
||||||
use Lucent\Query\Operator\OperatorRegistry;
|
use Lucent\Query\Operator\OperatorRegistry;
|
||||||
@@ -24,7 +23,7 @@ use Lucent\ViewModel\ViewModel;
|
|||||||
use function Lucent\Response\fail;
|
use function Lucent\Response\fail;
|
||||||
use function Lucent\Response\ok;
|
use function Lucent\Response\ok;
|
||||||
|
|
||||||
class RecordController extends Controller
|
class RecordController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly RecordService $recordService,
|
private readonly RecordService $recordService,
|
||||||
@@ -35,20 +34,19 @@ class RecordController extends Controller
|
|||||||
private readonly Manager $recordManager,
|
private readonly Manager $recordManager,
|
||||||
private readonly OperatorRegistry $operatorRegistry,
|
private readonly OperatorRegistry $operatorRegistry,
|
||||||
private readonly ViewModel $viewModel,
|
private readonly ViewModel $viewModel,
|
||||||
)
|
) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$schemaName = $request->route("schemaName");
|
$schemaName = $request->route("schemaName");
|
||||||
|
|
||||||
if (!in_array($schemaName, $this->accountService->currentReadableSchemas())) {
|
if (
|
||||||
return $this->svelte->render(
|
!in_array(
|
||||||
layout: "channel",
|
$schemaName,
|
||||||
view: "recordNotFound",
|
$this->accountService->currentReadableSchemas(),
|
||||||
title: "Schema Not Found",
|
)
|
||||||
);
|
) {
|
||||||
|
return Svelte::view("recordNotFound", "Schema Not Found", []);
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = $this->accountService->all();
|
$users = $this->accountService->all();
|
||||||
@@ -57,12 +55,13 @@ class RecordController extends Controller
|
|||||||
$sort = data_get($urlParams, "sort") ?? $schema->sortBy;
|
$sort = data_get($urlParams, "sort") ?? $schema->sortBy;
|
||||||
$filter = data_get($urlParams, "filter") ?? [];
|
$filter = data_get($urlParams, "filter") ?? [];
|
||||||
|
|
||||||
$arguments = array_merge([
|
$arguments = array_merge(
|
||||||
|
[
|
||||||
"schema" => $schema->name,
|
"schema" => $schema->name,
|
||||||
"status_in" => "draft,published",
|
"status_in" => "draft,published",
|
||||||
], $filter);
|
],
|
||||||
|
$filter,
|
||||||
|
);
|
||||||
|
|
||||||
$skip = data_get($urlParams, "skip") ?? 0;
|
$skip = data_get($urlParams, "skip") ?? 0;
|
||||||
$limit = 30;
|
$limit = 30;
|
||||||
@@ -81,7 +80,6 @@ class RecordController extends Controller
|
|||||||
->parentsDepth(0)
|
->parentsDepth(0)
|
||||||
->runWithCount();
|
->runWithCount();
|
||||||
|
|
||||||
|
|
||||||
$records = $graph->getRootRecords()->toArray();
|
$records = $graph->getRootRecords()->toArray();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@@ -93,45 +91,62 @@ class RecordController extends Controller
|
|||||||
"systemFields" => array_values(System::list()),
|
"systemFields" => array_values(System::list()),
|
||||||
"operators" => $this->operatorRegistry->all(),
|
"operators" => $this->operatorRegistry->all(),
|
||||||
"sortParam" => $sort,
|
"sortParam" => $sort,
|
||||||
"sortField" => $schema->fields->merge(array_values(System::list()))->firstWhere(fn($field) => $field->name === $sort || "-" . $field->name === $sort || "data." . $field->name === $sort || "-data." . $field->name === $sort),
|
"sortField" => $schema->fields
|
||||||
|
->merge(array_values(System::list()))
|
||||||
|
->firstWhere(
|
||||||
|
fn($field) => $field->name === $sort ||
|
||||||
|
"-" . $field->name === $sort ||
|
||||||
|
"data." . $field->name === $sort ||
|
||||||
|
"-data." . $field->name === $sort,
|
||||||
|
),
|
||||||
"limit" => $limit,
|
"limit" => $limit,
|
||||||
"skip" => $skip,
|
"skip" => $skip,
|
||||||
"total" => $graph->total ?? 0,
|
"total" => $graph->total ?? 0,
|
||||||
"filter" => $request->input("filter") ?? [],
|
"filter" => $request->input("filter") ?? [],
|
||||||
"inModal" => true,
|
"inModal" => true,
|
||||||
"isWritable" => in_array($schemaName, $this->accountService->currentWritableSchemas())
|
"isWritable" => in_array(
|
||||||
|
$schemaName,
|
||||||
|
$this->accountService->currentWritableSchemas(),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($request->ajax()) {
|
if ($request->ajax()) {
|
||||||
$data["modalUrl"] = $request->fullUrl();
|
$data["modalUrl"] = $request->fullUrl();
|
||||||
if (str_starts_with(config("lucent.url"), "https")) {
|
if (str_starts_with(config("lucent.url"), "https")) {
|
||||||
$data["modalUrl"] = str_replace("http://", "https://", $request->fullUrl());
|
$data["modalUrl"] = str_replace(
|
||||||
|
"http://",
|
||||||
|
"https://",
|
||||||
|
$request->fullUrl(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
$data["inModal"] = false;
|
$data["inModal"] = false;
|
||||||
return $this->svelte->render(
|
return Svelte::view(
|
||||||
layout: "channel",
|
|
||||||
view: "contentIndex",
|
view: "contentIndex",
|
||||||
title: "Records",
|
title: "Records",
|
||||||
data: $data
|
data: $data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportCSV(Request $request)
|
public function exportCSV(Request $request)
|
||||||
{
|
{
|
||||||
$schemaName = $request->route("schemaName");
|
$schemaName = $request->route("schemaName");
|
||||||
$schema = $this->channelService->channel->schemas->where("name", $schemaName)->first();
|
$schema = $this->channelService->channel->schemas
|
||||||
|
->where("name", $schemaName)
|
||||||
|
->first();
|
||||||
|
|
||||||
$urlParams = $request->all();
|
$urlParams = $request->all();
|
||||||
|
|
||||||
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
||||||
$filter = data_get($urlParams, "filter") ?? [];
|
$filter = data_get($urlParams, "filter") ?? [];
|
||||||
$arguments = array_merge([
|
$arguments = array_merge(
|
||||||
|
[
|
||||||
"schema" => $schema->name,
|
"schema" => $schema->name,
|
||||||
"status_in" => "draft,published",
|
"status_in" => "draft,published",
|
||||||
], $filter);
|
],
|
||||||
|
$filter,
|
||||||
|
);
|
||||||
|
|
||||||
$records = $this->query
|
$records = $this->query
|
||||||
->filter($arguments)
|
->filter($arguments)
|
||||||
@@ -143,53 +158,75 @@ class RecordController extends Controller
|
|||||||
->run()
|
->run()
|
||||||
->tree();
|
->tree();
|
||||||
|
|
||||||
header('Content-Type: application/csv');
|
header("Content-Type: application/csv");
|
||||||
header('Content-Disposition: attachment; filename="' . $schemaName . '.csv";');
|
header(
|
||||||
$handle = fopen('php://output', 'w');
|
'Content-Disposition: attachment; filename="' .
|
||||||
|
$schemaName .
|
||||||
|
'.csv";',
|
||||||
|
);
|
||||||
|
$handle = fopen("php://output", "w");
|
||||||
$relationColumns = $this->makeCsvRelationColumns($schema);
|
$relationColumns = $this->makeCsvRelationColumns($schema);
|
||||||
$csvRow = ["id", ...array_keys($records[0]->data->toArray()),...$relationColumns];
|
$csvRow = [
|
||||||
fputcsv($handle, $csvRow, ',');
|
"id",
|
||||||
|
...array_keys($records[0]->data->toArray()),
|
||||||
|
...$relationColumns,
|
||||||
|
];
|
||||||
|
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_merge(
|
||||||
|
$csvRow,
|
||||||
|
$this->makeCsvRelationColumnValues($schema, $record->_children),
|
||||||
|
);
|
||||||
$csvRow = array_values($csvRow);
|
$csvRow = array_values($csvRow);
|
||||||
fputcsv($handle, $csvRow, ',');
|
fputcsv($handle, $csvRow, ",");
|
||||||
}
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
echo $handle;
|
echo $handle;
|
||||||
exit;
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function makeCsvRelationColumns($schema):array{
|
private function makeCsvRelationColumns($schema): array
|
||||||
return $schema->fields->filter(fn($f) => get_class($f) === Reference::class)->reduce(function($c,$f){
|
{
|
||||||
$c[] = $f->name." id";
|
return $schema->fields
|
||||||
$c[] = $f->name." name";
|
->filter(fn($f) => get_class($f) === Reference::class)
|
||||||
|
->reduce(function ($c, $f) {
|
||||||
|
$c[] = $f->name . " id";
|
||||||
|
$c[] = $f->name . " name";
|
||||||
return $c;
|
return $c;
|
||||||
},[]);
|
}, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function makeCsvRelationColumnValues($schema, $children):array{
|
private function makeCsvRelationColumnValues($schema, $children): array
|
||||||
return $schema->fields->filter(fn($f) => get_class($f) === Reference::class)->reduce(function($c,$f) use($children){
|
{
|
||||||
|
return $schema->fields
|
||||||
$fieldRecords = data_get($children,$f->name);
|
->filter(fn($f) => get_class($f) === Reference::class)
|
||||||
if(empty($fieldRecords)){
|
->reduce(function ($c, $f) use ($children) {
|
||||||
|
$fieldRecords = data_get($children, $f->name);
|
||||||
|
if (empty($fieldRecords)) {
|
||||||
$c[] = "";
|
$c[] = "";
|
||||||
$c[] = "";
|
$c[] = "";
|
||||||
}elseif (count($fieldRecords) === 1){
|
} elseif (count($fieldRecords) === 1) {
|
||||||
$c[] = data_get($fieldRecords,"0.id");
|
$c[] = data_get($fieldRecords, "0.id");
|
||||||
$c[] = $this->viewModel->getRecordName($fieldRecords[0]);
|
$c[] = $this->viewModel->getRecordName($fieldRecords[0]);
|
||||||
}else{
|
} else {
|
||||||
$c[] = collect($fieldRecords)->pluck("id")->join("::");
|
$c[] = collect($fieldRecords)->pluck("id")->join("::");
|
||||||
$c[] = collect($fieldRecords)->pluck("data.name")->join("::");
|
$c[] = collect($fieldRecords)
|
||||||
|
->pluck("data.name")
|
||||||
|
->join("::");
|
||||||
}
|
}
|
||||||
return $c;
|
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(),
|
||||||
|
)
|
||||||
|
) {
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
layout: "channel",
|
layout: "channel",
|
||||||
view: "recordNotFound",
|
view: "recordNotFound",
|
||||||
@@ -197,8 +234,12 @@ class RecordController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$schema = $this->channelService->channel->schemas->where("name", $request->input("schema"))->first();
|
$schema = $this->channelService->channel->schemas
|
||||||
$recordHistory = $this->recordManager->fromSession($request->session())->getRecords();
|
->where("name", $request->input("schema"))
|
||||||
|
->first();
|
||||||
|
$recordHistory = $this->recordManager
|
||||||
|
->fromSession($request->session())
|
||||||
|
->getRecords();
|
||||||
$record = $this->recordService->createEmpty($schema);
|
$record = $this->recordService->createEmpty($schema);
|
||||||
$queryRecord = QueryRecord::fromRecord($record);
|
$queryRecord = QueryRecord::fromRecord($record);
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
@@ -210,15 +251,22 @@ class RecordController extends Controller
|
|||||||
"record" => $queryRecord,
|
"record" => $queryRecord,
|
||||||
"recordHistory" => $recordHistory,
|
"recordHistory" => $recordHistory,
|
||||||
"isCreateMode" => true,
|
"isCreateMode" => true,
|
||||||
"isWritable" => in_array($record->schema, $this->accountService->currentWritableSchemas())
|
"isWritable" => in_array(
|
||||||
]
|
$record->schema,
|
||||||
|
$this->accountService->currentWritableSchemas(),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function newInline(Request $request)
|
public function newInline(Request $request)
|
||||||
{
|
{
|
||||||
if (!in_array($request->input("schema"), $this->accountService->currentWritableSchemas())) {
|
if (
|
||||||
|
!in_array(
|
||||||
|
$request->input("schema"),
|
||||||
|
$this->accountService->currentWritableSchemas(),
|
||||||
|
)
|
||||||
|
) {
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
layout: "channel",
|
layout: "channel",
|
||||||
view: "recordNotFound",
|
view: "recordNotFound",
|
||||||
@@ -226,7 +274,9 @@ class RecordController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$schema = $this->channelService->getSchema($request->input("schema"))->get();
|
$schema = $this->channelService
|
||||||
|
->getSchema($request->input("schema"))
|
||||||
|
->get();
|
||||||
$record = $this->recordService->createEmpty($schema);
|
$record = $this->recordService->createEmpty($schema);
|
||||||
$queryRecord = QueryRecord::fromRecord($record);
|
$queryRecord = QueryRecord::fromRecord($record);
|
||||||
|
|
||||||
@@ -234,7 +284,10 @@ class RecordController extends Controller
|
|||||||
"schema" => $schema,
|
"schema" => $schema,
|
||||||
"record" => $queryRecord,
|
"record" => $queryRecord,
|
||||||
"isCreateMode" => true,
|
"isCreateMode" => true,
|
||||||
"isWritable" => in_array($record->schema, $this->accountService->currentWritableSchemas())
|
"isWritable" => in_array(
|
||||||
|
$record->schema,
|
||||||
|
$this->accountService->currentWritableSchemas(),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +315,12 @@ class RecordController extends Controller
|
|||||||
|
|
||||||
$record = $graph->records->first();
|
$record = $graph->records->first();
|
||||||
|
|
||||||
if (!in_array($record->schema, $this->accountService->currentReadableSchemas())) {
|
if (
|
||||||
|
!in_array(
|
||||||
|
$record->schema,
|
||||||
|
$this->accountService->currentReadableSchemas(),
|
||||||
|
)
|
||||||
|
) {
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
layout: "channel",
|
layout: "channel",
|
||||||
view: "recordNotFound",
|
view: "recordNotFound",
|
||||||
@@ -271,7 +329,10 @@ class RecordController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$schema = $this->channelService->getSchema($record->schema)->get();
|
$schema = $this->channelService->getSchema($record->schema)->get();
|
||||||
$recordHistory = $this->recordManager->fromSession($request->session())->push($rid)->getRecords($rid);
|
$recordHistory = $this->recordManager
|
||||||
|
->fromSession($request->session())
|
||||||
|
->push($rid)
|
||||||
|
->getRecords($rid);
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
layout: "channel",
|
layout: "channel",
|
||||||
view: "recordEdit",
|
view: "recordEdit",
|
||||||
@@ -282,8 +343,11 @@ class RecordController extends Controller
|
|||||||
"record" => toArray($record),
|
"record" => toArray($record),
|
||||||
"users" => $this->accountService->all(),
|
"users" => $this->accountService->all(),
|
||||||
"recordHistory" => $recordHistory,
|
"recordHistory" => $recordHistory,
|
||||||
"isWritable" => in_array($record->schema, $this->accountService->currentWritableSchemas())
|
"isWritable" => in_array(
|
||||||
]
|
$record->schema,
|
||||||
|
$this->accountService->currentWritableSchemas(),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,19 +359,20 @@ class RecordController extends Controller
|
|||||||
|
|
||||||
if ($request->input("value")) {
|
if ($request->input("value")) {
|
||||||
if (in_array($request->input("ui"), ["text", "date"])) {
|
if (in_array($request->input("ui"), ["text", "date"])) {
|
||||||
$arguments["data." . $request->input("field") . "_regex"] = $request->input("value");
|
$arguments[
|
||||||
|
"data." . $request->input("field") . "_regex"
|
||||||
|
] = $request->input("value");
|
||||||
} elseif ($request->input("ui") == "number") {
|
} elseif ($request->input("ui") == "number") {
|
||||||
$arguments["data." . $request->input("field") . "_eqnum"] = floatval($request->input("value"));
|
$arguments[
|
||||||
|
"data." . $request->input("field") . "_eqnum"
|
||||||
|
] = floatval($request->input("value"));
|
||||||
} elseif ($request->input("ui") == "date") {
|
} elseif ($request->input("ui") == "date") {
|
||||||
} elseif ($request->input("ui") == "search") {
|
} elseif ($request->input("ui") == "search") {
|
||||||
$arguments["search_regex"] = $request->input("value");
|
$arguments["search_regex"] = $request->input("value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$records = $this->query
|
$records = $this->query->filter($arguments)->limit(10)->tree();
|
||||||
->filter($arguments)
|
|
||||||
->limit(10)
|
|
||||||
->tree();
|
|
||||||
|
|
||||||
if ($records->isEmpty()) {
|
if ($records->isEmpty()) {
|
||||||
return ok([]);
|
return ok([]);
|
||||||
@@ -320,7 +385,6 @@ class RecordController extends Controller
|
|||||||
{
|
{
|
||||||
$recordId = $request->input("record.id");
|
$recordId = $request->input("record.id");
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ($request->input("isCreateMode")) {
|
if ($request->input("isCreateMode")) {
|
||||||
$recordId = $this->recordService->create(
|
$recordId = $this->recordService->create(
|
||||||
data: new RecordInputData(
|
data: new RecordInputData(
|
||||||
@@ -329,15 +393,20 @@ class RecordController extends Controller
|
|||||||
$request->input("record.data"),
|
$request->input("record.data"),
|
||||||
Status::from($request->input("record.status")),
|
Status::from($request->input("record.status")),
|
||||||
),
|
),
|
||||||
edges: array_map(EdgeInputData::fromArray(...), $request->input("edges") ?? [])
|
edges: array_map(
|
||||||
|
EdgeInputData::fromArray(...),
|
||||||
|
$request->input("edges") ?? [],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$this->recordService->updateWithEdges(
|
$this->recordService->updateWithEdges(
|
||||||
id: $request->input("record.id"),
|
id: $request->input("record.id"),
|
||||||
data: $request->input("record.data"),
|
data: $request->input("record.data"),
|
||||||
status: Status::from($request->input("record.status")),
|
status: Status::from($request->input("record.status")),
|
||||||
edges: array_map(EdgeInputData::fromArray(...), $request->input("edges") ?? []),
|
edges: array_map(
|
||||||
|
EdgeInputData::fromArray(...),
|
||||||
|
$request->input("edges") ?? [],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +416,6 @@ class RecordController extends Controller
|
|||||||
->childrenDepth(1)
|
->childrenDepth(1)
|
||||||
->parentsDepth(1)
|
->parentsDepth(1)
|
||||||
->run();
|
->run();
|
||||||
|
|
||||||
} catch (ValidatorException $th) {
|
} catch (ValidatorException $th) {
|
||||||
return fail($th->getValidatorErrors());
|
return fail($th->getValidatorErrors());
|
||||||
} catch (LucentException $th) {
|
} catch (LucentException $th) {
|
||||||
@@ -356,11 +424,9 @@ class RecordController extends Controller
|
|||||||
return ok(toArray($newGraph));
|
return ok(toArray($newGraph));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function clone(Request $request)
|
public function clone(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$newRecordId = $this->recordService->clone(
|
$newRecordId = $this->recordService->clone(
|
||||||
recordId: $request->route("rid"),
|
recordId: $request->route("rid"),
|
||||||
);
|
);
|
||||||
@@ -374,10 +440,8 @@ class RecordController extends Controller
|
|||||||
|
|
||||||
public function status(Request $request)
|
public function status(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$ids = array_map(fn($rec) => $rec["id"], $request->input("records"));
|
$ids = array_map(fn($rec) => $rec["id"], $request->input("records"));
|
||||||
|
|
||||||
|
|
||||||
$this->recordService->changeStatusBulk(
|
$this->recordService->changeStatusBulk(
|
||||||
status: $request->route("status"),
|
status: $request->route("status"),
|
||||||
recordsIds: $ids,
|
recordsIds: $ids,
|
||||||
@@ -387,9 +451,12 @@ class RecordController extends Controller
|
|||||||
|
|
||||||
public function emptyTrash(Request $request)
|
public function emptyTrash(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->recordService->emptyTrash($request->route("schemaName"));
|
$this->recordService->emptyTrash($request->route("schemaName"));
|
||||||
return redirect($this->channelService->channel->lucentUrl . "/content/" . $request->route("schemaName"));
|
return redirect(
|
||||||
|
$this->channelService->channel->lucentUrl .
|
||||||
|
"/content/" .
|
||||||
|
$request->route("schemaName"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(Request $request)
|
public function delete(Request $request)
|
||||||
@@ -409,11 +476,11 @@ class RecordController extends Controller
|
|||||||
try {
|
try {
|
||||||
$this->recordService->rollback(
|
$this->recordService->rollback(
|
||||||
recordId: $request->route("rid"),
|
recordId: $request->route("rid"),
|
||||||
version: (int)$request->route("version")
|
version: (int) $request->route("version"),
|
||||||
);
|
);
|
||||||
} catch (ValidatorException $th) {
|
} catch (ValidatorException $th) {
|
||||||
return fail($th->getFirstValidatorError());
|
return fail($th->getFirstValidatorError());
|
||||||
} catch (LucentException|Throwable $th) {
|
} catch (LucentException | Throwable $th) {
|
||||||
return fail($th);
|
return fail($th);
|
||||||
}
|
}
|
||||||
return ok();
|
return ok();
|
||||||
|
|||||||
+34
-23
@@ -36,30 +36,9 @@ Route::group(
|
|||||||
Route::get("/verify", [AuthController::class, "verify"]);
|
Route::get("/verify", [AuthController::class, "verify"]);
|
||||||
Route::post("/verify", [AuthController::class, "postVerify"]);
|
Route::post("/verify", [AuthController::class, "postVerify"]);
|
||||||
});
|
});
|
||||||
|
// NEW
|
||||||
Route::middleware("lucent.auth")->group(function () {
|
Route::middleware("lucent.auth")->group(function () {
|
||||||
Route::get("/logout", [AuthController::class, "logout"]);
|
// SCHEMAS
|
||||||
Route::get("/profile", [AccountController::class, "profile"]);
|
|
||||||
Route::post("/account/update-name", [
|
|
||||||
AccountController::class,
|
|
||||||
"updateName",
|
|
||||||
]);
|
|
||||||
Route::post("/account/update-email", [
|
|
||||||
AccountController::class,
|
|
||||||
"updateEmail",
|
|
||||||
]);
|
|
||||||
Route::get("/command-report/{signature}", [
|
|
||||||
BuildController::class,
|
|
||||||
"report",
|
|
||||||
]);
|
|
||||||
Route::get("/command-report-source/{signature}", [
|
|
||||||
BuildController::class,
|
|
||||||
"reportSource",
|
|
||||||
]);
|
|
||||||
Route::post("/command/{signature}", [
|
|
||||||
BuildController::class,
|
|
||||||
"build",
|
|
||||||
]);
|
|
||||||
Route::get("/schemas", [SchemaController::class, "home"]);
|
Route::get("/schemas", [SchemaController::class, "home"]);
|
||||||
Route::get("/schemas/edit/{id}", [SchemaController::class, "edit"]);
|
Route::get("/schemas/edit/{id}", [SchemaController::class, "edit"]);
|
||||||
Route::post("/schemas", [SchemaController::class, "postCreate"]);
|
Route::post("/schemas", [SchemaController::class, "postCreate"]);
|
||||||
@@ -86,6 +65,38 @@ Route::group(
|
|||||||
FieldController::class,
|
FieldController::class,
|
||||||
"postReorder",
|
"postReorder",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// CONTENT
|
||||||
|
Route::get("content/{schemaName}", [
|
||||||
|
RecordController::class,
|
||||||
|
"index",
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
//OLD
|
||||||
|
Route::middleware("lucent.auth")->group(function () {
|
||||||
|
Route::get("/logout", [AuthController::class, "logout"]);
|
||||||
|
Route::get("/profile", [AccountController::class, "profile"]);
|
||||||
|
Route::post("/account/update-name", [
|
||||||
|
AccountController::class,
|
||||||
|
"updateName",
|
||||||
|
]);
|
||||||
|
Route::post("/account/update-email", [
|
||||||
|
AccountController::class,
|
||||||
|
"updateEmail",
|
||||||
|
]);
|
||||||
|
Route::get("/command-report/{signature}", [
|
||||||
|
BuildController::class,
|
||||||
|
"report",
|
||||||
|
]);
|
||||||
|
Route::get("/command-report-source/{signature}", [
|
||||||
|
BuildController::class,
|
||||||
|
"reportSource",
|
||||||
|
]);
|
||||||
|
Route::post("/command/{signature}", [
|
||||||
|
BuildController::class,
|
||||||
|
"build",
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware(["lucent.auth"])->group(function () {
|
Route::middleware(["lucent.auth"])->group(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user