From bf1bec644baaa1501304dbcb6c46e77ff1322386 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 22 Mar 2023 19:09:37 -0400 Subject: [PATCH] - Still WIP on storage and a new Update function also started --- composer.json | 2 +- meta/i18n/en/lean.nav.json | 3 +- meta/i18n/fr/lean.update.json | 7 +++ src/Controller/Console.php | 13 ++++- src/Form/Update/Git.php | 49 +++++++++++++++++++ view/lean-console/base/asset/lean.css | 15 +++--- view/lean-console/base/console/main-nav.phtml | 1 + view/lean-console/page/update/index.phtml | 33 +++++++++++++ 8 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 meta/i18n/fr/lean.update.json create mode 100644 src/Form/Update/Git.php create mode 100644 view/lean-console/page/update/index.phtml diff --git a/composer.json b/composer.json index 9dde68c..8909bda 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "authors": [ { "name": "Dave Mc Nicoll", - "email": "mcndave@gmail.com" + "email": "info@mcnd.ca" } ], "require": { diff --git a/meta/i18n/en/lean.nav.json b/meta/i18n/en/lean.nav.json index 000e983..4aa6110 100644 --- a/meta/i18n/en/lean.nav.json +++ b/meta/i18n/en/lean.nav.json @@ -1,7 +1,8 @@ { "lean": { "label": "Lean", - "dashboard": "Dashboard" + "dashboard": "Dashboard", + "update": "Update(s)" }, "storage": { diff --git a/meta/i18n/fr/lean.update.json b/meta/i18n/fr/lean.update.json new file mode 100644 index 0000000..0758a4d --- /dev/null +++ b/meta/i18n/fr/lean.update.json @@ -0,0 +1,7 @@ +{ + "title" : "Console -- LEAN", + "page-title": "Console", + "breadcrumb" : { + "index" : "Negundo" + } +} diff --git a/src/Controller/Console.php b/src/Controller/Console.php index 5f5a2eb..21aeb18 100644 --- a/src/Controller/Console.php +++ b/src/Controller/Console.php @@ -2,11 +2,12 @@ namespace Lean\Console\Controller; +use Picea\Ui\Method\FormHandler; use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface }; use Notes\Tell\Attribute\Language, Notes\Route\Attribute\Method\Route; -use \Lean\Console\Lib; +use \Lean\Console\{ Lib, Form }; #[Language("lean.console")] class Console { @@ -19,4 +20,14 @@ class Console { ]); } + + #[Route(route: "/update", name: "lean.console:update")] + public function update(ServerRequestInterface $request, array $arguments) : ResponseInterface + { + new FormHandler($request, $git = new Form\Update\Git(getenv('PROJECT_PATH'))); + + $status = iterator_to_array($git->run("/usr/bin/git status -s")); + + return $this->renderView("lean-console/page/update/index", get_defined_vars()); + } } \ No newline at end of file diff --git a/src/Form/Update/Git.php b/src/Form/Update/Git.php new file mode 100644 index 0000000..76378ee --- /dev/null +++ b/src/Form/Update/Git.php @@ -0,0 +1,49 @@ +valid(); + } + + public function execute(FormContextInterface $context) : void + { + + } + + public function run(string $command) : \Generator + { + $command = escapeshellcmd($command); + + $handle = popen("$command", 'r'); + + while ( false !== $output = fgets($handle, 2096) ){ + yield trim($output); + } + + pclose($handle); + } +} \ No newline at end of file diff --git a/view/lean-console/base/asset/lean.css b/view/lean-console/base/asset/lean.css index 05a6fa8..589b2c7 100644 --- a/view/lean-console/base/asset/lean.css +++ b/view/lean-console/base/asset/lean.css @@ -8,21 +8,21 @@ .text-center{text-align:center;}.text-right{text-align:right}.text-left{text-align:left;} -[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; font-size: 1rem; 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); } +[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); } [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-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);} -code {white-space:pre;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;} h1 {font-size:2rem;color:#525960} body {font-family:Helvetica Neue, Helvetica, Arial, sans-serif;} summary {cursor:pointer;} -#body-main {background:#ccc;min-height:calc(100vh - 90px);display:flex} +#body-main {background:#dfe3f9;min-height:calc(100vh - 90px);display:flex} /* Header */ -#body-header {background: #5e5e5e; color:#fff; min-height:60px;line-height:60px;padding:0 1rem} +#body-header {background: #5e5e5e; color:#fff; min-height:60px;line-height:60px;padding:0 1rem;border-bottom: 2px solid #9b9595;} #body-header .page-title {font-size:1.5rem} #body-header .page-title:before {content:"🔳"; margin-right:10px} @@ -41,7 +41,6 @@ summary {cursor:pointer;} /* Main content */ #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;font-size:1.4em;color: #4b4848 -} -#main-content section footer {background:#f9f9f9;padding:2vh 1vw;} \ No newline at end of file +#main-content section article {font-family: Courier New , Courier, monospace;font-size: 0.8em;background:#fff;padding:2vh 1vw;} +#main-content section header {background:#e8e8e8;padding:2vh 1vw;font-size:1.4em;color: #4b4848;border-top-left-radius: 4px;border-top-right-radius: 4px;} +#main-content section footer {background:#f9f9f9;padding:2vh 1vw;border-bottom-left-radius: 4px;bottom: 4px;} \ No newline at end of file diff --git a/view/lean-console/base/console/main-nav.phtml b/view/lean-console/base/console/main-nav.phtml index a83b92d..a9bb6df 100644 --- a/view/lean-console/base/console/main-nav.phtml +++ b/view/lean-console/base/console/main-nav.phtml @@ -2,6 +2,7 @@ diff --git a/view/lean-console/page/update/index.phtml b/view/lean-console/page/update/index.phtml new file mode 100644 index 0000000..c24e3e8 --- /dev/null +++ b/view/lean-console/page/update/index.phtml @@ -0,0 +1,33 @@ +{% extends "lean-console/base/layout" %} + +{% language.set "lean.update" %} + +{% title _("title") %} + +{% section "header" %} +
{% _ "page-title" %}
+{% endsection %} + +{% section "content" %} +
+
+

{% _ 'git.header' %}

+
+ +
+
+ 'git status' output + + + {% foreach $status as $line %} +
+ {% if $line %} + {{ $line }} + {% endif %} +
+ {% endforeach %} +
+
+
+
+{% endsection %} \ No newline at end of file