diff --git a/cmd/client/main.go b/cmd/client/main.go index fc8c493..81cbc0a 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -13,6 +13,7 @@ func main() { http.HandleFunc("/dashboard", handlers.AuthMiddleware(handlers.DashboardHandler)) + http.HandleFunc("/upload", handlers.AuthMiddleware(handlers.UploadHandler)) // Запуск сервера log.Println("Клиент запущен на :8080") log.Fatal(http.ListenAndServe(":8080", nil)) diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..4757d6d --- /dev/null +++ b/config/config.go @@ -0,0 +1,22 @@ +package config + +import ( + "log" + "os" +) + +var ( + // PocketBaseURL URL сервера PocketBase + PocketBaseURL string +) + +func init() { + // Получаем URL из переменной окружения или используем значение по умолчанию + PocketBaseURL = os.Getenv("POCKETBASE_URL") + if PocketBaseURL == "" { + PocketBaseURL = "http://localhost:8090" + log.Printf("POCKETBASE_URL не установлен, используем значение по умолчанию: %s", PocketBaseURL) + } else { + log.Printf("Используем POCKETBASE_URL из переменной окружения: %s", PocketBaseURL) + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 7005d83..72241d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ - services: server: build: @@ -14,3 +13,5 @@ services: - server ports: - "8080:8080" # Укажите порт клиента + environment: + - POCKETBASE_URL=http://server:8090 diff --git a/handlers/dashboard.go b/handlers/dashboard.go index f9362f7..17db275 100644 --- a/handlers/dashboard.go +++ b/handlers/dashboard.go @@ -2,13 +2,15 @@ package handlers import ( "encoding/json" + "fmt" "io" "log" "net/http" + "pocketbaseSigner/config" "pocketbaseSigner/models" + "time" ) - func DashboardHandler(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Метод не поддерживается", http.StatusMethodNotAllowed) @@ -31,7 +33,7 @@ func DashboardHandler(w http.ResponseWriter, r *http.Request) { } // Получаем данные пользователя - url := "http://localhost:8090/api/collections/users/records/" + userIdCookie.Value + url := config.PocketBaseURL + "/api/collections/users/records/" + userIdCookie.Value req, err := http.NewRequest("GET", url, nil) if err != nil { log.Printf("Ошибка при создании запроса: %v", err) @@ -87,7 +89,7 @@ func DashboardHandler(w http.ResponseWriter, r *http.Request) { padding: 20px; } .container { - max-width: 800px; + max-width: 1200px; margin: 0 auto; background: white; padding: 20px; @@ -114,6 +116,87 @@ func DashboardHandler(w http.ResponseWriter, r *http.Request) { .logout-btn:hover { background: #c82333; } + .files-section { + margin-top: 30px; + } + .files-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + gap: 20px; + margin-top: 20px; + } + .file-card { + background: #f8f9fa; + border: 1px solid #dee2e6; + border-radius: 8px; + padding: 15px; + cursor: pointer; + transition: transform 0.2s; + } + .file-card:hover { + transform: translateY(-5px); + box-shadow: 0 4px 8px rgba(0,0,0,0.1); + } + .file-name { + font-weight: bold; + margin-bottom: 10px; + word-break: break-word; + } + .file-date { + color: #6c757d; + font-size: 0.9em; + } + .pdf-viewer { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0,0,0,0.8); + display: none; + z-index: 1000; + } + .pdf-viewer iframe { + width: 90%; + height: 90%; + margin: 2% auto; + display: block; + background: white; + border: none; + border-radius: 8px; + } + .close-viewer { + position: absolute; + top: 20px; + right: 20px; + background: white; + border: none; + border-radius: 50%; + width: 40px; + height: 40px; + font-size: 20px; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + } + .upload-section { + margin-top: 20px; + padding: 20px; + background: #f8f9fa; + border-radius: 8px; + } + .upload-btn { + background: #28a745; + color: white; + border: none; + padding: 10px 20px; + border-radius: 4px; + cursor: pointer; + } + .upload-btn:hover { + background: #218838; + }
@@ -130,17 +213,124 @@ func DashboardHandler(w http.ResponseWriter, r *http.Request) {Имя: ` + userData.FirstName + `
Фамилия: ` + userData.LastName + `
Телефон: ` + userData.Phone + `
-Дата регистрации: ` + userData.Created + `
-Последнее обновление: ` + userData.Updated + `
-Статус верификации: ` + formatVerified(userData.Verified) + `
+ + +