Skip to content

Commit e7d1bb3

Browse files
author
chechojgb
committed
add: Funcionalidad basica tablero
Se agrego la funcionalidad de mostrar el estado de los agentes con su nombre en asterisk Se tiene un mini tablero en el dashboard para mostrar el estado de los agentes y crear un buen estilo para el componente.
1 parent a50fc53 commit e7d1bb3

27 files changed

+1189
-117
lines changed

.flowbite-react/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class-list.json
2+
pid

.flowbite-react/config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://unpkg.com/flowbite-react/schema.json",
3+
"components": [],
4+
"dark": true,
5+
"prefix": "",
6+
"path": "src/components",
7+
"tsx": true,
8+
"rsc": true
9+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ yarn-error.log
2222
/.nova
2323
/.vscode
2424
/.zed
25+
100.conf
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
use Illuminate\Support\Facades\Http;
5+
use Illuminate\Http\Request;
6+
use Illuminate\Http\JsonResponse;
7+
8+
9+
class PostProxyController extends Controller
10+
{
11+
12+
public function index(): JsonResponse
13+
{
14+
// Simulación de datos de prueba
15+
return response()->json([
16+
'queue' => rand(4, 10),
17+
'available' => rand(2, 6),
18+
'onCall' => rand(1, 4),
19+
'paused' => rand(0, 3),
20+
]);
21+
}
22+
23+
public function usersTable($area): JsonResponse
24+
{
25+
$response = Http::get("http://10.57.251.181:3002/area/{$area}");
26+
if (!$response->successful()) {
27+
return response()->json(['error' => 'No se pudo obtener los datos'], 500);
28+
}
29+
30+
$data = $response->json();
31+
32+
// Recorremos los elementos y solo modificamos 'member'
33+
foreach ($data as &$item) {
34+
if (!isset($item['member'])) continue;
35+
36+
$texto = $item['member'];
37+
38+
// Extraer nombre (lo que está antes del primer espacio)
39+
$nombre = explode(' ', $texto)[0];
40+
41+
// Extraer estado (palabra entre paréntesis como Busy, Idle, etc.)
42+
preg_match_all('/\((.*?)\)/', $texto, $matches);
43+
$estado = null;
44+
45+
foreach ($matches[1] as $match) {
46+
if (in_array($match, ['Busy', 'On Hold', 'In call', 'Ringing', 'Not in use'])) {
47+
$estado = $match;
48+
break;
49+
}
50+
}
51+
52+
// Sobrescribimos el campo member con los nuevos datos
53+
$item['member'] = [
54+
'nombre' => $nombre,
55+
'estado' => $estado,
56+
];
57+
}
58+
59+
return response()->json($data);
60+
}
61+
62+
private function randomTimeBetween(int $minSeconds, int $maxSeconds): string
63+
{
64+
$seconds = rand($minSeconds, $maxSeconds);
65+
return gmdate("H:i:s", $seconds);
66+
}
67+
68+
69+
public function getOverview()
70+
{
71+
$response = Http::get('http://10.57.251.181:3001/extensions/overview');
72+
73+
if (!$response->successful()) {
74+
return response()->json(['error' => 'No se pudo obtener los datos'], 500);
75+
}
76+
77+
$data = $response->json();
78+
79+
// Recorremos los elementos y solo modificamos 'member'
80+
foreach ($data as &$item) {
81+
if (!isset($item['member'])) continue;
82+
83+
$texto = $item['member'];
84+
85+
// Extraer nombre (lo que está antes del primer espacio)
86+
$nombre = explode(' ', $texto)[0];
87+
88+
// Extraer estado (palabra entre paréntesis como Busy, Idle, etc.)
89+
preg_match_all('/\((.*?)\)/', $texto, $matches);
90+
$estado = null;
91+
92+
foreach ($matches[1] as $match) {
93+
if (in_array($match, ['Busy', 'On Hold', 'In call', 'Ringing', 'Not in use'])) {
94+
$estado = $match;
95+
break;
96+
}
97+
}
98+
99+
// Sobrescribimos el campo member con los nuevos datos
100+
$item['member'] = [
101+
'nombre' => $nombre,
102+
'estado' => $estado,
103+
];
104+
}
105+
106+
return response()->json($data);
107+
}
108+
109+
110+
}

