Compare commits

...

7 Commits

Author SHA1 Message Date
52d808071c Revert version to 2.2.1-dev
All checks were successful
Create Docker Image / Test Application (x86_64) (push) Successful in 28s
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 1m34s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 2m50s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-07-03 13:17:25 +08:00
305ef0f5a3 Minor code consistency changes, no functional changes 2025-07-03 13:17:25 +08:00
f1316d698d Implement DN Entry rename 2025-07-03 13:17:25 +08:00
339ba7258a Make the ajax calls POST methods, and make the 'Create Entry' in the tree configurable so calls to children() can just return child entries 2025-07-03 13:17:25 +08:00
883ac5d90f Dont render delete button on Entries that have subordinates 2025-07-03 13:17:13 +08:00
46277146c5 Fix rendering of Add Value attributes when the attribute is also rendered by a template, resulting in double javascript and blank values 2025-07-03 13:16:58 +08:00
06747064d4 Fix add new attributes where being marked as readonly 2025-07-03 13:16:58 +08:00
15 changed files with 138 additions and 49 deletions

View File

@ -48,7 +48,7 @@ Entry Editing:
- [ ] JpegPhoto Create/Delete - [ ] JpegPhoto Create/Delete
- [ ] Binary attribute upload - [ ] Binary attribute upload
- [ ] If removing an objectClass, remove all attributes that only that objectclass provided - [ ] If removing an objectClass, remove all attributes that only that objectclass provided
- [ ] Rename an entry - [ ] Move an entry
- [ ] Group membership selection - [ ] Group membership selection
- [ ] Attribute tag creation - [ ] Attribute tag creation

View File

@ -172,6 +172,8 @@ class Attribute implements \Countable, \ArrayAccess
'required_by' => $this->schema?->required_by_object_classes ?: collect(), 'required_by' => $this->schema?->required_by_object_classes ?: collect(),
// Used in Object Classes // Used in Object Classes
'used_in' => $this->schema?->used_in_object_classes ?: collect(), 'used_in' => $this->schema?->used_in_object_classes ?: collect(),
// For single value attributes
'value' => $this->schema?->is_single_value ? $this->values->first() : NULL,
// The current attribute values // The current attribute values
'values' => ($this->no_attr_tags || $this->is_internal) ? $this->tagValues() : $this->_values, 'values' => ($this->no_attr_tags || $this->is_internal) ? $this->tagValues() : $this->_values,
// The original attribute values // The original attribute values

View File

@ -38,7 +38,7 @@ class AjaxController extends Controller
*/ */
public function children(Request $request): Collection public function children(Request $request): Collection
{ {
$dn = Crypt::decryptString($request->query('_key')); $dn = Crypt::decryptString($request->post('_key'));
// Sometimes our key has a command, so we'll ignore it // Sometimes our key has a command, so we'll ignore it
if (str_starts_with($dn,'*') && ($x=strpos($dn,'|'))) if (str_starts_with($dn,'*') && ($x=strpos($dn,'|')))
@ -57,13 +57,18 @@ class AjaxController extends Controller
'tooltip'=>$item->getDn(), 'tooltip'=>$item->getDn(),
]) ])
->prepend( ->prepend(
[ $request->create
'title'=>sprintf('[%s]',__('Create Entry')), ? [
'item'=>Crypt::encryptString(sprintf('*%s|%s','create',$dn)), 'title'=>sprintf('[%s]',__('Create Entry')),
'lazy'=>FALSE, 'item'=>Crypt::encryptString(sprintf('*%s|%s','create',$dn)),
'icon'=>'fas fa-fw fa-square-plus text-warning', 'lazy'=>FALSE,
'tooltip'=>__('Create new LDAP item here'), 'icon'=>'fas fa-fw fa-square-plus text-warning',
]); 'tooltip'=>__('Create new LDAP item here'),
]
: []
)
->filter()
->values();
} }
public function schema_view(Request $request) public function schema_view(Request $request)

View File

