Redrawing service chain on subscriber select
diff --git a/views/ngXosViews/diagnostic/.eslintrc b/views/ngXosViews/diagnostic/.eslintrc
index c6e1175..ef5b468 100644
--- a/views/ngXosViews/diagnostic/.eslintrc
+++ b/views/ngXosViews/diagnostic/.eslintrc
@@ -38,6 +38,7 @@
//"angular/ng_di": [0, "function or array"]
},
"globals" :{
- "angular": true
+ "angular": true,
+ "d3": true
}
}
\ No newline at end of file
diff --git a/views/ngXosViews/diagnostic/mocks/data/subscribers.json b/views/ngXosViews/diagnostic/mocks/data/subscribers.json
index 3642257..26cb9d3 100644
--- a/views/ngXosViews/diagnostic/mocks/data/subscribers.json
+++ b/views/ngXosViews/diagnostic/mocks/data/subscribers.json
@@ -1,6 +1,6 @@
[
{
- "humanReadableName":"My House",
+ "humanReadableName":"Marc Twain",
"id":1,
"created":"2016-02-17T19:36:04.167Z",
"updated":"2016-02-17T19:36:05.413Z",
@@ -16,5 +16,23 @@
"name":"My House",
"service_specific_attribute":"{\"url_filter_enable\": false, \"cdn_enable\": false, \"url_filter_level\": \"R\", \"users\": [{\"mac\": \"01:02:03:04:05:06\", \"level\": \"PG_13\", \"id\": 0, \"name\": \"Mom's PC\"}, {\"mac\": \"34:36:3B:C9:B6:A6\", \"id\": 1, \"name\": \"Jill's Laptop\", \"level\": \"PG_13\"}, {\"mac\": \"68:5B:35:9D:91:D5\", \"level\": \"PG_13\", \"id\": 2, \"name\": \"Jack's Laptop\"}, {\"id\": 3, \"mac\": \"90:E2:BA:82:F9:75\", \"name\": \"Dad's PC\", \"level\": \"PG_13\"}], \"firewall_enable\": false}",
"service_specific_id":"123"
+ },
+ {
+ "humanReadableName":"Jack London",
+ "id":2,
+ "created":"2016-02-17T19:36:04.167Z",
+ "updated":"2016-02-17T19:36:05.413Z",
+ "enacted":null,
+ "policed":null,
+ "backend_register":"{}",
+ "backend_status":"0 - Provisioning in progress",
+ "deleted":false,
+ "write_protect":false,
+ "lazy_blocked":false,
+ "no_sync":false,
+ "kind":"CordSubscriberRoot",
+ "name":"My House",
+ "service_specific_attribute":"{\"url_filter_enable\": false, \"cdn_enable\": false, \"url_filter_level\": \"R\", \"users\": [{\"mac\": \"01:02:03:04:05:06\", \"level\": \"PG_13\", \"id\": 0, \"name\": \"Mom's PC\"}, {\"mac\": \"34:36:3B:C9:B6:A6\", \"id\": 1, \"name\": \"Jill's Laptop\", \"level\": \"PG_13\"}, {\"mac\": \"68:5B:35:9D:91:D5\", \"level\": \"PG_13\", \"id\": 2, \"name\": \"Jack's Laptop\"}, {\"id\": 3, \"mac\": \"90:E2:BA:82:F9:75\", \"name\": \"Dad's PC\", \"level\": \"PG_13\"}], \"firewall_enable\": false}",
+ "service_specific_id":"123"
}
]
\ No newline at end of file
diff --git a/views/ngXosViews/diagnostic/mocks/data/tenants.json b/views/ngXosViews/diagnostic/mocks/data/tenants.json
index 3f7574c..16ede99 100644
--- a/views/ngXosViews/diagnostic/mocks/data/tenants.json
+++ b/views/ngXosViews/diagnostic/mocks/data/tenants.json
@@ -155,7 +155,7 @@
"subscriber_service": null,
"subscriber_tenant": null,
"subscriber_user": null,
- "subscriber_root": "http://clnode078.clemson.cloudlab.us:9999/xos/tenantroots/1/",
+ "subscriber_root": 1,
"service_specific_id": "123",
"service_specific_attribute": "{\"creator_id\": 1, \"c_tag\": \"432\", \"s_tag\": \"222\"}",
"connect_method": "na"
@@ -182,28 +182,5 @@
"service_specific_id": null,
"service_specific_attribute": "{\"creator_id\": 1, \"dependencies\": \"org.onosproject.openflow-base, org.onosproject.olt, org.ciena.onos.ext_notifier, org.ciena.onos.volt_event_publisher\", \"name\": \"vOLT_ONOS_app\", \"install_dependencies\": \"onos-ext-notifier-1.0-SNAPSHOT.oar, onos-ext-volt-event-publisher-1.0-SNAPSHOT.oar\"}",
"connect_method": "na"
- },
- {
- "humanReadableName": "vCPE-tenant-4",
- "id": 14,
- "created": "2016-02-17T19:36:04.650Z",
- "updated": "2016-02-17T20:55:18.115Z",
- "enacted": null,
- "policed": null,
- "backend_register": "{\"next_run\": 1455771318.072057, \"last_failure\": 1455742518.072061, \"last_success\": 1455737797.006782, \"exponent\": 871, \"failures\": 871}",
- "backend_status": "2 - Exception('defer object vCPE-tenant-4 due to waiting on instance.instance_name',)",
- "deleted": false,
- "write_protect": false,
- "lazy_blocked": false,
- "no_sync": false,
- "kind": "vCPE",
- "provider_service": 2,
- "subscriber_service": null,
- "subscriber_tenant": "3",
- "subscriber_user": null,
- "subscriber_root": null,
- "service_specific_id": null,
- "service_specific_attribute": "{\"instance_id\": 11, \"creator_id\": 1}",
- "connect_method": "na"
}
]
\ No newline at end of file
diff --git a/views/ngXosViews/diagnostic/src/css/serviceTopology.css b/views/ngXosViews/diagnostic/src/css/serviceTopology.css
index ebd17e5..4b88ccb 100644
--- a/views/ngXosViews/diagnostic/src/css/serviceTopology.css
+++ b/views/ngXosViews/diagnostic/src/css/serviceTopology.css
@@ -246,6 +246,12 @@
}
}
+/* MODALS */
+
+.modal.fade.in {
+ display: block;
+}
+
/* ANIMATIONS */
@keyframes bounceInRight {
diff --git a/views/ngXosViews/diagnostic/src/index.html b/views/ngXosViews/diagnostic/src/index.html
index c3f0623..eacbfe1 100644
--- a/views/ngXosViews/diagnostic/src/index.html
+++ b/views/ngXosViews/diagnostic/src/index.html
@@ -33,6 +33,7 @@
<script src="/api/ng-xos.js"></script>
<script src="/api/ng-hpcapi.js"></script>
<script src="/.tmp/main.js"></script>
+<script src="/.tmp/subscriber-modal.js"></script>
<script src="/.tmp/serviceTopologyHelper.js"></script>
<script src="/.tmp/serviceTopology.js"></script>
<script src="/.tmp/rest_services.js"></script>
diff --git a/views/ngXosViews/diagnostic/src/js/diagnostic.js b/views/ngXosViews/diagnostic/src/js/diagnostic.js
index 63ab420..c9787ba 100644
--- a/views/ngXosViews/diagnostic/src/js/diagnostic.js
+++ b/views/ngXosViews/diagnostic/src/js/diagnostic.js
@@ -7,7 +7,7 @@
restrict: 'E',
templateUrl: 'templates/diagnostic.tpl.html',
controllerAs: 'vm',
- controller: function(Subscribers, ServiceRelation){
+ controller: function(Subscribers, ServiceRelation, $rootScope){
this.loader = true;
this.error = false;
Subscribers.query().$promise
@@ -25,6 +25,13 @@
.finally(() => {
this.loader = false;
});
+
+ $rootScope.$on('subscriber.selected', (evt, subscriber) => {
+ ServiceRelation.getBySubscriber(subscriber)
+ .then((serviceChain) => {
+ this.serviceChain = serviceChain;
+ });
+ });
}
}
});
diff --git a/views/ngXosViews/diagnostic/src/js/logicTopology.js b/views/ngXosViews/diagnostic/src/js/logicTopology.js
index da2fef6..a3501dd 100644
--- a/views/ngXosViews/diagnostic/src/js/logicTopology.js
+++ b/views/ngXosViews/diagnostic/src/js/logicTopology.js
@@ -92,6 +92,17 @@
handleSvg($element[0]);
LogicTopologyHelper.setupTree(svg);
+ this.openSubscriberModal = () => {
+ this.subscriberModal = true;
+ $scope.$apply();
+ };
+
+
+ // listen for subscriber modal event
+ $rootScope.$on('subscriber.modal.open', () => {
+ this.openSubscriberModal();
+ });
+
}
};
});
diff --git a/views/ngXosViews/diagnostic/src/js/logicTopologyHelper.js b/views/ngXosViews/diagnostic/src/js/logicTopologyHelper.js
index 3be26c5..f860d9e 100644
--- a/views/ngXosViews/diagnostic/src/js/logicTopologyHelper.js
+++ b/views/ngXosViews/diagnostic/src/js/logicTopologyHelper.js
@@ -2,7 +2,7 @@
'use strict';
angular.module('xos.serviceTopology')
- .service('LogicTopologyHelper', function($window, $log, lodash, serviceTopologyConfig, NodeDrawer){
+ .service('LogicTopologyHelper', function($window, $log, $rootScope, lodash, serviceTopologyConfig, NodeDrawer){
var diagonal, nodes, links, i = 0, svgWidth, svgHeight, layout;
@@ -118,6 +118,12 @@
NodeDrawer.addPhisical(node.filter('.subscriber'));
NodeDrawer.addDevice(node.filter('.device'));
+ // add event listener to subscriber
+ node.filter('.subscriber')
+ .on('click', () => {
+ $rootScope.$emit('subscriber.modal.open');
+ });
+
//update nodes
// TODO if data change, only update them
// NodeDrawer.updateRack(node.filter('.rack'));
diff --git a/views/ngXosViews/diagnostic/src/js/subscriber-modal.js b/views/ngXosViews/diagnostic/src/js/subscriber-modal.js
new file mode 100644
index 0000000..f805c1a
--- /dev/null
+++ b/views/ngXosViews/diagnostic/src/js/subscriber-modal.js
@@ -0,0 +1,27 @@
+(function () {
+ 'use strict';
+ angular.module('xos.serviceTopology')
+ .directive('subscriberModal', function(){
+ return {
+ scope: {
+ subscribers: '=',
+ open: '='
+ },
+ bindToController: true,
+ restrict: 'E',
+ templateUrl: 'templates/subscriber-modal.tpl.html',
+ controllerAs: 'vm',
+ controller: function($rootScope){
+
+ this.close = () => {
+ this.open = false;
+ };
+
+ this.select = (subscriber) => {
+ $rootScope.$emit('subscriber.selected', subscriber);
+ this.close();
+ };
+ }
+ };
+ });
+})();
diff --git a/views/ngXosViews/diagnostic/src/templates/logicTopology.tpl.html b/views/ngXosViews/diagnostic/src/templates/logicTopology.tpl.html
index 9bd0551..0cff927 100644
--- a/views/ngXosViews/diagnostic/src/templates/logicTopology.tpl.html
+++ b/views/ngXosViews/diagnostic/src/templates/logicTopology.tpl.html
@@ -1,3 +1,4 @@
+<subscriber-modal open="vm.subscriberModal" subscribers="vm.subscribers"></subscriber-modal>
<div class="instances-stats animate" ng-hide="vm.hideInstanceStats">
<div class="row">
<div class="col-sm-3 col-sm-offset-8">
diff --git a/views/ngXosViews/diagnostic/src/templates/subscriber-modal.tpl.html b/views/ngXosViews/diagnostic/src/templates/subscriber-modal.tpl.html
new file mode 100644
index 0000000..9c005a3
--- /dev/null
+++ b/views/ngXosViews/diagnostic/src/templates/subscriber-modal.tpl.html
@@ -0,0 +1,17 @@
+<div class="modal fade" ng-class="{in: vm.open}" tabindex="-1" role="dialog">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button ng-click="vm.close()" type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
+ <h4 class="modal-title">Select a subscriber:</h4>
+ </div>
+ <div class="modal-body">
+ <select class="form-control" ng-options="s as s.humanReadableName for s in vm.subscribers" ng-model="vm.selected"></select>
+ </div>
+ <div class="modal-footer">
+ <button ng-click="vm.close()" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ <button ng-click="vm.select(vm.selected)" type="button" class="btn btn-primary">Select</button>
+ </div>
+ </div><!-- /.modal-content -->
+ </div><!-- /.modal-dialog -->
+</div><!-- /.modal -->
\ No newline at end of file