Source

frontend/src/api/routes/robots/rpaAttributes.js

  1. /**
  2. * @category Frontend
  3. * @module
  4. */
  5. /**
  6. * @description Will send a backend call to retrieve all attribute objects related to the provided robotId
  7. * @param {String} robotId Id of the robot for which to retrieve the values
  8. * @returns {Array} Array of attribute objects related to the robot
  9. */
  10. const getAllAttributes = async (robotId) => {
  11. const response = await fetch(`/robots/rpaattributes/${robotId}`);
  12. return response;
  13. };
  14. /**
  15. * @description Will send a backend call to update all given attribute objects with the new ones
  16. * @param {Array} attributeObjectList All updated attribute objects to overwrite the old attribute objects with
  17. * @returns {Array} Array of all updated attribute objects
  18. */
  19. const updateManyAttributes = async (attributeObjectList) => {
  20. const requestStringAttributes = `/robots/rpaattributes`;
  21. const response = await fetch(requestStringAttributes, {
  22. body: JSON.stringify({ attributeObjectList }),
  23. method: 'PUT',
  24. headers: {
  25. 'Content-Type': 'application/json;charset=utf-8',
  26. },
  27. });
  28. return response;
  29. };
  30. /**
  31. * @description Delete attributes for the given activities by sending a call to the backend
  32. * @param {String} robotId Id of the robot that is being used
  33. * @param {String} unusedActivityListString Stringified List of activityIds
  34. * @returns {Object} Mongoose query describing execution of call
  35. */
  36. const deleteAttributesForActivities = (robotId, activityIdList) => {
  37. const requestStringParameters = `/robots/rpaattributes/${robotId}`;
  38. fetch(requestStringParameters, {
  39. method: 'DELETE',
  40. body: JSON.stringify({ activityIdList }),
  41. headers: {
  42. 'Content-Type': 'application/json;charset=utf-8',
  43. },
  44. }).catch((err) => {
  45. console.error(err);
  46. });
  47. };
  48. export {
  49. getAllAttributes,
  50. updateManyAttributes,
  51. deleteAttributesForActivities,
  52. };