I was wondering if it is possible to load a .cshtml or controller so I can easily use razor for my dashboard in Umbraco 7. All the examples I could find are outdated.
If I'm not mistaken the dashboard section is now using Angular so I don't think you can use .cshtml for creating them. I can see that the "changepassword.html" is referring to som angular controllers so that is probably the way to go about it.
angular.module('umbraco.resources').factory('dashResource', function ($q, $http) {
return {
getAdvertisementModel: function () {
return $http.get("backoffice/Aneto/AnetoApi/GetAdvertisementModel");
}
};
});
AnetoApiController.cs
using System.Linq;
using umbraco;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.Editors;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
namespace Web.Controllers.Api
{
[PluginController("Aneto")]
[IsBackOffice]
public class AnetoApiController : UmbracoAuthorizedJsonController
{
private int TotaalOpenAdsTemp;
private int TotaalGeslotenAdsTemp;
public AdvertismentTotalViewModel GetAdvertisementModel()
{
IPublishedContent homePage = Umbraco.TypedContentAtRoot().First();
var advertentieOverview = homePage.Descendants("Advertenties");
var advertentieItems = advertentieOverview.DescendantsOrSelf("AdvertentieItem");
var alleAdvertentieItems = uQuery.GetDocument(1068).GetChildDocuments();
foreach (var item in advertentieItems)
{
var test = item.Properties.FirstOrDefault(p => p.PropertyTypeAlias == "status").Value.ToString();
if (item.Properties.FirstOrDefault(p => p.PropertyTypeAlias == "status").Value.ToString() == "Open")
{
TotaalOpenAdsTemp = TotaalOpenAdsTemp + 1;
}
}
return new AdvertismentTotalViewModel()
{
TotaalAds = alleAdvertentieItems.Count(),
TotaalOpenAds = TotaalOpenAdsTemp,
TotaalGeslotenAds = alleAdvertentieItems.Count() - TotaalOpenAdsTemp,
TotaalReacties = 0,
TotaalGebruikers = umbraco.cms.businesslogic.member.Member.GetAll.Count()
};
}
}
public class AdvertismentTotalViewModel
{
public int TotaalAds { get; set; }
public int TotaalOpenAds { get; set; }
public int TotaalGeslotenAds { get; set; }
public int TotaalReacties { get; set; }
public int TotaalGebruikers { get; set; }
}
}
Dashboard.config
Hi everyone,
I was wondering if it is possible to load a .cshtml or controller so I can easily use razor for my dashboard in Umbraco 7. All the examples I could find are outdated.
My config looks like below:
Giving me the following error:
Authorization error: Unauthorized access to URL: views/dashboard/default/customdashboard.cshtml
If I load a regular .html file it works fine.
Any ideas?
Hi Desley
If I'm not mistaken the dashboard section is now using Angular so I don't think you can use .cshtml for creating them. I can see that the "changepassword.html" is referring to som angular controllers so that is probably the way to go about it.
Hope this helps.
/Jan
Thanks. I suppose there aren't any examples to be found with the current conditions?
Hi Desley
Not that I know of unfortunately...
/Jan
Got it working with the following 2 links:
http://www.netaddicts.be/umbraco/v7-xpathdropdownlist-aka-docr/
http://our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/47827-404-For-PluginController
For anyone with similar needs.
Hi Desley
Thanks for sharing - Had not seen that very useful blog-post by Dirk. Just bookmarked it for a later read :)
Mind sharing the code for your solution as well?
/Jan
There are probably better ways but this is all I could come up with as a beginner.
package.manifest
DashboardAd.html
Aneto.Ad.controller.js
Aneto.Ad.resource.js
AnetoApiController.cs
is working on a reply...