mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Get full workspace object
This commit is contained in:
@@ -77,7 +77,7 @@ func GetWorkspace(db *db.DB) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
respondJSON(w, map[string]string{"name": workspace.Name})
|
||||
respondJSON(w, workspace)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ func (db *DB) CreateWorkspace(workspace *models.Workspace) error {
|
||||
|
||||
func (db *DB) GetWorkspaceByID(id int) (*models.Workspace, error) {
|
||||
workspace := &models.Workspace{}
|
||||
err := db.QueryRow("SELECT id, user_id, name, root_path, created_at FROM workspaces WHERE id = ?", id).
|
||||
err := db.QueryRow("SELECT id, user_id, name, created_at FROM workspaces WHERE id = ?", id).
|
||||
Scan(&workspace.ID, &workspace.UserID, &workspace.Name, &workspace.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -29,7 +29,7 @@ func (db *DB) GetWorkspaceByID(id int) (*models.Workspace, error) {
|
||||
}
|
||||
|
||||
func (db *DB) GetWorkspacesByUserID(userID int) ([]*models.Workspace, error) {
|
||||
rows, err := db.Query("SELECT id, user_id, name, root_path, created_at FROM workspaces WHERE user_id = ?", userID)
|
||||
rows, err := db.Query("SELECT id, user_id, name, created_at FROM workspaces WHERE user_id = ?", userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const apiCall = async (url, options = {}) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchLastWorkspace = async () => {
|
||||
export const fetchLastWorkspaceId = async () => {
|
||||
const response = await apiCall(`${API_BASE_URL}/users/1/workspaces/last`);
|
||||
return response.json();
|
||||
};
|
||||
@@ -59,6 +59,13 @@ export const deleteFile = async (workspaceId, filePath) => {
|
||||
return response.text();
|
||||
};
|
||||
|
||||
export const getWorkspace = async (workspaceId) => {
|
||||
const response = await apiCall(
|
||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}`
|
||||
);
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const fetchWorkspaceSettings = async (workspaceId) => {
|
||||
const response = await apiCall(
|
||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/settings`
|
||||
|
||||
Reference in New Issue
Block a user