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": [
{
"parameterName": "irgendwas",
"type": "string",
"type": "text",
"displayName": "Irgendwas tolles"
},
{

View File

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

View File

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

View File

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

View File

@ -7,7 +7,29 @@ import (
"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 {
Category string `json:"category"`
@ -70,18 +92,15 @@ func ReadGroups() {
return
}
//log.Info().Msgf("File content: %s", string(content))
var group Group
json.Unmarshal(content, &group)
group.Id = entry.Name()
Groups = append(Groups, 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 {
User UserData
GroupTasks []grouptasks.Group
User UserData
CategoryGroups []grouptasks.CategoryGroup
}
type UserData struct {

View File

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