From f01f88b3bda54bc8e6fae29a07fd48265725d299 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 12 Apr 2023 08:17:57 +1000 Subject: [PATCH] Work on DN edit rendering --- app/Classes/LDAP/Attribute.php | 5 +- app/Classes/LDAP/Attribute/ObjectClass.php | 29 +++++++-- app/Classes/LDAP/Schema/AttributeType.php | 1 + app/Http/Controllers/HomeController.php | 18 ++++-- public/css/fixes.css | 18 +++++- .../architect/views/auth/login.blade.php | 2 +- .../layouts/partials/contentheader.blade.php | 59 +++++++++++-------- .../layouts/partials/sidebarmenu.blade.php | 2 +- .../views/components/attribute.blade.php | 4 +- .../attribute/binary/jpegphoto.blade.php | 3 +- .../attribute/objectclass.blade.php | 13 ++-- .../components/attribute/password.blade.php | 2 +- resources/views/frames/dn.blade.php | 38 ++++++++++-- resources/views/home.blade.php | 14 +++-- 14 files changed, 147 insertions(+), 61 deletions(-) diff --git a/app/Classes/LDAP/Attribute.php b/app/Classes/LDAP/Attribute.php index 4cab883..be5f300 100644 --- a/app/Classes/LDAP/Attribute.php +++ b/app/Classes/LDAP/Attribute.php @@ -25,9 +25,6 @@ class Attribute // Current and Old Values protected Collection $values; - // Can this attribute be deleted - protected bool $is_deletable = FALSE; - // Is this attribute an internal attribute protected bool $is_internal = FALSE; @@ -129,6 +126,8 @@ class Attribute 'description' => $this->schema ? $this->schema->{$key} : NULL, // Attribute hints 'hints' => $this->hints(), + // Can this attribute be edited + 'is_editable' => $this->schema ? $this->schema->{$key} : NULL, // Is this an internal attribute 'is_internal' => isset($this->{$key}) && $this->{$key}, // Is this attribute the RDN diff --git a/app/Classes/LDAP/Attribute/ObjectClass.php b/app/Classes/LDAP/Attribute/ObjectClass.php index 1fb0cbc..f297d1a 100644 --- a/app/Classes/LDAP/Attribute/ObjectClass.php +++ b/app/Classes/LDAP/Attribute/ObjectClass.php @@ -3,6 +3,7 @@ namespace App\Classes\LDAP\Attribute; use Illuminate\Contracts\View\View; +use Illuminate\Support\Collection; use App\Classes\LDAP\Attribute; @@ -11,15 +12,33 @@ use App\Classes\LDAP\Attribute; */ final class ObjectClass extends Attribute { - public function __get(string $key): mixed + // Which of the values is the structural object class + protected Collection $structural; + + public function __construct(string $name,array $values) { - switch ($key) { - case 'is_structural': return FALSE; // @todo - need to determine which of the values is the structural objectclass value(s) - default: - return parent::__get($key); + parent::__construct($name,$values); + + $this->structural = collect(); + + // Determine which of the values is the structural objectclass + foreach ($values as $oc) { + if (config('server')->schema('objectclasses',$oc)->isStructural()) + $this->structural->push($oc); } } + /** + * Is a specific value the structural objectclass + * + * @param string $value + * @return bool + */ + public function isStructural(string $value): bool + { + return $this->structural->search($value) !== FALSE; + } + public function render(bool $edit=FALSE): View { return view('components.attribute.objectclass') diff --git a/app/Classes/LDAP/Schema/AttributeType.php b/app/Classes/LDAP/Schema/AttributeType.php index 38bce96..acaa319 100644 --- a/app/Classes/LDAP/Schema/AttributeType.php +++ b/app/Classes/LDAP/Schema/AttributeType.php @@ -257,6 +257,7 @@ final class AttributeType extends Base { case 'children': return $this->children; case 'forced_as_may': return $this->forced_as_may; case 'is_collective': return $this->is_collective; + case 'is_editable': return ! $this->is_no_user_modification; case 'is_no_user_modification': return $this->is_no_user_modification; case 'is_single_value': return $this->is_single_value; case 'equality': return $this->equality; diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 6cf7c3b..9ec4bee 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -39,9 +39,12 @@ class HomeController extends Controller { $dn = Crypt::decryptString($request->post('key')); + $page_actions = collect(['edit'=>TRUE,'copy'=>TRUE]); + return view('frames.dn') ->with('o',config('server')->fetch($dn)) - ->with('dn',$dn); + ->with('dn',$dn) + ->with('page_actions',$page_actions); } public function entry_update(EntryRequest $request) @@ -56,7 +59,8 @@ class HomeController extends Controller Session::put('dn',$request->dn); if (! $dirty=$o->getDirty()) - return back()->with(['note'=>__('No attributes changed')]); + return back() + ->with('note',__('No attributes changed')); try { $o->update($request->except(['_token','dn'])); @@ -66,7 +70,8 @@ class HomeController extends Controller switch ($x=$e->getDetailedError()->getErrorCode()) { case 50: - return back()->withErrors(sprintf('%s: %s (%s)',__('LDAP Server Error Code'),$x,__($e->getDetailedError()->getErrorMessage()))); + return back() + ->withErrors(sprintf('%s: %s (%s)',__('LDAP Server Error Code'),$x,__($e->getDetailedError()->getErrorMessage()))); default: abort(599,$e->getDetailedError()->getErrorMessage()); @@ -77,7 +82,8 @@ class HomeController extends Controller switch ($x=$e->getDetailedError()->getErrorCode()) { case 8: - return back()->withErrors(sprintf('%s: %s (%s)',__('LDAP Server Error Code'),$x,__($e->getDetailedError()->getErrorMessage()))); + return back() + ->withErrors(sprintf('%s: %s (%s)',__('LDAP Server Error Code'),$x,__($e->getDetailedError()->getErrorMessage()))); default: abort(599,$e->getDetailedError()->getErrorMessage()); @@ -85,8 +91,8 @@ class HomeController extends Controller } return back() - ->with(['success'=>__('Entry updated')]) - ->with(['updated'=>$dirty]); + ->with('success',__('Entry updated')) + ->with('updated',$dirty); } /** diff --git a/public/css/fixes.css b/public/css/fixes.css index fc78190..8430e33 100644 --- a/public/css/fixes.css +++ b/public/css/fixes.css @@ -216,4 +216,20 @@ p { margin: 5px 0 0; } } -*/ \ No newline at end of file +*/ + +/** Ensure our DN menu is at the top **/ +.app-page-title .page-title-wrapper { + align-items: start; +} + +/** Change the background on our read-only form items **/ +.form-control:disabled, .form-control[readonly] { + background-color: #f9f9f9; +} + +/** Make our placeholder text on forms lighter **/ + +.form-control::placeholder { + color: #a0aec0; +} \ No newline at end of file diff --git a/resources/themes/architect/views/auth/login.blade.php b/resources/themes/architect/views/auth/login.blade.php index 16cf868..e642977 100644 --- a/resources/themes/architect/views/auth/login.blade.php +++ b/resources/themes/architect/views/auth/login.blade.php @@ -91,7 +91,7 @@ } - @append \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 94281cb..5af0c2b 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -40,11 +40,15 @@ @if(file_exists('home-note.html'))
-
-
NOTE
- - {!! file_get_contents('home-note.html') !!} - +
+
+
+
NOTE
+ + {!! file_get_contents('home-note.html') !!} + +
+
@endif @endsection