diff --git a/src/assets/imagen.png b/src/assets/imagen.png new file mode 100644 index 0000000..e61ff32 Binary files /dev/null and b/src/assets/imagen.png differ diff --git a/src/assets/parada-de-autobus.png b/src/assets/parada-de-autobus.png new file mode 100644 index 0000000..10db639 Binary files /dev/null and b/src/assets/parada-de-autobus.png differ diff --git a/src/assets/partida.png b/src/assets/partida.png new file mode 100644 index 0000000..15de289 Binary files /dev/null and b/src/assets/partida.png differ diff --git a/src/assets/termino.png b/src/assets/termino.png new file mode 100644 index 0000000..492e708 Binary files /dev/null and b/src/assets/termino.png differ diff --git a/src/layouts/Sidebar.svelte b/src/layouts/Sidebar.svelte index c43b03a..6aca2e4 100644 --- a/src/layouts/Sidebar.svelte +++ b/src/layouts/Sidebar.svelte @@ -58,6 +58,11 @@ Personas + + + Roles + + diff --git a/src/pages/mapas/FormParadero.svelte b/src/pages/mapas/FormParadero.svelte new file mode 100644 index 0000000..d5b5ca1 --- /dev/null +++ b/src/pages/mapas/FormParadero.svelte @@ -0,0 +1,139 @@ + + +
+
+
+ Icono de Paradero + Paradero +
+ +
+
+ Coordenadas: +
+
Latitud
+
{form.stop_lat}
+
+
+
Longitud
+
{form.stop_lon}
+
+ + Propiedades: +
+
+
Nombre
+ +
+
+
Descripción
+ +
+
+
+ +
+
+
+ + + {#each imagenes as imagen} + + {/each} + + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +{#if parada} +
dispatch('close')}>
+{/if} + + +{#if parada} + +{/if} \ No newline at end of file diff --git a/src/pages/mapas/Paraderos.svelte b/src/pages/mapas/Paraderos.svelte index 2880d0c..cefc3e2 100644 --- a/src/pages/mapas/Paraderos.svelte +++ b/src/pages/mapas/Paraderos.svelte @@ -1,38 +1,70 @@ -Paraderos + + + + -
-
-
-
- -
-
-
-
Región
- -
-
-
-
-
Comuna
- -
-
-
-
- -
-
-
-
- {#if loading} - - Cargando ubicaciones... - {/if} -
+
+
+ + {#if loading}{/if} + Paraderos + +
+
+
+
Región
+
-
- {#if google_api_key} - onMostrarParaderos(ev.detail)} - /> - {/if} +
+
+
Comuna
+ +
+
+
+
+ +
+
+
+
+
+
+
-{#if paradero} - paradero = null} /> -{/if} \ No newline at end of file + parada = null} /> \ No newline at end of file diff --git a/src/pages/mapas/Rutas.svelte b/src/pages/mapas/Rutas.svelte index 68362e1..83ab5fb 100644 --- a/src/pages/mapas/Rutas.svelte +++ b/src/pages/mapas/Rutas.svelte @@ -1,142 +1,150 @@ -Paraderos + + + + -
-
-
-
-
-
Operador
- -
-
-
-
-
Linea
- -
-
-
- {#if loading} - - Cargando rutas... - {/if} -
+ +
+
+ + {#if loading}{/if} + Rutas + +
+
+
+
Operador
+
-
- {#if google_api_key} -
- onPolyline(ev.detail)} - /> -
- {/if} +
+
+
Linea
+ +
+
+
+ +
+
+
diff --git a/src/pages/roles/Admin.svelte b/src/pages/roles/Admin.svelte new file mode 100644 index 0000000..7d9c147 --- /dev/null +++ b/src/pages/roles/Admin.svelte @@ -0,0 +1,109 @@ + + +Roles + +
+
+ +
+
+
+ + + + + + + + + + {#each roles as app, index} + + + + + + {/each} + +
Nro + onOrderBy('id_rol')}>ID + {#if ordering === 'id_rol'}{/if} + {#if ordering === '-id_rol'}{/if} + + onOrderBy('nombre_rol')}>Nombre + {#if ordering === 'nombre_rol'}{/if} + {#if ordering === '-nombre_rol'}{/if} +
{offset + index + 1}{app.id_rol} onEdita(app)}>{app.nombre_rol}
+
+
+ +
+ +{#if rol} + rol = null} + on:refresh={() => onPage(page)} + /> +{/if} + + \ No newline at end of file diff --git a/src/pages/roles/ModalRol.svelte b/src/pages/roles/ModalRol.svelte new file mode 100644 index 0000000..c45832b --- /dev/null +++ b/src/pages/roles/ModalRol.svelte @@ -0,0 +1,275 @@ + + +
+ dispatch('close')}> +
+
+
Rol ID
+
+ {#if rol.id_rol} + + {:else} + + {/if} +
+
+
+
Nombre Rol
+
+ +
+
+

Permiso a aplicaciones

+
+                
+               
+              
+ + +
+
+
+ + + + + + + + + + + {#each form3 as aplicacion} + + + + + + + + + {/each} + + +
AplicacionesAccesoSolo visualizar
{aplicacion.nombre_app}
+
+
+
+
+ + + + +
+
diff --git a/src/pages/rolesaplicaciones/Admin.svelte b/src/pages/rolesaplicaciones/Admin.svelte new file mode 100644 index 0000000..84bbce2 --- /dev/null +++ b/src/pages/rolesaplicaciones/Admin.svelte @@ -0,0 +1,121 @@ + + +rolesyaplicaciones +
+ {data2} + {#each data2 as rol} + {rol.id_rol} + {rol.id_aplicacion} + {/each} +
+ +
+
+ +
+
+
+ + + + + + + + + + + {#each roles as app, index} + + + + + + + {/each} + +
Nro + onOrderBy('id_aplicacion')}>ID rol + {#if ordering === 'id_aplicacion'}{/if} + {#if ordering === '-id_aplicacion'}{/if} + + onOrderBy('id_rol')}>Id app + {#if ordering === 'id_rol'}{/if} + {#if ordering === '-id_rol'}{/if} + Solo Visualizar
{offset + index + 1}{app.id_rol} onEdita(app)}>{app.id_aplicacion}{app.solo_visualizar}
+
+
+ +
+ +{#if rol} + rol = null} + on:refresh={() => onPage(page)} + /> +{/if} + + + \ No newline at end of file diff --git a/src/pages/rolesaplicaciones/ModalRolaplicacion.svelte b/src/pages/rolesaplicaciones/ModalRolaplicacion.svelte new file mode 100644 index 0000000..5589475 --- /dev/null +++ b/src/pages/rolesaplicaciones/ModalRolaplicacion.svelte @@ -0,0 +1,95 @@ + + +
+ dispatch('close')}> +
+
+
ID app
+
+ {#if rol.id_aplicacion} + + {:else} + + {/if} +
+
+
+
ID rol
+
+ +
+
+
+
+ + +
+
+
+ + + + +
+
\ No newline at end of file diff --git a/src/routes/user.routes.js b/src/routes/user.routes.js index d1f4d21..d10f84d 100644 --- a/src/routes/user.routes.js +++ b/src/routes/user.routes.js @@ -11,6 +11,8 @@ import PagePersonaCreate from '$/pages/personas/Persona.svelte' import PagePersonaModifica from '$/pages/personas/Persona.svelte' import PageMapaParaderos from '$/pages/mapas/Paraderos.svelte' import PageMapaRutas from '$/pages/mapas/Rutas.svelte' +import PageRoles from '$/pages/roles/Admin.svelte' +import PageRolesyAplicaciones from '$/pages/rolesaplicaciones/Admin.svelte' export const routes = [ { path: '/', component: PageHome }, @@ -19,6 +21,8 @@ export const routes = [ { path: '/usuarios', component: PageUsuarios }, { path: '/usuarios/nuevo', component: PageUsuarioCreate }, { path: '/usuarios/:login', component: PageUsuarioModifica }, + { path: '/roles', component: PageRoles }, + { path: '/rolesaplicaciones', component: PageRolesyAplicaciones }, { path: '/comunas', component: PageComunas }, { path: '/personas', component: PagePersonas }, { path: '/personas/nuevo', component: PagePersonaCreate }, @@ -26,4 +30,5 @@ export const routes = [ { path: '/mapas/paraderos', component: PageMapaParaderos }, { path: '/mapas/rutas', component: PageMapaRutas }, { path: '*', component: PageError }, + ] \ No newline at end of file diff --git a/src/services/paraderos.js b/src/services/paraderos.js index f60768c..600f607 100644 --- a/src/services/paraderos.js +++ b/src/services/paraderos.js @@ -2,7 +2,7 @@ import { base, getToken } from './_config' export function getUrlImagen(id_paradero) { - return `${base}/paraderos/image/${id_paradero}` + return `${base}/paraderos-image/${id_paradero}` } export async function getParaderos(params) { @@ -51,15 +51,34 @@ export async function deleteParadero(id) { return res.json() } -export async function saveImageParadero(id = null, file) { - const form = new FormData() - form.append('imagen', file) +export async function getParaderoImagenes(id_paradero) { + const res = await fetch(`${base}/paraderos-image/?id_paradero=${id_paradero}`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.text() + return res.json() +} - const res = await fetch(`${base}/paraderos/image/${id}/`, { +export async function createParaderoImagen(id_paradero, file) { + const form = new FormData() + form.append('id_paradero', id_paradero) + form.append('imagen', file) + form.append('content_type', file.type) + + const res = await fetch(`${base}/paraderos-image/`, { method: 'POST', body: form, headers: { "Authorization": `Bearer ${getToken()}` } }) if (!res.ok) throw await res.text() return res.json() +} + +export async function deleteParaderoImagen(id_paradero_imagen) { + const res = await fetch(`${base}/paraderos-image/${id_paradero_imagen}/`, { + method: 'DELETE', + headers: { "Authorization": `Bearer ${getToken()}` } + }) + if (!res.ok) throw await res.text() + return res.text() } \ No newline at end of file diff --git a/src/services/roles.js b/src/services/roles.js new file mode 100644 index 0000000..e7bafe3 --- /dev/null +++ b/src/services/roles.js @@ -0,0 +1,47 @@ +import { base, getToken } from './_config' + +export async function getRoles(params) { + const query = !params ? '' : '?' + (new URLSearchParams(params).toString()); + const res = await fetch(`${base}/roles/${query}`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function getRol(id) { + const res = await fetch(`${base}/roles/${id}/`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function createRol(data) { + const res = await fetch(`${base}/roles/`, { + method: 'POST', + body: JSON.stringify(data), + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function updateRol({ id_rol: id, ...data }) { + const res = await fetch(`${base}/roles/${id}/`, { + method: 'PATCH', + body: JSON.stringify(data), + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function deleteRol(id) { + const res = await fetch(`${base}/roles/${id}/`, { + method: 'DELETE', + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.text() +} \ No newline at end of file diff --git a/src/services/rolesyaplicaciones.js b/src/services/rolesyaplicaciones.js new file mode 100644 index 0000000..6b2a789 --- /dev/null +++ b/src/services/rolesyaplicaciones.js @@ -0,0 +1,58 @@ +import { base, getToken } from './_config' + +export async function getRolesyaplicaciones(idRol) { + const params = idRol ? { id_rol: idRol } : null; // Preparar los parámetros de la consulta + const query = params ? '?' + new URLSearchParams(params).toString() : ''; + const res = await fetch(`${base}/rolyaplicacion/${query}`, { + headers: {"Authorization": `Bearer ${getToken()}`,"Content-Type": "application/json"} + }); + if (!res.ok) throw await res.json(); + return res.json(); +} + +export async function getRolesaplicaciones(params) { + const query = !params ? '' : '?' + (new URLSearchParams(params).toString()); + const res = await fetch(`${base}/rolyaplicacion/${query}`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + + +export async function getRolyaplicacion(id) { + const res = await fetch(`${base}/rolyaplicacion/${id}/`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function createRolyaplicacion(data) { + const res = await fetch(`${base}/rolyaplicacion/`, { + method: 'POST', + body: JSON.stringify(data), + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function updateRolyaplicacion({ id_rol_app: id, ...data }) { + const res = await fetch(`${base}/rolyaplicacion/${id}/`, { + method: 'PATCH', + body: JSON.stringify(data), + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function deleteRolyaplicacion(id) { + const res = await fetch(`${base}/rolyaplicacion/${id}/`, { + method: 'DELETE', + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.text() +} \ No newline at end of file