Skip to content

Commit 26e15d4

Browse files
committed
Grunt-include-source
* Include grunt include-source * include index.tpl.html * Refatored Modules of *.module.js to *.app.js for evit conflits in auto include sources * Migrate folder module/tests for tests/module * Fix Karma * Include Grunt default process
1 parent 519c1f0 commit 26e15d4

21 files changed

Lines changed: 189 additions & 99 deletions

File tree

Gruntfile.js

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function (grunt) {
1717

1818
// Configurable paths for the application
1919
var appConfig = {
20-
app: require ('./bower.json').appPath || 'client/app',
20+
app: require ('./bower.json').appPath || 'client/app',
2121
test: require ('./bower.json').appPath || 'client/test',
2222
dist: 'dist',
2323
api: 'http://0.0.0.0:3000/api/',
@@ -58,7 +58,10 @@ module.exports = function (grunt) {
5858
tasks: ['wiredep']
5959
},
6060
js: {
61-
files: ['!<%= yeoman.app %>/modules/**/tests/**', '<%= yeoman.app %>/modules/**/{,*/}*.js'],
61+
files: [
62+
'!<%= yeoman.app %>/modules/**/tests/**',
63+
'<%= yeoman.app %>/modules/**/{,*/}*.js'
64+
],
6265
tasks: ['newer:jshint:all'],
6366
options: {
6467
livereload: '<%= connect.options.livereload %>'
@@ -226,7 +229,39 @@ module.exports = function (grunt) {
226229
]
227230
}
228231
},
229-
232+
includeSource: {
233+
options: {
234+
basePath: 'client/app',
235+
baseUrl: '',
236+
templates: {
237+
html: {
238+
js: '<script src="{filePath}"></script>',
239+
css: '<link rel="stylesheet" href="{filePath}" />'
240+
},
241+
haml: {
242+
js: '%script{src: "{filePath}"}/',
243+
css: '%link{href: "{filePath}", rel: "stylesheet"}/'
244+
},
245+
jade: {
246+
js: 'script(src="{filePath}", type="text/javascript")',
247+
css: 'link(href="{filePath}", rel="stylesheet", type="text/css")'
248+
},
249+
scss: {
250+
scss: '@import "{filePath}";',
251+
css: '@import "{filePath}";'
252+
},
253+
less: {
254+
less: '@import "{filePath}";',
255+
css: '@import "{filePath}";'
256+
}
257+
}
258+
},
259+
myTarget: {
260+
files: {
261+
'client/app/index.html': 'client/app/index.tpl.html'
262+
}
263+
}
264+
},
230265
// Automatically inject Bower components into the app
231266
wiredep: {
232267
app: {
@@ -506,7 +541,7 @@ module.exports = function (grunt) {
506541
// Load the plugin that provides the "loopback-angular" and "grunt-docular" tasks.
507542
grunt.loadNpmTasks ('grunt-loopback-angular');
508543
grunt.loadNpmTasks ('grunt-docular');
509-
grunt.loadNpmTasks('grunt-angular-gettext');
544+
grunt.loadNpmTasks ('grunt-angular-gettext');
510545

511546

512547
grunt.registerTask ('serve', 'Compile then start a connect web server', function (target) {
@@ -562,6 +597,8 @@ module.exports = function (grunt) {
562597
]);
563598

564599
grunt.registerTask ('default', [
600+
'includeSource',
601+
'wiredep',
565602
//'newer:jshint',
566603
'test',
567604
'ngconstant:development',

client/app/index.html

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<meta name="description" content="">
77
<meta name="viewport" content="width=device-width">
88
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
9+
910
<!-- build:css styles/vendor.css -->
1011
<!-- bower:css -->
1112
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
@@ -17,11 +18,11 @@
1718
<link rel="stylesheet" href="bower_components/codemirror/lib/codemirror.css" />
1819
<link rel="stylesheet" href="bower_components/codemirror/theme/monokai.css" />
1920
<!-- endbower -->
20-
2121
<!-- endbuild -->
2222
<!-- build:css styles/main.css -->
23-
<link rel="stylesheet" href="css/AdminLTE.css">
24-
<link rel="stylesheet" href="css/main.css">
23+
<link rel="stylesheet" href="css/AdminLTE.css" />
24+
<link rel="stylesheet" href="css/main.css" />
25+
<link rel="stylesheet" href="modules/core/css/core.css" />
2526
<!-- endbuild -->
2627
</head>
2728
<body class="{{getSetting('appTheme') }} {{ getSetting('appLayout') }} " ng-controller="MainCtrl">
@@ -59,8 +60,6 @@
5960
<script src="bower_components/json3/lib/json3.js"></script>
6061
<![endif]-->
6162
<!-- endbuild -->
62-
63-
6463
<!-- build:js scripts/vendor.js -->
6564
<!-- bower:js -->
6665
<script src="bower_components/jquery/dist/jquery.js"></script>
@@ -93,101 +92,84 @@
9392
<script src="bower_components/angular-elastic/elastic.js"></script>
9493
<script src="bower_components/angular-autoFields-bootstrap/autofields.min.js"></script>
9594
<script src="bower_components/angular-autoFields-bootstrap/autofields-bootstrap.min.js"></script>
96-
<script src="bower_components/angular-translate/angular-translate.js"></script>
97-
<script src="bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
98-
<script src="bower_components/angular-translate-loader-url/angular-translate-loader-url.js"></script>
9995
<script src="bower_components/angular-gettext/dist/angular-gettext.js"></script>
10096
<!-- endbower -->
101-
10297
<!-- endbuild -->
103-
10498
<!-- build:js scripts/scripts.js -->
99+
<!-- JS -->
105100
<script src="js/app.js"></script>
106-
<script src="js/lb-services.js"></script>
107101
<script src="js/config.js"></script>
102+
<script src="js/lb-services.js"></script>
108103
<script src="js/translations.js"></script>
109-
<!--CORE-->
110-
<script src="modules/core/core.module.js"></script>
111-
<script src="modules/core/config/core.routes.js"></script>
104+
<!-- MODULES -->
105+
<script src="modules/about/app.about.js"></script>
106+
<script src="modules/about/controllers/about.controller.js"></script>
107+
<script src="modules/core/app.core.js"></script>
112108
<script src="modules/core/config/core.config.js"></script>
109+
<script src="modules/core/config/core.routes.js"></script>
113110
<script src="modules/core/controllers/home.ctrl.js"></script>
114-
<script src="modules/core/controllers/main.ctrl.js"></script>
115111
<script src="modules/core/controllers/layout.ctrl.js"></script>
112+
<script src="modules/core/controllers/main.ctrl.js"></script>
116113
<script src="modules/core/controllers/router.ctrl.js"></script>
117114
<script src="modules/core/directives/admin-box.js"></script>
118115
<script src="modules/core/directives/admin-form.js"></script>
119116
<script src="modules/core/directives/admin-header.js"></script>
120117
<script src="modules/core/directives/date.js"></script>
121118
<script src="modules/core/directives/home.js"></script>
122-
<script src="modules/core/directives/small-box.directive.js"></script>
123119
<script src="modules/core/directives/navbar.js"></script>
124-
<!--Users-->
125-
<script src="modules/users/user.module.js"></script>
126-
<script src="modules/users/config/users.auth.js"></script>
127-
<script src="modules/users/config/users.routes.js"></script>
128-
<script src="modules/users/directives/login.js"></script>
129-
<script src="modules/users/directives/register.js"></script>
130-
<script src="modules/users/controllers/login.ctrl.js"></script>
131-
<script src="modules/users/controllers/register.ctrl.js"></script>
132-
<script src="modules/users/controllers/users.ctrl.js"></script>
133-
<script src="modules/users/services/appauth.service.js"></script>
134-
<!--About-->
135-
<script src="modules/about/about.module.js"></script>
136-
<script src="modules/about/controllers/about.controller.js"></script>
137-
<!--Events-->
138-
<script src="modules/events/events.module.js"></script>
120+
<script src="modules/core/directives/small-box.directive.js"></script>
121+
<script src="modules/events/app.events.js"></script>
139122
<script src="modules/events/config/events.config.js"></script>
140123
<script src="modules/events/config/events.routes.js"></script>
141124
<script src="modules/events/controllers/events.ctrl.js"></script>
142-
<!--Files-->
143-
<script src="modules/files/file.module.js"></script>
125+
<script src="modules/files/app.files.js"></script>
144126
<script src="modules/files/config/file.config.js"></script>
145127
<script src="modules/files/config/file.routes.js"></script>
146-
<script src="modules/files/controllers/upload.ctrl.js"></script>
147128
<script src="modules/files/controllers/files.ctrl.js"></script>
148-
<!--Notes-->
149-
<script src="modules/notes/notes.module.js"></script>
129+
<script src="modules/files/controllers/upload.ctrl.js"></script>
130+
<script src="modules/notes/app.notes.js"></script>
150131
<script src="modules/notes/config/notes.config.js"></script>
151132
<script src="modules/notes/config/notes.routes.js"></script>
152133
<script src="modules/notes/controllers/notes.ctrl.js"></script>
153-
<!--Pages-->
154-
<script src="modules/pages/pages.module.js"></script>
134+
<script src="modules/pages/app.pages.js"></script>
155135
<script src="modules/pages/config/pages.config.js"></script>
156136
<script src="modules/pages/config/pages.routes.js"></script>
157137
<script src="modules/pages/controllers/pages.ctrl.js"></script>
158-
<!-- Posts -->
159-
<script src="modules/posts/posts.module.js"></script>
138+
<script src="modules/posts/app.posts.js"></script>
160139
<script src="modules/posts/config/posts.config.js"></script>
161140
<script src="modules/posts/config/posts.routes.js"></script>
162141
<script src="modules/posts/controllers/posts.ctrl.js"></script>
163-
<!--Products-->
164-
<script src="modules/products/products.module.js"></script>
142+
<script src="modules/products/app.products.js"></script>
165143
<script src="modules/products/config/products.config.js"></script>
166144
<script src="modules/products/config/products.routes.js"></script>
167-
<script src="modules/products/controllers/products.ctrl.js"></script>
168145
<script src="modules/products/controllers/categories.ctrl.js"></script>
169-
170-
<!--Sandbox-->
171-
<script src="modules/sandbox/sandbox.module.js"></script>
146+
<script src="modules/products/controllers/products.ctrl.js"></script>
147+
<script src="modules/sandbox/app.sandbox.js"></script>
172148
<script src="modules/sandbox/config/sandbox.config.js"></script>
173149
<script src="modules/sandbox/config/sandbox.routes.js"></script>
174-
<script src="modules/sandbox/controllers/datepickerdemo.ctrl.js"></script>
175-
<script src="modules/sandbox/controllers/sandbox.ctrl.js"></script>
176-
<script src="modules/sandbox/controllers/sandbox.dashboard.ctrl.js"></script>
177-
<script src="modules/sandbox/controllers/sandbox.autofields.ctrl.js"></script>
178150
<script src="modules/sandbox/controllers/sandbox.alerts.ctrl.js"></script>
151+
<script src="modules/sandbox/controllers/sandbox.autofields.ctrl.js"></script>
179152
<script src="modules/sandbox/controllers/sandbox.bootstrap.alert.ctrl.js"></script>
180153
<script src="modules/sandbox/controllers/sandbox.bootstrap.tabs.ctrl.js"></script>
154+
<script src="modules/sandbox/controllers/sandbox.ctrl.js"></script>
155+
<script src="modules/sandbox/controllers/sandbox.dashboard.ctrl.js"></script>
156+
<script src="modules/sandbox/controllers/sandbox.datepickerdemo.ctrl.js"></script>
181157
<script src="modules/sandbox/controllers/sandbox.forms.ctrl.js"></script>
182158
<script src="modules/sandbox/controllers/sandbox.toast.ctrl.js"></script>
183159
<script src="modules/sandbox/controllers/sandbox.tress.ctrl.js"></script>
184-
<!--Settings-->
185-
<script src="modules/settings/settings.module.js"></script>
160+
<script src="modules/settings/app.settings.js"></script>
186161
<script src="modules/settings/config/settings.config.js"></script>
187162
<script src="modules/settings/config/settings.routes.js"></script>
188163
<script src="modules/settings/controllers/settings.ctrl.js"></script>
189-
164+
<script src="modules/users/app.users.js"></script>
165+
<script src="modules/users/config/users.auth.js"></script>
166+
<script src="modules/users/config/users.routes.js"></script>
167+
<script src="modules/users/controllers/login.ctrl.js"></script>
168+
<script src="modules/users/controllers/register.ctrl.js"></script>
169+
<script src="modules/users/controllers/users.ctrl.js"></script>
170+
<script src="modules/users/directives/login.js"></script>
171+
<script src="modules/users/directives/register.js"></script>
172+
<script src="modules/users/services/appauth.service.js"></script>
190173
<!-- endbuild -->
191-
192174
</body>
193175
</html>

client/app/index.tpl.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!doctype html>
2+
<html ng-app="loopbackApp" ng-controller="LayoutCtrl">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Admin: {{ getSetting('appName') }}</title>
6+
<meta name="description" content="">
7+
<meta name="viewport" content="width=device-width">
8+
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
9+
10+
<!-- build:css styles/vendor.css -->
11+
<!-- bower:css -->
12+
<!-- endbower -->
13+
<!-- endbuild -->
14+
<!-- build:css styles/main.css -->
15+
<!-- include: "type": "css", "files": "css/*.css" -->
16+
<!-- include: "type": "css", "files": "modules/**/*.css" -->
17+
<!-- endbuild -->
18+
</head>
19+
<body class="{{getSetting('appTheme') }} {{ getSetting('appLayout') }} " ng-controller="MainCtrl">
20+
<!--[if lt IE 7]>
21+
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
22+
your browser</a> to improve your experience.</p>
23+
<![endif]-->
24+
<div ui-view class="full-height"></div>
25+
26+
<div ng-controller="toasty-controller">
27+
<toasty-container toasty-defaults='{"timeout": 3000, "close-button":true, "sound": false}'></toasty-container>
28+
</div>
29+
30+
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
31+
<script>
32+
(function (i, s, o, g, r, a, m) {
33+
i['GoogleAnalyticsObject'] = r;
34+
i[r] = i[r] || function () {
35+
(i[r].q = i[r].q || []).push (arguments)
36+
}, i[r].l = 1 * new Date ();
37+
a = s.createElement (o),
38+
m = s.getElementsByTagName (o)[0];
39+
a.async = 1;
40+
a.src = g;
41+
m.parentNode.insertBefore (a, m)
42+
}) (window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
43+
44+
ga ('create', 'UA-XXXXX-X');
45+
ga ('send', 'pageview');
46+
</script>
47+
48+
<!-- build:js scripts/oldieshim.js -->
49+
<!--[if lt IE 9]>
50+
<script src="bower_components/es5-shim/es5-shim.js"></script>
51+
<script src="bower_components/json3/lib/json3.js"></script>
52+
<![endif]-->
53+
<!-- endbuild -->
54+
<!-- build:js scripts/vendor.js -->
55+
<!-- bower:js -->
56+
<!-- endbower -->
57+
<!-- endbuild -->
58+
<!-- build:js scripts/scripts.js -->
59+
<!-- JS -->
60+
<!-- include: "type": "js", "files": "js/**/*.js" -->
61+
<!-- MODULES -->
62+
<!-- include: "type": "js", "files": "modules/**/*.js" -->
63+
<!-- endbuild -->
64+
</body>
65+
</html>

client/app/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ angular.module('loopbackApp', [
3030
'toasty',
3131
'autofields',
3232
'gettext',
33-
'com.module.about',
3433
'com.module.core',
34+
'com.module.about',
3535
'com.module.events',
3636
'com.module.files',
3737
'com.module.notes',

client/app/modules/core/config/core.config.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
'use strict';
22
angular.module ('com.module.core')
3-
.run (function ($rootScope, gettextCatalog) {
3+
.run (function ($rootScope, Setting, gettextCatalog) {
44

5+
// Left Sidemenu
56
$rootScope.menu = [];
67

8+
// Add Sidebar Menu
79
$rootScope.addMenu = function (name, uisref, icon) {
810
$rootScope.menu.push ({
911
name: name,
@@ -12,10 +14,13 @@ angular.module ('com.module.core')
1214
});
1315
};
1416

15-
$rootScope.addMenu (gettextCatalog.getString('Dashboard'), 'app.home', 'fa-dashboard');
17+
// Add Menu Dashboard
18+
$rootScope.addMenu (gettextCatalog.getString ('Dashboard'), 'app.home', 'fa-dashboard');
1619

20+
// Dashboard
1721
$rootScope.dashboardBox = [];
1822

23+
// Add Dashboard Box
1924
$rootScope.addDashboardBox = function (name, color, icon, quantity, href) {
2025
$rootScope.dashboardBox.push ({
2126
name: name,
@@ -26,6 +31,42 @@ angular.module ('com.module.core')
2631
});
2732
};
2833

34+
// Get Settings for Database
35+
$rootScope.setSetting = function (key, value) {
36+
37+
Setting.find ({
38+
filter: {
39+
where: {
40+
key: key
41+
}
42+
}
43+
}, function (data) {
44+
45+
if (data.length) {
46+
data[0].value = value;
47+
data[0].$save ();
48+
} else {
49+
Setting.create ({
50+
key: key,
51+
value: value
52+
}, function (data) {
53+
console.log (data);
54+
});
55+
}
56+
$rootScope.loadSettings ();
57+
});
58+
};
59+
60+
// Load Settings blank
61+
$rootScope.settings = {};
62+
63+
// Get Settings for Loopback Service
64+
$rootScope.loadSettings = function () {
65+
Setting.find (function (settings) {
66+
$rootScope.settings.data = settings;
67+
});
68+
};
69+
2970
})
3071
.config (function (formlyConfigProvider) {
3172
var templates = 'modules/core/views/elements/fields/';

0 commit comments

Comments
 (0)