Matteo Scandolo | fcdbed3 | 2016-02-08 16:55:44 -0800 | [diff] [blame] | 1 | (function () { |
| 2 | 'use strict'; |
| 3 | |
| 4 | angular.module('xos.serviceTopology') |
| 5 | .directive('diagnostic', function(){ |
| 6 | return { |
| 7 | restrict: 'E', |
| 8 | templateUrl: 'templates/diagnostic.tpl.html', |
| 9 | controllerAs: 'vm', |
Matteo Scandolo | 388795a | 2016-02-22 09:57:55 -0800 | [diff] [blame^] | 10 | controller: function(Subscribers, ServiceRelation, $rootScope){ |
Matteo Scandolo | 07246ca | 2016-02-22 09:16:46 -0800 | [diff] [blame] | 11 | this.loader = true; |
| 12 | this.error = false; |
Matteo Scandolo | 5103148 | 2016-02-17 13:54:11 -0800 | [diff] [blame] | 13 | Subscribers.query().$promise |
Matteo Scandolo | fcdbed3 | 2016-02-08 16:55:44 -0800 | [diff] [blame] | 14 | .then((subscribers) => { |
| 15 | this.subscribers = subscribers; |
Matteo Scandolo | 77d8fa0 | 2016-02-16 17:43:00 -0800 | [diff] [blame] | 16 | return ServiceRelation.get(); |
Matteo Scandolo | fcdbed3 | 2016-02-08 16:55:44 -0800 | [diff] [blame] | 17 | }) |
| 18 | .then((serviceChain) => { |
| 19 | this.serviceChain = serviceChain; |
Matteo Scandolo | 07246ca | 2016-02-22 09:16:46 -0800 | [diff] [blame] | 20 | }) |
| 21 | .catch(e => { |
| 22 | throw new Error(e); |
| 23 | this.error = e; |
| 24 | }) |
| 25 | .finally(() => { |
| 26 | this.loader = false; |
Matteo Scandolo | fcdbed3 | 2016-02-08 16:55:44 -0800 | [diff] [blame] | 27 | }); |
Matteo Scandolo | 388795a | 2016-02-22 09:57:55 -0800 | [diff] [blame^] | 28 | |
| 29 | $rootScope.$on('subscriber.selected', (evt, subscriber) => { |
| 30 | ServiceRelation.getBySubscriber(subscriber) |
| 31 | .then((serviceChain) => { |
| 32 | this.serviceChain = serviceChain; |
| 33 | }); |
| 34 | }); |
Matteo Scandolo | fcdbed3 | 2016-02-08 16:55:44 -0800 | [diff] [blame] | 35 | } |
| 36 | } |
| 37 | }); |
| 38 | })(); |