- Merged latest commit and pushed modifications
This commit is contained in:
commit
e78492d398
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Lean\Console\Controller;
|
||||
|
||||
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
||||
|
||||
use Notes\Route\Annotation\Object\Route as RouteParam,
|
||||
Notes\Route\Annotation\Method\Route,
|
||||
Notes\Security\Annotation\Security,
|
||||
Notes\Tell\Annotation\Language;
|
||||
|
||||
use \Lean\Console\Lib;
|
||||
|
||||
/**
|
||||
* @Language("lean.dev")
|
||||
*/
|
||||
class Dev {
|
||||
use Lib\ConsoleControllerTrait;
|
||||
|
||||
/**
|
||||
* @Route("/phpinfo", "name" => "lean.dev:phpinfo")
|
||||
*/
|
||||
public function home(ServerRequestInterface $request, array $arguments) : ResponseInterface
|
||||
{
|
||||
phpinfo();
|
||||
die();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ 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
|
||||
|
@ -33,6 +34,7 @@ class Database implements FormInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
#<<<<<<< HEAD
|
||||
$tableEntity = $adapter->schemaTable($databaseName, $tableName);
|
||||
|
||||
if ( $tableEntity ) {
|
||||
|
@ -40,13 +42,37 @@ class Database implements FormInterface
|
|||
|
||||
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 columns are different
|
||||
$context->status[$entity] = [
|
||||
'msg' => "up-to-date",
|
||||
'query' => "",
|
||||
];
|
||||
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] = [
|
||||
|
@ -77,6 +103,9 @@ class Database implements FormInterface
|
|||
$entity::repository()->createTable();
|
||||
}
|
||||
}
|
||||
elseif ( $context->alter ?? false ) {
|
||||
|
||||
}
|
||||
|
||||
$this->initialize($context);
|
||||
}
|
||||
|
@ -90,4 +119,4 @@ class Database implements FormInterface
|
|||
public array $actions = [];
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ use Picea;
|
|||
/**
|
||||
* @Language("lean.route")
|
||||
* @RouteParam("methods" => [ 'GET', 'POST', 'DELETE' ], "base" => "/~")
|
||||
* @Security('locked' => false)
|
||||
* @Security('locked' => true)
|
||||
* @Taxus("admin")
|
||||
*/
|
||||
trait ConsoleControllerTrait
|
||||
{
|
||||
|
@ -23,6 +24,5 @@ trait ConsoleControllerTrait
|
|||
$this->picea = $picea;
|
||||
$this->session = $session;
|
||||
$this->container = $container;
|
||||
// $this->mailer = $mailer;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,8 @@ class DatabaseMigrations
|
|||
$this->entities[$entity] = $entity::resolveEntity();
|
||||
}
|
||||
}
|
||||
|
||||
ksort($this->entities);
|
||||
}
|
||||
|
||||
protected static function files(string $path, string $fileExtension = "") : \Generator
|
||||
|
|
|
@ -20,15 +20,15 @@ summary {cursor:pointer;}
|
|||
#body-main {background:#ccc;min-height:calc(100vh - 90px);display:flex}
|
||||
|
||||
/* Header */
|
||||
#body-header {background: #385075; color:#fff; min-height:60px;line-height:60px;padding:0 1rem}
|
||||
#body-header {background: #6b7fa8; color:#fff; min-height:60px;line-height:60px;padding:0 1rem}
|
||||
#body-header .page-title {font-size:1.5rem}
|
||||
#body-header .page-title:before {content:"🔳"; margin-right:10px}
|
||||
|
||||
/* Footer */
|
||||
#body-footer {background: #2e2e30;color: #fff;height: 30px;line-height: 30px;font-size: 0.8rem;padding: 0 0.5rem;text-align: right;border-top:2px solid #434446;}
|
||||
#body-footer {background: #475262;color: #fff;height: 30px;line-height: 30px;font-size: 0.8rem;padding: 0 0.5rem;text-align: right;border-top:2px solid #434446;}
|
||||
|
||||
/* Sidebar */
|
||||
#main-nav {background:#393a3c;border-top:2px solid #172842;min-width:210px;color:#fff;font-family:consolas, courier new, monospace;font-size:0.9rem}
|
||||
#main-nav {background:#6b7fa8;border-top:2px solid #44526f;min-width:210px;color:#fff;font-family:consolas, courier new, monospace;font-size:0.9rem}
|
||||
#main-nav label {background:rgba(0,0,0,0.2);text-transform:uppercase ; display:block;padding:0.8rem 1rem;font-size:1.15em;}
|
||||
#main-nav label:before {content:"⊙"; margin-right:10px}
|
||||
#main-nav a {color: #efecec;text-decoration:none;display:block;padding:0rem 1rem;background:rgba(255,255,255,0.05);transition:all 0.3s ease;line-height:3em;font-size:0.9em}
|
||||
|
@ -37,7 +37,7 @@ summary {cursor:pointer;}
|
|||
#main-nav li + li {border-top:1px solid #555}
|
||||
|
||||
/* Main content */
|
||||
#main-content {padding:4vh 2vw;border-top:2px solid #172842;width:100%;}
|
||||
#main-content {padding:4vh 2vw;border-top:2px solid #7d7d7d;width:100%;}
|
||||
#main-content section {border-radius:4px;box-shadow: 1px 1px 3px rgba(0,0,0,0.5)}
|
||||
#main-content section article {background:#fff;padding:2vh 1vw;}
|
||||
#main-content section header {background:#e8e8e8;padding:2vh 1vw;}
|
|
@ -55,6 +55,7 @@
|
|||
<div>🗸 This table is up-to-date</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
{% switch $context->status[$entity]['msg'] %}
|
||||
{% case 'unexisting' %}
|
||||
|
@ -64,6 +65,14 @@
|
|||
<button name="create" value="{{$entity}}" class="btn-blue">🗸 {% _ 'database.table.create' %}</button>
|
||||
</div>
|
||||
{% break %}
|
||||
|
||||
{% case 'altering' %}
|
||||
{% php $alter[] = $entity %}
|
||||
|
||||
<div class="text-right">
|
||||
<button name="create" value="{{$entity}}" class="btn-blue">🗸 {% _ 'database.table.alter' %}</button>
|
||||
</div>
|
||||
{% break %}
|
||||
{% endswitch %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue