This commit is contained in:
2020-10-23 18:59:51 +00:00
parent 4bfa45f92c
commit 5f440184ce
9 changed files with 46 additions and 24 deletions

2
.vscode/launch.json vendored
View File

@@ -52,7 +52,7 @@
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
"AYANOVA_SERVER_TEST_MODE": "false", "AYANOVA_SERVER_TEST_MODE": "true",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\" "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"

View File

@@ -80,37 +80,44 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Bulk add tags to list of object id's specified /// Bulk add tags to list of object id's specified
/// </summary> /// </summary>
/// <param name="ayaType"></param>
/// <param name="tag"></param> /// <param name="tag"></param>
/// <param name="idList"></param> /// <param name="dataListSelection"></param>
/// <returns>Job Id</returns> /// <returns>Job Id</returns>
[HttpPost("bulk-add/{ayaType}/{tag}")] [HttpPost("bulk-add/{tag}")]
public async Task<IActionResult> BulkAdd([FromRoute] AyaType ayaType, [FromRoute] string tag, [FromBody] List<long> idList) public async Task<IActionResult> BulkAdd([FromRoute] string tag, [FromBody] DataListSelection dataListSelection)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute)))
if (dataListSelection.IsEmpty)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "DataListSelection is required"));
if (!dataListSelection.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type"));
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
if (!Authorized.HasModifyRole(HttpContext.Items, dataListSelection.ObjectType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
if (idList.Count == 0)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids are required"));
tag = TagBiz.NormalizeTag(tag); tag = TagBiz.NormalizeTag(tag);
if (string.IsNullOrWhiteSpace(tag)) if (string.IsNullOrWhiteSpace(tag))
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag required")); return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag required"));
var JobName = $"Bulk operation: Add tag \"{tag}\" on {ayaType} ({idList.Count} specified)"; await dataListSelection.RehydrateIdList(ct, UserRolesFromContext.Roles(HttpContext.Items), log);
if (dataListSelection.SelectedRowIds.Length == 0)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids"));
var JobName = $"Bulk operation: Add tag \"{tag}\" on {dataListSelection.ObjectType} ({dataListSelection.SelectedRowIds.LongLength} specified)";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
{ {
idList = idList, idList = dataListSelection.SelectedRowIds,
tag = tag tag = tag
}); });
OpsJob j = new OpsJob(); OpsJob j = new OpsJob();
j.Name = JobName; j.Name = JobName;
j.ObjectType = ayaType; j.ObjectType = dataListSelection.ObjectType;
j.JobType = JobType.BulkCoreBizObjectOperation; j.JobType = JobType.BulkCoreBizObjectOperation;
j.SubType = JobSubType.TagAdd; j.SubType = JobSubType.TagAdd;
j.Exclusive = false; j.Exclusive = false;

View File

@@ -316,12 +316,11 @@ namespace AyaNova.Biz
//REPORT DATA //REPORT DATA
//Data fetched to return to report designer for Client report design usage //Data fetched to return to report designer for Client report design usage
public async Task<Newtonsoft.Json.Linq.JArray> GetReportData(DataListSelection reportDataParam, AuthorizationRoles overrideRoles = AuthorizationRoles.NoRole) public async Task<Newtonsoft.Json.Linq.JArray> GetReportData(DataListSelection reportDataParam)
{ {
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::GetReportData"); var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::GetReportData");
AuthorizationRoles effectiveRoles = CurrentUserRoles; AuthorizationRoles effectiveRoles = CurrentUserRoles;
if (overrideRoles != AuthorizationRoles.NoRole)
effectiveRoles = overrideRoles;
if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, reportDataParam.ObjectType)) if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, reportDataParam.ObjectType))
{ {
@@ -345,7 +344,7 @@ namespace AyaNova.Biz
//RENDER //RENDER
// //
public async Task<string> RenderReport(RenderReportParameter reportParam, string apiUrl, AuthorizationRoles overrideRoles = AuthorizationRoles.NoRole) public async Task<string> RenderReport(RenderReportParameter reportParam, string apiUrl)
{ {
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::RenderReport"); var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::RenderReport");
@@ -358,8 +357,6 @@ namespace AyaNova.Biz
} }
AuthorizationRoles effectiveRoles = CurrentUserRoles; AuthorizationRoles effectiveRoles = CurrentUserRoles;
if (overrideRoles != AuthorizationRoles.NoRole)
effectiveRoles = overrideRoles;
if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, report.ObjectType)) if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, report.ObjectType))

