diff --git a/angular/RestClient/src/app/app.routes.ts b/angular/RestClient/src/app/app.routes.ts index c889563c2d7e4e5c07af018265c29076f167c4fb..43242b610cb181c362b1b3181f96b1d6c6e5fc5f 100644 --- a/angular/RestClient/src/app/app.routes.ts +++ b/angular/RestClient/src/app/app.routes.ts @@ -1,12 +1,10 @@ import { UnauthorizedComponent } from './page/unauthorized/unauthorized.component'; import { AppRoute } from './core/models/Route.interface'; -import { rolGuard, rolGuardChild } from '@core/guards'; +import { rolGuardChild } from '@core/guards'; +import { AUTH_ROUTES } from '@features/auth'; export const routes: AppRoute[] = [ // Auth - { - path: '', - loadChildren: () => import('./features/auth').then((m) => m.AUTH_ROUTES), - }, + ...AUTH_ROUTES, // Hoteles { path: 'hotels', diff --git a/angular/RestClient/src/app/core/guards/rol.guard.ts b/angular/RestClient/src/app/core/guards/rol.guard.ts index 4688794138c0606d922a497cb3f653752e49c41b..c00bdb92e47666fb1ebdf3b992b55f8f5d4e3e28 100644 --- a/angular/RestClient/src/app/core/guards/rol.guard.ts +++ b/angular/RestClient/src/app/core/guards/rol.guard.ts @@ -78,9 +78,6 @@ export const rolGuardChild: CanActivateChildFn = (childRoute, state) => { let requiredRol = childRoute.data['expectedRole'] ?? getInheritedRole(childRoute); - // Si no hay rol especificado se supone libre de verificación - if (!requiredRol) return true; - // Verificar si el usuario tiene el rol requerido return verifyRol(requiredRol); }; diff --git a/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts b/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts index 460494edfc8d18a33e3df60ae68a90ce75264d76..662ebd07f1bef996d298bf370be0e9095ac57f1c 100644 --- a/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts +++ b/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts @@ -26,6 +26,8 @@ export class HotelClientService { if (!startDate || !endDate) return this.http.get<Hotel[]>(url); const start = new Date(startDate).toISOString().split('T')[0]; const end = new Date(endDate).toISOString().split('T')[0]; + console.log({start, end}) + return this.http.get<Hotel[]>(url, { params: { start, end } }); } diff --git a/angular/RestClient/src/app/features/hotels/hotel-list/hotel-list.component.ts b/angular/RestClient/src/app/features/hotels/hotel-list/hotel-list.component.ts index f9a21d8f1330adf8bc6968d6c44e18374b39828d..2ae04a93f7b2cab834214fbff80efb7de43623a1 100644 --- a/angular/RestClient/src/app/features/hotels/hotel-list/hotel-list.component.ts +++ b/angular/RestClient/src/app/features/hotels/hotel-list/hotel-list.component.ts @@ -68,6 +68,8 @@ export class HotelListComponent { rooms: Room[] = []; trateRooms: Room[] = []; userId = 0; + start:Date = new Date(new Date().getDate() - 3); + end:Date = new Date(new Date().getDate() - 3); constructor( private fb: FormBuilder, @@ -81,7 +83,6 @@ export class HotelListComponent { const baseUrl = getBasePath(url).split('/')[1]; const isHotelManger = url.split('/')[1] === 'me'; const isAdmin = baseUrl === 'admin'; - console.log({ isHotelManger, isAdmin, baseUrl }); this.isManaging = isHotelManger || isAdmin; const today = new Date(); @@ -153,15 +154,19 @@ export class HotelListComponent { getHotels() { const { start, end } = this.dateRangeForm.value.dateRange; + console.log({start, end, s:this.start, e:this.end}) + if (end != null && this.end.getDate() === end.getDate()) return + const observable = this.isManaging - ? this.hotelClient.getAllHotelsByUser(this.userId) - : this.hotelClient.getAllHotels(start, end); - console.log('a', this.isManaging); - + ? this.hotelClient.getAllHotelsByUser(this.userId) + : this.hotelClient.getAllHotels(start, end); + observable.subscribe({ next: (resp) => { if (!!resp && (resp as never[]).length >= 0) { + this.start = start + this.end = end this._hotels = resp; this.update(); } diff --git a/angular/RestClient/src/app/features/users/admin.routes.ts b/angular/RestClient/src/app/features/users/admin.routes.ts index 8441e25b2765e0748dba3bcd2c08413ffd78474f..77ec42dbd8eeb75165bb8fac82b9a0a21d2424fe 100644 --- a/angular/RestClient/src/app/features/users/admin.routes.ts +++ b/angular/RestClient/src/app/features/users/admin.routes.ts @@ -2,7 +2,7 @@ import { AppRoute } from '@core/models/Route.interface'; import { MainPageComponent } from 'app/features/users/main-page/main-page.component'; import { UserFormRoute } from 'app/features/users/types/UserFormData'; import { UserFormComponent } from 'app/features/users/user-form/user-form.component'; -import { COMMON_USERS_ROUTES } from 'app/features/users/users.routes'; +import { COMMON_USERS_ROUTES, USERS_ROUTES } from 'app/features/users/users.routes'; function changeToAdminScope(routes: UserFormRoute[]) { return routes.map((r) => { @@ -40,7 +40,7 @@ export const ADMIN_ROUTES: AppRoute[] = [ }, { path: ':id', - children: changeToAdminScope(COMMON_USERS_ROUTES), + children: changeToAdminScope(USERS_ROUTES), }, ], }, diff --git a/kong_config_3.json b/kong_config_3.json new file mode 100644 index 0000000000000000000000000000000000000000..4c7c832b986d3ccaa595f67ec98faa60349e66de --- /dev/null +++ b/kong_config_3.json @@ -0,0 +1 @@ +{"createdUser":null,"updatedUser":null,"id":1,"name":"1735494180877_practica","kong_node_name":"Kong","kong_node_url":"http://kong:8001","kong_version":"3.9.0","data":{"services":[{"path":"/users","port":8201,"client_certificate":null,"id":"1d1ce8d9-aa4b-4576-8d91-00326d00c26e","name":"Users","tags":[],"ca_certificates":null,"created_at":1735150914,"updated_at":1735486602,"protocol":"http","host":"users-api","tls_verify":null,"enabled":true,"read_timeout":60000,"tls_verify_depth":null,"connect_timeout":60000,"write_timeout":60000,"retries":5,"extras":{}},{"path":"/hotels","port":8301,"client_certificate":null,"id":"37407f92-1d9f-4d88-b80f-0bc9a3fb57fd","name":"Hotels","tags":[],"ca_certificates":null,"created_at":1735151821,"updated_at":1735486602,"protocol":"http","host":"hotels-api","tls_verify":null,"enabled":true,"read_timeout":60000,"tls_verify_depth":null,"connect_timeout":60000,"write_timeout":60000,"retries":5,"extras":{}},{"path":"/auth","port":8101,"client_certificate":null,"id":"60e76e38-63f1-4fd7-b10c-51456722a312","name":"Auth","tags":[],"ca_certificates":null,"created_at":1735151037,"updated_at":1735486602,"protocol":"http","host":"auth-api","tls_verify":null,"enabled":true,"read_timeout":60000,"tls_verify_depth":null,"connect_timeout":60000,"write_timeout":60000,"retries":5,"extras":{}},{"path":"/bookings","port":8401,"client_certificate":null,"id":"ae250c19-10c3-4ed2-8cdb-d62497721da2","name":"Bookings","tags":[],"ca_certificates":null,"created_at":1735151922,"updated_at":1735486602,"protocol":"http","host":"bookings-api","tls_verify":null,"enabled":true,"read_timeout":60000,"tls_verify_depth":null,"connect_timeout":60000,"write_timeout":60000,"retries":5,"extras":{}}],"routes":[{"hosts":null,"strip_path":true,"request_buffering":true,"sources":null,"https_redirect_status_code":426,"tags":null,"destinations":null,"created_at":1735151081,"updated_at":1735486602,"methods":["OPTIONS","POST","DELETE"],"protocols":["http","https"],"service":{"id":"60e76e38-63f1-4fd7-b10c-51456722a312"},"regex_priority":0,"id":"4f7e698c-aed6-4919-8d72-a24ce6a2a333","snis":null,"paths":["/api/auth"],"preserve_host":false,"name":"Auth","path_handling":"v1","response_buffering":true,"headers":null},{"hosts":null,"strip_path":true,"request_buffering":true,"sources":null,"https_redirect_status_code":426,"tags":null,"destinations":null,"created_at":1735151945,"updated_at":1735486602,"methods":["GET","POST","PATCH","PUT","DELETE","OPTIONS"],"protocols":["http","https"],"service":{"id":"ae250c19-10c3-4ed2-8cdb-d62497721da2"},"regex_priority":0,"id":"810bbb6d-a10d-416d-b5db-a121762981fa","snis":null,"paths":["/api/bookings"],"preserve_host":false,"name":"Bookings","path_handling":"v1","response_buffering":true,"headers":null},{"hosts":null,"strip_path":true,"request_buffering":true,"sources":null,"https_redirect_status_code":426,"tags":null,"destinations":null,"created_at":1735486723,"updated_at":1735486747,"methods":["GET","OPTIONS","PUT","PATCH","POST","DELETE"],"protocols":["http","https"],"service":{"id":"37407f92-1d9f-4d88-b80f-0bc9a3fb57fd"},"regex_priority":0,"id":"dc4b871c-7013-43f3-b4e1-8cfaf94ae03c","snis":null,"paths":["/api/hotels"],"preserve_host":false,"name":"Hotels","path_handling":"v1","response_buffering":true,"headers":null},{"hosts":null,"strip_path":true,"request_buffering":true,"sources":null,"https_redirect_status_code":426,"tags":null,"destinations":null,"created_at":1735150976,"updated_at":1735486602,"methods":["OPTIONS","GET","POST","DELETE","PUT","PATCH"],"protocols":["http","https"],"service":{"id":"1d1ce8d9-aa4b-4576-8d91-00326d00c26e"},"regex_priority":0,"id":"df0fefa6-7df8-4ae3-baed-ae58add42bbf","snis":null,"paths":["/api/users"],"preserve_host":false,"name":"Usuarios","path_handling":"v1","response_buffering":true,"headers":null}],"consumers":[{"created_at":1735155577,"updated_at":1735486602,"id":"c012b84f-63af-461f-8a8d-b8f99a2bd006","custom_id":null,"tags":[],"username":"JWT","credentials":{"jwts":[{"created_at":1735155689,"consumer":{"id":"c012b84f-63af-461f-8a8d-b8f99a2bd006"},"key":"9L8RmLEKMFd54WrR06CE9zoRSAGpCWeu","rsa_public_key":null,"secret":"MiClaveDeSeguridadMuyLargaParaQueNoFalleSpringBoot","algorithm":"HS256","tags":null,"id":"d9fc99a4-b111-4ff2-a02c-9348fcb176cb"}]}}],"plugins":[{"created_at":1735155843,"updated_at":1735487924,"consumer":null,"service":null,"protocols":["grpc","grpcs","http","https"],"route":{"id":"810bbb6d-a10d-416d-b5db-a121762981fa"},"config":{"uri_param_names":["jwt"],"cookie_names":[],"header_names":["Authorization"],"anonymous":null,"run_on_preflight":false,"secret_is_base64":false,"maximum_expiration":0,"key_claim_name":"kid","realm":null,"claims_to_verify":["exp"]},"tags":null,"enabled":true,"instance_name":null,"name":"jwt","id":"3e302549-c51f-469d-a71d-98f30f2ddcab"},{"created_at":1735156525,"updated_at":1735487917,"consumer":null,"service":null,"protocols":["grpc","grpcs","http","https"],"route":{"id":"df0fefa6-7df8-4ae3-baed-ae58add42bbf"},"config":{"uri_param_names":["jwt"],"cookie_names":[],"header_names":["Authorization"],"anonymous":null,"run_on_preflight":false,"secret_is_base64":false,"maximum_expiration":0,"key_claim_name":"kid","realm":null,"claims_to_verify":["exp"]},"tags":null,"enabled":true,"instance_name":null,"name":"jwt","id":"8386bf54-ede1-4f34-bb87-989ce4276e8a"},{"created_at":1735486785,"updated_at":1735487895,"consumer":null,"service":null,"protocols":["grpc","grpcs","http","https"],"route":{"id":"dc4b871c-7013-43f3-b4e1-8cfaf94ae03c"},"config":{"uri_param_names":["jwt"],"cookie_names":[],"header_names":["Authorization"],"anonymous":null,"run_on_preflight":false,"secret_is_base64":false,"maximum_expiration":0,"key_claim_name":"kid","realm":null,"claims_to_verify":["exp"]},"tags":null,"enabled":true,"instance_name":null,"name":"jwt","id":"d1fc4321-6bb5-432a-92cd-52b245df6a52"}],"acls":[],"upstreams":[],"certificates":[],"snis":[]},"createdAt":"2024-12-29T17:43:00.000Z","updatedAt":"2024-12-29T17:43:00.000Z"} \ No newline at end of file