Yeoman generator for ngViews is working
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/index.js b/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
index 43a4bcc..182f6cd 100755
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/index.js
@@ -6,6 +6,9 @@
var config = {};
module.exports = generators.Base.extend({
+ _fistCharToUpper: function(string){
+ return string.replace(/^./, string[0].toUpperCase());
+ },
prompting: function(){
var done = this.async();
this.prompt({
@@ -38,13 +41,20 @@
{ name: config.name, author: {name:user.git.name(), email: user.git.email()} }
);
},
- index: function(){
+ indexDev: function(){
this.fs.copyTpl(
this.templatePath('src/index.html'),
this.destinationPath(`${this.config.get('folder')}/${config.name}/src/index.html`),
{ name: config.name }
);
},
+ indexProd: function(){
+ this.fs.copyTpl(
+ this.templatePath('src/prod.html'),
+ this.destinationPath(`${this.config.get('folder')}/${config.name}/src/xos${this._fistCharToUpper(config.name)}.html`),
+ { name: config.name, fileName: this._fistCharToUpper(config.name) }
+ );
+ },
mainJs: function(){
this.fs.copyTpl(
this.templatePath('src/js/main.js'),
@@ -56,7 +66,11 @@
this.fs.copy(this.templatePath('src/templates/users-list.tpl.html'), this.destinationPath(`${this.config.get('folder')}/${config.name}/src/templates/users-list.tpl.html`));
},
gulp: function(){
- this.fs.copy(this.templatePath('gulp/*.js'), this.destinationPath(`${this.config.get('folder')}/${config.name}/gulp`));
+ this.fs.copyTpl(
+ this.templatePath('gulp/*.js'),
+ this.destinationPath(`${this.config.get('folder')}/${config.name}/gulp`),
+ {name:config.name, fileName: this._fistCharToUpper(config.name)}
+ );
this.fs.copy(this.templatePath('gulpfile.js'), this.destinationPath(`${this.config.get('folder')}/${config.name}/gulpfile.js`));
}
},
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
index 40136c8..d01c070 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulp/build.js
@@ -20,8 +20,6 @@
var babel = require('gulp-babel');
var angularFilesort = require('gulp-angular-filesort');
-var TEMPLATE_HEADER = '/*This code is autogenerated from the templates files */ angular.module("<%= module %>"<%= standalone %>).run(["$templateCache", function($templateCache) {';
-
module.exports = function(options){
// empty the dist folder
@@ -37,7 +35,7 @@
.pipe(babel())
.pipe(ngmin())
.pipe(angularFilesort())
- .pipe(concat('xosContentProvider.js'))
+ .pipe(concat('xos<%= fileName %>.js'))
.pipe(uglify())
.pipe(gulp.dest(options.dist));
});
@@ -46,23 +44,28 @@
gulp.task('templates', function(){
return gulp.src("./src/templates/*.html")
.pipe(templateCache({
- module: 'xos.contentProviderApp',
- root: '../../static/templates/contentProvider/',
- templateHeader: TEMPLATE_HEADER
+ module: 'xos.<%= name %>',
+ root: 'templates/'
}))
.pipe(gulp.dest(options.scripts));
});
// copy js output to Django Folder
gulp.task('copyJs', function(){
- return gulp.src('dist/xosContentProvider.js')
- .pipe(gulp.dest('../static/js/'))
+ return gulp.src('dist/xos<%= fileName %>.js')
+ .pipe(gulp.dest(options.static + 'js/'))
});
// copy vendor js output to Django Folder
gulp.task('copyVendor', function(){
return gulp.src('dist/xosNgVendor.js')
- .pipe(gulp.dest('../static/js/vendor/'));
+ .pipe(gulp.dest(options.static + 'js/vendor/'));
+ });
+
+ // copy html index to Django Folder
+ gulp.task('copyHtml', function(){
+ return gulp.src(options.src + 'xos<%= fileName %>.html')
+ .pipe(gulp.dest(options.dashboards))
});
// minify vendor js files
@@ -86,6 +89,7 @@
'templates',
'scripts',
'copyJs',
+ 'copyHtml',
'wiredep',
'copyVendor'
);
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulpfile.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulpfile.js
index fd2db79..ad85ab2 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulpfile.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/gulpfile.js
@@ -8,7 +8,9 @@
scripts: 'src/js/',
tmp: 'src/.tmp',
dist: 'dist/',
- api: '../../ngXosLib/api/'
+ api: '../../ngXosLib/api/',
+ static: '../../static/', // this is the django static folder
+ dashboards: '../../dashboards/' // this is the django html folder
};
wrench.readdirSyncRecursive('./gulp')
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
index 7dc19d0..c366893 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/package.json
@@ -3,7 +3,10 @@
"version": "1.0.0",
"description": "Angular Application for XOS, created with generator-xos",
"scripts": {
- "start": "gulp serve"
+ "prestart": "npm install && bower install",
+ "start": "gulp serve",
+ "prebuild": "npm install && bower install",
+ "build": "gulp"
},
"keywords": [
"XOS",
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js
index d816188..4ae87f5 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/js/main.js
@@ -9,7 +9,8 @@
'ngResource',
'ngRoute',
'ngCookies',
- 'ngLodash'
+ 'ngLodash',
+ 'xos.xos'
])
.config(($interpolateProvider, $routeProvider, $resourceProvider) => {
$interpolateProvider.startSymbol('{$');
@@ -48,7 +49,7 @@
};
})
// ENDTODO
-.directive('usersList', function(){
+.directive('usersList', function(xos){
return {
restrict: 'E',
scope: {},
@@ -56,12 +57,17 @@
controllerAs: 'vm',
templateUrl: 'templates/users-list.tpl.html',
controller: function(){
- this.deleteCp = function(id){
- ContentProvider.delete({id: id}).$promise
- .then(function(){
- $location.url('/');
- });
- };
+ // creating the API object
+ const api = new xos({domain: ''});
+
+ // retrieving user list
+ api.User_List_GET()
+ .then((users) => {
+ this.users = users;
+ })
+ .catch((e) => {
+ throw new Error(e);
+ });
}
};
});
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/prod.html b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/prod.html
new file mode 100644
index 0000000..4909a29
--- /dev/null
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/prod.html
@@ -0,0 +1,8 @@
+<div ng-app="xos.<%= name %>">
+ <ng-view></ng-view>
+</div>
+
+<link rel="stylesheet" href="{{ STATIC_URL }}/css/xosLib.css">
+<script src="{{ STATIC_URL }}js/vendor/xosNgVendor.js"></script>
+<script src="{{ STATIC_URL }}js/xosApi.js"></script>
+<script src="{{ STATIC_URL }}js/xos<%= fileName %>.js"></script>
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html
index 2873029..2983ad0 100644
--- a/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html
+++ b/xos/core/xoslib/ngXosLib/generator-xos/app/templates/src/templates/users-list.tpl.html
@@ -1,4 +1,13 @@
-<div class="row-fluid">
+<div class="row">
+ <h1>Users List</h1>
+ <p>This is only an example view.</p>
+</div>
+<div class="row">
+ <div class="span4">Email</div>
+ <div class="span4">First Name</div>
+ <div class="span4">Last Name</div>
+</div>
+<div class="row" ng-repeat="user in vm.users">
<div class="span4">{{user.email}}</div>
<div class="span4">{{user.firstname}}</div>
<div class="span4">{{user.lastname}}</div>