provide total pages on new group task creation to auto adjust the total pages on the web table

main
alex 2023-09-02 22:42:52 +02:00
parent e77194741d
commit b8795e2615
5 changed files with 110 additions and 66 deletions

View File

@ -113,7 +113,9 @@ func ReloadCategoryGroups(category string) {
}
if len(categoryGroups) > 0 {
socketclients.BroadcastMessage(structs.SendSocketMessage{
socketclients.BroadcastMessageToTopic(
utils.SubscribedDynamicTopicGroupTasks+category,
structs.SendSocketMessage{
Cmd: utils.SentCmdGroupTasksReloaded,
Body: struct {
Category string
@ -124,7 +126,9 @@ func ReloadCategoryGroups(category string) {
},
})
} else { // category was removed
socketclients.BroadcastMessage(structs.SendSocketMessage{
socketclients.BroadcastMessageToTopic(
utils.SubscribedDynamicTopicGroupTasks+category,
structs.SendSocketMessage{
Cmd: utils.SentCmdGroupTasksReloaded,
Body: struct {
RemovedCategory string
@ -950,7 +954,13 @@ func StartGroupTask(userId string, groupTask structs.GroupTasks) {
utils.SubscribedDynamicTopicGroupTasks+groupTask.Category,
structs.SendSocketMessage{
Cmd: utils.SentCmdNewGroupTaskStarted,
Body: groupTask,
Body: struct {
GroupTask structs.GroupTasks
TotalPages int
}{
GroupTask: groupTask,
TotalPages: utils.GetTotalPages([]structs.GroupTasks{}, "category = ?", groupTask.Category),
},
})
go RunGroupTask(RunGroupTaskArgs{

View File

@ -103,6 +103,7 @@ type ApiGroupTaskRequest struct {
Category string
GroupId string
Description string
// this format is needed [{"description": "bla"}]
GlobalInputs json.RawMessage
}

View File

@ -41,7 +41,11 @@ const (
)
var (
AcceptedAvatarFileTypes = []string{"image/png", "image/jpeg", "image/jpg", "image/gif"}
AcceptedAvatarFileTypes = []string{
"image/png",
"image/jpeg",
"image/jpg",
"image/gif"}
)
// commands sent to web clients
@ -85,6 +89,7 @@ const (
SentCmdInstallingGlobalPythonPackagesFailed = 37
SentCmdInstallingGlobalPythonPackagesFinished = 38
SentCmdUpdateUsers = 39
SentCmdCheckingForGroupTasksCategoryGroupChanges = 40
)
// commands received from web clients

View File

@ -216,6 +216,11 @@
"name": "stockItemId",
"in": "path",
"required": true
},
{
"description": "Page number",
"name": "page",
"in": "query"
}
],
"responses": {
@ -738,6 +743,7 @@
"type": "string"
},
"GlobalInputs": {
"description": "this format is needed [{\"description\": \"bla\"}]",
"type": "object"
},
"GroupId": {
@ -862,6 +868,21 @@
},
"x-go-package": "jannex/admin-dashboard-backend/modules/structs"
},
"GetGroupTaskStepsResponse": {
"type": "object",
"properties": {
"GroupTask": {
"$ref": "#/definitions/GroupTasks"
},
"GroupTaskSteps": {
"type": "array",
"items": {
"$ref": "#/definitions/GroupTaskSteps"
}
}
},
"x-go-package": "jannex/admin-dashboard-backend/modules/structs"
},
"GlobalInputs": {
"type": "object",
"properties": {

View File

@ -155,8 +155,9 @@ func RunHub() {
break
}
socketclients.BroadcastMessageToUsersWithPermission(
socketclients.BroadcastMessageToUsersWithPermissionAndTopic(
systempermissions.ConvertXYPermission(utils.PermissionGroupTasksOverviewXYView, category),
utils.SubscribedDynamicTopicGroupTasks+category,
structs.SendSocketMessage{
Cmd: utils.SentCmdReloadingGroupTasks,
Body: category,
@ -312,6 +313,12 @@ func RunHub() {
break
}
socketclients.BroadcastMessageToTopic(
utils.SubscribedDynamicTopicGroupTasks,
structs.SendSocketMessage{
Cmd: utils.SentCmdCheckingForGroupTasksCategoryGroupChanges,
})
grouptasks.LookingForCategoryGroupChanges(data.Conn.Locals("userId").(string))
break
case utils.ReceivedCmdHandleUserActionTaskStep: