Redrawing service chain on subscriber select
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