Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8323c6218e | ||
|
|
6d8763a22c | ||
|
|
0471c0ab83 | ||
|
|
0d3f807d9d | ||
|
|
e5fab028b3 | ||
|
|
7117021750 | ||
|
|
2fd9331c15 | ||
|
|
3de4b78a0b | ||
|
|
5b68bb191b | ||
|
|
d8b208426a | ||
|
|
3a8e56a617 | ||
|
|
39b02507a3 | ||
|
|
ce2b9399c2 | ||
|
|
cd38800131 | ||
|
|
0b1286c05f | ||
|
|
73fca52013 |
No files matched your search
@@ -4,23 +4,25 @@
|
|||||||
.justify-content-around{justify-content: space-around;}.justify-content-end{justify-content: end}
|
.justify-content-around{justify-content: space-around;}.justify-content-end{justify-content: end}
|
||||||
.flex {display:flex}
|
.flex {display:flex}
|
||||||
|
|
||||||
:root {
|
:root {--color-red: #d47474}
|
||||||
--color-red: #d47474
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-center{text-align:center;}.text-right{text-align:right}.text-left{text-align:left;}
|
.text-center{text-align:center;}.text-right{text-align:right}.text-left{text-align:left;}
|
||||||
|
.m-0 {margin:0!important}.mx-0 {margin-left:0!important;margin-right:0!important}.my-0 {margin-top:0!important;margin-bottom:0!important}
|
||||||
|
.p-0 {padding:0!important}.px-0 {padding-left:0!important;padding-right:0!important}.py-0 {padding-top:0!important;padding-bottom:0!important}
|
||||||
|
|
||||||
[class^="btn-"], [class~=" btn-"] { display: inline-block; font-weight: 400; text-align: center; white-space: nowrap; vertical-align: middle; user-select: none; border: 1px solid transparent; padding: .375rem .75rem; line-height: 1.5; border-radius: .25rem; cursor:pointer; transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; background:rgba(0,0,0,0.3); color:rgba(255,255,255,0.8); text-decoration:none; }
|
[class^="btn-"], [class~=" btn-"] { display: inline-block; font-weight: 400; font-size:16px; text-align: center; white-space: nowrap; vertical-align: middle; user-select: none; border: 1px solid transparent; padding: .375rem .75rem; line-height: 1.5; border-radius: .25rem; cursor:pointer; transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; background:rgba(0,0,0,0.3); color:rgba(255,255,255,0.8); text-decoration:none; }
|
||||||
[class^="btn-"]:hover, [class~=" btn-"]:hover {border-color: rgba(0, 0, 0, 0.5);text-decoration: underline;}
|
[class^="btn-"]:hover, [class~=" btn-"]:hover {border-color: rgba(0, 0, 0, 0.5);text-decoration: underline;}
|
||||||
.btn-red {background: rgba(155,0,0,0.5);color: rgba(255, 255, 255, 0.9);}
|
.btn-red {background: rgba(155,0,0,0.5);color: rgba(255, 255, 255, 0.9);}
|
||||||
.btn-green {background: rgba(0,155,0,0.5);color: rgba(255, 255, 255, 0.9);}
|
.btn-green {background: rgba(0,155,0,0.5);color: rgba(255, 255, 255, 0.9);}
|
||||||
.btn-blue {background: rgba(0,0,155,0.5);color: rgba(255, 255, 255, 0.9);}
|
.btn-blue {background: rgba(0,0,155,0.5);color: rgba(255, 255, 255, 0.9);}
|
||||||
|
.btn-yellow {background: rgba(249, 200, 11, 0.69);color: rgba(255, 255, 255, 0.9);}
|
||||||
|
.bg-yellow {background:#c09f1f!important}
|
||||||
|
|
||||||
body{background:#f3f3f9}
|
body{background:#f3f3f9}
|
||||||
code {white-space:pre-line;font-family:monospace;color: #e6e6e6;background: #343537;display: block;padding: 1rem;line-height: 1.5em;border: 1px solid #2e2e30;}
|
code {white-space:pre-line;font-family:monospace;color: #e6e6e6;background: #343537;display: block;padding: 1rem;line-height: 1.5em;border: 1px solid #2e2e30;}
|
||||||
body {font-family:Helvetica Neue, Helvetica, Arial, sans-serif;}
|
body {font-family:Helvetica Neue, Helvetica, Arial, sans-serif;}
|
||||||
summary {cursor:pointer;}
|
summary {cursor:pointer;}
|
||||||
|
|
||||||
|
|
||||||
#body-main {min-height:calc(100vh - 30px);display:flex}
|
#body-main {min-height:calc(100vh - 30px);display:flex}
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
@@ -36,19 +38,23 @@ summary {cursor:pointer;}
|
|||||||
#body-footer {background: #fff;color: #333;height: 30px;line-height: 30px;font-size: 0.8rem;padding: 0 0.5rem;text-align: right;border-top:1px solid #ebedee;}
|
#body-footer {background: #fff;color: #333;height: 30px;line-height: 30px;font-size: 0.8rem;padding: 0 0.5rem;text-align: right;border-top:1px solid #ebedee;}
|
||||||
|
|
||||||
/* Sidebar */
|
/* Sidebar */
|
||||||
#main-nav {background:#242528;width:240px;color:#fff;font-family:consolas, courier new, monospace;font-size:0.9rem;position:fixed;top:0;bottom:0;overflow-y:scroll;padding-bottom:2rem;border-right: 2px solid #333;}
|
#main-nav {background:#373737;width:240px;color:#fff;font-family:consolas, courier new, monospace;font-size:0.9rem;position:fixed;top:0;bottom:0;overflow-y:auto;padding-bottom:2rem;border-right: 2px solid #333;}
|
||||||
#main-nav .app-title {font-size:1.3rem; text-align:center;padding:1.8rem 0}
|
#main-nav .app-title {font-size:1.3rem; text-align:center;padding:1.8rem 0}
|
||||||
#main-nav .app-title:before {content:"🔳"; margin-right:10px}
|
#main-nav .app-title:before {content:"🔳"; margin-right:10px}
|
||||||
#main-nav label {color: #a4a4a4;text-transform:uppercase ; display:block;padding:0.8rem 1rem;font-size:1.15em;}
|
#main-nav label {color: #a4a4a4;text-transform:uppercase ; display:block;padding:0.8rem 1rem;font-size:1.15em;}
|
||||||
#main-nav label:before {content:"⊙"; margin-right:10px}
|
#main-nav label:before {content:"⊙"; margin-right:10px}
|
||||||
#main-nav a {color: #efecec;text-decoration:none;display:block;padding:0 1rem 0 2rem;transition:all 0.3s ease;line-height:3em;font-size:0.9em}
|
#main-nav a {color: #efecec;text-decoration:none;display:block;padding:0 1rem 0 2rem;transition:all 0.3s ease;line-height:2.5em;font-size:0.9em}
|
||||||
#main-nav a:before {content:"›"; margin-right:10px;line-height:3em}
|
#main-nav a:before {content:"›"; margin-right:10px;}
|
||||||
#main-nav a:hover {background:rgba(255,255,255,0.1)}
|
#main-nav a:hover {background:rgba(255,255,255,0.1)}
|
||||||
|
|
||||||
/* Main content */
|
/* Main content */
|
||||||
#main-content {padding:4vh 2vw;width:100%;margin-left:auto;}
|
#main-content {padding:4vh 2vw;width:100%;margin-left:auto;}
|
||||||
#main-content section {border-radius:0.3rem;box-shadow: 0 1px 2px rgba(56,65,74,.15)}
|
#main-content section {border-radius:0.3rem;box-shadow: 0 1px 2px rgba(56,65,74,.15);display: flex;flex-direction: column;}
|
||||||
#main-content section article {border-radius:0.3rem;font-family: Courier New , Courier, monospace;font-size: 0.8em;background:#fff;padding:1.5rem;}
|
#main-content section article {border-radius:0.3rem;font-family: Courier New , Courier, monospace;font-size: 0.8em;background:#fff;padding:1.5rem;border: 1px solid #00000029;}
|
||||||
#main-content section header {border-top-left:0.3rem;border-top-right:4px;background:#fff;padding:1rem 1rem;font-size:1.2em;color: #4b4848;border-bottom:1px solid #e9ebec;display:flex;align-items:center}
|
#main-content section header + article {border-top:0;border-top-left-radius: unset;border-top-right-radius: unset}
|
||||||
#main-content section footer {border-bottom-left:0.3rem;border-bottom-right:0.3rem;background:#f9f9f9;padding:2vh 1vw;}
|
#main-content section header:has(+ article) {border: 1px solid #00000029;border-bottom:0}
|
||||||
|
#main-content section header {border-top-left-radius:0.3rem;border-top-right-radius:0.3rem;background:#373737;padding:1rem 1rem;font-size:1.2em;color: #fff;border-bottom:1px solid #7b7b7b;display:flex;align-items:center}
|
||||||
|
#main-content section article:has(+ footer) {border-bottom-left-radius:unset;border-bottom-right-radius:unset;border-bottom:0}
|
||||||
|
#main-content section footer {border-bottom-left-radius:0.3rem;border-bottom-right-radius:0.3rem;background:#f9f9f9;padding:1.5vh 1vw;line-height:1.5vh}
|
||||||
|
#main-content section article + footer {border: 1px solid #00000029;border-top:0}
|
||||||
|
#main-content section article [class*="col-"] {overflow-x:auto}
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"mcnd/lean": "dev-master"
|
"mcnd/lean": "1.4.2"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ return [
|
|||||||
|
|
||||||
'ulmus' => [
|
'ulmus' => [
|
||||||
'entities' => [
|
'entities' => [
|
||||||
'Lean\\Console\\Entity\\Firewall' => implode(DIRECTORY_SEPARATOR, [ $path , "src", "Entity", "Firewall" ]),
|
Lean\Console\Entity\Firewall::class => implode(DIRECTORY_SEPARATOR, [ $path , "src", "Entity", "Firewall" ]),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -39,8 +39,12 @@ return [
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'cli' => [
|
||||||
|
'Lean\\Console\\Cli' => implode(DIRECTORY_SEPARATOR, [ $path, "src", "Cli", "" ]),
|
||||||
|
],
|
||||||
|
|
||||||
'routes' => ! getenv('DEBUG') ? [] : [
|
'routes' => ! getenv('DEBUG') ? [] : [
|
||||||
'Lean\\Console\\Controller' => implode(DIRECTORY_SEPARATOR, [ $path, "src", "Controller", "" ]),
|
Lean\Console\Controller::class => implode(DIRECTORY_SEPARATOR, [ $path, "src", "Controller", "" ]),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,29 @@
|
|||||||
"fields": "{$count} fields",
|
"fields": "{$count} fields",
|
||||||
"name": "Table Name",
|
"name": "Table Name",
|
||||||
"actions": "Actions",
|
"actions": "Actions",
|
||||||
|
"count": "Entries",
|
||||||
"table-fields" : "Fields in table",
|
"table-fields" : "Fields in table",
|
||||||
"create": "Create table",
|
"create": "Create table",
|
||||||
"createAll": "Create all tables",
|
"createAll": "Create all tables",
|
||||||
"query": "SQL Query",
|
"query": "SQL Query",
|
||||||
|
"add-column": "+ New row",
|
||||||
"alter": "Alter table",
|
"alter": "Alter table",
|
||||||
"alterAll": "Alter all tables",
|
"alterAll": "Alter all tables",
|
||||||
"uptodate": "This table is up-to-date"
|
"uptodate": "This table is up-to-date"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"database_insert": {
|
||||||
|
"add": "Create",
|
||||||
|
"breadcrumb": "Insert",
|
||||||
|
"readonly": "This field is read-only",
|
||||||
|
|
||||||
|
"table": {
|
||||||
|
"column": "Column",
|
||||||
|
"type": "Data type",
|
||||||
|
"function": "Function",
|
||||||
|
"attributes": "Attributs",
|
||||||
|
"value": "Value"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
"title" : "Debugging -- LEAN",
|
"title" : "Debugging -- LEAN",
|
||||||
"page-title": "Déboguage",
|
"page-title": "Déboguage",
|
||||||
"logs": {
|
"logs": {
|
||||||
"breadcrumb": "Journaux d'événements"
|
"breadcrumb": "Journaux d'événements",
|
||||||
|
"line": "Lines number: "
|
||||||
},
|
},
|
||||||
"phpinfo": {
|
"phpinfo": {
|
||||||
"breadcrumb": "phpinfo()"
|
"breadcrumb": "phpinfo()"
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lean\Console\Cli;
|
||||||
|
|
||||||
|
use Mcnd\CLI\OptionValueTypeEnum;
|
||||||
|
use Notes\CLI\Attribute\{Option, Command};
|
||||||
|
use Psr\Http\Message\{ServerRequestInterface, ResponseInterface};
|
||||||
|
|
||||||
|
use Lean\Console\{Lib, };
|
||||||
|
|
||||||
|
# https://www.asciiart.eu/text-to-ascii-art
|
||||||
|
#[Command(description: PHP_EOL . <<<CLI
|
||||||
|
#[color:gray, bg: black]╔═════════════════════════╗[#]
|
||||||
|
#[color:gray, bg: black]║ _ ║[#]
|
||||||
|
#[color:gray, bg: black]║ | | ___ __ _ _ __ ║[#]
|
||||||
|
#[color:gray, bg: black]║ | | / _ \/ _` | '_ \ ║[#]
|
||||||
|
#[color:gray, bg: black]║ | |__| __/ (_| | | | | ║[#]
|
||||||
|
#[color:gray, bg: black]║ |_____\___|\__,_|_| |_| ║[#]
|
||||||
|
#[color:gray, bg: black]║ ║[#]
|
||||||
|
#[color:gray, bg: black]╚═════════════════════════╝[#]
|
||||||
|
|
||||||
|
Try #[color:gray, bg: black]'cli lean-console --help'[#] for more information.
|
||||||
|
CLI
|
||||||
|
, command: 'lean-console')]
|
||||||
|
#[Option(switch: ['-h', '--help'], description: "Display help for the given command. When no command is given display help for the list command")]
|
||||||
|
#[Option(switch: ['-q', '--quiet'], description: "Do not output any message")]
|
||||||
|
#[Option(switch: ['-n', '--no-interaction'], description: "Run script without user interaction")]
|
||||||
|
#[Option(switch: ['-v', '-vv', '-vvv', '--verbose'], description: "Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug", value: OptionValueTypeEnum::OptionalValue)]
|
||||||
|
class Console
|
||||||
|
{
|
||||||
|
use Lib\ConsoleControllerTrait;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lean\Console\Cli;
|
||||||
|
|
||||||
|
use Mcnd\CLI\OptionValueTypeEnum;
|
||||||
|
use Notes\CLI\Attribute\{Option, Command};
|
||||||
|
use Psr\Http\Message\{ServerRequestInterface, ResponseInterface};
|
||||||
|
|
||||||
|
use Lean\Console\{Lib, };
|
||||||
|
|
||||||
|
# https://www.asciiart.eu/text-to-ascii-art
|
||||||
|
#[Command(description: PHP_EOL . <<<CLI
|
||||||
|
#[color:gray, bg: black]╔═════════════════════════╗[#]
|
||||||
|
#[color:gray, bg: black]║ _ ║[#]
|
||||||
|
#[color:gray, bg: black]║ | | ___ __ _ _ __ ║[#]
|
||||||
|
#[color:gray, bg: black]║ | | / _ \/ _` | '_ \ ║[#]
|
||||||
|
#[color:gray, bg: black]║ | |__| __/ (_| | | | | ║[#]
|
||||||
|
#[color:gray, bg: black]║ |_____\___|\__,_|_| |_| ║[#]
|
||||||
|
#[color:gray, bg: black]║ ║[#]
|
||||||
|
#[color:gray, bg: black]║ STORAGE ║[#]
|
||||||
|
#[color:gray, bg: black]╚═════════════════════════╝[#]
|
||||||
|
|
||||||
|
Try #[color:gray, bg: black]'cli lean-console storage --help'[#] for more information.
|
||||||
|
CLI
|
||||||
|
, command: 'lean-console storage')]
|
||||||
|
#[Option(switch: ['-h', '--help'], description: "Display help for the given command. When no command is given display help for the list command")]
|
||||||
|
#[Option(switch: ['-q', '--quiet'], description: "Do not output any message")]
|
||||||
|
#[Option(switch: ['-n', '--no-interaction'], description: "Run script without user interaction")]
|
||||||
|
#[Option(switch: ['-v', '-vv', '-vvv', '--verbose'], description: "Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug", value: OptionValueTypeEnum::OptionalValue)]
|
||||||
|
class Storage
|
||||||
|
{
|
||||||
|
use Lib\ConsoleControllerTrait;
|
||||||
|
|
||||||
|
#[Command(description: "Generate entities based on an existing connection", command: "entity:generate")]
|
||||||
|
#[Option(switch: ['-l', '--list'], description: "")]
|
||||||
|
public function generate_entity(ServerRequestInterface $request, array $arguments): ResponseInterface
|
||||||
|
{
|
||||||
|
dump($arguments);
|
||||||
|
|
||||||
|
return $this->renderCLI($request, ":)");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ class Console {
|
|||||||
|
|
||||||
$status = iterator_to_array($git->run("/usr/bin/git status -s"));
|
$status = iterator_to_array($git->run("/usr/bin/git status -s"));
|
||||||
$diff = iterator_to_array($git->run("/usr/bin/git diff"));
|
$diff = iterator_to_array($git->run("/usr/bin/git diff"));
|
||||||
|
$lastUpdate = iterator_to_array($git->run("/usr/bin/git show --no-patch --format=%ci"))[0] ?? null;
|
||||||
|
|
||||||
return $this->renderView("lean-console/page/update/index", get_defined_vars());
|
return $this->renderView("lean-console/page/update/index", get_defined_vars());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
namespace Lean\Console\Controller;
|
namespace Lean\Console\Controller;
|
||||||
|
|
||||||
use League\Route\Router;
|
use Picea\{Ui\Method\FormHandler};
|
||||||
use Picea\{FileFetcher, Picea, Caching\Opcache, Extension\UrlExtension, Ui\Method\FormHandler};
|
|
||||||
use Lean\File;
|
use Lean\File;
|
||||||
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
||||||
use Lean\Console\{ Form, Lib };
|
use Lean\Console\{ Form, Lib };
|
||||||
use Notes\Tell\Attribute\Language, Notes\Route\Attribute\Method\Route;
|
use Notes\Route\Attribute\Method\Route;
|
||||||
|
|
||||||
class Debugging extends Console {
|
class Debugging extends Console {
|
||||||
use Lib\ConsoleControllerTrait;
|
use Lib\ConsoleControllerTrait;
|
||||||
@@ -17,7 +16,7 @@ class Debugging extends Console {
|
|||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
new FormHandler($request, new Form\Debugging\Logs(), $this->pushContext(new Lib\FormContext($request, "debugging.logs")));
|
# new FormHandler($request, new Form\Debugging\Logs(), $this->pushContext(new Lib\FormContext($request, "debugging.logs")));
|
||||||
|
|
||||||
$path = getenv('LOGS_PATH');
|
$path = getenv('LOGS_PATH');
|
||||||
|
|
||||||
@@ -25,9 +24,9 @@ class Debugging extends Console {
|
|||||||
|
|
||||||
$default = basename(ini_get('error_log'));
|
$default = basename(ini_get('error_log'));
|
||||||
|
|
||||||
$open = end($files);
|
$open = File::sanitizeFilePath($request->getQueryParams()['logfile'] ?? end($files));
|
||||||
|
|
||||||
$content = File::tail($path . DIRECTORY_SEPARATOR . $open, 100);
|
$content = File::tail($path . DIRECTORY_SEPARATOR . $open, $request->getQueryParams()['line'] ?? 100);
|
||||||
|
|
||||||
return $this->renderView("lean-console/page/debugging/logs", get_defined_vars());
|
return $this->renderView("lean-console/page/debugging/logs", get_defined_vars());
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -27,7 +27,7 @@ class Storage extends Console {
|
|||||||
$migrations = $this->container->has(Lib\DatabaseMigrations::class) ? $this->container->get(Lib\DatabaseMigrations::class) : false;
|
$migrations = $this->container->has(Lib\DatabaseMigrations::class) ? $this->container->get(Lib\DatabaseMigrations::class) : false;
|
||||||
$migrations->getEntities();
|
$migrations->getEntities();
|
||||||
|
|
||||||
$context = (new FormHandler($request, new Form\Storage\DatabaseMigration($migrations)))->context;
|
$context = (new FormHandler($request, new Form\Storage\Database\Migrate($migrations), $this->pushContext(new Lib\FormContext($request, "database.migrate"))))->context;
|
||||||
|
|
||||||
return $this->renderView("lean-console/page/storage/database", get_defined_vars());
|
return $this->renderView("lean-console/page/storage/database", get_defined_vars());
|
||||||
}
|
}
|
||||||
@@ -39,13 +39,23 @@ class Storage extends Console {
|
|||||||
$migrations = $this->container->has(Lib\DatabaseMigrations::class) ? $this->container->get(Lib\DatabaseMigrations::class) : false;
|
$migrations = $this->container->has(Lib\DatabaseMigrations::class) ? $this->container->get(Lib\DatabaseMigrations::class) : false;
|
||||||
$migrations->getEntities();
|
$migrations->getEntities();
|
||||||
|
|
||||||
$form = new Form\Storage\DatabaseImport($migrations, $connections);
|
$form = new Form\Storage\Database\Import($migrations, $connections);
|
||||||
|
|
||||||
$context = (new FormHandler($request, $form, $this->pushContext(new Lib\FormContext($request, "database.import"))))->context;
|
$context = (new FormHandler($request, $form, $this->pushContext(new Lib\FormContext($request, "database.import"))))->context;
|
||||||
|
|
||||||
return $this->renderView("lean-console/page/storage/database_import", get_defined_vars());
|
return $this->renderView("lean-console/page/storage/database_import", get_defined_vars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route(route: "/storage/database/insert", name: "lean.console:storage.database_insert")]
|
||||||
|
public function insert(ServerRequestInterface $request, array $arguments) : ResponseInterface
|
||||||
|
{
|
||||||
|
$class = $request->getQueryParams()['source'] ?? $request->getParsedBody()['source'];
|
||||||
|
|
||||||
|
$context = (new FormHandler($request, new Form\Storage\Database\Insert(new $class())))->context;
|
||||||
|
|
||||||
|
return $this->renderView("lean-console/page/storage/database_insert", get_defined_vars());
|
||||||
|
}
|
||||||
|
|
||||||
#[Route(route: "/storage/session", name: "lean.console:storage.session")] # migrated from: "/storage/session", "name" => "lean.console:storage.session"
|
#[Route(route: "/storage/session", name: "lean.console:storage.session")] # migrated from: "/storage/session", "name" => "lean.console:storage.session"
|
||||||
public function session(ServerRequestInterface $request, array $arguments) : ResponseInterface
|
public function session(ServerRequestInterface $request, array $arguments) : ResponseInterface
|
||||||
{
|
{
|
||||||
@@ -74,12 +84,4 @@ class Storage extends Console {
|
|||||||
{
|
{
|
||||||
return rtrim(ini_get("session.save_path"), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
return rtrim(ini_get("session.save_path"), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createTable() : void
|
|
||||||
{
|
|
||||||
foreach($migrations->entities as $table) {
|
|
||||||
// $repository = $table
|
|
||||||
// $entity::repository()->createTable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Lean\Console\Form;
|
|
||||||
|
|
||||||
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
|
|
||||||
|
|
||||||
use \Lean\Console\Lib;
|
|
||||||
|
|
||||||
use Picea\Compiler\Context;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
|
||||||
use Ulmus\Common\EntityResolver;
|
|
||||||
use \Ulmus\Entity\InformationSchema\Table;
|
|
||||||
|
|
||||||
class Database implements FormInterface
|
|
||||||
{
|
|
||||||
protected ? Lib\DatabaseMigrations $migration;
|
|
||||||
|
|
||||||
public function __construct(Lib\DatabaseMigrations $migration)
|
|
||||||
{
|
|
||||||
$this->migration = $migration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function initialize(FormContextInterface $context) : void
|
|
||||||
{
|
|
||||||
$context->tableExist = [];
|
|
||||||
|
|
||||||
foreach($this->migration->entities as $entity => $table) {
|
|
||||||
$adapter = $entity::resolveEntity()->sqlAdapter()->adapter();
|
|
||||||
|
|
||||||
$tableName = $table->tableName();
|
|
||||||
$databaseName = $table->databaseName();
|
|
||||||
|
|
||||||
if ( ! $tableName || ! $databaseName ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#<<<<<<< HEAD
|
|
||||||
$tableEntity = $adapter->schemaTable($databaseName, $tableName);
|
|
||||||
|
|
||||||
if ( $tableEntity ) {
|
|
||||||
#$fields = $entiy::resolveEntity()->fieldList();
|
|
||||||
|
|
||||||
foreach($tableEntity->columns as $col) {
|
|
||||||
//dump( $entity::field($col->name) );
|
|
||||||
#=======
|
|
||||||
# $table = Table::repository()
|
|
||||||
# ->where(Table::field('name'), $table->tableName())
|
|
||||||
# ->where(Table::field('schema'), $table->databaseName())
|
|
||||||
# ->loadOne();
|
|
||||||
|
|
||||||
# if ( $table ) {
|
|
||||||
# $fields = $entity::resolveEntity()->fieldList(EntityResolver::KEY_COLUMN_NAME, true);
|
|
||||||
|
|
||||||
# $alter = [];
|
|
||||||
|
|
||||||
# foreach($fields as $field => $definition) {
|
|
||||||
# if ( $table->columns->filtersCollection(fn($e) => $e->name === $field)->count() === 0 ) {
|
|
||||||
# $alter[$field] = $definition;
|
|
||||||
# }
|
|
||||||
#>>>>>>> 7194a33bec884d745e838c8ac2693b353e95a3ce
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $alter ) {
|
|
||||||
$context->status[$entity] = [
|
|
||||||
'msg' => "alter",
|
|
||||||
"query" => $entity::repository()->alterSqlQuery($alter)->getSqlQuery(true),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# if columns are different
|
|
||||||
$context->status[$entity] = [
|
|
||||||
'msg' => "up-to-date",
|
|
||||||
'query' => "",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$context->status[$entity] = [
|
|
||||||
'msg' => "unexisting",
|
|
||||||
'query' => $entity::repository()->createSqlQuery()->getSqlQuery(true),
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $context->formSent() ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validate(FormContextInterface $context) : bool
|
|
||||||
{
|
|
||||||
return $context->valid();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(FormContextInterface $context) : void
|
|
||||||
{
|
|
||||||
if ( $context->create ?? false ) {
|
|
||||||
$context->create::repository()->createTable();
|
|
||||||
}
|
|
||||||
elseif ( $context->createAll ?? false ) {
|
|
||||||
foreach(explode(',', $context->createAll) as $entity) {
|
|
||||||
$entity::repository()->createTable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ( $context->alter ?? false ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->initialize($context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getContext(ServerRequestInterface $request) : FormContextInterface
|
|
||||||
{
|
|
||||||
return new class($request) extends FormContext {
|
|
||||||
|
|
||||||
public array $status = [];
|
|
||||||
|
|
||||||
public array $actions = [];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lean\Console\Form\Storage\Database;
|
||||||
|
|
||||||
|
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
|
||||||
|
|
||||||
|
use \Lean\Console\{ Lib, Entity };
|
||||||
|
|
||||||
|
use Picea\Compiler\Context;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Ulmus\{ EntityCollection };
|
||||||
|
|
||||||
|
class GenerateEntity implements FormInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initialize(FormContextInterface $context) : void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validate(FormContextInterface $context) : bool
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return $context->valid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(FormContextInterface $context) : void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Lean\Console\Form\Storage;
|
namespace Lean\Console\Form\Storage\Database;
|
||||||
|
|
||||||
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
|
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ use Picea\Compiler\Context;
|
|||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Ulmus\{ EntityCollection };
|
use Ulmus\{ EntityCollection };
|
||||||
|
|
||||||
class DatabaseImport implements FormInterface
|
class Import implements FormInterface
|
||||||
{
|
{
|
||||||
protected ? Lib\DatabaseMigrations $migration;
|
protected ? Lib\DatabaseMigrations $migration;
|
||||||
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lean\Console\Form\Storage\Database;
|
||||||
|
|
||||||
|
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
|
||||||
|
|
||||||
|
use \Lean\Console\{ Lib, Entity };
|
||||||
|
|
||||||
|
use Picea\Compiler\Context;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Ulmus\{Attribute\Property\Field, Entity\EntityInterface, Entity\Field\Datetime, EntityCollection};
|
||||||
|
|
||||||
|
class Insert implements FormInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected EntityInterface $entity
|
||||||
|
) { }
|
||||||
|
|
||||||
|
public function initialize(FormContextInterface $context) : void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validate(FormContextInterface $context) : bool
|
||||||
|
{
|
||||||
|
|
||||||
|
return $context->valid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(FormContextInterface $context) : void
|
||||||
|
{
|
||||||
|
foreach ($this->entity::resolveEntity()->fieldList() as $field) {
|
||||||
|
$type = $field->getTypes()[0];
|
||||||
|
$value = $context->{$field->name};
|
||||||
|
|
||||||
|
if (! $field->getAttribute(Field::class)->object->readonly) {
|
||||||
|
if ($type->isEnum() && $value) {
|
||||||
|
$this->entity->{$field->name} = $type->type::from($value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->entity->{$field->name} = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temp patch while fixing default value in sqlite
|
||||||
|
if (property_exists($this->entity, 'createdAt')) {
|
||||||
|
$this->entity->createdAt = new Datetime();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entity::repository()->save($this->entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Lean\Console\Form\Storage;
|
namespace Lean\Console\Form\Storage\Database;
|
||||||
|
|
||||||
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
|
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
|
||||||
|
|
||||||
@@ -10,8 +10,9 @@ use Picea\Compiler\Context;
|
|||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Ulmus\Common\EntityResolver;
|
use Ulmus\Common\EntityResolver;
|
||||||
use \Ulmus\Entity\InformationSchema\Table;
|
use \Ulmus\Entity\InformationSchema\Table;
|
||||||
|
use Ulmus\Ulmus;
|
||||||
|
|
||||||
class DatabaseMigration implements FormInterface
|
class Migrate implements FormInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected ? Lib\DatabaseMigrations $migration,
|
protected ? Lib\DatabaseMigrations $migration,
|
||||||
@@ -47,6 +48,11 @@ class DatabaseMigration implements FormInterface
|
|||||||
$this->definition[$entity]['columns'] = new Lib\Database\DefinitionCollection();
|
$this->definition[$entity]['columns'] = new Lib\Database\DefinitionCollection();
|
||||||
|
|
||||||
foreach($table->fieldList(EntityResolver::KEY_COLUMN_NAME, true) as $field => $definition) {
|
foreach($table->fieldList(EntityResolver::KEY_COLUMN_NAME, true) as $field => $definition) {
|
||||||
|
|
||||||
|
if ( isset($definition->value) ) {
|
||||||
|
$definition->value = $entity::repository()->adapter->adapter()->writableValue($definition->value);
|
||||||
|
}
|
||||||
|
|
||||||
$this->definition[$entity]['columns'][$field] = $def = new Lib\Database\Definition(
|
$this->definition[$entity]['columns'][$field] = $def = new Lib\Database\Definition(
|
||||||
entity: $entity,
|
entity: $entity,
|
||||||
field: $field,
|
field: $field,
|
||||||
@@ -60,17 +66,12 @@ class DatabaseMigration implements FormInterface
|
|||||||
# Column do not exists
|
# Column do not exists
|
||||||
if ( $column === null ) {
|
if ( $column === null ) {
|
||||||
$def->action = "add";
|
$def->action = "add";
|
||||||
|
|
||||||
$def->modifier = new Lib\Database\Modifier(
|
|
||||||
type: Lib\Database\ModifierTypeEnum::Alter,
|
|
||||||
query: $entity::repository()
|
|
||||||
->alterSqlQuery([ $def->toArray() ])
|
|
||||||
->getSqlQuery(true)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
elseif ( ! $column->matchFieldDefinition($definition) ) {
|
elseif ( ! $column->matchFieldDefinition($definition) ) {
|
||||||
$def->action = "change";
|
$def->action = "change";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($def->action && $adapter->supportAlterColumnAction($def->action)) {
|
||||||
$def->modifier = new Lib\Database\Modifier(
|
$def->modifier = new Lib\Database\Modifier(
|
||||||
type: Lib\Database\ModifierTypeEnum::Alter,
|
type: Lib\Database\ModifierTypeEnum::Alter,
|
||||||
query: $entity::repository()
|
query: $entity::repository()
|
||||||
@@ -80,7 +81,6 @@ class DatabaseMigration implements FormInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ALTER TABLE `ajustements` CHANGE `annee` `annee` INT(11) NULL;
|
|
||||||
$alter = $this->definition[$entity]['columns']->filterAlter();
|
$alter = $this->definition[$entity]['columns']->filterAlter();
|
||||||
|
|
||||||
if ( $alter->count() ) {
|
if ( $alter->count() ) {
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Lean\Console\Lib;
|
namespace Lean\Console\Lib;
|
||||||
|
|
||||||
|
use DI\Attribute\Inject;
|
||||||
use Notes\Attribute\Ignore;
|
use Notes\Attribute\Ignore;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
@@ -20,20 +21,14 @@ trait ConsoleControllerTrait
|
|||||||
{
|
{
|
||||||
use \Lean\ControllerTrait;
|
use \Lean\ControllerTrait;
|
||||||
|
|
||||||
|
#[Inject]
|
||||||
protected ContainerInterface $container;
|
protected ContainerInterface $container;
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function __construct(? Picea\Picea $picea, Session $session, ContainerInterface $container) {
|
|
||||||
$this->picea = $picea;
|
|
||||||
$this->session = $session;
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Ignore]
|
#[Ignore]
|
||||||
public function version() : string
|
public function version() : string
|
||||||
{
|
{
|
||||||
$version = iterator_to_array(
|
$version = iterator_to_array(
|
||||||
(new Form\Update\Git(getenv('PROJECT_PATH')))->run("/usr/bin/git describe --tags")
|
new Form\Update\Git(getenv('PROJECT_PATH'))->run("/usr/bin/git describe --tags")
|
||||||
);
|
);
|
||||||
|
|
||||||
# dump($version);
|
# dump($version);
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ use Notes\Common\ReflectedProperty;
|
|||||||
class Definition
|
class Definition
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $entity,
|
public string $entity,
|
||||||
public string|null $field = null,
|
public string|null $field = null,
|
||||||
public array|null|ReflectedProperty $definition = null,
|
public array|null|ReflectedProperty $definition = null,
|
||||||
public null|Modifier|array $modifier = null,
|
public null|Modifier|array $modifier = null,
|
||||||
public null|Definition $previous = null,
|
public null|Definition $previous = null,
|
||||||
public null|string $action = null,
|
public null|string $action = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function toArray() : array
|
public function toArray() : array
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class DatabaseMigrations
|
|||||||
foreach($this->folderList as $namespace => $folder) {
|
foreach($this->folderList as $namespace => $folder) {
|
||||||
foreach(static::files($folder) as $file) {
|
foreach(static::files($folder) as $file) {
|
||||||
$name = $file->getBasename("." . $file->getExtension());
|
$name = $file->getBasename("." . $file->getExtension());
|
||||||
$subNs = substr($file->getPath(), strlen($folder));
|
$subNs = ltrim(str_replace('/', '\\', substr($file->getPath(), strlen($folder))), '\\');
|
||||||
$entity = rtrim($namespace, "\\") . ( $subNs ? "\\$subNs" : "" ) . "\\{$name}";
|
$entity = rtrim($namespace, "\\") . ( $subNs ? "\\$subNs" : "" ) . "\\{$name}";
|
||||||
|
|
||||||
if ( ! method_exists($entity, 'resolveEntity') ) {
|
if ( ! method_exists($entity, 'resolveEntity') ) {
|
||||||
@@ -34,6 +34,8 @@ class DatabaseMigrations
|
|||||||
if ( $resolve->sqlAdapter()->adapter() instanceof SqlAdapterInterface) {
|
if ( $resolve->sqlAdapter()->adapter() instanceof SqlAdapterInterface) {
|
||||||
$this->entities[$entity] = $resolve;
|
$this->entities[$entity] = $resolve;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,3 +37,4 @@
|
|||||||
<li><a href="{% route 'lean.console:debugging-phpinfo' %}">{% lang "lean.nav.debugging.phpinfo" %}</a></li>
|
<li><a href="{% route 'lean.console:debugging-phpinfo' %}">{% lang "lean.nav.debugging.phpinfo" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
<hr>
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
<h2>{{ $path }}</h2>
|
<h2>{{ $path }}</h2>
|
||||||
|
|
||||||
{% ui:form.get current_url() %}
|
{% ui:form.get current_url() %}
|
||||||
{% ui:select 'logfile', array_combine($files, $files), get('file') ?? $open %}
|
<small>{% _ 'logs.line' %} {% ui:text 'line', get('line') ?? 100, [ 'onchange' => "this.closest('form').submit()" ] %}</small>
|
||||||
|
{% ui:select 'logfile', array_combine($files, $files), get('file') ?? $open, [ 'onchange' => "this.closest('form').submit()" ] %}
|
||||||
{% ui:endform %}
|
{% ui:endform %}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
{% function routeHtml($route) %}
|
{% function routeHtml($route) %}
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<strong class="col route-name">{{ $route->name }}</strong>
|
<strong class="col-2 route-name">{{ $route->name }}</strong>
|
||||||
<div class="col route-uri">{{ $route->getRoute() }}</div>
|
<div class="col-3 route-uri">{{ $route->getRoute() }}</div>
|
||||||
<div class="col route-methods">{{ implode(', ', (array) ( $route->method ?? $route->methods )) }}</div>
|
<div class="col-2 route-methods">{{ implode(', ', (array) ( $route->method ?? $route->methods )) }}</div>
|
||||||
<div class="col controller-method">
|
<div class="col controller-method">
|
||||||
<span class="class">{{ $route->class }}</span>::<span>{{ $route->classMethod }}</span>
|
<span class="class">{{ $route->class }}</span>::<span>{{ $route->classMethod }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,9 +28,9 @@
|
|||||||
<article class="routes">
|
<article class="routes">
|
||||||
{% if $routes %}
|
{% if $routes %}
|
||||||
<strong class="grid">
|
<strong class="grid">
|
||||||
<div class="col route-name">{% _ 'route.name' %}</div>
|
<div class="col-2 route-name">{% _ 'route.name' %}</div>
|
||||||
<div class="col route-uri">{% _ 'route.uri' %}</div>
|
<div class="col-3 route-uri">{% _ 'route.uri' %}</div>
|
||||||
<div class="col route-methods">{% _ 'route.methods' %}</div>
|
<div class="col-2 route-methods">{% _ 'route.methods' %}</div>
|
||||||
<div class="col controller-method">{% _ 'route.target' %}</div>
|
<div class="col controller-method">{% _ 'route.target' %}</div>
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
{% endsection %}
|
{% endsection %}
|
||||||
|
|
||||||
{% section "content" %}
|
{% section "content" %}
|
||||||
|
|
||||||
{% if $connections %}
|
{% if $connections %}
|
||||||
{% foreach $connections as $connection %}
|
{% foreach $connections as $connection %}
|
||||||
<section>
|
<section>
|
||||||
@@ -35,27 +34,34 @@
|
|||||||
|
|
||||||
<div class="tables">
|
<div class="tables">
|
||||||
<strong class="grid table-item">
|
<strong class="grid table-item">
|
||||||
<div class="col">{% _ 'database.table.name' %}</div>
|
<div class="col col-4">{% _ 'database.table.name' %}</div>
|
||||||
<div class="col">{% _ 'database.table.table-fields' %}</div>
|
<div class="col col-2 text-center">{% _ 'database.table.table-fields' %}</div>
|
||||||
<div class="col col-grow-2">{% _ 'database.table.query' %}</div>
|
<div class="col col-3 text-center">{% _ 'database.table.query' %}</div>
|
||||||
<div class="col text-right">{% _ 'database.table.actions' %}</div>
|
<div class="col col-2 text-center">{% _ 'database.table.count' %}</div>
|
||||||
|
<div class="col col-1 text-center">{% _ 'database.table.actions' %}</div>
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
{% ui:form.post "database" %}
|
{% ui:form.post "database.migrate", current_url() %}
|
||||||
{% foreach array_filter($migrations->entities, fn($e) => $e->databaseAdapter() === $connection) as $entity => $item %}
|
{% foreach array_filter($migrations->entities, fn($e) => $e->databaseAdapter() === $connection) as $entity => $item %}
|
||||||
<div class="grid table-item align-items-center">
|
<div class="grid table-item align-items-center">
|
||||||
<div class="col"><span>📄</span> <span>{{ $item->tableName() }}</span></div>
|
<div class="col col-4"><span>📄</span> <span>{{ $item->tableName() }}</span></div>
|
||||||
<div class="col">{% _ "database.table.fields", [ 'count' => count( $item->fieldList() ) ] %}</div>
|
<div class="col col-2 text-center">{% _ "database.table.fields", [ 'count' => count( $item->fieldList() ) ] %}</div>
|
||||||
<div class="col col-grow-2">
|
<div class="col col-3 text-center">
|
||||||
{% if $context->definition[$entity]['table']->modifier->query %}
|
{% if $context->definition[$entity]['table']->modifier->query ?? false %}
|
||||||
<code>{{= implode('<br><br>',(array) $context->definition[$entity]['table']->modifier->query) }}</code>
|
<code>{{= implode('<br><br>',(array) $context->definition[$entity]['table']->modifier->query) }}</code>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div style="color:#abecab">✓ {% _ 'database.table.uptodate' %}</div>
|
<div style="color:#abecab">✓ {% _ 'database.table.uptodate' %}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col">
|
<div class="col col-2 text-center">
|
||||||
{% switch $context->definition[$entity]['table']->modifier->type %}
|
{% if $context->definition[$entity]['table']->modifier->type !== ModifierTypeEnum::Create %}
|
||||||
|
{{ $entity::repository()->count() }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col col-1 text-center">
|
||||||
|
{% switch $context->definition[$entity]['table']->modifier->type ?? false %}
|
||||||
{% case ModifierTypeEnum::Create %}
|
{% case ModifierTypeEnum::Create %}
|
||||||
{% php $createAll[] = $entity %}
|
{% php $createAll[] = $entity %}
|
||||||
|
|
||||||
@@ -72,6 +78,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{% break %}
|
{% break %}
|
||||||
{% endswitch %}
|
{% endswitch %}
|
||||||
|
|
||||||
|
<div class="text-right">
|
||||||
|
<a href="{% route 'lean.console:storage.database_insert', [ 'source' => $entity ] %}" class="btn-gray">{% _ 'database.table.add-column' %}</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endforeach %}
|
{% endforeach %}
|
||||||
@@ -95,7 +105,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.databases strong.grid {background: #242528;color:#fff}
|
.databases strong.grid {background: #888a91;color:#fff}
|
||||||
|
|
||||||
.databases .db-grid {padding:0.66rem 0.3rem}
|
.databases .db-grid {padding:0.66rem 0.3rem}
|
||||||
.databases .db-grid strong {color:#444}
|
.databases .db-grid strong {color:#444}
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
{% use Ulmus\Attribute\Property\Field %}
|
||||||
|
{% use Lean\Console\Lib\Database\ModifierTypeEnum %}
|
||||||
|
|
||||||
|
{% extends "lean-console/base/layout" %}
|
||||||
|
|
||||||
|
{% language.set "lean.storage" %}
|
||||||
|
|
||||||
|
{% title _("title") %}
|
||||||
|
|
||||||
|
{% section "breadcrumb-items" %}
|
||||||
|
<li class="breadcrumb-item"><a href="{% route 'lean.console:storage.database' %}">{% _ 'database.breadcrumb' %}</a></li>
|
||||||
|
<li class="breadcrumb-item">{% _ 'database_insert.breadcrumb' %}</li>
|
||||||
|
{% endsection %}
|
||||||
|
|
||||||
|
{% section "content" %}
|
||||||
|
<section class="insert">
|
||||||
|
<header class="bg-yellow">
|
||||||
|
<h2>{{ $class }}</h2>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<div class="database_insert">
|
||||||
|
<div class="tables">
|
||||||
|
<strong class="grid table-item">
|
||||||
|
<div class="col">{% _ 'database_insert.table.column' %}</div>
|
||||||
|
<div class="col">{% _ 'database_insert.table.type' %}</div>
|
||||||
|
<div class="col text-center">{% _ 'database_insert.table.attributes' %}</div>
|
||||||
|
<div class="col col-grow-4 text-center">{% _ 'database_insert.table.value' %}</div>
|
||||||
|
</strong>
|
||||||
|
|
||||||
|
{% ui:form.post "database.insert", current_url(get()) %}
|
||||||
|
{% foreach $class::resolveEntity()->fieldList() as $field %}
|
||||||
|
<div class="grid table-item align-items-center column-item">
|
||||||
|
<div class="col">
|
||||||
|
<span>{{ $field->name }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col ">
|
||||||
|
{% foreach $field->getTypes() as $type %}
|
||||||
|
<span title="{{ $type->type }}">{{ $type->isObject() ? substr($type->type, strrpos($type->type, '\\') + 1) : $type->type }}</span>
|
||||||
|
{% endforeach %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col attributes text-center">
|
||||||
|
{% foreach $field->attributes as $attribute %}
|
||||||
|
<span class="attribute" title="{% json.pretty.html $attribute->object %}">{{ $attribute->tag }}</span>
|
||||||
|
{% endforeach %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col col-grow-4">
|
||||||
|
{% foreach $field->getTypes() as $type %}
|
||||||
|
{% php $attr = $field->getAttribute(Field::class)->object->readonly ? [ 'disabled' => 'disabled', 'placeholder' => _('database_insert.readonly') ] : [] %}
|
||||||
|
|
||||||
|
{% if enum_exists($type->type) %}
|
||||||
|
{% php $enum = array_map(fn($e) => $e->value, $type->type::cases()) %}
|
||||||
|
|
||||||
|
{% if $type->nullable %}
|
||||||
|
{% php $enum = [ null => null ] + $enum %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% ui:select $field->name, array_combine($enum, $enum), $context->{$field->name}, $attr %}
|
||||||
|
{% else %}
|
||||||
|
{% ui:text $field->name, $context->{$field->name}, $attr %}
|
||||||
|
{% endif %}
|
||||||
|
{% endforeach %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# <div class="col">{% _ "database.table.fields", [ 'count' => count( $item->fieldList() ) ] %}</div>
|
||||||
|
<div class="col">
|
||||||
|
{% if $context->definition[$entity]['table']->modifier->query ?? false %}
|
||||||
|
<code>{{= implode('<br><br>',(array) $context->definition[$entity]['table']->modifier->query) }}</code>
|
||||||
|
{% else %}
|
||||||
|
<div style="color:#abecab">✓ {% _ 'database.table.uptodate' %}</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
</div> #}
|
||||||
|
</div>
|
||||||
|
{% endforeach %}
|
||||||
|
|
||||||
|
<div class="grid table-item">
|
||||||
|
<div class="col"></div>
|
||||||
|
<div class="col"></div>
|
||||||
|
<div class="col text-center"></div>
|
||||||
|
<div class="col col-grow-4 text-right py-2">
|
||||||
|
<button type="submit" class="btn-yellow">{% _ 'database_insert.add' %}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% ui:endform %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#main-content .insert article {background: #6a6a6a;padding:10px;}
|
||||||
|
|
||||||
|
select, input:not([type="file"]):not([type="button"]) {display: block;width: 100%;height: calc(2rem + 2px);padding: .375rem .75rem;font-size: 1rem;line-height: 1.5;color: #495057;background-color: #fff;background-clip: padding-box;border: 1px solid #ced4da; border-radius: 0; transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;}
|
||||||
|
select:disabled, input[disabled] {filter: contrast(60%);}
|
||||||
|
.database_insert strong.grid {background: #888a91;color:#fff}
|
||||||
|
|
||||||
|
.database_insert .db-grid {padding:0.66rem 0.3rem}
|
||||||
|
.database_insert .db-grid strong {color:#444}
|
||||||
|
.database_insert .db-grid:nth-child(even) {background: #e3e3e3;line-height: 1.5em;font-size: 1.3em;}
|
||||||
|
|
||||||
|
.database_insert .tables {color:#fff}
|
||||||
|
.database_insert .tables .table-item {padding:0.33rem 0;background:rgba(255,255,255,0.1);line-height: 1.8em;}
|
||||||
|
.database_insert .tables .table-item:nth-child(even) {background:rgba(255,255,255,0.2)}
|
||||||
|
.database_insert .attribute {display: inline-block;padding: .25em .4em 0 .4em;font-size: 70%;font-weight: 700;line-height: 1.2rem;text-align: center;white-space: nowrap;vertical-align: baseline;border-radius: .25rem;color:#ffe300; border:1px solid #ffe300}
|
||||||
|
.database_insert summary {background: #172841;color:#fff;margin: 0 -8px 0 -8px;padding:7px 10px}
|
||||||
|
|
||||||
|
.tables {background: #2d3137; #fff;padding: 2px 10px;}
|
||||||
|
.tables label {padding:10px 5px;display:block}
|
||||||
|
section + section { margin-top:15px; }
|
||||||
|
</style>
|
||||||
|
{% endsection %}
|
||||||
@@ -4,6 +4,30 @@
|
|||||||
|
|
||||||
{% title _("title") %}
|
{% title _("title") %}
|
||||||
|
|
||||||
|
|
||||||
|
{% function setStatusModifierClass($line) : string %}
|
||||||
|
{% return match(substr($line, 0, 2)) {
|
||||||
|
'??' => "action-add",
|
||||||
|
default => false,
|
||||||
|
} ?: match(substr($line, 0, 1)) {
|
||||||
|
'M' => "action-delete",
|
||||||
|
default => "",
|
||||||
|
}%}
|
||||||
|
{% endfunction %}
|
||||||
|
|
||||||
|
{% function setDiffModifierClass($line) : string %}
|
||||||
|
{% return match(substr($line, 0, 2)) {
|
||||||
|
'--' => "action-delete",
|
||||||
|
'++' => "action-add",
|
||||||
|
'@@' => "action-group",
|
||||||
|
default => false,
|
||||||
|
} ?: match(substr($line, 0, 1)) {
|
||||||
|
'-' => "action-delete",
|
||||||
|
'+' => "action-add",
|
||||||
|
default => "",
|
||||||
|
}%}
|
||||||
|
{% endfunction %}
|
||||||
|
|
||||||
{% section "content" %}
|
{% section "content" %}
|
||||||
<section>
|
<section>
|
||||||
<header>
|
<header>
|
||||||
@@ -16,11 +40,11 @@
|
|||||||
|
|
||||||
<code style="white-space:normal;font-size:120%">
|
<code style="white-space:normal;font-size:120%">
|
||||||
{% foreach $status as $line %}
|
{% foreach $status as $line %}
|
||||||
<div>
|
<div class="{{ setStatusModifierClass($line) }}">
|
||||||
{% if $line %}
|
{% if $line %}
|
||||||
{{ $line }}
|
{{ $line }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endforeach %}
|
{% endforeach %}
|
||||||
</code>
|
</code>
|
||||||
</div>
|
</div>
|
||||||
@@ -30,7 +54,7 @@
|
|||||||
|
|
||||||
<code style="white-space:normal;font-size:120%">
|
<code style="white-space:normal;font-size:120%">
|
||||||
{% foreach $diff as $line %}
|
{% foreach $diff as $line %}
|
||||||
<div>
|
<div class="{{ setDiffModifierClass($line) }}">
|
||||||
{% if $line %}
|
{% if $line %}
|
||||||
{{ $line }}
|
{{ $line }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -39,5 +63,14 @@
|
|||||||
</code>
|
</code>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
<footer>
|
||||||
|
{{ $lastUpdate }}
|
||||||
|
</footer>
|
||||||
</section>
|
</section>
|
||||||
{% endsection %}
|
{% endsection %}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.action-delete {color:#f88}
|
||||||
|
.action-add {color: #88ff8a}
|
||||||
|
.action-group {color:#88bcff}
|
||||||
|
</style>
|
||||||
Reference in new issue
Block a user