Bulk tag ops

This commit is contained in:
2020-05-16 00:12:36 +00:00
parent 1debeafbbd
commit d1fec5f415
3 changed files with 60 additions and 14 deletions

View File

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

View File

@@ -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
/// <param name="query">The query to filter the returned list by</param>
/// <returns>Filtered list (maximum 25 items are returned for any query)</returns>
[HttpGet("list")]
public async Task<IActionResult> GetList([FromQuery]string query)
public async Task<IActionResult> 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
/// <param name="query">The query to filter the returned list by</param>
/// <returns>List</returns>
[HttpGet("cloudlist")]
public async Task<IActionResult> GetCloudList([FromQuery]string query)
public async Task<IActionResult> 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
//
/// <summary>
/// Bulk add tags to objects
/// </summary>
/// <param name="ayaType">Required</param>
/// <param name="tagOpParams">Required</param>
/// <returns>Number of items affected</returns>
[HttpPost("bulk-add/{ayaType}")]
public async Task<IActionResult> 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

View File

@@ -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<long> BulkAdd(AyaType ayaType, BulkTagOpParameter tagOpParams, AyContext ct)
{
throw new System.NotImplementedException("NOT IMPLEMENTED YET");
}
public class BulkTagOpParameter
{
public string NewTag { get; set; }
public List<long> ObjectIds { get; set; }
}
}//eoc
public class TagCloudItem
{
public long RefCount { get; set; }
public string Name { get; set; }
}
}//ens