diff --git a/app/Classes/LDAP/Server.php b/app/Classes/LDAP/Server.php
index 8693f1b..6d1ce36 100644
--- a/app/Classes/LDAP/Server.php
+++ b/app/Classes/LDAP/Server.php
@@ -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
*
diff --git a/app/Http/Controllers/APIController.php b/app/Http/Controllers/APIController.php
index aea85ce..d9b88e2 100644
--- a/app/Http/Controllers/APIController.php
+++ b/app/Http/Controllers/APIController.php
@@ -26,6 +26,7 @@ class APIController extends Controller
'item'=>Crypt::encryptString($item),
'lazy'=>TRUE,
'icon'=>'fa-fw fas fa-sitemap',
+ 'tooltip'=>$item,
];
});
}
@@ -39,12 +40,12 @@ class APIController extends Controller
return (new Server())
->query($dn)
->transform(function($item) {
- //dd($item->getDistinguishedName(),$item);
return [
'title'=>$item->getDistinguishedName(),
'item'=>Crypt::encryptString($item->getDistinguishedName()),
'icon'=>'fa-fw fas fa-sitemap',
'lazy'=>TRUE,
+ 'tooltip'=>$item->getDistinguishedName(),
];
});
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index f8bfe52..740cd2f 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Crypt;
use App\Classes\LDAP\Server;
@@ -12,7 +13,23 @@ class HomeController extends Controller
$o = new Server;
return view('home')
- ->with('server',config('ldap.connections.default.name')) // @todo This connection name should be a config item
- ->with('bases',$o->getBaseDN());
+ ->with('server',config('ldap.connections.default.name'))
+ ->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));
}
}
diff --git a/public/js/custom.js b/public/js/custom.js
index 3fb5c13..495b634 100644
--- a/public/js/custom.js
+++ b/public/js/custom.js
@@ -12,6 +12,13 @@ function expandChildren(node) {
}
$(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
element
// and pass the tree options as an argument to the fancytree() function:
$('#tree').fancytree({
@@ -20,16 +27,24 @@ $(document).ready(function() {
autoCollapse: true, // Automatically collapse all siblings, when a node is expanded.
autoScroll: true, // Automatically scroll nodes into visible area.
focusOnSelect: true, // Set focus when node is checked by a mouse click
- click: function(event, data) {
- if (data.targetType == 'title')
- return false;
- },
- init: function(event, data) {
- expandChildren(data.tree.rootNode);
- },
- source: {
- url: "api/bases"
+ click: function(event,data) {
+ if (data.targetType == 'title') {
+ $.ajax({
+ url: 'render',
+ method: 'POST',
+ data: { key: data.node.data.item },
+ dataType: 'html',
+
+ }).done(function(html) {
+ console.log(data);
+ $('.main-content').empty().append(html);
+
+ }).fail(function() {
+ alert('Failed');
+ });
+ }
},
+ source: sources,
lazyLoad: function(event,data) {
data.result = {
url: "api/query",
diff --git a/resources/themes/architect/views/layouts/app.blade.php b/resources/themes/architect/views/layouts/app.blade.php
index ea95afd..ef2415f 100644
--- a/resources/themes/architect/views/layouts/app.blade.php
+++ b/resources/themes/architect/views/layouts/app.blade.php
@@ -15,13 +15,17 @@
- @include('architect::layouts.partials.contentheader')
+
+ @if (trim($__env->yieldContent('page_title')))
+ @include('architect::layouts.partials.contentheader')
+ @endif
-
-
-
-
- @yield('main-content')
+
+
+
+
+ @yield('main-content')
+
diff --git a/resources/themes/architect/views/layouts/dn.blade.php b/resources/themes/architect/views/layouts/dn.blade.php
new file mode 100644
index 0000000..bd2ec1c
--- /dev/null
+++ b/resources/themes/architect/views/layouts/dn.blade.php
@@ -0,0 +1,11 @@
+@if (trim($__env->yieldContent('page_title')))
+ @include('architect::layouts.partials.contentheader')
+@endif
+
+
+
+
+
+ @yield('main-content')
+
+
diff --git a/resources/themes/architect/views/layouts/partials/contentheader.blade.php b/resources/themes/architect/views/layouts/partials/contentheader.blade.php
index de4d992..8e2bd58 100644
--- a/resources/themes/architect/views/layouts/partials/contentheader.blade.php
+++ b/resources/themes/architect/views/layouts/partials/contentheader.blade.php
@@ -1,44 +1,49 @@
-
-
-
+ @if (trim($__env->yieldContent('page_icon')))
+
+
+
+ @endif
@yield('page_title','Page Title')
- @yield('page_subtitle','Page Sub Title')
+ @yield('page_subtitle','')
-
- {{--
-
- --}}
-
-
-
+ @endif
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 9a7cd32..16f4934 100644
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -4,10 +4,12 @@
Home
@endsection
-@section('contentheader_title')
- Home
+@section('page_title')
@endsection
-@section('contentheader_description')
+@section('page_subtitle')
+ Content Header - Description
+@endsection
+@section('page_icon')
@endsection
@section('main-content')
@@ -38,4 +40,8 @@
@endsection
-
+@section('page-scripts')
+
+@append
diff --git a/resources/views/widgets/dn.blade.php b/resources/views/widgets/dn.blade.php
new file mode 100644
index 0000000..9071f44
--- /dev/null
+++ b/resources/views/widgets/dn.blade.php
@@ -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')
+
+
+ @dump($leaf->getOriginal(),$leaf->countAttributes()) |
+
+ @foreach ($leaf->getAttributes() as $attribute => $value)
+
+ {{ $attribute }} |
+ {!! is_array($value) ? join(' ',$value) : $value !!} |
+
+ @endforeach
+
+@endsection
diff --git a/routes/web.php b/routes/web.php
index 0e2e983..05ba9b9 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -23,3 +23,4 @@ Auth::routes([
Route::redirect('/','home');
Route::get('logout','Auth\LoginController@logout');
Route::get('home','HomeController@home');
+Route::post('render','HomeController@render');