diff --git a/admin-dashboard.html b/admin-dashboard.html
index 45f2e52..335032d 100644
--- a/admin-dashboard.html
+++ b/admin-dashboard.html
@@ -2284,6 +2284,10 @@ function setupFileInput() {
// Reset form when modal is closed
// Initialize icon picker when the modal is shown
document.getElementById('appModal').addEventListener('show.bs.modal', function () {
+ // Initialize file input
+ setupFileInput();
+
+ // Initialize icon picker
initIconPicker();
// Set focus to search input when dropdown is shown
@@ -2601,6 +2605,57 @@ async function deleteApp(appId) {
}
}
+// Save app function
+async function saveApp(event) {
+ event.preventDefault();
+
+ // Get form data
+ const formData = new FormData(document.getElementById('appForm'));
+
+ // Add icon class to form data
+ const iconClass = document.getElementById('appIcon').value;
+ if (iconClass) {
+ formData.append('iconClass', iconClass);
+ }
+
+ // Add icon file if selected
+ const iconFile = document.getElementById('customIconInput').files[0];
+ if (iconFile) {
+ formData.append('icon', iconFile);
+ }
+
+ // Get app ID
+ const appId = document.getElementById('appId').value;
+
+ // Create request URL
+ const url = appId ? `/api/apps/${appId}` : '/api/apps';
+
+ // Set request method
+ const method = appId ? 'PUT' : 'POST';
+
+ // Send request
+ fetch(url, {
+ method: method,
+ body: formData,
+ credentials: 'include'
+ })
+ .then(response => {
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+ return response.json();
+ })
+ .then(data => {
+ showNotification('Aplikace byla úspěšně uložena', 'success');
+ loadApps();
+ closeAppModal();
+ })
+ .catch(error => {
+ console.error('Error:', error);
+ showNotification('Chyba při ukládání aplikace', 'error');
+ });
+}
+
// Logout functionality
document.getElementById('logoutBtn').addEventListener('click', function() {
localStorage.removeItem('token');
diff --git a/main.go b/main.go
index 1c906b9..4b2bf1d 100644
--- a/main.go
+++ b/main.go
@@ -24,7 +24,8 @@ type App struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description,omitempty"`
- Icon string `json:"icon,omitempty"`
+ Icon string `json:"icon,omitempty"` // For file uploads
+ IconClass string `json:"iconClass,omitempty"` // For Font Awesome icons
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
@@ -459,6 +460,9 @@ func CreateAppHandler(w http.ResponseWriter, r *http.Request) {
return
}
+ // Get icon class if provided
+ iconClass := r.FormValue("iconClass")
+
// Create a new app
app := App{
ID: fmt.Sprintf("%d", time.Now().UnixNano()),
@@ -466,6 +470,7 @@ func CreateAppHandler(w http.ResponseWriter, r *http.Request) {
URL: strings.TrimSpace(url),
Description: strings.TrimSpace(description),
Icon: iconPath,
+ IconClass: iconClass,
CreatedAt: time.Now().Format(time.RFC3339),
UpdatedAt: time.Now().Format(time.RFC3339),
}