Implementa un agente financiero que consulta información sobre la inflación en Argentina utilizando OpenAI y herramientas de Wikipedia y Yahoo Finance. Se define un flujo de trabajo en Prefect para gestionar la ejecución y el registro de mensajes enviados al modelo.
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
|||||||
|
# Python-generated files
|
||||||
|
__pycache__/
|
||||||
|
*.py[oc]
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
wheels/
|
||||||
|
*.egg-info
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
.venv
|
||||||
|
.env
|
||||||
|
|
||||||
|
frontend/node_modules/
|
||||||
|
artifacts/
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3.13
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"version": "1",
|
||||||
|
"metadata": {
|
||||||
|
"marimo_version": "0.16.5"
|
||||||
|
},
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"id": "MJUe",
|
||||||
|
"code_hash": "cae6295b5ea6a5a8bbeb3a4b62455e9b",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"type": "data",
|
||||||
|
"data": {
|
||||||
|
"text/html": "<span class=\"markdown prose dark:prose-invert\"><h1 id=\"grafana-inicializacion-automatica\">Grafana: Inicializaci\u00f3n autom\u00e1tica \ud83d\ude80</h1></span>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Hbol",
|
||||||
|
"code_hash": "1d0db38904205bec4d6f6f6a1f6cec3e",
|
||||||
|
"outputs": [],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "vblA",
|
||||||
|
"code_hash": "b49a6e0c12564133fa8062d7ab194132",
|
||||||
|
"outputs": [],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "bkHC",
|
||||||
|
"code_hash": "ff918159a708fa3e7707f530b4065044",
|
||||||
|
"outputs": [],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lEQa",
|
||||||
|
"code_hash": "4d9a7cdeb028ab0e0df782ba3a18ec56",
|
||||||
|
"outputs": [],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "PKri",
|
||||||
|
"code_hash": "00c3d02fb8d07fe71d1cfee535b803bf",
|
||||||
|
"outputs": [],
|
||||||
|
"console": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
|||||||
|
from fastapi import APIRouter
|
||||||
|
from primera_ejecucion_de_un_agente import flujo_principal as run_task
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/run")
|
||||||
|
def execute_task(task_name: str):
|
||||||
|
result = run_task()
|
||||||
|
return {"task": task_name, "result": result}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
receivers:
|
||||||
|
otlp:
|
||||||
|
protocols:
|
||||||
|
grpc:
|
||||||
|
http:
|
||||||
|
|
||||||
|
processors:
|
||||||
|
batch:
|
||||||
|
|
||||||
|
exporters:
|
||||||
|
clickhousetraces:
|
||||||
|
endpoint: tcp://clickhouse:9000?database=signoz_traces
|
||||||
|
tls:
|
||||||
|
insecure: true
|
||||||
|
|
||||||
|
signozclickhousemetrics:
|
||||||
|
dsn: tcp://clickhouse:9000?database=signoz_metrics
|
||||||
|
tls:
|
||||||
|
insecure: true
|
||||||
|
|
||||||
|
service:
|
||||||
|
pipelines:
|
||||||
|
traces:
|
||||||
|
receivers: [otlp]
|
||||||
|
processors: [batch]
|
||||||
|
exporters: [clickhousetraces]
|
||||||
|
metrics:
|
||||||
|
receivers: [otlp]
|
||||||
|
processors: [batch]
|
||||||
|
exporters: [signozclickhousemetrics]
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
-- Habilitar extensiones solicitadas
|
||||||
|
CREATE EXTENSION IF NOT EXISTS hstore;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS citext;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS tablefunc;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS unaccent;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS ltree;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS vector;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS timescaledb;
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
name: npm test
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test_pull_request:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: '**/yarn.lock'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn
|
||||||
|
- name: Run build
|
||||||
|
run: npm run build
|
||||||
|
- name: Run tests
|
||||||
|
run: npm test
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.vscode
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
v24.3.0
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/** @type {import("@ianvs/prettier-plugin-sort-imports").PrettierConfig} */
|
||||||
|
const config = {
|
||||||
|
printWidth: 100,
|
||||||
|
singleQuote: true,
|
||||||
|
trailingComma: 'es5',
|
||||||
|
plugins: ['@ianvs/prettier-plugin-sort-imports'],
|
||||||
|
importOrder: [
|
||||||
|
'.*styles.css$',
|
||||||
|
'',
|
||||||
|
'dayjs',
|
||||||
|
'^react$',
|
||||||
|
'^next$',
|
||||||
|
'^next/.*$',
|
||||||
|
'<BUILTIN_MODULES>',
|
||||||
|
'<THIRD_PARTY_MODULES>',
|
||||||
|
'^@mantine/(.*)$',
|
||||||
|
'^@mantinex/(.*)$',
|
||||||
|
'^@mantine-tests/(.*)$',
|
||||||
|
'^@docs/(.*)$',
|
||||||
|
'^@/.*$',
|
||||||
|
'^../(?!.*.css$).*$',
|
||||||
|
'^./(?!.*.css$).*$',
|
||||||
|
'\\.css$',
|
||||||
|
],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: '*.mdx',
|
||||||
|
options: {
|
||||||
|
printWidth: 70,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import type { StorybookConfig } from '@storybook/react-vite';
|
||||||
|
|
||||||
|
const config: StorybookConfig = {
|
||||||
|
core: {
|
||||||
|
disableWhatsNewNotifications: true,
|
||||||
|
disableTelemetry: true,
|
||||||
|
enableCrashReports: false,
|
||||||
|
},
|
||||||
|
stories: ['../src/**/*.mdx', '../src/**/*.story.@(js|jsx|ts|tsx)'],
|
||||||
|
addons: ['@storybook/addon-themes'],
|
||||||
|
framework: {
|
||||||
|
name: '@storybook/react-vite',
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import '@mantine/core/styles.css';
|
||||||
|
|
||||||
|
import { ColorSchemeScript, MantineProvider } from '@mantine/core';
|
||||||
|
import { theme } from '../src/theme';
|
||||||
|
|
||||||
|
export const parameters = {
|
||||||
|
layout: 'fullscreen',
|
||||||
|
options: {
|
||||||
|
showPanel: false,
|
||||||
|
storySort: (a: any, b: any) => a.title.localeCompare(b.title, undefined, { numeric: true }),
|
||||||
|
},
|
||||||
|
backgrounds: { disable: true },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const globalTypes = {
|
||||||
|
theme: {
|
||||||
|
name: 'Theme',
|
||||||
|
description: 'Mantine color scheme',
|
||||||
|
defaultValue: 'light',
|
||||||
|
toolbar: {
|
||||||
|
icon: 'mirror',
|
||||||
|
items: [
|
||||||
|
{ value: 'light', title: 'Light' },
|
||||||
|
{ value: 'dark', title: 'Dark' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const decorators = [
|
||||||
|
(renderStory: any, context: any) => {
|
||||||
|
const scheme = (context.globals.theme || 'light') as 'light' | 'dark';
|
||||||
|
return (
|
||||||
|
<MantineProvider theme={theme} forceColorScheme={scheme}>
|
||||||
|
<ColorSchemeScript />
|
||||||
|
{renderStory()}
|
||||||
|
</MantineProvider>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
dist
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"extends": ["stylelint-config-standard-scss"],
|
||||||
|
"rules": {
|
||||||
|
"custom-property-pattern": null,
|
||||||
|
"selector-class-pattern": null,
|
||||||
|
"scss/no-duplicate-mixins": null,
|
||||||
|
"declaration-empty-line-before": null,
|
||||||
|
"declaration-block-no-redundant-longhand-properties": null,
|
||||||
|
"alpha-value-notation": null,
|
||||||
|
"custom-property-empty-line-before": null,
|
||||||
|
"property-no-vendor-prefix": null,
|
||||||
|
"color-function-notation": null,
|
||||||
|
"length-zero-no-unit": null,
|
||||||
|
"selector-not-notation": null,
|
||||||
|
"no-descending-specificity": null,
|
||||||
|
"comment-empty-line-before": null,
|
||||||
|
"scss/at-mixin-pattern": null,
|
||||||
|
"scss/at-rule-no-unknown": null,
|
||||||
|
"value-keyword-case": null,
|
||||||
|
"media-feature-range-notation": null,
|
||||||
|
"selector-pseudo-class-no-unknown": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"ignorePseudoClasses": ["global"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
+942
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
|
|||||||
|
nodeLinker: node-modules
|
||||||
|
|
||||||
|
yarnPath: .yarn/releases/yarn-4.10.3.cjs
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Mantine Vite template
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
This template comes with the following features:
|
||||||
|
|
||||||
|
- [PostCSS](https://postcss.org/) with [mantine-postcss-preset](https://mantine.dev/styles/postcss-preset)
|
||||||
|
- [TypeScript](https://www.typescriptlang.org/)
|
||||||
|
- [Storybook](https://storybook.js.org/)
|
||||||
|
- [Vitest](https://vitest.dev/) setup with [React Testing Library](https://testing-library.com/docs/react-testing-library/intro)
|
||||||
|
- ESLint setup with [eslint-config-mantine](https://github.com/mantinedev/eslint-config-mantine)
|
||||||
|
|
||||||
|
## npm scripts
|
||||||
|
|
||||||
|
## Build and dev scripts
|
||||||
|
|
||||||
|
- `dev` – start development server
|
||||||
|
- `build` – build production version of the app
|
||||||
|
- `preview` – locally preview production build
|
||||||
|
|
||||||
|
### Testing scripts
|
||||||
|
|
||||||
|
- `typecheck` – checks TypeScript types
|
||||||
|
- `lint` – runs ESLint
|
||||||
|
- `prettier:check` – checks files with Prettier
|
||||||
|
- `vitest` – runs vitest tests
|
||||||
|
- `vitest:watch` – starts vitest watch
|
||||||
|
- `test` – runs `vitest`, `prettier:check`, `lint` and `typecheck` scripts
|
||||||
|
|
||||||
|
### Other scripts
|
||||||
|
|
||||||
|
- `storybook` – starts storybook dev server
|
||||||
|
- `storybook:build` – build production storybook bundle to `storybook-static`
|
||||||
|
- `prettier:write` – formats all files with Prettier
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import mantine from 'eslint-config-mantine';
|
||||||
|
import { defineConfig } from 'eslint/config';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
|
||||||
|
// @ts-check
|
||||||
|
export default defineConfig(
|
||||||
|
tseslint.configs.recommended,
|
||||||
|
...mantine,
|
||||||
|
{ ignores: ['**/*.{mjs,cjs,js,d.ts,d.mts}'] },
|
||||||
|
{
|
||||||
|
files: ['**/*.story.tsx'],
|
||||||
|
rules: { 'no-console': 'off' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
tsconfigRootDir: process.cwd(),
|
||||||
|
project: ['./tsconfig.json'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="minimum-scale=1, initial-scale=1, width=device-width, user-scalable=no"
|
||||||
|
/>
|
||||||
|
<title>My App</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Generated
+9602
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
"name": "mantine-vite-template",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
|
"lint": "npm run eslint && npm run stylelint",
|
||||||
|
"eslint": "eslint . --cache",
|
||||||
|
"stylelint": "stylelint '**/*.css' --cache",
|
||||||
|
"prettier": "prettier --check \"**/*.{ts,tsx}\"",
|
||||||
|
"prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
|
||||||
|
"vitest": "vitest run",
|
||||||
|
"vitest:watch": "vitest",
|
||||||
|
"test": "npm run typecheck && npm run prettier && npm run lint && npm run vitest && npm run build",
|
||||||
|
"storybook": "storybook dev -p 6006",
|
||||||
|
"storybook:build": "storybook build"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@mantine/core": "8.3.1",
|
||||||
|
"@mantine/hooks": "8.3.1",
|
||||||
|
"@phosphor-icons/react": "^2.1.10",
|
||||||
|
"@react-three/fiber": "^9.3.0",
|
||||||
|
"dockview": "^4.9.0",
|
||||||
|
"phosphor-react": "^1.4.1",
|
||||||
|
"react": "^19.1.1",
|
||||||
|
"react-dom": "^19.1.1",
|
||||||
|
"react-router-dom": "^7.8.2",
|
||||||
|
"three": "^0.180.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.35.0",
|
||||||
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
|
||||||
|
"@storybook/addon-themes": "^9.1.5",
|
||||||
|
"@storybook/react": "^9.1.5",
|
||||||
|
"@storybook/react-vite": "^9.1.5",
|
||||||
|
"@testing-library/dom": "^10.4.1",
|
||||||
|
"@testing-library/jest-dom": "^6.8.0",
|
||||||
|
"@testing-library/react": "^16.3.0",
|
||||||
|
"@testing-library/user-event": "^14.6.1",
|
||||||
|
"@types/node": "^24.3.1",
|
||||||
|
"@types/react": "^19.1.12",
|
||||||
|
"@types/react-dom": "^19.1.9",
|
||||||
|
"@vitejs/plugin-react": "^5.0.2",
|
||||||
|
"eslint": "^9.35.0",
|
||||||
|
"eslint-config-mantine": "^4.0.3",
|
||||||
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"identity-obj-proxy": "^3.0.0",
|
||||||
|
"jsdom": "^26.1.0",
|
||||||
|
"postcss": "^8.5.6",
|
||||||
|
"postcss-preset-mantine": "1.18.0",
|
||||||
|
"postcss-simple-vars": "^7.0.1",
|
||||||
|
"prettier": "^3.6.2",
|
||||||
|
"prop-types": "^15.8.1",
|
||||||
|
"storybook": "^9.1.5",
|
||||||
|
"stylelint": "^16.24.0",
|
||||||
|
"stylelint-config-standard-scss": "^16.0.0",
|
||||||
|
"typescript": "^5.9.2",
|
||||||
|
"typescript-eslint": "^8.43.0",
|
||||||
|
"vite": "^7.1.5",
|
||||||
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
|
"vitest": "^3.2.4"
|
||||||
|
},
|
||||||
|
"packageManager": "yarn@4.9.4"
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: {
|
||||||
|
'postcss-preset-mantine': {},
|
||||||
|
'postcss-simple-vars': {
|
||||||
|
variables: {
|
||||||
|
'mantine-breakpoint-xs': '36em',
|
||||||
|
'mantine-breakpoint-sm': '48em',
|
||||||
|
'mantine-breakpoint-md': '62em',
|
||||||
|
'mantine-breakpoint-lg': '75em',
|
||||||
|
'mantine-breakpoint-xl': '88em',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import '@mantine/core/styles.css';
|
||||||
|
|
||||||
|
import { MantineProvider } from '@mantine/core';
|
||||||
|
import { Router } from './Router';
|
||||||
|
import { theme } from './theme';
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
return (
|
||||||
|
<MantineProvider theme={theme}>
|
||||||
|
<Router />
|
||||||
|
</MantineProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
|
||||||
|
import { HomePage } from './pages/Home.page';
|
||||||
|
import { Error_404 } from './components/404/404';
|
||||||
|
|
||||||
|
const router = createBrowserRouter([
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
element: <HomePage />,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
path: '*',
|
||||||
|
element: <Error_404 /> },
|
||||||
|
]);
|
||||||
|
|
||||||
|
export function Router() {
|
||||||
|
return <RouterProvider router={router} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { Box, Title, Text, Button, Group, Stack, Image, Center } from '@mantine/core';
|
||||||
|
import { useMantineTheme } from '@mantine/core';
|
||||||
|
import { ArrowLeft } from 'phosphor-react'; // ← Importa el icono directamente
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { MantineCardWithShader } from './HoloShader_404';
|
||||||
|
import { AppShellWithMenu } from '../Appshell/Appshell';
|
||||||
|
|
||||||
|
export function Error_404() {
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppShellWithMenu>
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
padding: '2rem',
|
||||||
|
paddingTop: '0.5rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
padding: '2rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack align="center" maw={500} mx="auto">
|
||||||
|
<MantineCardWithShader />
|
||||||
|
<Title order={1}>Página no encontrada</Title>
|
||||||
|
<Text size="lg">
|
||||||
|
Parece que la página que estás buscando no existe o fue removida. Pero no te preocupes,
|
||||||
|
puedes volver al inicio fácilmente.
|
||||||
|
</Text>
|
||||||
|
<Group mt="md">
|
||||||
|
<Button
|
||||||
|
component={Link}
|
||||||
|
to="/"
|
||||||
|
size="md"
|
||||||
|
variant="gradient"
|
||||||
|
gradient={{
|
||||||
|
from: theme.colors.brand[7],
|
||||||
|
to: theme.colors.secondary[4],
|
||||||
|
}}
|
||||||
|
leftSection={<ArrowLeft size={18} />} // ← Usa el icono Phosphor aquí
|
||||||
|
>
|
||||||
|
Volver al inicio
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</AppShellWithMenu>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
import { Card, Title, Box, useMantineTheme } from '@mantine/core';
|
||||||
|
import { Canvas, extend, useFrame, useThree } from '@react-three/fiber';
|
||||||
|
import { useRef, useMemo } from 'react';
|
||||||
|
import * as THREE from 'three';
|
||||||
|
|
||||||
|
// 🎨 Utilidad para convertir hex a RGB [0–1]
|
||||||
|
function hexToRGBArray(hex: string): [number, number, number] {
|
||||||
|
const bigint = parseInt(hex.replace('#', ''), 16);
|
||||||
|
return [
|
||||||
|
((bigint >> 16) & 255) / 255,
|
||||||
|
((bigint >> 8) & 255) / 255,
|
||||||
|
(bigint & 255) / 255,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✨ Shader personalizado estilo holográfico, con color dinámico
|
||||||
|
class HoloShaderMaterial extends THREE.ShaderMaterial {
|
||||||
|
constructor(color: [number, number, number]) {
|
||||||
|
super({
|
||||||
|
uniforms: {
|
||||||
|
u_time: { value: 0 },
|
||||||
|
u_resolution: { value: new THREE.Vector2() },
|
||||||
|
u_color: { value: new THREE.Vector3(...color) },
|
||||||
|
},
|
||||||
|
vertexShader: `
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(position, 1.0);
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
fragmentShader: `
|
||||||
|
precision mediump float;
|
||||||
|
uniform float u_time;
|
||||||
|
uniform vec2 u_resolution;
|
||||||
|
uniform vec3 u_color;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 uv = gl_FragCoord.xy / u_resolution;
|
||||||
|
vec2 pos = uv * 10.0;
|
||||||
|
pos.x += u_time * 0.3;
|
||||||
|
pos.y += sin(u_time * 0.2) * 2.0;
|
||||||
|
|
||||||
|
float color = sin(pos.x + sin(pos.y + sin(pos.x))) * 0.5 + 0.5;
|
||||||
|
|
||||||
|
vec3 c = vec3(
|
||||||
|
u_color.r + 0.2 * sin(u_time + pos.x),
|
||||||
|
u_color.g + 0.2 * cos(u_time + pos.y),
|
||||||
|
u_color.b + 0.2 * sin(pos.x + pos.y + u_time)
|
||||||
|
);
|
||||||
|
|
||||||
|
gl_FragColor = vec4(c * color, 1.0);
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extend({ HoloShaderMaterial });
|
||||||
|
|
||||||
|
// 🎥 Plano con el shader
|
||||||
|
function HoloPlane({ color }: { color: [number, number, number] }) {
|
||||||
|
const mat = useRef<any>(null);
|
||||||
|
const { size } = useThree();
|
||||||
|
|
||||||
|
useFrame(({ clock }) => {
|
||||||
|
if (mat.current) {
|
||||||
|
mat.current.uniforms.u_time.value = clock.getElapsedTime();
|
||||||
|
mat.current.uniforms.u_resolution.value.set(size.width, size.height);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const material = useMemo(() => new HoloShaderMaterial(color), [color]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<mesh>
|
||||||
|
<planeGeometry args={[2, 2]} />
|
||||||
|
<primitive object={material} ref={mat} attach="material" />
|
||||||
|
</mesh>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🎨 Fondo que ocupa todo el contenedor
|
||||||
|
function HolographicBackground({ color }: { color: [number, number, number] }) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
inset: 0,
|
||||||
|
zIndex: 0,
|
||||||
|
pointerEvents: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Canvas orthographic camera={{ zoom: 1, position: [0, 0, 1] }}>
|
||||||
|
<HoloPlane color={color} />
|
||||||
|
</Canvas>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🧩 Componente final con fondo shader y texto 404
|
||||||
|
export function MantineCardWithShader() {
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
const hex = theme.colors[theme.primaryColor][6];
|
||||||
|
const rgb = hexToRGBArray(hex);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
withBorder
|
||||||
|
radius="lg"
|
||||||
|
shadow="xl"
|
||||||
|
style={{
|
||||||
|
position: 'relative',
|
||||||
|
overflow: 'hidden',
|
||||||
|
minHeight: 300,
|
||||||
|
minWidth: 400,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<HolographicBackground color={rgb} />
|
||||||
|
|
||||||
|
<Box style={{ position: 'relative', zIndex: 1, textAlign: 'center' }}>
|
||||||
|
<Title
|
||||||
|
order={1}
|
||||||
|
style={{
|
||||||
|
fontSize: '15rem',
|
||||||
|
fontWeight: 900,
|
||||||
|
backgroundImage: 'linear-gradient(to bottom, rgba(255,255,255,1), rgba(255,255,255,0))',
|
||||||
|
WebkitBackgroundClip: 'text',
|
||||||
|
WebkitTextFillColor: 'transparent',
|
||||||
|
textAlign: 'center',
|
||||||
|
lineHeight: 1,
|
||||||
|
userSelect: 'none', // <-- evita selección
|
||||||
|
textDecoration: 'none', // <-- evita subrayado
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
404
|
||||||
|
</Title>
|
||||||
|
</Box>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
.navbar {
|
||||||
|
height: 100vh; /* ← Ocupa todo el alto de la ventana */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background-color: light-dark(var(--mantine-color-white), var(--mantine-color-dark-6));
|
||||||
|
width: 300px;
|
||||||
|
border-right: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
|
||||||
|
position: sticky; /* ← Opcional, si quieres que se quede "pegado" */
|
||||||
|
top: 0; /* ← Ancla arriba */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-family:
|
||||||
|
Greycliff CF,
|
||||||
|
var(--mantine-font-family);
|
||||||
|
margin-bottom: var(--mantine-spacing-sm);
|
||||||
|
background-color: var(--mantine-color-body);
|
||||||
|
padding: var(--mantine-spacing-xs);
|
||||||
|
padding-top: 15px;
|
||||||
|
height: 50px;
|
||||||
|
border-bottom: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-7));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Esta es la barra izquierda pequeña donde los iconos */
|
||||||
|
.aside {
|
||||||
|
flex: 0 0 52px;
|
||||||
|
background-color: var(--mantine-color-body);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
border-right: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-7));
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
flex: 1;
|
||||||
|
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-6));
|
||||||
|
}
|
||||||
|
|
||||||
|
.topSection {
|
||||||
|
padding-top: 12px; /* o la cantidad que desees */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Estos son los iconos */
|
||||||
|
.mainLink {
|
||||||
|
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
border-radius: var(--mantine-radius-md);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-dark-0));
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-5));
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-active] {
|
||||||
|
&,
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--mantine-color-brand-7);
|
||||||
|
color: var(--mantine-color-brand-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.link {
|
||||||
|
display: block;
|
||||||
|
text-decoration: none;
|
||||||
|
border-top-right-radius: var(--mantine-radius-md);
|
||||||
|
border-bottom-right-radius: var(--mantine-radius-md);
|
||||||
|
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-dark-0));
|
||||||
|
padding: 0 var(--mantine-spacing-md);
|
||||||
|
font-size: var(--mantine-font-size-sm);
|
||||||
|
margin-right: var(--mantine-spacing-md);
|
||||||
|
font-weight: 420;
|
||||||
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: light-dark(var(--mantine-color-gray-1), var(--mantine-color-dark-5));
|
||||||
|
color: light-dark(var(--mantine-color-dark), var(--mantine-color-light));
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-active] {
|
||||||
|
&,
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--mantine-color-brand-7);
|
||||||
|
color: var(--mantine-color-brand-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
import {
|
||||||
|
AppShell,
|
||||||
|
Burger,
|
||||||
|
Group,
|
||||||
|
Tooltip,
|
||||||
|
UnstyledButton,
|
||||||
|
Title,
|
||||||
|
useMantineTheme,
|
||||||
|
} from '@mantine/core';
|
||||||
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
|
import { useEffect, useMemo } from 'react';
|
||||||
|
import { Link, useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { submenuLinks } from './Links_Appshell/submenuLinks';
|
||||||
|
import { mainLinksdata } from './Links_Appshell/navigationsLinks';
|
||||||
|
import { default as LogoIcon } from '../icons/favicon';
|
||||||
|
|
||||||
|
import classes from './Appshell.module.css';
|
||||||
|
|
||||||
|
import {
|
||||||
|
useAppShellStore,
|
||||||
|
getLastSubmenuRoute,
|
||||||
|
setLastSubmenuRoute,
|
||||||
|
} from '@/stores/useAppShellStore';
|
||||||
|
|
||||||
|
type AppShellWithMenuProps = {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function AppShellWithMenu({ children }: AppShellWithMenuProps) {
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const isMobile = useMediaQuery('(max-width: 768px)');
|
||||||
|
|
||||||
|
// Zustand store
|
||||||
|
const {
|
||||||
|
activeMain,
|
||||||
|
setActiveMain,
|
||||||
|
activeLink,
|
||||||
|
setActiveLink,
|
||||||
|
mobileOpened,
|
||||||
|
desktopOpened,
|
||||||
|
toggleMobile,
|
||||||
|
toggleDesktop,
|
||||||
|
openDesktop,
|
||||||
|
closeMobile,
|
||||||
|
} = useAppShellStore();
|
||||||
|
|
||||||
|
const isCollapsed = useMemo(
|
||||||
|
() => (isMobile ? !mobileOpened : !desktopOpened),
|
||||||
|
[isMobile, mobileOpened, desktopOpened]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Detectar main activo según la ruta
|
||||||
|
useEffect(() => {
|
||||||
|
const currentPath =
|
||||||
|
location.pathname?.toLowerCase().replace(/\/$/, '') ?? '';
|
||||||
|
|
||||||
|
let matchedMain: string | null = null;
|
||||||
|
let maxMatchLength = 0;
|
||||||
|
|
||||||
|
Object.entries(submenuLinks).forEach(([main, items]) => {
|
||||||
|
items.forEach((item: { to: string }) => {
|
||||||
|
const itemPath = item.to.toLowerCase().replace(/\/$/, '');
|
||||||
|
if (currentPath === itemPath || currentPath.startsWith(itemPath + '/')) {
|
||||||
|
if (itemPath.length > maxMatchLength) {
|
||||||
|
matchedMain = main;
|
||||||
|
maxMatchLength = itemPath.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (matchedMain) setActiveMain(matchedMain);
|
||||||
|
}, [location.pathname, setActiveMain]);
|
||||||
|
|
||||||
|
// Actualizar activeLink
|
||||||
|
useEffect(() => {
|
||||||
|
const sublinks = submenuLinks[activeMain as keyof typeof submenuLinks] || [];
|
||||||
|
const found = sublinks.find((item) => item.to === location.pathname);
|
||||||
|
setActiveLink(found?.label ?? '');
|
||||||
|
}, [location.pathname, activeMain, setActiveLink]);
|
||||||
|
|
||||||
|
const mainLinks = mainLinksdata.map((link) => (
|
||||||
|
<Tooltip
|
||||||
|
label={link.label}
|
||||||
|
position="right"
|
||||||
|
withArrow
|
||||||
|
transitionProps={{ duration: 0 }}
|
||||||
|
key={link.label}
|
||||||
|
>
|
||||||
|
<UnstyledButton
|
||||||
|
onClick={() => {
|
||||||
|
setActiveMain(link.label);
|
||||||
|
const remembered = getLastSubmenuRoute(link.label);
|
||||||
|
const fallback =
|
||||||
|
submenuLinks[link.label as keyof typeof submenuLinks]?.[0]?.to;
|
||||||
|
if (isCollapsed && (remembered || fallback)) {
|
||||||
|
navigate(remembered ?? fallback);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className={classes.mainLink}
|
||||||
|
data-active={link.label === activeMain || undefined}
|
||||||
|
>
|
||||||
|
<link.icon size={24} weight="duotone" />
|
||||||
|
</UnstyledButton>
|
||||||
|
</Tooltip>
|
||||||
|
));
|
||||||
|
|
||||||
|
const links: React.ReactNode = (
|
||||||
|
(submenuLinks[activeMain as keyof typeof submenuLinks] || []) as {
|
||||||
|
label: string;
|
||||||
|
to: string;
|
||||||
|
}[]
|
||||||
|
).map((item) => (
|
||||||
|
<Link
|
||||||
|
className={classes.link}
|
||||||
|
data-active={activeLink === item.label || undefined}
|
||||||
|
to={item.to}
|
||||||
|
key={item.label}
|
||||||
|
style={{ display: isCollapsed ? 'none' : 'block' }}
|
||||||
|
onClick={() => {
|
||||||
|
setLastSubmenuRoute(activeMain, item.to);
|
||||||
|
if (isMobile) closeMobile();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isMobile) openDesktop();
|
||||||
|
}, [isMobile, openDesktop]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppShell
|
||||||
|
header={{ height: 60 }}
|
||||||
|
navbar={{
|
||||||
|
width: isCollapsed ? 60 : 300,
|
||||||
|
breakpoint: 'sm',
|
||||||
|
collapsed: { mobile: !mobileOpened, desktop: !desktopOpened },
|
||||||
|
}}
|
||||||
|
padding={0}
|
||||||
|
styles={{
|
||||||
|
main: {
|
||||||
|
height: '100dvh', // o '100vh', pero mejor con 100dvh para evitar bugs móviles
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Header */}
|
||||||
|
<AppShell.Header>
|
||||||
|
<Group h="100%" px="sm">
|
||||||
|
<Burger
|
||||||
|
opened={mobileOpened}
|
||||||
|
onClick={toggleMobile}
|
||||||
|
hiddenFrom="sm"
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
<Burger
|
||||||
|
opened={desktopOpened}
|
||||||
|
onClick={toggleDesktop}
|
||||||
|
visibleFrom="sm"
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
<LogoIcon
|
||||||
|
style={{ width: 30, height: 30 }}
|
||||||
|
circleFill={theme.colors.brand[9]}
|
||||||
|
pathFill={theme.colors.secondary[2]}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
</AppShell.Header>
|
||||||
|
|
||||||
|
{/* Navbar */}
|
||||||
|
<AppShell.Navbar>
|
||||||
|
<div className={classes.wrapper}>
|
||||||
|
<div className={classes.aside}>
|
||||||
|
<div className={classes.topSection}>{mainLinks}</div>
|
||||||
|
</div>
|
||||||
|
<div className={classes.main}>
|
||||||
|
{!isCollapsed && (
|
||||||
|
<Title order={4} className={classes.title}>
|
||||||
|
{activeMain}
|
||||||
|
</Title>
|
||||||
|
)}
|
||||||
|
{links}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</AppShell.Navbar>
|
||||||
|
|
||||||
|
{/* Main Content */}
|
||||||
|
<AppShell.Main>{children}</AppShell.Main>
|
||||||
|
</AppShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// src/data/navigationLinks.ts
|
||||||
|
import { House, Book, Users, Camera, Flask, Gear } from "phosphor-react";
|
||||||
|
|
||||||
|
export const mainLinksdata = [
|
||||||
|
{ icon: House, label: "Home" },
|
||||||
|
// { icon: Book, label: "Biblioteca" },
|
||||||
|
// { icon: Users, label: "AgentesLLMs" },
|
||||||
|
// { icon: Camera, label: "CameraNoir" },
|
||||||
|
// { icon: Flask, label: "Experimentos" },
|
||||||
|
// { icon: Gear, label: "Settings" },
|
||||||
|
];
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// src/data/submenuLinks.ts
|
||||||
|
|
||||||
|
export const submenuLinks = {
|
||||||
|
|
||||||
|
// Home Principal
|
||||||
|
|
||||||
|
Home: [
|
||||||
|
{ label: 'Inicio', to: '/' },
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
// Biblioteca
|
||||||
|
|
||||||
|
// Biblioteca: [
|
||||||
|
// { label: 'Biblioteca', to: '/bibliot/Biblioteca' },
|
||||||
|
// { label: 'test', to: '/bibliot/editortest' },
|
||||||
|
|
||||||
|
// ],
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { Button, Group, useMantineColorScheme } from '@mantine/core';
|
||||||
|
|
||||||
|
export function ColorSchemeToggle() {
|
||||||
|
const { setColorScheme, colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group justify="center" mt="xl">
|
||||||
|
<Button
|
||||||
|
variant={colorScheme === 'light' ? 'filled' : 'outline'}
|
||||||
|
onClick={() => setColorScheme('light')}
|
||||||
|
>
|
||||||
|
Light
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant={colorScheme === 'dark' ? 'filled' : 'outline'}
|
||||||
|
onClick={() => setColorScheme('dark')}
|
||||||
|
>
|
||||||
|
Dark
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant={colorScheme === 'auto' ? 'filled' : 'outline'}
|
||||||
|
onClick={() => setColorScheme('auto')}
|
||||||
|
>
|
||||||
|
Auto
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { AppShellWithMenu } from './Appshell/Appshell';
|
||||||
|
|
||||||
|
|
||||||
|
export function Plantilla() {
|
||||||
|
return (
|
||||||
|
<AppShellWithMenu>
|
||||||
|
|
||||||
|
</AppShellWithMenu>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { TextInput, PasswordInput, Button, Paper, Title, Container, Group, Alert } from '@mantine/core';
|
||||||
|
import { User, Lock } from 'phosphor-react'; // ← Importa los iconos Phosphor
|
||||||
|
|
||||||
|
export function LoginPage() {
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [password, setPassword] = useState('');
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setLoading(true);
|
||||||
|
setError('');
|
||||||
|
// Aquí deberías llamar a tu endpoint de login (ajusta la URL y payload)
|
||||||
|
try {
|
||||||
|
const res = await fetch('/api/v1/usuarios/login', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ email, password })
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error('Credenciales incorrectas');
|
||||||
|
// Aquí puedes guardar el usuario/token en el estado global o localStorage
|
||||||
|
window.location.href = '/';
|
||||||
|
} catch (err: any) {
|
||||||
|
setError(err.message);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container size={420} my={40}>
|
||||||
|
<Title align="center" mb={20}>Iniciar sesión</Title>
|
||||||
|
<Paper withBorder shadow="md" p={30} mt={30} radius="md">
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<TextInput
|
||||||
|
label="Email"
|
||||||
|
placeholder="tucorreo@ejemplo.com"
|
||||||
|
icon={<User size={18} />} // ← Usa el icono Phosphor aquí
|
||||||
|
value={email}
|
||||||
|
onChange={e => setEmail(e.target.value)}
|
||||||
|
required
|
||||||
|
mb={10}
|
||||||
|
/>
|
||||||
|
<PasswordInput
|
||||||
|
label="Contraseña"
|
||||||
|
placeholder="Tu contraseña"
|
||||||
|
icon={<Lock size={18} />} // ← Usa el icono Phosphor aquí
|
||||||
|
value={password}
|
||||||
|
onChange={e => setPassword(e.target.value)}
|
||||||
|
required
|
||||||
|
mb={20}
|
||||||
|
/>
|
||||||
|
{error && <Alert color="red" mb={10}>{error}</Alert>}
|
||||||
|
<Group mt="md">
|
||||||
|
<Button type="submit" loading={loading} fullWidth>
|
||||||
|
Entrar
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</form>
|
||||||
|
</Paper>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
.title {
|
||||||
|
color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
|
||||||
|
font-size: rem(100px);
|
||||||
|
font-weight: 900;
|
||||||
|
letter-spacing: rem(-2px);
|
||||||
|
|
||||||
|
@media (max-width: $mantine-breakpoint-md) {
|
||||||
|
font-size: rem(50px);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { Welcome } from './Welcome';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'Welcome',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Usage = () => <Welcome />;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { render, screen } from '@test-utils';
|
||||||
|
import { Welcome } from './Welcome';
|
||||||
|
|
||||||
|
describe('Welcome component', () => {
|
||||||
|
it('has correct Vite guide link', () => {
|
||||||
|
render(<Welcome />);
|
||||||
|
expect(screen.getByText('this guide')).toHaveAttribute(
|
||||||
|
'href',
|
||||||
|
'https://mantine.dev/guides/vite/'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { Anchor, Text, Title } from '@mantine/core';
|
||||||
|
import classes from './Welcome.module.css';
|
||||||
|
|
||||||
|
export function Welcome() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Title className={classes.title} ta="center" mt={100}>
|
||||||
|
Welcome to{' '}
|
||||||
|
<Text inherit variant="gradient" component="span" gradient={{ from: 'pink', to: 'yellow' }}>
|
||||||
|
Mantine
|
||||||
|
</Text>
|
||||||
|
</Title>
|
||||||
|
<Text c="dimmed" ta="center" size="lg" maw={580} mx="auto" mt="xl">
|
||||||
|
This starter Vite project includes a minimal setup, if you want to learn more on Mantine +
|
||||||
|
Vite integration follow{' '}
|
||||||
|
<Anchor href="https://mantine.dev/guides/vite/" size="lg">
|
||||||
|
this guide
|
||||||
|
</Anchor>
|
||||||
|
. To get started edit pages/Home.page.tsx file.
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="185.21428mm"
|
||||||
|
height="185.21428mm"
|
||||||
|
viewBox="0 0 185.21428 185.21428"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
sodipodi:docname="favicon.svg"
|
||||||
|
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview1"
|
||||||
|
pagecolor="#242424"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:zoom="0.52284039"
|
||||||
|
inkscape:cx="317.49651"
|
||||||
|
inkscape:cy="284.02549"
|
||||||
|
inkscape:window-width="1147"
|
||||||
|
inkscape:window-height="927"
|
||||||
|
inkscape:window-x="2024"
|
||||||
|
inkscape:window-y="105"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs1" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-13.15728,-55.159447)">
|
||||||
|
<circle
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="path1"
|
||||||
|
cx="105.76442"
|
||||||
|
cy="147.76659"
|
||||||
|
r="92.60714" />
|
||||||
|
<path
|
||||||
|
d="m 60.52824,130.59648 q 5.092664,-3.88488 12.125369,-6.43431 7.032718,-2.54944 15.035463,-4.12768 2.78883,-3.52067 5.45641,-6.91992 2.66758,-3.52066 4.60763,-6.55571 1.94007,-3.15645 3.031358,-5.82731 1.09128,-2.792247 0.84876,-4.977477 l 0.24252,0.2428 q -0.60628,-1.21402 -2.910088,-1.82102 -2.30382,-0.72842 -5.45642,-0.72842 -4.00138,0 -8.972768,1.09262 -4.971406,0.97121 -10.064057,2.91365 -5.092651,1.82102 -10.064057,4.491867 -4.850147,2.67085 -8.851513,5.94871 -3.880108,3.27786 -6.547698,7.16273 -2.546319,3.88487 -2.910081,8.13394 -5.456413,-4.61327 -7.881486,-8.49814 -2.303829,-4.00627 -2.303829,-7.52694 0,-6.19151 3.152597,-10.926187 3.152597,-4.73468 8.124003,-8.13393 5.092651,-3.52067 11.519091,-5.827315 6.547698,-2.306631 13.095396,-3.642054 6.668943,-1.456837 12.852879,-1.94244 6.305193,-0.607005 10.912843,-0.607005 6.911448,0 12.974128,0.971207 6.06269,0.971221 10.54908,3.035062 4.60766,1.942428 7.27523,4.856075 2.66758,2.91365 2.66758,6.91992 -0.72751,3.88487 -2.54632,7.16272 -1.69755,3.277867 -3.88013,6.312907 -2.18257,2.91365 -4.60766,5.94871 -2.30381,2.91365 -4.24387,5.94871 2.78884,0.12142 5.09265,0.36421 2.42508,0.12141 4.72891,0.12141 l -5.33517,13.35423 q -3.27384,0 -5.33517,0 -2.0613,0 -3.6376,0.12142 -1.45505,0 -2.78884,0.12141 -1.21253,0.12141 -2.78884,0.3642 -0.2425,0 -0.36376,0.12142 -0.12128,0 -0.36376,0 -8.730248,12.86862 -13.944158,27.19407 -5.213911,14.20405 -7.881489,28.77232 -4.728902,0.2428 -8.972771,-0.36422 -4.122624,-0.4856 -7.153976,-2.06382 -2.910081,-1.45683 -4.365128,-4.00627 -1.455047,-2.54946 -0.727524,-6.31292 0.848782,-3.27786 2.425074,-7.76973 1.697551,-4.61329 3.637617,-9.59078 2.061313,-5.09889 4.24387,-10.19778 2.303828,-5.22029 4.486386,-9.71218 -3.031339,1.33543 -6.91146,3.15647 -3.880108,1.82102 -6.668943,3.64206 z m 103.06565,44.5546 q 0.24249,3.64205 -1.94006,8.49814 -2.18258,4.8561 -5.69893,10.07639 -3.3951,5.22029 -7.63897,10.31916 -4.24389,5.2203 -8.12401,9.46937 -3.8801,4.24907 -6.91144,7.04132 -3.03134,2.91365 -4.12263,3.52066 -1.57629,0.60702 -3.27384,1.09263 -1.57629,0.607 -3.88013,-0.36422 -1.45506,-0.60699 -3.51638,-1.69963 -1.94005,-0.97122 -3.6376,-2.42803 -1.8188,-1.33542 -2.78884,-3.15646 -1.09128,-1.69963 -0.60626,-3.76347 0.48502,-1.82104 2.30383,-4.49187 1.69755,-2.67085 4.12261,-5.70591 2.54633,-3.03505 5.57768,-6.1915 3.15261,-3.03505 6.3052,-5.82729 3.27385,-2.79225 6.3052,-4.85609 3.15258,-2.06384 5.82015,-3.03506 0.36376,-0.12142 0.72754,-1.82103 0.36375,-1.69964 0.12115,-4.49187 -0.12115,-1.45684 -0.72752,-3.15646 -0.48502,-1.69963 -1.45505,-3.03505 -0.84876,-1.33543 -2.18254,-2.18525 -1.3338,-0.97122 -2.91009,-0.97122 -2.78884,0 -5.82018,2.91365 -3.03134,2.54946 -5.57767,1.82104 -2.4251,-0.72842 -3.7589,-3.03506 -1.21252,-2.42803 -0.84877,-5.46309 0.48502,-3.03505 3.39511,-5.09889 0.97004,-0.60702 4.00138,-3.03505 3.03135,-2.54945 6.66897,-5.7059 3.63759,-3.15646 7.03269,-6.31292 3.39512,-3.27785 5.09267,-5.3417 1.57629,-1.94242 2.0613,-3.03504 0.48502,-1.09261 0.36376,-1.69963 -0.12116,-0.60702 -0.72752,-0.72842 -0.48502,-0.2428 -0.84877,-0.2428 -1.45505,-0.12141 -3.3951,-0.2428 -1.81881,-0.12142 -3.51636,0 -1.69754,0.12128 -3.15259,0.4856 -1.33379,0.2428 -1.81881,0.72842 -0.97002,0.7284 -3.03134,3.88487 -1.94005,3.03505 -4.24386,6.67711 -2.30383,3.64207 -4.48642,7.04132 -2.06132,3.39927 -3.03135,4.85609 -2.18257,3.03505 -4.36511,3.88487 -2.30382,0.72842 -3.88012,0 -1.57631,-0.72841 -1.94007,-2.54945 -0.48501,-1.82102 0.84878,-4.00627 1.45505,-2.30664 3.1526,-5.34169 1.69754,-3.15646 3.51636,-6.55571 1.81878,-3.52067 3.63759,-7.16274 1.94008,-3.64206 3.75889,-7.16273 1.3338,-2.42803 2.78885,-3.88487 1.45503,-1.57822 3.8801,-2.42803 2.9101,-0.72842 6.42644,-0.97122 3.63761,-0.24281 7.15397,-0.12141 3.51636,0 6.66895,0.3642 3.15259,0.2428 5.2139,0.36422 2.30381,0.24279 4.48638,1.94243 2.30383,1.69962 3.88013,3.88485 1.69755,2.18524 2.42507,4.6133 0.72752,2.30664 -0.12116,3.88486 -0.12115,0.24281 -1.45503,1.57823 -1.33379,1.33543 -3.51636,3.39927 -2.06131,2.06383 -4.7289,4.61327 -2.66758,2.42805 -5.33516,4.97749 -2.54633,2.42805 -4.9714,4.61329 -2.42506,2.18523 -4.00137,3.64205 h 1.45505 q 4.60763,0 7.88149,0.72842 3.39511,0.607 6.54769,3.27785 2.66758,-3.03505 5.57768,-7.52693 2.91008,-4.61328 5.45641,-8.74095 2.30381,-4.00628 4.60764,-5.22029 2.42506,-1.21402 4.12263,-0.60702 1.81879,0.48561 2.42507,2.54946 0.72751,1.94243 -0.36376,4.49186 -6.79022,11.0476 -11.15534,18.21033 -4.24387,7.04132 -6.30518,9.95498 z"
|
||||||
|
id="text1-8-5-1"
|
||||||
|
style="fill:#000000"
|
||||||
|
aria-label="Fz"
|
||||||
|
inkscape:label="text1" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.9 KiB |
@@ -0,0 +1,37 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
type LogoIconProps = React.SVGProps<SVGSVGElement> & {
|
||||||
|
circleFill?: string;
|
||||||
|
pathFill?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const LogoIcon: React.FC<LogoIconProps> = ({
|
||||||
|
style,
|
||||||
|
circleFill = 'currentColor',
|
||||||
|
pathFill = 'currentColor',
|
||||||
|
...props
|
||||||
|
}) => (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="1em"
|
||||||
|
height="1em"
|
||||||
|
viewBox="0 0 185.21428 185.21428"
|
||||||
|
style={style}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<g transform="translate(-13.15728,-55.159447)">
|
||||||
|
<circle
|
||||||
|
cx="105.76442"
|
||||||
|
cy="147.76659"
|
||||||
|
r="92.60714"
|
||||||
|
fill={circleFill}
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m 60.52824,130.59648 q 5.092664,-3.88488 12.125369,-6.43431 7.032718,-2.54944 15.035463,-4.12768 2.78883,-3.52067 5.45641,-6.91992 2.66758,-3.52066 4.60763,-6.55571 1.94007,-3.15645 3.031358,-5.82731 1.09128,-2.792247 0.84876,-4.977477 l 0.24252,0.2428 q -0.60628,-1.21402 -2.910088,-1.82102 -2.30382,-0.72842 -5.45642,-0.72842 -4.00138,0 -8.972768,1.09262 -4.971406,0.97121 -10.064057,2.91365 -5.092651,1.82102 -10.064057,4.491867 -4.850147,2.67085 -8.851513,5.94871 -3.880108,3.27786 -6.547698,7.16273 -2.546319,3.88487 -2.910081,8.13394 -5.456413,-4.61327 -7.881486,-8.49814 -2.303829,-4.00627 -2.303829,-7.52694 0,-6.19151 3.152597,-10.926187 3.152597,-4.73468 8.124003,-8.13393 5.092651,-3.52067 11.519091,-5.827315 6.547698,-2.306631 13.095396,-3.642054 6.668943,-1.456837 12.852879,-1.94244 6.305193,-0.607005 10.912843,-0.607005 6.911448,0 12.974128,0.971207 6.06269,0.971221 10.54908,3.035062 4.60766,1.942428 7.27523,4.856075 2.66758,2.91365 2.66758,6.91992 -0.72751,3.88487 -2.54632,7.16272 -1.69755,3.277867 -3.88013,6.312907 -2.18257,2.91365 -4.60766,5.94871 -2.30381,2.91365 -4.24387,5.94871 2.78884,0.12142 5.09265,0.36421 2.42508,0.12141 4.72891,0.12141 l -5.33517,13.35423 q -3.27384,0 -5.33517,0 -2.0613,0 -3.6376,0.12142 -1.45505,0 -2.78884,0.12141 -1.21253,0.12141 -2.78884,0.3642 -0.2425,0 -0.36376,0.12142 -0.12128,0 -0.36376,0 -8.730248,12.86862 -13.944158,27.19407 -5.213911,14.20405 -7.881489,28.77232 -4.728902,0.2428 -8.972771,-0.36422 -4.122624,-0.4856 -7.153976,-2.06382 -2.910081,-1.45683 -4.365128,-4.00627 -1.455047,-2.54946 -0.727524,-6.31292 0.848782,-3.27786 2.425074,-7.76973 1.697551,-4.61329 3.637617,-9.59078 2.061313,-5.09889 4.24387,-10.19778 2.303828,-5.22029 4.486386,-9.71218 -3.031339,1.33543 -6.91146,3.15647 -3.880108,1.82102 -6.668943,3.64206 z m 103.06565,44.5546 q 0.24249,3.64205 -1.94006,8.49814 -2.18258,4.8561 -5.69893,10.07639 -3.3951,5.22029 -7.63897,10.31916 -4.24389,5.2203 -8.12401,9.46937 -3.8801,4.24907 -6.91144,7.04132 -3.03134,2.91365 -4.12263,3.52066 -1.57629,0.60702 -3.27384,1.09263 -1.57629,0.607 -3.88013,-0.36422 -1.45506,-0.60699 -3.51638,-1.69963 -1.94005,-0.97122 -3.6376,-2.42803 -1.8188,-1.33542 -2.78884,-3.15646 -1.09128,-1.69963 -0.60626,-3.76347 0.48502,-1.82104 2.30383,-4.49187 1.69755,-2.67085 4.12261,-5.70591 2.54633,-3.03505 5.57768,-6.1915 3.15261,-3.03505 6.3052,-5.82729 3.27385,-2.79225 6.3052,-4.85609 3.15258,-2.06384 5.82015,-3.03506 0.36376,-0.12142 0.72754,-1.82103 0.36375,-1.69964 0.12115,-4.49187 -0.12115,-1.45684 -0.72752,-3.15646 -0.48502,-1.69963 -1.45505,-3.03505 -0.84876,-1.33543 -2.18254,-2.18525 -1.3338,-0.97122 -2.91009,-0.97122 -2.78884,0 -5.82018,2.91365 -3.03134,2.54946 -5.57767,1.82104 -2.4251,-0.72842 -3.7589,-3.03506 -1.21252,-2.42803 -0.84877,-5.46309 0.48502,-3.03505 3.39511,-5.09889 0.97004,-0.60702 4.00138,-3.03505 3.03135,-2.54945 6.66897,-5.7059 3.63759,-3.15646 7.03269,-6.31292 3.39512,-3.27785 5.09267,-5.3417 1.57629,-1.94242 2.0613,-3.03504 0.48502,-1.09261 0.36376,-1.69963 -0.12116,-0.60702 -0.72752,-0.72842 -0.48502,-0.2428 -0.84877,-0.2428 -1.45505,-0.12141 -3.3951,-0.2428 -1.81881,-0.12142 -3.51636,0 -1.69754,0.12128 -3.15259,0.4856 -1.33379,0.2428 -1.81881,0.72842 -0.97002,0.7284 -3.03134,3.88487 -1.94005,3.03505 -4.24386,6.67711 -2.30383,3.64207 -4.48642,7.04132 -2.06132,3.39927 -3.03135,4.85609 -2.18257,3.03505 -4.36511,3.88487 -2.30382,0.72842 -3.88012,0 -1.57631,-0.72841 -1.94007,-2.54945 -0.48501,-1.82102 0.84878,-4.00627 1.45505,-2.30664 3.1526,-5.34169 1.69754,-3.15646 3.51636,-6.55571 1.81878,-3.52067 3.63759,-7.16274 1.94008,-3.64206 3.75889,-7.16273 1.3338,-2.42803 2.78885,-3.88487 1.45503,-1.57822 3.8801,-2.42803 2.9101,-0.72842 6.42644,-0.97122 3.63761,-0.24281 7.15397,-0.12141 3.51636,0 6.66895,0.3642 3.15259,0.2428 5.2139,0.36422 2.30381,0.24279 4.48638,1.94243 2.30383,1.69962 3.88013,3.88485 1.69755,2.18524 2.42507,4.6133 0.72752,2.30664 -0.12116,3.88486 -0.12115,0.24281 -1.45503,1.57823 -1.33379,1.33543 -3.51636,3.39927 -2.06131,2.06383 -4.7289,4.61327 -2.66758,2.42805 -5.33516,4.97749 -2.54633,2.42805 -4.9714,4.61329 -2.42506,2.18523 -4.00137,3.64205 h 1.45505 q 4.60763,0 7.88149,0.72842 3.39511,0.607 6.54769,3.27785 2.66758,-3.03505 5.57768,-7.52693 2.91008,-4.61328 5.45641,-8.74095 2.30381,-4.00628 4.60764,-5.22029 2.42506,-1.21402 4.12263,-0.60702 1.81879,0.48561 2.42507,2.54946 0.72751,1.94243 -0.36376,4.49186 -6.79022,11.0476 -11.15534,18.21033 -4.24387,7.04132 -6.30518,9.95498 z"
|
||||||
|
fill={pathFill}
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default LogoIcon;
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="185.21428mm"
|
||||||
|
height="185.21428mm"
|
||||||
|
viewBox="0 0 185.21428 185.21428"
|
||||||
|
version="1.1"
|
||||||
|
id="svg1"
|
||||||
|
sodipodi:docname="favicon.svg"
|
||||||
|
inkscape:version="1.4 (86a8ad7, 2024-10-11)"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview1"
|
||||||
|
pagecolor="#242424"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:zoom="0.52284039"
|
||||||
|
inkscape:cx="317.49651"
|
||||||
|
inkscape:cy="284.02549"
|
||||||
|
inkscape:window-width="1147"
|
||||||
|
inkscape:window-height="927"
|
||||||
|
inkscape:window-x="2024"
|
||||||
|
inkscape:window-y="105"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs1" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-13.15728,-55.159447)">
|
||||||
|
<circle
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="path1"
|
||||||
|
cx="105.76442"
|
||||||
|
cy="147.76659"
|
||||||
|
r="92.60714" />
|
||||||
|
<path
|
||||||
|
d="m 60.52824,130.59648 q 5.092664,-3.88488 12.125369,-6.43431 7.032718,-2.54944 15.035463,-4.12768 2.78883,-3.52067 5.45641,-6.91992 2.66758,-3.52066 4.60763,-6.55571 1.94007,-3.15645 3.031358,-5.82731 1.09128,-2.792247 0.84876,-4.977477 l 0.24252,0.2428 q -0.60628,-1.21402 -2.910088,-1.82102 -2.30382,-0.72842 -5.45642,-0.72842 -4.00138,0 -8.972768,1.09262 -4.971406,0.97121 -10.064057,2.91365 -5.092651,1.82102 -10.064057,4.491867 -4.850147,2.67085 -8.851513,5.94871 -3.880108,3.27786 -6.547698,7.16273 -2.546319,3.88487 -2.910081,8.13394 -5.456413,-4.61327 -7.881486,-8.49814 -2.303829,-4.00627 -2.303829,-7.52694 0,-6.19151 3.152597,-10.926187 3.152597,-4.73468 8.124003,-8.13393 5.092651,-3.52067 11.519091,-5.827315 6.547698,-2.306631 13.095396,-3.642054 6.668943,-1.456837 12.852879,-1.94244 6.305193,-0.607005 10.912843,-0.607005 6.911448,0 12.974128,0.971207 6.06269,0.971221 10.54908,3.035062 4.60766,1.942428 7.27523,4.856075 2.66758,2.91365 2.66758,6.91992 -0.72751,3.88487 -2.54632,7.16272 -1.69755,3.277867 -3.88013,6.312907 -2.18257,2.91365 -4.60766,5.94871 -2.30381,2.91365 -4.24387,5.94871 2.78884,0.12142 5.09265,0.36421 2.42508,0.12141 4.72891,0.12141 l -5.33517,13.35423 q -3.27384,0 -5.33517,0 -2.0613,0 -3.6376,0.12142 -1.45505,0 -2.78884,0.12141 -1.21253,0.12141 -2.78884,0.3642 -0.2425,0 -0.36376,0.12142 -0.12128,0 -0.36376,0 -8.730248,12.86862 -13.944158,27.19407 -5.213911,14.20405 -7.881489,28.77232 -4.728902,0.2428 -8.972771,-0.36422 -4.122624,-0.4856 -7.153976,-2.06382 -2.910081,-1.45683 -4.365128,-4.00627 -1.455047,-2.54946 -0.727524,-6.31292 0.848782,-3.27786 2.425074,-7.76973 1.697551,-4.61329 3.637617,-9.59078 2.061313,-5.09889 4.24387,-10.19778 2.303828,-5.22029 4.486386,-9.71218 -3.031339,1.33543 -6.91146,3.15647 -3.880108,1.82102 -6.668943,3.64206 z m 103.06565,44.5546 q 0.24249,3.64205 -1.94006,8.49814 -2.18258,4.8561 -5.69893,10.07639 -3.3951,5.22029 -7.63897,10.31916 -4.24389,5.2203 -8.12401,9.46937 -3.8801,4.24907 -6.91144,7.04132 -3.03134,2.91365 -4.12263,3.52066 -1.57629,0.60702 -3.27384,1.09263 -1.57629,0.607 -3.88013,-0.36422 -1.45506,-0.60699 -3.51638,-1.69963 -1.94005,-0.97122 -3.6376,-2.42803 -1.8188,-1.33542 -2.78884,-3.15646 -1.09128,-1.69963 -0.60626,-3.76347 0.48502,-1.82104 2.30383,-4.49187 1.69755,-2.67085 4.12261,-5.70591 2.54633,-3.03505 5.57768,-6.1915 3.15261,-3.03505 6.3052,-5.82729 3.27385,-2.79225 6.3052,-4.85609 3.15258,-2.06384 5.82015,-3.03506 0.36376,-0.12142 0.72754,-1.82103 0.36375,-1.69964 0.12115,-4.49187 -0.12115,-1.45684 -0.72752,-3.15646 -0.48502,-1.69963 -1.45505,-3.03505 -0.84876,-1.33543 -2.18254,-2.18525 -1.3338,-0.97122 -2.91009,-0.97122 -2.78884,0 -5.82018,2.91365 -3.03134,2.54946 -5.57767,1.82104 -2.4251,-0.72842 -3.7589,-3.03506 -1.21252,-2.42803 -0.84877,-5.46309 0.48502,-3.03505 3.39511,-5.09889 0.97004,-0.60702 4.00138,-3.03505 3.03135,-2.54945 6.66897,-5.7059 3.63759,-3.15646 7.03269,-6.31292 3.39512,-3.27785 5.09267,-5.3417 1.57629,-1.94242 2.0613,-3.03504 0.48502,-1.09261 0.36376,-1.69963 -0.12116,-0.60702 -0.72752,-0.72842 -0.48502,-0.2428 -0.84877,-0.2428 -1.45505,-0.12141 -3.3951,-0.2428 -1.81881,-0.12142 -3.51636,0 -1.69754,0.12128 -3.15259,0.4856 -1.33379,0.2428 -1.81881,0.72842 -0.97002,0.7284 -3.03134,3.88487 -1.94005,3.03505 -4.24386,6.67711 -2.30383,3.64207 -4.48642,7.04132 -2.06132,3.39927 -3.03135,4.85609 -2.18257,3.03505 -4.36511,3.88487 -2.30382,0.72842 -3.88012,0 -1.57631,-0.72841 -1.94007,-2.54945 -0.48501,-1.82102 0.84878,-4.00627 1.45505,-2.30664 3.1526,-5.34169 1.69754,-3.15646 3.51636,-6.55571 1.81878,-3.52067 3.63759,-7.16274 1.94008,-3.64206 3.75889,-7.16273 1.3338,-2.42803 2.78885,-3.88487 1.45503,-1.57822 3.8801,-2.42803 2.9101,-0.72842 6.42644,-0.97122 3.63761,-0.24281 7.15397,-0.12141 3.51636,0 6.66895,0.3642 3.15259,0.2428 5.2139,0.36422 2.30381,0.24279 4.48638,1.94243 2.30383,1.69962 3.88013,3.88485 1.69755,2.18524 2.42507,4.6133 0.72752,2.30664 -0.12116,3.88486 -0.12115,0.24281 -1.45503,1.57823 -1.33379,1.33543 -3.51636,3.39927 -2.06131,2.06383 -4.7289,4.61327 -2.66758,2.42805 -5.33516,4.97749 -2.54633,2.42805 -4.9714,4.61329 -2.42506,2.18523 -4.00137,3.64205 h 1.45505 q 4.60763,0 7.88149,0.72842 3.39511,0.607 6.54769,3.27785 2.66758,-3.03505 5.57768,-7.52693 2.91008,-4.61328 5.45641,-8.74095 2.30381,-4.00628 4.60764,-5.22029 2.42506,-1.21402 4.12263,-0.60702 1.81879,0.48561 2.42507,2.54946 0.72751,1.94243 -0.36376,4.49186 -6.79022,11.0476 -11.15534,18.21033 -4.24387,7.04132 -6.30518,9.95498 z"
|
||||||
|
id="text1-8-5-1"
|
||||||
|
style="fill:#000000"
|
||||||
|
aria-label="Fz"
|
||||||
|
inkscape:label="text1" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.9 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { ColorSchemeToggle } from '../components/ColorSchemeToggle/ColorSchemeToggle';
|
||||||
|
import { Welcome } from '../components/Welcome/Welcome';
|
||||||
|
|
||||||
|
import { AppShellWithMenu } from '@/components/Appshell/Appshell';
|
||||||
|
|
||||||
|
export function HomePage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<AppShellWithMenu>
|
||||||
|
|
||||||
|
<Welcome />
|
||||||
|
<ColorSchemeToggle />
|
||||||
|
|
||||||
|
</AppShellWithMenu>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// stores/useAppShellStore.ts
|
||||||
|
import { create } from 'zustand';
|
||||||
|
|
||||||
|
interface AppShellState {
|
||||||
|
activeMain: string;
|
||||||
|
activeLink: string;
|
||||||
|
mobileOpened: boolean;
|
||||||
|
desktopOpened: boolean;
|
||||||
|
setActiveMain: (main: string) => void;
|
||||||
|
setActiveLink: (link: string) => void;
|
||||||
|
toggleMobile: () => void;
|
||||||
|
toggleDesktop: () => void;
|
||||||
|
openDesktop: () => void;
|
||||||
|
closeMobile: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Persistencia en localStorage (solo para rutas, si lo quieres)
|
||||||
|
const STORAGE_KEY = 'lastSubmenuRoutes';
|
||||||
|
function getLastSubmenuRoute(section: string): string | null {
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(STORAGE_KEY);
|
||||||
|
const parsed = raw ? JSON.parse(raw) : {};
|
||||||
|
return parsed[section] ?? null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function setLastSubmenuRoute(section: string, route: string) {
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(STORAGE_KEY);
|
||||||
|
const parsed = raw ? JSON.parse(raw) : {};
|
||||||
|
parsed[section] = route;
|
||||||
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(parsed));
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useAppShellStore = create<AppShellState>((set) => ({
|
||||||
|
activeMain: 'Home',
|
||||||
|
activeLink: '',
|
||||||
|
mobileOpened: false,
|
||||||
|
desktopOpened: true,
|
||||||
|
setActiveMain: (main) => set({ activeMain: main }),
|
||||||
|
setActiveLink: (link) => set({ activeLink: link }),
|
||||||
|
toggleMobile: () => set((s) => ({ mobileOpened: !s.mobileOpened })),
|
||||||
|
toggleDesktop: () => set((s) => ({ desktopOpened: !s.desktopOpened })),
|
||||||
|
openDesktop: () => set({ desktopOpened: true }),
|
||||||
|
closeMobile: () => set({ mobileOpened: false }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export { getLastSubmenuRoute, setLastSubmenuRoute };
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { createTheme } from '@mantine/core';
|
||||||
|
|
||||||
|
export const theme = createTheme({
|
||||||
|
colors: {
|
||||||
|
// Definición de la paleta principal
|
||||||
|
brand: [
|
||||||
|
"#e7f2ff",
|
||||||
|
"#d0e1ff",
|
||||||
|
"#a1c0fa",
|
||||||
|
"#6e9df6",
|
||||||
|
"#447ff1",
|
||||||
|
"#296df0",
|
||||||
|
"#1863f0",
|
||||||
|
"#0753d6",
|
||||||
|
"#0049c1",
|
||||||
|
"#003faa"
|
||||||
|
],
|
||||||
|
// Puedes añadir hasta 3 colores adicionales si lo deseas
|
||||||
|
secondary: [
|
||||||
|
"#ecf4ff",
|
||||||
|
"#dce4f5",
|
||||||
|
"#b9c7e2",
|
||||||
|
"#94a8d0",
|
||||||
|
"#748dc0",
|
||||||
|
"#5f7cb7",
|
||||||
|
"#5474b4",
|
||||||
|
"#44639f",
|
||||||
|
"#3a5890",
|
||||||
|
"#2c4b80"
|
||||||
|
],
|
||||||
|
accent: [
|
||||||
|
'#fff3e0',
|
||||||
|
'#ffe0b2',
|
||||||
|
'#ffcc80',
|
||||||
|
'#ffb74d',
|
||||||
|
'#ffa726',
|
||||||
|
'#ff9800',
|
||||||
|
'#fb8c00',
|
||||||
|
'#f57c00',
|
||||||
|
'#ef6c00',
|
||||||
|
'#e65100',
|
||||||
|
],
|
||||||
|
neutral: [
|
||||||
|
'#fafafa',
|
||||||
|
'#f5f5f5',
|
||||||
|
'#eeeeee',
|
||||||
|
'#e0e0e0',
|
||||||
|
'#bdbdbd',
|
||||||
|
'#9e9e9e',
|
||||||
|
'#757575',
|
||||||
|
'#616161',
|
||||||
|
'#424242',
|
||||||
|
'#212121',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
primaryColor: 'brand', // Establece 'brand' como el color primario
|
||||||
|
primaryShade: { light: 6, dark: 8 }, // Define los tonos primarios para los esquemas de color claro y oscuro
|
||||||
|
});
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
|
||||||
|
export * from '@testing-library/react';
|
||||||
|
export { render } from './render';
|
||||||
|
export { userEvent };
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { render as testingLibraryRender } from '@testing-library/react';
|
||||||
|
import { MantineProvider } from '@mantine/core';
|
||||||
|
import { theme } from '../src/theme';
|
||||||
|
|
||||||
|
export function render(ui: React.ReactNode) {
|
||||||
|
return testingLibraryRender(ui, {
|
||||||
|
wrapper: ({ children }: { children: React.ReactNode }) => (
|
||||||
|
<MantineProvider theme={theme} env="test">
|
||||||
|
{children}
|
||||||
|
</MantineProvider>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"types": ["node", "@testing-library/jest-dom", "vitest/globals"],
|
||||||
|
"target": "ESNext",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||||
|
"allowJs": false,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": false,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"],
|
||||||
|
"@test-utils": ["./test-utils"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src", "test-utils", ".storybook/main.ts", ".storybook/preview.tsx"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import react from '@vitejs/plugin-react';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [react(), tsconfigPaths()],
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'jsdom',
|
||||||
|
setupFiles: './vitest.setup.mjs',
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import '@testing-library/jest-dom/vitest';
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
|
const { getComputedStyle } = window;
|
||||||
|
window.getComputedStyle = (elt) => getComputedStyle(elt);
|
||||||
|
window.HTMLElement.prototype.scrollIntoView = () => {};
|
||||||
|
|
||||||
|
Object.defineProperty(window, 'matchMedia', {
|
||||||
|
writable: true,
|
||||||
|
value: vi.fn().mockImplementation((query) => ({
|
||||||
|
matches: false,
|
||||||
|
media: query,
|
||||||
|
onchange: null,
|
||||||
|
addListener: vi.fn(),
|
||||||
|
removeListener: vi.fn(),
|
||||||
|
addEventListener: vi.fn(),
|
||||||
|
removeEventListener: vi.fn(),
|
||||||
|
dispatchEvent: vi.fn(),
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
class ResizeObserver {
|
||||||
|
observe() {}
|
||||||
|
unobserve() {}
|
||||||
|
disconnect() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.ResizeObserver = ResizeObserver;
|
||||||
+4458
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,90 @@
|
|||||||
|
import psycopg2
|
||||||
|
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
|
||||||
|
|
||||||
|
def recreate_logs_table(conn_info, retention_days=30):
|
||||||
|
"""
|
||||||
|
Elimina y recrea la tabla 'logs' en TimescaleDB con configuración optimizada.
|
||||||
|
Incluye:
|
||||||
|
- Hypertable por 'timestamp'
|
||||||
|
- Índices por service, timestamp y level
|
||||||
|
- Políticas de compresión y retención automáticas
|
||||||
|
"""
|
||||||
|
|
||||||
|
conn = psycopg2.connect(**conn_info)
|
||||||
|
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
|
||||||
|
cur = conn.cursor()
|
||||||
|
|
||||||
|
print("⚠️ Eliminando tabla 'logs' si existe...")
|
||||||
|
cur.execute("DROP TABLE IF EXISTS logs CASCADE;")
|
||||||
|
|
||||||
|
print("🔧 Creando tabla 'logs'...")
|
||||||
|
cur.execute("""
|
||||||
|
CREATE TABLE logs (
|
||||||
|
id BIGSERIAL,
|
||||||
|
service TEXT NOT NULL,
|
||||||
|
level TEXT NOT NULL,
|
||||||
|
message TEXT NOT NULL,
|
||||||
|
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
|
metadata JSONB
|
||||||
|
);
|
||||||
|
""")
|
||||||
|
|
||||||
|
print("🧱 Configurando hypertable 'logs'...")
|
||||||
|
cur.execute("""
|
||||||
|
SELECT create_hypertable('logs', 'timestamp', if_not_exists => TRUE);
|
||||||
|
""")
|
||||||
|
|
||||||
|
print("⚡ Creando índices...")
|
||||||
|
cur.execute("""
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_logs_service_timestamp
|
||||||
|
ON logs (service, timestamp DESC);
|
||||||
|
""")
|
||||||
|
cur.execute("""
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_logs_level
|
||||||
|
ON logs (level);
|
||||||
|
""")
|
||||||
|
cur.execute("""
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_logs_timestamp
|
||||||
|
ON logs (timestamp DESC);
|
||||||
|
""")
|
||||||
|
|
||||||
|
print("📦 Activando compresión...")
|
||||||
|
cur.execute("""
|
||||||
|
ALTER TABLE logs SET (
|
||||||
|
timescaledb.compress,
|
||||||
|
timescaledb.compress_segmentby = 'service'
|
||||||
|
);
|
||||||
|
""")
|
||||||
|
|
||||||
|
print("🗓️ Añadiendo políticas automáticas...")
|
||||||
|
cur.execute("""
|
||||||
|
SELECT add_compression_policy('logs', INTERVAL '7 days');
|
||||||
|
""")
|
||||||
|
cur.execute(f"""
|
||||||
|
SELECT add_retention_policy('logs', INTERVAL '{retention_days} days');
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
cur.close()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
print("✅ Tabla 'logs' recreada y configurada correctamente.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Ejecutar la configuración al ejecutar el script directamente
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
||||||
|
conn_info = {
|
||||||
|
"dbname": "basededatos",
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "mipassword",
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 55432,
|
||||||
|
}
|
||||||
|
|
||||||
|
recreate_logs_table(conn_info, retention_days=90)
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
from prefect import flow, task, get_run_logger
|
||||||
|
from prefect.filesystems import LocalFileSystem
|
||||||
|
|
||||||
|
local_file_system_block = LocalFileSystem.load("localfile")
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import psycopg2
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
import json
|
||||||
|
|
||||||
|
class TimescaleHandler(logging.Handler):
|
||||||
|
def __init__(self, conn_info):
|
||||||
|
super().__init__()
|
||||||
|
self.conn_info = conn_info
|
||||||
|
|
||||||
|
def emit(self, record: logging.LogRecord):
|
||||||
|
try:
|
||||||
|
conn = psycopg2.connect(**self.conn_info)
|
||||||
|
cur = conn.cursor()
|
||||||
|
cur.execute("""
|
||||||
|
INSERT INTO logs (service, level, message, timestamp, metadata)
|
||||||
|
VALUES (%s, %s, %s, %s, %s)
|
||||||
|
""", (
|
||||||
|
"prefect",
|
||||||
|
record.levelname,
|
||||||
|
record.getMessage(),
|
||||||
|
datetime.now(timezone.utc),
|
||||||
|
json.dumps({
|
||||||
|
"filename": record.pathname,
|
||||||
|
"lineno": record.lineno,
|
||||||
|
"func": record.funcName,
|
||||||
|
"module": record.module,
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
conn.commit()
|
||||||
|
cur.close()
|
||||||
|
conn.close()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[TimescaleHandler] Error al guardar log: {e}")
|
||||||
|
|
||||||
|
# 🧩 Tarea Prefect con logging
|
||||||
|
@task(name="tarea_log", log_prints=True)
|
||||||
|
def tarea_log():
|
||||||
|
conn_info = {
|
||||||
|
"dbname": "basededatos",
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "mipassword",
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 55432,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prefect ya crea este logger con el contexto actual
|
||||||
|
logger = get_run_logger()
|
||||||
|
timescale_handler = TimescaleHandler(conn_info)
|
||||||
|
|
||||||
|
# 💡 Aseguramos que se guarden también los DEBUG
|
||||||
|
logger.logger.setLevel(logging.DEBUG)
|
||||||
|
timescale_handler.setLevel(logging.DEBUG)
|
||||||
|
logger.logger.addHandler(timescale_handler)
|
||||||
|
|
||||||
|
# Ahora todo lo que se loguee aquí también se guarda en TimescaleDB
|
||||||
|
logger.debug("Mensaje debug: variables inicializadas correctamente")
|
||||||
|
logger.info("Iniciando tarea Prefect con logging en Timescale 🚀")
|
||||||
|
logger.warning("Advertencia de ejemplo")
|
||||||
|
logger.error("Error simulado para prueba")
|
||||||
|
|
||||||
|
# Puedes seguir usando print() si quieres, pero prefieren logger
|
||||||
|
print("Esto solo se mostrará en stdout, no se guarda en Timescale")
|
||||||
|
|
||||||
|
@flow(name="comprobar_logs", result_storage=local_file_system_block, log_prints=True) # type: ignore
|
||||||
|
def comprobar_logs():
|
||||||
|
tarea_log()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
comprobar_logs()
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import uvicorn
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
|
from backend.api.router import router as router
|
||||||
|
|
||||||
|
def create_app() -> FastAPI:
|
||||||
|
"""Crea y configura la aplicación FastAPI."""
|
||||||
|
app = FastAPI(
|
||||||
|
title="Backend Modular 🚀",
|
||||||
|
description="API modular con endpoints separados por carpetas",
|
||||||
|
version="1.0.0",
|
||||||
|
)
|
||||||
|
|
||||||
|
# CORS
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173"],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Routers
|
||||||
|
app.include_router(router, prefix="/api")
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def root():
|
||||||
|
return {"message": "Backend corriendo 🧠🔥"}
|
||||||
|
|
||||||
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
app = create_app()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Modo desarrollo con recarga automática
|
||||||
|
uvicorn.run(
|
||||||
|
"main:app",
|
||||||
|
host="0.0.0.0",
|
||||||
|
port=8000,
|
||||||
|
reload=True, # recarga al cambiar código
|
||||||
|
log_level="info"
|
||||||
|
)
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
{
|
||||||
|
"version": "1",
|
||||||
|
"metadata": {
|
||||||
|
"marimo_version": "0.16.5"
|
||||||
|
},
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"id": "MJUe",
|
||||||
|
"code_hash": "bf4c2ec3da54726b1dcf7bbacfb8a9fc",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"type": "data",
|
||||||
|
"data": {
|
||||||
|
"text/html": "<span class=\"markdown prose dark:prose-invert\"><h1 id=\"opentelemetry-grafana-stack-con-dashboards-preconfigurados\">\ud83d\udd2d OpenTelemetry + Grafana Stack con dashboards preconfigurados \ud83d\ude80</h1></span>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Hbol",
|
||||||
|
"code_hash": "1d0db38904205bec4d6f6f6a1f6cec3e",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"type": "data",
|
||||||
|
"data": {
|
||||||
|
"text/plain": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "vblA",
|
||||||
|
"code_hash": "9d8691f09dd3c2a110820415983b143e",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"type": "data",
|
||||||
|
"data": {
|
||||||
|
"text/plain": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "bkHC",
|
||||||
|
"code_hash": "95bf1fb529e82c3fbd4731c219f2b0b4",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"type": "data",
|
||||||
|
"data": {
|
||||||
|
"text/plain": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "lEQa",
|
||||||
|
"code_hash": "4d9a7cdeb028ab0e0df782ba3a18ec56",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"type": "data",
|
||||||
|
"data": {
|
||||||
|
"text/plain": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"console": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "PKri",
|
||||||
|
"code_hash": "42e8a076992b5694ca5db7e1da939de4",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"type": "data",
|
||||||
|
"data": {
|
||||||
|
"text/plain": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"console": [
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": "time=\"2025-10-05T18:15:27+02:00\" level=warning msg=\"/home/lucas/DataProyects/mis_agentes/conseguir_datos_con_agentes/observability_stack/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion\"\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": "time=\"2025-10-05T18:15:27+02:00\" level=warning msg=\"/home/lucas/DataProyects/mis_agentes/conseguir_datos_con_agentes/observability_stack/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion\"\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Network observability_stack_default Creating\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Network observability_stack_default Created\n Container tempo Creating\n Container victoria Creating\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container victoria Created\n Container tempo Created\n Container otel-collector Creating\n Container grafana-srv Creating\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container otel-collector Created\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container grafana-srv Created\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container victoria Starting\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container tempo Starting\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container victoria Started\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container tempo Started\n Container otel-collector Starting\n Container grafana-srv Starting\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": "\u2705 Sistema de observabilidad inicializado con dashboards preconfigurados\nGrafana: http://localhost:33000 (user: admin, pass: admin123)\nCollector OTLP HTTP: http://localhost:4318\nCollector OTLP gRPC: localhost:4317\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"name": "stderr",
|
||||||
|
"text": " Container otel-collector Started\n Container grafana-srv Started\n"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,102 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.14.17"
|
||||||
|
app = marimo.App(width="medium")
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell(hide_code=True)
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""# Grafana: Inicialización automática 🚀""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import os
|
||||||
|
import yaml
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# ==== Parámetros ====
|
||||||
|
PUERTO_GRAFANA = 33000 # puerto host -> 3000 del contenedor
|
||||||
|
SERVICIO = "grafana_srv"
|
||||||
|
ADMIN_USER = "admin"
|
||||||
|
ADMIN_PASSWORD = "admin123"
|
||||||
|
RUTA_PROYECTO = Path(".").resolve()
|
||||||
|
|
||||||
|
return (
|
||||||
|
ADMIN_PASSWORD,
|
||||||
|
ADMIN_USER,
|
||||||
|
Path,
|
||||||
|
PUERTO_GRAFANA,
|
||||||
|
RUTA_PROYECTO,
|
||||||
|
SERVICIO,
|
||||||
|
subprocess,
|
||||||
|
yaml,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(Path, yaml):
|
||||||
|
def crear_docker_compose(ruta: Path, servicio: str, puerto_host: int, admin_user: str, admin_password: str):
|
||||||
|
compose = {
|
||||||
|
"version": "3.8",
|
||||||
|
"services": {
|
||||||
|
servicio: {
|
||||||
|
"image": "grafana/grafana:latest",
|
||||||
|
"container_name": servicio,
|
||||||
|
"restart": "always",
|
||||||
|
"ports": [f"{puerto_host}:3000"],
|
||||||
|
"environment": {
|
||||||
|
"GF_SECURITY_ADMIN_USER": admin_user,
|
||||||
|
"GF_SECURITY_ADMIN_PASSWORD": admin_password,
|
||||||
|
"GF_USERS_ALLOW_SIGN_UP": "false",
|
||||||
|
"GF_INSTALL_PLUGINS": "grafana-piechart-panel,grafana-worldmap-panel",
|
||||||
|
},
|
||||||
|
"volumes": [
|
||||||
|
"grafana_data:/var/lib/grafana",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"volumes": {"grafana_data": {}}
|
||||||
|
}
|
||||||
|
|
||||||
|
(ruta / "docker-compose.yml").write_text(yaml.dump(compose, sort_keys=False), encoding="utf-8")
|
||||||
|
|
||||||
|
return (crear_docker_compose,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(Path, subprocess):
|
||||||
|
def construir_y_levantar(ruta: Path):
|
||||||
|
def _run(cmd):
|
||||||
|
subprocess.run(cmd, cwd=ruta, check=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
_run(["docker", "compose", "build"])
|
||||||
|
_run(["docker", "compose", "up", "-d"])
|
||||||
|
except Exception:
|
||||||
|
_run(["docker-compose", "build"])
|
||||||
|
_run(["docker-compose", "up", "-d"])
|
||||||
|
|
||||||
|
return (construir_y_levantar,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(ADMIN_PASSWORD, ADMIN_USER, PUERTO_GRAFANA, RUTA_PROYECTO, SERVICIO, construir_y_levantar, crear_docker_compose):
|
||||||
|
if __name__ == "__main__":
|
||||||
|
RUTA_PROYECTO.mkdir(parents=True, exist_ok=True)
|
||||||
|
crear_docker_compose(RUTA_PROYECTO, SERVICIO, PUERTO_GRAFANA, ADMIN_USER, ADMIN_PASSWORD)
|
||||||
|
construir_y_levantar(RUTA_PROYECTO)
|
||||||
|
print(f"✅ Grafana inicializado en http://localhost:{PUERTO_GRAFANA} (usuario: {ADMIN_USER}, contraseña: {ADMIN_PASSWORD})")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.16.5"
|
||||||
|
app = marimo.App(width="columns")
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell(hide_code=True)
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""# 🐘 Postgres: DDBB con extensiones avanzadas (pgvector, PostGIS, TimescaleDB, etc.)""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import os
|
||||||
|
import textwrap
|
||||||
|
import yaml
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# ==== Parámetros ====
|
||||||
|
PUERTO_POSTGRES = 55432
|
||||||
|
SERVICIO = "postgres_ext"
|
||||||
|
PASSWORD = "mipassword"
|
||||||
|
USER = "postgres"
|
||||||
|
DBNAME = "basededatos"
|
||||||
|
|
||||||
|
# ==== Extensiones que quieres habilitar ====
|
||||||
|
EXTENSIONES = [
|
||||||
|
# Builtins
|
||||||
|
"hstore", "citext", "uuid-ossp", "pg_trgm",
|
||||||
|
"fuzzystrmatch", "tablefunc", "unaccent", "ltree",
|
||||||
|
# Ecosistema extendido
|
||||||
|
"postgis", "pgvector", "timescaledb",
|
||||||
|
]
|
||||||
|
|
||||||
|
RUTA_PROYECTO = Path(".").resolve()
|
||||||
|
return (
|
||||||
|
DBNAME,
|
||||||
|
EXTENSIONES,
|
||||||
|
PASSWORD,
|
||||||
|
PUERTO_POSTGRES,
|
||||||
|
Path,
|
||||||
|
RUTA_PROYECTO,
|
||||||
|
SERVICIO,
|
||||||
|
USER,
|
||||||
|
subprocess,
|
||||||
|
yaml,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.function
|
||||||
|
def pkgs_para_extensiones(exts, pg_major=15):
|
||||||
|
"""
|
||||||
|
Devuelve (pkgs_apt, builtins, needs_timescale_repo)
|
||||||
|
builtins = extensiones que no requieren apt
|
||||||
|
pkgs_apt = paquetes apt necesarios para extensiones adicionales
|
||||||
|
needs_timescale_repo = True si hay que añadir el repo de TimescaleDB
|
||||||
|
"""
|
||||||
|
builtins = []
|
||||||
|
pkgs_apt = []
|
||||||
|
needs_timescale_repo = False
|
||||||
|
|
||||||
|
for e in exts:
|
||||||
|
e_low = e.lower()
|
||||||
|
|
||||||
|
if e_low in {
|
||||||
|
"hstore", "citext", "uuid-ossp", "pg_trgm",
|
||||||
|
"fuzzystrmatch", "tablefunc", "unaccent", "ltree"
|
||||||
|
}:
|
||||||
|
builtins.append(e_low)
|
||||||
|
|
||||||
|
elif e_low == "postgis":
|
||||||
|
pkgs_apt += [
|
||||||
|
f"postgresql-{pg_major}-postgis-3",
|
||||||
|
f"postgresql-{pg_major}-postgis-3-scripts",
|
||||||
|
"gdal-bin",
|
||||||
|
"proj-bin",
|
||||||
|
]
|
||||||
|
|
||||||
|
elif e_low == "pgvector":
|
||||||
|
pkgs_apt += [f"postgresql-{pg_major}-pgvector"]
|
||||||
|
|
||||||
|
elif e_low == "timescaledb":
|
||||||
|
needs_timescale_repo = True
|
||||||
|
pkgs_apt += [f"timescaledb-2-postgresql-{pg_major}"]
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Extensión no soportada: {e}")
|
||||||
|
|
||||||
|
pkgs_apt = sorted(set(pkgs_apt))
|
||||||
|
return pkgs_apt, builtins, needs_timescale_repo
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(DBNAME, Path, USER):
|
||||||
|
from textwrap import dedent
|
||||||
|
from textwrap import indent
|
||||||
|
from textwrap import dedent
|
||||||
|
|
||||||
|
def generar_dockerfile(ruta: Path, exts, pg_major=15):
|
||||||
|
ruta.mkdir(parents=True, exist_ok=True)
|
||||||
|
pkgs_apt, builtins, needs_timescale_repo = pkgs_para_extensiones(exts, pg_major)
|
||||||
|
|
||||||
|
base_image = f"postgres:{pg_major}"
|
||||||
|
|
||||||
|
apt_lines = [
|
||||||
|
"RUN apt-get update && \\",
|
||||||
|
" apt-get install -y wget gnupg && \\",
|
||||||
|
]
|
||||||
|
|
||||||
|
if needs_timescale_repo:
|
||||||
|
apt_lines += [
|
||||||
|
" wget -qO- https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor -o /usr/share/keyrings/timescaledb.gpg && \\",
|
||||||
|
' echo \"deb [signed-by=/usr/share/keyrings/timescaledb.gpg] https://packagecloud.io/timescale/timescaledb/debian bookworm main\" > /etc/apt/sources.list.d/timescaledb.list && \\',
|
||||||
|
" apt-get update && \\",
|
||||||
|
]
|
||||||
|
|
||||||
|
if pkgs_apt:
|
||||||
|
apt_lines.append(" DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \\")
|
||||||
|
for pkg in pkgs_apt:
|
||||||
|
apt_lines.append(f" {pkg} \\")
|
||||||
|
apt_lines.append(" && rm -rf /var/lib/apt/lists/*")
|
||||||
|
|
||||||
|
apt_block = "\n".join(apt_lines)
|
||||||
|
|
||||||
|
# Si usa Timescale, añadimos pre-carga
|
||||||
|
preload_block = ""
|
||||||
|
if "timescaledb" in [e.lower() for e in exts]:
|
||||||
|
preload_block = (
|
||||||
|
"\n# Preload TimescaleDB\n"
|
||||||
|
"RUN echo \"shared_preload_libraries = 'timescaledb'\" >> /usr/share/postgresql/postgresql.conf.sample\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
dockerfile = f"""
|
||||||
|
FROM {base_image}
|
||||||
|
|
||||||
|
# Variables de entorno
|
||||||
|
ENV POSTGRES_USER={USER} \\
|
||||||
|
POSTGRES_DB={DBNAME}
|
||||||
|
|
||||||
|
{apt_block}
|
||||||
|
|
||||||
|
{preload_block}
|
||||||
|
|
||||||
|
# Copiamos scripts de inicialización
|
||||||
|
COPY docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
|
||||||
|
"""
|
||||||
|
|
||||||
|
(ruta / "Dockerfile").write_text(dedent(dockerfile).strip() + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
return (generar_dockerfile,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(Path):
|
||||||
|
def generar_init_sql(ruta: Path, exts):
|
||||||
|
init_dir = ruta / "docker-entrypoint-initdb.d"
|
||||||
|
init_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
lines = ["-- Habilitar extensiones solicitadas"]
|
||||||
|
for e in exts:
|
||||||
|
e_low = e.lower()
|
||||||
|
ext_name = {
|
||||||
|
"pgvector": "vector",
|
||||||
|
"postgis": "postgis",
|
||||||
|
"hstore": "hstore",
|
||||||
|
"citext": "citext",
|
||||||
|
"uuid-ossp": "\"uuid-ossp\"",
|
||||||
|
"pg_trgm": "pg_trgm",
|
||||||
|
"fuzzystrmatch": "fuzzystrmatch",
|
||||||
|
"tablefunc": "tablefunc",
|
||||||
|
"unaccent": "unaccent",
|
||||||
|
"ltree": "ltree",
|
||||||
|
"timescaledb": "timescaledb",
|
||||||
|
}.get(e_low, e_low)
|
||||||
|
lines.append(f"CREATE EXTENSION IF NOT EXISTS {ext_name};")
|
||||||
|
|
||||||
|
sql = "\n".join(lines) + "\n"
|
||||||
|
(init_dir / "10-extensions.sql").write_text(sql, encoding="utf-8")
|
||||||
|
|
||||||
|
return (generar_init_sql,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(DBNAME, Path, USER, yaml):
|
||||||
|
def crear_docker_compose(ruta: Path, servicio: str, puerto_host: int, password: str):
|
||||||
|
compose = {
|
||||||
|
"services": {
|
||||||
|
servicio: {
|
||||||
|
"build": {"context": "."},
|
||||||
|
"restart": "always",
|
||||||
|
"ports": [f"{puerto_host}:5432"],
|
||||||
|
"environment": {
|
||||||
|
"POSTGRES_PASSWORD": password,
|
||||||
|
"POSTGRES_USER": USER,
|
||||||
|
"POSTGRES_DB": DBNAME,
|
||||||
|
},
|
||||||
|
"healthcheck": {
|
||||||
|
"test": ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"],
|
||||||
|
"interval": "10s",
|
||||||
|
"timeout": "5s",
|
||||||
|
"retries": 5,
|
||||||
|
},
|
||||||
|
"volumes": ["postgres_data:/var/lib/postgresql/data"],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"volumes": {"postgres_data": {}},
|
||||||
|
}
|
||||||
|
|
||||||
|
(ruta / "docker-compose.yml").write_text(yaml.dump(compose, sort_keys=False), encoding="utf-8")
|
||||||
|
|
||||||
|
return (crear_docker_compose,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(Path, subprocess):
|
||||||
|
def construir_y_levantar(ruta: Path):
|
||||||
|
def _run(cmd):
|
||||||
|
subprocess.run(cmd, cwd=ruta, check=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
_run(["docker", "compose", "build"])
|
||||||
|
_run(["docker", "compose", "up", "-d"])
|
||||||
|
except Exception:
|
||||||
|
_run(["docker-compose", "build"])
|
||||||
|
_run(["docker-compose", "up", "-d"])
|
||||||
|
|
||||||
|
return (construir_y_levantar,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(
|
||||||
|
EXTENSIONES,
|
||||||
|
PASSWORD,
|
||||||
|
PUERTO_POSTGRES,
|
||||||
|
RUTA_PROYECTO,
|
||||||
|
SERVICIO,
|
||||||
|
construir_y_levantar,
|
||||||
|
crear_docker_compose,
|
||||||
|
generar_dockerfile,
|
||||||
|
generar_init_sql,
|
||||||
|
):
|
||||||
|
if __name__ == "__main__":
|
||||||
|
RUTA_PROYECTO.mkdir(parents=True, exist_ok=True)
|
||||||
|
generar_dockerfile(RUTA_PROYECTO, EXTENSIONES)
|
||||||
|
generar_init_sql(RUTA_PROYECTO, EXTENSIONES)
|
||||||
|
crear_docker_compose(RUTA_PROYECTO, SERVICIO, PUERTO_POSTGRES, PASSWORD)
|
||||||
|
construir_y_levantar(RUTA_PROYECTO)
|
||||||
|
print(f"✅ Postgres inicializado en http://localhost:{PUERTO_POSTGRES}")
|
||||||
|
print("📦 Extensiones instaladas:", ", ".join(EXTENSIONES))
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
version: '3.9'
|
||||||
|
services:
|
||||||
|
otel-collector:
|
||||||
|
image: otel/opentelemetry-collector-contrib:0.136.0
|
||||||
|
container_name: otel-collector
|
||||||
|
command:
|
||||||
|
- --config=/etc/otel/config.yaml
|
||||||
|
volumes:
|
||||||
|
- ./otel-config.yaml:/etc/otel/config.yaml
|
||||||
|
ports:
|
||||||
|
- 4317:4317
|
||||||
|
- 4318:4318
|
||||||
|
depends_on:
|
||||||
|
- victoria
|
||||||
|
- tempo
|
||||||
|
victoria:
|
||||||
|
image: victoriametrics/victoria-metrics:latest
|
||||||
|
container_name: victoria
|
||||||
|
ports:
|
||||||
|
- 8428:8428
|
||||||
|
volumes:
|
||||||
|
- ./victoria-data:/victoria-metrics-data
|
||||||
|
command:
|
||||||
|
- --storageDataPath=/victoria-metrics-data
|
||||||
|
- --retentionPeriod=3
|
||||||
|
tempo:
|
||||||
|
image: grafana/tempo:latest
|
||||||
|
container_name: tempo
|
||||||
|
ports:
|
||||||
|
- 3200:3200
|
||||||
|
volumes:
|
||||||
|
- ./tempo-data:/var/tempo
|
||||||
|
command:
|
||||||
|
- -config.file=/etc/tempo.yaml
|
||||||
|
configs:
|
||||||
|
- source: tempo_config
|
||||||
|
target: /etc/tempo.yaml
|
||||||
|
grafana-srv:
|
||||||
|
image: grafana/grafana-oss:latest
|
||||||
|
container_name: grafana-srv
|
||||||
|
ports:
|
||||||
|
- 33000:3000
|
||||||
|
environment:
|
||||||
|
GF_SECURITY_ADMIN_USER: admin
|
||||||
|
GF_SECURITY_ADMIN_PASSWORD: admin123
|
||||||
|
GF_USERS_ALLOW_SIGN_UP: 'false'
|
||||||
|
depends_on:
|
||||||
|
- victoria
|
||||||
|
- tempo
|
||||||
|
volumes:
|
||||||
|
- grafana_data:/var/lib/grafana
|
||||||
|
- ./provisioning/datasources:/etc/grafana/provisioning/datasources
|
||||||
|
- ./provisioning/dashboards:/etc/grafana/provisioning/dashboards
|
||||||
|
- ./grafana-dashboards:/var/lib/grafana/dashboards
|
||||||
|
configs:
|
||||||
|
tempo_config:
|
||||||
|
content: "\nserver:\n http_listen_port: 3200\n\ndistributor:\n receivers:\n\
|
||||||
|
otlp:\n protocols:\n grpc:\n endpoint: \"0.0.0.0:4317\"\n http:\n\
|
||||||
|
\ endpoint: \"0.0.0.0:4318\"\n\ningester:\n trace_idle_period: 10s\n \
|
||||||
|
\ max_block_bytes: 1000000\n max_block_duration: 5m\n\ncompactor:\n compaction:\n\
|
||||||
|
block_retention: 24h\n\nstorage:\n trace:\nwal:\n path: /var/tempo/wal\nlocal:\n\
|
||||||
|
\ path: /var/tempo/blocks\n"
|
||||||
|
volumes:
|
||||||
|
grafana_data: {}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"uid": "overview",
|
||||||
|
"title": "\ud83d\udcca System Overview",
|
||||||
|
"timezone": "browser",
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"type": "graph",
|
||||||
|
"title": "CPU Usage",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "process_cpu_seconds_total",
|
||||||
|
"legendFormat": "{{instance}}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "table",
|
||||||
|
"title": "Logs (simulados)",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "up"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"schemaVersion": 36,
|
||||||
|
"version": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
receivers:
|
||||||
|
otlp:
|
||||||
|
protocols:
|
||||||
|
grpc: {}
|
||||||
|
http: {}
|
||||||
|
processors:
|
||||||
|
batch: {}
|
||||||
|
exporters:
|
||||||
|
prometheusremotewrite:
|
||||||
|
endpoint: http://victoria:8428/api/v1/write
|
||||||
|
otlp/tempo:
|
||||||
|
endpoint: http://tempo:4317
|
||||||
|
tls:
|
||||||
|
insecure: true
|
||||||
|
debug:
|
||||||
|
verbosity: normal
|
||||||
|
service:
|
||||||
|
pipelines:
|
||||||
|
metrics:
|
||||||
|
receivers:
|
||||||
|
- otlp
|
||||||
|
processors:
|
||||||
|
- batch
|
||||||
|
exporters:
|
||||||
|
- prometheusremotewrite
|
||||||
|
- debug
|
||||||
|
traces:
|
||||||
|
receivers:
|
||||||
|
- otlp
|
||||||
|
processors:
|
||||||
|
- batch
|
||||||
|
exporters:
|
||||||
|
- otlp/tempo
|
||||||
|
- debug
|
||||||
|
logs:
|
||||||
|
receivers:
|
||||||
|
- otlp
|
||||||
|
processors:
|
||||||
|
- batch
|
||||||
|
exporters:
|
||||||
|
- prometheusremotewrite
|
||||||
|
- debug
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
providers:
|
||||||
|
- name: default
|
||||||
|
orgId: 1
|
||||||
|
folder: ''
|
||||||
|
type: file
|
||||||
|
disableDeletion: false
|
||||||
|
updateIntervalSeconds: 10
|
||||||
|
options:
|
||||||
|
path: /var/lib/grafana/dashboards
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
datasources:
|
||||||
|
- name: VictoriaMetrics
|
||||||
|
type: prometheus
|
||||||
|
access: proxy
|
||||||
|
url: http://victoria:8428
|
||||||
|
isDefault: true
|
||||||
|
- name: Tempo
|
||||||
|
type: tempo
|
||||||
|
access: proxy
|
||||||
|
url: http://tempo:3200
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
田Jpu6�
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
Binary file not shown.
@@ -0,0 +1,76 @@
|
|||||||
|
from agno.agent import Agent
|
||||||
|
from agno.models.openai import OpenAIChat
|
||||||
|
|
||||||
|
# Prefect imports #######################################
|
||||||
|
|
||||||
|
from prefect import task, flow
|
||||||
|
from prefect.logging import get_run_logger
|
||||||
|
from prefect.filesystems import LocalFileSystem
|
||||||
|
|
||||||
|
local_file_system_block = LocalFileSystem.load("localfile")
|
||||||
|
|
||||||
|
# Cargar variables de entorno ###########################
|
||||||
|
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
openai_api_key = os.getenv("OPENAI_API_KEY")
|
||||||
|
|
||||||
|
|
||||||
|
prefect_logger = get_run_logger()
|
||||||
|
|
||||||
|
# Definir tareas ###############################################
|
||||||
|
|
||||||
|
@task(name="Inicializar agente financiero", log_prints=True)
|
||||||
|
def inicializar_agente_financiero():
|
||||||
|
prefect_logger.debug(f"Inicializando el agente financiero")
|
||||||
|
# Aquí se podría agregar la lógica para inicializar el agente
|
||||||
|
return "Agente financiero inicializado"
|
||||||
|
|
||||||
|
|
||||||
|
@task(name="Analizar datos financieros", log_prints=True)
|
||||||
|
def analizar_datos_financieros(datos: str):
|
||||||
|
|
||||||
|
prefect_logger = get_run_logger()
|
||||||
|
|
||||||
|
prefect_logger.debug(f"Creando el agente con OpenAI")
|
||||||
|
|
||||||
|
prefect_logger.debug(f"analizando los datos: {datos}")
|
||||||
|
|
||||||
|
# Crear el agente
|
||||||
|
agente = Agent(
|
||||||
|
model=OpenAIChat(id="gpt-4o-mini", api_key=openai_api_key),
|
||||||
|
name="analista_financiero",
|
||||||
|
description="Agente especializado en análisis financiero y económico"
|
||||||
|
)
|
||||||
|
|
||||||
|
prefect_logger.debug(f"Ejecutando el agente")
|
||||||
|
|
||||||
|
respuesta = agente.run("Da un resumen corto financiero de los siguientes datos: " + datos)
|
||||||
|
|
||||||
|
prefect_logger.info(f"Respuesta del agente: {respuesta.content}")
|
||||||
|
|
||||||
|
return respuesta.content
|
||||||
|
|
||||||
|
|
||||||
|
# Definir el flujo principal #########################################
|
||||||
|
|
||||||
|
@flow(name="Flujo financiero", result_storage=local_file_system_block, log_prints=True) # type: ignore
|
||||||
|
def flujo_principal():
|
||||||
|
datos_ejemplo = "La bolsa de valores de Nueva York cerró al alza hoy, con el índice S&P 500 subiendo un 1.2% impulsado por ganancias en el sector tecnológico. Las acciones de Apple y Microsoft lideraron las ganancias, mientras que los mercados europeos también mostraron signos de recuperación tras datos económicos positivos."
|
||||||
|
|
||||||
|
agente_inicializado = inicializar_agente_financiero.submit().result()
|
||||||
|
|
||||||
|
|
||||||
|
resultado_analisis = analizar_datos_financieros.submit(datos_ejemplo).result()
|
||||||
|
|
||||||
|
return resultado_analisis
|
||||||
|
|
||||||
|
|
||||||
|
# Ejecutar el flujo principal #############################
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
flujo_principal()
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[project]
|
||||||
|
name = "conseguir-datos-con-agentes"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.13"
|
||||||
|
dependencies = [
|
||||||
|
"agno>=2.1.1",
|
||||||
|
"icecream>=2.1.8",
|
||||||
|
"marimo>=0.16.5",
|
||||||
|
"openai>=2.1.0",
|
||||||
|
"prefect>=3.4.22",
|
||||||
|
"psycopg2>=2.9.10",
|
||||||
|
"wikipedia>=1.4.0",
|
||||||
|
"yfinance>=0.2.66",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.marimo.runtime]
|
||||||
|
dotenv = [".env", "/home/lucas/DataProyects/Snippets_marimo_noteebooks/secrets/.env.snpt"]
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
# Constantes ##########################################################################
|
||||||
|
|
||||||
|
PROMPT = "Busca en Wikipedia información sobre la inflación en Argentina y dame un resumen."
|
||||||
|
|
||||||
|
|
||||||
|
# Librerias de Agno ################################################################
|
||||||
|
|
||||||
|
from agno.agent import Agent
|
||||||
|
from agno.models.openai import OpenAIChat
|
||||||
|
from agno.tools.yfinance import YFinanceTools
|
||||||
|
from agno.tools.wikipedia import WikipediaTools
|
||||||
|
|
||||||
|
# Prefect imports ##################################################################
|
||||||
|
|
||||||
|
from prefect import task, flow
|
||||||
|
from prefect.logging import get_run_logger
|
||||||
|
from prefect.filesystems import LocalFileSystem
|
||||||
|
|
||||||
|
local_file_system_block = LocalFileSystem.load("localfile")
|
||||||
|
|
||||||
|
# Cargar variables de entorno ######################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
openai_api_key = os.getenv("OPENAI_API_KEY")
|
||||||
|
|
||||||
|
|
||||||
|
# Imports adicionales #########################################################
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 01. Averiguar el prompt que se envía a OpenAI ################################################
|
||||||
|
|
||||||
|
|
||||||
|
@task(name="averiguar_el_prompt_que_seenvia_a_openai", log_prints=True)
|
||||||
|
def averiguar_el_prompt_que_seenvia_a_openai(prompt_de_usuario: str):
|
||||||
|
prefect_logger = get_run_logger()
|
||||||
|
|
||||||
|
try:
|
||||||
|
prefect_logger.debug("Creando el agente con OpenAI")
|
||||||
|
|
||||||
|
agente = Agent(
|
||||||
|
model=OpenAIChat(id="gpt-4o-mini", api_key=openai_api_key),
|
||||||
|
name="analista_financiero",
|
||||||
|
description="Agente especializado en análisis financiero y económico",
|
||||||
|
debug_mode=True,
|
||||||
|
tools=[YFinanceTools(), WikipediaTools()],
|
||||||
|
)
|
||||||
|
|
||||||
|
prefect_logger.debug("Preparando los mensajes que se enviarán al modelo...")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 🚀 Este método interno construye los mensajes igual que antes,
|
||||||
|
# pero no requiere crear un RunOutput ni AgentSession manualmente.
|
||||||
|
run_messages = agente._get_run_messages(
|
||||||
|
run_response=None,
|
||||||
|
input=prompt_de_usuario,
|
||||||
|
session=None,
|
||||||
|
session_state={},
|
||||||
|
user_id=None,
|
||||||
|
audio=None,
|
||||||
|
images=None,
|
||||||
|
videos=None,
|
||||||
|
files=None,
|
||||||
|
knowledge_filters=None,
|
||||||
|
add_history_to_context=False,
|
||||||
|
dependencies=None,
|
||||||
|
add_dependencies_to_context=False,
|
||||||
|
add_session_state_to_context=False,
|
||||||
|
metadata=None,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
prefect_logger.error("❌ Error al generar los mensajes con _get_run_messages()")
|
||||||
|
prefect_logger.error(f"Tipo de error: {type(e).__name__}")
|
||||||
|
prefect_logger.error(f"Detalle: {str(e)}")
|
||||||
|
prefect_logger.error(traceback.format_exc())
|
||||||
|
raise
|
||||||
|
|
||||||
|
mensajes_enviados = []
|
||||||
|
try:
|
||||||
|
for msg in run_messages.messages:
|
||||||
|
mensajes_enviados.append({
|
||||||
|
"role": msg.role,
|
||||||
|
"content": msg.content
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
prefect_logger.error("❌ Error al procesar los mensajes construidos.")
|
||||||
|
prefect_logger.error(f"Tipo de error: {type(e).__name__}")
|
||||||
|
prefect_logger.error(f"Detalle: {str(e)}")
|
||||||
|
prefect_logger.error(traceback.format_exc())
|
||||||
|
raise
|
||||||
|
|
||||||
|
prefect_logger.info("✅ Mensajes construidos por el agente:")
|
||||||
|
for m in mensajes_enviados:
|
||||||
|
prefect_logger.info(f"ROLE: {m['role']}\nCONTENT:\n{m['content']}\n{'-'*40}")
|
||||||
|
|
||||||
|
resultado = agente.run(prompt_de_usuario)
|
||||||
|
|
||||||
|
prefect_logger.info("✅ Resultado de la ejecución:")
|
||||||
|
prefect_logger.info(f"{resultado}")
|
||||||
|
|
||||||
|
prefect_logger.debug("Función completada correctamente ✅")
|
||||||
|
|
||||||
|
return mensajes_enviados
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
prefect_logger.error("💥 Error inesperado en la tarea averiguar_el_prompt_que_seenvia_a_openai")
|
||||||
|
prefect_logger.error(f"Tipo de error: {type(e).__name__}")
|
||||||
|
prefect_logger.error(f"Mensaje: {str(e)}")
|
||||||
|
prefect_logger.error(traceback.format_exc())
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Definir el flujo principal #########################################
|
||||||
|
|
||||||
|
@flow(name="Flujo financiero", result_storage=local_file_system_block, log_prints=True) # type: ignore
|
||||||
|
def flujo_principal():
|
||||||
|
|
||||||
|
resultado_analisis = averiguar_el_prompt_que_seenvia_a_openai.submit(PROMPT).result()
|
||||||
|
|
||||||
|
return resultado_analisis
|
||||||
|
|
||||||
|
|
||||||
|
# Ejecutar el flujo principal #############################
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
flujo_principal()
|
||||||
Reference in New Issue
Block a user