View File

@@ -1,7 +1,10 @@
using System.Threading.Tasks;
using AyaNova.Biz; using AyaNova.Biz;
using Newtonsoft.Json.Linq;
namespace AyaNova.Models namespace AyaNova.Models
{ {
//Used to drive processes that rely on selections made at client from a datalist
//either a preselected list of id's or a datalist key and listview filter object that can
//be used to rehydrate a list of id's
public class DataListSelection public class DataListSelection
{ {
public AyaType ObjectType { get; set; } public AyaType ObjectType { get; set; }
@@ -9,7 +12,18 @@ namespace AyaNova.Models
public string DataListKey { get; set; } public string DataListKey { get; set; }
public string ListView { get; set; }//optional, if null or empty will use default list view built into DataList public string ListView { get; set; }//optional, if null or empty will use default list view built into DataList
public bool IsEmpty
{
get
{
return SelectedRowIds.LongLength == 0 && string.IsNullOrWhiteSpace(DataListKey);
}
}
public async Task RehydrateIdList(AyContext ct, AuthorizationRoles userRoles, Microsoft.Extensions.Logging.ILogger log)
{
if (SelectedRowIds.Length == 0)
SelectedRowIds = await AyaNova.DataList.DataListFetcher.GetIdListResponseAsync(DataListKey, ListView, ct, userRoles, log);
}
} }
} }

View File

@@ -1876,6 +1876,7 @@
"Event": "Veranstaltung", "Event": "Veranstaltung",
"Extensions": "Erweiterungen", "Extensions": "Erweiterungen",
"SelectedItems": "Ausgewählte Elemente", "SelectedItems": "Ausgewählte Elemente",
"AllItemsInList": "Alle Elemente in der Liste",
"Remove": "Entfernen", "Remove": "Entfernen",
"NotifyDeliveryMethod": "Benachrichtigungsversandmethode", "NotifyDeliveryMethod": "Benachrichtigungsversandmethode",
"NotifyEventType": "Benachrichtigungsereignis", "NotifyEventType": "Benachrichtigungsereignis",

View File

@@ -1876,6 +1876,7 @@
"Event": "Event", "Event": "Event",
"Extensions": "Extensions", "Extensions": "Extensions",
"SelectedItems": "Selected items", "SelectedItems": "Selected items",
"AllItemsInList": "All items in list",
"Remove": "Remove", "Remove": "Remove",
"NotifyDeliveryMethod": "Notification delivery method", "NotifyDeliveryMethod": "Notification delivery method",
"NotifyEventType": "Notification event", "NotifyEventType": "Notification event",

View File

@@ -1876,6 +1876,7 @@
"Event": "Evento", "Event": "Evento",
"Extensions": "Extensiones", "Extensions": "Extensiones",
"SelectedItems": "Elementos seleccionados", "SelectedItems": "Elementos seleccionados",
"AllItemsInList": "Todos los elementos de la lista",
"Remove": "Eliminar", "Remove": "Eliminar",
"NotifyDeliveryMethod": "Método de entrega de notificaciones", "NotifyDeliveryMethod": "Método de entrega de notificaciones",
"NotifyEventType": "Evento de notificación", "NotifyEventType": "Evento de notificación",

View File

@@ -1876,6 +1876,7 @@
"Event": "Un événement", "Event": "Un événement",
"Extensions": "Extensions", "Extensions": "Extensions",
"SelectedItems": "Éléments sélectionnés", "SelectedItems": "Éléments sélectionnés",
"AllItemsInList": "Tous les éléments de la liste",
"Remove": "Retirer", "Remove": "Retirer",
"NotifyDeliveryMethod": "Méthode de remise des notifications", "NotifyDeliveryMethod": "Méthode de remise des notifications",
"NotifyEventType": "Événement de notification", "NotifyEventType": "Événement de notification",