mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 04:22:58 +00:00
Add files via upload
This commit is contained in:
+38
-15
@@ -72,7 +72,7 @@
|
||||
</div>
|
||||
<h2 class="text-xl font-bold text-gray-800 mb-2">OSTicket</h2>
|
||||
<p class="text-gray-600 mb-4">Systém technické podpory a hlášení problémů</p>
|
||||
<a href="#" class="block text-center bg-orange-600 hover:bg-orange-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
<a href="http://osticket/" class="block text-center bg-orange-600 hover:bg-orange-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
Otevřít aplikaci
|
||||
</a>
|
||||
</div>
|
||||
@@ -82,9 +82,9 @@
|
||||
<div class="rounded-full w-14 h-14 flex items-center justify-center bg-purple-100 text-purple-600 mb-4">
|
||||
<i class="fas fa-tasks text-2xl"></i>
|
||||
</div>
|
||||
<h2 class="text-xl font-bold text-gray-800 mb-2">Canboard úkolníček</h2>
|
||||
<h2 class="text-xl font-bold text-gray-800 mb-2">Kanboard úkolníček</h2>
|
||||
<p class="text-gray-600 mb-4">Správa úkolů a projektů v přehledném kanban stylu</p>
|
||||
<a href="#" class="block text-center bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
<a href="http://kanboard/" class="block text-center bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
|
||||
Otevřít aplikaci
|
||||
</a>
|
||||
</div>
|
||||
@@ -185,20 +185,43 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Function to open Windows Explorer with a specific path
|
||||
// Function to open Windows folders via Go server
|
||||
function openWindowsFolder(path) {
|
||||
// Using ActiveX to open Windows Explorer (works in IE)
|
||||
try {
|
||||
const shell = new ActiveXObject("Shell.Application");
|
||||
shell.Explore(path);
|
||||
return;
|
||||
} catch (e) {
|
||||
console.log("ActiveX not supported or disabled");
|
||||
}
|
||||
// Show loading indicator or disable button
|
||||
const allButtons = document.querySelectorAll('button');
|
||||
allButtons.forEach(button => {
|
||||
if (button.innerHTML.includes('Otevřít složku')) {
|
||||
button.disabled = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Fallback to file:// protocol
|
||||
const encodedPath = path.split('\\').map(part => encodeURIComponent(part)).join('/');
|
||||
window.open('file:///' + encodedPath, '_blank');
|
||||
// Make API call to our Go endpoint
|
||||
fetch('/open-folder', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ path: path })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
console.error('Chyba při otevírání složky:', data.error);
|
||||
alert('Chyba při otevírání složky: ' + data.error);
|
||||
} else {
|
||||
console.log('Složka úspěšně otevřena');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Chyba při komunikaci se serverem:', error);
|
||||
alert('Chyba při komunikaci se serverem. Zkuste to prosím později.');
|
||||
})
|
||||
.finally(() => {
|
||||
// Re-enable buttons
|
||||
allButtons.forEach(button => {
|
||||
button.disabled = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -50,6 +51,8 @@ func main() {
|
||||
http.ServeFile(w, r, "evidence-aut.html")
|
||||
}))
|
||||
|
||||
http.HandleFunc("/open-folder", enableCORS(handleOpenFolder))
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
@@ -156,6 +159,66 @@ func handleSubmit(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(`{"message":"Záznam byl úspěšně uložen a email odeslán"}`))
|
||||
}
|
||||
|
||||
// handleOpenFolder opens a Windows Explorer window to the specified folder path
|
||||
func handleOpenFolder(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
// Only allow POST requests
|
||||
if r.Method != http.MethodPost {
|
||||
if r.Method == http.MethodOptions {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
json.NewEncoder(w).Encode(map[string]string{"error": "Only POST method is allowed"})
|
||||
return
|
||||
}
|
||||
|
||||
// Parse the request body
|
||||
type FolderRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
var req FolderRequest
|
||||
err := json.NewDecoder(r.Body).Decode(&req)
|
||||
if err != nil {
|
||||
log.Printf("Chyba při čtení těla požadavku: %v", err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(map[string]string{"error": "Failed to parse request body"})
|
||||
return
|
||||
}
|
||||
|
||||
// Validate the folder path
|
||||
if req.Path == "" {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(map[string]string{"error": "Path is required"})
|
||||
return
|
||||
}
|
||||
|
||||
// Sanitize the path (basic security - you might want to add more validation)
|
||||
// Ensure it's a valid Windows network path
|
||||
if !strings.HasPrefix(req.Path, "M:\\") {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(map[string]string{"error": "Only network paths on M: drive are allowed"})
|
||||
return
|
||||
}
|
||||
|
||||
// Construct the command to open Windows Explorer
|
||||
cmd := exec.Command("explorer.exe", req.Path)
|
||||
|
||||
// Run the command
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
log.Printf("Chyba při spouštění explorer.exe: %v", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
json.NewEncoder(w).Encode(map[string]string{"error": fmt.Sprintf("Failed to open folder: %v", err)})
|
||||
return
|
||||
}
|
||||
|
||||
// Send a success response
|
||||
json.NewEncoder(w).Encode(map[string]string{"status": "success", "message": "Folder opened successfully"})
|
||||
}
|
||||
|
||||
func sendEmail(entry TripEntry, parsedDateStart, parsedDateEnd time.Time, czechMonths []string) error {
|
||||
smtpHost := "mail.pp-kunovice.cz"
|
||||
smtpPort := 465
|
||||
|
||||
Reference in New Issue
Block a user