category groups

main
alex 2023-04-22 01:15:29 +02:00
parent 55f38bfeb5
commit b9b4081514
7 changed files with 38 additions and 15 deletions

View File

@ -4,7 +4,7 @@
"globalInputs": [ "globalInputs": [
{ {
"parameterName": "irgendwas", "parameterName": "irgendwas",
"type": "string", "type": "text",
"displayName": "Irgendwas tolles" "displayName": "Irgendwas tolles"
}, },
{ {

View File

@ -3,9 +3,9 @@
"name": "Produktionstask 1", "name": "Produktionstask 1",
"globalInputs": [ "globalInputs": [
{ {
"parameterName": "irgendwas", "parameterName": "kundenname",
"type": "string", "type": "text",
"displayName": "Irgendwas tolles" "displayName": "Name des Kunden"
}, },
{ {
"parameterName": "kiste", "parameterName": "kiste",
@ -22,7 +22,7 @@
"parameter": [ "parameter": [
{ {
"parameterName": "labelformat", "parameterName": "labelformat",
"type": "string", "type": "text",
"displayName": "Format des Labels", "displayName": "Format des Labels",
"global": false "global": false
}, },

View File

@ -0,0 +1,4 @@
{
"category": "Test",
"name": "hello world"
}

View File

@ -1,4 +1,4 @@
{ {
"category": "Umbach", "category": "Umbach",
"name": "Umbach Snack bar" "name": "Umbach Snack bar auffüllen"
} }

View File

@ -7,7 +7,29 @@ import (
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
var Groups []Group var CategoryGroups []CategoryGroup
type CategoryGroup struct {
Category string `json:"category"`
Groups []Group `json:"groups"`
}
func addCategoryGroup(group Group) {
for index, categoryGroup := range CategoryGroups {
if categoryGroup.Category == group.Category {
CategoryGroups[index].Groups = append(CategoryGroups[index].Groups, group)
return
}
}
categoryGroup := CategoryGroup{
Category: group.Category,
}
categoryGroup.Groups = append(categoryGroup.Groups, group)
CategoryGroups = append(CategoryGroups, categoryGroup)
}
type Group struct { type Group struct {
Category string `json:"category"` Category string `json:"category"`
@ -70,18 +92,15 @@ func ReadGroups() {
return return
} }
//log.Info().Msgf("File content: %s", string(content))
var group Group var group Group
json.Unmarshal(content, &group) json.Unmarshal(content, &group)
group.Id = entry.Name() group.Id = entry.Name()
Groups = append(Groups, group)
log.Info().Msgf("Group: %s", group) log.Info().Msgf("Group: %s", group)
log.Info().Msgf("Number of groups: %d", len(Groups))
addCategoryGroup(group)
} }
} }
} }

View File

@ -79,8 +79,8 @@ func (socketClient *SocketClient) writeMessage(messageType int, message SendSock
} }
type InitUserSocketConnection struct { type InitUserSocketConnection struct {
User UserData User UserData
GroupTasks []grouptasks.Group CategoryGroups []grouptasks.CategoryGroup
} }
type UserData struct { type UserData struct {

View File

@ -50,7 +50,7 @@ func RunHub() {
Username: user.Username, Username: user.Username,
Email: user.Email, Email: user.Email,
}, },
GroupTasks: grouptasks.Groups, CategoryGroups: grouptasks.CategoryGroups,
}, },
}) })