diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 78fffe99..17d882fa 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -8,23 +8,24 @@ NOTE: no bulk tag op route will work with every object in order for safety, ther note: they can use a datalist to select so no need to add any filtering ability here todo: SET TAGS ability to bulk tag items from list (SERVER AND CLIENT) - route: bulk tag by type and id collection + route: bulk-add by type and id collection parameters=Type, [id], tag - route: bulk tag by type and all objects no id specified + route: bulk-add-all by type and all objects no id specified parameters=Type, tag todo: REPLACE TAGS - route: bulk replace one tag with another tag by type and id collection - parameters=Type, [id], oldTag, newTag - route: bulk repalce one tag with another tag by type and all objects no collection + route: bulk-replace one tag with another tag by type and id collection parameters=Type, [id], oldTag, newTag + route: bulk-replace-all one tag with another tag by type and all objects no collection + parameters=Type, oldTag, newTag todo: REMOVE TAGS - route: bulk remove specified tag by type and id collection + route: bulk-remove specified tag by type and id collection parameters=Type, [id], tag - route: bulk remove tag by type and all objects no id specified + route: bulk-remove-all tag by type and all objects no id specified parameters=Type, tag + todo: API root controller build mode and server info should be authorized shoudln't they? Unauthorized people have no need to see that stuff todo: api / server landing page is shitty on a mobile diff --git a/server/AyaNova/Controllers/TagController.cs b/server/AyaNova/Controllers/TagController.cs index 398efa82..cbb85ae9 100644 --- a/server/AyaNova/Controllers/TagController.cs +++ b/server/AyaNova/Controllers/TagController.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; @@ -46,7 +47,7 @@ namespace AyaNova.Api.Controllers /// The query to filter the returned list by /// Filtered list (maximum 25 items are returned for any query) [HttpGet("list")] - public async Task GetList([FromQuery]string query) + public async Task GetList([FromQuery] string query) { if (serverState.IsClosed) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); @@ -59,7 +60,7 @@ namespace AyaNova.Api.Controllers /// The query to filter the returned list by /// List [HttpGet("cloudlist")] - public async Task GetCloudList([FromQuery]string query) + public async Task GetCloudList([FromQuery] string query) { if (serverState.IsClosed) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); @@ -67,6 +68,32 @@ namespace AyaNova.Api.Controllers } + ///////////////////////////////// + //BULK OPS + // + + + /// + /// Bulk add tags to objects + /// + /// Required + /// Required + /// Number of items affected + [HttpPost("bulk-add/{ayaType}")] + public async Task BulkAdd([FromRoute] AyaType ayaType, [FromBody] TagUtil.BulkTagOpParameter tagOpParams) + { + if (!serverState.IsOpen) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + if (!ModelState.IsValid) + return BadRequest(new ApiErrorResponse(ModelState)); + if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) + return StatusCode(403, new ApiNotAuthorizedResponse()); + return Ok(ApiOkResponse.Response(await TagUtil.BulkAdd(ayaType, tagOpParams, ct), true)); + } + + + + }//eoc }//ens \ No newline at end of file diff --git a/server/AyaNova/biz/TagUtil.cs b/server/AyaNova/biz/TagUtil.cs index e51592f2..99c1a1f3 100644 --- a/server/AyaNova/biz/TagUtil.cs +++ b/server/AyaNova/biz/TagUtil.cs @@ -204,13 +204,31 @@ namespace AyaNova.Biz .ToListAsync(); } } + public class TagCloudItem + { + public long RefCount { get; set; } + public string Name { get; set; } + } + + + ///////////////////////////////// + //BULK OPS + // + + public static async Task BulkAdd(AyaType ayaType, BulkTagOpParameter tagOpParams, AyContext ct) + { + throw new System.NotImplementedException("NOT IMPLEMENTED YET"); + } + + + public class BulkTagOpParameter + { + public string NewTag { get; set; } + public List ObjectIds { get; set; } + } }//eoc - public class TagCloudItem - { - public long RefCount { get; set; } - public string Name { get; set; } - } + }//ens