Skip to content

Instantly share code, notes, and snippets.

@sdorra
Last active September 4, 2015 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sdorra/33d24bd8e36f4d3011e0 to your computer and use it in GitHub Desktop.
Save sdorra/33d24bd8e36f4d3011e0 to your computer and use it in GitHub Desktop.
ADF shared data
<div>
<h3>angular-dashboard-framework</h3>
<p>Dashboard framework with Angular.js and Twitter Bootstrap.</p>
</div>
<div>
<ng-include src="vm.page" />
</div>
<div>
<h3>SCM-Manager</h3>
<p>The easiest way to share and manage your Git, Mercurial and Subversion repositories over http.</p>
</div>
<div>
<ul>
<li ng-repeat="page in vm.pages">
<a href="" ng-click="vm.setPage(page.href)">
{{page.name}}
</a>
</li>
</ul>
</div>
angular.module('adf.shared.widgets', ['adf.provider'])
.config(function($logProvider, dashboardProvider){
// enable debug logging
$logProvider.debugEnabled(true);
// register widgets
dashboardProvider
.widget('toc', {
title: 'Table of contents',
description: 'Displays table of contents',
templateUrl: 'toc.html',
controller: 'tocController',
controllerAs: 'vm'
})
.widget('content', {
title: 'Display content',
description: 'Displays content',
templateUrl: 'content.html',
controller: 'contentController',
controllerAs: 'vm'
});
})
.service('contentService', function(){
var currentPage = "adf";
return {
page: function(page){
if (page){
currentPage = page;
}
return currentPage;
}
};
})
.controller('contentController', function($scope, $log, contentService){
var vm = this;
vm.page = createPageUri(contentService.page());
// watch for page changes
$scope.$watch(function(){
return contentService.page();
}, function(newValue, oldValue){
if (newValue !== oldValue){
vm.page = createPageUri(newValue);
$log.debug('switch page to ' + vm.page);
}
});
function createPageUri(page){
return page + '.html';
};
})
.controller('tocController', function($log, contentService){
this.pages = [{
name: 'angular-dashboard-framework',
href: 'adf'
},{
name: 'SCM-Manager',
href: 'scm'
}];
this.setPage = function(page){
$log.debug('set page to ' + page);
contentService.page(page);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment