mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 12:32:59 +00:00
s
This commit is contained in:
+4
-4
@@ -374,7 +374,7 @@
|
|||||||
<a href="http://ppc-app/pwkweb2/" class="hover:text-brand-light-blue">Obědy</a>
|
<a href="http://ppc-app/pwkweb2/" class="hover:text-brand-light-blue">Obědy</a>
|
||||||
<a href="http://osticket/" class="hover:text-brand-light-blue">OSticket</a>
|
<a href="http://osticket/" class="hover:text-brand-light-blue">OSticket</a>
|
||||||
<a href="http://kanboard/" class="hover:text-brand-light-blue">Kanboard</a>
|
<a href="http://kanboard/" class="hover:text-brand-light-blue">Kanboard</a>
|
||||||
<a href="http://webportal/kontakt" class="hover:text-brand-light-blue">Kontakt</a>
|
<a href="http://webportal:8080" class="hover:text-brand-light-blue">Kontakt</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@
|
|||||||
<a href="http://ppc-app/pwkweb2/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Obědy</a>
|
<a href="http://ppc-app/pwkweb2/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Obědy</a>
|
||||||
<a href="http://osticket/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">OSticket</a>
|
<a href="http://osticket/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">OSticket</a>
|
||||||
<a href="http://kanboard/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Kanboard</a>
|
<a href="http://kanboard/" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Kanboard</a>
|
||||||
<a href="webportal/kontakt" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Kontakt</a>
|
<a href="webportal:8080" class="block px-3 py-2 rounded-md text-base font-medium hover:text-brand-light-blue">Kontakt</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@
|
|||||||
<p class="text-xs text-gray-500">Firemní kontakty a důležitá čísla</p>
|
<p class="text-xs text-gray-500">Firemní kontakty a důležitá čísla</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a href="http://webportal/kontakt" class="text-sm text-blue-600 hover:text-blue-800 hover:underline">
|
<a href="http://webportal:8080" class="text-sm text-blue-600 hover:text-blue-800 hover:underline">
|
||||||
Otevřít
|
Otevřít
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -484,7 +484,7 @@
|
|||||||
<li><a href="http://webportal/evidence-aut" class="hover:text-white">Evidence aut</a></li>
|
<li><a href="http://webportal/evidence-aut" class="hover:text-white">Evidence aut</a></li>
|
||||||
<li><a href="http://ppc-app/pwkweb2/" class="hover:text-white">Objednávka obědů</a></li>
|
<li><a href="http://ppc-app/pwkweb2/" class="hover:text-white">Objednávka obědů</a></li>
|
||||||
<li><a href="http://osticket/" class="hover:text-white">Technická podpora</a></li>
|
<li><a href="http://osticket/" class="hover:text-white">Technická podpora</a></li>
|
||||||
<li><a href="http://webportal/kontakt" class="hover:text-white">Kontakty</a></li>
|
<li><a href="http://webportal:8080" class="hover:text-white">Kontakty</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -188,54 +188,85 @@ func enableCORS(next http.Handler) http.Handler {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In-memory store for apps (in a real app, use a database)
|
||||||
|
var appsStore = make(map[string]App)
|
||||||
|
var lastAppID = 0
|
||||||
|
|
||||||
// App Handlers
|
// App Handlers
|
||||||
func GetAppsHandler(w http.ResponseWriter, r *http.Request) {
|
func GetAppsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// In a real app, this would fetch from a database
|
// Convert map to slice
|
||||||
apps := []App{
|
appsList := make([]App, 0, len(appsStore))
|
||||||
{
|
for _, app := range appsStore {
|
||||||
ID: "1",
|
appsList = append(appsList, app)
|
||||||
Name: "Kontakt",
|
}
|
||||||
URL: "/kontakt",
|
|
||||||
Description: "Kontaktní formulář",
|
// If no apps, return empty array instead of null
|
||||||
Icon: "",
|
if appsList == nil {
|
||||||
CreatedAt: time.Now().Format(time.RFC3339),
|
appsList = []App{}
|
||||||
UpdatedAt: time.Now().Format(time.RFC3339),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(apps)
|
json.NewEncoder(w).Encode(appsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAppHandler(w http.ResponseWriter, r *http.Request) {
|
func GetAppHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
id := vars["id"]
|
id := vars["id"]
|
||||||
|
|
||||||
// In a real app, this would fetch from a database
|
app, exists := appsStore[id]
|
||||||
if id != "1" {
|
if !exists {
|
||||||
http.Error(w, "App not found", http.StatusNotFound)
|
http.Error(w, "App not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app := App{
|
|
||||||
ID: id,
|
|
||||||
Name: "Kontakt",
|
|
||||||
URL: "/kontakt",
|
|
||||||
Description: "Kontaktní formulář",
|
|
||||||
Icon: "",
|
|
||||||
CreatedAt: time.Now().Format(time.RFC3339),
|
|
||||||
UpdatedAt: time.Now().Format(time.RFC3339),
|
|
||||||
}
|
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(app)
|
json.NewEncoder(w).Encode(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func generateUniqueID() string {
|
||||||
|
lastAppID++
|
||||||
|
return fmt.Sprintf("%d", lastAppID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleFileUpload(r *http.Request, fieldName string) (string, error) {
|
||||||
|
file, handler, err := r.FormFile(fieldName)
|
||||||
|
if err != nil {
|
||||||
|
// No file was uploaded
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
// Create uploads directory if it doesn't exist
|
||||||
|
if err := os.MkdirAll("uploads", 0755); err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create uploads directory: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate a unique filename
|
||||||
|
ext := filepath.Ext(handler.Filename)
|
||||||
|
filename := fmt.Sprintf("%d%s", time.Now().UnixNano(), ext)
|
||||||
|
filepath := filepath.Join("uploads", filename)
|
||||||
|
|
||||||
|
// Create the file
|
||||||
|
out, err := os.Create(filepath)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create file: %v", err)
|
||||||
|
}
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
// Copy the file content
|
||||||
|
_, err = io.Copy(out, file)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to save file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename, nil
|
||||||
|
}
|
||||||
|
|
||||||
func CreateAppHandler(w http.ResponseWriter, r *http.Request) {
|
func CreateAppHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// Parse form data
|
// Parse form data
|
||||||
err := r.ParseMultipartForm(10 << 20) // 10 MB max file size
|
err := r.ParseMultipartForm(10 << 20) // 10 MB max file size
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Error parsing form data", http.StatusBadRequest)
|
http.Error(w, "Error parsing form data: "+err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,6 +275,44 @@ func CreateAppHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
url := r.FormValue("url")
|
url := r.FormValue("url")
|
||||||
description := r.FormValue("description")
|
description := r.FormValue("description")
|
||||||
|
|
||||||
|
// Validate required fields
|
||||||
|
if name == "" || url == "" {
|
||||||
|
http.Error(w, "Name and URL are required", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle file upload
|
||||||
|
icon, err := handleFileUpload(r, "icon")
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Error uploading icon: "+err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new app
|
||||||
|
now := time.Now().Format(time.RFC3339)
|
||||||
|
app := App{
|
||||||
|
ID: generateUniqueID(),
|
||||||
|
Name: name,
|
||||||
|
URL: url,
|
||||||
|
Description: description,
|
||||||
|
Icon: icon,
|
||||||
|
CreatedAt: now,
|
||||||
|
UpdatedAt: now,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save to in-memory store
|
||||||
|
appsStore[app.ID] = app
|
||||||
|
|
||||||
|
// Return the created app
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.WriteHeader(http.StatusCreated)
|
||||||
|
json.NewEncoder(w).Encode(app)
|
||||||
|
|
||||||
|
// Get form values
|
||||||
|
name := r.FormValue("name")
|
||||||
|
url := r.FormValue("url")
|
||||||
|
description := r.FormValue("description")
|
||||||
|
|
||||||
// Handle file upload
|
// Handle file upload
|
||||||
var iconPath string
|
var iconPath string
|
||||||
file, handler, err := r.FormFile("icon")
|
file, handler, err := r.FormFile("icon")
|
||||||
|
|||||||
Reference in New Issue
Block a user