Fixed routing, was conflicting between apps
diff --git a/xos/core/xoslib/dashboards/xosContentProvider.html b/xos/core/xoslib/dashboards/xosContentProvider.html
index 22b0620..e632b39 100644
--- a/xos/core/xoslib/dashboards/xosContentProvider.html
+++ b/xos/core/xoslib/dashboards/xosContentProvider.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" href="/css/dev.css">
<!-- endinject -->
-<div ng-app="xos.contentProvider">
+<div id="xosContentProvider">
<div ui-view></div>
</div>
diff --git a/xos/core/xoslib/dashboards/xosSampleView.html b/xos/core/xoslib/dashboards/xosSampleView.html
new file mode 100644
index 0000000..92d6f9a
--- /dev/null
+++ b/xos/core/xoslib/dashboards/xosSampleView.html
@@ -0,0 +1,14 @@
+<!-- browserSync -->
+
+<!-- inject:css -->
+<link rel="stylesheet" href="/css/dev.css">
+<!-- endinject -->
+
+<div id="xosSampleView">
+ <div ui-view></div>
+</div>
+
+
+<!-- inject:js -->
+<script src="/../../static/js/xosSampleView.js"></script>
+<!-- endinject -->
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 ac8d19d..878e4eb 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
@@ -7,8 +7,7 @@
'ui.router',
'xos.helpers'
])
-.config(($stateProvider, $urlRouterProvider) => {
- $urlRouterProvider.otherwise('/');
+.config(($stateProvider) => {
$stateProvider
.state('user-list', {
url: '/',
diff --git a/xos/core/xoslib/ngXosViews/contentProvider/gulp/build.js b/xos/core/xoslib/ngXosViews/contentProvider/gulp/build.js
index a633fbf..e851505 100644
--- a/xos/core/xoslib/ngXosViews/contentProvider/gulp/build.js
+++ b/xos/core/xoslib/ngXosViews/contentProvider/gulp/build.js
@@ -23,6 +23,7 @@
var rename = require('gulp-rename');
var replace = require('gulp-replace');
+var TEMPLATE_FOOTER = '}]);angular.bootstrap(angular.element(\'#xosContentProvider\'), [\'xos.contentProvider\']);';
module.exports = function(options){
// delete previous builded file
@@ -50,7 +51,8 @@
return gulp.src('./src/templates/*.html')
.pipe(templateCache({
module: 'xos.contentProvider',
- root: 'templates/'
+ root: 'templates/',
+ templateFooter: TEMPLATE_FOOTER
}))
.pipe(gulp.dest(options.tmp));
});
@@ -61,6 +63,7 @@
// remove dev dependencies from html
.pipe(replace(/<!-- bower:css -->(\n.*)*\n<!-- endbower --><!-- endcss -->/, ''))
.pipe(replace(/<!-- bower:js -->(\n.*)*\n<!-- endbower --><!-- endjs -->/, ''))
+ .pipe(replace(/ng-app=".*"\s/, ''))
// injecting minified files
.pipe(
inject(
diff --git a/xos/core/xoslib/ngXosViews/contentProvider/gulp/server.js b/xos/core/xoslib/ngXosViews/contentProvider/gulp/server.js
index 722eb58..ad7c681 100644
--- a/xos/core/xoslib/ngXosViews/contentProvider/gulp/server.js
+++ b/xos/core/xoslib/ngXosViews/contentProvider/gulp/server.js
@@ -113,7 +113,7 @@
.pipe(gulp.dest(options.src));
});
- gulp.task('js-watch', ['inject'], function(){
+ gulp.task('js-watch', ['injectScript'], function(){
browserSync.reload();
});
diff --git a/xos/core/xoslib/ngXosViews/contentProvider/spec/contentprovider.test.js b/xos/core/xoslib/ngXosViews/contentProvider/spec/contentprovider.test.js
index 5a56d26..b19ce0c 100644
--- a/xos/core/xoslib/ngXosViews/contentProvider/spec/contentprovider.test.js
+++ b/xos/core/xoslib/ngXosViews/contentProvider/spec/contentprovider.test.js
@@ -16,8 +16,8 @@
httpProvider = $httpProvider;
- // mocking routeParams to pass 1 as id
- $provide.provider('$routeParams', function(){
+ // mocking stateParams to pass 1 as id
+ $provide.provider('$stateParams', function(){
/* eslint-disable no-invalid-this*/
this.$get = function(){
return {id: 1};
diff --git a/xos/core/xoslib/ngXosViews/contentProvider/src/css/dev.css b/xos/core/xoslib/ngXosViews/contentProvider/src/css/dev.css
index af92e84..1457e38 100644
--- a/xos/core/xoslib/ngXosViews/contentProvider/src/css/dev.css
+++ b/xos/core/xoslib/ngXosViews/contentProvider/src/css/dev.css
@@ -1,4 +1,4 @@
-[ng-app]{
+#xosContentProvider{
position: absolute;
top: 100px;
left: 200px;
diff --git a/xos/core/xoslib/ngXosViews/contentProvider/src/index.html b/xos/core/xoslib/ngXosViews/contentProvider/src/index.html
index ba0006c..b203c67 100644
--- a/xos/core/xoslib/ngXosViews/contentProvider/src/index.html
+++ b/xos/core/xoslib/ngXosViews/contentProvider/src/index.html
@@ -6,7 +6,7 @@
<link rel="stylesheet" href="/css/dev.css">
<!-- endinject -->
-<div ng-app="xos.contentProvider">
+<div ng-app="xos.contentProvider" id="xosContentProvider">
<div ui-view></div>
</div>
diff --git a/xos/core/xoslib/ngXosViews/contentProvider/src/js/main.js b/xos/core/xoslib/ngXosViews/contentProvider/src/js/main.js
index 256b95c..6f93c0a 100644
--- a/xos/core/xoslib/ngXosViews/contentProvider/src/js/main.js
+++ b/xos/core/xoslib/ngXosViews/contentProvider/src/js/main.js
@@ -1,10 +1,3 @@
-/* global angular */
-/* eslint-disable dot-location*/
-
-// TODO
-// - Add Cache
-// - Refactor routing with ui.router and child views (share the navigation and header)
-
'use strict';
angular.module('xos.contentProvider', [
@@ -16,14 +9,14 @@
'xos.xos'
])
.config(($stateProvider, $urlRouterProvider) => {
- $urlRouterProvider.otherwise('/');
+
$stateProvider
.state('list', {
url: '/',
template: '<content-provider-list></content-provider-list>',
})
.state('details', {
- url: '/contentProvider/:id?',
+ url: '/contentProvider/:id',
template: '<content-provider-detail></content-provider-detail>'
})
.state('cdn', {
@@ -87,11 +80,11 @@
scope: {},
templateUrl: 'templates/cp_list.html',
controller: function(){
- var _this = this;
+ var self = this;
ContentProvider.query().$promise
.then(function(cp){
- _this.contentProviderList = cp;
+ self.contentProviderList = cp;
})
.catch(function(e){
throw new Error(e);
@@ -100,13 +93,13 @@
this.deleteCp = function(id){
ContentProvider.delete({id: id}).$promise
.then(function(){
- lodash.remove(_this.contentProviderList, {id: id});
+ lodash.remove(self.contentProviderList, {id: id});
});
};
}
};
})
-.directive('contentProviderDetail', function(ContentProvider, ServiceProvider, $routeParams, $location){
+.directive('contentProviderDetail', function(ContentProvider, ServiceProvider, $stateParams, $location){
return {
restrict: 'E',
controllerAs: 'vm',
@@ -114,26 +107,26 @@
templateUrl: 'templates/cp_detail.html',
controller: function(){
this.pageName = 'detail';
- var _this = this;
+ var self = this;
- if($routeParams.id){
- ContentProvider.get({id: $routeParams.id}).$promise
+ if($stateParams.id){
+ ContentProvider.get({id: $stateParams.id}).$promise
.then(function(cp){
- _this.cp = cp;
+ self.cp = cp;
}).catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
});
}
else{
- _this.cp = new ContentProvider();
+ self.cp = new ContentProvider();
}
ServiceProvider.query().$promise
.then(function(sp){
- _this.sp = sp;
+ self.sp = sp;
});
this.saveContentProvider = function(cp){
@@ -149,7 +142,7 @@
}
p.then(function(res){
- _this.result = {
+ self.result = {
status: 1,
msg: 'Content Provider Saved'
};
@@ -158,7 +151,7 @@
}
})
.catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
@@ -167,23 +160,23 @@
}
};
})
-.directive('contentProviderCdn', function($routeParams, CdnPrefix, ContentProvider, lodash){
+.directive('contentProviderCdn', function($stateParams, CdnPrefix, ContentProvider, lodash){
return{
restrict: 'E',
controllerAs: 'vm',
scope: {},
templateUrl: 'templates/cp_cdn_prefix.html',
controller: function(){
- var _this = this;
+ var self = this;
this.pageName = 'cdn';
- if($routeParams.id){
- ContentProvider.get({id: $routeParams.id}).$promise
+ if($stateParams.id){
+ ContentProvider.get({id: $stateParams.id}).$promise
.then(function(cp){
- _this.cp = cp;
+ self.cp = cp;
}).catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
@@ -192,27 +185,27 @@
CdnPrefix.query().$promise
.then(function(prf){
- _this.prf = prf;
+ self.prf = prf;
// set the active CdnPrefix for this contentProvider
- _this.cp_prf = lodash.where(prf, {contentProvider: parseInt($routeParams.id)});
+ self.cp_prf = lodash.where(prf, {contentProvider: parseInt($stateParams.id)});
}).catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
});
this.addPrefix = function(prf){
- prf.contentProvider = $routeParams.id;
+ prf.contentProvider = $stateParams.id;
var item = new CdnPrefix(prf);
item.$save()
.then(function(res){
- _this.cp_prf.push(res);
+ self.cp_prf.push(res);
})
.catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
@@ -222,10 +215,10 @@
this.removePrefix = function(item){
item.$delete()
.then(function(){
- lodash.remove(_this.cp_prf, item);
+ lodash.remove(self.cp_prf, item);
})
.catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
@@ -234,7 +227,7 @@
}
};
})
-.directive('contentProviderServer', function($routeParams, OriginServer, ContentProvider, lodash){
+.directive('contentProviderServer', function($stateParams, OriginServer, ContentProvider, lodash){
return{
restrict: 'E',
controllerAs: 'vm',
@@ -242,43 +235,43 @@
templateUrl: 'templates/cp_origin_server.html',
controller: function(){
this.pageName = 'server';
- this.protocols = {'http': 'HTTP', 'rtmp': 'RTMP', 'rtp': 'RTP','shout': 'SHOUTcast'};
+ this.protocols = {'http': 'HTTP', 'rtmp': 'RTMP', 'rtp': 'RTP', 'shout': 'SHOUTcast'};
- var _this = this;
+ var self = this;
- if($routeParams.id){
- ContentProvider.get({id: $routeParams.id}).$promise
+ if($stateParams.id){
+ ContentProvider.get({id: $stateParams.id}).$promise
.then(function(cp){
- _this.cp = cp;
+ self.cp = cp;
}).catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
});
}
- OriginServer.query({contentProvider: $routeParams.id}).$promise
+ OriginServer.query({contentProvider: $stateParams.id}).$promise
.then(function(cp_os){
- _this.cp_os = cp_os;
+ self.cp_os = cp_os;
}).catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
});
this.addOrigin = function(os){
- os.contentProvider = $routeParams.id;
+ os.contentProvider = $stateParams.id;
var item = new OriginServer(os);
item.$save()
.then(function(res){
- _this.cp_os.push(res);
+ self.cp_os.push(res);
})
.catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
@@ -288,10 +281,10 @@
this.removeOrigin = function(item){
item.$delete()
.then(function(){
- lodash.remove(_this.cp_os, item);
+ lodash.remove(self.cp_os, item);
})
.catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
@@ -300,33 +293,33 @@
}
};
})
-.directive('contentProviderUsers', function($routeParams, ContentProvider, User, lodash){
+.directive('contentProviderUsers', function($stateParams, ContentProvider, User, lodash){
return{
restrict: 'E',
controllerAs: 'vm',
scope: {},
templateUrl: 'templates/cp_user.html',
controller: function(){
- var _this = this;
+ var self = this;
this.pageName = 'user';
this.cp_users = [];
- if($routeParams.id){
+ if($stateParams.id){
User.query().$promise
.then(function(users){
- _this.users = users;
- return ContentProvider.get({id: $routeParams.id}).$promise;
+ self.users = users;
+ return ContentProvider.get({id: $stateParams.id}).$promise;
})
.then(function(res){
- res.users = _this.populateUser(res.users, _this.users);
+ res.users = self.populateUser(res.users, self.users);
return res;
})
.then(function(cp){
- _this.cp = cp;
+ self.cp = cp;
}).catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
@@ -341,11 +334,11 @@
};
this.addUserToCp = function(user){
- _this.cp.users.push(user);
+ self.cp.users.push(user);
};
this.removeUserFromCp = function(user){
- lodash.remove(_this.cp.users, user);
+ lodash.remove(self.cp.users, user);
};
this.saveContentProvider = function(cp){
@@ -356,16 +349,16 @@
cp.$update()
.then(function(res){
- _this.cp.users = _this.populateUser(res.users, _this.users);
+ self.cp.users = self.populateUser(res.users, self.users);
- _this.result = {
+ self.result = {
status: 1,
msg: 'Content Provider Saved'
};
})
.catch(function(e){
- _this.result = {
+ self.result = {
status: 0,
msg: e.data.detail
};
diff --git a/xos/core/xoslib/ngXosViews/contentProvider/src/templates/cp_list.html b/xos/core/xoslib/ngXosViews/contentProvider/src/templates/cp_list.html
index 3303564..e54ebe6 100644
--- a/xos/core/xoslib/ngXosViews/contentProvider/src/templates/cp_list.html
+++ b/xos/core/xoslib/ngXosViews/contentProvider/src/templates/cp_list.html
@@ -11,7 +11,7 @@
</thead>
<tr ng-repeat="item in vm.contentProviderList">
<td>
- <a href="#/contentProvider/{$ item.id $}">{$ item.humanReadableName $}</a>
+ <a ui-sref="details({ id: item.id })">{$ item.humanReadableName $}</a>
</td>
<td>
{$ item.description $}
diff --git a/xos/core/xoslib/ngXosViews/sampleView/.bowerrc b/xos/core/xoslib/ngXosViews/sampleView/.bowerrc
new file mode 100644
index 0000000..e491038
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/.bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory": "src/vendor/"
+}
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosViews/sampleView/.eslintrc b/xos/core/xoslib/ngXosViews/sampleView/.eslintrc
new file mode 100644
index 0000000..c852748
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/.eslintrc
@@ -0,0 +1,42 @@
+{
+ "ecmaFeatures": {
+ "blockBindings": true,
+ "forOf": true,
+ "destructuring": true,
+ "arrowFunctions": true,
+ "templateStrings": true
+ },
+ "env": {
+ "browser": true,
+ "node": true,
+ "es6": true
+ },
+ "plugins": [
+ //"angular"
+ ],
+ "rules": {
+ "quotes": [2, "single"],
+ "camelcase": [1, {"properties": "always"}],
+ "no-underscore-dangle": 1,
+ "eqeqeq": [2, "smart"],
+ "no-alert": 1,
+ "key-spacing": [1, { "beforeColon": false, "afterColon": true }],
+ "indent": [2, 2],
+ "no-irregular-whitespace": 1,
+ "eol-last": 0,
+ "max-nested-callbacks": [2, 4],
+ "comma-spacing": [1, {"before": false, "after": true}],
+ "no-trailing-spaces": [1, { skipBlankLines: true }],
+ "no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
+ "new-cap": 0,
+
+ //"angular/ng_module_name": [2, '/^xos\.*[a-z]*$/'],
+ //"angular/ng_controller_name": [2, '/^[a-z].*Ctrl$/'],
+ //"angular/ng_service_name": [2, '/^[A-Z].*Service$/'],
+ //"angular/ng_directive_name": [2, '/^[a-z]+[[A-Z].*]*$/'],
+ //"angular/ng_di": [0, "function or array"]
+ },
+ "globals" :{
+ "angular": true
+ }
+}
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosViews/sampleView/.gitignore b/xos/core/xoslib/ngXosViews/sampleView/.gitignore
new file mode 100644
index 0000000..567aee4
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/.gitignore
@@ -0,0 +1,6 @@
+dist/
+src/vendor
+.tmp
+node_modules
+npm-debug.log
+dist/
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosViews/sampleView/bower.json b/xos/core/xoslib/ngXosViews/sampleView/bower.json
new file mode 100644
index 0000000..2dd8883
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/bower.json
@@ -0,0 +1,29 @@
+{
+ "name": "xos-sampleView",
+ "version": "0.0.0",
+ "authors": [
+ "Matteo Scandolo <matteo.scandolo@link-me.it>"
+ ],
+ "description": "The sampleView view",
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "static/js/vendor/",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ },
+ "devDependencies": {
+ "jquery": "~2.1.4",
+ "angular-mocks": "~1.4.7",
+ "angular": "~1.4.7",
+ "angular-ui-router": "~0.2.15",
+ "angular-cookies": "~1.4.7",
+ "angular-resource": "~1.4.7",
+ "ng-lodash": "~0.3.0",
+ "bootstrap-css": "2.3.2"
+ }
+}
diff --git a/xos/core/xoslib/ngXosViews/sampleView/gulp/build.js b/xos/core/xoslib/ngXosViews/sampleView/gulp/build.js
new file mode 100644
index 0000000..7e8e5a1
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/gulp/build.js
@@ -0,0 +1,115 @@
+'use strict';
+
+// BUILD
+//
+// The only purpose of this gulpfile is to build a XOS view and copy the correct files into
+// .html => dashboards
+// .js (minified and concat) => static/js
+//
+// The template are parsed and added to js with angular $templateCache
+
+var gulp = require('gulp');
+var ngAnnotate = require('gulp-ng-annotate');
+var uglify = require('gulp-uglify');
+var templateCache = require('gulp-angular-templatecache');
+var runSequence = require('run-sequence');
+var concat = require('gulp-concat');
+var del = require('del');
+var wiredep = require('wiredep');
+var angularFilesort = require('gulp-angular-filesort');
+var _ = require('lodash');
+var eslint = require('gulp-eslint');
+var inject = require('gulp-inject');
+var rename = require('gulp-rename');
+var replace = require('gulp-replace');
+
+var TEMPLATE_FOOTER = '}]);angular.bootstrap(angular.element(\'#xosSampleView\'), [\'xos.sampleView\']);';
+module.exports = function(options){
+
+ // delete previous builded file
+ gulp.task('clean', function(){
+ return del(
+ [options.dashboards + 'xosSampleView.html'],
+ {force: true}
+ );
+ });
+
+ // compile and minify scripts
+ gulp.task('scripts', function() {
+ return gulp.src([
+ options.tmp + '**/*.js'
+ ])
+ .pipe(ngAnnotate())
+ .pipe(angularFilesort())
+ .pipe(concat('xosSampleView.js'))
+ .pipe(uglify())
+ .pipe(gulp.dest(options.static + 'js/'));
+ });
+
+ // set templates in cache
+ gulp.task('templates', function(){
+ return gulp.src('./src/templates/*.html')
+ .pipe(templateCache({
+ module: 'xos.sampleView',
+ root: 'templates/',
+ templateFooter: TEMPLATE_FOOTER
+ }))
+ .pipe(gulp.dest(options.tmp));
+ });
+
+ // copy html index to Django Folder
+ gulp.task('copyHtml', ['clean'], function(){
+ return gulp.src(options.src + 'index.html')
+ // remove dev dependencies from html
+ .pipe(replace(/<!-- bower:css -->(\n.*)*\n<!-- endbower --><!-- endcss -->/, ''))
+ .pipe(replace(/<!-- bower:js -->(\n.*)*\n<!-- endbower --><!-- endjs -->/, ''))
+ .pipe(replace(/ng-app=".*"\s/, ''))
+ // injecting minified files
+ .pipe(
+ inject(
+ gulp.src([
+ options.static + 'js/vendor/xosSampleViewVendor.js',
+ options.static + 'js/xosSampleView.js'
+ ])
+ )
+ )
+ .pipe(rename('xosSampleView.html'))
+ .pipe(gulp.dest(options.dashboards));
+ });
+
+ // minify vendor js files
+ gulp.task('wiredep', function(){
+ var bowerDeps = wiredep().js;
+ if(!bowerDeps){
+ return;
+ }
+
+ // remove angular (it's already loaded)
+ _.remove(bowerDeps, function(dep){
+ return dep.indexOf('angular/angular.js') !== -1;
+ });
+
+ return gulp.src(bowerDeps)
+ .pipe(concat('xosSampleViewVendor.js'))
+ .pipe(uglify())
+ .pipe(gulp.dest(options.static + 'js/vendor/'));
+ });
+
+ gulp.task('lint', function () {
+ return gulp.src(['src/js/**/*.js'])
+ .pipe(eslint())
+ .pipe(eslint.format())
+ .pipe(eslint.failAfterError());
+ });
+
+ gulp.task('build', function() {
+ runSequence(
+ 'templates',
+ 'babel',
+ 'scripts',
+ 'wiredep',
+ 'copyHtml',
+ 'cleanTmp'
+ );
+ });
+};
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosViews/sampleView/gulp/server.js b/xos/core/xoslib/ngXosViews/sampleView/gulp/server.js
new file mode 100644
index 0000000..ad7c681
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/gulp/server.js
@@ -0,0 +1,132 @@
+'use strict';
+
+var gulp = require('gulp');
+var browserSync = require('browser-sync').create();
+var inject = require('gulp-inject');
+var runSequence = require('run-sequence');
+var angularFilesort = require('gulp-angular-filesort');
+var babel = require('gulp-babel');
+var wiredep = require('wiredep').stream;
+var httpProxy = require('http-proxy');
+var del = require('del');
+
+var proxy = httpProxy.createProxyServer({
+ target: 'http://0.0.0.0:9999'
+});
+
+
+proxy.on('error', function(error, req, res) {
+ res.writeHead(500, {
+ 'Content-Type': 'text/plain'
+ });
+
+ console.error('[Proxy]', error);
+});
+
+module.exports = function(options){
+
+ // open in browser with sync and proxy to 0.0.0.0
+ gulp.task('browser', function() {
+ browserSync.init({
+ // reloadDelay: 500,
+ // logLevel: 'debug',
+ // logConnections: true,
+ snippetOptions: {
+ rule: {
+ match: /<!-- browserSync -->/i
+ }
+ },
+ server: {
+ baseDir: options.src,
+ routes: {
+ '/api': options.api,
+ '/xosHelpers/src': options.helpers
+ },
+ middleware: function(req, res, next){
+ if(
+ req.url.indexOf('/xos/') !== -1 ||
+ req.url.indexOf('/xoslib/') !== -1 ||
+ req.url.indexOf('/hpcapi/') !== -1
+ ){
+ proxy.web(req, res);
+ }
+ else{
+ next();
+ }
+ }
+ }
+ });
+
+ gulp.watch(options.src + 'js/**/*.js', ['js-watch']);
+ gulp.watch(options.src + 'vendor/**/*.js', ['bower'], function(){
+ browserSync.reload();
+ });
+ gulp.watch(options.src + '**/*.html', function(){
+ browserSync.reload();
+ });
+ });
+
+ // transpile js with sourceMaps
+ gulp.task('babel', function(){
+ return gulp.src(options.scripts + '**/*.js')
+ .pipe(babel({sourceMaps: true}))
+ .pipe(gulp.dest(options.tmp));
+ });
+
+ // inject scripts
+ gulp.task('injectScript', ['cleanTmp', 'babel'], function(){
+ return gulp.src(options.src + 'index.html')
+ .pipe(
+ inject(
+ gulp.src([
+ options.tmp + '**/*.js',
+ options.api + '*.js',
+ options.helpers + '**/*.js'
+ ])
+ .pipe(angularFilesort()),
+ {
+ ignorePath: [options.src, '/../../ngXosLib']
+ }
+ )
+ )
+ .pipe(gulp.dest(options.src));
+ });
+
+ // inject CSS
+ gulp.task('injectCss', function(){
+ return gulp.src(options.src + 'index.html')
+ .pipe(
+ inject(
+ gulp.src(options.src + 'css/*.css'),
+ {
+ ignorePath: [options.src]
+ }
+ )
+ )
+ .pipe(gulp.dest(options.src));
+ });
+
+ // inject bower dependencies with wiredep
+ gulp.task('bower', function () {
+ return gulp.src(options.src + 'index.html')
+ .pipe(wiredep({devDependencies: true}))
+ .pipe(gulp.dest(options.src));
+ });
+
+ gulp.task('js-watch', ['injectScript'], function(){
+ browserSync.reload();
+ });
+
+ gulp.task('cleanTmp', function(){
+ return del([options.tmp + '**/*']);
+ });
+
+ gulp.task('serve', function() {
+ runSequence(
+ 'bower',
+ 'injectScript',
+ 'injectCss',
+ ['browser']
+ );
+ });
+};
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosViews/sampleView/gulpfile.js b/xos/core/xoslib/ngXosViews/sampleView/gulpfile.js
new file mode 100644
index 0000000..f114774
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/gulpfile.js
@@ -0,0 +1,24 @@
+'use strict';
+
+var gulp = require('gulp');
+var wrench = require('wrench');
+
+var options = {
+ src: 'src/',
+ scripts: 'src/js/',
+ tmp: 'src/.tmp',
+ dist: 'dist/',
+ api: '../../ngXosLib/api/',
+ helpers: '../../ngXosLib/xosHelpers/src/',
+ static: '../../static/', // this is the django static folder
+ dashboards: '../../dashboards/' // this is the django html folder
+};
+
+wrench.readdirSyncRecursive('./gulp')
+.map(function(file) {
+ require('./gulp/' + file)(options);
+});
+
+gulp.task('default', function () {
+ gulp.start('build');
+});
diff --git a/xos/core/xoslib/ngXosViews/sampleView/karma.conf.js b/xos/core/xoslib/ngXosViews/sampleView/karma.conf.js
new file mode 100644
index 0000000..83d3f63
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/karma.conf.js
@@ -0,0 +1,88 @@
+// Karma configuration
+// Generated on Tue Oct 06 2015 09:27:10 GMT+0000 (UTC)
+
+/* eslint indent: [2,2], quotes: [2, "single"]*/
+
+/*eslint-disable*/
+var wiredep = require('wiredep');
+var path = require('path');
+
+var bowerComponents = wiredep( {devDependencies: true} )[ 'js' ].map(function( file ){
+ return path.relative(process.cwd(), file);
+});
+
+module.exports = function(config) {
+/*eslint-enable*/
+ config.set({
+
+ // base path that will be used to resolve all patterns (eg. files, exclude)
+ basePath: '',
+
+
+ // frameworks to use
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+ frameworks: ['jasmine'],
+
+
+ // list of files / patterns to load in the browser
+ files: bowerComponents.concat([
+ '../../static/js/xosApi.js',
+ '../../static/js/vendor/ngXosHelpers.js',
+ 'src/js/**/*.js',
+ 'spec/**/*.mock.js',
+ 'spec/**/*.test.js',
+ 'src/**/*.html'
+ ]),
+
+
+ // list of files to exclude
+ exclude: [
+ ],
+
+
+ // preprocess matching files before serving them to the browser
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+ preprocessors: {
+ 'src/js/**/*.js': ['babel'],
+ 'spec/**/*.test.js': ['babel'],
+ 'src/**/*.html': ['ng-html2js']
+ },
+
+ ngHtml2JsPreprocessor: {
+ stripPrefix: 'src/', //strip the src path from template url (http://stackoverflow.com/questions/22869668/karma-unexpected-request-when-testing-angular-directive-even-with-ng-html2js)
+ moduleName: 'templates' // define the template module name
+ },
+
+ // test results reporter to use
+ // possible values: 'dots', 'progress'
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
+ reporters: ['mocha'],
+
+
+ // web server port
+ port: 9876,
+
+
+ // enable / disable colors in the output (reporters and logs)
+ colors: true,
+
+
+ // level of logging
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+ logLevel: config.LOG_INFO,
+
+
+ // enable / disable watching file and executing tests whenever any file changes
+ autoWatch: true,
+
+
+ // start these browsers
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+ browsers: ['PhantomJS'],
+
+
+ // Continuous Integration mode
+ // if true, Karma captures browsers, runs the tests and exits
+ singleRun: false
+ });
+};
diff --git a/xos/core/xoslib/ngXosViews/sampleView/package.json b/xos/core/xoslib/ngXosViews/sampleView/package.json
new file mode 100644
index 0000000..1cb8d7f
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "xos-sampleView",
+ "version": "1.0.0",
+ "description": "Angular Application for XOS, created with generator-xos",
+ "scripts": {
+ "prestart": "npm install && bower install",
+ "start": "gulp serve",
+ "prebuild": "npm install && bower install",
+ "build": "gulp",
+ "test": "karma start",
+ "lint": "eslint src/js/"
+ },
+ "keywords": [
+ "XOS",
+ "Angular",
+ "XOSlib"
+ ],
+ "author": "Matteo Scandolo",
+ "license": "MIT",
+ "dependencies": {},
+ "devDependencies": {
+ "browser-sync": "^2.9.11",
+ "del": "^2.0.2",
+ "gulp": "^3.9.0",
+ "gulp-angular-filesort": "^1.1.1",
+ "gulp-angular-templatecache": "^1.8.0",
+ "gulp-babel": "^5.3.0",
+ "gulp-concat": "^2.6.0",
+ "gulp-inject": "^3.0.0",
+ "gulp-minify-html": "^1.0.4",
+ "gulp-rename": "^1.2.2",
+ "gulp-replace": "^0.5.4",
+ "gulp-uglify": "^1.4.2",
+ "http-proxy": "^1.12.0",
+ "proxy-middleware": "^0.15.0",
+ "run-sequence": "^1.1.4",
+ "wiredep": "^3.0.0-beta",
+ "wrench": "^1.5.8",
+ "gulp-ng-annotate": "^1.1.0",
+ "lodash": "^3.10.1",
+ "eslint": "^1.8.0",
+ "eslint-plugin-angular": "linkmesrl/eslint-plugin-angular",
+ "gulp-eslint": "^1.0.0"
+ }
+}
diff --git a/xos/core/xoslib/ngXosViews/sampleView/spec/sample.test.js b/xos/core/xoslib/ngXosViews/sampleView/spec/sample.test.js
new file mode 100644
index 0000000..c169d10
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/spec/sample.test.js
@@ -0,0 +1,37 @@
+'use strict';
+
+describe('The User List', () => {
+
+ var scope, element, isolatedScope, httpBackend;
+
+ beforeEach(module('xos.sampleView'));
+ beforeEach(module('templates'));
+
+ beforeEach(inject(function($httpBackend, $compile, $rootScope){
+
+ httpBackend = $httpBackend;
+ // Setting up mock request
+ $httpBackend.expectGET('/xos/users/?no_hyperlinks=1').respond([
+ {
+ email: 'matteo.scandolo@link-me.it',
+ firstname: 'Matteo',
+ lastname: 'Scandolo'
+ }
+ ]);
+
+ scope = $rootScope.$new();
+ element = angular.element('<users-list></users-list>');
+ $compile(element)(scope);
+ scope.$digest();
+ isolatedScope = element.isolateScope().vm;
+ }));
+
+ it('should load 1 users', () => {
+ httpBackend.flush();
+ expect(isolatedScope.users.length).toBe(1);
+ expect(isolatedScope.users[0].email).toEqual('matteo.scandolo@link-me.it');
+ expect(isolatedScope.users[0].firstname).toEqual('Matteo');
+ expect(isolatedScope.users[0].lastname).toEqual('Scandolo');
+ });
+
+});
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosViews/sampleView/src/css/dev.css b/xos/core/xoslib/ngXosViews/sampleView/src/css/dev.css
new file mode 100644
index 0000000..74330ad
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/src/css/dev.css
@@ -0,0 +1,5 @@
+#xosSampleView{
+ position: absolute;
+ top: 100px;
+ left: 200px;
+}
\ No newline at end of file
diff --git a/xos/core/xoslib/ngXosViews/sampleView/src/index.html b/xos/core/xoslib/ngXosViews/sampleView/src/index.html
new file mode 100644
index 0000000..b745fa6
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/src/index.html
@@ -0,0 +1,32 @@
+<!-- browserSync -->
+<!-- bower:css -->
+<link rel="stylesheet" href="vendor/bootstrap-css/css/bootstrap.css" />
+<!-- endbower --><!-- endcss -->
+<!-- inject:css -->
+<link rel="stylesheet" href="/css/dev.css">
+<!-- endinject -->
+
+<div ng-app="xos.sampleView" id="xosSampleView">
+ <div ui-view></div>
+</div>
+
+<!-- bower:js -->
+<script src="vendor/jquery/dist/jquery.js"></script>
+<script src="vendor/angular/angular.js"></script>
+<script src="vendor/angular-mocks/angular-mocks.js"></script>
+<script src="vendor/angular-ui-router/release/angular-ui-router.js"></script>
+<script src="vendor/angular-cookies/angular-cookies.js"></script>
+<script src="vendor/angular-resource/angular-resource.js"></script>
+<script src="vendor/ng-lodash/build/ng-lodash.js"></script>
+<script src="vendor/bootstrap-css/js/bootstrap.js"></script>
+<!-- endbower --><!-- endjs -->
+<!-- inject:js -->
+<script src="/xosHelpers/src/xosHelpers.module.js"></script>
+<script src="/xosHelpers/src/services/noHyperlinks.interceptor.js"></script>
+<script src="/xosHelpers/src/services/csrfToken.interceptor.js"></script>
+<script src="/xosHelpers/src/services/api.services.js"></script>
+<script src="/api/ng-xoslib.js"></script>
+<script src="/api/ng-xos.js"></script>
+<script src="/api/ng-hpcapi.js"></script>
+<script src="/.tmp/main.js"></script>
+<!-- endinject -->
diff --git a/xos/core/xoslib/ngXosViews/sampleView/src/js/main.js b/xos/core/xoslib/ngXosViews/sampleView/src/js/main.js
new file mode 100644
index 0000000..2c42227
--- /dev/null
+++ b/xos/core/xoslib/ngXosViews/sampleView/src/js/main.js
@@ -0,0 +1,39 @@
+'use strict';
+
+angular.module('xos.sampleView', [
+ 'ngResource',
+ 'ngCookies',
+ 'ngLodash',
+ 'ui.router',
+ 'xos.helpers'
+])
+.config(($stateProvider) => {
+
+ $stateProvider
+ .state('user-list', {
+ url: '/',
+ template: '<users-list></users-list>'
+ });
+})
+.config(function($httpProvider){
+ $httpProvider.interceptors.push('NoHyperlinks');
+})
+.directive('usersList', function(){
+ return {
+ restrict: 'E',
+ scope: {},
+ bindToController: true,
+ controllerAs: 'vm',
+ templateUrl: 'templates/users-list.tpl.html',
+ controller: function(XosApi){
+ // retrieving user list
+ XosApi.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/ngXosViews/contentProvider/src/templates/users-list.tpl.html b/xos/core/xoslib/ngXosViews/sampleView/src/templates/users-list.tpl.html
similarity index 100%
rename from xos/core/xoslib/ngXosViews/contentProvider/src/templates/users-list.tpl.html
rename to xos/core/xoslib/ngXosViews/sampleView/src/templates/users-list.tpl.html
diff --git a/xos/core/xoslib/static/js/xosContentProvider.js b/xos/core/xoslib/static/js/xosContentProvider.js
index 5e39995..219cbca 100644
--- a/xos/core/xoslib/static/js/xosContentProvider.js
+++ b/xos/core/xoslib/static/js/xosContentProvider.js
@@ -1 +1 @@
-"use strict";angular.module("xos.contentProvider",["ngResource","ngCookies","ngLodash","xos.helpers","ui.router","xos.xos"]).config(["$stateProvider","$urlRouterProvider",function(n,e){e.otherwise("/"),n.state("list",{url:"/",template:"<content-provider-list></content-provider-list>"}).state("details",{url:"/contentProvider/:id?",template:"<content-provider-detail></content-provider-detail>"}).state("cdn",{url:"/contentProvider/:id/cdn_prefix",template:"<content-provider-cdn></content-provider-cdn>"}).state("server",{url:"/contentProvider/:id/origin_server",template:"<content-provider-server></content-provider-server>"}).state("users",{url:"/contentProvider/:id/users",template:"<content-provider-users></content-provider-users>"})}]).config(["$httpProvider",function(n){n.interceptors.push("SetCSRFToken"),n.interceptors.push("NoHyperlinks")}]).service("ContentProvider",["$resource",function(n){return n("/hpcapi/contentproviders/:id/",{id:"@id"},{update:{method:"PUT"}})}]).service("ServiceProvider",["$resource",function(n){return n("/hpcapi/serviceproviders/:id/",{id:"@id"})}]).service("CdnPrefix",["$resource",function(n){return n("/hpcapi/cdnprefixs/:id/",{id:"@id"})}]).service("OriginServer",["$resource",function(n){return n("/hpcapi/originservers/:id/",{id:"@id"})}]).service("User",["$resource",function(n){return n("/xos/users/:id/",{id:"@id"})}]).directive("cpActions",["ContentProvider","$location",function(n,e){return{restrict:"E",scope:{id:"=id"},bindToController:!0,controllerAs:"vm",templateUrl:"templates/cp_actions.html",controller:function(){this.deleteCp=function(t){n["delete"]({id:t}).$promise.then(function(){e.url("/")})}}}}]).directive("contentProviderList",["ContentProvider","lodash",function(n,e){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_list.html",controller:function(){var t=this;n.query().$promise.then(function(n){t.contentProviderList=n})["catch"](function(n){throw new Error(n)}),this.deleteCp=function(s){n["delete"]({id:s}).$promise.then(function(){e.remove(t.contentProviderList,{id:s})})}}}}]).directive("contentProviderDetail",["ContentProvider","ServiceProvider","$routeParams","$location",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_detail.html",controller:function(){this.pageName="detail";var i=this;t.id?n.get({id:t.id}).$promise.then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}):i.cp=new n,e.query().$promise.then(function(n){i.sp=n}),this.saveContentProvider=function(n){var e,t=!1;n.id?e=n.$update():(t=!0,n.name=n.humanReadableName,e=n.$save()),e.then(function(n){i.result={status:1,msg:"Content Provider Saved"},t&&s.url("contentProvider/"+n.id+"/")})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]).directive("contentProviderCdn",["$routeParams","CdnPrefix","ContentProvider","lodash",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_cdn_prefix.html",controller:function(){var i=this;this.pageName="cdn",n.id&&t.get({id:n.id}).$promise.then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),e.query().$promise.then(function(e){i.prf=e,i.cp_prf=s.where(e,{contentProvider:parseInt(n.id)})})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),this.addPrefix=function(t){t.contentProvider=n.id;var s=new e(t);s.$save().then(function(n){i.cp_prf.push(n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})},this.removePrefix=function(n){n.$delete().then(function(){s.remove(i.cp_prf,n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]).directive("contentProviderServer",["$routeParams","OriginServer","ContentProvider","lodash",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_origin_server.html",controller:function(){this.pageName="server",this.protocols={http:"HTTP",rtmp:"RTMP",rtp:"RTP",shout:"SHOUTcast"};var i=this;n.id&&t.get({id:n.id}).$promise.then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),e.query({contentProvider:n.id}).$promise.then(function(n){i.cp_os=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),this.addOrigin=function(t){t.contentProvider=n.id;var s=new e(t);s.$save().then(function(n){i.cp_os.push(n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})},this.removeOrigin=function(n){n.$delete().then(function(){s.remove(i.cp_os,n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]).directive("contentProviderUsers",["$routeParams","ContentProvider","User","lodash",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_user.html",controller:function(){var i=this;this.pageName="user",this.cp_users=[],n.id&&t.query().$promise.then(function(t){return i.users=t,e.get({id:n.id}).$promise}).then(function(n){return n.users=i.populateUser(n.users,i.users),n}).then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),this.populateUser=function(n,e){for(var t=0;t<n.length;t++)n[t]=s.find(e,{id:n[t]});return n},this.addUserToCp=function(n){i.cp.users.push(n)},this.removeUserFromCp=function(n){s.remove(i.cp.users,n)},this.saveContentProvider=function(n){n.users=s.pluck(n.users,"id"),n.$update().then(function(n){i.cp.users=i.populateUser(n.users,i.users),i.result={status:1,msg:"Content Provider Saved"}})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]),angular.module("xos.contentProvider").run(["$templateCache",function(n){n.put("templates/cp_actions.html",'<a href="#/" class="btn btn-default">\n <i class="icon icon-arrow-left"></i>Back\n</a>\n<a href="#/contentProvider/" class="btn btn-success">\n <i class="icon icon-plus"></i>Create\n</a>\n<a ng-click="vm.deleteCp(vm.id)" class="btn btn-danger">\n <i class="icon icon-remove"></i>Remove\n</a>'),n.put("templates/cp_cdn_prefix.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div class="span10">\n <div ng-repeat="item in vm.cp_prf" class="well">\n <div class="row-fluid">\n <div class="span4">\n {{item.humanReadableName}}\n </div>\n <div class="span6">\n <!-- TODO show the name instead that id -->\n {{item.defaultOriginServer}}\n </div>\n <div class="span2">\n <a ng-click="vm.removePrefix(item)" class="btn btn-danger pull-right">\n <i class="icon icon-remove"></i>\n </a>\n </div>\n </div>\n </div>\n <hr>\n <form ng-submit="vm.addPrefix(vm.new_prf)">\n <div class="row-fluid">\n <div class="span4">\n <label>Prefix</label>\n <input type="text" ng-model="vm.new_prf.prefix" required style="max-width: 90%">\n </div>\n <div class="span6">\n <label>Default Origin Server</label>\n <select ng-model="vm.new_prf.defaultOriginServer" style="max-width: 100%">\n <option ng-repeat="prf in vm.prf" ng-value="prf.id">{$ prf.humanReadableName $}</option>\n </select>\n </div>\n <div class="span2 text-right">\n <button class="btn btn-success margin-wells">\n <i class="icon icon-plus"></i>\n </button>\n </div>\n </div>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>'),n.put("templates/cp_detail.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div ng-show="vm.cp.id" class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div ng-class="{span10: vm.cp.id, span12: !vm.cp.id}">\n <!-- TODO hide form on not found -->\n <form ng-submit="vm.saveContentProvider(vm.cp)">\n <fieldset>\n <div class="row-fluid">\n <div class="span6">\n <label>Name:</label>\n <input type="text" ng-model="vm.cp.humanReadableName" required/>\n </div>\n <div class="span6">\n <label class="checkbox">\n <input type="checkbox" ng-model="vm.cp.enabled" /> Enabled\n </label>\n </div>\n </div>\n <div class="row-fluid">\n <div class="span12">\n <label>Description</label>\n <textarea style="width: 100%" ng-model="vm.cp.description"></textarea>\n </div>\n </div>\n <div class="row-fluid">\n <div class="span12">\n <label>Service provider</label>\n <select required ng-model="vm.cp.serviceProvider" ng-options="sp.id as sp.humanReadableName for sp in vm.sp"></select>\n </div>\n </div>\n <div class="row-fluid">\n <div class="span12">\n <button class="btn btn-success">\n <span ng-show="vm.cp.id">Save</span>\n <span ng-show="!vm.cp.id">Create</span>\n </button>\n </div>\n </div>\n </fieldset>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>'),n.put("templates/cp_list.html",'<table class="table table-striped" ng-show="vm.contentProviderList.length > 0">\n <thead>\n <tr>\n <th>\n Name\n </th>\n <th>Description</th>\n <th>Status</th>\n <th></th>\n </tr>\n </thead>\n <tr ng-repeat="item in vm.contentProviderList">\n <td>\n <a href="#/contentProvider/{$ item.id $}">{$ item.humanReadableName $}</a>\n </td>\n <td>\n {$ item.description $}\n </td>\n <td>\n {$ item.enabled $}\n </td>\n <td class="text-right">\n <a ng-click="vm.deleteCp(item.id)" class="btn btn-danger"><i class="icon icon-remove"></i></a></td>\n </tr>\n</table>\n<div class="alert alert-error" ng-show="vm.contentProviderList.length == 0">\n No Content Provider defined\n</div>\n\n<div class="row">\n <div class="span12 text-right">\n <a class="btn btn-success"href="#/contentProvider/">Create</a>\n </div>\n</div>'),n.put("templates/cp_origin_server.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div class="span10">\n <div ng-repeat="item in vm.cp_os" class="well">\n <div class="row-fluid">\n <div class="span4">\n {{item.humanReadableName}}\n </div>\n <div class="span6">\n <!-- TODO shoe the name instead that url -->\n {{item.defaultOriginServer}}\n </div>\n <div class="span2">\n <a ng-click="vm.removeOrigin(item)" class="btn btn-danger pull-right">\n <i class="icon icon-remove"></i>\n </a>\n </div>\n </div>\n </div>\n <hr>\n <form ng-submit="vm.addOrigin(vm.new_os)">\n <div class="row-fluid">\n <div class="span4">\n <label>Protocol</label>\n <select ng-model="vm.new_os.protocol" ng-options="k as v for (k,v) in vm.protocols" style="max-width: 100%;"></select>\n </div>\n <div class="span6">\n <label>Url</label>\n <input type="text" ng-model="vm.new_os.url" required>\n </div>\n <div class="span2 text-right">\n <button class="btn btn-success margin-wells">\n <i class="icon icon-plus"></i>\n </button>\n </div>\n </div>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>'),n.put("templates/cp_side_nav.html",'<ul class="nav nav-list">\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'detail\'}" href="#/contentProvider/{$ vm.cp.id $}">Details</a>\n </li>\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'cdn\'}" href="#/contentProvider/{$ vm.cp.id $}/cdn_prefix">Cdn Prexix</a>\n </li>\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'server\'}" href="#/contentProvider/{$ vm.cp.id $}/origin_server">Origin Server</a>\n </li>\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'user\'}" href="#/contentProvider/{$ vm.cp.id $}/users">Users</a>\n </li>\n</ul>'),n.put("templates/cp_user.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div class="span10">\n <div ng-repeat="item in vm.cp.users" class="well">\n <div class="row-fluid">\n <div class="span3">\n {{item.firstname}}\n </div>\n <div class="span3">\n {{item.lastname}}\n </div>\n <div class="span4">\n {{item.email}}\n </div>\n <div class="span2">\n <a ng-click="vm.removeUserFromCp(item)" class="btn btn-danger pull-right">\n <i class="icon icon-remove"></i>\n </a>\n </div>\n </div>\n </div>\n <hr>\n <form ng-submit="vm.saveContentProvider(vm.cp)">\n <div class="row-fluid">\n <div class="span8">\n <label>Select user:</label>\n <select ng-model="vm.user" ng-options="u as u.username for u in vm.users" ng-change="vm.addUserToCp(vm.user)"></select>\n </div> \n <div class="span4 text-right">\n <button class="btn btn-success margin-wells">\n Save\n </button>\n </div>\n </div>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>'),n.put("templates/users-list.tpl.html",'<div class="row">\n <h1>Users List</h1>\n <p>This is only an example view.</p>\n</div>\n<div class="row">\n <div class="span4">Email</div>\n <div class="span4">First Name</div>\n <div class="span4">Last Name</div>\n</div> \n<div class="row" ng-repeat="user in vm.users">\n <div class="span4">{{user.email}}</div>\n <div class="span4">{{user.firstname}}</div>\n <div class="span4">{{user.lastname}}</div>\n</div> ')}]);
\ No newline at end of file
+"use strict";angular.module("xos.contentProvider",["ngResource","ngCookies","ngLodash","xos.helpers","ui.router","xos.xos"]).config(["$stateProvider","$urlRouterProvider",function(n,e){n.state("list",{url:"/",template:"<content-provider-list></content-provider-list>"}).state("details",{url:"/contentProvider/:id",template:"<content-provider-detail></content-provider-detail>"}).state("cdn",{url:"/contentProvider/:id/cdn_prefix",template:"<content-provider-cdn></content-provider-cdn>"}).state("server",{url:"/contentProvider/:id/origin_server",template:"<content-provider-server></content-provider-server>"}).state("users",{url:"/contentProvider/:id/users",template:"<content-provider-users></content-provider-users>"})}]).config(["$httpProvider",function(n){n.interceptors.push("SetCSRFToken"),n.interceptors.push("NoHyperlinks")}]).service("ContentProvider",["$resource",function(n){return n("/hpcapi/contentproviders/:id/",{id:"@id"},{update:{method:"PUT"}})}]).service("ServiceProvider",["$resource",function(n){return n("/hpcapi/serviceproviders/:id/",{id:"@id"})}]).service("CdnPrefix",["$resource",function(n){return n("/hpcapi/cdnprefixs/:id/",{id:"@id"})}]).service("OriginServer",["$resource",function(n){return n("/hpcapi/originservers/:id/",{id:"@id"})}]).service("User",["$resource",function(n){return n("/xos/users/:id/",{id:"@id"})}]).directive("cpActions",["ContentProvider","$location",function(n,e){return{restrict:"E",scope:{id:"=id"},bindToController:!0,controllerAs:"vm",templateUrl:"templates/cp_actions.html",controller:function(){this.deleteCp=function(t){n["delete"]({id:t}).$promise.then(function(){e.url("/")})}}}}]).directive("contentProviderList",["ContentProvider","lodash",function(n,e){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_list.html",controller:function(){var t=this;n.query().$promise.then(function(n){t.contentProviderList=n})["catch"](function(n){throw new Error(n)}),this.deleteCp=function(s){n["delete"]({id:s}).$promise.then(function(){e.remove(t.contentProviderList,{id:s})})}}}}]).directive("contentProviderDetail",["ContentProvider","ServiceProvider","$stateParams","$location",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_detail.html",controller:function(){this.pageName="detail";var i=this;t.id?n.get({id:t.id}).$promise.then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}):i.cp=new n,e.query().$promise.then(function(n){i.sp=n}),this.saveContentProvider=function(n){var e,t=!1;n.id?e=n.$update():(t=!0,n.name=n.humanReadableName,e=n.$save()),e.then(function(n){i.result={status:1,msg:"Content Provider Saved"},t&&s.url("contentProvider/"+n.id+"/")})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]).directive("contentProviderCdn",["$stateParams","CdnPrefix","ContentProvider","lodash",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_cdn_prefix.html",controller:function(){var i=this;this.pageName="cdn",n.id&&t.get({id:n.id}).$promise.then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),e.query().$promise.then(function(e){i.prf=e,i.cp_prf=s.where(e,{contentProvider:parseInt(n.id)})})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),this.addPrefix=function(t){t.contentProvider=n.id;var s=new e(t);s.$save().then(function(n){i.cp_prf.push(n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})},this.removePrefix=function(n){n.$delete().then(function(){s.remove(i.cp_prf,n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]).directive("contentProviderServer",["$stateParams","OriginServer","ContentProvider","lodash",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_origin_server.html",controller:function(){this.pageName="server",this.protocols={http:"HTTP",rtmp:"RTMP",rtp:"RTP",shout:"SHOUTcast"};var i=this;n.id&&t.get({id:n.id}).$promise.then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),e.query({contentProvider:n.id}).$promise.then(function(n){i.cp_os=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),this.addOrigin=function(t){t.contentProvider=n.id;var s=new e(t);s.$save().then(function(n){i.cp_os.push(n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})},this.removeOrigin=function(n){n.$delete().then(function(){s.remove(i.cp_os,n)})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]).directive("contentProviderUsers",["$stateParams","ContentProvider","User","lodash",function(n,e,t,s){return{restrict:"E",controllerAs:"vm",scope:{},templateUrl:"templates/cp_user.html",controller:function(){var i=this;this.pageName="user",this.cp_users=[],n.id&&t.query().$promise.then(function(t){return i.users=t,e.get({id:n.id}).$promise}).then(function(n){return n.users=i.populateUser(n.users,i.users),n}).then(function(n){i.cp=n})["catch"](function(n){i.result={status:0,msg:n.data.detail}}),this.populateUser=function(n,e){for(var t=0;t<n.length;t++)n[t]=s.find(e,{id:n[t]});return n},this.addUserToCp=function(n){i.cp.users.push(n)},this.removeUserFromCp=function(n){s.remove(i.cp.users,n)},this.saveContentProvider=function(n){n.users=s.pluck(n.users,"id"),n.$update().then(function(n){i.cp.users=i.populateUser(n.users,i.users),i.result={status:1,msg:"Content Provider Saved"}})["catch"](function(n){i.result={status:0,msg:n.data.detail}})}}}}]),angular.module("xos.contentProvider").run(["$templateCache",function(n){n.put("templates/cp_actions.html",'<a href="#/" class="btn btn-default">\n <i class="icon icon-arrow-left"></i>Back\n</a>\n<a href="#/contentProvider/" class="btn btn-success">\n <i class="icon icon-plus"></i>Create\n</a>\n<a ng-click="vm.deleteCp(vm.id)" class="btn btn-danger">\n <i class="icon icon-remove"></i>Remove\n</a>'),n.put("templates/cp_cdn_prefix.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div class="span10">\n <div ng-repeat="item in vm.cp_prf" class="well">\n <div class="row-fluid">\n <div class="span4">\n {{item.humanReadableName}}\n </div>\n <div class="span6">\n <!-- TODO show the name instead that id -->\n {{item.defaultOriginServer}}\n </div>\n <div class="span2">\n <a ng-click="vm.removePrefix(item)" class="btn btn-danger pull-right">\n <i class="icon icon-remove"></i>\n </a>\n </div>\n </div>\n </div>\n <hr>\n <form ng-submit="vm.addPrefix(vm.new_prf)">\n <div class="row-fluid">\n <div class="span4">\n <label>Prefix</label>\n <input type="text" ng-model="vm.new_prf.prefix" required style="max-width: 90%">\n </div>\n <div class="span6">\n <label>Default Origin Server</label>\n <select ng-model="vm.new_prf.defaultOriginServer" style="max-width: 100%">\n <option ng-repeat="prf in vm.prf" ng-value="prf.id">{$ prf.humanReadableName $}</option>\n </select>\n </div>\n <div class="span2 text-right">\n <button class="btn btn-success margin-wells">\n <i class="icon icon-plus"></i>\n </button>\n </div>\n </div>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>'),n.put("templates/cp_detail.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div ng-show="vm.cp.id" class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div ng-class="{span10: vm.cp.id, span12: !vm.cp.id}">\n <!-- TODO hide form on not found -->\n <form ng-submit="vm.saveContentProvider(vm.cp)">\n <fieldset>\n <div class="row-fluid">\n <div class="span6">\n <label>Name:</label>\n <input type="text" ng-model="vm.cp.humanReadableName" required/>\n </div>\n <div class="span6">\n <label class="checkbox">\n <input type="checkbox" ng-model="vm.cp.enabled" /> Enabled\n </label>\n </div>\n </div>\n <div class="row-fluid">\n <div class="span12">\n <label>Description</label>\n <textarea style="width: 100%" ng-model="vm.cp.description"></textarea>\n </div>\n </div>\n <div class="row-fluid">\n <div class="span12">\n <label>Service provider</label>\n <select required ng-model="vm.cp.serviceProvider" ng-options="sp.id as sp.humanReadableName for sp in vm.sp"></select>\n </div>\n </div>\n <div class="row-fluid">\n <div class="span12">\n <button class="btn btn-success">\n <span ng-show="vm.cp.id">Save</span>\n <span ng-show="!vm.cp.id">Create</span>\n </button>\n </div>\n </div>\n </fieldset>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>'),n.put("templates/cp_list.html",'<table class="table table-striped" ng-show="vm.contentProviderList.length > 0">\n <thead>\n <tr>\n <th>\n Name\n </th>\n <th>Description</th>\n <th>Status</th>\n <th></th>\n </tr>\n </thead>\n <tr ng-repeat="item in vm.contentProviderList">\n <td>\n <a ui-sref="details({ id: item.id })">{$ item.humanReadableName $}</a>\n </td>\n <td>\n {$ item.description $}\n </td>\n <td>\n {$ item.enabled $}\n </td>\n <td class="text-right">\n <a ng-click="vm.deleteCp(item.id)" class="btn btn-danger"><i class="icon icon-remove"></i></a></td>\n </tr>\n</table>\n<div class="alert alert-error" ng-show="vm.contentProviderList.length == 0">\n No Content Provider defined\n</div>\n\n<div class="row">\n <div class="span12 text-right">\n <a class="btn btn-success"href="#/contentProvider/">Create</a>\n </div>\n</div>'),n.put("templates/cp_origin_server.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div class="span10">\n <div ng-repeat="item in vm.cp_os" class="well">\n <div class="row-fluid">\n <div class="span4">\n {{item.humanReadableName}}\n </div>\n <div class="span6">\n <!-- TODO shoe the name instead that url -->\n {{item.defaultOriginServer}}\n </div>\n <div class="span2">\n <a ng-click="vm.removeOrigin(item)" class="btn btn-danger pull-right">\n <i class="icon icon-remove"></i>\n </a>\n </div>\n </div>\n </div>\n <hr>\n <form ng-submit="vm.addOrigin(vm.new_os)">\n <div class="row-fluid">\n <div class="span4">\n <label>Protocol</label>\n <select ng-model="vm.new_os.protocol" ng-options="k as v for (k,v) in vm.protocols" style="max-width: 100%;"></select>\n </div>\n <div class="span6">\n <label>Url</label>\n <input type="text" ng-model="vm.new_os.url" required>\n </div>\n <div class="span2 text-right">\n <button class="btn btn-success margin-wells">\n <i class="icon icon-plus"></i>\n </button>\n </div>\n </div>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>'),n.put("templates/cp_side_nav.html",'<ul class="nav nav-list">\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'detail\'}" href="#/contentProvider/{$ vm.cp.id $}">Details</a>\n </li>\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'cdn\'}" href="#/contentProvider/{$ vm.cp.id $}/cdn_prefix">Cdn Prexix</a>\n </li>\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'server\'}" href="#/contentProvider/{$ vm.cp.id $}/origin_server">Origin Server</a>\n </li>\n <li>\n <a class="btn" ng-class="{\'btn-primary\': vm.pageName == \'user\'}" href="#/contentProvider/{$ vm.cp.id $}/users">Users</a>\n </li>\n</ul>'),n.put("templates/cp_user.html",'<div class="row-fluid">\n <div class="span6">\n <h1>{$ vm.cp.humanReadableName $}</h1>\n </div>\n <div class="span6 text-right">\n <cp-actions id="vm.cp.id"></cp-actions>\n </div>\n</div>\n<hr>\n<div class="row-fluid">\n <div class="span2">\n <div ng-include="\'templates/cp_side_nav.html\'"></div>\n </div>\n <div class="span10">\n <div ng-repeat="item in vm.cp.users" class="well">\n <div class="row-fluid">\n <div class="span3">\n {{item.firstname}}\n </div>\n <div class="span3">\n {{item.lastname}}\n </div>\n <div class="span4">\n {{item.email}}\n </div>\n <div class="span2">\n <a ng-click="vm.removeUserFromCp(item)" class="btn btn-danger pull-right">\n <i class="icon icon-remove"></i>\n </a>\n </div>\n </div>\n </div>\n <hr>\n <form ng-submit="vm.saveContentProvider(vm.cp)">\n <div class="row-fluid">\n <div class="span8">\n <label>Select user:</label>\n <select ng-model="vm.user" ng-options="u as u.username for u in vm.users" ng-change="vm.addUserToCp(vm.user)"></select>\n </div> \n <div class="span4 text-right">\n <button class="btn btn-success margin-wells">\n Save\n </button>\n </div>\n </div>\n </form>\n <div class="alert" ng-show="vm.result" ng-class="{\'alert-success\': vm.result.status === 1,\'alert-error\': vm.result.status === 0}">\n {$ vm.result.msg $}\n </div>\n </div>\n</div>')}]),angular.bootstrap(angular.element("#xosContentProvider"),["xos.contentProvider"]);
\ No newline at end of file
diff --git a/xos/core/xoslib/static/js/xosSampleView.js b/xos/core/xoslib/static/js/xosSampleView.js
new file mode 100644
index 0000000..69ec0bc
--- /dev/null
+++ b/xos/core/xoslib/static/js/xosSampleView.js
@@ -0,0 +1 @@
+"use strict";angular.module("xos.sampleView",["ngResource","ngCookies","ngLodash","ui.router","xos.helpers"]).config(["$stateProvider",function(s){s.state("user-list",{url:"/",template:"<users-list></users-list>"})}]).config(["$httpProvider",function(s){s.interceptors.push("NoHyperlinks")}]).directive("usersList",function(){return{restrict:"E",scope:{},bindToController:!0,controllerAs:"vm",templateUrl:"templates/users-list.tpl.html",controller:["XosApi",function(s){var e=this;s.User_List_GET().then(function(s){e.users=s})["catch"](function(s){throw new Error(s)})}]}}),angular.module("xos.sampleView").run(["$templateCache",function(s){s.put("templates/users-list.tpl.html",'<div class="row">\n <h1>Users List</h1>\n <p>This is only an example view.</p>\n</div>\n<div class="row">\n <div class="span4">Email</div>\n <div class="span4">First Name</div>\n <div class="span4">Last Name</div>\n</div> \n<div class="row" ng-repeat="user in vm.users">\n <div class="span4">{{user.email}}</div>\n <div class="span4">{{user.firstname}}</div>\n <div class="span4">{{user.lastname}}</div>\n</div> ')}]),angular.bootstrap(angular.element("#xosSampleView"),["xos.sampleView"]);
\ No newline at end of file