From c97f4066aa23ebba22a2acd8277e74a77a612b7f Mon Sep 17 00:00:00 2001 From: Ronald Morales Date: Mon, 29 Jan 2024 20:20:33 -0300 Subject: [PATCH] app red Transporte- operador - listado gtfs --- src/layouts/Footer.svelte | 2 +- src/layouts/Sidebar.svelte | 17 ++ src/pages/gtfs_archivo/Admin.svelte | 117 ++++++++++++++ .../gtfs_archivo/FiltroRedTransporte.svelte | 54 +++++++ src/pages/operadores/Admin.svelte | 127 +++++++++++++++ src/pages/operadores/ModalOperador.svelte | 101 ++++++++++++ src/pages/red_transporte/Admin.svelte | 146 ++++++++++++++++++ .../red_transporte/ModalRedTransporte.svelte | 119 ++++++++++++++ src/routes/user.routes.js | 6 + src/services/gtfs_archivo.js | 47 ++++++ src/services/operadores.js | 2 +- src/services/red_transporte.js | 47 ++++++ 12 files changed, 783 insertions(+), 2 deletions(-) create mode 100644 src/pages/gtfs_archivo/Admin.svelte create mode 100644 src/pages/gtfs_archivo/FiltroRedTransporte.svelte create mode 100644 src/pages/operadores/Admin.svelte create mode 100644 src/pages/operadores/ModalOperador.svelte create mode 100644 src/pages/red_transporte/Admin.svelte create mode 100644 src/pages/red_transporte/ModalRedTransporte.svelte create mode 100644 src/services/gtfs_archivo.js create mode 100644 src/services/red_transporte.js diff --git a/src/layouts/Footer.svelte b/src/layouts/Footer.svelte index 4be67ed..04476da 100644 --- a/src/layouts/Footer.svelte +++ b/src/layouts/Footer.svelte @@ -5,7 +5,7 @@

- EMPRESA S.A. + . ©

