@php
use Illuminate\Support\Facades\Redis;
@endphp
@props(['isStatic', 'userid', 'ip_address', 'online'])
@if (!$isStatic)
@php
$userid = $userid ?? '';
$useRedis = globalPermission('clientManageThroughNodeJs');
if ($useRedis) {
$userActiveInfo = json_decode(Redis::get('active:' . $userid), true);
$userSecretInfo = json_decode(Redis::get('secret:' . $userid), true);
$isOnline = $userActiveInfo !== null;
$currentAddress = $userActiveInfo['address'] ?? '';
$lastLoggedOut = $userSecretInfo['last-logged-out'] ?? null;
} else {
$isOnline = array_key_exists($userid, $online['onlineUsers']);
$currentAddress = $online['onlineUsers'][$userid]['address'] ?? '';
$lastLoggedOut = $online['allUsers'][$userid]['last-logged-out'] ?? null;
}
@endphp
@if ($isOnline)
@can('router-remote-access')
@endcan
@if (globalPermission('online-offline-using-api'))
Online
@else
{{ $currentAddress }}
@endif
@else
@if ($lastLoggedOut)
@if (preg_match('/\b\d{4}\b/', $lastLoggedOut, $matches) == 1)
@if ($matches[0] != '1970')
@if (globalPermission('online-offline-using-api'))
Offline
@else
{{ $useRedis ? $lastLoggedOut : parseDate($lastLoggedOut) }}
@endif
@else
Never Connected
@endif
@endif
@endif
@endif
@else
@if(isset($ip_address)) {
@if (array_key_exists($ip_address, $online['ipArpListsGlobal']))
{{ $online['ipArpListsGlobal'][$ip_address]['disabled'] == 'false' ? 'Online' : 'ARP-Disabled' }}
@endif
@else
Offline
@endif
@endif