New resource generator for REST Apis
diff --git a/views/ngXosLib/generator-xos/app/templates/gulp/server.js b/views/ngXosLib/generator-xos/app/templates/gulp/server.js
index 33f8768..13659c3 100644
--- a/views/ngXosLib/generator-xos/app/templates/gulp/server.js
+++ b/views/ngXosLib/generator-xos/app/templates/gulp/server.js
@@ -50,7 +50,6 @@
server: {
baseDir: options.src,
routes: {
- '/api': options.api,
'/xosHelpers/src': options.helpers
},
middleware: function(req, res, next){
@@ -109,8 +108,7 @@
inject(
gulp.src([
options.tmp + '**/*.js',
- options.api + '*.js',
- options.helpers + '**/*.js'
+ options.helpers + '**/*.js' // todo add Babel here
])
.pipe(angularFilesort()),
{
diff --git a/views/ngXosLib/generator-xos/app/templates/src/index.html b/views/ngXosLib/generator-xos/app/templates/src/index.html
index b271d11..f546c21 100644
--- a/views/ngXosLib/generator-xos/app/templates/src/index.html
+++ b/views/ngXosLib/generator-xos/app/templates/src/index.html
@@ -4,7 +4,7 @@
<!-- inject:css -->
<!-- endinject -->
-<div ng-app="xos.<%= name %>" id="xos<%= fileName %>">
+<div ng-app="xos.<%= name %>" id="xos<%= fileName %>" class="container">
<div ui-view></div>
</div>
diff --git a/views/ngXosLib/generator-xos/app/templates/src/js/main.js b/views/ngXosLib/generator-xos/app/templates/src/js/main.js
index 4492f9c..9c0e259 100644
--- a/views/ngXosLib/generator-xos/app/templates/src/js/main.js
+++ b/views/ngXosLib/generator-xos/app/templates/src/js/main.js
@@ -24,9 +24,9 @@
bindToController: true,
controllerAs: 'vm',
templateUrl: 'templates/users-list.tpl.html',
- controller: function($http){
+ controller: function(Users){
// retrieving user list
- $http.get('/api/core/users')
+ Users.query().$promise
.then((users) => {
this.users = users;
})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js b/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
index 9618b27..df7ee4e 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Subscribers.js
@@ -7,23 +7,23 @@
angular.module('xos.helpers')
.service('Subscribers', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/', { subscriber_id: '@id'});
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/', { subscriber_id: '@id' });
})
.service('Subscriber-features', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/', { subscriber_id: '@id'});
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/', { subscriber_id: '@id' });
})
.service('Subscriber-features-uplink_speed', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/', { subscriber_id: '@id'});
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uplink_speed/', { subscriber_id: '@id' });
})
.service('Subscriber-features-downlink_speed', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/', { subscriber_id: '@id'});
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/downlink_speed/', { subscriber_id: '@id' });
})
.service('Subscriber-features-cdn', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/cdn/', { subscriber_id: '@id'});
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/cdn/', { subscriber_id: '@id' });
})
.service('Subscriber-features-uverse', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uverse/', { subscriber_id: '@id'});
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/uverse/', { subscriber_id: '@id' });
})
.service('Subscriber-features-status', function($resource){
- return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/status/', { subscriber_id: '@id'});
+ return $resource('/api/tenant/cord/subscriber/:subscriber_id/features/status/', { subscriber_id: '@id' });
})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js b/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
index 4e3f39a..7f1f9b5 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Truckroll.js
@@ -7,5 +7,5 @@
angular.module('xos.helpers')
.service('Truckroll-Collection', function($resource){
- return $resource('/api/tenant/truckroll/:truckroll_id/', { truckroll_id: '@id'});
+ return $resource('/api/tenant/truckroll/:truckroll_id/', { truckroll_id: '@id' });
})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/Users.js b/views/ngXosLib/xosHelpers/src/services/rest/Users.js
new file mode 100644
index 0000000..2e8f552
--- /dev/null
+++ b/views/ngXosLib/xosHelpers/src/services/rest/Users.js
@@ -0,0 +1,11 @@
+'use strict';
+
+/*
+ * List of the XOS users
+
+ */
+
+angular.module('xos.helpers')
+.service('Users', function($resource){
+ return $resource('/api/core/users/');
+})
diff --git a/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js b/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
index fc1cda2..e69f8ea 100644
--- a/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
+++ b/views/ngXosLib/xosHelpers/src/services/rest/vOLT.js
@@ -7,5 +7,5 @@
angular.module('xos.helpers')
.service('vOLT-Collection', function($resource){
- return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id'});
+ return $resource('/api/tenant/cord/volt/:volt_id/', { volt_id: '@id' });
})
diff --git a/views/ngXosLib/xosHelpers/src/xosHelpers.module.js b/views/ngXosLib/xosHelpers/src/xosHelpers.module.js
index c4b40f1..eb9222c 100644
--- a/views/ngXosLib/xosHelpers/src/xosHelpers.module.js
+++ b/views/ngXosLib/xosHelpers/src/xosHelpers.module.js
@@ -1,36 +1,33 @@
(function() {
- 'use strict';
- console.log('XOS Helpers Module')
- angular.module('bugSnag', []).factory('$exceptionHandler', function () {
- return function (exception, cause) {
- if( window.Bugsnag ){
- Bugsnag.notifyException(exception, {diagnostics:{cause: cause}});
- }
- else{
- console.error(exception, cause, exception.stack);
- }
- };
- });
+ 'use strict';
+ console.log('XOS Helpers Module')
+ angular.module('bugSnag', []).factory('$exceptionHandler', function () {
+ return function (exception, cause) {
+ if( window.Bugsnag ){
+ Bugsnag.notifyException(exception, {diagnostics: {cause: cause}});
+ }
+ else{
+ console.error(exception, cause, exception.stack);
+ }
+ };
+ });
- angular
- .module('xos.helpers',[
- 'ngCookies',
- 'ngResource',
- 'xos.xos',
- 'xos.hpcapi',
- 'xos.xoslib',
- 'bugSnag',
- 'xos.uiComponents'
- ])
- .config(config);
+ angular
+ .module('xos.helpers', [
+ 'ngCookies',
+ 'ngResource',
+ 'bugSnag',
+ 'xos.uiComponents'
+ ])
+ .config(config);
- function config($httpProvider, $interpolateProvider, $resourceProvider) {
- $httpProvider.interceptors.push('SetCSRFToken');
+ function config($httpProvider, $interpolateProvider, $resourceProvider) {
+ $httpProvider.interceptors.push('SetCSRFToken');
- $interpolateProvider.startSymbol('{$');
- $interpolateProvider.endSymbol('$}');
+ $interpolateProvider.startSymbol('{$');
+ $interpolateProvider.endSymbol('$}');
- // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html
- $resourceProvider.defaults.stripTrailingSlashes = false;
- }
+ // NOTE http://www.masnun.com/2013/09/18/django-rest-framework-angularjs-resource-trailing-slash-problem.html
+ $resourceProvider.defaults.stripTrailingSlashes = false;
+ }
})();
\ No newline at end of file
diff --git a/views/ngXosViews/sampleView/env/default.js b/views/ngXosViews/sampleView/env/default.js
index 5194914..2a5e8c0 100644
--- a/views/ngXosViews/sampleView/env/default.js
+++ b/views/ngXosViews/sampleView/env/default.js
@@ -8,6 +8,6 @@
module.exports = {
host: 'http://xos.dev:9999',
- xoscsrftoken: 'tfu7IRY4yS7gL1ofUH1sniQhuz7DTE5z',
- xossessionid: 'p3jagapanyfm7c1aqnkkahv85usgyaiu'
+ xoscsrftoken: 'NZ7lKKUcUUSYNeb7qpYKECL3MW3pKbSl',
+ xossessionid: 'kkhk28qo1dy6fc3v8lmzla6ry1dgm5xw'
};
diff --git a/views/ngXosViews/sampleView/gulp/server.js b/views/ngXosViews/sampleView/gulp/server.js
index 346bd79..13659c3 100644
--- a/views/ngXosViews/sampleView/gulp/server.js
+++ b/views/ngXosViews/sampleView/gulp/server.js
@@ -50,16 +50,14 @@
server: {
baseDir: options.src,
routes: {
- '/api': options.api,
'/xosHelpers/src': options.helpers
},
middleware: function(req, res, next){
- console.log(req.url);
if(
req.url.indexOf('/xos/') !== -1 ||
req.url.indexOf('/xoslib/') !== -1 ||
req.url.indexOf('/hpcapi/') !== -1 ||
- req.url.indexOf(`${conf.host}/api/`) !== -1
+ req.url.indexOf('/api/') !== -1
){
if(conf.xoscsrftoken && conf.xossessionid){
req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
@@ -110,8 +108,7 @@
inject(
gulp.src([
options.tmp + '**/*.js',
- options.api + '*.js',
- options.helpers + '**/*.js'
+ options.helpers + '**/*.js' // todo add Babel here
])
.pipe(angularFilesort()),
{
diff --git a/views/ngXosViews/sampleView/src/index.html b/views/ngXosViews/sampleView/src/index.html
index 3b7337a..d24bb88 100644
--- a/views/ngXosViews/sampleView/src/index.html
+++ b/views/ngXosViews/sampleView/src/index.html
@@ -6,7 +6,7 @@
<link rel="stylesheet" href="/css/main.css">
<!-- endinject -->
-<div ng-app="xos.sampleView" id="xosSampleView">
+<div ng-app="xos.sampleView" id="xosSampleView" class="container">
<div ui-view></div>
</div>
@@ -22,13 +22,17 @@
<!-- endbower --><!-- endjs -->
<!-- inject:js -->
<script src="/xosHelpers/src/xosHelpers.module.js"></script>
+<script src="/xosHelpers/src/services/rest/vSG.js"></script>
+<script src="/xosHelpers/src/services/rest/vOLT.js"></script>
+<script src="/xosHelpers/src/services/rest/Users.js"></script>
+<script src="/xosHelpers/src/services/rest/Truckroll.js"></script>
+<script src="/xosHelpers/src/services/rest/Subscribers.js"></script>
+<script src="/xosHelpers/src/services/rest/ONOS-Services.js"></script>
+<script src="/xosHelpers/src/services/rest/ONOS-Apps.js"></script>
<script src="/xosHelpers/src/ui_components/table/table.component.js"></script>
<script src="/xosHelpers/src/ui_components/ui-components.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/views/ngXosViews/sampleView/src/js/main.js b/views/ngXosViews/sampleView/src/js/main.js
index 185f09b..896ab77 100644
--- a/views/ngXosViews/sampleView/src/js/main.js
+++ b/views/ngXosViews/sampleView/src/js/main.js
@@ -24,9 +24,9 @@
bindToController: true,
controllerAs: 'vm',
templateUrl: 'templates/users-list.tpl.html',
- controller: function($http){
+ controller: function(Users){
// retrieving user list
- $http.get('/api/core/users')
+ Users.query().$promise
.then((users) => {
this.users = users;
})