diff --git a/src/layouts/Sidebar.svelte b/src/layouts/Sidebar.svelte index 6098186..efa3b4d 100644 --- a/src/layouts/Sidebar.svelte +++ b/src/layouts/Sidebar.svelte @@ -36,6 +36,13 @@ Rutas + + + + + + Listado Archivos GTFS + @@ -49,6 +56,16 @@ Aplicaciones + + + Red de Transporte + + + + + Operadores + + Servicios de Buses diff --git a/src/pages/gtfs_archivo/Admin.svelte b/src/pages/gtfs_archivo/Admin.svelte new file mode 100644 index 0000000..983ce99 --- /dev/null +++ b/src/pages/gtfs_archivo/Admin.svelte @@ -0,0 +1,117 @@ + + +Listado Archivos GTFS + +
+ +
+
+ + + + + + + + + + + + + + + + {#each lista_gtfs as app, index} + + + + + + + + + {/each} + +
Nro + onOrderBy('id_gtfs')}>ID + {#if ordering === 'id_gtfs'}{/if} + {#if ordering === '-id_gtfs'}{/if} + + onOrderBy('nombre_red')}>Archivo + {#if ordering === 'archivo'}{/if} + {#if ordering === '-archivo'}{/if} + + onOrderBy('created')}>Creado el + {#if ordering === 'created'}{/if} + {#if ordering === '-created'}{/if} + + onOrderBy('status')}>Estado + {#if ordering === 'status'}{/if} + {#if ordering === '-status'}{/if} + + onOrderBy('vigente')}>Vigente + {#if ordering === 'vigente'}{/if} + {#if ordering === '-vigente'}{/if} +
{offset + index + 1}{app.id_red}{app.archivo}{app.created}{app.status}{app.vigente ? '✅':'🚫'}
+
+
+ +
+ + + \ No newline at end of file diff --git a/src/pages/gtfs_archivo/FiltroRedTransporte.svelte b/src/pages/gtfs_archivo/FiltroRedTransporte.svelte new file mode 100644 index 0000000..6a6f34e --- /dev/null +++ b/src/pages/gtfs_archivo/FiltroRedTransporte.svelte @@ -0,0 +1,54 @@ + + +
+
+ +
+
Redes de Transporte
+ +
+ + + +
+ +
diff --git a/src/pages/operadores/Admin.svelte b/src/pages/operadores/Admin.svelte new file mode 100644 index 0000000..fffc119 --- /dev/null +++ b/src/pages/operadores/Admin.svelte @@ -0,0 +1,127 @@ + + +Operadores + +
+
+ {#if escritura} + + {/if} +
+
+
+ + + + + + + + + + + + {#each operadores as app, index} + + + + + + + {/each} + +
Nro + onOrderBy('id_operador')}>ID + {#if ordering === 'id_operador'}{/if} + {#if ordering === '-id_operador'}{/if} + + onOrderBy('nombre_operador')}>Nombre + {#if ordering === 'nombre_operador'}{/if} + {#if ordering === '-nombre_operador'}{/if} + + onOrderBy('vigente')}>Vigente + {#if ordering === 'vigente'}{/if} + {#if ordering === '-vigente'}{/if} +
{offset + index + 1}{app.id_operador} onEdita(app)}>{app.nombre_operador}{app.vigente ? '✅':'🚫'}
+
+
+ +
+ + +{#if operador} + operador = null} + on:refresh={() => onPage(page)} + /> +{/if} + + \ No newline at end of file diff --git a/src/pages/operadores/ModalOperador.svelte b/src/pages/operadores/ModalOperador.svelte new file mode 100644 index 0000000..d082a45 --- /dev/null +++ b/src/pages/operadores/ModalOperador.svelte @@ -0,0 +1,101 @@ + + +
+ dispatch('close')}> +
+
+
ID
+
+ {#if operador.id_operador} + + {:else} + + {/if} +
+
+
+
Nombre
+
+ +
+
+ +
+
+ + +
+
+
+ + {#if escritura} + + + {/if} + +
+
+ + \ No newline at end of file diff --git a/src/pages/red_transporte/Admin.svelte b/src/pages/red_transporte/Admin.svelte new file mode 100644 index 0000000..ed41d4b --- /dev/null +++ b/src/pages/red_transporte/Admin.svelte @@ -0,0 +1,146 @@ + + +Redes de Transporte + +
+
+ {#if escritura} + + {/if} +
+
+
+ + + + + + + + + + + + + + + + {#each redes as app, index} + + + + + + + + + + {/each} + +
Nro + onOrderBy('id_red')}>ID + {#if ordering === 'id_red'}{/if} + {#if ordering === '-id_red'}{/if} + + onOrderBy('nombre_red')}>Nombre + {#if ordering === 'nombre_red'}{/if} + {#if ordering === '-nombre_red'}{/if} + + onOrderBy('descripcion')}>Descripcion + {#if ordering === 'descripcion'}{/if} + {#if ordering === '-descripcion'}{/if} + + onOrderBy('url_gtfs_rt')}>URL_GTFS_RT + {#if ordering === 'url_gtfs_rt'}{/if} + {#if ordering === '-url_gtfs_rt'}{/if} + + onOrderBy('api_key')}>api_key + {#if ordering === 'api_key'}{/if} + {#if ordering === '-api_key'}{/if} + + onOrderBy('vigente')}>Vigente + {#if ordering === 'vigente'}{/if} + {#if ordering === '-vigente'}{/if} +
{offset + index + 1}{app.id_red} onEdita(app)}>{app.nombre_red}{app.descripcion}{app.url_gtfs_rt}{app.api_key}{app.vigente ? '✅':'🚫'}
+
+
+ +
+ +{#if red} + red = null} + on:refresh={() => onPage(page)} + /> +{/if} + + \ No newline at end of file diff --git a/src/pages/red_transporte/ModalRedTransporte.svelte b/src/pages/red_transporte/ModalRedTransporte.svelte new file mode 100644 index 0000000..ea45235 --- /dev/null +++ b/src/pages/red_transporte/ModalRedTransporte.svelte @@ -0,0 +1,119 @@ + + +
+ dispatch('close')}> +
+
+
ID
+
+ {#if red.id_red} + + {:else} + + {/if} +
+
+
+
Nombre
+
+ +
+
+
+
Descripcion
+
+ +
+
+
+
URL GTFS-RT
+
+ +
+
+
+
API Key
+
+ +
+
+
+
+ + +
+
+
+ + {#if escritura} + + + {/if} + +
+
+ + \ No newline at end of file diff --git a/src/routes/user.routes.js b/src/routes/user.routes.js index b228de5..a9bcc20 100644 --- a/src/routes/user.routes.js +++ b/src/routes/user.routes.js @@ -2,6 +2,9 @@ import PageHome from '$/pages/site/Home.svelte' import PagePerfil from '$/pages/usuarios/Perfil.svelte' import PageError from '$/pages/site/Error.svelte' import PageAplicaciones from '$/pages/aplicaciones/Admin.svelte' +import PageOperador from '$/pages/operadores/Admin.svelte' +import PageRedTransporte from '$/pages/red_transporte/Admin.svelte' +import PageArchivoGTFS from '$/pages/gtfs_archivo/Admin.svelte' import PageUsuarios from '$/pages/usuarios/Admin.svelte' import PageUsuarioCreate from '$/pages/usuarios/Usuario.svelte' import PageUsuarioModifica from '$/pages/usuarios/Usuario.svelte' @@ -21,6 +24,9 @@ export const routes_base = [ { path: '/', component: PageHome, public: true }, { path: '/perfil', component: PagePerfil, public: true }, { path: '/aplicaciones', component: PageAplicaciones }, + { path: '/red-transporte', component: PageRedTransporte }, + { path: '/gtfs-archivo', component: PageArchivoGTFS }, + { path: '/operadores', component: PageOperador }, { path: '/usuarios', component: PageUsuarios }, { path: '/usuarios/nuevo', component: PageUsuarioCreate }, { path: '/usuarios/:login', component: PageUsuarioModifica }, diff --git a/src/services/gtfs_archivo.js b/src/services/gtfs_archivo.js new file mode 100644 index 0000000..646d2da --- /dev/null +++ b/src/services/gtfs_archivo.js @@ -0,0 +1,47 @@ +import { base, getToken } from './_config' + +export async function getGtfsArchivo(params) { + const query = !params ? '' : '?' + (new URLSearchParams(params).toString()); + const res = await fetch(`${base}/gtfs-archivo/${query}`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function getGtfsArchivoId(id) { + const res = await fetch(`${base}/gtfs-archivo/${id}/`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function createGtfsArchivo(data) { + const res = await fetch(`${base}/gtfs-archivo/`, { + 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 updateGtfsArchivo({ id_red: id = null, ...data }) { + const res = await fetch(`${base}/gtfs-archivo/${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 deleteGtfsArchivo(id) { + const res = await fetch(`${base}/gtfs-archivo/${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/operadores.js b/src/services/operadores.js index e01da0e..5d8a194 100644 --- a/src/services/operadores.js +++ b/src/services/operadores.js @@ -44,5 +44,5 @@ export async function deleteOperador(id) { headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } }) if (!res.ok) throw await res.text() - return res.json() + return res.text() } diff --git a/src/services/red_transporte.js b/src/services/red_transporte.js new file mode 100644 index 0000000..5f89cec --- /dev/null +++ b/src/services/red_transporte.js @@ -0,0 +1,47 @@ +import { base, getToken } from './_config' + +export async function getRedTransporte(params) { + const query = !params ? '' : '?' + (new URLSearchParams(params).toString()); + const res = await fetch(`${base}/red-transporte/${query}`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function getRedTransporteId(id) { + const res = await fetch(`${base}/red-transporte/${id}/`, { + headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" } + }) + if (!res.ok) throw await res.json() + return res.json() +} + +export async function createRedTransporte(data) { + const res = await fetch(`${base}/red-transporte/`, { + 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 updateRedTransporte({ id_red: id = null, ...data }) { + const res = await fetch(`${base}/red-transporte/${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 deleteRedTransporte(id) { + const res = await fetch(`${base}/red-transporte/${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