I have put togerher a custom dashboard. I have tried in the Content section and did not show and I am tryingnow in the setting section and it stll does not show.
Here is my code` this lives in a folder call (/App_Plugins/KFADashboard/ and file is called "KFADashboard.html
<div class="welcome">
<h1>Weclome to KFA Umbarco Dashboard</h1>
<p>This is Setting section, where our CSS and JavaScript live</p>
</div>
Here is package.manifest also, it lives there as well:
I think I figured it out. I needed to added to Dashboard.config file. And now it works.
If I would need to bring data from my database, can I do that on a custom dashboard. I have table in Umbraco called recipes and I would like to show a list of them,
Essentially you can add an additional javascript file in your manifest file that defines an angularJS controller, and your HTML view can then reference this controller.
From the controller you can make a Get Request to an API controller.
So if you create an API controller that inherits UmbracoAuthorizedApiController (to route it so it's only accessible via the backoffice) you create an endpoint that queries your custom database table, and returns the data over the API to the angularJS controller that can then add it to the $scope to be rendered in the custom dashboard view!
Marc:
Would I have to add a custom route in order to see the data in the dqashboard. I am using the tutorial to help me build the api.
Here is what I got:
In the App Folder, I have an area called "Recipes":
Here is api Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Umbraco.Core.Persistence;
using Umbraco.Web.WebApi;
using Umbraco.Web.Editors;
using Recipes.Models.pocos;
namespace Recipes.Controllers
{
[Umbraco.Web.Mvc.PluginController("Recipes")]
public class RecipeApiController : UmbracoAuthorizedJsonController
{
public class Recipe
{
int RecipeId { get; set; }
string RecipeName { get; set; }
DateTime DateSubmitted { get; set; }
}
public IEnumerable<Recipe>GetAllRecipes()
{
var db = UmbracoContext.Application.DatabaseContext.Database;
var query = "SELECT RecipeId, RecipeName, DateSubmitted FROM CMSRecipes WHERE StatusId = 2";
return db.Fetch<Recipe>(query);
}
}
}
For the plugin it self, I have a view and two angular controllers, on thatr is resource:
// adds the resource to umbraco.resources module:
angular.module('umbraco.resources').factory('recipeResource',
function ($q, $http, umbRequestHelper) {
// the factory object returned
return {
// this calls the ApiController we setup earlier
getAllrecipes: function () {
return umbRequestHelper.resourcePromise(
$http.get("backoffice/Recipes/RecipeApi/GetAllRecipes"),
"Failed to retrieve all Recipe data");
}
};
}
);
The other that works on view page: (recipe.picker.js)
If you request the endpoint directly via the browser, then an UmbracoAuthorizedJsonController won't work as it will be missing the AngularJS csrf header on the request.
If you change to inherit from: UmbracoAuthorizedApiController then does that then work for you?
Hello Matthew ,
I'm facing same problem i create view ,package.manifest and lang xml also but my custom dashboard not shown ..i dont know why ..pls help me to resolve this issue
Custom Dashboard not appearing
I have put togerher a custom dashboard. I have tried in the Content section and did not show and I am tryingnow in the setting section and it stll does not show.
Here is my code` this lives in a folder call (/App_Plugins/KFADashboard/ and file is called "KFADashboard.html
Here is package.manifest also, it lives there as well:
I have created a language file as well, that lives in a folder (/App_Plugins/KFADashboard/lang/en-US.xml):
I am missing somrthing? Thanks Matthew Berner
`
I think I figured it out. I needed to added to Dashboard.config file. And now it works.
If I would need to bring data from my database, can I do that on a custom dashboard. I have table in Umbraco called recipes and I would like to show a list of them,
Hi Matthew
Not sure if you've seen the following tutorial about creating a custom dashboard, that might be useful as a reference:
https://our.umbraco.com/Documentation/Tutorials/Creating-a-Custom-Dashboard/index-v7
Essentially you can add an additional javascript file in your manifest file that defines an angularJS controller, and your HTML view can then reference this controller.
From the controller you can make a Get Request to an API controller.
So if you create an API controller that inherits UmbracoAuthorizedApiController (to route it so it's only accessible via the backoffice) you create an endpoint that queries your custom database table, and returns the data over the API to the angularJS controller that can then add it to the $scope to be rendered in the custom dashboard view!
regards
Marc
Marc: Would I have to add a custom route in order to see the data in the dqashboard. I am using the tutorial to help me build the api. Here is what I got: In the App Folder, I have an area called "Recipes": Here is api Code:
For the plugin it self, I have a view and two angular controllers, on thatr is resource:
The other that works on view page: (recipe.picker.js)
Then when I tested I got a message, saying I was not autorized. Thanks Matt
Hi Matt
If you request the endpoint directly via the browser, then an UmbracoAuthorizedJsonController won't work as it will be missing the AngularJS csrf header on the request.
If you change to inherit from: UmbracoAuthorizedApiController then does that then work for you?
regards
Marc
Hello Matthew , I'm facing same problem i create view ,package.manifest and lang xml also but my custom dashboard not shown ..i dont know why ..pls help me to resolve this issue
Regards, Megha
What version are you doing this on though?
The original post was years ago and depending on the version things are quite different.
is working on a reply...