mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-07 05:46:06 -06:00
#4633 Ajax request for header
This commit is contained in:
parent
40d9214926
commit
064247b2e2
@ -12,3 +12,14 @@ function crudAjax(params, url, type = 'GET', callback = () => {}, async = false,
|
|||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUserNavMenu(html, element) {
|
||||||
|
crudAjax({}, '/ajax/get-user-info', 'GET', function (callback) {
|
||||||
|
if (callback['userName']){
|
||||||
|
element.html(html);
|
||||||
|
$(element).find('.addBlock').html(callback['addBlockHtml']);
|
||||||
|
$(element).find('.username').html(callback['userName']);
|
||||||
|
$(element).find('.profile-img').attr('src', `${callback['profileImg']}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Http\Controller;
|
<?php namespace Visiosoft\ProfileModule\Http\Controller;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||||
|
use Anomaly\Streams\Platform\Image\Command\MakeImageInstance;
|
||||||
use Visiosoft\AddblockExtension\Command\addBlock;
|
use Visiosoft\AddblockExtension\Command\addBlock;
|
||||||
|
|
||||||
class CacheController extends PublicController
|
class CacheController extends PublicController
|
||||||
@ -8,11 +9,14 @@ class CacheController extends PublicController
|
|||||||
public function getUserInfo()
|
public function getUserInfo()
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
$profile_img = $this->dispatch(
|
||||||
|
new MakeImageInstance($user->file ?: 'theme::images/no_profile.svg', 'img')
|
||||||
|
)->url();
|
||||||
$user = $user ? $user->first_name . ' ' . $user->last_name : $user;
|
$user = $user ? $user->first_name . ' ' . $user->last_name : $user;
|
||||||
|
|
||||||
$getAddBlockHtml = new addBlock('navigation/dropdown', []);
|
$getAddBlockHtml = new addBlock('navigation/dropdown', []);
|
||||||
$addBlockHtml = $getAddBlockHtml->handle();
|
$addBlockHtml = $getAddBlockHtml->handle();
|
||||||
|
|
||||||
return ['userName' => $user, 'addBlockHtml' => $addBlockHtml];
|
return ['userName' => $user, 'profileImg' => $profile_img, 'addBlockHtml' => $addBlockHtml];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user