Change query() to children() - expose hassuborinates
This commit is contained in:
parent
1ebdffa358
commit
c549d28340
@ -78,11 +78,12 @@ class Server
|
|||||||
* @param string $dn
|
* @param string $dn
|
||||||
* @return |null
|
* @return |null
|
||||||
*/
|
*/
|
||||||
public function query(string $dn)
|
public function children(string $dn)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return ($x=(new Entry)
|
return ($x=(new Entry)
|
||||||
->query()
|
->query()
|
||||||
|
->select(['dn','hassubordinates'])
|
||||||
->setDn($dn)
|
->setDn($dn)
|
||||||
->listing()
|
->listing()
|
||||||
->get()) ? $x : NULL;
|
->get()) ? $x : NULL;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use LdapRecord\Query\Collection;
|
use LdapRecord\Query\Collection;
|
||||||
@ -35,20 +36,20 @@ class APIController extends Controller
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function query(Request $request): Collection
|
public function children(Request $request): Collection
|
||||||
{
|
{
|
||||||
$levels = $request->query('depth',1);
|
$levels = $request->query('depth',1);
|
||||||
$dn = Crypt::decryptString($request->query('key'));
|
$dn = Crypt::decryptString($request->query('key'));
|
||||||
Log::debug(sprintf('%s: Query [%s] - Levels [%d]',__METHOD__,$dn,$levels));
|
Log::debug(sprintf('%s: Query [%s] - Levels [%d]',__METHOD__,$dn,$levels));
|
||||||
|
|
||||||
return (new Server())
|
return (new Server())
|
||||||
->query($dn)
|
->children($dn)
|
||||||
->transform(function($item) {
|
->transform(function($item) {
|
||||||
return [
|
return [
|
||||||
'title'=>$item->getDn(),
|
'title'=>$item->getRdn(),
|
||||||
'item'=>Crypt::encryptString($item->getDn()),
|
'item'=>Crypt::encryptString($item->getDn()),
|
||||||
'icon'=>'fa-fw fas fa-sitemap',
|
'icon'=>'fa-fw fas fa-sitemap',
|
||||||
'lazy'=>TRUE,
|
'lazy'=>Arr::get($item->getAttribute('hassubordinates'),0) == 'TRUE',
|
||||||
'tooltip'=>$item->getDn(),
|
'tooltip'=>$item->getDn(),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
6
public/js/custom.js
vendored
6
public/js/custom.js
vendored
@ -47,7 +47,7 @@ $(document).ready(function() {
|
|||||||
source: sources,
|
source: sources,
|
||||||
lazyLoad: function(event,data) {
|
lazyLoad: function(event,data) {
|
||||||
data.result = {
|
data.result = {
|
||||||
url: "api/query",
|
url: 'api/children',
|
||||||
data: {key: data.node.data.item,depth: 1}
|
data: {key: data.node.data.item,depth: 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ $(document).ready(function() {
|
|||||||
},
|
},
|
||||||
keydown: function(event, data){
|
keydown: function(event, data){
|
||||||
switch( $.ui.fancytree.eventToString(data.originalEvent) ) {
|
switch( $.ui.fancytree.eventToString(data.originalEvent) ) {
|
||||||
case "return":
|
case 'return':
|
||||||
case "space":
|
case 'space':
|
||||||
data.node.toggleExpanded();
|
data.node.toggleExpanded();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,5 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
|
|||||||
*/
|
*/
|
||||||
Route::group([],function() {
|
Route::group([],function() {
|
||||||
Route::get('/bases','APIController@bases');
|
Route::get('/bases','APIController@bases');
|
||||||
Route::get('/query', 'APIController@query');
|
Route::get('/children','APIController@children');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user