Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9dc6c217fa | ||
|
|
c4bd121388 | ||
|
|
e26c2af201 | ||
|
|
093c55616c |
@@ -4,8 +4,10 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gitea.tecamino.com/paadi/access-handler/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -151,9 +153,12 @@ func (aH *AccessHandler) DeleteWorkspace(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
for _, u := range users {
|
||||
if u.Settings.Workspace == workspace.Name {
|
||||
u.Settings.Workspace = ""
|
||||
if u.Workspaces == nil {
|
||||
continue
|
||||
} else if u.Settings.Workspace.Name == workspace.Name {
|
||||
u.Settings.Workspace = nil
|
||||
}
|
||||
|
||||
u.Workspaces = slices.DeleteFunc(u.Workspaces, func(w *models.Workspace) bool {
|
||||
@@ -161,16 +166,54 @@ func (aH *AccessHandler) DeleteWorkspace(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// crearemove folder
|
||||
// remove folder
|
||||
err = os.RemoveAll(workspace.Uuid.String())
|
||||
if err != nil {
|
||||
aH.logger.Error("DeleteWorkspace", err)
|
||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "workspace(s) deleted",
|
||||
})
|
||||
}
|
||||
|
||||
func (aH *AccessHandler) ReadWorkspaceData(c *gin.Context) {
|
||||
|
||||
var workspace models.Workspace
|
||||
|
||||
err := c.ShouldBindBodyWithJSON(&workspace)
|
||||
if err != nil {
|
||||
aH.logger.Error("ReadWorkspaceData", err)
|
||||
c.JSON(http.StatusBadRequest, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if workspace.Uuid == uuid.Nil {
|
||||
aH.logger.Error("ReadWorkspaceData", "uuid nil")
|
||||
c.JSON(http.StatusBadRequest, nil)
|
||||
return
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(workspace.Uuid.String())
|
||||
if err != nil {
|
||||
aH.logger.Error("ReadWorkspaceData", err)
|
||||
c.JSON(http.StatusBadRequest, nil)
|
||||
return
|
||||
}
|
||||
|
||||
var response []string
|
||||
for _, f := range files {
|
||||
if f.IsDir() || !strings.Contains(filepath.Ext(f.Name()), ".db") {
|
||||
continue
|
||||
}
|
||||
response = append(response, f.Name())
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": response,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ type Settings struct {
|
||||
AppName string `json:"appName,omitempty"`
|
||||
DatabaseName string `json:"databaseName,omitempty"`
|
||||
DatabaseToken string `json:"databaseToken,omitempty"`
|
||||
Workspace string `json:"workspace,omitempty"`
|
||||
Workspace *Workspace `json:"workspace,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Settings) DefaultQuasarSettings() {
|
||||
|
||||
Reference in New Issue
Block a user