Skip to content

Commit f3a32ec

Browse files
committed
Merge pull request colmena#16 from movibe/docular
Docular for Angular JS Modules
2 parents 6ef4207 + 24a155a commit f3a32ec

131 files changed

Lines changed: 2038 additions & 1865 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ client/app/scripts/config.js
88
storage
99
npm-debug.log
1010
.idea/
11+
docs
12+
downloaded
1113
docular_generated
1214
.strong-pm/

Gruntfile.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = function (grunt) {
3434
tasks: ['wiredep']
3535
},
3636
js: {
37-
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
37+
files: ['<%= yeoman.app %>/scripts/{,*/}*.js', '<%= yeoman.app %>/modules/{,*/}*.js'],
3838
tasks: ['newer:jshint:all'],
3939
options: {
4040
livereload: '<%= connect.options.livereload %>'
@@ -393,8 +393,28 @@ module.exports = function (grunt) {
393393
}
394394
}
395395
},
396+
docularserver: {
397+
targetDir: "docs",
398+
livereload: true,
399+
port: 8000
400+
},
396401
docular: {
402+
useHtml5Mode: true, //Use angular's html5 mode? true/false.
403+
docular_webapp_target: 'docs', //The place where the docs will be generated
404+
showAngularDocs: true,
405+
showDocularDocs: true,
397406
groups: [
407+
{
408+
groupTitle: 'Admin',
409+
groupId: 'loopbackApp',
410+
sections: [
411+
{
412+
id: 'loopbackApp',
413+
title: 'LoopBack Services',
414+
scripts: [ 'client/app/modules/**/{,*/}*.js' ]
415+
}
416+
]
417+
},
398418
{
399419
groupTitle: 'LoopBack',
400420
groupId: 'loopback',

client/app/index.html

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,73 @@
7171
<script src="scripts/app.js"></script>
7272
<script src="scripts/lb-services.js"></script>
7373
<script src="scripts/config.js"></script>
74-
<script src="scripts/controllers/main.js"></script>
75-
<script src="scripts/controllers/login.js"></script>
76-
<script src="scripts/controllers/home.js"></script>
77-
<script src="scripts/directives/date.js"></script>
78-
<script src="scripts/directives/navbar.js"></script>
79-
<script src="scripts/directives/login.js"></script>
80-
<script src="scripts/directives/register.js"></script>
81-
<script src="scripts/services/appauth.js"></script>
82-
<script src="scripts/directives/home.js"></script>
83-
<script src="scripts/controllers/pages.js"></script>
84-
<script src="scripts/controllers/users.js"></script>
85-
<script src="scripts/controllers/sandbox.js"></script>
86-
<script src="scripts/controllers/notes.js"></script>
87-
<script src="scripts/controllers/posts.js"></script>
88-
<script src="scripts/controllers/settings.js"></script>
89-
<script src="scripts/controllers/products.js"></script>
90-
<script src="scripts/controllers/files.js"></script>
91-
<script src="scripts/controllers/events.js"></script>
92-
<script src="scripts/directives/admin-form.js"></script>
93-
<script src="scripts/directives/admin-box.js"></script>
94-
<script src="scripts/directives/admin-header.js"></script>
74+
<!--CORE-->
75+
<script src="modules/core/core.module.js"></script>
76+
<script src="modules/core/config/core.routes.js"></script>
77+
<script src="modules/core/config/core.auth.js"></script>
78+
<script src="modules/core/controllers/home.ctrl.js"></script>
79+
<script src="modules/core/controllers/main.ctrl.js"></script>
80+
<script src="modules/core/controllers/layout.ctrl.js"></script>
81+
<script src="modules/core/controllers/login.ctrl.js"></script>
82+
<script src="modules/core/controllers/router.ctrl.js"></script>
83+
<script src="modules/core/directives/admin-box.js"></script>
84+
<script src="modules/core/directives/admin-form.js"></script>
85+
<script src="modules/core/directives/admin-header.js"></script>
86+
<script src="modules/core/directives/date.js"></script>
87+
<script src="modules/core/directives/home.js"></script>
88+
<script src="modules/core/directives/login.js"></script>
89+
<script src="modules/core/directives/register.js"></script>
90+
<script src="modules/core/directives/small-box.directive.js"></script>
91+
<script src="modules/core/directives/navbar.js"></script>
92+
<script src="modules/core/services/appauth.service.js"></script>
93+
<!--About-->
94+
<script src="modules/about/about.module.js"></script>
95+
<script src="modules/about/controllers/about.controller.js"></script>
96+
<!--Events-->
97+
<script src="modules/events/events.module.js"></script>
98+
<script src="modules/events/config/events.routes.js"></script>
99+
<script src="modules/events/controllers/events.ctrl.js"></script>
100+
<!--Files-->
101+
<script src="modules/files/file.module.js"></script>
102+
<script src="modules/files/config/file.routes.js"></script>
103+
<script src="modules/files/controllers/upload.ctrl.js"></script>
104+
<script src="modules/files/controllers/files.ctrl.js"></script>
105+
<!--Notes-->
106+
<script src="modules/notes/notes.module.js"></script>
107+
<script src="modules/notes/config/notes.routes.js"></script>
108+
<script src="modules/notes/controllers/notes.ctrl.js"></script>
109+
<!--Pages-->
110+
<script src="modules/pages/pages.module.js"></script>
111+
<script src="modules/pages/config/pages.routes.js"></script>
112+
<script src="modules/pages/controllers/pages.ctrl.js"></script>
113+
<!-- Posts -->
114+
<script src="modules/posts/posts.module.js"></script>
115+
<script src="modules/posts/config/posts.routes.js"></script>
116+
<script src="modules/posts/controllers/posts.ctrl.js"></script>
117+
<!--Products-->
118+
<script src="modules/products/products.module.js"></script>
119+
<script src="modules/products/config/products.routes.js"></script>
120+
<script src="modules/products/controllers/products.ctrl.js"></script>
121+
<script src="modules/products/controllers/categories.ctrl.js"></script>
122+
<!--Sandbox-->
123+
<script src="modules/sandbox/sandbox.module.js"></script>
124+
<script src="modules/sandbox/config/sandbox.routes.js"></script>
125+
<script src="modules/sandbox/controllers/datepickerdemo.ctrl.js"></script>
126+
<script src="modules/sandbox/controllers/sandbox.ctrl.js"></script>
127+
<script src="modules/sandbox/controllers/sandboxalerts.ctrl.js"></script>
128+
<script src="modules/sandbox/controllers/sandboxbootstrapalert.ctrl.js"></script>
129+
<script src="modules/sandbox/controllers/sandboxbootstraptabs.ctrl.js"></script>
130+
<script src="modules/sandbox/controllers/sandboxforms.ctrl.js"></script>
131+
<script src="modules/sandbox/controllers/sandboxtoast.ctrl.js"></script>
132+
<script src="modules/sandbox/controllers/sandboxtress.ctrl.js"></script>
133+
<!--Settings-->
134+
<script src="modules/settings/settings.module.js"></script>
135+
<script src="modules/settings/config/settings.routes.js"></script>
136+
<script src="modules/settings/controllers/settings.ctrl.js"></script>
137+
<!--Users-->
138+
<script src="modules/users/user.module.js"></script>
139+
<script src="modules/users/config/users.routes.js"></script>
140+
<script src="modules/users/controllers/users.ctrl.js"></script>
95141
<!-- endbuild -->
96142

97143
</body>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict';
2+
angular.module ('com.module.about',[]);

client/app/scripts/controllers/about.js renamed to client/app/modules/about/controllers/about.controller.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
'use strict';
2-
2+
angular.module ('com.module.about')
33
/**
44
* @ngdoc function
5-
* @name clientApp.controller:AboutCtrl
5+
* @name com.module.about.controller:AboutCtrl
66
* @description
77
* # AboutCtrl
88
* Controller of the clientApp
99
*/
10-
angular.module('clientApp')
11-
.controller('AboutCtrl', function ($scope) {
10+
.controller ('AboutCtrl', function ($scope) {
1211
$scope.awesomeThings = [
1312
'HTML5 Boilerplate',
1413
'AngularJS',
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
'use strict';
2+
angular.module ('com.module.core')
3+
.config (function ($routeProvider, $httpProvider) {
4+
5+
// Intercept 401 responses and redirect to login screen
6+
$httpProvider.interceptors.push (function ($q, $location, AppAuth, toasty) {
7+
return {
8+
responseError: function (rejection) {
9+
10+
if (rejection.status === 401) {
11+
AppAuth.currentUser = null;
12+
// save the current location so that login can redirect back
13+
$location.nextAfterLogin = $location.path ();
14+
15+
if ($location.path () === '/router' || $location.path () === '/login') {
16+
console.log ('401 while on router on login path');
17+
} else {
18+
if ($location.path () !== '/register') {
19+
$location.path ('/login');
20+
}
21+
toasty.pop.warning ({
22+
title: 'Error 401 received',
23+
msg: 'We received a 401 error from the API! Redirecting to login',
24+
sound: false
25+
});
26+
}
27+
}
28+
if (rejection.status === 404) {
29+
console.log (rejection);
30+
toasty.pop.error ({title: 'Error 404 received', msg: rejection.data.error.message, sound: false});
31+
}
32+
if (rejection.status === 422) {
33+
console.log (rejection);
34+
toasty.pop.error ({title: 'Error 422 received', msg: rejection.data.error.message, sound: false});
35+
}
36+
if (rejection.status === 0) {
37+
$location.path ('/');
38+
toasty.pop.error ({
39+
title: 'Connection Refused',
40+
msg: 'The connection to the API is refused. Please verify that the API is running!',
41+
sound: false
42+
});
43+
}
44+
return $q.reject (rejection);
45+
}
46+
};
47+
});
48+
})
49+
.config (function (formlyConfigProvider) {
50+
var templates = 'modules/core/views/elements/fields/';
51+
var formly = templates + 'formly-field-';
52+
var fields = [
53+
'checkbox',
54+
'email',
55+
'hidden',
56+
'number',
57+
'password',
58+
'radio',
59+
'select',
60+
'text',
61+
'textarea'
62+
];
63+
64+
angular.forEach (fields, function (val) {
65+
formlyConfigProvider.setTemplateUrl (val, formly + val + '.html');
66+
});
67+
68+
formlyConfigProvider.setTemplateUrl ('date', templates + 'date.html');
69+
formlyConfigProvider.setTemplateUrl ('time', templates + 'time.html');
70+
71+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
angular.module ('com.module.core')
3+
.config (function ($stateProvider, $urlRouterProvider) {
4+
$stateProvider
5+
.state ('login', {
6+
url: '/login',
7+
template: '<login></login>',
8+
controller: 'LoginCtrl'
9+
}).state ('register', {
10+
url: '/register',
11+
template: '<register></register>',
12+
controller: 'LoginCtrl'
13+
}).state ('router', {
14+
url: '/router',
15+
template: '<div class="lockscreen" style="height: 100%"></div>',
16+
controller: 'RouteCtrl'
17+
})
18+
.state ('app', {
19+
abstract: true,
20+
url: '/app',
21+
templateUrl: 'modules/core/views/app.html',
22+
controller: 'MainCtrl'
23+
})
24+
.state ('app.home', {
25+
url: '',
26+
templateUrl: 'modules/core/views/home.html',
27+
controller: 'HomeCtrl'
28+
});
29+
$urlRouterProvider.otherwise ('/router');
30+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
/**
3+
* @ngdoc function
4+
* @name com.module.core.controller:HomeCtrl
5+
* @description Dashboard
6+
* @requires $scopoe
7+
* @requires $http
8+
* @requires Post
9+
* @requires Page
10+
* @requires Event
11+
* @requires Category
12+
* @requires Product
13+
* @requires ENV
14+
**/
15+
angular.module ('com.module.core')
16+
.controller ('HomeCtrl', function ($scope, $http, Post, Page, Event, Category, Product, ENV) {
17+
18+
$scope.count = {};
19+
20+
Product.find (function (products) {
21+
$scope.count.products = products.length;
22+
});
23+
24+
Category.find (function (categories) {
25+
$scope.count.categories = categories.length;
26+
});
27+
28+
Post.find (function (posts) {
29+
$scope.count.posts = posts.length;
30+
});
31+
32+
Page.find (function (pages) {
33+
$scope.count.pages = pages.length;
34+
});
35+
36+
Event.find (function (events) {
37+
$scope.count.events = events.length;
38+
});
39+
40+
$scope.count.files = 0;
41+
42+
$http.get (ENV.apiUrl + '/containers/files/files').success (function (data) {
43+
$scope.count.files = data.length;
44+
});
45+
46+
});
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
'use strict';
2+
angular.module ('com.module.core')
3+
/**
4+
* @ngdoc function
5+
* @name com.module.core.controller:LayoutCtrl
6+
* @description Layout controller
7+
* @requires $scope
8+
* @requires Setting
9+
* @requires Env
10+
**/
11+
.controller ('LayoutCtrl', function ($scope, Setting, ENV) {
12+
13+
$scope.appName = 'LB-NG-BS';
14+
$scope.apiUrl = ENV.apiUrl;
15+
$scope.appTheme = 'skin-blue';
16+
$scope.appThemes = [
17+
{
18+
'name': 'Black',
19+
'class': 'skin-black'
20+
},
21+
{
22+
'name': 'Blue',
23+
'class': 'skin-blue'
24+
}
25+
];
26+
$scope.appLayout = '';
27+
$scope.appLayouts = [
28+
{
29+
'name': 'Fixed',
30+
'class': 'fixed'
31+
},
32+
{
33+
'name': 'Scrolling',
34+
'class': 'not-fixed'
35+
}
36+
];
37+
38+
$scope.setTheme = function (theme) {
39+
$scope.appTheme = theme;
40+
};
41+
42+
$scope.setLayout = function (layout) {
43+
$scope.appLayout = layout;
44+
};
45+
46+
$scope.toggleSidebar = function () {
47+
var $ = angular.element;
48+
if ($ (window).width () <= 992) {
49+
$ ('.row-offcanvas').toggleClass ('active');
50+
$ ('.left-side').removeClass ('collapse-left');
51+
$ ('.right-side').removeClass ('strech');
52+
$ ('.row-offcanvas').toggleClass ('relative');
53+
} else {
54+
// Else, enable content streching
55+
$ ('.left-side').toggleClass ('collapse-left');
56+
$ ('.right-side').toggleClass ('strech');
57+
}
58+
};
59+
60+
$scope.settings = {};
61+
62+
Setting.find (function (settings) {
63+
settings.forEach (function (item) {
64+
$scope.settings[item.key] = item.value;
65+
});
66+
});
67+
68+
});

0 commit comments

Comments
 (0)