Update ElementType Resource to not use hardcoded URL but to use the Umbraco.Sys.ServerVariables.umbracoUrls instead

This commit is contained in:
Warren Buckley
2020-06-24 11:21:24 +01:00
parent cb7f4a964c
commit c53ea9382f
3 changed files with 8 additions and 11 deletions

View File

@@ -8,21 +8,14 @@ function elementTypeResource($q, $http, umbRequestHelper) {
return {
getAll: function () {
var url = Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + "/backoffice/UmbracoApi/ElementType/GetAll";
return umbRequestHelper.resourcePromise(
$http.get(url),
'Failed to retrieve element types'
);
/*
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"elementTypeApiBaseUrl",
"GetAll")),
"Failed to retrieve data");
*/
"Failed to retrieve element types");
}
};

View File

@@ -318,6 +318,10 @@ namespace Umbraco.Web.Editors
"imageUrlGeneratorApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<ImageUrlGeneratorController>(
controller => controller.GetCropUrl(null, null, null, null, null))
},
{
"elementTypeApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<ElementTypeController>(
controller => controller.GetAll())
},
}
},
{

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using Umbraco.Core.Services;
using Umbraco.Web.Editors;
using Umbraco.Web.Mvc;
namespace Umbraco.Web.Editors
@@ -9,7 +9,7 @@ namespace Umbraco.Web.Editors
[PluginController("UmbracoApi")]
public class ElementTypeController : UmbracoAuthorizedJsonController
{
[System.Web.Http.HttpGet]
[HttpGet]
public IEnumerable<object> GetAll()
{
return Services.ContentTypeService