Restored mcord topology
diff --git a/views/ngXosViews/mcordTopology/bower.json b/views/ngXosViews/mcordTopology/bower.json
index cb9b543..ed83aa4 100644
--- a/views/ngXosViews/mcordTopology/bower.json
+++ b/views/ngXosViews/mcordTopology/bower.json
@@ -24,7 +24,7 @@
"angular-ui-router": "0.2.15",
"angular-cookies": "1.4.7",
"angular-resource": "1.4.7",
- "ng-lodash": "0.3.0",
+ "lodash": "^3.10.1",
"bootstrap-css": "2.3.2"
}
}
diff --git a/views/ngXosViews/mcordTopology/env/default.js b/views/ngXosViews/mcordTopology/env/default.js
index df86216..acc8b5a 100644
--- a/views/ngXosViews/mcordTopology/env/default.js
+++ b/views/ngXosViews/mcordTopology/env/default.js
@@ -7,7 +7,7 @@
// (works only for local environment as both application are served on the same domain)
module.exports = {
- host: 'http://clnode067.clemson.cloudlab.us:9999/',
- xoscsrftoken: 'Pkq9PqoAsaMvrEiFAgxfw47IxTOtd0Y5',
- xossessionid: 'qa1t49qeecdehofjkndqvxik71iwzfvf'
+ host: 'http://xos.dev:9999/',
+ xoscsrftoken: 's1hmvk8d66UwxnRlDze64FrswXBeHjRD',
+ xossessionid: '4qgqwp46w5ln4q24vitc8f5gx6i66wyk'
};
diff --git a/views/ngXosViews/mcordTopology/gulp/build.js b/views/ngXosViews/mcordTopology/gulp/build.js
index 80ba4be..afc12dd 100644
--- a/views/ngXosViews/mcordTopology/gulp/build.js
+++ b/views/ngXosViews/mcordTopology/gulp/build.js
@@ -27,16 +27,22 @@
var mqpacker = require('css-mqpacker');
var csswring = require('csswring');
-var TEMPLATE_FOOTER = `
-angular.module('xos.mcordTopology').run(function($location){$location.path('/')});
-angular.bootstrap(angular.element('#xosMcordTopology'), ['xos.mcordTopology']);`;
+const TEMPLATE_FOOTER = `
+angular.module('xos.mcordTopology')
+.run(['$location', function(a){
+ a.path('/');
+}])
+`
module.exports = function(options){
// delete previous builded file
gulp.task('clean', function(){
return del(
- [options.dashboards + 'xosMcordTopology.html'],
+ [
+ options.dashboards + 'xosMcordTopology.html',
+ options.static + 'css/xosMcordTopology.css'
+ ],
{force: true}
);
});
@@ -48,6 +54,7 @@
mqpacker,
csswring
];
+
gulp.src([
`${options.css}**/*.css`,
`!${options.css}dev.css`
@@ -56,7 +63,8 @@
.pipe(gulp.dest(options.tmp + '/css/'));
});
- gulp.task('copyCss', ['css'], function(){
+ // copy css in correct folder
+ gulp.task('copyCss', ['wait'], function(){
return gulp.src([`${options.tmp}/css/*.css`])
.pipe(concat('xosMcordTopology.css'))
.pipe(gulp.dest(options.static + 'css/'))
@@ -72,7 +80,7 @@
.pipe(concat('xosMcordTopology.js'))
.pipe(concat.header('//Autogenerated, do not edit!!!\n'))
.pipe(concat.footer(TEMPLATE_FOOTER))
- // .pipe(uglify())
+ .pipe(uglify())
.pipe(gulp.dest(options.static + 'js/'));
});
@@ -81,19 +89,17 @@
return gulp.src('./src/templates/*.html')
.pipe(templateCache({
module: 'xos.mcordTopology',
- root: 'templates/',
- templateFooter: TEMPLATE_FOOTER
+ root: 'templates/'
}))
.pipe(gulp.dest(options.tmp));
});
// copy html index to Django Folder
- gulp.task('copyHtml', ['clean'], function(){
+ gulp.task('copyHtml', 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(
@@ -134,14 +140,24 @@
.pipe(eslint.failAfterError());
});
+ gulp.task('wait', function (cb) {
+ // setTimeout could be any async task
+ setTimeout(function () {
+ cb();
+ }, 1000);
+ });
+
gulp.task('build', function() {
runSequence(
+ 'clean',
'templates',
- 'copyCss',
'babel',
'scripts',
'wiredep',
- 'copyHtml'
+ 'css',
+ 'copyCss',
+ 'copyHtml',
+ 'cleanTmp'
);
});
};
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/gulp/server.js b/views/ngXosViews/mcordTopology/gulp/server.js
index 162bc97..167a5a9 100644
--- a/views/ngXosViews/mcordTopology/gulp/server.js
+++ b/views/ngXosViews/mcordTopology/gulp/server.js
@@ -9,6 +9,7 @@
var wiredep = require('wiredep').stream;
var httpProxy = require('http-proxy');
var del = require('del');
+var sass = require('gulp-sass');
const environment = process.env.NODE_ENV;
@@ -23,10 +24,6 @@
target: conf.host || 'http://0.0.0.0:9999'
});
-var traffic = httpProxy.createProxyServer({
- target: 'http://10.128.13.3'
-});
-
proxy.on('error', function(error, req, res) {
res.writeHead(500, {
@@ -53,14 +50,11 @@
server: {
baseDir: options.src,
routes: {
- '/api': options.api,
- '/xosHelpers/src': options.helpers
+ '/xos/core/xoslib/static/js/vendor': options.helpers
},
middleware: function(req, res, next){
if(
- req.url.indexOf('/xos/') !== -1 ||
- req.url.indexOf('/xoslib/') !== -1 ||
- req.url.indexOf('/hpcapi/') !== -1
+ req.url.indexOf('/api/') !== -1
){
if(conf.xoscsrftoken && conf.xossessionid){
req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
@@ -68,9 +62,9 @@
}
proxy.web(req, res);
}
- else if(req.url.indexOf('videoLocal') !== -1){
- console.log('traffic: ', req.url);
- traffic.web(req, res);
+ else if(req.url.indexOf('/videoLocal.txt') !== -1){
+ let a = (Math.random() * 10).toString();
+ res.end(a)
}
else{
next();
@@ -86,6 +80,19 @@
gulp.watch(options.src + '**/*.html', function(){
browserSync.reload();
});
+ gulp.watch(options.css + '**/*.css', function(){
+ browserSync.reload();
+ });
+ gulp.watch(`${options.sass}/**/*.scss`, ['sass'], function(){
+ browserSync.reload();
+ });
+ });
+
+ // compile sass
+ gulp.task('sass', function () {
+ return gulp.src(`${options.sass}/**/*.scss`)
+ .pipe(sass().on('error', sass.logError))
+ .pipe(gulp.dest(options.css));
});
// transpile js with sourceMaps
@@ -102,8 +109,7 @@
inject(
gulp.src([
options.tmp + '**/*.js',
- options.api + '*.js',
- options.helpers + '**/*.js'
+ options.helpers + 'ngXosHelpers.js'
])
.pipe(angularFilesort()),
{
@@ -145,6 +151,7 @@
gulp.task('serve', function() {
runSequence(
+ 'sass',
'bower',
'injectScript',
'injectCss',
diff --git a/views/ngXosViews/mcordTopology/gulpfile.js b/views/ngXosViews/mcordTopology/gulpfile.js
index a3523ee..08df554 100644
--- a/views/ngXosViews/mcordTopology/gulpfile.js
+++ b/views/ngXosViews/mcordTopology/gulpfile.js
@@ -6,11 +6,12 @@
var options = {
src: 'src/',
css: 'src/css/',
+ sass: 'src/sass/',
scripts: 'src/js/',
tmp: 'src/.tmp',
dist: 'dist/',
api: '../../ngXosLib/api/',
- helpers: '../../ngXosLib/xosHelpers/src/',
+ helpers: '../../../xos/core/xoslib/static/js/vendor/',
static: '../../../xos/core/xoslib/static/', // this is the django static folder
dashboards: '../../../xos/core/xoslib/dashboards/' // this is the django html folder
};
diff --git a/views/ngXosViews/mcordTopology/karma.conf.js b/views/ngXosViews/mcordTopology/karma.conf.js
index 83d3f63..4123be9 100644
--- a/views/ngXosViews/mcordTopology/karma.conf.js
+++ b/views/ngXosViews/mcordTopology/karma.conf.js
@@ -26,8 +26,8 @@
// list of files / patterns to load in the browser
files: bowerComponents.concat([
- '../../static/js/xosApi.js',
- '../../static/js/vendor/ngXosHelpers.js',
+ '../../../xos/core/xoslib/static/js/vendor/ngXosVendor.js',
+ '../../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js',
'src/js/**/*.js',
'spec/**/*.mock.js',
'spec/**/*.test.js',
diff --git a/views/ngXosViews/mcordTopology/package.json b/views/ngXosViews/mcordTopology/package.json
index 9826895..94bb877 100644
--- a/views/ngXosViews/mcordTopology/package.json
+++ b/views/ngXosViews/mcordTopology/package.json
@@ -8,9 +8,8 @@
"prebuild": "npm install && bower install",
"build": "gulp",
"test": "karma start",
- "lint": "eslint src/js/",
- "mocks": "easy-mocker -c ./mocks/mcord.conf.json -d ./mocks/data",
- "dev": "NODE_ENV=mock gulp serve"
+ "test:ci": "karma start --single-run",
+ "lint": "eslint src/js/"
},
"keywords": [
"XOS",
@@ -42,9 +41,20 @@
"gulp-postcss": "^6.0.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
+ "gulp-sass": "^2.2.0",
"gulp-uglify": "^1.4.2",
"http-proxy": "^1.12.0",
+ "ink-docstrap": "^0.5.2",
+ "jasmine-core": "~2.3.4",
+ "karma": "^0.13.14",
+ "karma-babel-preprocessor": "~5.2.2",
+ "karma-coverage": "^0.5.3",
+ "karma-jasmine": "~0.3.6",
+ "karma-mocha-reporter": "~1.1.1",
+ "karma-ng-html2js-preprocessor": "^0.2.0",
+ "karma-phantomjs-launcher": "~0.2.1",
"lodash": "^3.10.1",
+ "phantomjs": "^1.9.19",
"proxy-middleware": "^0.15.0",
"run-sequence": "^1.1.4",
"wiredep": "^3.0.0-beta",
diff --git a/views/ngXosViews/mcordTopology/src/css/main.css b/views/ngXosViews/mcordTopology/src/css/main.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/css/main.css
diff --git a/views/ngXosViews/mcordTopology/src/index.html b/views/ngXosViews/mcordTopology/src/index.html
index 691a869..d8985de 100644
--- a/views/ngXosViews/mcordTopology/src/index.html
+++ b/views/ngXosViews/mcordTopology/src/index.html
@@ -4,10 +4,11 @@
<!-- endbower --><!-- endcss -->
<!-- inject:css -->
<link rel="stylesheet" href="/css/dev.css">
+<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/css/mcord.css">
<!-- endinject -->
-<div ng-app="xos.mcordTopology" id="xosMcordTopology">
+<div ng-app="xos.mcordTopology" id="xosMcordTopology" class="container-fluid">
<div ui-view></div>
</div>
@@ -19,17 +20,11 @@
<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/lodash/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="/../../../xos/core/xoslib/static/js/vendor/ngXosHelpers.js"></script>
<script src="/.tmp/main.js"></script>
<script src="/.tmp/static.data.js"></script>
<script src="/.tmp/node_drawer.js"></script>
diff --git a/views/ngXosViews/mcordTopology/src/js/main.js b/views/ngXosViews/mcordTopology/src/js/main.js
index a479717..f926df9 100644
--- a/views/ngXosViews/mcordTopology/src/js/main.js
+++ b/views/ngXosViews/mcordTopology/src/js/main.js
@@ -3,7 +3,6 @@
angular.module('xos.mcordTopology', [
'ngResource',
'ngCookies',
- 'ngLodash',
'ui.router',
'xos.helpers'
])
@@ -17,12 +16,17 @@
.config(function($httpProvider){
$httpProvider.interceptors.push('NoHyperlinks');
})
+.factory('_', $window => $window._)
.service('Traffic', function($http, $q){
this.get = () => {
var deferred = $q.defer();
$http.get('videoLocal.txt')
.then(res => {
deferred.resolve(res.data);
+ })
+ .catch(e => {
+ console.log(e);
+ deferred.resolve(Math.random() * 10)
});
return deferred.promise;
}
@@ -34,7 +38,7 @@
bindToController: true,
controllerAs: 'vm',
template: '',
- controller: function($element, $interval, $rootScope, XosApi, lodash, TopologyElements, NodeDrawer, Traffic){
+ controller: function($element, $interval, $rootScope, _, $http, TopologyElements, NodeDrawer, Traffic){
const el = $element[0];
@@ -45,7 +49,7 @@
let trafficCorrection = 5;
const filterBBU = (instances) => {
- return lodash.filter(instances, i => i.name.indexOf('BBU') >= 0);
+ return _.filter(instances, i => i.name.indexOf('BBU') >= 0);
};
const filterOthers = (instances) => {
@@ -91,11 +95,13 @@
traffic = newTraffic;
- return XosApi.Instance_List_GET()
+ return $http.get('/api/core/xos/instances');
+ // return XosApi.Instance_List_GET()
})
.then((instances) => {
- addBbuNodes(filterBBU(instances));
- addOtherNodes(filterOthers(instances));
+
+ addBbuNodes(filterBBU(instances.data));
+ addOtherNodes(filterOthers(instances.data));
draw(svg, nodes, links);
})
@@ -127,9 +133,9 @@
const buildLinks = (links, nodes) => {
return links.map((l) => {
-
- let source = lodash.findIndex(nodes, {id: l.source});
- let target = lodash.findIndex(nodes, {id: l.target});
+ console.log(_.find);
+ let source = _.findIndex(nodes, {id: l.source});
+ let target = _.findIndex(nodes, {id: l.target});
// console.log(`link-${source}-${target}`, source, target);
return {
source: source,
@@ -144,7 +150,7 @@
// find fabric nodes and center horizontally
const positionFabricNodes = (nodes) => {
- return lodash.map(nodes, n => {
+ return _.map(nodes, n => {
if(n.type !== 'fabric'){
return n;
}
diff --git a/views/ngXosViews/mcordTopology/src/sass/main.scss b/views/ngXosViews/mcordTopology/src/sass/main.scss
new file mode 100644
index 0000000..78cf25b
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/sass/main.scss
@@ -0,0 +1,5 @@
+@import '../../../../style/sass/lib/_variables.scss';
+
+#xosMcordTopology {
+
+}
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/src/templates/users-list.tpl.html b/views/ngXosViews/mcordTopology/src/templates/users-list.tpl.html
new file mode 100644
index 0000000..fd8d208
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/templates/users-list.tpl.html
@@ -0,0 +1,16 @@
+<div class="row">
+ <div class="col-xs-12">
+ <h1>Users List</h1>
+ <p>This is only an example view.</p>
+ </div>
+</div>
+<div class="row">
+ <div class="col-xs-4">Email</div>
+ <div class="col-xs-4">First Name</div>
+ <div class="col-xs-4">Last Name</div>
+</div>
+<div class="row" ng-repeat="user in vm.users">
+ <div class="col-xs-4">{{user.email}}</div>
+ <div class="col-xs-4">{{user.firstname}}</div>
+ <div class="col-xs-4">{{user.lastname}}</div>
+</div>
\ No newline at end of file