Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
fortune-admin
=============

## Running as a standalone app

1) npm install

2) bower install

3) node app.js [port]

4) open your browser

## Running as a plugin for existing app

1) Add .css and .js fortune-admin files
Expand All @@ -37,12 +27,25 @@ fortune-admin
fortuneAdminProvider.setApiNamespace('/api/v2');
//3. Mount plugin to any route of your choice
fortuneAdminProvider.mountTo($routeProvider, '/admin');
//optional 4. If you're running the app standalone use this to render native navbar
//There's no need to manually set up navbar in this case
fortuneAdminProvider.enableNavbar();

//fortune-admin defaults to use html5Mode
$locationProvider.html5Mode(true);
});
```

## Pluggable menu

There are two directives that allow you to integrate navbars and make use of fortune-admin as a plugin simple and fun.

`<fortune-admin-resources-cells></fortune-admin-resources-cells>` this will insert resources dropdown with `<li>` as a root element

`<fortune-admin-uml-cells></fortune-admin-uml-cells>` this will insert simple link to UML diagram. Again, the root element is `<li>`

See /src/templates/views/mynavbar.html for usage example

## Running with html5Mode disabled

fortuneAdminProvider has html5Mode method which accepts a boolean and optional hash prefix
Expand Down
2 changes: 2 additions & 0 deletions fortune-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Build date: 2014-01-10
#fortune-admin{
padding-top: 20px;
padding-bottom: 20px;
}
#fortune-admin.wmargin{
margin-top: 60px;
}

Expand Down
4 changes: 2 additions & 2 deletions fortune-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ angular.module("/templates/views/mynavbar.html", []).run(["$templateCache", func

angular.module("/templates/views/resources.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("/templates/views/resources.html",
"<section id=\"fortune-admin\">\n" +
"<section id=\"fortune-admin\" ng-class=\"{wmargin: navbarEnabled}\">\n" +
" <div ng-if=\"navbarEnabled\">\n" +
" <fortune-admin-navbar></fortune-admin-navbar>\n" +
" </div>\n" +
Expand Down Expand Up @@ -144,7 +144,7 @@ angular.module("/templates/views/resourcesCells.html", []).run(["$templateCache"

angular.module("/templates/views/uml.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("/templates/views/uml.html",
"<section id=\"fortune-admin\">\n" +
"<section id=\"fortune-admin\" ng-class=\"{wmargin: navbarEnabled}\">\n" +
" <div ng-if=\"navbarEnabled\">\n" +
" <fortune-admin-navbar></fortune-admin-navbar>\n" +
" </div>\n" +
Expand Down
2 changes: 1 addition & 1 deletion fortune-admin.min.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/directives/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ angular.module('fortuneAdmin.Directives', [
}
}])

.directive('faRef', ['$http', '$compile',
function($http, $compile){
.directive('faRef', ['$http', '$compile', '$cacheFactory',
function($http, $compile, $cacheFactory){
return {
restrict: 'E',
replace: false,
Expand All @@ -96,17 +96,20 @@ angular.module('fortuneAdmin.Directives', [
var resources = scope.resources,
currentResource,
refRoute;
scope.$on('$routeChangeStart', function(){
var $httpCache = $cacheFactory.get('$http');
$httpCache.removeAll();
});


$http.get(CONFIG.fortuneAdmin.baseEndpoint + '/resources').success(function(data){
$http.get(CONFIG.fortuneAdmin.baseEndpoint + '/resources', {cache: true}).success(function(data){
resources = data.resources;
angular.forEach(resources, function(resource){
if (resource.name === scope.ref.ref){
refRoute = resource.route;
currentResource = resource;
}
});
$http.get(CONFIG.fortuneAdmin.getApiNamespace() + '/' + refRoute)
$http.get(CONFIG.fortuneAdmin.getApiNamespace() + '/' + refRoute, {cache: true})
.success(function(data){
var PK = currentResource.modelOptions ? currentResource.modelOptions.pk || 'id' : 'id';
scope.list = data[refRoute];
Expand Down
2 changes: 2 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#fortune-admin{
padding-top: 20px;
padding-bottom: 20px;
}
#fortune-admin.wmargin{
margin-top: 60px;
}

Expand Down
2 changes: 1 addition & 1 deletion src/templates/views/resources.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section id="fortune-admin">
<section id="fortune-admin" ng-class="{wmargin: navbarEnabled}">
<div ng-if="navbarEnabled">
<fortune-admin-navbar></fortune-admin-navbar>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/views/uml.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section id="fortune-admin">
<section id="fortune-admin" ng-class="{wmargin: navbarEnabled}">
<div ng-if="navbarEnabled">
<fortune-admin-navbar></fortune-admin-navbar>
</div>
Expand Down