Add files via upload

This commit is contained in:
Tomáš Dvořák
2025-05-23 09:54:55 +02:00
committed by GitHub
parent a2fec20eb2
commit 511bbccfe6
+9 -4
View File
@@ -20,6 +20,7 @@ type Contact struct {
Position string `json:"position"`
Phone string `json:"phone,omitempty"`
ServicePhone string `json:"service_phone,omitempty"`
Internal bool `json:"internal"`
}
type ContactData struct {
@@ -132,7 +133,7 @@ func loadData() {
log.Printf("Warning: Could not save cached data: %v", err)
}
log.Printf("Loaded %d contacts from Excel file", len(currentData.Contacts) + len(currentData.InternalContacts))
log.Printf("Loaded %d contacts from Excel file", len(currentData.Contacts)+len(currentData.InternalContacts))
}
func calculateFileHash(filename string) (string, error) {
@@ -301,12 +302,16 @@ func cleanPhoneNumber(phone string) string {
func processContacts(contacts []Contact) *ContactData {
var data ContactData
data.InternalContacts = []Contact{} // Initialize as empty array
data.Contacts = []Contact{}
data.InternalContacts = []Contact{}
for _, contact := range contacts {
if strings.Contains(contact.Name, "Interní") {
// Check for internal contacts (either name contains "Interní" or position starts with "Interní")
if strings.Contains(contact.Name, "Interní") || strings.HasPrefix(contact.Position, "Interní") {
contact.Internal = true
data.InternalContacts = append(data.InternalContacts, contact)
} else {
contact.Internal = false
data.Contacts = append(data.Contacts, contact)
}
}
@@ -355,7 +360,7 @@ func reloadData(w http.ResponseWriter, r *http.Request) {
loadData()
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `{"status": "reloaded", "contacts_count": %d}`, len(currentData.Contacts) + len(currentData.InternalContacts))
fmt.Fprintf(w, `{"status": "reloaded", "contacts_count": %d}`, len(currentData.Contacts)+len(currentData.InternalContacts))
}
func getEmbeddedHTML() string {