From 5ad9c95f8c91ffb822145f0a56796c56bd124242 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 28 Jan 2020 20:08:36 +0000 Subject: [PATCH] --- .../AuthorizationRolesController.cs | 34 ++++------------- server/AyaNova/Startup.cs | 1 + server/AyaNova/biz/BizRoles.cs | 38 ++++++++++--------- 3 files changed, 29 insertions(+), 44 deletions(-) diff --git a/server/AyaNova/Controllers/AuthorizationRolesController.cs b/server/AyaNova/Controllers/AuthorizationRolesController.cs index eb01bd5b..51a1008a 100644 --- a/server/AyaNova/Controllers/AuthorizationRolesController.cs +++ b/server/AyaNova/Controllers/AuthorizationRolesController.cs @@ -43,45 +43,27 @@ namespace AyaNova.Api.Controllers /// /// Get roles - /// + /// + /// Return as compact JSON format /// Dictionary list of AyaNova object types and their authorization role rights in AyaNova [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)); } - // /// - // /// Get all possible enumerated values picklist key names - // /// - // /// List of AyaNova enumerated type list key names that can be fetched from the AyaEnumPickList/GetPickListRoute - // [HttpGet("listkeys")] - // public ActionResult GetTypesList() - // { - // if (!serverState.IsOpen) - // { - // return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); - // } - - // List> ret = new List>(); - // ret.Add(new KeyValuePair("usertypes", "AyaNova user account types")); - // ret.Add(new KeyValuePair("authorizationroles", "AyaNova user account role types")); - // ret.Add(new KeyValuePair("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these")); - // ret.Add(new KeyValuePair("datatypes", "Types of data used in AyaNova for display and formatting UI purposes")); - - // return Ok(ApiOkResponse.Response(ret, true)); - // } - diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index cb0e8d94..57819e61 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -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"; diff --git a/server/AyaNova/biz/BizRoles.cs b/server/AyaNova/biz/BizRoles.cs index 44c260b1..4364e219 100644 --- a/server/AyaNova/biz/BizRoles.cs +++ b/server/AyaNova/biz/BizRoles.cs @@ -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 lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject>(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 lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject>(lastRoles); +// if (lastRolesDeserialized.Count != roles.Count) +// { +// throw new System.ArgumentException("BizRoles::Constructor - roles were modified from last snapshot for client!!!"); +// } -#endif +// #endif #endregion