@ -29,7 +29,7 @@ class HomeController extends Controller
{ {
private const LOGKEY = 'CHc'; private const LOGKEY = 'CHc';
private const INTERNAL_POST = ['_auto_value','_key','_rdn','_rdn_value','_step','_template','_token','_userpassword_hash']; private const INTERNAL_POST = ['_auto_value','_key','_rdn','_rdn_new','_rdn_value','_step','_template','_token','_userpassword_hash'];
/** /**
* Create a new object in the LDAP server * Create a new object in the LDAP server
@ -206,7 +206,7 @@ class HomeController extends Controller
} }
return Redirect::to('/') return Redirect::to('/')
->with('success',[sprintf('%s: %s',__('Deleted'),$dn)]); ->with('success',sprintf('%s: %s',__('Deleted'),$dn));
} }
public function entry_export(Request $request,string $id): \Illuminate\View\View public function entry_export(Request $request,string $id): \Illuminate\View\View
@ -298,7 +298,7 @@ class HomeController extends Controller
$request->get('_userpassword_hash')); $request->get('_userpassword_hash'));
if (! $o->getDirty()) if (! $o->getDirty())
return back() return Redirect::back()
->withInput() ->withInput()
->with('note',__('No attributes changed')); ->with('note',__('No attributes changed'));
@ -307,6 +307,31 @@ class HomeController extends Controller
->with('o',$o); ->with('o',$o);
} }
public function entry_rename(Request $request): \Illuminate\Http\RedirectResponse|\Illuminate\View\View
{
$from_dn = Crypt::decryptString($request->post('dn'));
Log::info(sprintf('%s:Renaming [%s] to [%s]',self::LOGKEY,$from_dn,$request->post('_rdn_new')));
$o = config('server')->fetch($from_dn);
if (! $o)
return Redirect::back()
->withInput()
->with('note',__('DN doesnt exist'));
try {
$o->rename($request->post('_rdn_new'));
} catch (\Exception $e) {
return Redirect::to('/')
->with('failed',$e->getMessage());
}
return Redirect::to('/')
->withInput(['_key'=>Crypt::encryptString('*dn|'.$o->getDN())])
->with('success',sprintf('%s: %s',__('Entry renamed'),$from_dn));
}
/** /**
* Update a DN entry * Update a DN entry
* *
@ -326,7 +351,7 @@ class HomeController extends Controller
$o->{$key} = array_filter($value); $o->{$key} = array_filter($value);
if (! $dirty=$o->getDirty()) if (! $dirty=$o->getDirty())
return back() return Redirect::back()
->withInput() ->withInput()
->with('note',__('No attributes changed')); ->with('note',__('No attributes changed'));
@ -412,7 +437,7 @@ class HomeController extends Controller
->with('page_actions',collect([ ->with('page_actions',collect([
'copy'=>FALSE, 'copy'=>FALSE,
'create'=>($x=($o->getObjects()->except('entryuuid')->count() > 0)), 'create'=>($x=($o->getObjects()->except('entryuuid')->count() > 0)),
'delete'=>$x, 'delete'=>(! is_null($xx=$o->getObject('hassubordinates')->value)) && ($xx === 'FALSE'),
'edit'=>$x, 'edit'=>$x,
'export'=>$x, 'export'=>$x,
])), ])),
@ -505,8 +530,8 @@ class HomeController extends Controller
// Setup // Setup
$cmd = NULL; $cmd = NULL;
$dn = NULL; $dn = NULL;
$key = $request->get('_key',old('_key')) $key = ($x=$request->get('_key',old('_key')))
? Crypt::decryptString($request->get('_key',old('_key'))) ? Crypt::decryptString($x)
: NULL; : NULL;
// Determine if our key has a command // Determine if our key has a command
@ -518,9 +543,9 @@ class HomeController extends Controller
$dn = ($m[2] !== '_NOP') ? $m[2] : NULL; $dn = ($m[2] !== '_NOP') ? $m[2] : NULL;
} }
} elseif (old('dn',$request->get('_key'))) { } elseif ($x=old('dn',$request->get('_key'))) {
$cmd = 'dn'; $cmd = 'dn';
$dn = Crypt::decryptString(old('dn',$request->get('_key'))); $dn = Crypt::decryptString($x);
} }
return ['cmd'=>$cmd,'dn'=>$dn]; return ['cmd'=>$cmd,'dn'=>$dn];

View File

@ -1 +1 @@
v2.2.0-rel v2.2.1-dev

View File

@ -59,7 +59,7 @@ $(document).ready(function() {
if (typeof basedn !== 'undefined') { if (typeof basedn !== 'undefined') {
sources = basedn; sources = basedn;
} else { } else {
sources = { url: '/ajax/bases' }; sources = { method: 'POST', url: '/ajax/bases' };
} }
// Attach the fancytree widget to an existing <div id="tree"> element // Attach the fancytree widget to an existing <div id="tree"> element
@ -95,8 +95,9 @@ $(document).ready(function() {
source: sources, source: sources,
lazyLoad: function(event,data) { lazyLoad: function(event,data) {
data.result = { data.result = {
method: 'POST',
url: '/ajax/children', url: '/ajax/children',
data: {_key: data.node.data.item,depth: 1} data: {_key: data.node.data.item,create: true}
}; };
expandChildren(data.tree.rootNode); expandChildren(data.tree.rootNode);

View File

@ -46,7 +46,7 @@
</span> </span>
@endif @endif
@if((! $o->no_attr_tags) && (! $o->is_rdn)) @if((! $o->no_attr_tags) && (! $o->is_rdn) && (! $template))
<span data-bs-toggle="tab" href="#langtag-{{ $o->name_lc }}-+" class="bg-primary-subtle btn btn-outline-primary border-primary addable d-none"> <span data-bs-toggle="tab" href="#langtag-{{ $o->name_lc }}-+" class="bg-primary-subtle btn btn-outline-primary border-primary addable d-none">
<i class="fas fa-fw fa-plus text-dark" data-bs-toggle="tooltip" data-bs-custom-class="custom-tooltip" aria-label="Add Lang Tag" data-bs-original-title="Add Lang Tag"></i> <i class="fas fa-fw fa-plus text-dark" data-bs-toggle="tooltip" data-bs-custom-class="custom-tooltip" aria-label="Add Lang Tag" data-bs-original-title="Add Lang Tag"></i>
</span> </span>

View File

@ -1,5 +1,5 @@
<!-- $o=Attribute::class --> <!-- $o=Attribute::class -->
<x-attribute.layout :edit="$edit=($edit ?? FALSE)" :new="$new=($new ?? FALSE)" :o="$o"> <x-attribute.layout :edit="$edit=($edit ?? FALSE)" :new="$new=($new ?? FALSE)" :o="$o" :template="$template">
<div class="col-12"> <div class="col-12">
<div class="tab-content"> <div class="tab-content">
@foreach($o->langtags as $langtag) @foreach($o->langtags as $langtag)
@ -22,7 +22,7 @@
name="{{ $o->name_lc }}[{{ $langtag }}][]" name="{{ $o->name_lc }}[{{ $langtag }}][]"
value="{{ $value ?: ($av ?? '') }}" value="{{ $value ?: ($av ?? '') }}"
placeholder="{{ ! is_null($x=$tv->get($loop->index)) ? $x : '['.__('NEW').']' }}" placeholder="{{ ! is_null($x=$tv->get($loop->index)) ? $x : '['.__('NEW').']' }}"
readonly @readonly(! $edit)
@disabled($o->isDynamic())> @disabled($o->isDynamic())>
<div class="invalid-feedback pb-2"> <div class="invalid-feedback pb-2">

View File

@ -4,7 +4,7 @@
{{ $slot }} {{ $slot }}
</attribute> </attribute>
<x-attribute.widget.options :o="$o" :edit="$edit" :new="$new"/> <x-attribute.widget.options :o="$o" :edit="$edit" :new="$new" :template="$template ?? FALSE"/>
</div> </div>
</div> </div>

View File

@ -6,7 +6,7 @@
@php($clone=FALSE) @php($clone=FALSE)
<span class="p-0 m-0"> <span class="p-0 m-0">
@if($o->is_rdn) @if($o->is_rdn)
<button class="btn btn-sm btn-outline-focus mt-3" disabled><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</button> <span id="entry-rename" class="btn btn-sm btn-outline-focus mt-3" data-bs-toggle="modal" data-bs-target="#page-modal"><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</span>
@elseif($edit && $o->can_addvalues) @elseif($edit && $o->can_addvalues)
@switch(get_class($o)) @switch(get_class($o))
@case(Certificate::class) @case(Certificate::class)
@ -26,7 +26,7 @@
@break @break
@case(ObjectClass::class) @case(ObjectClass::class)
<span type="button" @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-bs-toggle="modal" data-bs-target="#new_objectclass-modal"><i class="fas fa-fw fa-plus"></i> @lang('Add Objectclass')</span> <span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-bs-toggle="modal" data-bs-target="#new_objectclass-modal"><i class="fas fa-fw fa-plus"></i> @lang('Add Objectclass')</span>
<!-- NEW OBJECT CLASS --> <!-- NEW OBJECT CLASS -->
<div class="modal fade" id="new_objectclass-modal" tabindex="-1" aria-labelledby="new_objectclass-label" aria-hidden="true" data-bs-backdrop="static"> <div class="modal fade" id="new_objectclass-modal" tabindex="-1" aria-labelledby="new_objectclass-label" aria-hidden="true" data-bs-backdrop="static">
@ -255,18 +255,18 @@
@default @default
@if($o->isDynamic()) @break @endif @if($o->isDynamic()) @break @endif
@php($clone=TRUE) @php($clone=TRUE)
@if($o->values_old->count()) @if($o->values_old->count() && (! $template))
<span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-attribute="{{ $o->name }}" id="{{ $o->name_lc }}-addnew"><i class="fas fa-fw fa-plus"></i> @lang('Add Value')</span> <span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-attribute="{{ $o->name_lc }}" id="{{ $o->name_lc }}-addnew"><i class="fas fa-fw fa-plus"></i> @lang('Add Value')</span>
@endif @endif
@section('page-scripts') @section('page-scripts')
@if($clone && $edit && $o->can_addvalues) @if((! $template) && $clone && $edit && $o->can_addvalues)
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
// Create a new entry when Add Value clicked // Create a new entry when Add Value clicked
$('#{{ $o->name_lc }}-addnew.addable').click(function(item) { $('form#dn-edit #{{ $o->name_lc }}-addnew.addable').click(function(item) {
var attribute = $(this).data('attribute'); var attribute = $(this).data('attribute');
var active = $('attribute[id='+attribute+']').find('.tab-pane.active'); var active = $('#template-default attribute[id='+attribute+']');
active.find('input:last') active.find('input:last')
.clone() .clone()

View File

@ -1,11 +1,5 @@
@if(session()->has('success')) @if(session()->has('success'))
<div class="alert alert-success"> <div class="alert alert-success p-2">
<h4 class="alert-heading"><i class="fas fa-fw fa-thumbs-up"></i> Success!</h4> <p class="m-0"><i class="fas fa-fw fa-thumbs-up"></i> {{ session()->pull('success') }}</p>
<hr>
<ul class="square">
@foreach(session()->get('success') as $item)
<li>{{ $item }}</li>
@endforeach
</ul>
</div> </div>
@endif @endif

View File

@ -9,30 +9,29 @@
<div class="col"> <div class="col">
<div class="action-buttons float-end"> <div class="action-buttons float-end">
<ul class="nav"> <ul class="nav">
@if(isset($page_actions) && $page_actions->get('create')) @if($page_actions->get('create'))
<li> <li>
<button class="btn btn-outline-dark p-1 m-1" id="entry-create" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Create Child Entry')"><i class="fas fa-fw fa-diagram-project fs-5"></i></button> <button class="btn btn-outline-dark p-1 m-1" id="entry-create" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Create Child Entry')"><i class="fas fa-fw fa-diagram-project fs-5"></i></button>
</li> </li>
@endif @endif
@if(isset($page_actions) && $page_actions->get('export')) @if($page_actions->get('export'))
<li> <li>
<span id="entry-export" data-bs-toggle="modal" data-bs-target="#page-modal"> <span id="entry-export" data-bs-toggle="modal" data-bs-target="#page-modal">
<button class="btn btn-outline-dark p-1 m-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Export')"><i class="fas fa-fw fa-download fs-5"></i></button> <button class="btn btn-outline-dark p-1 m-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Export')"><i class="fas fa-fw fa-download fs-5"></i></button>
</span> </span>
</li> </li>
@endif @endif
@if(isset($page_actions) && $page_actions->get('copy')) @if($page_actions->get('copy'))
<li> <li>
<button class="btn btn-outline-dark p-1 m-1" id="entry-copy-move" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Copy/Move')" disabled><i class="fas fa-fw fa-copy fs-5"></i></button> <button class="btn btn-outline-dark p-1 m-1" id="entry-copy-move" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Copy/Move')" disabled><i class="fas fa-fw fa-copy fs-5"></i></button>
</li> </li>
@endif @endif
@if(isset($page_actions) && $page_actions->get('edit')) @if($page_actions->get('edit'))
<li> <li>
<button class="btn btn-outline-dark p-1 m-1" id="entry-edit" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Edit Entry')"><i class="fas fa-fw fa-edit fs-5"></i></button> <button class="btn btn-outline-dark p-1 m-1" id="entry-edit" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Edit Entry')"><i class="fas fa-fw fa-edit fs-5"></i></button>
</li> </li>
@endif @endif
<!-- @todo Dont offer the delete button for an entry with children --> @if($page_actions->get('delete'))
@if(isset($page_actions) && $page_actions->get('delete'))
<li> <li>
<span id="entry-delete" data-bs-toggle="modal" data-bs-target="#page-modal"> <span id="entry-delete" data-bs-toggle="modal" data-bs-target="#page-modal">
<button class="btn btn-outline-danger p-1 m-1" data-bs-custom-class="custom-tooltip-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Delete Entry')"><i class="fas fa-fw fa-trash-can fs-5"></i></button> <button class="btn btn-outline-danger p-1 m-1" data-bs-custom-class="custom-tooltip-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@lang('Delete Entry')"><i class="fas fa-fw fa-trash-can fs-5"></i></button>
@ -52,9 +51,10 @@
</div> </div>
@endif @endif
<x-success/>
<x-updated/>
<x-note/> <x-note/>
<x-error/> <x-error/>
<x-updated/>
<x-failed/> <x-failed/>
@endsection @endsection
@ -282,6 +282,25 @@
}) })
break; break;
case 'entry-rename':
$.ajax({
method: 'GET',
url: '{{ url('modal/rename') }}/'+dn,
dataType: 'html',
cache: false,
beforeSend: function() {
that.empty().append('<span class="p-3"><i class="fas fa-3x fa-spinner fa-pulse"></i></span>');
},
success: function(data) {
that.empty().html(data);
},
error: function(e) {
if (e.status !== 412)
alert('That didnt work? Please try again....');
},
});
break;
default: default:
switch ($(item.relatedTarget).attr('name')) { switch ($(item.relatedTarget).attr('name')) {
case 'entry-userpassword-check': case 'entry-userpassword-check':

View File

@ -2,6 +2,7 @@
@section('main-content') @section('main-content')
<x-success/> <x-success/>
<x-failed/>
<div class="card card-solid mb-3"> <div class="card card-solid mb-3">
<div class="card-body"> <div class="card-body">

View File

@ -0,0 +1,40 @@
<div class="modal-header bg-dark text-white">
<h1 class="modal-title fs-5">
<strong>@lang('Rename') <strong>{{ $x=Crypt::decryptString($dn) }}</strong>
</h1>
</div>
<form id="entry-rename-form" method="POST" action="{{ url('entry/rename') }}">
<div class="modal-body">
@csrf
<input type="hidden" name="dn" value="{{ $dn }}">
<div class="row">
<div class="col-12">
<label for="rdn" class="form-label">@lang('New RDN')</label>
<div class="input-group mb-3">
<input type="text" id="rdn" name="_rdn_new" class="form-control w-25" placeholder="{{ $rdn=collect(explode(',',$x))->first() }}" value="{{ $rdn }}">
<span class="input-group-text" id="label">{{ collect(explode(',',$x))->skip(1)->join(',') }}</span>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<x-modal.close/>
<button id="entry-rename" type="submit" class="btn btn-sm btn-primary" disabled>@lang('Rename')</button>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
var rdn = '{{ $rdn }}';
// Complete the RDN
$('#rdn').on('input',function(item) {
rdn = $(this).val();
$('button[id=entry-rename]').attr('disabled',! rdn.includes('='));
})
});
</script>

View File

@ -49,6 +49,7 @@ Route::controller(HomeController::class)->group(function() {
Route::post('entry/password/check/','entry_password_check'); Route::post('entry/password/check/','entry_password_check');
Route::post('entry/attr/add/{id}','entry_attr_add'); Route::post('entry/attr/add/{id}','entry_attr_add');
Route::post('entry/objectclass/add','entry_objectclass_add'); Route::post('entry/objectclass/add','entry_objectclass_add');
Route::post('entry/rename','entry_rename');
Route::post('entry/update/commit','entry_update'); Route::post('entry/update/commit','entry_update');
Route::post('entry/update/pending','entry_pending_update'); Route::post('entry/update/pending','entry_pending_update');
@ -56,6 +57,7 @@ Route::controller(HomeController::class)->group(function() {
Route::view('modal/delete/{dn}','modals.entry-delete'); Route::view('modal/delete/{dn}','modals.entry-delete');
Route::view('modal/export/{dn}','modals.entry-export'); Route::view('modal/export/{dn}','modals.entry-export');
Route::view('modal/rename/{dn}','modals.entry-rename');
Route::view('modal/userpassword-check/{dn}','modals.entry-userpassword-check'); Route::view('modal/userpassword-check/{dn}','modals.entry-userpassword-check');
}); });
}); });
@ -63,8 +65,8 @@ Route::controller(HomeController::class)->group(function() {
Route::controller(AjaxController::class) Route::controller(AjaxController::class)
->prefix('ajax') ->prefix('ajax')
->group(function() { ->group(function() {
Route::get('bases','bases'); Route::post('bases','bases');
Route::get('children','children'); Route::post('children','children');
Route::post('schema/view','schema_view'); Route::post('schema/view','schema_view');
Route::post('schema/objectclass/attrs/{id}','schema_objectclass_attrs'); Route::post('schema/objectclass/attrs/{id}','schema_objectclass_attrs');
}); });