Edoruin commited on
Commit
a568b10
·
1 Parent(s): e086c0e

first commit

Browse files
Files changed (5) hide show
  1. .env +4 -0
  2. Dockerfile +19 -0
  3. app/main.py +84 -0
  4. app/requirements.txt +2 -0
  5. docker-compose.yml +22 -0
.env ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ GITLAB_URL=https://gitlab.com/makerspace_hdn/
2
+ GITLAB_TOKEN=glpat-VkujDazDFGuvc0uCRRSXS286MQp1Omg2bmFxCw.01.12039j3cr
3
+ GITLAB_GROUP_ID=115981034
4
+
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+
3
+ # Instalar dependencias de sistema para Flet
4
+ RUN apt-get update && apt-get install -y \
5
+ git \
6
+ && rm -rf /var/lib/apt/lists/*
7
+
8
+ WORKDIR /app
9
+
10
+ COPY app/requirements.txt .
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ COPY app/ .
14
+
15
+ # Exponer el puerto que definimos en main.py
16
+ EXPOSE 8080
17
+
18
+ # Comando para ejecutar la app en modo PWA
19
+ CMD ["python", "main.py"]
app/main.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import flet as ft
2
+ import gitlab
3
+ import os
4
+
5
+ def main(page: ft.Page):
6
+ page.title = "MAKERSPACE DATABASE"
7
+ page.theme_mode = ft.ThemeMode.DARK
8
+ page.padding = 20
9
+
10
+ # 1. Configuración de Variables
11
+ GITLAB_URL = os.getenv("GITLAB_URL", "https://gitlab.com")
12
+ TOKEN = os.getenv("GITLAB_TOKEN")
13
+ GROUP_ID = os.getenv("GITLAB_GROUP_ID") # ID del grupo Makerspace
14
+
15
+ if not TOKEN or not GROUP_ID:
16
+ page.add(ft.Text("ERROR: Falta GITLAB_TOKEN o GITLAB_GROUP_ID", color="red", size=20))
17
+ return
18
+
19
+ try:
20
+ gl = gitlab.Gitlab(GITLAB_URL, private_token=TOKEN)
21
+ gl.auth()
22
+ # Obtener el objeto del grupo
23
+ target_group = gl.groups.get(GROUP_ID)
24
+ except Exception as e:
25
+ page.add(ft.Text(f"Error de conexión: {e}", color="red"))
26
+ return
27
+
28
+ repo_list = ft.ListView(expand=1, spacing=10, padding=20)
29
+ loading_indicator = ft.ProgressBar(visible=False, color="blue")
30
+
31
+ def load_projects(e=None):
32
+ loading_indicator.visible = True
33
+ repo_list.controls.clear()
34
+ page.update()
35
+
36
+ try:
37
+ # Traer proyectos específicamente del grupo
38
+ # 'include_subgroups=True' por si tienes carpetas dentro del grupo
39
+ projects = target_group.projects.list(all=True, include_subgroups=True)
40
+
41
+ for p in projects:
42
+ # El objeto de proyecto de grupo es un poco diferente,
43
+ # a veces es mejor obtener el objeto de proyecto completo
44
+ repo_list.controls.append(
45
+ ft.Container(
46
+ content=ft.ListTile(
47
+ leading=ft.Icon(ft.icons.FOLDER),
48
+ title=ft.Text(p.name, weight="bold"),
49
+ subtitle=ft.Text(f"Creado: {p.created_at[:10]}"),
50
+ trailing=ft.IconButton(
51
+ icon=ft.icons.DOWNLOAD,
52
+ on_click=lambda _, pid=p.id: page.launch_url(
53
+ f"{GITLAB_URL}/api/v4/projects/{pid}/repository/archive.zip?private_token={TOKEN}"
54
+ )
55
+ ),
56
+ ),
57
+ bgcolor=ft.colors.SURFACE_VARIANT,
58
+ border_radius=10,
59
+ )
60
+ )
61
+ except Exception as ex:
62
+ repo_list.controls.append(ft.Text(f"Error: {ex}"))
63
+
64
+ loading_indicator.visible = False
65
+ page.update()
66
+
67
+ # Interfaz
68
+ page.add(
69
+ ft.Row([
70
+ ft.Icon(ft.icons.GROUPS, color="blue", size=30),
71
+ ft.Column([
72
+ ft.Text(f"MAKERSPACE DATABASE", size=25, weight="bold"),
73
+ ft.Text(f"Grupo: {target_group.name}", size=15, color="blue")
74
+ ])
75
+ ], alignment=ft.MainAxisAlignment.START),
76
+ ft.Divider(),
77
+ loading_indicator,
78
+ repo_list
79
+ )
80
+
81
+ load_projects()
82
+
83
+ if __name__ == "__main__":
84
+ ft.app(target=main, view=ft.AppView.WEB_BROWSER, port=8080, host="0.0.0.0")
app/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flet
2
+ python-gitlab
docker-compose.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ makerspace-app:
3
+ build: .
4
+ container_name: makerspace_db
5
+ environment:
6
+ - GITLAB_URL=${GITLAB_URL}
7
+ - GITLAB_TOKEN=${GITLAB_TOKEN}
8
+ - GITLAB_GROUP_ID=${GITLAB_GROUP_ID}
9
+ - PYTHONUNBUFFERED=1
10
+ restart: always
11
+
12
+ tunnel:
13
+ image: alpine:latest
14
+ container_name: localtunnel_service
15
+ depends_on:
16
+ - makerspace-app
17
+ # Añadimos parámetros para mantener la conexión viva y evitar que se cierre por "timeout"
18
+ command: >
19
+ sh -c "apk add --no-cache openssh &&
20
+ echo '--- INICIANDO TUNEL COMPATIBLE ---' &&
21
+ ssh -t -o StrictHostKeyChecking=no -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -R mi-makerspace-2026:80:makerspace-app:8080 serveo.net"
22
+ restart: always