up
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
# SISTEMA DE WEBSITE
|
# SISTEMA DE WEBSITE
|
||||||
|
|
||||||
Este sistema ha sido desarrollado por U-Site para Gases del Oriente con el propósito de optimizar la gestión administrativa, mejorar la experiencia del usuario y facilitar el acceso a información clave. Está diseñado para centralizar la administración de contenidos web, trámites virtuales y configuraciones del sistema, asegurando eficiencia, seguridad y personalización según las necesidades de la organización y sus usuarios.
|
Este sistema ha sido desarrollado por U-Site para Usite SAS BIC con el propósito de optimizar la gestión administrativa, mejorar la experiencia del usuario y facilitar el acceso a información clave. Está diseñado para centralizar la administración de contenidos web, trámites virtuales y configuraciones del sistema, asegurando eficiencia, seguridad y personalización según las necesidades de la organización y sus usuarios.
|
||||||
|
|
||||||
## Descripción
|
## Descripción
|
||||||
|
|
||||||
El software permite crear una plataforma moderna y segura que optimiza la experiencia del usuario y asegura la protección de datos. Ofrece una página web con un diseño atractivo y funcional, adaptado a diversos dispositivos y navegadores, mientras que la oficina virtual proporciona herramientas colaborativas y de comunicación para la gestión interna. Entre sus principales funcionalidades, incluye una interfaz intuitiva, medidas de seguridad avanzadas, y una experiencia optimizada para dispositivos móviles y de escritorio. Además, ofrece soporte continuo y mantenimiento para asegurar el buen funcionamiento de la plataforma, mejorando la seguridad cibernética y reforzando la presencia digital de GASES DEL ORIENTE S.A E.S.P.
|
El software permite crear una plataforma moderna y segura que optimiza la experiencia del usuario y asegura la protección de datos. Ofrece una página web con un diseño atractivo y funcional, adaptado a diversos dispositivos y navegadores, mientras que la oficina virtual proporciona herramientas colaborativas y de comunicación para la gestión interna. Entre sus principales funcionalidades, incluye una interfaz intuitiva, medidas de seguridad avanzadas, y una experiencia optimizada para dispositivos móviles y de escritorio. Además, ofrece soporte continuo y mantenimiento para asegurar el buen funcionamiento de la plataforma, mejorando la seguridad cibernética y reforzando la presencia digital de Usite SAS BIC.
|
||||||
|
|
||||||
## Requisitos del Sistema
|
## Requisitos del Sistema
|
||||||
|
|
||||||
@@ -13,8 +13,8 @@ El software permite crear una plataforma moderna y segura que optimiza la experi
|
|||||||
|
|
||||||
## Instalación
|
## Instalación
|
||||||
|
|
||||||
1. Clona el repositorio de GitHub: `git clone https://github.com/lizandrogd/gases.git`
|
1. Clona el repositorio de GitHub: `git clone https://github.com/lizandrogd/soft_usite.git`
|
||||||
2. Accede al directorio del proyecto: `cd gases`
|
2. Accede al directorio del proyecto: `cd soft_usite`
|
||||||
3. Instala las dependencias de go: `go mod tidy`
|
3. Instala las dependencias de go: `go mod tidy`
|
||||||
|
|
||||||
## Uso
|
## Uso
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ mail:
|
|||||||
password:
|
password:
|
||||||
encryption: tls
|
encryption: tls
|
||||||
from_address: "itsursujit@gmail.com"
|
from_address: "itsursujit@gmail.com"
|
||||||
from_name: "Sujit Baniya"
|
from_name: "Usite SAS BIC"
|
||||||
|
|
||||||
token:
|
token:
|
||||||
app_jwt_secret: SECRET_APP
|
app_jwt_secret: SECRET_APP
|
||||||
|
|||||||
+4
-4
@@ -16,11 +16,11 @@ type Mail struct {
|
|||||||
*mail.SMTPServer
|
*mail.SMTPServer
|
||||||
*mail.SMTPClient
|
*mail.SMTPClient
|
||||||
Host string `mapstructure:"MAIL_HOST" yaml:"host" env:"MAIL_HOST" env-default:"smtp-mail.outlook.com"`
|
Host string `mapstructure:"MAIL_HOST" yaml:"host" env:"MAIL_HOST" env-default:"smtp-mail.outlook.com"`
|
||||||
Username string `mapstructure:"MAIL_USERNAME" yaml:"username" env:"MAIL_USERNAME" env-default:"ovirtual@gasesdeloriente.com.co"`
|
Username string `mapstructure:"MAIL_USERNAME" yaml:"username" env:"MAIL_USERNAME" env-default:"info@u-site.app"`
|
||||||
Password string `mapstructure:"MAIL_PASSWORD" yaml:"password" env:"MAIL_PASSWORD" env-default:"Gases2023**"`
|
Password string `mapstructure:"MAIL_PASSWORD" yaml:"password" env:"MAIL_PASSWORD" env-default:""`
|
||||||
Encryption string `mapstructure:"MAIL_ENCRYPTION" yaml:"encryption" env:"MAIL_ENCRYPTION" env-default:"tls"`
|
Encryption string `mapstructure:"MAIL_ENCRYPTION" yaml:"encryption" env:"MAIL_ENCRYPTION" env-default:"tls"`
|
||||||
FromAddress string `mapstructure:"MAIL_FROM_ADDRESS" yaml:"from_address" env:"MAIL_FROM_ADDRESS" env-default:"ovirtual@gasesdeloriente.com.co"`
|
FromAddress string `mapstructure:"MAIL_FROM_ADDRESS" yaml:"from_address" env:"MAIL_FROM_ADDRESS" env-default:"info@u-site.app"`
|
||||||
FromName string `mapstructure:"MAIL_FROM_NAME" yaml:"from_name" env:"MAIL_FROM_NAME" env-default:"Gases"`
|
FromName string `mapstructure:"MAIL_FROM_NAME" yaml:"from_name" env:"MAIL_FROM_NAME" env-default:"Usite SAS BIC"`
|
||||||
View *ViewConfig
|
View *ViewConfig
|
||||||
Port int `mapstructure:"MAIL_PORT" yaml:"port" env:"MAIL_PORT" env-default:"587"` // Cambié a 465 para SSL
|
Port int `mapstructure:"MAIL_PORT" yaml:"port" env:"MAIL_PORT" env-default:"587"` // Cambié a 465 para SSL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"html"
|
||||||
|
"net"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/sujit-baniya/fiber-boilerplate/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// getAppURL devuelve la URL base absoluta (sin slash final).
|
||||||
|
// Si APP_URL es http://localhost sin puerto, añade APP_PORT para enlaces en desarrollo.
|
||||||
|
func getAppURL() string {
|
||||||
|
u := strings.TrimRight(app.Http.Server.Url, "/")
|
||||||
|
if u == "" {
|
||||||
|
return fmt.Sprintf("http://localhost:%s", app.Http.Server.Port)
|
||||||
|
}
|
||||||
|
|
||||||
|
parsed, err := url.Parse(u)
|
||||||
|
if err != nil || parsed.Host == "" {
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
|
host := parsed.Hostname()
|
||||||
|
if parsed.Port() == "" && app.Http.Server.Port != "" {
|
||||||
|
if host == "localhost" || host == "127.0.0.1" {
|
||||||
|
parsed.Host = net.JoinHostPort(host, app.Http.Server.Port)
|
||||||
|
return strings.TrimRight(parsed.String(), "/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
|
// absAppURL convierte una ruta relativa en URL absoluta para correo/Telegram.
|
||||||
|
func absAppURL(path string) string {
|
||||||
|
if path == "" {
|
||||||
|
return getAppURL()
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(path, "/") {
|
||||||
|
path = "/" + path
|
||||||
|
}
|
||||||
|
return getAppURL() + path
|
||||||
|
}
|
||||||
|
|
||||||
|
func adminTicketPath(ticketID uint) string {
|
||||||
|
return fmt.Sprintf("/app/tickets?ticket=%d", ticketID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func portalTicketPath(proyectoSlug string, ticketID uint) string {
|
||||||
|
if proyectoSlug == "" {
|
||||||
|
return "/portal/dashboard"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("/portal/proyecto/%s?tab=Tickets&ticket=%d", url.PathEscape(proyectoSlug), ticketID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func escapeTelegramHTML(s string) string {
|
||||||
|
return html.EscapeString(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func telegramHTMLLink(absURL, label string) string {
|
||||||
|
return fmt.Sprintf(`<a href="%s">%s</a>`, escapeTelegramHTML(absURL), escapeTelegramHTML(label))
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/sujit-baniya/fiber-boilerplate/app"
|
||||||
|
"github.com/sujit-baniya/fiber-boilerplate/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetAppURLLocalhostAddsPort(t *testing.T) {
|
||||||
|
app.Http = &config.AppConfig{
|
||||||
|
Server: config.ServerConfig{
|
||||||
|
Url: "http://localhost",
|
||||||
|
Port: "8084",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if got := getAppURL(); got != "http://localhost:8084" {
|
||||||
|
t.Fatalf("getAppURL() = %q, want http://localhost:8084", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAbsAppURLRelativePath(t *testing.T) {
|
||||||
|
app.Http = &config.AppConfig{
|
||||||
|
Server: config.ServerConfig{
|
||||||
|
Url: "http://localhost",
|
||||||
|
Port: "8084",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
got := absAppURL("/app/tickets?ticket=3")
|
||||||
|
want := "http://localhost:8084/app/tickets?ticket=3"
|
||||||
|
if got != want {
|
||||||
|
t.Fatalf("absAppURL() = %q, want %q", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTelegramHTMLLinkEscapesAmpersand(t *testing.T) {
|
||||||
|
link := telegramHTMLLink("http://localhost:8084/portal/p?tab=Tickets&ticket=1", "Ver portal")
|
||||||
|
if link != `<a href="http://localhost:8084/portal/p?tab=Tickets&ticket=1">Ver portal</a>` {
|
||||||
|
t.Fatalf("telegramHTMLLink() = %q", link)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@ package services
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/sujit-baniya/fiber-boilerplate/app"
|
|
||||||
"github.com/sujit-baniya/fiber-boilerplate/pkg/models"
|
"github.com/sujit-baniya/fiber-boilerplate/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,8 +18,8 @@ func DispatchTicketNuevo(ticket *models.ProyectoTicket, portalUser *models.Porta
|
|||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
baseURL := getAppURL()
|
ticketPath := adminTicketPath(ticket.ID)
|
||||||
ticketURL := baseURL + "/app/tickets"
|
ticketURL := absAppURL(ticketPath)
|
||||||
titulo := fmt.Sprintf("Nuevo ticket: %s", ticket.Titulo)
|
titulo := fmt.Sprintf("Nuevo ticket: %s", ticket.Titulo)
|
||||||
cuerpo := fmt.Sprintf("Cliente: %s\nProyecto: %s\n%s", ticket.AutorNombre, proyectoNombre, ticket.Descripcion)
|
cuerpo := fmt.Sprintf("Cliente: %s\nProyecto: %s\n%s", ticket.AutorNombre, proyectoNombre, ticket.Descripcion)
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ func DispatchTicketNuevo(ticket *models.ProyectoTicket, portalUser *models.Porta
|
|||||||
UsuarioID: 0,
|
UsuarioID: 0,
|
||||||
Titulo: titulo,
|
Titulo: titulo,
|
||||||
Cuerpo: cuerpo,
|
Cuerpo: cuerpo,
|
||||||
Url: ticketURL,
|
Url: ticketPath,
|
||||||
Icono: "🎫",
|
Icono: "🎫",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -39,8 +39,12 @@ func DispatchTicketNuevo(ticket *models.ProyectoTicket, portalUser *models.Porta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cfg.CanalTelegram {
|
if cfg.CanalTelegram {
|
||||||
msg := fmt.Sprintf("🎫 <b>Nuevo ticket</b>\nProyecto: <b>%s</b>\nCliente: %s\nTítulo: <b>%s</b>\n\n%s\n\n🔗 <a href=\"%s\">Ver tickets</a>",
|
msg := fmt.Sprintf("🎫 <b>Nuevo ticket</b>\nProyecto: <b>%s</b>\nCliente: %s\nTítulo: <b>%s</b>\n\n%s\n\n🔗 %s",
|
||||||
proyectoNombre, ticket.AutorNombre, ticket.Titulo, ticket.Descripcion, ticketURL)
|
escapeTelegramHTML(proyectoNombre),
|
||||||
|
escapeTelegramHTML(ticket.AutorNombre),
|
||||||
|
escapeTelegramHTML(ticket.Titulo),
|
||||||
|
escapeTelegramHTML(ticket.Descripcion),
|
||||||
|
telegramHTMLLink(ticketURL, "Ver ticket"))
|
||||||
sendTelegramAdmin(msg)
|
sendTelegramAdmin(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,8 +59,8 @@ func DispatchTicketRespuestaCliente(ticket *models.ProyectoTicket, contenido str
|
|||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
baseURL := getAppURL()
|
ticketPath := adminTicketPath(ticket.ID)
|
||||||
ticketURL := baseURL + "/app/tickets"
|
ticketURL := absAppURL(ticketPath)
|
||||||
titulo := fmt.Sprintf("Respuesta de cliente en: %s", ticket.Titulo)
|
titulo := fmt.Sprintf("Respuesta de cliente en: %s", ticket.Titulo)
|
||||||
cuerpo := fmt.Sprintf("Cliente: %s\nProyecto: %s\n%s", ticket.AutorNombre, proyectoNombre, contenido)
|
cuerpo := fmt.Sprintf("Cliente: %s\nProyecto: %s\n%s", ticket.AutorNombre, proyectoNombre, contenido)
|
||||||
|
|
||||||
@@ -66,7 +70,7 @@ func DispatchTicketRespuestaCliente(ticket *models.ProyectoTicket, contenido str
|
|||||||
UsuarioID: 0,
|
UsuarioID: 0,
|
||||||
Titulo: titulo,
|
Titulo: titulo,
|
||||||
Cuerpo: cuerpo,
|
Cuerpo: cuerpo,
|
||||||
Url: ticketURL,
|
Url: ticketPath,
|
||||||
Icono: "💬",
|
Icono: "💬",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -76,8 +80,11 @@ func DispatchTicketRespuestaCliente(ticket *models.ProyectoTicket, contenido str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cfg.CanalTelegram {
|
if cfg.CanalTelegram {
|
||||||
msg := fmt.Sprintf("💬 <b>Respuesta de cliente</b>\nProyecto: <b>%s</b>\nCliente: %s\n\n%s\n\n🔗 <a href=\"%s\">Ver tickets</a>",
|
msg := fmt.Sprintf("💬 <b>Respuesta de cliente</b>\nProyecto: <b>%s</b>\nCliente: %s\n\n%s\n\n🔗 %s",
|
||||||
proyectoNombre, ticket.AutorNombre, contenido, ticketURL)
|
escapeTelegramHTML(proyectoNombre),
|
||||||
|
escapeTelegramHTML(ticket.AutorNombre),
|
||||||
|
escapeTelegramHTML(contenido),
|
||||||
|
telegramHTMLLink(ticketURL, "Ver ticket"))
|
||||||
sendTelegramAdmin(msg)
|
sendTelegramAdmin(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,8 +106,12 @@ func DispatchTicketRespuestaAdmin(ticket *models.ProyectoTicket, contenido strin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
baseURL := getAppURL()
|
proyectoSlug := ""
|
||||||
portalURL := baseURL + "/portal/dashboard"
|
if proy, err := models.GetProyectoByID(ticket.ProyectoID); err == nil {
|
||||||
|
proyectoSlug = proy.Slug
|
||||||
|
}
|
||||||
|
portalPath := portalTicketPath(proyectoSlug, ticket.ID)
|
||||||
|
portalURL := absAppURL(portalPath)
|
||||||
titulo := fmt.Sprintf("Respuesta en tu ticket: %s", ticket.Titulo)
|
titulo := fmt.Sprintf("Respuesta en tu ticket: %s", ticket.Titulo)
|
||||||
cuerpo := fmt.Sprintf("El equipo respondió: %s", contenido)
|
cuerpo := fmt.Sprintf("El equipo respondió: %s", contenido)
|
||||||
|
|
||||||
@@ -110,7 +121,7 @@ func DispatchTicketRespuestaAdmin(ticket *models.ProyectoTicket, contenido strin
|
|||||||
UsuarioID: portalUser.ID,
|
UsuarioID: portalUser.ID,
|
||||||
Titulo: titulo,
|
Titulo: titulo,
|
||||||
Cuerpo: cuerpo,
|
Cuerpo: cuerpo,
|
||||||
Url: portalURL,
|
Url: portalPath,
|
||||||
Icono: "💬",
|
Icono: "💬",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -119,8 +130,11 @@ func DispatchTicketRespuestaAdmin(ticket *models.ProyectoTicket, contenido strin
|
|||||||
}
|
}
|
||||||
if cfg.CanalTelegram && portalUser.TelegramChatID != "" {
|
if cfg.CanalTelegram && portalUser.TelegramChatID != "" {
|
||||||
ts := NewTelegramService()
|
ts := NewTelegramService()
|
||||||
msg := fmt.Sprintf("💬 <b>El equipo respondió tu ticket</b>\nProyecto: <b>%s</b>\nTicket: <b>%s</b>\n\n%s\n\n🔗 <a href=\"%s\">Ver tu portal</a>",
|
msg := fmt.Sprintf("💬 <b>El equipo respondió tu ticket</b>\nProyecto: <b>%s</b>\nTicket: <b>%s</b>\n\n%s\n\n🔗 %s",
|
||||||
proyectoNombre, ticket.Titulo, contenido, portalURL)
|
escapeTelegramHTML(proyectoNombre),
|
||||||
|
escapeTelegramHTML(ticket.Titulo),
|
||||||
|
escapeTelegramHTML(contenido),
|
||||||
|
telegramHTMLLink(portalURL, "Ver en el portal"))
|
||||||
if err := ts.SendMessageWithToken(portalUser.TelegramChatID, msg, getAdminBotToken()); err != nil {
|
if err := ts.SendMessageWithToken(portalUser.TelegramChatID, msg, getAdminBotToken()); err != nil {
|
||||||
log.Printf("[Notif] Error telegram portal_user %d: %v", portalUser.ID, err)
|
log.Printf("[Notif] Error telegram portal_user %d: %v", portalUser.ID, err)
|
||||||
}
|
}
|
||||||
@@ -147,12 +161,11 @@ func DispatchFacturaSubida(factura *models.Factura) {
|
|||||||
clienteNombre = factura.Cliente.Nombre
|
clienteNombre = factura.Cliente.Nombre
|
||||||
}
|
}
|
||||||
|
|
||||||
baseURL := getAppURL()
|
portalPath := "/portal/dashboard"
|
||||||
// Construir URL apuntando a la pestaña Facturas del proyecto (o dashboard si no tiene proyecto)
|
|
||||||
portalURL := baseURL + "/portal/dashboard"
|
|
||||||
if factura.ProyectoID != nil && factura.Proyecto != nil && factura.Proyecto.Slug != "" {
|
if factura.ProyectoID != nil && factura.Proyecto != nil && factura.Proyecto.Slug != "" {
|
||||||
portalURL = baseURL + "/portal/proyecto/" + factura.Proyecto.Slug + "?tab=Facturas"
|
portalPath = fmt.Sprintf("/portal/proyecto/%s?tab=Facturas", url.PathEscape(factura.Proyecto.Slug))
|
||||||
}
|
}
|
||||||
|
portalURL := absAppURL(portalPath)
|
||||||
|
|
||||||
for _, u := range portalUsers {
|
for _, u := range portalUsers {
|
||||||
u := u
|
u := u
|
||||||
@@ -165,7 +178,7 @@ func DispatchFacturaSubida(factura *models.Factura) {
|
|||||||
UsuarioID: u.ID,
|
UsuarioID: u.ID,
|
||||||
Titulo: titulo,
|
Titulo: titulo,
|
||||||
Cuerpo: cuerpo,
|
Cuerpo: cuerpo,
|
||||||
Url: portalURL,
|
Url: portalPath,
|
||||||
Icono: "🧾",
|
Icono: "🧾",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -174,8 +187,11 @@ func DispatchFacturaSubida(factura *models.Factura) {
|
|||||||
}
|
}
|
||||||
if cfg.CanalTelegram && u.TelegramChatID != "" {
|
if cfg.CanalTelegram && u.TelegramChatID != "" {
|
||||||
ts := NewTelegramService()
|
ts := NewTelegramService()
|
||||||
msg := fmt.Sprintf("🧾 <b>Nueva factura disponible</b>\nNúmero: <b>%s</b>\nMonto: %s %.2f\n\n🔗 <a href=\"%s\">Ver en el portal</a>",
|
msg := fmt.Sprintf("🧾 <b>Nueva factura disponible</b>\nNúmero: <b>%s</b>\nMonto: %s %.2f\n\n🔗 %s",
|
||||||
factura.Numero, factura.Moneda, factura.Monto, portalURL)
|
escapeTelegramHTML(factura.Numero),
|
||||||
|
escapeTelegramHTML(factura.Moneda),
|
||||||
|
factura.Monto,
|
||||||
|
telegramHTMLLink(portalURL, "Ver en el portal"))
|
||||||
if err := ts.SendMessageWithToken(u.TelegramChatID, msg, getAdminBotToken()); err != nil {
|
if err := ts.SendMessageWithToken(u.TelegramChatID, msg, getAdminBotToken()); err != nil {
|
||||||
log.Printf("[Notif] Error telegram portal_user %d: %v", u.ID, err)
|
log.Printf("[Notif] Error telegram portal_user %d: %v", u.ID, err)
|
||||||
}
|
}
|
||||||
@@ -233,13 +249,3 @@ func sendTelegramAdmin(mensaje string) {
|
|||||||
_ = models.CreateTelegramLog(logEntry)
|
_ = models.CreateTelegramLog(logEntry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getAppURL devuelve la URL base configurada en APP_URL (sin slash final).
|
|
||||||
func getAppURL() string {
|
|
||||||
u := app.Http.Server.Url
|
|
||||||
// quitar slash final si lo hay
|
|
||||||
if len(u) > 0 && u[len(u)-1] == '/' {
|
|
||||||
u = u[:len(u)-1]
|
|
||||||
}
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -166,7 +166,7 @@
|
|||||||
<!-- Lista de tickets -->
|
<!-- Lista de tickets -->
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<template x-for="t in tickets" :key="t.ID">
|
<template x-for="t in tickets" :key="t.ID">
|
||||||
<div class="bg-white rounded-xl border overflow-hidden" :class="t._noLeidos > 0 ? 'border-[#8eb02f]' : 'border-slate-200'">
|
<div :id="'portal-ticket-' + t.ID" class="bg-white rounded-xl border overflow-hidden" :class="t._noLeidos > 0 ? 'border-[#8eb02f]' : 'border-slate-200'">
|
||||||
<div class="p-4 flex items-start justify-between cursor-pointer" @click="abrirTicket(t)">
|
<div class="p-4 flex items-start justify-between cursor-pointer" @click="abrirTicket(t)">
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center gap-2 mb-1">
|
<div class="flex items-center gap-2 mb-1">
|
||||||
@@ -261,12 +261,22 @@ function portalProyecto() {
|
|||||||
facturasNoLeidas: 0,
|
facturasNoLeidas: 0,
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
// Soporte de URL param ?tab=Facturas
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const tabParam = params.get('tab');
|
const tabParam = params.get('tab');
|
||||||
if (tabParam) this.activeTab = tabParam;
|
if (tabParam) this.activeTab = tabParam;
|
||||||
await this.loadTickets();
|
await this.loadTickets();
|
||||||
// Si la tab activa es Facturas, marcar como leídas automáticamente
|
const ticketId = params.get('ticket');
|
||||||
|
if (ticketId) {
|
||||||
|
this.activeTab = 'Tickets';
|
||||||
|
const t = this.tickets.find(x => String(x.ID) === String(ticketId));
|
||||||
|
if (t) {
|
||||||
|
t._open = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const el = document.getElementById('portal-ticket-' + t.ID);
|
||||||
|
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this.activeTab === 'Facturas') {
|
if (this.activeTab === 'Facturas') {
|
||||||
this.marcarFacturasLeidas();
|
this.marcarFacturasLeidas();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<!-- Lista -->
|
<!-- Lista -->
|
||||||
<div x-show="!loading" class="space-y-3">
|
<div x-show="!loading" class="space-y-3">
|
||||||
<template x-for="t in tickets" :key="t.ID">
|
<template x-for="t in tickets" :key="t.ID">
|
||||||
<div class="bg-white border border-slate-200 rounded-xl overflow-hidden shadow-sm">
|
<div :id="'ticket-' + t.ID" class="bg-white border border-slate-200 rounded-xl overflow-hidden shadow-sm">
|
||||||
<!-- Cabecera del ticket -->
|
<!-- Cabecera del ticket -->
|
||||||
<div class="p-4 flex items-start gap-4 cursor-pointer" @click="t._open = !t._open">
|
<div class="p-4 flex items-start gap-4 cursor-pointer" @click="t._open = !t._open">
|
||||||
<!-- Indicador de estado -->
|
<!-- Indicador de estado -->
|
||||||
@@ -124,7 +124,12 @@ function ticketsAdmin() {
|
|||||||
{ val: 'cerrado', label: 'Cerrados' },
|
{ val: 'cerrado', label: 'Cerrados' },
|
||||||
],
|
],
|
||||||
|
|
||||||
async init() { await this.load(); },
|
async init() {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
if (params.get('ticket')) this.filtro = 'todos';
|
||||||
|
await this.load();
|
||||||
|
this.openTicketFromQuery();
|
||||||
|
},
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -136,6 +141,18 @@ function ticketsAdmin() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
openTicketFromQuery() {
|
||||||
|
const ticketId = new URLSearchParams(window.location.search).get('ticket');
|
||||||
|
if (!ticketId) return;
|
||||||
|
const t = this.tickets.find(x => String(x.ID) === String(ticketId));
|
||||||
|
if (!t) return;
|
||||||
|
t._open = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const el = document.getElementById('ticket-' + t.ID);
|
||||||
|
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
async cambiarEstado(t, estado) {
|
async cambiarEstado(t, estado) {
|
||||||
await axios.put(`/app/tickets/${t.ID}/estado`, { estado });
|
await axios.put(`/app/tickets/${t.ID}/estado`, { estado });
|
||||||
t.estado = estado;
|
t.estado = estado;
|
||||||
|
|||||||
Reference in New Issue
Block a user