Start on fetching DN from server
This commit is contained in:
parent
130ae005a3
commit
f323be3d7f
@ -54,6 +54,27 @@ class Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a DN from the server
|
||||||
|
*
|
||||||
|
* @param $dn
|
||||||
|
* @return |null
|
||||||
|
*/
|
||||||
|
public function fetch(string $dn,array $attributes=['*'])
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return ($x=(new Adldap)
|
||||||
|
->addProvider(config('ldap.connections.default.settings'))
|
||||||
|
->search()
|
||||||
|
->select($attributes)
|
||||||
|
->findByDn($dn)) ? $x : NULL;
|
||||||
|
|
||||||
|
// @todo Tidy up this exception
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
dd(['e'=>$e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query the server for a DN
|
* Query the server for a DN
|
||||||
*
|
*
|
||||||
|
@ -26,6 +26,7 @@ class APIController extends Controller
|
|||||||
'item'=>Crypt::encryptString($item),
|
'item'=>Crypt::encryptString($item),
|
||||||
'lazy'=>TRUE,
|
'lazy'=>TRUE,
|
||||||
'icon'=>'fa-fw fas fa-sitemap',
|
'icon'=>'fa-fw fas fa-sitemap',
|
||||||
|
'tooltip'=>$item,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -39,12 +40,12 @@ class APIController extends Controller
|
|||||||
return (new Server())
|
return (new Server())
|
||||||
->query($dn)
|
->query($dn)
|
||||||
->transform(function($item) {
|
->transform(function($item) {
|
||||||
//dd($item->getDistinguishedName(),$item);
|
|
||||||
return [
|
return [
|
||||||
'title'=>$item->getDistinguishedName(),
|
'title'=>$item->getDistinguishedName(),
|
||||||
'item'=>Crypt::encryptString($item->getDistinguishedName()),
|
'item'=>Crypt::encryptString($item->getDistinguishedName()),
|
||||||
'icon'=>'fa-fw fas fa-sitemap',
|
'icon'=>'fa-fw fas fa-sitemap',
|
||||||
'lazy'=>TRUE,
|
'lazy'=>TRUE,
|
||||||
|
'tooltip'=>$item->getDistinguishedName(),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
|
||||||
use App\Classes\LDAP\Server;
|
use App\Classes\LDAP\Server;
|
||||||
|
|
||||||
@ -12,7 +13,23 @@ class HomeController extends Controller
|
|||||||
$o = new Server;
|
$o = new Server;
|
||||||
|
|
||||||
return view('home')
|
return view('home')
|
||||||
->with('server',config('ldap.connections.default.name')) // @todo This connection name should be a config item
|
->with('server',config('ldap.connections.default.name'))
|
||||||
->with('bases',$o->getBaseDN());
|
->with('bases',$o->getBaseDN()->transform(function($item) {
|
||||||
|
return [
|
||||||
|
'title'=>$item,
|
||||||
|
'item'=>Crypt::encryptString($item),
|
||||||
|
'lazy'=>TRUE,
|
||||||
|
'icon'=>'fa-fw fas fa-sitemap',
|
||||||
|
'tooltip'=>$item,
|
||||||
|
];
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render(Request $request) {
|
||||||
|
$dn = Crypt::decryptString($request->post('key'));
|
||||||
|
|
||||||
|
return view('widgets.dn')
|
||||||
|
->with('dn',$dn)
|
||||||
|
->with('leaf',(new Server())->fetch($dn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
public/js/custom.js
vendored
33
public/js/custom.js
vendored
@ -12,6 +12,13 @@ function expandChildren(node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
// If our bases have been set, we'll render them directly
|
||||||
|
if (typeof basedn !== 'undefined') {
|
||||||
|
sources = basedn;
|
||||||
|
} else {
|
||||||
|
sources = { url: 'api/bases' };
|
||||||
|
}
|
||||||
|
|
||||||
// Attach the fancytree widget to an existing <div id="tree"> element
|
// Attach the fancytree widget to an existing <div id="tree"> element
|
||||||
// and pass the tree options as an argument to the fancytree() function:
|
// and pass the tree options as an argument to the fancytree() function:
|
||||||
$('#tree').fancytree({
|
$('#tree').fancytree({
|
||||||
@ -20,16 +27,24 @@ $(document).ready(function() {
|
|||||||
autoCollapse: true, // Automatically collapse all siblings, when a node is expanded.
|
autoCollapse: true, // Automatically collapse all siblings, when a node is expanded.
|
||||||
autoScroll: true, // Automatically scroll nodes into visible area.
|
autoScroll: true, // Automatically scroll nodes into visible area.
|
||||||
focusOnSelect: true, // Set focus when node is checked by a mouse click
|
focusOnSelect: true, // Set focus when node is checked by a mouse click
|
||||||
click: function(event, data) {
|
click: function(event,data) {
|
||||||
if (data.targetType == 'title')
|
if (data.targetType == 'title') {
|
||||||
return false;
|
$.ajax({
|
||||||
},
|
url: 'render',
|
||||||
init: function(event, data) {
|
method: 'POST',
|
||||||
expandChildren(data.tree.rootNode);
|
data: { key: data.node.data.item },
|
||||||
},
|
dataType: 'html',
|
||||||
source: {
|
|
||||||
url: "api/bases"
|
}).done(function(html) {
|
||||||
|
console.log(data);
|
||||||
|
$('.main-content').empty().append(html);
|
||||||
|
|
||||||
|
}).fail(function() {
|
||||||
|
alert('Failed');
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
source: sources,
|
||||||
lazyLoad: function(event,data) {
|
lazyLoad: function(event,data) {
|
||||||
data.result = {
|
data.result = {
|
||||||
url: "api/query",
|
url: "api/query",
|
||||||
|
@ -15,7 +15,10 @@
|
|||||||
|
|
||||||
<div class="app-main__outer">
|
<div class="app-main__outer">
|
||||||
<div class="app-main__inner">
|
<div class="app-main__inner">
|
||||||
|
<div class="main-content">
|
||||||
|
@if (trim($__env->yieldContent('page_title')))
|
||||||
@include('architect::layouts.partials.contentheader')
|
@include('architect::layouts.partials.contentheader')
|
||||||
|
@endif
|
||||||
|
|
||||||
<!-- Main content -->
|
<!-- Main content -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -25,6 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@include('architect::layouts.partials.contentfooter')
|
@include('architect::layouts.partials.contentfooter')
|
||||||
</div>
|
</div>
|
||||||
|
11
resources/themes/architect/views/layouts/dn.blade.php
Normal file
11
resources/themes/architect/views/layouts/dn.blade.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
@if (trim($__env->yieldContent('page_title')))
|
||||||
|
@include('architect::layouts.partials.contentheader')
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Main content -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<!-- Your Page Content Here -->
|
||||||
|
@yield('main-content')
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,16 +1,20 @@
|
|||||||
<div class="app-page-title">
|
<div class="app-page-title">
|
||||||
<div class="page-title-wrapper">
|
<div class="page-title-wrapper">
|
||||||
<div class="page-title-heading">
|
<div class="page-title-heading">
|
||||||
|
@if (trim($__env->yieldContent('page_icon')))
|
||||||
<div class="page-title-icon">
|
<div class="page-title-icon">
|
||||||
<i class="@yield('page_icon','pe-7s-car')"></i>
|
<i class="@yield('page_icon','')"></i>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
<div>
|
<div>
|
||||||
@yield('page_title','Page Title')
|
@yield('page_title','Page Title')
|
||||||
<div class="page-title-subheading">
|
<div class="page-title-subheading">
|
||||||
@yield('page_subtitle','Page Sub Title')
|
@yield('page_subtitle','')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@isset($page_actions)
|
||||||
<div class="page-title-actions">
|
<div class="page-title-actions">
|
||||||
{{--
|
{{--
|
||||||
<button type="button" data-toggle="tooltip" title="Example Tooltip" data-placement="bottom" class="btn-shadow mr-3 btn btn-dark">
|
<button type="button" data-toggle="tooltip" title="Example Tooltip" data-placement="bottom" class="btn-shadow mr-3 btn btn-dark">
|
||||||
@ -40,5 +44,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
Home
|
Home
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('contentheader_title')
|
@section('page_title')
|
||||||
Home
|
|
||||||
@endsection
|
@endsection
|
||||||
@section('contentheader_description')
|
@section('page_subtitle')
|
||||||
|
Content Header - Description
|
||||||
|
@endsection
|
||||||
|
@section('page_icon')
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('main-content')
|
@section('main-content')
|
||||||
@ -38,4 +40,8 @@
|
|||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@section('page-scripts')
|
||||||
|
<script>
|
||||||
|
var basedn = {!! $bases->toJson() !!};
|
||||||
|
</script>
|
||||||
|
@append
|
||||||
|
29
resources/views/widgets/dn.blade.php
Normal file
29
resources/views/widgets/dn.blade.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
@extends('architect::layouts.dn')
|
||||||
|
|
||||||
|
@section('htmlheader_title')
|
||||||
|
Home
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('page_title')
|
||||||
|
{{ $dn }}
|
||||||
|
@endsection
|
||||||
|
@section('page_subtitle')
|
||||||
|
{{ $leaf->entryuuid[0] }}
|
||||||
|
@endsection
|
||||||
|
@section('page_icon')
|
||||||
|
fas fa-cog
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('main-content')
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">@dump($leaf->getOriginal(),$leaf->countAttributes())</td>
|
||||||
|
</tr>
|
||||||
|
@foreach ($leaf->getAttributes() as $attribute => $value)
|
||||||
|
<tr>
|
||||||
|
<th>{{ $attribute }}</th>
|
||||||
|
<td>{!! is_array($value) ? join('<br>',$value) : $value !!}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
@endsection
|
@ -23,3 +23,4 @@ Auth::routes([
|
|||||||
Route::redirect('/','home');
|
Route::redirect('/','home');
|
||||||
Route::get('logout','Auth\LoginController@logout');
|
Route::get('logout','Auth\LoginController@logout');
|
||||||
Route::get('home','HomeController@home');
|
Route::get('home','HomeController@home');
|
||||||
|
Route::post('render','HomeController@render');
|
||||||
|
Loading…
Reference in New Issue
Block a user