mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-19 02:06:45 +00:00
Add reclaim assigned tasks button
This commit is contained in:
parent
470b1b162b
commit
ae32cb43d1
@ -106,6 +106,7 @@ func New() *WebAPI {
|
|||||||
api.router.POST("/project/webhook_secret/:id", LogRequestMiddleware(api.SetWebhookSecret))
|
api.router.POST("/project/webhook_secret/:id", LogRequestMiddleware(api.SetWebhookSecret))
|
||||||
api.router.POST("/project/reset_failed_tasks/:id", LogRequestMiddleware(api.ResetFailedTasks))
|
api.router.POST("/project/reset_failed_tasks/:id", LogRequestMiddleware(api.ResetFailedTasks))
|
||||||
api.router.POST("/project/hard_reset/:id", LogRequestMiddleware(api.HardReset))
|
api.router.POST("/project/hard_reset/:id", LogRequestMiddleware(api.HardReset))
|
||||||
|
api.router.POST("/project/reclaim_assigned_tasks/:id", LogRequestMiddleware(api.ReclaimAssignedTasks))
|
||||||
|
|
||||||
api.router.POST("/task/submit", LogRequestMiddleware(api.SubmitTask))
|
api.router.POST("/task/submit", LogRequestMiddleware(api.SubmitTask))
|
||||||
api.router.GET("/task/get/:project", LogRequestMiddleware(api.GetTaskFromProject))
|
api.router.GET("/task/get/:project", LogRequestMiddleware(api.GetTaskFromProject))
|
||||||
|
@ -318,3 +318,7 @@ type ResetFailedTaskResponse struct {
|
|||||||
type HardResetResponse struct {
|
type HardResetResponse struct {
|
||||||
AffectedTasks int64 `json:"affected_tasks"`
|
AffectedTasks int64 `json:"affected_tasks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReclaimAssignedTasksResponse struct {
|
||||||
|
AffectedTasks int64 `json:"affected_tasks"`
|
||||||
|
}
|
||||||
|
@ -756,3 +756,35 @@ func (api *WebAPI) HardReset(r *Request) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *WebAPI) ReclaimAssignedTasks(r *Request) {
|
||||||
|
|
||||||
|
pid, err := strconv.ParseInt(r.Ctx.UserValue("id").(string), 10, 64)
|
||||||
|
if err != nil || pid <= 0 {
|
||||||
|
r.Json(JsonResponse{
|
||||||
|
Ok: false,
|
||||||
|
Message: "Invalid project id",
|
||||||
|
}, 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
sess := api.Session.StartFasthttp(r.Ctx)
|
||||||
|
manager := sess.Get("manager")
|
||||||
|
|
||||||
|
if !isActionOnProjectAuthorized(pid, manager, storage.RoleMaintenance, api.Database) {
|
||||||
|
r.Json(JsonResponse{
|
||||||
|
Ok: false,
|
||||||
|
Message: "Unauthorized",
|
||||||
|
}, 403)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res := api.Database.ReclaimAssignedTasks(pid)
|
||||||
|
|
||||||
|
r.OkJson(JsonResponse{
|
||||||
|
Ok: true,
|
||||||
|
Content: ReclaimAssignedTasksResponse{
|
||||||
|
AffectedTasks: res,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -50,3 +50,21 @@ func (database Database) HardReset(pid int64) int64 {
|
|||||||
|
|
||||||
return rowsAffected
|
return rowsAffected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (database Database) ReclaimAssignedTasks(pid int64) int64 {
|
||||||
|
|
||||||
|
db := database.getDB()
|
||||||
|
|
||||||
|
res, err := db.Exec(`UPDATE task SET assignee=NULL, assign_time=NULL
|
||||||
|
WHERE project=$1 AND status=1`, pid)
|
||||||
|
handleErr(err)
|
||||||
|
|
||||||
|
rowsAffected, _ := res.RowsAffected()
|
||||||
|
|
||||||
|
logrus.WithFields(logrus.Fields{
|
||||||
|
"rowsAffected": rowsAffected,
|
||||||
|
"project": pid,
|
||||||
|
}).Info("Reclaim assigned tasks")
|
||||||
|
|
||||||
|
return rowsAffected
|
||||||
|
}
|
||||||
|
@ -122,4 +122,8 @@ export class ApiService {
|
|||||||
return this.http.post(this.url + `/project/hard_reset/${pid}`, null, this.options);
|
return this.http.post(this.url + `/project/hard_reset/${pid}`, null, this.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reclaimAssignedTasks(pid: number) {
|
||||||
|
return this.http.post(this.url + `/project/reclaim_assigned_tasks/${pid}`, null, this.options);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,10 @@
|
|||||||
<mat-icon>warning</mat-icon>
|
<mat-icon>warning</mat-icon>
|
||||||
{{"dashboard.hard_reset"|translate}}
|
{{"dashboard.hard_reset"|translate}}
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-raised-button color="accent" (click)="reclaimAssignedTasks()">
|
||||||
|
<mat-icon>replay</mat-icon>
|
||||||
|
{{"dashboard.reclaim"|translate}}
|
||||||
|
</button>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
@ -442,4 +442,20 @@ export class ProjectDashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reclaimAssignedTasks() {
|
||||||
|
this.dialog.open(AreYouSureComponent, {
|
||||||
|
width: '250px',
|
||||||
|
}).afterClosed().subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this.apiService.reclaimAssignedTasks(this.project.id).subscribe(data => {
|
||||||
|
this.translate.get('project.reclaim_response').subscribe(t =>
|
||||||
|
this.messenger.show(t + data['content']['affected_tasks']));
|
||||||
|
}, error => {
|
||||||
|
this.translate.get('messenger.unauthorized').subscribe(t =>
|
||||||
|
this.messenger.show(t));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
"secret": "Secret",
|
"secret": "Secret",
|
||||||
"reset_response": "Reset failed tasks: ",
|
"reset_response": "Reset failed tasks: ",
|
||||||
"hard_reset_response": "Deleted tasks: ",
|
"hard_reset_response": "Deleted tasks: ",
|
||||||
|
"reclaim_response": "Reclaimed tasks: ",
|
||||||
"assign_rate": "Task assign rate limit",
|
"assign_rate": "Task assign rate limit",
|
||||||
"submit_rate": "Task submit rate limit",
|
"submit_rate": "Task submit rate limit",
|
||||||
"rate": "per second",
|
"rate": "per second",
|
||||||
@ -87,7 +88,8 @@
|
|||||||
"reset_failed": "Reset failed tasks",
|
"reset_failed": "Reset failed tasks",
|
||||||
"pause": "Pause",
|
"pause": "Pause",
|
||||||
"resume": "Resume",
|
"resume": "Resume",
|
||||||
"hard_reset": "Hard_reset"
|
"hard_reset": "Hard reset",
|
||||||
|
"reclaim": "Reclaim assigned tasks"
|
||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"title": "Login",
|
"title": "Login",
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
"version": "Version git (hash du commit)",
|
"version": "Version git (hash du commit)",
|
||||||
"reset_response": "Réinitialisé les tâches en échec: ",
|
"reset_response": "Réinitialisé les tâches en échec: ",
|
||||||
"hard_reset_response": "Supprimé toutes les tâches: ",
|
"hard_reset_response": "Supprimé toutes les tâches: ",
|
||||||
|
"reclaim_response": "Désaffecté les tâches: ",
|
||||||
"assign_rate": "Taux d'assignation de tâches",
|
"assign_rate": "Taux d'assignation de tâches",
|
||||||
"submit_rate": "Taux de soumission de tâches",
|
"submit_rate": "Taux de soumission de tâches",
|
||||||
"rate": "par seconde",
|
"rate": "par seconde",
|
||||||
@ -83,7 +84,8 @@
|
|||||||
"metadata": "Métadonnés du projet",
|
"metadata": "Métadonnés du projet",
|
||||||
"empty": "Aucune tâche",
|
"empty": "Aucune tâche",
|
||||||
"refresh": "Rafraîchir",
|
"refresh": "Rafraîchir",
|
||||||
"actions": "Actions"
|
"actions": "Actions",
|
||||||
|
"reclaim": "Déaffecter les tâches"
|
||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"title": "Ouvrir un session",
|
"title": "Ouvrir un session",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user