Merge remote-tracking branch 'origin/v8/dev' into v9/dev
# Conflicts: # src/Umbraco.Core/Runtime/CoreRuntime.cs
This commit is contained in:
@@ -7,38 +7,59 @@
|
||||
* Controls the dashboards of the application
|
||||
*
|
||||
*/
|
||||
|
||||
function DashboardController($scope, $routeParams, dashboardResource, localizationService) {
|
||||
|
||||
function DashboardController($scope, $q, $routeParams, $location, dashboardResource, localizationService) {
|
||||
const DASHBOARD_QUERY_PARAM = 'dashboard';
|
||||
|
||||
$scope.page = {};
|
||||
$scope.page.nameLocked = true;
|
||||
$scope.page.loading = true;
|
||||
|
||||
$scope.dashboard = {};
|
||||
localizationService.localize("sections_" + $routeParams.section).then(function(name){
|
||||
$scope.dashboard.name = name;
|
||||
});
|
||||
|
||||
dashboardResource.getDashboard($routeParams.section).then(function(tabs){
|
||||
$scope.dashboard.tabs = tabs;
|
||||
|
||||
// set first tab to active
|
||||
if($scope.dashboard.tabs && $scope.dashboard.tabs.length > 0) {
|
||||
$scope.dashboard.tabs[0].active = true;
|
||||
}
|
||||
|
||||
var promises = [];
|
||||
|
||||
promises.push(localizationService.localize("sections_" + $routeParams.section).then(function (name) {
|
||||
$scope.dashboard.name = name;
|
||||
}));
|
||||
|
||||
promises.push(dashboardResource.getDashboard($routeParams.section).then(function (tabs) {
|
||||
$scope.dashboard.tabs = tabs;
|
||||
|
||||
if ($scope.dashboard.tabs && $scope.dashboard.tabs.length > 0) {
|
||||
initActiveTab();
|
||||
}
|
||||
}));
|
||||
|
||||
$q.all(promises).then(function () {
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
|
||||
$scope.changeTab = function(tab) {
|
||||
$scope.dashboard.tabs.forEach(function(tab) {
|
||||
tab.active = false;
|
||||
});
|
||||
$scope.changeTab = function (tab) {
|
||||
if ($scope.dashboard.tabs && $scope.dashboard.tabs.length > 0) {
|
||||
$scope.dashboard.tabs.forEach(function (tab) {
|
||||
tab.active = false;
|
||||
});
|
||||
}
|
||||
|
||||
tab.active = true;
|
||||
$location.search(DASHBOARD_QUERY_PARAM, tab.alias);
|
||||
};
|
||||
|
||||
function initActiveTab() {
|
||||
// Check the query parameter for a dashboard alias
|
||||
const dashboardAlias = $location.search()[DASHBOARD_QUERY_PARAM];
|
||||
const dashboardIndex = $scope.dashboard.tabs.findIndex(tab => tab.alias === dashboardAlias);
|
||||
|
||||
// Set the first dashboard to active if there is no query parameter or we can't find a matching dashboard for the alias
|
||||
const activeIndex = dashboardIndex !== -1 ? dashboardIndex : 0;
|
||||
|
||||
const tab = $scope.dashboard.tabs[activeIndex];
|
||||
|
||||
tab.active = true;
|
||||
$location.search(DASHBOARD_QUERY_PARAM, tab.alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//register it
|
||||
// Register it
|
||||
angular.module('umbraco').controller("Umbraco.DashboardController", DashboardController);
|
||||
|
||||
Reference in New Issue
Block a user