schema index
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
||||
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||
import { post } from "../../modules/remote";
|
||||
import { getApp } from "../../app";
|
||||
let { channel, user, data, newRank } = $props();
|
||||
@@ -28,7 +28,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
||||
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||
{#snippet body()}
|
||||
<h3 class="header-small mb-4 mt-5">Create a <em>{data.type}</em> field</h3>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
||||
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||
import TextFieldProps from "./TextFieldProps.svelte";
|
||||
import DeleteButton from "../../common/DeleteButton.svelte";
|
||||
import { post } from "../../modules/remote";
|
||||
@@ -42,7 +42,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
||||
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||
{#snippet body()}
|
||||
<h3 class="header-small mb-4 mt-5">
|
||||
Edit <em>{data.field.type}</em> field {data.field.name}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import RecordRow from "./RecordRow.svelte";
|
||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
||||
import { get } from "../../modules/remote";
|
||||
let { channel, user } = $props();
|
||||
let { channel, user, data } = $props();
|
||||
let records = $state([]);
|
||||
let graph = $state(null);
|
||||
let users = $state([]);
|
||||
@@ -16,7 +16,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
||||
<ChannelLayout {body} {channel} schemas={data.schemas} {user}></ChannelLayout>
|
||||
{#snippet body()}
|
||||
<h3 class="header-small mb-4 mt-5">Latest Content changes</h3>
|
||||
{#if records.length > 0}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
||||
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||
import Sortable from "../../common/Sortable.svelte";
|
||||
import DeleteButton from "../../common/DeleteButton.svelte";
|
||||
import { post } from "../../modules/remote";
|
||||
@@ -42,7 +42,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
||||
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||
{#snippet body()}
|
||||
<h3>Edit Schema</h3>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import ChannelLayout from "../../layouts/ChannelLayout.svelte";
|
||||
import SchemaLayout from "../../layouts/SchemaLayout.svelte";
|
||||
import Sortable from "../../common/Sortable.svelte";
|
||||
import { post } from "../../modules/remote";
|
||||
import { getApp } from "../../app";
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<ChannelLayout {body} {channel} {user}></ChannelLayout>
|
||||
<SchemaLayout {body} {channel} {user}></SchemaLayout>
|
||||
{#snippet body()}
|
||||
<h3 class="header-small mb-4 mt-5">Schemas</h3>
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<script>
|
||||
import Header from "./Header.svelte";
|
||||
import Navbar from "./Navbar.svelte";
|
||||
let { body, channel, user } = $props();
|
||||
let { body, channel, user, schemas } = $props();
|
||||
</script>
|
||||
|
||||
<Header {channel} {user}></Header>
|
||||
<main>
|
||||
<aside class="sidebar-content">
|
||||
<Navbar {channel}></Navbar>
|
||||
<Navbar {channel} {schemas}></Navbar>
|
||||
</aside>
|
||||
<div class="main-content">
|
||||
{@render body()}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
<div class="top-nav">
|
||||
<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>
|
||||
|
||||
<!-- {#if channel.commands.length > 0}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
<script>
|
||||
let { channel } = $props();
|
||||
import { getApp } from "../app";
|
||||
let { channel, schemas } = $props();
|
||||
const app = getApp();
|
||||
</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;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Lucent\Account\AccountService;
|
||||
use Lucent\Core\Repository\SchemaRepo;
|
||||
use Lucent\Query\Query;
|
||||
use Lucent\Svelte\Svelte;
|
||||
use function Lucent\Response\ok;
|
||||
|
||||
class HomeController extends Controller
|
||||
class HomeController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AccountService $accountService,
|
||||
@@ -20,7 +20,11 @@ class HomeController extends Controller
|
||||
|
||||
public function home()
|
||||
{
|
||||
return Svelte::view("homeIndex", "Records", []);
|
||||
$schemas = SchemaRepo::all();
|
||||
|
||||
return Svelte::view("homeIndex", "Records", [
|
||||
"schemas" => $schemas,
|
||||
]);
|
||||
}
|
||||
|
||||
public function records(Request $request): Response
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace Lucent\Http\Controller;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Lucent\Account\AccountService;
|
||||
use Lucent\Account\AuthService;
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\LucentException;
|
||||
use Lucent\Query\Operator\OperatorRegistry;
|
||||
@@ -24,31 +23,30 @@ use Lucent\ViewModel\ViewModel;
|
||||
use function Lucent\Response\fail;
|
||||
use function Lucent\Response\ok;
|
||||
|
||||
class RecordController extends Controller
|
||||
class RecordController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly RecordService $recordService,
|
||||
private readonly AccountService $accountService,
|
||||
private readonly ChannelService $channelService,
|
||||
private readonly Svelte $svelte,
|
||||
private readonly Query $query,
|
||||
private readonly Manager $recordManager,
|
||||
private readonly RecordService $recordService,
|
||||
private readonly AccountService $accountService,
|
||||
private readonly ChannelService $channelService,
|
||||
private readonly Svelte $svelte,
|
||||
private readonly Query $query,
|
||||
private readonly Manager $recordManager,
|
||||
private readonly OperatorRegistry $operatorRegistry,
|
||||
private readonly ViewModel $viewModel,
|
||||
)
|
||||
{
|
||||
}
|
||||
) {}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$schemaName = $request->route("schemaName");
|
||||
|
||||
if (!in_array($schemaName, $this->accountService->currentReadableSchemas())) {
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
title: "Schema Not Found",
|
||||
);
|
||||
if (
|
||||
!in_array(
|
||||
$schemaName,
|
||||
$this->accountService->currentReadableSchemas(),
|
||||
)
|
||||
) {
|
||||
return Svelte::view("recordNotFound", "Schema Not Found", []);
|
||||
}
|
||||
|
||||
$users = $this->accountService->all();
|
||||
@@ -57,12 +55,13 @@ class RecordController extends Controller
|
||||
$sort = data_get($urlParams, "sort") ?? $schema->sortBy;
|
||||
$filter = data_get($urlParams, "filter") ?? [];
|
||||
|
||||
$arguments = array_merge([
|
||||
"schema" => $schema->name,
|
||||
"status_in" => "draft,published",
|
||||
], $filter);
|
||||
|
||||
|
||||
$arguments = array_merge(
|
||||
[
|
||||
"schema" => $schema->name,
|
||||
"status_in" => "draft,published",
|
||||
],
|
||||
$filter,
|
||||
);
|
||||
|
||||
$skip = data_get($urlParams, "skip") ?? 0;
|
||||
$limit = 30;
|
||||
@@ -81,7 +80,6 @@ class RecordController extends Controller
|
||||
->parentsDepth(0)
|
||||
->runWithCount();
|
||||
|
||||
|
||||
$records = $graph->getRootRecords()->toArray();
|
||||
|
||||
$data = [
|
||||
@@ -93,45 +91,62 @@ class RecordController extends Controller
|
||||
"systemFields" => array_values(System::list()),
|
||||
"operators" => $this->operatorRegistry->all(),
|
||||
"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,
|
||||
"skip" => $skip,
|
||||
"total" => $graph->total ?? 0,
|
||||
"filter" => $request->input("filter") ?? [],
|
||||
"inModal" => true,
|
||||
"isWritable" => in_array($schemaName, $this->accountService->currentWritableSchemas())
|
||||
"isWritable" => in_array(
|
||||
$schemaName,
|
||||
$this->accountService->currentWritableSchemas(),
|
||||
),
|
||||
];
|
||||
|
||||
if ($request->ajax()) {
|
||||
$data["modalUrl"] = $request->fullUrl();
|
||||
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;
|
||||
}
|
||||
$data["inModal"] = false;
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
return Svelte::view(
|
||||
view: "contentIndex",
|
||||
title: "Records",
|
||||
data: $data
|
||||
data: $data,
|
||||
);
|
||||
}
|
||||
|
||||
public function exportCSV(Request $request)
|
||||
{
|
||||
$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();
|
||||
|
||||
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
||||
$filter = data_get($urlParams, "filter") ?? [];
|
||||
$arguments = array_merge([
|
||||
"schema" => $schema->name,
|
||||
"status_in" => "draft,published",
|
||||
], $filter);
|
||||
|
||||
$arguments = array_merge(
|
||||
[
|
||||
"schema" => $schema->name,
|
||||
"status_in" => "draft,published",
|
||||
],
|
||||
$filter,
|
||||
);
|
||||
|
||||
$records = $this->query
|
||||
->filter($arguments)
|
||||
@@ -143,53 +158,75 @@ class RecordController extends Controller
|
||||
->run()
|
||||
->tree();
|
||||
|
||||
header('Content-Type: application/csv');
|
||||
header('Content-Disposition: attachment; filename="' . $schemaName . '.csv";');
|
||||
$handle = fopen('php://output', 'w');
|
||||
header("Content-Type: application/csv");
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="' .
|
||||
$schemaName .
|
||||
'.csv";',
|
||||
);
|
||||
$handle = fopen("php://output", "w");
|
||||
$relationColumns = $this->makeCsvRelationColumns($schema);
|
||||
$csvRow = ["id", ...array_keys($records[0]->data->toArray()),...$relationColumns];
|
||||
fputcsv($handle, $csvRow, ',');
|
||||
$csvRow = [
|
||||
"id",
|
||||
...array_keys($records[0]->data->toArray()),
|
||||
...$relationColumns,
|
||||
];
|
||||
fputcsv($handle, $csvRow, ",");
|
||||
foreach ($records as $record) {
|
||||
|
||||
$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);
|
||||
fputcsv($handle, $csvRow, ',');
|
||||
fputcsv($handle, $csvRow, ",");
|
||||
}
|
||||
fclose($handle);
|
||||
echo $handle;
|
||||
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 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;
|
||||
},[]);
|
||||
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)
|
||||
{
|
||||
if (!in_array($request->input("schema"), $this->accountService->currentWritableSchemas())) {
|
||||
if (
|
||||
!in_array(
|
||||
$request->input("schema"),
|
||||
$this->accountService->currentWritableSchemas(),
|
||||
)
|
||||
) {
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
@@ -197,8 +234,12 @@ class RecordController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
$schema = $this->channelService->channel->schemas->where("name", $request->input("schema"))->first();
|
||||
$recordHistory = $this->recordManager->fromSession($request->session())->getRecords();
|
||||
$schema = $this->channelService->channel->schemas
|
||||
->where("name", $request->input("schema"))
|
||||
->first();
|
||||
$recordHistory = $this->recordManager
|
||||
->fromSession($request->session())
|
||||
->getRecords();
|
||||
$record = $this->recordService->createEmpty($schema);
|
||||
$queryRecord = QueryRecord::fromRecord($record);
|
||||
return $this->svelte->render(
|
||||
@@ -210,15 +251,22 @@ class RecordController extends Controller
|
||||
"record" => $queryRecord,
|
||||
"recordHistory" => $recordHistory,
|
||||
"isCreateMode" => true,
|
||||
"isWritable" => in_array($record->schema, $this->accountService->currentWritableSchemas())
|
||||
]
|
||||
"isWritable" => in_array(
|
||||
$record->schema,
|
||||
$this->accountService->currentWritableSchemas(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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(
|
||||
layout: "channel",
|
||||
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);
|
||||
$queryRecord = QueryRecord::fromRecord($record);
|
||||
|
||||
@@ -234,7 +284,10 @@ class RecordController extends Controller
|
||||
"schema" => $schema,
|
||||
"record" => $queryRecord,
|
||||
"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();
|
||||
|
||||
if (!in_array($record->schema, $this->accountService->currentReadableSchemas())) {
|
||||
if (
|
||||
!in_array(
|
||||
$record->schema,
|
||||
$this->accountService->currentReadableSchemas(),
|
||||
)
|
||||
) {
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
@@ -271,7 +329,10 @@ class RecordController extends Controller
|
||||
}
|
||||
|
||||
$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(
|
||||
layout: "channel",
|
||||
view: "recordEdit",
|
||||
@@ -282,8 +343,11 @@ class RecordController extends Controller
|
||||
"record" => toArray($record),
|
||||
"users" => $this->accountService->all(),
|
||||
"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 (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") {
|
||||
$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") == "search") {
|
||||
$arguments["search_regex"] = $request->input("value");
|
||||
}
|
||||
}
|
||||
|
||||
$records = $this->query
|
||||
->filter($arguments)
|
||||
->limit(10)
|
||||
->tree();
|
||||
$records = $this->query->filter($arguments)->limit(10)->tree();
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
return ok([]);
|
||||
@@ -320,7 +385,6 @@ class RecordController extends Controller
|
||||
{
|
||||
$recordId = $request->input("record.id");
|
||||
try {
|
||||
|
||||
if ($request->input("isCreateMode")) {
|
||||
$recordId = $this->recordService->create(
|
||||
data: new RecordInputData(
|
||||
@@ -329,15 +393,20 @@ class RecordController extends Controller
|
||||
$request->input("record.data"),
|
||||
Status::from($request->input("record.status")),
|
||||
),
|
||||
edges: array_map(EdgeInputData::fromArray(...), $request->input("edges") ?? [])
|
||||
edges: array_map(
|
||||
EdgeInputData::fromArray(...),
|
||||
$request->input("edges") ?? [],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
||||
$this->recordService->updateWithEdges(
|
||||
id: $request->input("record.id"),
|
||||
data: $request->input("record.data"),
|
||||
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)
|
||||
->parentsDepth(1)
|
||||
->run();
|
||||
|
||||
} catch (ValidatorException $th) {
|
||||
return fail($th->getValidatorErrors());
|
||||
} catch (LucentException $th) {
|
||||
@@ -356,11 +424,9 @@ class RecordController extends Controller
|
||||
return ok(toArray($newGraph));
|
||||
}
|
||||
|
||||
|
||||
public function clone(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$newRecordId = $this->recordService->clone(
|
||||
recordId: $request->route("rid"),
|
||||
);
|
||||
@@ -374,10 +440,8 @@ class RecordController extends Controller
|
||||
|
||||
public function status(Request $request)
|
||||
{
|
||||
|
||||
$ids = array_map(fn($rec) => $rec["id"], $request->input("records"));
|
||||
|
||||
|
||||
$this->recordService->changeStatusBulk(
|
||||
status: $request->route("status"),
|
||||
recordsIds: $ids,
|
||||
@@ -387,9 +451,12 @@ class RecordController extends Controller
|
||||
|
||||
public function emptyTrash(Request $request)
|
||||
{
|
||||
|
||||
$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)
|
||||
@@ -409,11 +476,11 @@ class RecordController extends Controller
|
||||
try {
|
||||
$this->recordService->rollback(
|
||||
recordId: $request->route("rid"),
|
||||
version: (int)$request->route("version")
|
||||
version: (int) $request->route("version"),
|
||||
);
|
||||
} catch (ValidatorException $th) {
|
||||
return fail($th->getFirstValidatorError());
|
||||
} catch (LucentException|Throwable $th) {
|
||||
} catch (LucentException | Throwable $th) {
|
||||
return fail($th);
|
||||
}
|
||||
return ok();
|
||||
|
||||
+34
-23
@@ -36,30 +36,9 @@ Route::group(
|
||||
Route::get("/verify", [AuthController::class, "verify"]);
|
||||
Route::post("/verify", [AuthController::class, "postVerify"]);
|
||||
});
|
||||
|
||||
// NEW
|
||||
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",
|
||||
]);
|
||||
// SCHEMAS
|
||||
Route::get("/schemas", [SchemaController::class, "home"]);
|
||||
Route::get("/schemas/edit/{id}", [SchemaController::class, "edit"]);
|
||||
Route::post("/schemas", [SchemaController::class, "postCreate"]);
|
||||
@@ -86,6 +65,38 @@ Route::group(
|
||||
FieldController::class,
|
||||
"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 () {
|
||||
|
||||
Reference in New Issue
Block a user