Working on adding icons to the tasks, and started working on the tasks page

This commit is contained in:
Colin Dawson 2026-03-14 14:30:35 +00:00
parent 55d1beadbc
commit 7048594ea9
12 changed files with 91 additions and 21 deletions

View File

@ -4,6 +4,7 @@ public class TaskMetadata
{
public string TaskType { get; set; }
public string DisplayName { get; set; }
public string Icon { get; set; }
public List<string> Capabilities { get; set; } = [];
public string OutcomeLabel { get; set; }

View File

@ -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;
/// <summary>
/// User manage is responsible for managing users within e-suite.
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class TasksController : ESuiteControllerBase
{
private readonly IWorkflowTemplateManager _workflowTemplateManager;
public TasksController()
{
}
/// <summary>
/// Get a list of workflow templates
/// </summary>
/// <param name="paging"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[Route("myTasks")]
[AccessKey(SecurityAccess.ViewTasks)]
[HttpGet]
public async Task<IActionResult> GetMyTasks(
[FromQuery] Paging paging,
CancellationToken cancellationToken = default!
)
{
return Ok();
}
}

View File

@ -21,8 +21,7 @@ public class WorkflowTemplateController : ESuiteControllerBase
{
_workflowTemplateManager = workflowTemplateManager;
}
/// <summary>
/// Get a list of workflow templates
/// </summary>
@ -33,7 +32,10 @@ public class WorkflowTemplateController : ESuiteControllerBase
[Route("templates")]
[AccessKey(SecurityAccess.ViewWorkflowTemplates)]
[HttpGet]
public async Task<IActionResult> GetWorkflowTemplates([FromQuery] Paging paging, CancellationToken cancellationToken = default!)
public async Task<IActionResult> 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<IActionResult> GetWorkflowTemplateVersions([FromQuery] Paging paging,CancellationToken cancellationToken = default!)
public async Task<IActionResult> 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<IActionResult> EditTemplateVersion(GetWorkflowTemplateVersion template, CancellationToken cancellationToken = default!)
public async Task<IActionResult> 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<IActionResult> PatchWorkflowTemplateVersion([FromQuery] IGeneralIdRef templateId, [FromBody] PatchWorkflowTemplateVersion patchTemplate, CancellationToken cancellationToken = default!)
public async Task<IActionResult> 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<IActionResult> 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);
}
}

View File

@ -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
}

View File

@ -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

View File

@ -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)
{
}
}

View File

@ -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<ApprovalTaskAssignee>, IOutcome<ApprovalVerdict>
{
public List<ApprovalTaskAssignee> Assignees { get; set; } = [];

View File

@ -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<ApprovalTaskAttribute>, IOutcome<ApprovalVerdict>
{
public ICollection<ITask> Tasks { get; } = new List<ITask>();

View File

@ -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<DefaultOutcome>
{
public List<OutcomeAction<DefaultOutcome>> OutcomeActions { get; set; } = [];

View File

@ -8,7 +8,7 @@ namespace e_suite.Workflow.Core.Tasks;
/// <summary>
/// A user has to open this task, manually set it to ready to complete
/// </summary>
[GeneralTask]
[GeneralTask(taskIcon: "faSquareCheck")]
public class BasicTask : TaskBase, IAssignees<TaskAssignee>, IOutcome<DefaultOutcome>
{
public List<TaskAssignee> Assignees { get; set; } = [];

View File

@ -5,7 +5,7 @@ using eSuite.Core.Miscellaneous;
namespace e_suite.Workflow.Core.Tasks;
[GeneralTask]
[GeneralTask(taskIcon: "faFileLines")]
public class FormDataInputTask : TaskBase, IAssignees<TaskAssignee>, IFormTemplate, IOutcome<DefaultOutcome>
{
public List<TaskAssignee> Assignees { get; set; } = [];

View File

@ -10,7 +10,7 @@ namespace e_suite.Workflow.Core.Tasks;
/// <summary>
/// A Milestone task does not have any specific processing, so is ready to complete as soon at it starts.
/// </summary>
[GeneralTask]
[GeneralTask(taskIcon: "faFlagCheckered")]
public class MilestoneTask : TaskBase, IOutcome<DefaultOutcome>
{
public List<OutcomeAction<DefaultOutcome>> OutcomeActions { get; set; } = [];