Added mCord apps
diff --git a/views/ngXosViews/mcordTopology/.bowerrc b/views/ngXosViews/mcordTopology/.bowerrc
new file mode 100644
index 0000000..e491038
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/.bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory": "src/vendor/"
+}
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/.eslintrc b/views/ngXosViews/mcordTopology/.eslintrc
new file mode 100644
index 0000000..c852748
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/.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/views/ngXosViews/mcordTopology/.gitignore b/views/ngXosViews/mcordTopology/.gitignore
new file mode 100644
index 0000000..567aee4
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/.gitignore
@@ -0,0 +1,6 @@
+dist/
+src/vendor
+.tmp
+node_modules
+npm-debug.log
+dist/
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/bower.json b/views/ngXosViews/mcordTopology/bower.json
new file mode 100644
index 0000000..cb9b543
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/bower.json
@@ -0,0 +1,30 @@
+{
+ "name": "xos-mcordTopology",
+ "version": "0.0.0",
+ "authors": [
+ "Matteo Scandolo <teo@onlab.us>"
+ ],
+ "description": "The mcordTopology view",
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "static/js/vendor/",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "d3": "~3.5.16"
+ },
+ "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/views/ngXosViews/mcordTopology/env/default.js b/views/ngXosViews/mcordTopology/env/default.js
new file mode 100644
index 0000000..df86216
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/env/default.js
@@ -0,0 +1,13 @@
+// This is a default configuration for your development environment.
+// You can duplicate this configuration for any of your Backend Environments.
+// Different configurations are loaded setting a NODE_ENV variable that contain the config file name.
+// `NODE_ENV=local npm start`
+//
+// If xoscsrftoken or xossessionid are not specified the browser value are used
+// (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'
+};
diff --git a/views/ngXosViews/mcordTopology/env/mock.js b/views/ngXosViews/mcordTopology/env/mock.js
new file mode 100644
index 0000000..610ad78
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/env/mock.js
@@ -0,0 +1,5 @@
+module.exports = {
+ host: 'http://localhost:4000',
+ xoscsrftoken: 'Pkq9PqoAsaMvrEiFAgxfw47IxTOtd0Y5',
+ xossessionid: 'qa1t49qeecdehofjkndqvxik71iwzfvf'
+};
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/gulp/build.js b/views/ngXosViews/mcordTopology/gulp/build.js
new file mode 100644
index 0000000..fb2cccb
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/gulp/build.js
@@ -0,0 +1,119 @@
+'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.module('xos.mcordTopology').run(function($location){$location.path('/')});
+angular.bootstrap(angular.element('#xosMcordTopology'), ['xos.mcordTopology']);`;
+
+module.exports = function(options){
+
+ // delete previous builded file
+ gulp.task('clean', function(){
+ return del(
+ [options.dashboards + 'xosMcordTopology.html'],
+ {force: true}
+ );
+ });
+
+ // compile and minify scripts
+ gulp.task('scripts', function() {
+ return gulp.src([
+ options.tmp + '**/*.js'
+ ])
+ .pipe(ngAnnotate())
+ .pipe(angularFilesort())
+ .pipe(concat('xosMcordTopology.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.mcordTopology',
+ 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/xosMcordTopologyVendor.js',
+ options.static + 'js/xosMcordTopology.js'
+ ]),
+ {ignorePath: '/../../../xos/core/xoslib'}
+ )
+ )
+ .pipe(rename('xosMcordTopology.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('xosMcordTopologyVendor.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/views/ngXosViews/mcordTopology/gulp/server.js b/views/ngXosViews/mcordTopology/gulp/server.js
new file mode 100644
index 0000000..7605294
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/gulp/server.js
@@ -0,0 +1,146 @@
+'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');
+
+const environment = process.env.NODE_ENV;
+
+if (environment){
+ var conf = require(`../env/${environment}.js`);
+}
+else{
+ var conf = require('../env/default.js')
+}
+
+var proxy = httpProxy.createProxyServer({
+ target: conf.host || '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,
+ startPath: '#/',
+ 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
+ ){
+ if(conf.xoscsrftoken && conf.xossessionid){
+ req.headers.cookie = `xoscsrftoken=${conf.xoscsrftoken}; xossessionid=${conf.xossessionid}`;
+ req.headers['x-csrftoken'] = conf.xoscsrftoken;
+ }
+ 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']
+ );
+ });
+};
diff --git a/views/ngXosViews/mcordTopology/gulpfile.js b/views/ngXosViews/mcordTopology/gulpfile.js
new file mode 100644
index 0000000..b2cdab8
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/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: '../../../xos/core/xoslib/static/', // this is the django static folder
+ dashboards: '../../../xos/core/xoslib/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/views/ngXosViews/mcordTopology/karma.conf.js b/views/ngXosViews/mcordTopology/karma.conf.js
new file mode 100644
index 0000000..83d3f63
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/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/views/ngXosViews/mcordTopology/mocks/data/instances.json b/views/ngXosViews/mcordTopology/mocks/data/instances.json
new file mode 100644
index 0000000..572c775
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/mocks/data/instances.json
@@ -0,0 +1,56 @@
+[
+ {
+ "id": 1,
+ "humanReadableName": "BBU_service_instance-1",
+ "instance_id": "instance-00000001",
+ "instance_uuid": "42b75cb7-7205-4a68-9100-b2c1e3ea69b5",
+ "name": "BBU_service_instance-1",
+ "instance_name": "mysite_BBU-1",
+ "ip": "130.127.133.91"
+ },
+ {
+ "id": 2,
+ "humanReadableName": "BBU_service_instance-2",
+ "instance_id": "instance-00000002",
+ "instance_uuid": "42b75cb7-7205-4a68-9200-b2c2e3ea69b5",
+ "name": "BBU_service_instance-2",
+ "instance_name": "mysite_BBU-2",
+ "ip": "130.127.133.92"
+ },
+ {
+ "id": 5,
+ "humanReadableName": "vsg_service_instance-4",
+ "instance_id": "instance-00000004",
+ "instance_uuid": "44b75cb7-7405-4a68-9400-b4c4e3ea69b5",
+ "name": "vsg_service_instance-4",
+ "instance_name": "mysite_vsg-4",
+ "ip": "130.127.133.94"
+ },
+ {
+ "id": 6,
+ "humanReadableName": "MME_service_instance-4",
+ "instance_id": "instance-00000004",
+ "instance_uuid": "44b75cb7-7405-4a68-9400-b4c4e3ea69b5",
+ "name": "MME_service_instance-4",
+ "instance_name": "mysite_MME-4",
+ "ip": "130.127.133.94"
+ },
+ {
+ "id": 7,
+ "humanReadableName": "SGW_service_instance-4",
+ "instance_id": "instance-00000004",
+ "instance_uuid": "44b75cb7-7405-4a68-9400-b4c4e3ea69b5",
+ "name": "SGW_service_instance-4",
+ "instance_name": "mysite_SGW-4",
+ "ip": "130.127.133.94"
+ },
+ {
+ "id": 8,
+ "humanReadableName": "PGW_service_instance-4",
+ "instance_id": "instance-00000004",
+ "instance_uuid": "44b75cb7-7405-4a68-9400-b4c4e3ea69b5",
+ "name": "PGW_service_instance-4",
+ "instance_name": "mysite_PGW-4",
+ "ip": "130.127.133.94"
+ }
+]
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/mocks/mcord.conf.json b/views/ngXosViews/mcordTopology/mocks/mcord.conf.json
new file mode 100644
index 0000000..7246775
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/mocks/mcord.conf.json
@@ -0,0 +1,8 @@
+[
+ {
+ "url": "instances",
+ "base": "xos/",
+ "methods": ["GET", "POST"],
+ "param": "id"
+ }
+]
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/package.json b/views/ngXosViews/mcordTopology/package.json
new file mode 100644
index 0000000..b2606c2
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "xos-mcordTopology",
+ "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/",
+ "mocks": "easy-mocker -c ./mocks/mcord.conf.json -d ./mocks/data",
+ "dev": "NODE_ENV=mock gulp serve"
+ },
+ "keywords": [
+ "XOS",
+ "Angular",
+ "XOSlib"
+ ],
+ "author": "Matteo Scandolo",
+ "license": "MIT",
+ "dependencies": {},
+ "devDependencies": {
+ "browser-sync": "^2.9.11",
+ "del": "^2.0.2",
+ "easy-mocker": "^1.2.0",
+ "eslint": "^1.8.0",
+ "eslint-plugin-angular": "linkmesrl/eslint-plugin-angular",
+ "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-eslint": "^1.0.0",
+ "gulp-inject": "^3.0.0",
+ "gulp-minify-html": "^1.0.4",
+ "gulp-ng-annotate": "^1.1.0",
+ "gulp-rename": "^1.2.2",
+ "gulp-replace": "^0.5.4",
+ "gulp-uglify": "^1.4.2",
+ "http-proxy": "^1.12.0",
+ "lodash": "^3.10.1",
+ "proxy-middleware": "^0.15.0",
+ "run-sequence": "^1.1.4",
+ "wiredep": "^3.0.0-beta",
+ "wrench": "^1.5.8"
+ }
+}
diff --git a/views/ngXosViews/mcordTopology/spec/sample.test.js b/views/ngXosViews/mcordTopology/spec/sample.test.js
new file mode 100644
index 0000000..ecc17a0
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/spec/sample.test.js
@@ -0,0 +1,37 @@
+'use strict';
+
+describe('The User List', () => {
+
+ var scope, element, isolatedScope, httpBackend;
+
+ beforeEach(module('xos.mcordTopology'));
+ beforeEach(module('templates'));
+
+ beforeEach(inject(function($httpBackend, $compile, $rootScope){
+
+ httpBackend = $httpBackend;
+ // Setting up mock request
+ $httpBackend.expectGET('/xos/users/?no_hyperlinks=1').respond([
+ {
+ email: 'teo@onlab.us',
+ 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('teo@onlab.us');
+ expect(isolatedScope.users[0].firstname).toEqual('Matteo');
+ expect(isolatedScope.users[0].lastname).toEqual('Scandolo');
+ });
+
+});
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/src/css/dev.css b/views/ngXosViews/mcordTopology/src/css/dev.css
new file mode 100644
index 0000000..32d915d
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/css/dev.css
@@ -0,0 +1,7 @@
+#xosMcordTopology{
+ position: absolute;
+ /*top: 100px;
+ left: 200px;*/
+ width: 100%;
+ height: 100%;
+}
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/src/css/mcord.css b/views/ngXosViews/mcordTopology/src/css/mcord.css
new file mode 100644
index 0000000..68cca28
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/css/mcord.css
@@ -0,0 +1,62 @@
+[ui-view],
+m-cord-topology{
+ width: 100%;
+ height: 100%;
+ display: block;
+}
+
+line {
+ stroke: blue;
+ stroke-width: 1;
+}
+
+line.big{
+ stroke-width: 2;
+}
+
+circle,
+rect {
+ fill: #fff;
+ stroke-width: 1;
+}
+
+.fabric {
+ stroke: none;
+ fill: #123456;
+ fill-rule: evenodd;
+}
+
+.fabric-container {
+ fill: transparent;
+ stroke: #000;
+ stroke-width: 1;
+}
+
+.bbu {
+ stroke: black;
+ fill: #FF7F0E;
+}
+
+.rru {
+ stroke: #000;
+ fill: #FFBB78;
+}
+
+.rru-shadow {
+ fill: #FFBB78;
+ opacity: .4
+}
+
+.MME, .SGW, .PGW {
+ fill: purple;
+ stroke: #000;
+}
+
+.bbu text,
+.MME text,
+.SGW text,
+.PGW text {
+ font-size: 10px;
+ stroke-width: 0;
+ fill: #000;
+}
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/src/index.html b/views/ngXosViews/mcordTopology/src/index.html
new file mode 100644
index 0000000..691a869
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/index.html
@@ -0,0 +1,36 @@
+<!-- browserSync -->
+<!-- bower:css -->
+<link rel="stylesheet" href="vendor/bootstrap-css/css/bootstrap.css" />
+<!-- endbower --><!-- endcss -->
+<!-- inject:css -->
+<link rel="stylesheet" href="/css/dev.css">
+<link rel="stylesheet" href="/css/mcord.css">
+<!-- endinject -->
+
+<div ng-app="xos.mcordTopology" id="xosMcordTopology">
+ <div ui-view></div>
+</div>
+
+<!-- bower:js -->
+<script src="vendor/d3/d3.js"></script>
+<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>
+<script src="/.tmp/static.data.js"></script>
+<script src="/.tmp/node_drawer.js"></script>
+<!-- endinject -->
diff --git a/views/ngXosViews/mcordTopology/src/js/main.js b/views/ngXosViews/mcordTopology/src/js/main.js
new file mode 100644
index 0000000..bf57f1d
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/js/main.js
@@ -0,0 +1,296 @@
+'use strict';
+
+angular.module('xos.mcordTopology', [
+ 'ngResource',
+ 'ngCookies',
+ 'ngLodash',
+ 'ui.router',
+ 'xos.helpers'
+])
+.config(($stateProvider) => {
+ $stateProvider
+ .state('topology', {
+ url: '/',
+ template: '<m-cord-topology></m-cord-topology>'
+ });
+})
+.config(function($httpProvider){
+ $httpProvider.interceptors.push('NoHyperlinks');
+})
+.directive('mCordTopology', function(){
+ return {
+ restrict: 'E',
+ scope: {},
+ bindToController: true,
+ controllerAs: 'vm',
+ template: '',
+ controller: function($element, $interval, XosApi, lodash, TopologyElements, NodeDrawer){
+
+ const el = $element[0];
+
+ let nodes = [];
+ let links = [];
+
+ const filterBBU = (instances) => {
+ return lodash.filter(instances, i => i.name.indexOf('BBU') >= 0);
+ };
+
+ const filterOthers = (instances) => {
+ return lodash.filter(instances, i => {
+ return (i.name.indexOf('MME') >= 0)
+ || (i.name.indexOf('SGW') >= 0)
+ || (i.name.indexOf('PGW') >= 0)
+ });
+ };
+
+ // retrieving instances list
+ const getData = () => {
+
+ nodes = TopologyElements.nodes;
+ links = TopologyElements.links;
+
+ XosApi.Instance_List_GET()
+ .then((instances) => {
+ addBbuNodes(filterBBU(instances));
+ addOtherNodes(filterOthers(instances));
+
+ draw(svg, nodes, links);
+ })
+ .catch((e) => {
+ throw new Error(e);
+ });
+ };
+
+ const force = d3.layout.force();
+
+ // create svg elements
+ const svg = d3.select(el)
+ .append('svg')
+ .style('width', `${el.clientWidth}px`)
+ .style('height', `${el.clientHeight}px`);
+
+ const linkContainer = svg.append('g')
+ .attr({
+ class: 'link-container'
+ });
+
+ const nodeContainer = svg.append('g')
+ .attr({
+ class: 'node-container'
+ });
+
+ // replace human readable ids with d3 ids
+ // NOTE now ids are not manatined on update...
+ 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(`link-${source}-${target}`, source, target);
+ return {
+ source: source,
+ target: target,
+ value: 1,
+ id: `link-${source}-${target}`,
+ type: l.source.indexOf('fabric') >= 0 ? 'big':'small'
+ };
+
+ });
+ };
+
+ // find fabric nodes and center horizontally
+ const positionFabricNodes = (nodes) => {
+ return lodash.map(nodes, n => {
+ if(n.type !== 'fabric'){
+ return n;
+ }
+
+ n.x = n.x * hStep;
+ n.y = n.y * vStep;
+
+ return n;
+ });
+ };
+
+ const addBbuNodes = (instances) => {
+
+ // calculate bbu hStep
+ let bbuHStep = ((el.clientWidth / 2) / (instances.length + 1));
+
+ // create nodes
+ let bbuNodes = instances.map((n, i) => {
+ return {
+ type: 'bbu',
+ name: n.name,
+ id: `bbu-${n.id}`,
+ fixed: true,
+ y: vStep * 3,
+ x: bbuHStep * (i + 1)
+ };
+ });
+
+ // create links
+ let bbuLinks = bbuNodes.map(n => {
+ return {
+ source: n.id,
+ target: 'fabric2'
+ };
+ });
+
+ // fake RRU nodes and links
+ instances.forEach((n, i) => {
+ bbuNodes.push({
+ type: 'rru',
+ name: 'rru',
+ id: `rru-${n.id}`,
+ fixed: true,
+ y: vStep * 4,
+ x: bbuHStep * (i + 1)
+ });
+
+ bbuLinks.push({
+ source: `rru-${n.id}`,
+ target: `bbu-${n.id}`
+ });
+ })
+
+ nodes = nodes.concat(bbuNodes);
+
+
+ links = links.concat(bbuLinks);
+ };
+
+ // add MME, PGW, SGW nodes
+ const addOtherNodes = (instances) => {
+ let hStep = ((el.clientWidth / 2) / (instances.length + 1));
+
+ // create nodes
+ let otherNodes = instances.map((n, i) => {
+ return {
+ type: n.name.substring(0, 3),
+ name: n.name,
+ id: `${n.name.substring(0, 3)}-${n.id}`,
+ fixed: true,
+ y: vStep * 3,
+ x: (el.clientWidth / 2) + (hStep * (i + 1))
+ };
+ });
+
+ // create links
+ let otherLinks = otherNodes.map(n => {
+ return {
+ source: n.id,
+ target: 'fabric4'
+ };
+ });
+
+
+ nodes = nodes.concat(otherNodes);
+ links = links.concat(otherLinks);
+ }
+
+ let hStep, vStep;
+
+ hStep = el.clientWidth / 3;
+ vStep = el.clientHeight / 5;
+
+ const draw = (svg, nodes, links) => {
+
+ hStep = el.clientWidth / 3;
+ vStep = el.clientHeight / 5;
+
+ links = buildLinks(links, nodes);
+
+ nodes = positionFabricNodes(nodes);
+
+
+ // start force layout
+ force
+ .nodes(nodes)
+ .links(links)
+ .size([el.clientWidth, el.clientHeight])
+ .charge(-20)
+ .chargeDistance(200)
+ .linkDistance(80)
+ .linkStrength(0.1)
+ .start();
+
+
+ const linkContainer = d3.select('.link-container');
+ const nodeContainer = d3.select('.node-container');
+
+ NodeDrawer.drawFabricBox(nodeContainer, hStep, vStep);
+
+ // draw links
+ var link = linkContainer.selectAll('.link')
+ .data(links, d => d.id);
+
+ link.enter().append('line')
+ .attr({
+ // class: 'link',
+ id: d => d.id,
+ opacity: 0,
+ class: d => `link ${d.type}`
+ })
+ .transition()
+ .duration(1000)
+ // .delay((d, i) => 50 * i)
+ .attr({
+ opacity: 1
+ });
+
+ link.exit()
+ .remove();
+
+ //draw nodes
+ var node = nodeContainer.selectAll('.node')
+ .data(nodes, d => {
+ return d.id
+ });
+
+ // append a group for any new node
+ var enter = node.enter()
+ .append('g', d => d.interfaceCfgIdentifier)
+ .attr({
+ class: d => `${d.type} node`,
+ transform: d => `translate(${d.x}, ${d.y})`
+ });
+
+ // draw nodes
+ NodeDrawer.drawBbus(enter.filter('.bbu'))
+ NodeDrawer.drawRrus(enter.filter('.rru'))
+ NodeDrawer.drawFabric(enter.filter('.fabric'))
+ NodeDrawer.drawOthers(enter.filter(d => {
+ return (
+ d.type === 'MME' ||
+ d.type === 'SGW' ||
+ d.type === 'PGW'
+ )
+ }));
+
+ // remove nodes
+ var exit = node.exit();
+
+ NodeDrawer.removeElements(exit);
+
+ force.on('tick', function() {
+ link
+ .attr('x1', d => d.source.x )
+ .attr('y1', d => d.source.y )
+ .attr('x2', d => d.target.x )
+ .attr('y2', d => d.target.y );
+
+ node.attr('transform', (d) => `translate(${d.x},${d.y})`);
+ });
+ };
+
+ $interval(() => {
+ getData();
+ }, 5000);
+ getData();
+
+
+ }
+ };
+});
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/src/js/node_drawer.js b/views/ngXosViews/mcordTopology/src/js/node_drawer.js
new file mode 100644
index 0000000..14bdf99
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/js/node_drawer.js
@@ -0,0 +1,167 @@
+'use strict';
+
+angular.module('xos.mcordTopology')
+.service('NodeDrawer', function(TopologyElements){
+
+ const duration = 500;
+
+ let isFabricDrawed = false;
+
+ this.drawFabricBox = (svg, hStep, vStep) => {
+
+ if(isFabricDrawed){
+ return;
+ }
+
+ let fabric = svg.append('g')
+ .attr({
+ transform: `translate(${hStep - 25}, ${vStep - 25})`
+ });
+
+ fabric.append('rect')
+ .attr({
+ width: hStep + 50,
+ height: vStep + 50,
+ class: 'fabric-container'
+ });
+
+ fabric.append('text')
+ .text('Fabric')
+ .attr({
+ 'text-anchor': 'middle',
+ x: ((hStep + 50) / 2),
+ y: -10
+ });
+
+ isFabricDrawed = true;
+ };
+
+ this.drawBbus = (nodes) => {
+
+ nodes.append('circle')
+ .attr({
+ class: d => d.type,
+ r: 0,
+ opacity: 0
+ })
+ .transition()
+ .duration(duration)
+ // .delay((d, i) => i * (duration / 2))
+ .attr({
+ r: 15,
+ opacity: 1
+ });
+
+ nodes.append('text')
+ .attr({
+ 'text-anchor': 'start',
+ y: 17,
+ x: 17,
+ opacity: 0
+ })
+ .text(d => `BBU ${d.name.substr(d.name.length - 1, 1)}`)
+ .transition()
+ .duration(duration * 2)
+ .attr({
+ opacity: 1
+ });
+ };
+
+ this.drawRrus = (nodes) => {
+
+ nodes.append('circle')
+ .attr({
+ class: d => `${d.type}-shadow`,
+ r: 0,
+ opacity: 0
+ })
+ .transition()
+ .duration(duration * 2)
+ // .delay((d, i) => i * (duration / 2))
+ .attr({
+ r: 30,
+ opacity: 1
+ });
+
+ nodes.append('circle')
+ .attr({
+ class: d => d.type,
+ r: 0,
+ opacity: 0
+ })
+ .transition()
+ .duration(duration)
+ // .delay((d, i) => i * (duration / 2))
+ .attr({
+ r: 10,
+ opacity: 1
+ });
+ };
+
+ this.drawFabric = (nodes) => {
+ nodes
+ .append('rect')
+ .attr({
+ width: 30,
+ height: 30,
+ x: -15,
+ y: -15
+ });
+
+ nodes
+ .append('path')
+ .attr({
+ class: d => d.type,
+ opacity: 0,
+ d: () => TopologyElements.icons.switch,
+ transform: `translate(-22, -22), scale(0.4)`
+ })
+ .transition()
+ .duration(duration)
+ // .delay((d, i) => i * (duration / 2))
+ .attr({
+ opacity: 1
+ });
+ };
+
+ this.drawOthers = (nodes) => {
+ nodes.append('circle')
+ .attr({
+ class: d => d.type,
+ r: 0,
+ opacity: 0
+ })
+ .transition()
+ .duration(duration)
+ // .delay((d, i) => i * (duration / 2))
+ .attr({
+ r: 15,
+ opacity: 1
+ });
+
+ nodes.append('text')
+ .attr({
+ 'text-anchor': 'start',
+ y: 17,
+ x: 17,
+ opacity: 0
+ })
+ .text(d => d.type)
+ .transition()
+ .duration(duration * 2)
+ .attr({
+ opacity: 1
+ });
+
+ };
+
+ this.removeElements = (nodes) => {
+ nodes
+ .transition()
+ .duration(duration)
+ .attr({
+ opacity: 0
+ })
+ .remove();
+ };
+});
\ No newline at end of file
diff --git a/views/ngXosViews/mcordTopology/src/js/static.data.js b/views/ngXosViews/mcordTopology/src/js/static.data.js
new file mode 100644
index 0000000..c38239d
--- /dev/null
+++ b/views/ngXosViews/mcordTopology/src/js/static.data.js
@@ -0,0 +1,63 @@
+'use strict';
+
+angular.module('xos.mcordTopology')
+.constant('TopologyElements', {
+ nodes: [
+ {
+ id: 'fabric1',
+ type: 'fabric',
+ name: 'fabric1',
+ fixed: true,
+ x: 1,
+ y: 1
+ },
+ {
+ id: 'fabric2',
+ type: 'fabric',
+ name: 'fabric2',
+ fixed: true,
+ x: 1,
+ y: 2
+ },
+ {
+ id: 'fabric3',
+ type: 'fabric',
+ name: 'fabric3',
+ fixed: true,
+ x: 2,
+ y: 1
+ },
+ {
+ id: 'fabric4',
+ type: 'fabric',
+ name: 'fabric4',
+ fixed: true,
+ x: 2,
+ y: 2
+ }
+ ],
+ links: [
+ {
+ source: 'fabric1',
+ target: 'fabric2'
+ },
+ {
+ source: 'fabric1',
+ target: 'fabric4'
+ },
+ {
+ source: 'fabric3',
+ target: 'fabric4'
+ },
+ {
+ source: 'fabric3',
+ target: 'fabric2'
+ }
+ ],
+ icons: {
+ switch: `M10,20a10,10,0,0,1,10-10h70a10,10,0,0,1,10,10v70a10,10,
+ 0,0,1-10,10h-70a10,10,0,0,1-10-10zM60,26l12,0,0-8,18,13-18,13,0
+ -8-12,0zM60,60l12,0,0-8,18,13-18,13,0-8-12,0zM50,40l-12,0,0-8
+ -18,13,18,13,0-8,12,0zM50,74l-12,0,0-8-18,13,18,13,0-8,12,0z`,
+ }
+})
\ No newline at end of file