Skip to content

Commit 339ba72

Browse files
committed
Make the ajax calls POST methods, and make the 'Create Entry' in the tree configurable so calls to children() can just return child entries
1 parent 883ac5d commit 339ba72

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

app/Http/Controllers/AjaxController.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function bases(): Collection
3838
*/
3939
public function children(Request $request): Collection
4040
{
41-
$dn = Crypt::decryptString($request->query('_key'));
41+
$dn = Crypt::decryptString($request->post('_key'));
4242

4343
// Sometimes our key has a command, so we'll ignore it
4444
if (str_starts_with($dn,'*') && ($x=strpos($dn,'|')))
@@ -57,13 +57,18 @@ public function children(Request $request): Collection
5757
'tooltip'=>$item->getDn(),
5858
])
5959
->prepend(
60-
[
61-
'title'=>sprintf('[%s]',__('Create Entry')),
62-
'item'=>Crypt::encryptString(sprintf('*%s|%s','create',$dn)),
63-
'lazy'=>FALSE,
64-
'icon'=>'fas fa-fw fa-square-plus text-warning',
65-
'tooltip'=>__('Create new LDAP item here'),
66-
]);
60+
$request->create
61+
? [
62+
'title'=>sprintf('[%s]',__('Create Entry')),
63+
'item'=>Crypt::encryptString(sprintf('*%s|%s','create',$dn)),
64+
'lazy'=>FALSE,
65+
'icon'=>'fas fa-fw fa-square-plus text-warning',
66+
'tooltip'=>__('Create new LDAP item here'),
67+
]
68+
: []
69+
)
70+
->filter()
71+
->values();
6772
}
6873

6974
public function schema_view(Request $request)

public/js/custom.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $(document).ready(function() {
5959
if (typeof basedn !== 'undefined') {
6060
sources = basedn;
6161
} else {
62-
sources = { url: '/ajax/bases' };
62+
sources = { method: 'POST', url: '/ajax/bases' };
6363
}
6464

6565
// Attach the fancytree widget to an existing <div id="tree"> element
@@ -95,8 +95,9 @@ $(document).ready(function() {
9595
source: sources,
9696
lazyLoad: function(event,data) {
9797
data.result = {
98+
method: 'POST',
9899
url: '/ajax/children',
99-
data: {_key: data.node.data.item,depth: 1}
100+
data: {_key: data.node.data.item,create: true}
100101
};
101102

102103
expandChildren(data.tree.rootNode);

routes/web.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
Route::controller(AjaxController::class)
6464
->prefix('ajax')
6565
->group(function() {
66-
Route::get('bases','bases');
67-
Route::get('children','children');
66+
Route::post('bases','bases');
67+
Route::post('children','children');
6868
Route::post('schema/view','schema_view');
6969
Route::post('schema/objectclass/attrs/{id}','schema_objectclass_attrs');
7070
});

0 commit comments

Comments
 (0)