diff --git a/api/common/Controller/Proyectos.php b/api/common/Controller/Proyectos.php index 106e840..c310f34 100644 --- a/api/common/Controller/Proyectos.php +++ b/api/common/Controller/Proyectos.php @@ -44,12 +44,14 @@ class Proyectos { } public function operadores(Request $request, Response $response, $id_proyecto): Response { $proyecto = Model::factory(Proyecto::class)->find_one($id_proyecto); +error_log(var_export($proyecto->operadores(), true)); $output = [ 'proyecto' => $proyecto->as_array(), 'operadores' => $proyecto->operadores() ? array_map(function($item) { - if ($item) { - return $item->as_array(); - } + $arr = $item->as_array(); + $arr['agente_tipo'] = $item->agente_tipo()->as_array(); + $arr['agente_tipo']['agente'] = $arr['operador'] = $item->agente_tipo()->agente()->as_array(); + return $arr; }, $proyecto->operadores()) : null ]; return $this->withJson($response, $output); diff --git a/api/nginx.conf b/api/nginx.conf index 9f1a5ca..d4901bf 100644 --- a/api/nginx.conf +++ b/api/nginx.conf @@ -18,7 +18,7 @@ server { location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass backend:9000; + fastcgi_pass operadores-backend:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/api/src/Proyecto.php b/api/src/Proyecto.php index dbf7d92..78be0a6 100644 --- a/api/src/Proyecto.php +++ b/api/src/Proyecto.php @@ -45,12 +45,10 @@ class Proyecto extends Model { public function operadores() { if ($this->operadores === null) { $pas = $this->has_many(ProyectoAgente::class, 'proyecto')->find_many(); - $operadores = []; - foreach ($pas as $pa) { - $id = $pa->agente_tipo()->agente()->id; - $operadores []= Model::factory(Operador::class)->find_one($id); - } - $this->operadores = $operadores; + $pas = array_filter($pas, function($pa) { + return ($pa->agente_tipo()->tipo() === 'operador'); + }); + $this->operadores = $pas; } return $this->operadores; } diff --git a/docker-compose.yml b/docker-compose.yml index 0e448f8..9c4b16f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,53 +1,61 @@ version: '3' services: - backend-proxy: - container_name: backend_proxy + operadores-backend-proxy: + profiles: + - operadores + container_name: operadores_api image: nginx volumes: - - ./api/:/app/ - - ./api/nginx.conf:/etc/nginx/conf.d/default.conf - - ./logs/api/:/var/log/nginx/ + - ${OPERADORES_PATH:-.}/api/:/app/ + - ${OPERADORES_PATH:-.}/api/nginx.conf:/etc/nginx/conf.d/default.conf + - ./logs/operadores/api/:/var/log/nginx/ restart: unless-stopped ports: - 8001:80 depends_on: - - backend - backend: - container_name: backend + - operadores-backend + operadores-backend: + profiles: + - operadores + container_name: operadores_backend restart: unless-stopped image: php build: - context: ./api + context: ${OPERADROES_PATH:-.}/api dockerfile: PHP.Dockerfile - env_file: .db.env + env_file: ${OPERADORES_PATH:-.}/.db.env volumes: - - ./api/:/app/ + - ${OPERADORES_PATH:-.}/api/:/app/ # depends_on: # - db - frontend-proxy: - container_name: frontend_proxy + operadores-frontend-proxy: + profiles: + - operadores + container_name: operadores_ui image: nginx volumes: - - ./ui/:/app/ - - ./ui/nginx.conf:/etc/nginx/conf.d/default.conf - - ./logs/ui/:/var/log/nginx/ + - ${OPERADORES_PATH:-.}/ui/:/app/ + - ${OPERADORES_PATH:-.}/ui/nginx.conf:/etc/nginx/conf.d/default.conf + - ./logs/operadores/ui/:/var/log/nginx/ restart: unless-stopped ports: - 8000:80 depends_on: - - frontend - frontend: - container_name: frontend + - operadores-frontend + operadores-frontend: + profiles: + - operadores + container_name: operadores_frontend restart: unless-stopped image: php:ui build: - context: ./ui + context: ${OPERADORES_PATH:-.}/ui dockerfile: PHP.Dockerfile - env_file: .ui.env + env_file: ${OPERADORES_PATH:-.}/.ui.env volumes: - - ./ui/:/app/ + - ${OPERADORES_PATH:-.}/ui/:/app/ # # db: # image: mariadb @@ -68,3 +76,8 @@ services: # #volumes: # database: + +networks: + default: + external: true + name: incoviba_network diff --git a/ui/nginx.conf b/ui/nginx.conf index 84c68da..f1cd9cd 100644 --- a/ui/nginx.conf +++ b/ui/nginx.conf @@ -13,7 +13,7 @@ server { location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass frontend:9000; + fastcgi_pass operadores-frontend:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/ui/resources/views/layout/menu.blade.php b/ui/resources/views/layout/menu.blade.php index 719c7c4..a714a86 100644 --- a/ui/resources/views/layout/menu.blade.php +++ b/ui/resources/views/layout/menu.blade.php @@ -23,6 +23,13 @@ @include('layout.menu.informes') +