bootstrap/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
return Application::configure(basePath: dirname(__DIR__))
1111
->withRouting(
1212
web: __DIR__.'/../routes/web.php',
13+
api: __DIR__.'/../routes/api.php',
1314
commands: __DIR__.'/../routes/console.php',
1415
health: '/up',
1516
)

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"php": "^8.2",
1313
"inertiajs/inertia-laravel": "^2.0",
1414
"laravel/framework": "^12.0",
15+
"laravel/sanctum": "^4.0",
1516
"laravel/tinker": "^2.10.1",
1617
"tightenco/ziggy": "^2.4"
1718
},
@@ -82,4 +83,4 @@
8283
},
8384
"minimum-stability": "stable",
8485
"prefer-stable": true
85-
}
86+
}

composer.lock

Lines changed: 65 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/sanctum.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
use Laravel\Sanctum\Sanctum;
4+
5+
return [
6+
7+
/*
8+
|--------------------------------------------------------------------------
9+
| Stateful Domains
10+
|--------------------------------------------------------------------------
11+
|
12+
| Requests from the following domains / hosts will receive stateful API
13+
| authentication cookies. Typically, these should include your local
14+
| and production domains which access your API via a frontend SPA.
15+
|
16+
*/
17+
18+
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
19+
'%s%s',
20+
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
21+
Sanctum::currentApplicationUrlWithPort(),
22+
// Sanctum::currentRequestHost(),
23+
))),
24+
25+
/*
26+
|--------------------------------------------------------------------------
27+
| Sanctum Guards
28+
|--------------------------------------------------------------------------
29+
|
30+
| This array contains the authentication guards that will be checked when
31+
| Sanctum is trying to authenticate a request. If none of these guards
32+
| are able to authenticate the request, Sanctum will use the bearer
33+
| token that's present on an incoming request for authentication.
34+
|
35+
*/
36+
37+
'guard' => ['web'],
38+
39+
/*
40+
|--------------------------------------------------------------------------
41+
| Expiration Minutes
42+
|--------------------------------------------------------------------------
43+
|
44+
| This value controls the number of minutes until an issued token will be
45+
| considered expired. This will override any values set in the token's
46+
| "expires_at" attribute, but first-party sessions are not affected.
47+
|
48+
*/
49+
50+
'expiration' => null,
51+
52+
/*
53+
|--------------------------------------------------------------------------
54+
| Token Prefix
55+
|--------------------------------------------------------------------------
56+
|
57+
| Sanctum can prefix new tokens in order to take advantage of numerous
58+
| security scanning initiatives maintained by open source platforms
59+
| that notify developers if they commit tokens into repositories.
60+
|
61+
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
62+
|
63+
*/
64+
65+
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
66+
67+
/*
68+
|--------------------------------------------------------------------------
69+
| Sanctum Middleware
70+
|--------------------------------------------------------------------------
71+
|
72+
| When authenticating your first-party SPA with Sanctum you may need to
73+
| customize some of the middleware Sanctum uses while processing the
74+
| request. You may change the middleware listed below as required.
75+
|
76+
*/
77+
78+
'middleware' => [
79+
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
80+
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
81+
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
82+
],
83+
84+
];
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('personal_access_tokens', function (Blueprint $table) {
15+
$table->id();
16+
$table->morphs('tokenable');
17+
$table->string('name');
18+
$table->string('token', 64)->unique();
19+
$table->text('abilities')->nullable();
20+
$table->timestamp('last_used_at')->nullable();
21+
$table->timestamp('expires_at')->nullable();
22+
$table->timestamps();
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*/
29+
public function down(): void
30+
{
31+
Schema::dropIfExists('personal_access_tokens');
32+
}
33+
};

0 commit comments

Comments
 (0)