From 7048594ea9c4ec0a7f3051980d01dec66cb1b574 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sat, 14 Mar 2026 14:30:35 +0000 Subject: [PATCH] Working on adding icons to the tasks, and started working on the tasks page --- .../e-suite.API.Common/TaskMetadata.cs | 1 + .../eSuite.API/Controllers/TasksController.cs | 42 +++++++++++++++++++ .../Controllers/WorkflowTemplateController.cs | 30 +++++++++---- .../eSuite.Core/Security/SecurityAccess.cs | 5 ++- .../WorkflowTemplateManager.cs | 6 ++- .../Attributes/GeneralTaskAttribute.cs | 16 +++++-- .../Tasks/AdhocApprovalTask.cs | 2 +- e-suite.Workflow.Core/Tasks/ApprovalTask.cs | 2 +- .../Tasks/AssetUploadTask.cs | 2 +- e-suite.Workflow.Core/Tasks/BasicTask.cs | 2 +- .../Tasks/FormDataInputTask.cs | 2 +- e-suite.Workflow.Core/Tasks/MilestoneTask.cs | 2 +- 12 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 e-suite.API/eSuite.API/Controllers/TasksController.cs diff --git a/e-suite.API.Common/e-suite.API.Common/TaskMetadata.cs b/e-suite.API.Common/e-suite.API.Common/TaskMetadata.cs index 767e4cc..b19753b 100644 --- a/e-suite.API.Common/e-suite.API.Common/TaskMetadata.cs +++ b/e-suite.API.Common/e-suite.API.Common/TaskMetadata.cs @@ -4,6 +4,7 @@ public class TaskMetadata { public string TaskType { get; set; } public string DisplayName { get; set; } + public string Icon { get; set; } public List Capabilities { get; set; } = []; public string OutcomeLabel { get; set; } diff --git a/e-suite.API/eSuite.API/Controllers/TasksController.cs b/e-suite.API/eSuite.API/Controllers/TasksController.cs new file mode 100644 index 0000000..8498cc4 --- /dev/null +++ b/e-suite.API/eSuite.API/Controllers/TasksController.cs @@ -0,0 +1,42 @@ +using e_suite.API.Common; +using e_suite.Utilities.Pagination; +using eSuite.API.security; +using eSuite.API.Utilities; +using eSuite.Core.Security; +using Microsoft.AspNetCore.Mvc; + +namespace eSuite.API.Controllers; + +/// +/// User manage is responsible for managing users within e-suite. +/// +[Route("api/[controller]")] +[ApiController] +public class TasksController : ESuiteControllerBase +{ + private readonly IWorkflowTemplateManager _workflowTemplateManager; + + public TasksController() + { + + } + + + /// + /// Get a list of workflow templates + /// + /// + /// + /// + /// + [Route("myTasks")] + [AccessKey(SecurityAccess.ViewTasks)] + [HttpGet] + public async Task GetMyTasks( + [FromQuery] Paging paging, + CancellationToken cancellationToken = default! + ) + { + return Ok(); + } +} \ No newline at end of file diff --git a/e-suite.API/eSuite.API/Controllers/WorkflowTemplateController.cs b/e-suite.API/eSuite.API/Controllers/WorkflowTemplateController.cs index 87e8cd0..cb2b931 100644 --- a/e-suite.API/eSuite.API/Controllers/WorkflowTemplateController.cs +++ b/e-suite.API/eSuite.API/Controllers/WorkflowTemplateController.cs @@ -21,8 +21,7 @@ public class WorkflowTemplateController : ESuiteControllerBase { _workflowTemplateManager = workflowTemplateManager; } - - + /// /// Get a list of workflow templates /// @@ -33,7 +32,10 @@ public class WorkflowTemplateController : ESuiteControllerBase [Route("templates")] [AccessKey(SecurityAccess.ViewWorkflowTemplates)] [HttpGet] - public async Task GetWorkflowTemplates([FromQuery] Paging paging, CancellationToken cancellationToken = default!) + public async Task GetWorkflowTemplates( + [FromQuery] Paging paging, + CancellationToken cancellationToken = default! + ) { var result = await _workflowTemplateManager.GetWorkflowTemplatesAsync(paging, cancellationToken); return Ok(result); @@ -69,7 +71,10 @@ public class WorkflowTemplateController : ESuiteControllerBase [Route("templateVersions")] [AccessKey(SecurityAccess.ViewWorkflowTemplates)] [HttpGet] - public async Task GetWorkflowTemplateVersions([FromQuery] Paging paging,CancellationToken cancellationToken = default!) + public async Task GetWorkflowTemplateVersions( + [FromQuery] Paging paging, + CancellationToken cancellationToken = default! + ) { var result = await _workflowTemplateManager.GetWorkflowTemplateVersionsAsync(paging, cancellationToken); return Ok(result); @@ -107,7 +112,10 @@ public class WorkflowTemplateController : ESuiteControllerBase [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [AccessKey(SecurityAccess.EditWorkflowTemplate)] - public async Task EditTemplateVersion(GetWorkflowTemplateVersion template, CancellationToken cancellationToken = default!) + public async Task EditTemplateVersion( + GetWorkflowTemplateVersion template, + CancellationToken cancellationToken = default! + ) { await _workflowTemplateManager.EditTemplateVersion(AuditUserDetails, template, cancellationToken); return Ok(); @@ -124,9 +132,14 @@ public class WorkflowTemplateController : ESuiteControllerBase [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [AccessKey(SecurityAccess.EditWorkflowTemplate)] - public async Task PatchWorkflowTemplateVersion([FromQuery] IGeneralIdRef templateId, [FromBody] PatchWorkflowTemplateVersion patchTemplate, CancellationToken cancellationToken = default!) + public async Task PatchWorkflowTemplateVersion( + [FromQuery] IGeneralIdRef templateId, + [FromBody] PatchWorkflowTemplateVersion patchTemplate, + CancellationToken cancellationToken = default! + ) { - await _workflowTemplateManager.PatchTemplateVersion(AuditUserDetails, templateId, patchTemplate, cancellationToken); + await _workflowTemplateManager.PatchTemplateVersion(AuditUserDetails, templateId, patchTemplate, + cancellationToken); return Ok(); } @@ -180,7 +193,7 @@ public class WorkflowTemplateController : ESuiteControllerBase [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ProblemDetails))] [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ProblemDetails))] - [AccessKey(SecurityAccess.DeleteWorkflowTemplate)] + [AccessKey(SecurityAccess.Everyone)] public async Task GetAllowedTaskMetadataList( [FromQuery] string? taskType, CancellationToken cancellationToken = default! @@ -189,5 +202,4 @@ public class WorkflowTemplateController : ESuiteControllerBase var result = await _workflowTemplateManager.GetAllowedTaskMetadataList(taskType, cancellationToken); return Ok(result); } - } \ No newline at end of file diff --git a/e-suite.Core/eSuite.Core/Security/SecurityAccess.cs b/e-suite.Core/eSuite.Core/Security/SecurityAccess.cs index 74ee6af..751a797 100644 --- a/e-suite.Core/eSuite.Core/Security/SecurityAccess.cs +++ b/e-suite.Core/eSuite.Core/Security/SecurityAccess.cs @@ -251,5 +251,8 @@ public enum SecurityAccess DeleteWorkflowTemplate = 76, [Display(Name = "CreateActivity", Description = "Create an activity based on a Workflow Template", GroupName = "Activities")] - CreateActivity = 77 + CreateActivity = 77, + + [Display(Name = "ViewTasks", Description = "View activity tasks that are in progress", GroupName = "Activities")] + ViewTasks = 78 } \ No newline at end of file diff --git a/e-suite.Modules.WorkflowTemplatesManager/WorkflowTemplateManager.cs b/e-suite.Modules.WorkflowTemplatesManager/WorkflowTemplateManager.cs index 5431df8..07da1b7 100644 --- a/e-suite.Modules.WorkflowTemplatesManager/WorkflowTemplateManager.cs +++ b/e-suite.Modules.WorkflowTemplatesManager/WorkflowTemplateManager.cs @@ -4,7 +4,6 @@ using e_suite.API.Common.exceptions; using e_suite.API.Common.repository; using e_suite.Database.Audit; using e_suite.Database.Core.Extensions; -using e_suite.Modules.WorkflowTemplatesManager.Repository; using e_suite.Utilities.Pagination; using e_suite.Workflow.Core.Attributes; using e_suite.Workflow.Core.Extensions; @@ -13,7 +12,6 @@ using eSuite.Core.Miscellaneous; using System.Linq.Expressions; using System.Reflection; using e_suite.Database.Core.Tables.Workflow; -using Microsoft.AspNetCore.Mvc; //using WorkflowVersion = e_suite.Workflow.Core.WorkflowVersion; @@ -243,11 +241,15 @@ public class WorkflowTemplateManager : IWorkflowTemplateManager .Select(FormatInterfaceName) .ToList(); + var taskAttribute = t.GetCustomAttributes(typeof(TaskTypeAttribute), inherit: true).FirstOrDefault() as TaskTypeAttribute; + var newTaskMetadata = new TaskMetadata { TaskType = t.FullName!, DisplayName = t.Name, + Icon = taskAttribute?.TaskIcon ?? string.Empty }; + newTaskMetadata.Capabilities.AddRange(capabilities); var outcomeInterface = interfaces diff --git a/e-suite.Workflow.Core/Attributes/GeneralTaskAttribute.cs b/e-suite.Workflow.Core/Attributes/GeneralTaskAttribute.cs index 4f5ac9d..45fe795 100644 --- a/e-suite.Workflow.Core/Attributes/GeneralTaskAttribute.cs +++ b/e-suite.Workflow.Core/Attributes/GeneralTaskAttribute.cs @@ -2,18 +2,28 @@ public abstract class TaskTypeAttribute : Attribute { + protected TaskTypeAttribute(string taskIcon = "") + { + TaskIcon = taskIcon; + } + + public string TaskIcon { get; } } public class GeneralTaskAttribute : TaskTypeAttribute { - public bool AllowMultiple { get; } - - public GeneralTaskAttribute(bool allowMultiple = true) + public GeneralTaskAttribute(string taskIcon = "", bool allowMultiple = true) : base(taskIcon) { AllowMultiple = allowMultiple; } + + public bool AllowMultiple { get; } } public class ApprovalTaskAttribute : TaskTypeAttribute { + public ApprovalTaskAttribute(string taskIcon = "") : base(taskIcon) + { + + } } \ No newline at end of file diff --git a/e-suite.Workflow.Core/Tasks/AdhocApprovalTask.cs b/e-suite.Workflow.Core/Tasks/AdhocApprovalTask.cs index f4744d7..6510896 100644 --- a/e-suite.Workflow.Core/Tasks/AdhocApprovalTask.cs +++ b/e-suite.Workflow.Core/Tasks/AdhocApprovalTask.cs @@ -4,7 +4,7 @@ using e_suite.Workflow.Core.Interfaces; namespace e_suite.Workflow.Core.Tasks; -[GeneralTask] +[GeneralTask(taskIcon: "faEyeSlash")] public class AdhocApprovalTask : TaskBase, IAssignees, IOutcome { public List Assignees { get; set; } = []; diff --git a/e-suite.Workflow.Core/Tasks/ApprovalTask.cs b/e-suite.Workflow.Core/Tasks/ApprovalTask.cs index 6ae1cf3..8748f58 100644 --- a/e-suite.Workflow.Core/Tasks/ApprovalTask.cs +++ b/e-suite.Workflow.Core/Tasks/ApprovalTask.cs @@ -4,7 +4,7 @@ using e_suite.Workflow.Core.Interfaces; namespace e_suite.Workflow.Core.Tasks; -[GeneralTask] +[GeneralTask(taskIcon: "faEye")] public class ApprovalTask : TaskBase, IStage, IOutcome { public ICollection Tasks { get; } = new List(); diff --git a/e-suite.Workflow.Core/Tasks/AssetUploadTask.cs b/e-suite.Workflow.Core/Tasks/AssetUploadTask.cs index dd7daef..c7527b5 100644 --- a/e-suite.Workflow.Core/Tasks/AssetUploadTask.cs +++ b/e-suite.Workflow.Core/Tasks/AssetUploadTask.cs @@ -4,7 +4,7 @@ using e_suite.Workflow.Core.Interfaces; namespace e_suite.Workflow.Core.Tasks; -[GeneralTask] +[GeneralTask(taskIcon: "faCloudArrowUp")] public class AssetUploadTask : TaskBase, IOutcome { public List> OutcomeActions { get; set; } = []; diff --git a/e-suite.Workflow.Core/Tasks/BasicTask.cs b/e-suite.Workflow.Core/Tasks/BasicTask.cs index fdaaa52..f24a068 100644 --- a/e-suite.Workflow.Core/Tasks/BasicTask.cs +++ b/e-suite.Workflow.Core/Tasks/BasicTask.cs @@ -8,7 +8,7 @@ namespace e_suite.Workflow.Core.Tasks; /// /// A user has to open this task, manually set it to ready to complete /// -[GeneralTask] +[GeneralTask(taskIcon: "faSquareCheck")] public class BasicTask : TaskBase, IAssignees, IOutcome { public List Assignees { get; set; } = []; diff --git a/e-suite.Workflow.Core/Tasks/FormDataInputTask.cs b/e-suite.Workflow.Core/Tasks/FormDataInputTask.cs index 813cb24..cdaab1a 100644 --- a/e-suite.Workflow.Core/Tasks/FormDataInputTask.cs +++ b/e-suite.Workflow.Core/Tasks/FormDataInputTask.cs @@ -5,7 +5,7 @@ using eSuite.Core.Miscellaneous; namespace e_suite.Workflow.Core.Tasks; -[GeneralTask] +[GeneralTask(taskIcon: "faFileLines")] public class FormDataInputTask : TaskBase, IAssignees, IFormTemplate, IOutcome { public List Assignees { get; set; } = []; diff --git a/e-suite.Workflow.Core/Tasks/MilestoneTask.cs b/e-suite.Workflow.Core/Tasks/MilestoneTask.cs index 3a89bfa..c8e0eff 100644 --- a/e-suite.Workflow.Core/Tasks/MilestoneTask.cs +++ b/e-suite.Workflow.Core/Tasks/MilestoneTask.cs @@ -10,7 +10,7 @@ namespace e_suite.Workflow.Core.Tasks; /// /// A Milestone task does not have any specific processing, so is ready to complete as soon at it starts. /// -[GeneralTask] +[GeneralTask(taskIcon: "faFlagCheckered")] public class MilestoneTask : TaskBase, IOutcome { public List> OutcomeActions { get; set; } = [];