mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-11-19 10:53:32 +01:00
feat: Implement comprehensive log viewer with advanced features
- Add new log viewer component in admin tools - Support dynamic log file browsing and content display - Implement custom scrollbar for log content - Add log file refresh, download, and view capabilities - Update environment variables for log configuration - Enhance logging system with more flexible configuration options
This commit is contained in:
1 parent
ed81b2c9be
commit
a8b4588ecb
15 files changed
+634
-761
No files matched your search
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/starfleetcptn/gomft/internal/db"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@@ -55,7 +54,7 @@ func (h *Handlers) HandleAPILogin(c *gin.Context) {
|
||||
// HandleAPIConfigs handles the GET /api/configs route
|
||||
func (h *Handlers) HandleAPIConfigs(c *gin.Context) {
|
||||
userID := c.GetUint("userID")
|
||||
|
||||
|
||||
var configs []db.TransferConfig
|
||||
h.DB.Where("created_by = ?", userID).Find(&configs)
|
||||
|
||||
@@ -66,7 +65,7 @@ func (h *Handlers) HandleAPIConfigs(c *gin.Context) {
|
||||
func (h *Handlers) HandleAPIConfig(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
userID := c.GetUint("userID")
|
||||
|
||||
|
||||
var config db.TransferConfig
|
||||
if err := h.DB.First(&config, id).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Config not found"})
|
||||
@@ -109,7 +108,7 @@ func (h *Handlers) HandleAPICreateConfig(c *gin.Context) {
|
||||
func (h *Handlers) HandleAPIUpdateConfig(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
userID := c.GetUint("userID")
|
||||
|
||||
|
||||
var config db.TransferConfig
|
||||
if err := h.DB.First(&config, id).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Config not found"})
|
||||
@@ -150,7 +149,7 @@ func (h *Handlers) HandleAPIUpdateConfig(c *gin.Context) {
|
||||
func (h *Handlers) HandleAPIDeleteConfig(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
userID := c.GetUint("userID")
|
||||
|
||||
|
||||
var config db.TransferConfig
|
||||
if err := h.DB.First(&config, id).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Config not found"})
|
||||
@@ -184,38 +183,6 @@ func (h *Handlers) HandleAPIDeleteConfig(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Config deleted successfully"})
|
||||
}
|
||||
|
||||
// HandleAPITestConnection handles the POST /api/configs/test route
|
||||
func (h *Handlers) HandleAPITestConnection(c *gin.Context) {
|
||||
var config db.TransferConfig
|
||||
if err := c.ShouldBindJSON(&config); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("Invalid request data: %v", err)})
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Implement connection testing based on protocol
|
||||
// This is a placeholder for the actual connection testing logic
|
||||
success := true
|
||||
message := "Connection successful"
|
||||
|
||||
// Example of how connection testing might work
|
||||
switch config.SourceType {
|
||||
case "sftp":
|
||||
// Test SFTP connection
|
||||
// success, message = testSFTPConnection(config)
|
||||
case "ftp":
|
||||
// Test FTP connection
|
||||
// success, message = testFTPConnection(config)
|
||||
default:
|
||||
success = false
|
||||
message = "Unsupported source type"
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": success,
|
||||
"message": message,
|
||||
})
|
||||
}
|
||||
|
||||
// HandleAPIJobs handles the API jobs request
|
||||
func (h *Handlers) HandleAPIJobs(c *gin.Context) {
|
||||
// Implementation will be moved from the old handlers.go
|
||||
@@ -250,7 +217,7 @@ func (h *Handlers) HandleAPIDeleteJob(c *gin.Context) {
|
||||
func (h *Handlers) HandleAPIRunJob(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
userID := c.GetUint("userID")
|
||||
|
||||
|
||||
var job db.Job
|
||||
if err := h.DB.First(&job, id).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Job not found"})
|
||||
@@ -284,7 +251,7 @@ func (h *Handlers) HandleAPIRunJob(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to run job: " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "Job started successfully",
|
||||
"jobId": job.ID,
|
||||
|
||||
Reference in new issue
Block a user