This commit is contained in:
@@ -43,45 +43,27 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
/// <summary>
|
||||
/// Get roles
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
/// <param name="AsJson">Return as compact JSON format</param>
|
||||
/// <returns>Dictionary list of AyaNova object types and their authorization role rights in AyaNova</returns>
|
||||
[HttpGet("list")]
|
||||
public ActionResult GetRoles()
|
||||
public ActionResult GetRoles([FromQuery] bool AsJson = false)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Ok(ApiOkResponse.Response(BizRoles.roles, true));
|
||||
//as json for client end of things
|
||||
if (AsJson)
|
||||
return Ok(ApiOkResponse.Response(Newtonsoft.Json.JsonConvert.SerializeObject(BizRoles.roles, Newtonsoft.Json.Formatting.None), true));
|
||||
else
|
||||
return Ok(ApiOkResponse.Response(BizRoles.roles, true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Get all possible enumerated values picklist key names
|
||||
// /// </summary>
|
||||
// /// <returns>List of AyaNova enumerated type list key names that can be fetched from the AyaEnumPickList/GetPickListRoute</returns>
|
||||
// [HttpGet("listkeys")]
|
||||
// public ActionResult GetTypesList()
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// {
|
||||
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
// }
|
||||
|
||||
// List<KeyValuePair<string, string>> ret = new List<KeyValuePair<string, string>>();
|
||||
// ret.Add(new KeyValuePair<string, string>("usertypes", "AyaNova user account types"));
|
||||
// ret.Add(new KeyValuePair<string, string>("authorizationroles", "AyaNova user account role types"));
|
||||
// ret.Add(new KeyValuePair<string, string>("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these"));
|
||||
// ret.Add(new KeyValuePair<string, string>("datatypes", "Types of data used in AyaNova for display and formatting UI purposes"));
|
||||
|
||||
// return Ok(ApiOkResponse.Response(ret, true));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -400,6 +400,7 @@ namespace AyaNova
|
||||
$"/swagger/{description.GroupName}/swagger.json",
|
||||
description.GroupName.ToUpperInvariant());
|
||||
}
|
||||
options.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None);
|
||||
options.DefaultModelsExpandDepth(-1);//This is meant to hide the Models section that would appear at the bottom of the swagger ui showing *all* models from the api
|
||||
options.DocumentTitle = "AyaNova API explorer";
|
||||
options.RoutePrefix = "api-docs";
|
||||
|
||||
@@ -163,30 +163,32 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
#region output as JSON for client side
|
||||
#if (DEBUG)
|
||||
//Deprecated, now have api route for this instead
|
||||
//no need to manually copy to client
|
||||
// #if (DEBUG)
|
||||
|
||||
//################## HOW TO USE ##########
|
||||
//############## Uncomment SerializeObject line, put a break on lastRoles, copy from the output in the LOG (good for javascript with quotes formatted that way) #######
|
||||
// #### NEED to separately take a copy and update "lastRoles" string here by copying from the variable watch for the "json" variable shown in the debugger because need the C# format escaped quotes string
|
||||
// //################## HOW TO USE ##########
|
||||
// //############## Uncomment SerializeObject line, put a break on lastRoles, copy from the output in the LOG (good for javascript with quotes formatted that way) #######
|
||||
// // #### NEED to separately take a copy and update "lastRoles" string here by copying from the variable watch for the "json" variable shown in the debugger because need the C# format escaped quotes string
|
||||
|
||||
//GENERATE JSON FROM ROLES
|
||||
string json = Newtonsoft.Json.JsonConvert.SerializeObject(roles, Newtonsoft.Json.Formatting.None);
|
||||
// //GENERATE JSON FROM ROLES
|
||||
// string json = Newtonsoft.Json.JsonConvert.SerializeObject(roles, Newtonsoft.Json.Formatting.None);
|
||||
|
||||
//Output roles JSON FRAGMENT string for CLIENT to log
|
||||
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", "BizRoles.cs -> biz-role-rights.js Client roles JSON fragment:");
|
||||
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", json);
|
||||
// //Output roles JSON FRAGMENT string for CLIENT to log
|
||||
// System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", "BizRoles.cs -> biz-role-rights.js Client roles JSON fragment:");
|
||||
// System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", json);
|
||||
|
||||
//ONGOING VALIDATION TO CATCH MISMATCH WHEN NEW ROLES ADDED (wont' catch changes to existing unfortunately)
|
||||
//var lastRoles = "{\"User\":{\"Change\":2,\"ReadFullRecord\":1},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1},\"Widget\":{\"Change\":34,\"ReadFullRecord\":17},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":32767},\"License\":{\"Change\":16386,\"ReadFullRecord\":8193},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576},\"JobOperations\":{\"Change\":16384,\"ReadFullRecord\":8195},\"AyaNova7Import\":{\"Change\":16384,\"ReadFullRecord\":0},\"Metrics\":{\"Change\":0,\"ReadFullRecord\":24576},\"Locale\":{\"Change\":16386,\"ReadFullRecord\":32767},\"DataListFilter\":{\"Change\":2,\"ReadFullRecord\":32767},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":32767}}";
|
||||
var lastRoles = "{\"User\":{\"Change\":2,\"ReadFullRecord\":1},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1},\"Widget\":{\"Change\":34,\"ReadFullRecord\":17},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":131071},\"License\":{\"Change\":16386,\"ReadFullRecord\":8193},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576},\"JobOperations\":{\"Change\":16384,\"ReadFullRecord\":8195},\"AyaNova7Import\":{\"Change\":16384,\"ReadFullRecord\":0},\"Metrics\":{\"Change\":0,\"ReadFullRecord\":24576},\"Locale\":{\"Change\":16386,\"ReadFullRecord\":131071},\"DataListFilter\":{\"Change\":2,\"ReadFullRecord\":131071},\"DataListTemplate\":{\"Change\":2,\"ReadFullRecord\":131071},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":131071}}";
|
||||
Dictionary<AyaType, BizRoleSet> lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<AyaType, BizRoleSet>>(lastRoles);
|
||||
if (lastRolesDeserialized.Count != roles.Count)
|
||||
{
|
||||
throw new System.ArgumentException("BizRoles::Constructor - roles were modified from last snapshot for client!!!");
|
||||
}
|
||||
// //ONGOING VALIDATION TO CATCH MISMATCH WHEN NEW ROLES ADDED (wont' catch changes to existing unfortunately)
|
||||
// //var lastRoles = "{\"User\":{\"Change\":2,\"ReadFullRecord\":1},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1},\"Widget\":{\"Change\":34,\"ReadFullRecord\":17},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":32767},\"License\":{\"Change\":16386,\"ReadFullRecord\":8193},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576},\"JobOperations\":{\"Change\":16384,\"ReadFullRecord\":8195},\"AyaNova7Import\":{\"Change\":16384,\"ReadFullRecord\":0},\"Metrics\":{\"Change\":0,\"ReadFullRecord\":24576},\"Locale\":{\"Change\":16386,\"ReadFullRecord\":32767},\"DataListFilter\":{\"Change\":2,\"ReadFullRecord\":32767},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":32767}}";
|
||||
// var lastRoles = "{\"User\":{\"Change\":2,\"ReadFullRecord\":1},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1},\"Widget\":{\"Change\":34,\"ReadFullRecord\":17},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":131071},\"License\":{\"Change\":16386,\"ReadFullRecord\":8193},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576},\"JobOperations\":{\"Change\":16384,\"ReadFullRecord\":8195},\"AyaNova7Import\":{\"Change\":16384,\"ReadFullRecord\":0},\"Metrics\":{\"Change\":0,\"ReadFullRecord\":24576},\"Locale\":{\"Change\":16386,\"ReadFullRecord\":131071},\"DataListFilter\":{\"Change\":2,\"ReadFullRecord\":131071},\"DataListTemplate\":{\"Change\":2,\"ReadFullRecord\":131071},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":131071}}";
|
||||
// Dictionary<AyaType, BizRoleSet> lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<AyaType, BizRoleSet>>(lastRoles);
|
||||
// if (lastRolesDeserialized.Count != roles.Count)
|
||||
// {
|
||||
// throw new System.ArgumentException("BizRoles::Constructor - roles were modified from last snapshot for client!!!");
|
||||
// }
|
||||
|
||||
|
||||
#endif
|
||||
// #endif
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user